📄 oadefinmodhier.cpp
字号:
// *****************************************************************************// *****************************************************************************// DefInModHier.cpp//// This file contains the member functions specific to the DefInModHier// class.//// *****************************************************************************// Except as specified in the OpenAccess terms of use of Cadence or Silicon// Integration Initiative, this material may not be copied, modified,// re-published, uploaded, executed, or distributed in any way, in any medium,// in whole or in part, without prior written permission from Cadence.//// Copyright 2002-2005 Cadence Design Systems, Inc.// All Rights Reserved.//// $Author: nitters $// $Revision: 1.18 $// $Date: 2005/02/23 10:26:41 $// $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaLefDef.h"BEGIN_LEFDEF_NAMESPACE// *****************************************************************************// DefInModHier::DefInModHier()// DefInModHier::~DefInModHier()//// This is the constructor for the DefInModHier class.// *****************************************************************************DefInModHier::DefInModHier(DefIn &translator): defIn(translator){}DefInModHier::~DefInModHier(){}// *****************************************************************************// DefInModHier::getScalarInst()// DefInModHier::getVectorInst()//// These functions create instances in the module hierarchy, at the level// determined from the name of the instance.// *****************************************************************************oaModScalarInst*DefInModHier::getScalarInst(const oaScalarName &name, const oaScalarName &masterLibName, const oaScalarName &masterCellName, const oaScalarName &masterViewName){ oaModule *module = getParentModule(name); oaString localStr = name[name.getNumMembers() - 1].getValue(); oaNativeNS ns; oaScalarName localName(ns, localStr); oaModScalarInst *modInst = oaModScalarInst::find(module, localName); if (!modInst) { modInst = oaModScalarInst::create(module, masterLibName, masterCellName, masterViewName, localName); } return modInst;}oaModVectorInstBit*DefInModHier::getVectorInstBit(const oaVectorBitName &name, const oaScalarName &masterLibName, const oaScalarName &masterCellName, const oaScalarName &masterViewName){ oaScalarName baseName; name.getBaseName(baseName); oaModule *module = getParentModule(baseName); oaString localStr = name[name.getNumMembers() - 1].getValue(); oaNativeNS ns; oaUInt4 bit = name.getIndex(); oaScalarName localName(ns, localStr); oaModVectorInstBit *modInst = oaModVectorInstBit::find(module, localName, bit); if (!modInst) { modInst = oaModVectorInstBit::create(module, masterLibName, masterCellName, masterViewName, localName, bit); } return modInst;}// *****************************************************************************// DefInModHier::getScalarNet()// DefInModHier::getBusNetBit()//// These functions create a net in the module hierarchy, at the module level// specified by the name of the net.// *****************************************************************************oaModScalarNet*DefInModHier::getScalarNet(const oaScalarName &name, oaSigType sigType){ oaModule *module = getParentModule(name); oaString localStr = name[name.getNumMembers() - 1].getValue(); oaNativeNS ns; oaScalarName localName(ns, localStr); oaModScalarNet *modNet = oaModScalarNet::find(module, localName); if (!modNet) { modNet = oaModScalarNet::create(module, localName, sigType); } return modNet;}oaModBusNetBit*DefInModHier::getBusNetBit(const oaVectorBitName &name, oaSigType sigType){ oaScalarName baseName; name.getBaseName(baseName); oaModule *module = getParentModule(baseName); oaString localStr = name[name.getNumMembers() - 1].getValue(); oaUInt4 bit = name.getIndex(); oaNativeNS ns; oaScalarName localName(ns, localStr); oaModBusNetBit *modNet = oaModBusNetBit::find(module, localName, bit); if (!modNet) { modNet = oaModBusNetBit::create(module, localName, bit, sigType); } return modNet;}// *****************************************************************************// DefInModHier::getModule()//// These functions find or create the module hierarchy for the given baseName.// *****************************************************************************oaModule*DefInModHier::getModule(oaModule *parentModule, const oaScalarName &name, const oaSimpleName &instName){ oaModInst *modInst = oaModModuleInst::find(parentModule, instName); if (modInst) { return modInst->getMasterModule(); } // Create a new module and/or module instance. oaModule *module = oaModule::find(parentModule->getDesign(), name); if (!module) { module = oaModule::create(parentModule->getDesign(), name); } // Instantiate the new module. if (instName.getType() == oacScalarNameType) { modInst = oaModModuleScalarInst::create(parentModule, module, *instName.getScalar()); } else { oaScalarName baseName; oaUInt4 bit = instName.getVectorBit()->getIndex(); instName.getVectorBit()->getBaseName(baseName); modInst = oaModModuleVectorInstBit::create(parentModule, module, baseName, bit); } return module;}// *****************************************************************************// DefInModHier::getParentModule()//// This function gets the module with the name of the parent of this name.// A hierarchy of modules will be created based on the name members.// Note: name members strings are in the oaNativeNS.// *****************************************************************************oaModule*DefInModHier::getParentModule(const oaScalarName &name){ oaModule *parentModule = defIn.design()->getTopModule(); oaNativeNS ns; static oaString moduleStr; static oaScalarName moduleName; static oaSimpleName localName; static oaString nameMemStr; static oaString defNameMemStr; moduleStr = ""; for (oaUInt4 i = 0; i < name.getNumMembers() - 1; i++) { nameMemStr = name[i].getValue(); localName.init(ns, nameMemStr); localName.get(defIn.getNS(), defNameMemStr); // Escape bus characters in the module names. for (oaUInt4 j = 0; j < defNameMemStr.getLength(); j++) { if ((defNameMemStr[j] == defIn.getNS().getOpenBusChar() || defNameMemStr[j] == defIn.getNS().getCloseBusChar()) && defNameMemStr[j - 1] != '\\') { moduleStr += '\\'; } moduleStr += defNameMemStr[j]; } moduleName.init(defIn.getNS(), moduleStr); parentModule = getModule(parentModule, moduleName, localName); moduleStr += "_"; } return parentModule;}END_LEFDEF_NAMESPACE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -