📄 oadefin.cpp
字号:
// *****************************************************************************// *****************************************************************************// DefIn.cpp//// This file contains the member functions for the DefIn 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.189 $// $Date: 2005/07/29 13:42:23 $// $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaLefDef.h"#include "defzlib.hpp"BEGIN_LEFDEF_NAMESPACE// *****************************************************************************// DefIn::DefIn()//// This is the constructor for the DefIn class. // *****************************************************************************DefIn::DefIn(oaUtil::MsgAdapter &msgAdapterIn): LefDefIn(msgAdapterIn, defNS), dbuPerUUFromTech(100), scaleFactor(1.0), update(false), options(NULL), defInModHier(NULL), defInBlockage(NULL), defInComponent(NULL), defInGroup(NULL), defInNDR(NULL), defInNet(NULL), defInPin(NULL), defInRegion(NULL), defInRow(NULL), defInScanChain(NULL), defInStyle(NULL), defInTrack(NULL), defInVia(NULL){ initCallbacks();}// *****************************************************************************// DefIn::~DefIn()//// This is the destructor for the DefIn class. // *****************************************************************************DefIn::~DefIn(){ delete defInModHier; delete defInBlockage; delete defInComponent; delete defInGroup; delete defInNDR; delete defInNet; delete defInPin; delete defInRegion; delete defInRow; delete defInScanChain; delete defInStyle; delete defInTrack; delete defInVia;}// *****************************************************************************// DefIn::run()//// This function checks we have the minimum options to run, creates/checks the// library and techDB, creates the design, launches the parsing and saves// the design. The design data are generated by the callbacks routines// registered with the parser.// *****************************************************************************voidDefIn::run(DefInOptions *newOptions){ options = newOptions; options->checkArgs(); defrSetCommentChar(options->getCommentChar()); init(); initLib(); initTechDB(); for (oaUInt4 i = 0; i < options->getNumFileNames(); i++) { oaString fileName = options->getFileName(i); FILE *file; if (options->getNumFileNames() > 1) { msgAdapter.printInfo("Processing file: %s.\n", (const char*) fileName); msgAdapter.flush(); } if (fileName.isEmpty() || oaUtil::TranslatorOptions::useStdio(fileName)) { file = stdin; } else { file = (FILE*) defGZipOpen(fileName, "rb"); } if (!file) { throw LefDefError(cCannotOpenFile, (const char*) fileName); } parse(file); if (file != stdin) { defGZipClose(file); } } close();}voidDefIn::run(FILE *file, DefInOptions *newOptions){ options = newOptions; options->checkArgs(); defrSetCommentChar(options->getCommentChar()); init(); initLib(); initTechDB(); parse(file); close();}// *****************************************************************************// DefIn::initLib()//// This function opens or creates the specified library. If no library path// is specified, it will use the library name as its path. // *****************************************************************************voidDefIn::initLib(){ oaString libPath(options->getLibPath()); if (libPath.isEmpty()) { options->getLibName().get(libPath); } lib() = oaUtil::LibMgr::create(options->getLibName(), libPath, options->getLibOptions());}// *****************************************************************************// DefIn::initTechDB()//// This function searches and returns the techDB of the specified library.// If an external tech library is specified, it attaches it to this library.// *****************************************************************************voidDefIn::initTechDB(){ if (!oaTech::exists(lib())) { oaScalarName scalarTechLibName = options->getTechLibName(); oaString techLibName; if (scalarTechLibName.isEmpty()) { throw LefDefError(cTechLibNotSpecified); } oaLib *tLib = oaLib::find(scalarTechLibName); if (!tLib) { throw LefDefError(cTechNotFound, (const char*) techLibName); } scalarTechLibName.get(techLibName); setAttachedTechLibName(lib(), techLibName); } // Open the techDB and get dbuPerUU and default constraint group. tech() = oaTech::open(lib(), 'r'); defRules() = NULL; dbuPerUUFromTech = tech()->getDBUPerUU(oaViewType::get(oacMaskLayout));}// *****************************************************************************// DefIn::close()// // This function saves and closes the design, and closes the technology// database.// *****************************************************************************voidDefIn::close(){ getDefInComponent()->resolveMasters(); for (oaUInt4 i = 0; i < designs.getNumElements(); i++) { if (designs[i]->isModified()) { oaBox box; designs[i]->getTopBlock()->getBBox(box); designs[i]->save(); } designs[i]->close(); } LefDefIn::close();}// *****************************************************************************// DefIn::warn()// DefIn::error()//// These functions prepend the line number to the message and forward it// to the base message handlers.// *****************************************************************************voidDefIn::warn(LefDefMsgIds msgId, ...){ const char *format = LefDefMsgs[msgId - oavLefDefMsgIdStartValue]; if (format) { oaString newFormat(1024); va_list args; oaString buf(1024); newFormat.format("Line %i: %s\n", defrLineNumber(), format); va_start(args, msgId); buf.format(newFormat, args); va_end(args); msgAdapter.printWarning((const char*) buf); }}voidDefIn::error(LefDefMsgIds msgId, ...){ const char *format = LefDefMsgs[msgId - oavLefDefMsgIdStartValue]; if (format) { oaString newFormat(1024); va_list args; oaString buf(1024); newFormat.format("Line %i: %s\n", defrLineNumber(), format); va_start(args, msgId); buf.format(newFormat, args); va_end(args); msgAdapter.printError((const char*) buf); }}// *****************************************************************************// DefIn::getSimpleName()//// This function escapes any hierarchical characters in the string, and// initialises the scalarname with this "flattened" string.// *****************************************************************************voidDefIn::getSimpleName(const oaString &s, oaSimpleName &name){ // Skip the first character if the name starts with a hierDelimiter. const char *str = s; if (((const char *)s)[0] == getNS().getHierDelimiter()) { str = &((const char *) s)[1]; } name.init(getNS(), str); // Flatten if we're not creating a module hierarchy. if (!getOptions()->createModHier()) { oaString flatStr(name[0].getValue()); for (oaUInt4 i = 1; i < name.getNumMembers(); i++) { flatStr += "\\"; flatStr += getNS().getHierDelimiter(); flatStr += name[i].getValue(); } if (name.getType() == oacVectorBitNameType) { name.getVectorBit()->init(getNS(), flatStr, true); } else { name.init(getNS(), flatStr); } }}// *****************************************************************************// DefIn::getInst()//// This function searches an inst with the given name. If the instance is not// found an exception is thrown.// *****************************************************************************oaInst*DefIn::getInst(const oaSimpleName &instName){ oaInst *inst = oaInst::find(topBlock(), instName); if (!inst) { oaString instStr; instName.get(getNS(), instStr); throw LefDefError(cCannotFindInst, (const char*) instStr); } return inst;}// *****************************************************************************// DefIn::getTerm()//// This function searches a term for the specified name. If the terminal is not// found an exception is thrown.// *****************************************************************************oaBitTerm*DefIn::getTerm(const oaSimpleName &termName){ oaBitTerm *term = (oaBitTerm*) oaTerm::find(topBlock(), termName); if (!term) { oaString termStr; termName.get(getNS(), termStr); throw LefDefError(cCannotFindTerm, (const char*) termStr); } return term;}// *****************************************************************************// DefIn::getTerm()//// This function finds or creates the OA terminal for this DEF pin.// *****************************************************************************oaBitTerm*DefIn::getTerm(const oaSimpleName &pinName, const oaSimpleName &netName, oaTermType termType, oaSigType sigType, oaBlockDomainVisibility visibility){ oaBitTerm *term = (oaBitTerm*) oaTerm::find(topBlock(), pinName); if (term) { return term; } oaBitNet *net = getNet(netName, sigType, visibility); switch (pinName.getType()) { case oacScalarNameType: term = oaScalarTerm::create(net, *pinName.getScalar(), termType, visibility); break; case oacVectorBitNameType: term = oaBusTermBit::create((oaBusNetBit*) net, *pinName.getVectorBit(), termType, visibility); } return term;}// *****************************************************************************// DefIn::getInstTerm()//// This function searches an instTerm for the specified instance/terminal name.// If it does not exist, it creates it. The instTerm is returned.// *****************************************************************************oaInstTerm*DefIn::getInstTerm(oaInst *inst, const oaSimpleName &pinName, oaBitNet *net, oaRouteMethod routeMethod, oaBlockDomainVisibility visibility){ oaDesign *master = inst->getMaster(); oaTerm *term = NULL; oaInstTerm *instTerm = NULL; // Find the terminal if the master is bound. if (master) { term = oaTerm::find(master->getTopBlock(), pinName); if (!term) { oaString pinStr; oaString instStr; pinName.get(getNS(), pinStr); inst->getName(getNS(), instStr); error(cCannotFindInstTerm, (const char*) pinStr, (const char*) instStr); } } // Find existing instTerms. if (inst->usesTermPositions()) { if (term) { instTerm = oaInstTerm::find(inst, term->getPosition()); } } else { if (term) { instTerm = oaInstTerm::find(inst, term); } else { instTerm = oaInstTerm::find(inst, pinName); } } if (instTerm) { // Verify that existing instTerm has the same connectivity. if (net) { oaBitNet *instTermNet = (oaBitNet*) instTerm->getNet(); if (!instTermNet) { // || visibility == oacExcludeFromModuleDomain) { instTerm->addToNet(net); } else if (instTermNet != net && !net->getEquivalentNets().includes(instTermNet)) { oaString pinStr; oaString netStr; oaString net2Str;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -