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

📄 oaverilogcallbacksin.cpp

📁 openaccess与verilog互相转化时所用的源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
// *****************************************************************************// *****************************************************************************// oaVerilogCallbacksIn.cpp//// This file contains the implementation of the CallbacksIn 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 istributed 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.143 $//  $Date: 2005/08/06 04:12:11 $//  $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaVerilogInPvt.h"BEGIN_VERILOG_NAMESPACEusing namespace	std;// *****************************************************************************// CallbacksIn::CallbacksIn()//// This is the constructor for the CallbacksIn class it takes a reference to// an Scanner and an oaVeriogInOption class as inputs.// *****************************************************************************CallbacksIn::CallbacksIn(const Scanner	&scanIn,			 OptionsIn	&optIn) :   options(optIn),    scanner(scanIn),    fileAndLine(NULL),    leafMgr(optIn),    currentLibrary(NULL),    currentDesign(NULL),    currentModule(NULL),    currentModuleType(ModuleUnknownType),    isLeaf(false),    lastTerm(NULL){    leafMgr.setCallbacks(this);    refCount = oaIntAppDef<oaModule>::get(OptionsIn::refCountName, 0, false);    bundleMember = oaInterPointerAppDef<oaModNet>::get(OptionsIn::bmemName, 						       false);    modifiedBy = oaBooleanAppDef<oaDesign>::get(OptionsIn::modifiedByName, 						false, false);    designCreatedBy = oaBooleanAppDef<oaDesign>::get(OptionsIn::createdByName, 						     false, false);    termCreatedBy = oaBooleanAppDef<oaModTerm>::get(OptionsIn::createdByName, 						    false, false);    netTermType = oaIntAppDef<oaModNet>::get(OptionsIn::termTypeName, 					     oacUnusedTermType, false);}// *****************************************************************************// CallbacksIn::~CallbacksIn()//// This is the destructor for the CallbacksIn class.// *****************************************************************************CallbacksIn::~CallbacksIn(){}// *****************************************************************************// CallbacksIn::all()//// This function is called at end of parsing.  An UnresolvedStubs exception is // thrown if there are unresolved stub modules and if the tolerate option is not// in effect. If the tolerate option is in effect then a warning message is // printed for unresolved stubs.  Finally, all open designs that are not leaf // cells are saved.// *****************************************************************************voidCallbacksIn::all(){    checkUnresolved();    oaIter<oaDesign>	designIter(oaDesign::getOpenDesigns());    while (oaDesign *design = designIter.getNext()) {	refCount->remove(design);	bundleMember->remove(design);	modifiedBy->remove(design);	designCreatedBy->remove(design);	oaIter<oaModule>    modIter(design->getModules());	if (!leafMgr.isLeaf(design)) {	    if (options.testBlackBoxEnabled() && isEmpty(design)		&& design->isModified()) {		design->save();	    }	}    }    closeAllDesigns();}// *****************************************************************************// CallbacksIn::alwaysConstruct()//// This function handles an ALWAYS block.// *****************************************************************************voidCallbacksIn::alwaysConstruct(){    notImplemented(AlwaysBlockImpl);}    // *****************************************************************************// CallbacksIn::appendToBundleName()//// This function appends a Value into a bundle net name. If the value is// numerical, the net name will be a bundle composed of the tie high and tie// low nets depending on the bit pattern of the numerical value.  The number of// bits in the bundle will be equal to the number of bits in the numerical// value.  If the value is a string, then the contents of the string will be// appended to the bundle.// *****************************************************************************voidCallbacksIn::appendToBundleName(const Value	&value,				oaBundleName	&netName){    if (value.isString()) {	oaName	valName;	Options::oaStringToName(value.getString(), valName);	switch (valName.getType()) {	  case oacBundleNameType:	    {		oaUInt4		i;		oaSimpleName	simple;		for (i = 0; i <	valName.getBundle()->getNumMembers(); i++) {		    simple = (*valName.getBundle())[i];		    netName.append(simple, simple.getRepeat());		}	    }	    break;	  case oacScalarNameType:	    netName.append(*valName.getScalar());	    break;	  case oacVectorNameType:	    netName.append(*valName.getVector());	    break;	  case oacVectorBitNameType:	    netName.append(*valName.getVectorBit());	    break;	}    } else {	Value	tmpVal = value;	oaUInt4	numBits	= value.getNumBits();	for (oaUInt4 i = 0; i <	numBits; i++) {	    if (tmpVal.testBit(numBits - i - 1)) {		netName.append(tieHighNet);	    } else {		netName.append(tieLowNet);	    }	}    }}// *****************************************************************************// CallbacksIn::attrInstance()//// This function reduces an attribute instance list to a single name/value pair.// The "spec" parameter is the first of the attribute instance list.  The // "speclist" parameter is the rest of the attribute instance list (which may be// empty).  IE: At least one attribute instance will be passed to this method.// *****************************************************************************voidCallbacksIn::attrInstance(const	oaParam	    &spec,			  const	ParamList   &speclist,			  oaParam	    &output){    output = spec;}// *****************************************************************************// CallbacksIn::beginModule()//// This function is called when a new module definition is found. The input// string "name" identifies the name of the new module.  This function creates// a new design for the given Verilog module if the module name is not the name// of a leaf cell.  The cell name of the design is the Verilog module name.// Additionally, a module of the same name as the Verilog module his created in// the design.  This module will also be set as the top module.// *****************************************************************************voidCallbacksIn::beginModule(const oaString	&name){    currentModuleName.init(vns, name);    oaDesign	*design = leafMgr.findLeaf(currentModuleName);    isLeaf = leafMgr.isLeaf(currentModuleName);        if (isLeaf) {	currentDesign = design;	currentModule = design->getTopModule();	currentModuleType = leafMgr.getType(currentModuleName);    } else {	const oaScalarName  &libName = options.getLibName();	const oaScalarName  &viewName = options.getViewName();	design = oaDesign::find(libName, currentModuleName, viewName);	if (design && designCreatedBy->get(design)) {	    design->purge();	    oaDesign::destroy(libName, currentModuleName, viewName);	    design = openDesign(libName, currentModuleName, viewName,				options.getViewType(), 'w');	} else if (oaDesign::exists(libName, currentModuleName, viewName)) {	    if (options.testOverwriteEnabled()) {		if (design) {		    design->purge();		}		oaDesign::destroy(libName, currentModuleName, viewName);		design = openDesign(libName, currentModuleName, viewName,				    options.getViewType(), 'w');	    } else {		oaString    libNameStr;		oaString    cellNameStr;		oaString    viewNameStr;		libName.get(vns, libNameStr);		currentModuleName.get(vns, cellNameStr);		viewName.get(vns, viewNameStr);		throw Error(DesignExists, NULL, (const char*) libNameStr,			    (const char*) cellNameStr,			    (const char*) viewNameStr);	    }	} else {	    design = openDesign(libName, currentModuleName, viewName,				options.getViewType(), 'w');	}	modifiedBy->set(design, true);	currentModule = oaModule::find(design, currentModuleName);	if (!currentModule) {	    currentModule = oaModule::create(design, currentModuleName);	    design->setTopModule(currentModule);	}	if (currentModule != design->getTopModule()) {	    throw Error(NotTopModule, fileAndLine, (const char*) name,			(const char*) name);	}	leafMgr.setType(currentModuleName, ModuleCellType);	currentModuleType = ModuleCellType;	currentDesign = design;    }     currentParams.clear();}// *****************************************************************************// CallbacksIn::binaryOpWithAttr()//// This function modifies the given binary operator "op" based on the supplied// attributes. The result should be stored in the "op" reference.// *****************************************************************************voidCallbacksIn::binaryOpWithAttr(oaString		&op, 			      const ParamList	&attr){}// *****************************************************************************// CallbacksIn::checkUnresolved()//// This function checks for unresolved modules in the input Verilog.  If // unresolved modules are found, then a message is printed and a list of // unresolved modules is printed.// *****************************************************************************voidCallbacksIn::checkUnresolved(){    oaUtil::HashTable<oaString, oaBoolean>  unresolved;    oaBoolean				    value;    oaIter<oaDesign>			    designIter(oaDesign::getOpenDesigns());    while (oaDesign *design = designIter.getNext()) {	if (!modifiedBy->get(design)) {	    continue;	}	oaIter<oaModInstHeader> ihdrIter(design->getModInstHeaders());	oaString		cellName;	while (oaModInstHeader *ihdr = ihdrIter.getNext()) {	    if (ihdr->getMaster() == NULL) {		ihdr->getCellName(vns, cellName);		if (!unresolved.find(cellName, value)) {		    unresolved.insert(cellName, true);		}	    }	}    }    if (unresolved.numEntries() > 0) {	oaString				    unresolvedNames;	oaString				    name;	oaUtil::HashTableIter<oaString, oaBoolean>  iter(&unresolved); 	while (iter.getNext(name, value)) {	    unresolvedNames += oaString("\n\t") + name;	    // Exceptions cannot hold messages larger than 1024 bytes.	    if (unresolvedNames.getLength() > 768) {		unresolvedNames += "\n\t[list truncated]";		break;	    }	}	unresolvedNames += "\n";	warning(Error(UnresolvedStubs, NULL, (const char*) unresolvedNames));    }}// *****************************************************************************// CallbacksIn::closeAllDesigns()//// This function closes all the designs that the reader opened.// *****************************************************************************voidCallbacksIn::closeAllDesigns(){    std::set<oaDesign*>::iterator   iter = openedDesigns.begin();    while (iter != openedDesigns.end()) {	oaDesign    *d = (*iter++);		if (options.testPurgeLeafsEnabled() || !leafMgr.isLeaf(d)) {	    d->close();	}    }    openedDesigns.clear();    if (options.testPurgeLeafsEnabled()) {	leafMgr.reset();    }}// *****************************************************************************// CallbacksIn::closeDesign()//// This function close the given design that the reader opened.  If the reader// did not open the given design and the purge arguement is false, this method // does nothing.  If the purge argument is true, then the design is purged// regardless of whether or not it was opened by the reader.// *****************************************************************************voidCallbacksIn::closeDesign(oaDesign   *design,			 oaBoolean  purge){    oaBoolean close = purge;    if (openedDesigns.find(design) != openedDesigns.end()) {	openedDesigns.erase(design);	close = true;    }    if (close) {	if (purge) {	    design->purge();	} else {	    design->close();	}    }}// *****************************************************************************// CallbacksIn::concatToPrimary()//// This function converts the values in a simple concatenation to a single// (primary) value.// *****************************************************************************void		CallbacksIn::concatToPrimary(ValueList	&concat,			     Value	&primary){    oaName		name;    oaBundleName	bundle;    ValueListIter	iter = concat.begin();    while (iter	!= concat.end()) {	appendToBundleName(**iter++, bundle);	name = bundle;    }    oaString	nameStr;    Options::oaNameToString(name, nameStr);    primary = nameStr;}// *****************************************************************************// CallbacksIn::configDeclaration()//// This function handles config declarations. The input string is the// configuration name.// *****************************************************************************voidCallbacksIn::configDeclaration(const oaString	&configID){    notImplemented(ConfigDeclImpl);}

⌨️ 快捷键说明

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