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

📄 oaverilogleafmgr.cpp

📁 openaccess与verilog互相转化时所用的源代码
💻 CPP
字号:
// *****************************************************************************// *****************************************************************************// oaVerilogLeafMgr.cpp//// This file contains the implementation for the LeafMgr class.  The// LeafMgr class implements a manager for references to modules that// are external to the Verilog input file(s).  // // *****************************************************************************// 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 2003-2005 Cadence Design Systems, Inc.//			     All Rights	Reserved.////  $Author: shaun $//  $Revision: 1.26 $//  $Date: 2005/05/14 02:51:38 $//  $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaVerilogInPvt.h"BEGIN_VERILOG_NAMESPACE// *****************************************************************************// LeafMgr::LeafMgr()//// This is the constructor for the LeafMgr class.// *****************************************************************************LeafMgr::LeafMgr(OptionsIn  &optIn):   options(optIn){}// *****************************************************************************// LeafMgr::LeafMgr()//// This is the destructor for the LeafMgr class.// *****************************************************************************LeafMgr::~LeafMgr(){    reset();}// *****************************************************************************// LeafMgr::findLeaf()//// This function searches the given leaf library and view lists for a design// that matches the given cell name and returns the found design.// *****************************************************************************oaDesign*LeafMgr::findLeaf(const	oaScalarName	&cellName){    oaString	cellNameStr;    cellName.get(vns, cellNameStr);    oaDesign	*design;    if (leafMap.find(cellNameStr, design)) {	return design;    }    ModuleTypeEnum modType;    if (leafClass.find(cellNameStr, modType)) {	return NULL;    }    // Conduct a search for an oaCell with the same name as the given cell     // name. If the cell name is found in the library then, by definition, the    // cell is a leaf. However, there may not be an appropriate design    // associated with the leaf.    ScalarNameListIter	libIter;    ScalarNameListIter	viewIter;    for	(libIter = options.leafLibs.begin(); libIter != options.leafLibs.end();	 libIter++) {	oaLib   *lib = oaLib::find(**libIter);	if (!lib) {	    oaString	libNameStr;	    (*libIter)->get(vns, libNameStr);	    throw Error(LeafLibraryNotFound, NULL, (const char*) libNameStr);	}        oaBoolean   gotAccess = false;        if (lib->getAccessLevel() == oacNoLibAccessLevel) {            lib->getAccess(oacReadLibAccess);            gotAccess = true;        }	if (oaCell::find(lib, cellName)) {	    leafClass.insert(cellNameStr, ModuleUndefLeafType);	} else {            if (gotAccess) {                lib->releaseAccess();            }	    continue;	}        if (gotAccess) {            lib->releaseAccess();        }	for (viewIter =	options.leafViews.begin(); 	     viewIter != options.leafViews.end(); viewIter++) {	    design = oaDesign::find(**libIter, cellName, **viewIter);	    if (!design && oaDesign::exists(**libIter, cellName, **viewIter)) {		design = callbacks->openDesign(**libIter, cellName, **viewIter, 					       'r');	    }	    if (design)	{		leafMap.insert(cellNameStr, design);		leafClass.insert(cellNameStr, ModuleIncompleteLeafType);		oaModule    *top = design->getTopModule();		if (top) {		    oaIter<oaModTerm>	termIter(top->getTerms());		    while (oaModTerm *term = termIter.getNext()) {			if (term->getPosition() != oacNullIndex) {			    leafClass.insert(cellNameStr, ModuleLeafType);			    break;			}		    }		} else if (options.testTopWarning()) {		    oaString	libNameStr;		    oaString	viewNameStr;		    (*libIter)->get(vns, libNameStr);		    (*viewIter)->get(vns, viewNameStr);		    callbacks->warning(Error(NoTopModule, NULL, 				             (const char*) libNameStr,					     (const char*) cellNameStr,					     (const char*) viewNameStr));		}		return design;	    }	}	// Since a cell exists in the current library for the leaf, but no	// compatible view exists, create a design for the leaf using the	// default view name.	design = callbacks->openDesign(**libIter, cellName, 				       options.defLeafViewName,				       options.getViewType(), 'w');	oaModule    *module = oaModule::create(design, cellName);	design->setTopModule(module);	leafMap.insert(cellNameStr, design);	leafClass.insert(cellNameStr, ModuleIncompleteLeafType);	return design;    }    // Since there is no cell associated with the given name in any of the leaf    // libraries, this cell name does not represent a leaf.    leafClass.insert(cellNameStr, ModuleStubType);    return NULL;}// *****************************************************************************// LeafMgr::getType()//// This function returns the Verilog leaf type the module associated with the // given cell name. If the cell name is known to the manager and there is no // leaf associated with the given cell name then the type returned is // ModuleCellType. If the cell name is not known to the manager, // then the type returned is ModuleUnknownType.// *****************************************************************************ModuleTypeEnumLeafMgr::getType(const oaScalarName &cellName){    oaString	cellNameStr;    cellName.get(vns, cellNameStr);    ModuleTypeEnum leafType;    if (leafClass.find(cellNameStr, leafType)) {	return leafType;    }    return ModuleUnknownType;}// *****************************************************************************// LeafMgr::isLeaf()//// This function returns true if the given design is a leaf.// *****************************************************************************oaBooleanLeafMgr::isLeaf(const oaDesign	*design){    oaScalarName    cellName;    design->getCellName(cellName);    return isLeaf(cellName);}// *****************************************************************************// LeafMgr::isLeaf()//// This function returns true if the given cell name represents a leaf.// *****************************************************************************oaBooleanLeafMgr::isLeaf(const oaScalarName  &cellName){    oaString	cellNameStr;    cellName.get(vns, cellNameStr);    ModuleTypeEnum leafType;    if (leafClass.find(cellNameStr, leafType)) {	return leafType != ModuleCellType 	       && leafType != ModuleStubType	       && leafType != ModuleUnknownType;    }    return false;}// *****************************************************************************// LeafMgr::reset()//// This function clears the leaf information from the manager and resets it to// the initial state.// *****************************************************************************voidLeafMgr::reset(){    leafMap.clear();    leafClass.clear();}// *****************************************************************************// LeafMgr::setCallbacks()//// This function sets the callbacks for the leaf manager.// *****************************************************************************voidLeafMgr::setCallbacks(CallbacksIn   *init){    callbacks = init;}// *****************************************************************************// LeafMgr::setType()//// This function sets the leaf type of the module associated with the given cell// name. // *****************************************************************************voidLeafMgr::setType(const oaScalarName &cellName,		 ModuleTypeEnum	    leafType){    oaString	cellNameStr;    cellName.get(vns, cellNameStr);    leafClass.insert(cellNameStr, leafType);}END_VERILOG_NAMESPACE

⌨️ 快捷键说明

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