⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oaverilogmodulecallbacksin.cpp

📁 openaccess与verilog互相转化时所用的源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	if (!design) {	    inst = getModInst(cellName, *instName.getScalar());	} else {	    inst = getInst(libName, cellName, viewName,			   *instName.getScalar());	}	break;      case oacVectorNameType:	if (!design) {	    inst = getModInst(cellName, *instName.getVector());	} else {	    inst = getInst(libName, cellName, viewName, 			   *instName.getVector());	}	break;      case oacVectorBitNameType: 	if (!design) {	    inst = getModInst(cellName, *instName.getVectorBit());	} else {	    inst = getInst(libName, cellName, viewName,			   *instName.getVectorBit());	}	break;      default:	{	    oaString	nameStr;	    Options::oaNameToString(instName, nameStr);	    throw Error(InvalidInstName, fileAndLine, (const char*) nameStr);	}	break;    }    if (!inst->isBound() && inst->isModModuleInst()) {	addStub(cellName, ((oaModModuleInst*) inst)->getHeader());    }    return inst;}// *****************************************************************************// ModuleCallbacksIn::getModInst()//// This function finds or creates a scalar inst from a given scalar name.// *****************************************************************************oaModModuleScalarInst*ModuleCallbacksIn::getModInst(const oaScalarName    &modName,			      const oaScalarName    &instName){    oaModModuleScalarInst *inst = oaModModuleScalarInst::find(currentModule, 							      instName);    if (!inst) {	inst = oaModModuleScalarInst::create(currentModule, modName, instName);    }    return inst;}// *****************************************************************************// ModuleCallbacksIn::getModInst()//// This function finds or creates a vector inst from a given vector name. // *****************************************************************************oaModModuleVectorInst*ModuleCallbacksIn::getModInst(const oaScalarName    &modName,			      const oaVectorName    &instName){    oaScalarName    baseName;    oaUInt4	    start;    oaUInt4	    stop;    oaInt4	    step;    instName.getBaseName(baseName);    getStartStopStep(instName, start, stop, step);    oaModModuleVectorInst   *inst;    inst = oaModModuleVectorInst::find(currentModule, baseName, start, stop);    if (!inst) {	inst = oaModModuleVectorInst::create(currentModule, modName, baseName, 					     start, stop);    }    return inst;}// *****************************************************************************// ModuleCallbacksIn::getModInst()//// This function finds or creates a vector inst from a given vector bit name.// *****************************************************************************oaModModuleVectorInstBit*ModuleCallbacksIn::getModInst(const oaScalarName    &modName,			      const oaVectorBitName &nameIn){    oaScalarName    baseName;    oaUInt4	    index;    nameIn.getBaseName(baseName);    index = nameIn.getIndex();    oaModModuleVectorInstBit	*inst;        inst = oaModModuleVectorInstBit::find(currentModule, baseName, index);    if (!inst) {	inst = oaModModuleVectorInstBit::create(currentModule, modName, 						baseName, index);    }    return inst;}// *****************************************************************************// ModuleCallbacksIn::init()//// This function initializes the callbacks. It must be called before parsing// takes place.// *****************************************************************************voidModuleCallbacksIn::init(){    CallbacksIn::init();    oaScalarName    cellName = options.getTempDesignName();    if (!options.getTopModuleName().isEmpty()) {	cellName.init(vns, options.getTopModuleName());    }    oaChar  mode = 'w';    if (oaDesign::exists(options.getLibName(), cellName, 			 options.getViewName())) {	mode = options.testOverwriteEnabled() ? 'w' : 'a';    }    currentDesign = openDesign(options.getLibName(), cellName,			       options.getViewName(), options.getViewType(),			       mode);    modifiedBy->set(currentDesign, true);    currentModuleIndex = 0;}// *****************************************************************************// ModuleCallbacksIn::isStub()//// This function returns true if the given moduleName is the name of a stub // module.// *****************************************************************************oaBooleanModuleCallbacksIn::isStub(const oaScalarName	&moduleName) const{    oaString	modNameStr;    HdrSet	*hdrs;    moduleName.get(vns, modNameStr);    return stubMap.find(modNameStr, hdrs);}// *****************************************************************************// ModuleCallbacksIn::moduleInstance()//// This function is called for each module instantiation in a module definition.// The instMasterN string describes the name of the instance master. The // parameter array is ignored in the base callback implementation, but it may// be used by a derived class to modify the creation of instances. The name of// the created instance is written to instNameOut.// *****************************************************************************voidModuleCallbacksIn::moduleInstance(const	oaString    &instMasterN,				  const	ParamList   &parameterL,				  const	oaName	    &instNameIn){    if (!isLeaf) {	getModInst(instMasterN, parameterL, instNameIn);	lastTerm = NULL;    }}// *****************************************************************************// ModuleCallbacksIn::pruneUnreferencedModules()//// This function removes all unreferenced modules (and modules that will become// unreferenced by the removal of the unreferenced module) from the design.// This function will not remove the top module from the design.// *****************************************************************************voidModuleCallbacksIn::pruneUnreferencedModules(){    oaIter<oaModule>	modIter(currentDesign->getModules());    while (oaModule *module = modIter.getNext()) {	setRefCount(module, 0);    }    modIter.reset();    setRefCount(currentDesign->getTopModule(), 1);    while (oaModule *module = modIter.getNext()) {	oaIter<oaModModuleInstHeader>	ihdrIter(module->getModuleInstHeaders());	while (oaModModuleInstHeader *ihdr = ihdrIter.getNext()) {	    oaModule	*master = ihdr->getMasterModule();	    if (master) {		setRefCount(master, getRefCount(master) + 1);	    }	}    }     oaBoolean	moduleDeleted;    do {	moduleDeleted = false;	oaIter<oaModule>    modIter(currentDesign->getModules());	while (oaModule *module = modIter.getNext()) {	    if (getRefCount(module) == 0) {		oaIter<oaModModuleInstHeader>	iter(module->getModuleInstHeaders());		while (oaModModuleInstHeader *ihdr = iter.getNext()) {		    oaModule	*master = ihdr->getMasterModule();		    if (master) {			setRefCount(master, getRefCount(master) - 1);		    }		}				module->destroy();		setRefCount(module, oacNullIndex);		moduleDeleted = true;	    }	}    } while (moduleDeleted);}// *****************************************************************************// ModuleCallbacksIn::saveBlackBoxes()//// This function saves all black-box modules and designs.  Black box modules are// saved under the same library and view names as the original module.// *****************************************************************************voidModuleCallbacksIn::saveBlackBoxes(){    detachEmptyModules();    oaIter<oaDesign>	designIter(oaDesign::getOpenDesigns());        while (oaDesign *design = designIter.getNext()) {	if (design->getTopModule() && isEmpty(design)) {	    cleanModuleInterface(design->getTopModule());	    design->save();	}    }}// *****************************************************************************// ModuleCallbacksIn::setCurrentDesign()//// This function sets the current working Design.  When embedding modules// into a single design, the current design should not change.  Therefore// this function explicitly does nothing.// *****************************************************************************voidModuleCallbacksIn::setCurrentDesign(oaDesign	*design){}// *****************************************************************************// ModuleCallbacksIn::selectUnreferencedModules()//// This function finds all modules that do not have references to them in the// current design and adds them to the given group.// *****************************************************************************voidModuleCallbacksIn::selectUnreferencedModules(oaGroup	*results){    oaIter<oaModule>	modIter(currentDesign->getModules());    while (oaModule *module = modIter.getNext()) {	if (getRefCount(module) == 0) {	    oaGroupMember::create(results, module);	}    }}// *****************************************************************************// ModuleCallbacksIn::selectDeepHierarchy()//// This function computes the depth of the hierarchy for each module in the // candidates group and returns the module(s) with the deepest hierarchy into// the results group.// *****************************************************************************voidModuleCallbacksIn::selectDeepHierarchy(oaGroup	*candidates){    oaIter<oaGroupMember>   candidateIter(candidates->getMembers());    oaUInt4		    maxDepth = 0;    while (oaGroupMember *member = candidateIter.getNext()) {	oaUInt4	depth = getModHierDepth((oaModule*) member->getObject());	if (depth > maxDepth) {	    maxDepth = depth;	}    }    candidateIter.reset();    while (oaGroupMember *member = candidateIter.getNext()) {	oaUInt4	depth = getModHierDepth((oaModule*) member->getObject());	if (depth < maxDepth) {	    member->destroy();	}    }}// *****************************************************************************// ModuleCallbacksIn::selectLatest()//// This function returns the module that appears latest in the Verilog input // from the set of modules in the candidates group.// *****************************************************************************oaModule*ModuleCallbacksIn::selectLatest(oaGroup	*candidates){    oaModule		    *latest = NULL;    oaIter<oaGroupMember>   memIter(candidates->getMembers());    while (oaGroupMember *mem = memIter.getNext()) {	oaModule    *module = (oaModule*) mem->getObject();	if (!latest || moduleIndex->get(latest) < moduleIndex->get(module)) {	    latest = module;	}    }    return latest;}// *****************************************************************************// ModuleCallbacksIn::setTopModule()//// This function sets the top module of the design. It assumes that all modules// have been created. If the top module name is given, then this method uses// the given module name as the top module. Otherwise, it detects the top module// using the ModuleCallbacksIn::detectTopModule method.// *****************************************************************************oaModule*ModuleCallbacksIn::setTopModule(){    oaModule	*top;    if (!options.getTopModuleName().isEmpty()) {	oaScalarName	cellName(vns, options.getTopModuleName());	top = oaModule::find(currentDesign, cellName);	if (!top) {	    throw Error(TopModuleNotDefined, NULL, 			(const char*) options.getTopModuleName());	}    } else {	top = detectTopModule();    }    if (top && !currentDesign->getTopModule()) {	currentDesign->setTopModule(top);    }    return top;}END_VERILOG_NAMESPACE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -