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

📄 oalefdefbase.cpp

📁 openaccess读def,lef文件所用的源代码
💻 CPP
字号:
// *****************************************************************************// *****************************************************************************// LefDef.cpp//// This file contains the member functions specific to the LefDefBase,// LefDefIn, and LefDefOut classes and their supporting classes.//// *****************************************************************************// 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: sailajad $// $Revision: 1.28 $// $Date: 2005/07/17 01:55:02 $// $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaLefDef.h"BEGIN_LEFDEF_NAMESPACE// *****************************************************************************// LefDefBase::LefDefBase()//// This is the default constructor for the LefDefBase class.// *****************************************************************************LefDefBase::LefDefBase(oaUtil::MsgAdapter   &msgAdapterIn,		       oaLefNS		    &nsIn):   libObj(NULL),    techObj(NULL),    defRulesObj(NULL),    designObj(NULL),    blockObj(NULL),    ns(nsIn),    msgAdapter(msgAdapterIn),    props(NULL),    lastProp(NULL){}// *****************************************************************************// LefDefBase::~LefDefBase()//// This is the default destructor for the LefDefBase class. It flushes and// closes the log file if one has been opened and returns allocated memory back// to the system.// *****************************************************************************LefDefBase::~LefDefBase(){    clearProps();}// *****************************************************************************// LefDefBase::isValidLayer()//// This function returns true if the layer is a layer that would be output to// LEF. This should match the switch in oaLefOutLayer::write().// *****************************************************************************oaBooleanLefDefBase::isValidLayer(oaPhysicalLayer    *layer){    switch (layer->getMaterial()) {      case oacNImplantMaterial:      case oacPImplantMaterial:        //if (getOptions()->getVersion() < cLefDefVersion55) {	    //return false;	//}      case oacMetalMaterial:      case oacCutMaterial:      case oacNDiffMaterial:      case oacPDiffMaterial:      case oacPolyMaterial:	  return true;    }        return false;}    // *****************************************************************************// LefDefBase::getLayerNum()// LefDefBase::getLayer()//// These function return find the layer and layerNumber. If it is not found an// exception is thrown.// *****************************************************************************oaLayerNumLefDefBase::getLayerNum(const oaString &layerName){     return getLayer(layerName)->getNumber();}oaPhysicalLayer*LefDefBase::getLayer(const oaString &layerName){     oaPhysicalLayer *layer = oaPhysicalLayer::find(tech(), layerName);    if (!layer) {	throw LefDefError(cCannotFindLayer, (const char*) layerName);    }    return layer;}oaPhysicalLayer*LefDefBase::getLayer(oaLayerNum	layerNum){     oaPhysicalLayer *layer = oaPhysicalLayer::find(tech(), layerNum);    if (!layer) {	oaString    buf(64);	buf.format("%d", layerNum);		throw LefDefError(cCannotFindLayer, (const char*) buf);    }    return layer;}// *****************************************************************************// LefDefBase::getLayerWidth()// LefDefBase::getLayerExt()// LefDefBase::getLayerCutBox()//// This function returns the width and extension for the given layerNum in the// given constraint group.// *****************************************************************************oaUInt4LefDefBase::getLayerWidth(const	oaConstraintGroup   *cg,			  oaLayerNum		    layerNum){    oaValue *v = getConstraint(cg, oacMinWidth, layerNum);        if (v && v->getType() == oacIntValueType) {	return ((oaIntValue*) v)->get();    }    return 0;}oaUInt4LefDefBase::getLayerExt(const oaConstraintGroup	*cg,			oaLayerNum		layerNum){    oaValue *v = getConstraint(cg, oacMinWireExtension, layerNum);        if (v && v->getType() == oacIntValueType) {	return ((oaIntValue*) v)->get();    }    return getLayerWidth(cg, layerNum) / 2;}// *****************************************************************************// LefDefBase::getRules()//// This function searches the given object for a LEF constraint group// *****************************************************************************oaConstraintGroup*LefDefBase::getRules(const oaObject *object){    if (object->hasConstraintGroup()) {	oaConstraintGroup		*rules = object->getConstraintGroup();	oaIter<oaConstraintGroupMem>	cgmIter(rules->getMembers());	while (oaConstraintGroupMem    *cgm = cgmIter.getNext()) {	    if (cgm->getObject()->getType() == oacConstraintGroupHeaderType) {		return ((oaConstraintGroupHeader*) cgm->getObject())->getConstraintGroup();	    }	    if (cgm->getObject()->getType() == oacConstraintGroupType) {		return (oaConstraintGroup*) cgm->getObject();	    }	}    }    return NULL;}// *****************************************************************************// LefDefBase::getDefaultRules()//// This function searches the given object for a LEF constraint group// *****************************************************************************oaConstraintGroup*LefDefBase::getDefaultRules(){    if (!defRulesObj) {	defRulesObj = oaConstraintGroup::find(tech(), cLefDefaultRules);		if (!defRulesObj) {	    if (techObj->hasDefaultConstraintGroup()) {		defRulesObj = techObj->getDefaultConstraintGroup();	    } else {		throw LefDefError(cTechCannotFindConstraints, cLefDefaultRules);	    }	}    }    return defRulesObj;}// *****************************************************************************// LefDefBase::getConstraint()//// This function gets the constraint for the given type, on the given layerNum,// returning its value if it exists.// *****************************************************************************oaValue*LefDefBase::getConstraint(const	oaConstraintGroup   *group,			  oaSimpleConstraintType    type,			  oaConstraintParamArray    *params,			  oaBoolean		    foundry,			  oaBoolean		    hard){    oaSimpleConstraintDef *def = oaSimpleConstraintDef::get(type);    oaConstraint    *c = oaSimpleConstraint::find(group, def, hard);    if ((!c || c->isHard() != hard) && foundry && group != getFoundryRules()) {	c = oaSimpleConstraint::find(getFoundryRules(), def, hard);    }    if (c && c->isHard() == hard) {	if (params && c->hasParams()) {	    c->getParams(*params);	}	return c->getValue();    }    return NULL;}oaValue*LefDefBase::getConstraint(const	oaConstraintGroup   *group,			  oaLayerConstraintType	    type,			  oaLayerNum		    layerNum,			  oaConstraintParamArray    *params,			  oaBoolean		    foundry,			  oaBoolean		    hard){    oaLayerConstraintDef *def = oaLayerConstraintDef::get(type);    oaConstraint    *c = oaLayerConstraint::find(group, layerNum, def, hard);    if ((!c || c->isHard() != hard) && foundry && group != getFoundryRules()) {	c = oaLayerConstraint::find(getFoundryRules(), layerNum, def, hard);    }    if (c && c->isHard() == hard) {	if (params && c->hasParams()) {	    c->getParams(*params);	}	return c->getValue();    }    return NULL;}oaValue*LefDefBase::getConstraint(const	oaConstraintGroup   *group,			  oaLayerPairConstraintType type,			  oaLayerNum		    layer1,			  oaLayerNum		    layer2,			  oaConstraintParamArray    *params,			  oaBoolean		    foundry,			  oaBoolean		    hard){    oaLayerPairConstraintDef *def = oaLayerPairConstraintDef::get(type);    oaConstraint    *c = oaLayerPairConstraint::find(group, layer1,						     layer2, def, hard);    if ((!c || c->isHard() != hard) && foundry && group != getFoundryRules()) {	c = oaLayerPairConstraint::find(getFoundryRules(), layer1, layer2, def, hard);    }    if (c && c->isHard() == hard) {	if (params && c->hasParams()) {	    c->getParams(*params);	}	return c->getValue();    }    return NULL;}    // *****************************************************************************// LefDefBase::findProp()//// This function searches the property list looking for a property with the// specified name and object type. An exception is thrown if none was found.// *****************************************************************************LefDefProp*LefDefBase::findProp(const oaString	&name,		     LefDefObjectType	objectType){    for (LefDefProp *p = props; p; p = p->getNext()) {	if (p->getName() == name && p->getObjectType() == objectType) {	    return p;	}    }    return NULL;}// *****************************************************************************// LefDefBase::getProp()//// This function searches the property list looking for a property with the// specified name and object type. An exception is thrown if none was found.// *****************************************************************************LefDefProp*LefDefBase::getProp(const oaString	&name,		    LefDefObjectType	objectType){    LefDefProp	*p = findProp(name, objectType);    if (!p) {	throw LefDefError(cInvalidProperty, (const char*) name);    }    return p;}// *****************************************************************************// LefDefBase::addProp()//// This function adds a property to the list of LEF/DEF properties in this// translator.// *****************************************************************************voidLefDefBase::addProp(LefDefProp  *propIn){    if (!props) {	props = propIn;    } else {	lastProp->setNext(propIn);    }    lastProp = propIn;}// *****************************************************************************// LefDefBase::hasProp()//// This function returns a boolean indicating whether the property list contains// any properties for the specified object type.// *****************************************************************************oaBooleanLefDefBase::hasProp(LefDefObjectType	objectType) const{    for (LefDefProp *p = props; p; p = p->getNext()) {	if (p->getObjectType() == objectType) {	    return true;	}    }    return false;}// *****************************************************************************// LefDefBase::clearProps()//// This function clears the property definition list// *****************************************************************************voidLefDefBase::clearProps(){    while (props) {	LefDefProp	*pd = props;		props = pd->getNext();	delete pd;    }    props    = NULL;    lastProp = NULL;}// *****************************************************************************// LefDefBase::init()//// This function clears the member variables for LefDefBase// *****************************************************************************voidLefDefBase::init(){    clearProps();    libObj = NULL;    techObj = NULL;    defRulesObj = NULL;    designObj = NULL;    blockObj = NULL;}// *****************************************************************************// LefDefBase::close()//// This function closes the tech database if it exists. Note that the libraries// are not closed by the translator component. This is up to the calling// application.// *****************************************************************************voidLefDefBase::close(){    if (techObj) {	techObj->close();    }}// *****************************************************************************// LefDefBase::error()//// This function reports an error to both stderr and the logfile.// The errorCount is incremented for the report at the end.// *****************************************************************************voidLefDefBase::error(LefDefMsgIds	msgId,		  ...){    const char* format = LefDefMsgs[msgId - oavLefDefMsgIdStartValue];    char	buf[1024];    va_list	args;    va_start(args, msgId);    vsprintf(buf, format, args);    va_end(args);    msgAdapter.printError("%s\n", buf);}// *****************************************************************************// LefDefBase::warn()//// This function reports a warning to both stderr and the logfile.// The warningCount is incremented for the report at the end.// *****************************************************************************voidLefDefBase::warn(LefDefMsgIds	msgId,		  ...){    const char* format = LefDefMsgs[msgId - oavLefDefMsgIdStartValue];    char	buf[1024];    va_list	args;    va_start(args, msgId);    vsprintf(buf, format, args);    va_end(args);    msgAdapter.printWarning("%s\n", buf);}END_LEFDEF_NAMESPACE

⌨️ 快捷键说明

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