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

📄 oalefin.cpp

📁 openaccess读def,lef文件所用的源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// *****************************************************************************// *****************************************************************************// LefIn.cpp//// This	file contains the member functions for the LefIn 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.175 $//  $Date: 2005/07/29 13:42:23 $//  $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaLefDef.h"#include "zlib.h"#include "lefzlib.hpp"BEGIN_LEFDEF_NAMESPACE// *****************************************************************************// LefIn::LefIn()//// This	is the constructor for the LefIn class.	// *****************************************************************************LefIn::LefIn(oaUtil::MsgAdapter	&msgAdapterIn):   LefDefIn(msgAdapterIn, lefNS),    overlapLayer(""),    dbuPerUU(100),    legacy(NULL),    techMode('w'),    techWarn(true),    options(NULL),    lefInGeomPin(NULL),    lefInGeomObs(NULL),    lefInLayer(NULL),    lefInMacro(NULL),    lefInNDR(NULL),    lefInPin(NULL),    lefInSite(NULL),    lefInVia(NULL),    lefInViaRule(NULL){    initCallbacks();}// *****************************************************************************// LefIn::~LefIn()//// This	is the destructor for the LefIn	class. // *****************************************************************************LefIn::~LefIn(){    delete lefInGeomPin;    delete lefInGeomObs;    delete lefInLayer;    delete lefInMacro;    delete lefInNDR;    delete lefInPin;    delete lefInSite;    delete lefInVia;    delete lefInViaRule;}// *****************************************************************************// LefIn::run()//// This	function checks	the given options, opens the library, techDB and input// LEF file, and launches the CAT parser.// *****************************************************************************voidLefIn::run(LefInOptions	*newOptions){    options = newOptions;    options->checkArgs();        lefrSetCommentChar(options->getCommentChar());    init();    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*) lefGZipOpen(fileName, "rb");	}		if (!file) {	    throw LefDefError(cCannotOpenFile, (const char*) fileName);	}	parse(file);	if (file != stdin) {	    lefGZipClose(file);	}    }    createConstraints();    postProcessLayers();    close();}voidLefIn::run(FILE		*file,	   LefInOptions	*newOptions){    options = newOptions;    options->checkArgs();        lefrSetCommentChar(options->getCommentChar());    init();    parse(file);    createConstraints();    postProcessLayers();    close();}// *****************************************************************************// LefIn::addLayer()//// This function adds a layer to the layerArray for the constraint group.// *****************************************************************************voidLefIn::addLayer(oaLayerNum  layerNum){     for (oaUInt4 i(0); i < layerArray.getNumElements(); i++) {	if (layerArray[i] == layerNum) {	    return;	}    }    layerArray.append(layerNum);}// *****************************************************************************// LefIn::addViaDef()//// This function adds a DEFAULT via to the viaArray for the constraint group.// *****************************************************************************voidLefIn::addViaDef(oaViaDef   *viaDef){     for (oaUInt4 i(0); i < viaDefArray.getNumElements(); i++) {	if (viaDefArray[i] == viaDef) {	    return;	}    }        viaDefArray.append(viaDef);}// *****************************************************************************// LefIn::setOverlapLayer//// This	function sets the overlapLayer name// *****************************************************************************voidLefIn::setOverlapLayer(const oaString	&name){    overlapLayer = name;    if (getLegacyProp())	{	setProp(getLegacyProp(), cLefOverlapLayer, name);    }}// *****************************************************************************// LefIn::warn()// LefIn::error()//// These functions prepend the line number, and pass the message on to the base// message handlers.// *****************************************************************************voidLefIn::warn(LefDefMsgIds   msgId,	     ...){    const char	*format = LefDefMsgs[msgId - oavLefDefMsgIdStartValue];    oaString	newFormat(1024);    va_list	args;    oaString	buf(1024);    newFormat.format("Line %i: %s\n", lefrLineNumber(), format);    va_start(args, msgId);    buf.format(newFormat, args);    va_end(args);    msgAdapter.printWarning((const char*) buf);}voidLefIn::error(LefDefMsgIds   msgId,	     ...){    const char	*format = LefDefMsgs[msgId - oavLefDefMsgIdStartValue];    oaString	newFormat(1024);    va_list	args;    oaString	buf(1024);    newFormat.format("Line %i: %s\n", lefrLineNumber(), format);    va_start(args, msgId);    buf.format(newFormat, args);    va_end(args);    msgAdapter.printError((const char*) buf);}// *****************************************************************************// LefIn::parse()//// This	function opens the LEF file, and launches the parser.// Note: any static data used by the translator	classes	should be reset	here.// *****************************************************************************voidLefIn::parse(FILE   *file){    lefrReset();    if (lefrReadGZip(file, "", this))	{	throw LefDefError(cParseError);    }}// *****************************************************************************// LefIn::parseVersion()//// This	function checks	that the version of the	lef file is supported by// this	translator. It will return STOP_PARSE if not.// *****************************************************************************voidLefIn::parseVersion(double data){}// *****************************************************************************// LefIn::parseCaseSensitive()//// This	function checks	that the lef file is case sensitive. If	it is not// a warning message is	printed, since we only support case sensitive files.// *****************************************************************************voidLefIn::parseCaseSensitive(int data){    if (!data) {	throw LefDefError(cCaseSensitiveOnly);    }}// *****************************************************************************// LefIn::parseWireExtension()//// This	function stores	the LEF	wireExtentionAtPin value in a boolean property.// *****************************************************************************voidLefIn::parseWireExtension(const	char	*data){   setBooleanProp(getLegacyProp(), cLefNoWireExtention, strcmp(data, "ON") == 0);}// *****************************************************************************// LefIn::parseBusBitChars()//// This	function handles the 'BUSBITCHARS' LEF construct.// It gets the delimiter pair value, sets the LEF NameSpace with the new// bus bit characters and stores them in a legacy property for lef output.// In default update mode, nothing is stored in	the database.// *****************************************************************************voidLefIn::parseBusBitChars(const char  *data){    oaString	busBitChars(data);    if (busBitChars.getLength()	!= 2) {	throw LefDefError(cInvalidBusBitChars, data);    }    if (busBitChars[(oaUInt4) 0] != lefNS.getOpenBusChar()	|| busBitChars[(oaUInt4) 1] != lefNS.getCloseBusChar() ) {	lefNS.setOpenBusChar(busBitChars[(oaUInt4) 0]);	lefNS.setCloseBusChar(busBitChars[(oaUInt4) 1]);	setProp(getLegacyProp(), cLefBusBitChars, busBitChars);    }}// *****************************************************************************// LefIn::parseDividerChar()//// This	function handles the 'DIVIDERCHAR' LEF construct.// It gets the value, sets the LEF NameSpace with the new hierarchy delimiter// character and stores	it in a	legacy property	for lef	output.// In default update mode, nothing is stored in	the technology database.// *****************************************************************************voidLefIn::parseDividerChar(const char  *data){    oaString	dividerChar(data);    if (dividerChar.getLength()	!= 1) {	throw LefDefError(cInvalidHierChar, data);    }    if (dividerChar[(oaUInt4) 0] != lefNS.getHierDelimiter()) {	lefNS.setHierDelimiter(dividerChar[(oaUInt4) 0]);	setProp(getLegacyProp(), cLefDividerChar, dividerChar);    }}// *****************************************************************************// LefIn::parseUnits()//// This	function stores	the given unit factors in the technology database.// For the distance unit, there	is an API on oaTech. For all other units// the values are stored in SI units in	DB, so no conversion is	nessecary.// These DB unit values	are stored as properties for lef output	only.// *****************************************************************************voidLefIn::parseUnits(lefiUnits *data){    if (data->hasDatabase()) {	dbuPerUU = oaUInt4(data->databaseNumber());    }    if (techMode == 'w' || getOptions()->overwriteMode()) {	tech()->setDBUPerUU(oaViewType::get(oacMaskLayout), dbuPerUU);    }    oaUInt4 techDBU = tech()->getDBUPerUU(oaViewType::get(oacMaskLayout));    if (dbuPerUU != techDBU) {	error(cDifferentUnits, dbuPerUU, techDBU);	dbuPerUU = techDBU;    }    if (data->hasTime())	{	setProp(getLegacyProp(), cLefTimeUnit, oaInt4(data->time()));    }    if (data->hasCapacitance()) {	setProp(getLegacyProp(), cLefCapacitanceUnit, oaInt4(data->capacitance()));    }        if (data->hasResistance()) {	setProp(getLegacyProp(), cLefResistanceUnit, oaInt4(data->resistance()));    }    if (data->hasPower()) {	setProp(getLegacyProp(), cLefPowerUnit, oaInt4(data->power()));    }    if (data->hasCurrent()) {	setProp(getLegacyProp(), cLefCurrentUnit, oaInt4(data->current()));    }    if (data->hasVoltage()) {	setProp(getLegacyProp(), cLefVoltageUnit, oaInt4(data->voltage()));    }    if (data->hasFrequency()) {	setProp(getLegacyProp(), cLefFrequencyUnit, oaInt4(data->frequency()));    }}// *****************************************************************************// LefIn::parseManufacturingGrid()//// This	function handles the 'MANUFACTURINGGRID' LEF construct.// The manufacturing grid is temporarily stored	in a variable, to be used// when	creating layers.// *****************************************************************************voidLefIn::parseManufacturingGrid(double	data){    tech()->setDefaultManufacturingGrid(uuToDBU(data));}// *****************************************************************************// LefIn::parseUseMinSpacing()//// This	function handles the 'USEMINSPACING' LEF construct.// The useminspacing values are	stored as properties for lef output.// *****************************************************************************voidLefIn::parseUseMinSpacing(lefiUseMinSpacing *data){    if (strcmp(data->name(), "PIN") == 0) {	setBooleanProp(getLegacyProp(), cLefUseMinSpacingPin, data->value() != 0);	return;    }         // OBS    setBooleanProp(getLegacyProp(), cLefUseMinSpacingObs, data->value() != 0);}// *****************************************************************************// LefIn::parseClearanceMeasure()//// This	callback function handles the 'CLEARANCEMEASURE' LEF construct.// The default value is	Euclidian, so only need	to handle MaxXY// *****************************************************************************voidLefIn::parseClearanceMeasure(const char	*data){    if (strcmp(data, "MAXXY") == 0) {	tech()->setClearanceMeasure(oacMaxXYClearanceMeasure);    }}// *****************************************************************************// LefIn::parseProp()//// This	function creates a new property	definition (LefDefProp),// and adds it to the translators list of property definitions.// Library properties are instantiated directly.// *****************************************************************************voidLefIn::parseProp(lefiProp   *data){    oaString		name = data->propName();    oaString		typeName = data->propType();    LefDefObjectEnum	objectType(cLefDefLibrary);    if (typeName == "library") {	objectType = cLefDefLibrary;    	if (name == cTechLibName) {	    return;	}    } else if (typeName	== "layer") {	objectType = cLefDefLayer;    } else if (typeName	== "via") {	objectType = cLefDefVia;    } else if (typeName	== "viarule") {	objectType = cLefDefViaRule;    } else if (typeName	== "nondefaultrule") {	objectType = cLefDefNonDefaultRule;    } else if (typeName	== "macro") {	objectType = cLefDefMacro;    } else if (typeName	== "pin") {	objectType = cLefDefPin;    } else {	return;    }        LefDefProp	  *propDef;    switch(data->dataType()) {      case 'I':	if (data->hasRange()) {	    propDef = new LefDefIntRangeProp(name, objectType,					       oaInt4(data->left()),					       oaInt4(data->right()));	} else {	    propDef = new LefDefIntProp(name, objectType);	}	break;      case 'R':	if (data->hasRange()) {	    propDef = new LefDefRealRangeProp(name, objectType,						data->left(),						data->right());	} else {	    propDef = new LefDefRealProp(name, objectType);	}	break;      case 'S':      case 'Q':	{	    oaString	value("");	    propDef = new LefDefStringProp(name, objectType, value);	}	break;      default:	return;    }    addProp(propDef);    // If this definition is for a library, create a property.    if (objectType == cLefDefLibrary) {	oaString    val(data->string());	if(data->dataType() == 'I' || data->dataType() == 'R') {	    val.format(256, "%lg", data->number());	}    	oaDMData    *dmData;	if (oaDMData::exists(lib())) {	    dmData = oaDMData::open(lib(), 'a');	} else {	    dmData = oaDMData::open(lib(), 'w');	}	createProp(propDef, dmData, val);	dmData->save();	dmData->close();    }}// *****************************************************************************// LefIn::parseAntennaInput()//// This	callback function handles the 'ANTENNAINPUTGATEAREA' LEF construct// (Antenna Size construct from	5.4 LEF	version	only).// Global antenna values are stored as legacy properties for lef output	only.// *****************************************************************************voidLefIn::parseAntennaInput(double	  data){    if (data < 0.0) {	error(cAntennaAreaInputNegative, data);	return;    }    setProp(getLegacyProp(), cLefAntennaInputGateArea, data);}// *****************************************************************************

⌨️ 快捷键说明

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