/** * @name Native Check Create * @brief Determine whether a simulation object is native to FLI and create * a handle if it is */ GpiObjHdl* FliImpl::native_check_create(std::string &name, GpiObjHdl *parent) { GpiObjHdl *new_obj = NULL; std::string fq_name = parent->get_name() + "/" + name; std::vector<char> writable(fq_name.begin(), fq_name.end()); writable.push_back('\0'); mtiRegionIdT rgn_hdl; mtiSignalIdT sig_hdl; mtiVariableIdT var_hdl; LOG_DEBUG("Looking for child %s from %s", name.c_str(), parent->get_name_str()); if ((rgn_hdl = mti_FindRegion(&writable[0])) != NULL) { LOG_DEBUG("Found a region %s -> %p", &writable[0], rgn_hdl); new_obj = new FliRegionObjHdl(this, rgn_hdl); } else if ((sig_hdl = mti_FindSignal(&writable[0])) != NULL) { LOG_DEBUG("Found a signal %s -> %p", &writable[0], sig_hdl); new_obj = new FliSignalObjHdl(this, sig_hdl); } else if ((var_hdl = mti_FindVar(&writable[0])) != NULL) { LOG_DEBUG("Found a variable %s -> %p", &writable[0], var_hdl); new_obj = new FliVariableObjHdl(this, var_hdl); } if (NULL == new_obj) { LOG_DEBUG("Didn't find anything named %s", &writable[0]); return NULL; } new_obj->initialise(fq_name); return new_obj; }
/** * @name Native Check Create * @brief Determine whether a simulation object is native to FLI and create * a handle if it is */ GpiObjHdl* FliImpl::native_check_create(std::string &name, GpiObjHdl *parent) { bool search_rgn = false; bool search_sig = false; bool search_var = false; std::string fq_name = parent->get_fullname(); gpi_objtype_t obj_type = parent->get_type(); if (fq_name == "/") { fq_name += name; search_rgn = true; search_sig = true; search_var = true; } else if (obj_type == GPI_MODULE) { fq_name += "/" + name; search_rgn = true; search_sig = true; search_var = true; } else if (obj_type == GPI_STRUCTURE) { FliValueObjHdl *fli_obj = reinterpret_cast<FliValueObjHdl *>(parent); fq_name += "." + name; search_rgn = false; search_var = fli_obj->is_var(); search_sig = !search_var; } else { LOG_ERROR("FLI: Parent of type %d must be of type GPI_MODULE or GPI_STRUCTURE to have a child.", obj_type); return NULL; } LOG_DEBUG("Looking for child %s from %s", name.c_str(), parent->get_name_str()); std::vector<char> writable(fq_name.begin(), fq_name.end()); writable.push_back('\0'); HANDLE hdl = NULL; PLI_INT32 accType; PLI_INT32 accFullType; if (search_rgn && (hdl = mti_FindRegion(&writable[0])) != NULL) { accType = acc_fetch_type(hdl); accFullType = acc_fetch_fulltype(hdl); LOG_DEBUG("Found region %s -> %p", fq_name.c_str(), hdl); LOG_DEBUG(" Type: %d", accType); LOG_DEBUG(" Full Type: %d", accFullType); } else if (search_sig && (hdl = mti_FindSignal(&writable[0])) != NULL) { accType = acc_fetch_type(hdl); accFullType = acc_fetch_fulltype(hdl); LOG_DEBUG("Found a signal %s -> %p", fq_name.c_str(), hdl); LOG_DEBUG(" Type: %d", accType); LOG_DEBUG(" Full Type: %d", accFullType); } else if (search_var && (hdl = mti_FindVar(&writable[0])) != NULL) { accFullType = accType = mti_GetVarKind(static_cast<mtiVariableIdT>(hdl)); LOG_DEBUG("Found a variable %s -> %p", fq_name.c_str(), hdl); LOG_DEBUG(" Type: %d", accType); LOG_DEBUG(" Full Type: %d", accFullType); } else if (search_rgn){ mtiRegionIdT rgn; /* If not found, check to see if the name of a generate loop and create a pseudo-region */ for (rgn = mti_FirstLowerRegion(parent->get_handle<mtiRegionIdT>()); rgn != NULL; rgn = mti_NextRegion(rgn)) { if (acc_fetch_fulltype(rgn) == accForGenerate) { std::string rgn_name = mti_GetRegionName(static_cast<mtiRegionIdT>(rgn)); if (rgn_name.compare(0,name.length(),name) == 0) { FliObj *fli_obj = dynamic_cast<FliObj *>(parent); return create_gpi_obj_from_handle(parent->get_handle<HANDLE>(), name, fq_name, fli_obj->get_acc_type(), fli_obj->get_acc_full_type()); } } } } if (NULL == hdl) { LOG_DEBUG("Didn't find anything named %s", &writable[0]); return NULL; } /* Generate Loops have inconsistent behavior across fli. A "name" * without an index, i.e. dut.loop vs dut.loop(0), will attempt to map * to index 0, if index 0 exists. If it doesn't then it won't find anything. * * If this unique case is hit, we need to create the Pseudo-region, with the handle * being equivalent to the parent handle. */ if (accFullType == accForGenerate) { FliObj *fli_obj = dynamic_cast<FliObj *>(parent); return create_gpi_obj_from_handle(parent->get_handle<HANDLE>(), name, fq_name, fli_obj->get_acc_type(), fli_obj->get_acc_full_type()); } return create_gpi_obj_from_handle(hdl, name, fq_name, accType, accFullType); }