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

📄 oaverilogoptions.cpp

📁 openaccess与verilog互相转化时所用的源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// This function sets the name of the net to use for "tie-high" constant// assignments.  The name of the global module is prefixed to the net name.// *****************************************************************************voidOptions::setTieHighNet(const oaScalarName   &tieHighName){    tieHigh = tieHighName;}// *****************************************************************************// Options::setTieLowName()//// This function sets the name of the net to use for "tie-low" constant// assignments.  The name of the global module is prefixed to the net name.// *****************************************************************************voidOptions::setTieLowNet(const oaScalarName    &tieLowName){    tieLow = tieLowName;}// *****************************************************************************// Options::setTopModuleName()//// This function sets the name of the top module in an embedded module // hierarchy.// *****************************************************************************voidOptions::setTopModuleName(const	oaString    &value){    topModuleName = value;}// *****************************************************************************// OptionsIn::setViewName()//// This function sets the name of the view to use for all created modules.// *****************************************************************************voidOptions::setViewName(const oaString	&value){    oaNativeNS	ns;    viewName.init(ns, value);}// *****************************************************************************// Options::testFileAndLine()//// This function returns true if file and line numbers should be include with // messages associated with exceptions that are thrown.  Otherwise, it returns// false.// *****************************************************************************oaBooleanOptions::testFileAndLine() const {    return fileAndLine;}// *****************************************************************************// Options::testWarningsEnabled()//// This function returns true if printing warning messages is enabled.// *****************************************************************************oaBooleanOptions::testWarningsEnabled() const {    return warningsEnabled;}// *****************************************************************************// Options::stripGeneratedPrefix()//// This function strips the unique name formatting prefix from the beginning// of the input name string to restore the name string to its original form.// This function does nothing if the input name string does not have the unique// name formatting prefix or if the resulting name would be empty.// *****************************************************************************voidOptions::stripGeneratedPrefix(oaString	&nameStr){    if (nameStr.substr(uniqueNamePrefix) == 0) {	oaUInt4	    prefixLength = uniqueNamePrefix.getLength();	oaUInt4	    endOfPrefix = nameStr.substr("_", prefixLength);	oaString    newID(nameStr.getLength() - prefixLength);	oaUInt4	    j = 0;		for (oaUInt4 i = endOfPrefix + 1; i < nameStr.getLength(); i++) {	    newID[j++] = nameStr[i];	}	newID[j] = '\0';	if (newID.getLength() != 0) {	    nameStr = newID;	}    }}// *****************************************************************************// Options::makeUniqueNetName()//// These functions take a given net name and transforms it into a unique name// based on the number of bits in the input name.  By "unique" we mean that // there will be no net in the given module that has the transformed name. // Unique net names are generated when gaps are present in the Verilog module// port declarations list or when a narrow net is connected to a wide terminal.// The first function generates unique scalar names. The second function// generates bus names whose base name is unique.// *****************************************************************************voidOptions::makeUniqueNetName(const oaModule   *module,			   const oaName	    &nameIn,			   oaName	    &nameOut,			   oaUInt4	    seed){    oaString	nameInStr;    oaString	nameOutStr(256);    oaString	format;    if (nameIn.getType() != oacEmptyNameType) {	format = uniqueNameFmt;	nameOut = nameIn;	oaNameToString(nameIn, nameInStr);    } else {	format = unconnectedNameFmt;	nameOutStr.format((const char*) format, seed);	oaStringToName(nameOutStr, nameOut);    }    while ((nameOut.getType() == oacScalarNameType 	    && oaModBusNetDef::find(module, *nameOut.getScalar()))	   || oaModNet::find(module, nameOut)) {	nameOutStr.format((const char*) format, ++seed);	nameOutStr += nameInStr;	oaStringToName(nameOutStr, nameOut);    }}voidOptions::makeUniqueNetName(const oaModule	*module,			   const oaUInt4	numBits,			   oaName		&nameOut,			   oaUInt4		seed){    oaString	    buf(256);    oaScalarName    baseName;    oaVerilogNS	    ns;       do {	buf.format((const char*) unconnectedNameFmt, seed++);	baseName.init(ns, buf);    } while (oaModBusNetDef::find(module, baseName)	     || oaModNet::find(module, baseName));    nameOut = oaVectorName(baseName, numBits - 1, 0, 1);}// *****************************************************************************// Options::makeUniqueTermName()//// This function takes a given term name and transforms it into a unique name// based on the number of bits in the input name.  By "unique" we mean that // there will be no term in the given module that has the transformed name.// Since this method may copy the input name to the output name, the caller// must not pass the same name as both the input and the output.// *****************************************************************************voidOptions::makeUniqueTermName(const oaModule  *module,			    const oaName    &nameIn,			    oaName	    &nameOut,			    oaUInt4	    seed){    oaString	nameInStr;    oaString	nameOutStr(256);    oaString	format;    if (nameIn.getType() != oacEmptyNameType) {	format = uniqueNameFmt;	nameOut = nameIn;	oaNameToString(nameIn, nameInStr);    } else {	format = unconnectedNameFmt;	nameOutStr.format((const char*) format, seed);	oaStringToName(nameOutStr, nameOut);    }    while (oaModTerm::find(module, nameOut)) {	nameOutStr.format((const char*) format, ++seed);	nameOutStr += nameInStr;	oaStringToName(nameOutStr, nameOut);    }}// *****************************************************************************// Options::oaNameToString()//// This function converts an oaName to an oaString using the namespace stored in// the parser. Since we want to also support bundle names and since the// Verilog namespace in particular does not explicitly support bundle names, we// need to do our own conversion.// *****************************************************************************voidOptions::oaNameToString(const oaName	&name, 			oaString	&str){    switch (name.getType()) {      case oacBundleNameType:	{	    oaVerilogNS	    vns;	    oaBundleName    *bN = name.getBundle();	    oaString	    nameStr;	    str = "{";	    if (bN->getNumMembers() == 1 && (*bN)[0].getRepeat() == 1) {		(*bN)[0].get(vns, nameStr);	    } else {		char	    rptBuf[80];		oaString    memStr;		for (oaUInt4 i = 0; i < bN->getNumMembers(); i++) {		    (*bN)[i].get(vns, memStr);		    		    if ((*bN)[i].getRepeat() > 1) {			sprintf(rptBuf, "%d*", (*bN)[i].getRepeat());		    } else {			rptBuf[0] = '\0';		    }		    if (i > 0) {			nameStr += ",";		    }		    nameStr += rptBuf + memStr;		}	    }	    str += nameStr + "}";	}	break;      case oacEmptyNameType:	str = "";    	break;      default:	{	    oaVerilogNS   vns;	    name.get(vns, str);	}	break;    }}// *****************************************************************************// Options::oaStringToName()//// This function converts an oaString to an oaName using the namespace stored in// the parser. This function also supports bundle names which are not part of// the Verilog name space. If the input string is zero length, then this // method will leave the name untouched and it will return false. Otherwise// the string is copied to the name and this method returns true.// *****************************************************************************oaBooleanOptions::oaStringToName(const oaString	&str, 			oaName		&name){    oaVerilogNS	vns;    if (str.getLength() == 0) {	return false;    }    if (((const char*) str)[0] == '{') {	oaBundleName	bundle;	char		*buf = new char[str.getLength()];	strncpy(buf, ((const char*) str) + 1, str.getLength() - 2);	buf[str.getLength() - 2] = '\0';	for (char *tok = strtok(buf, ","); tok != NULL; tok = strtok(NULL, ",")) {	    oaUInt4 repeat = 1;	    char    *member = tok;	    if (isdigit(*member)) {		member = strchr(tok, '*');		*member = '\0';		member++;		repeat = (oaUInt4) atoi(tok);	    } 	    bundle.append(oaSimpleName(vns, member), repeat);	}    	name = bundle;	delete [] buf;    } else {	name.init(vns, str);    }    return true;}END_VERILOG_NAMESPACE

⌨️ 快捷键说明

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