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

📄 oalefdefout.cpp

📁 openaccess读def,lef文件所用的源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// *****************************************************************************// *****************************************************************************// LefDef.cpp//// This file contains the member functions specific to the LefDefOut 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: sailajad $// $Revision: 1.32 $// $Date: 2005/07/17 01:55:02 $// $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaLefDef.h"BEGIN_LEFDEF_NAMESPACE// *****************************************************************************// LefDefOut::LefDefOut()//// This is the constructor for the LefDefOut class. The indent string and// indent level are initialized. The output is initially set to be stdout.// *****************************************************************************LefDefOut::LefDefOut(oaUtil::MsgAdapter	&msgAdapterIn,		     oaLefNS		&nsIn):   LefDefBase(msgAdapterIn, nsIn),    indentLevel(0),    indentShift(2),    file(NULL){    memset(indent, ' ', 128 * sizeof(oaChar));    indent[indentLevel] = '\0';}// *****************************************************************************// LefDefOut::~LefDefOut()//// This is the destructor for the LefDefOut class. The output file is flushed// and closed.// *****************************************************************************LefDefOut::~LefDefOut(){}// *****************************************************************************// LefDefOut::addGenVia()// LefDefOut::getGenVia()//// These functions keep track of a list of viaHeaders, in order to keep their// names for reference during the output of routes// The names are made up of "<oaStdViaDefName>_<index>"// *****************************************************************************oaUInt4LefDefOut::addGenVia(oaViaHeader    *viaHeader){    genVias.append(viaHeader);    return genVias.getNumElements();}oaBooleanLefDefOut::getGenVia(oaViaHeader    *viaHeader,		     oaString	    &name){    oaUInt4 num = genVias.find(viaHeader);        if (num != oacNullIndex) {	viaHeader->getViaDefName(name);	    	oaString buf(64);	    	buf.format("_%d", num + 1);	name += buf;	return true;    }    return false;}voidLefDefOut::clearGenVias(oaBoolean    keepNum){    if (keepNum) {	for (oaUInt4 i = 0; i < genVias.getNumElements(); i++) {	    genVias[i] = NULL;	}		return;	    }        genVias.setNumElements(0);}// *****************************************************************************// LefDefOut::encodeCutPattern()//// This function appends the rowCutPatterns for each row to the given string// Duplicate rowCutPatterns are removed by adding a "base20" multiplier// to the front of the first of the duplicate rowCutPatterns.// *****************************************************************************voidLefDefOut::writeCutPattern(const oaViaParam &param){    oaString	cutPattern;    oaString	rowPattern;    oaString	prevRowPattern;    oaUInt4	sameRows = 0;    for (oaUInt4 i = 0; i <= param.getCutRows(); i ++) {	if (i != param.getCutRows()) {	    encodeCutRowPattern(param, i, rowPattern);	}	if (i && (rowPattern != prevRowPattern		  || i == param.getCutRows())) {	    	    char buf[3];	    sprintf(buf, "%X_", sameRows);	    cutPattern += buf;	    sameRows = 0;	    compressCutRowPattern(prevRowPattern, cutPattern);	    if (i < param.getCutRows()) {		cutPattern += "_";	    }	}	sameRows++;	prevRowPattern = rowPattern;    }    outNoIndent("%s", (const char*) cutPattern);}// *****************************************************************************// LefDefOut::encodeCutRowPattern()//// This function creates a string of hexadecimal characters representing// the cut locations in the specified row// *****************************************************************************voidLefDefOut::encodeCutRowPattern(const oaViaParam	&param,			       oaUInt4		row,			       oaString		&rowPattern){    oaUInt4 i = 0;    rowPattern = "";    while (i < param.getCutColumns()) {	oaUInt4 val = 0;		for (oaUInt4 j = 0; j < 4 && i < param.getCutColumns(); j++) {	    if (param.hasDefaultCutPattern()		|| param.getCutPatternVal(row, i)) {		val += oaUInt4(pow(2., int(3 - j)));	    }	    i++;	}	char buf[2];	sprintf(buf, "%X", val);	rowPattern += buf;    }}// *****************************************************************************// LefDefOut::compressCutRowPattern()//// This function compresses duplicate characters in the given string// by adding a base20 multiplier value// *****************************************************************************voidLefDefOut::compressCutRowPattern(const oaString	&rowPattern,				 oaString	&compPattern){    char c = 0;    oaInt4 num = 0;    for (oaUInt4 i = 0; i <= rowPattern.getLength(); i++) {	if (i && (rowPattern[i] != c || i == rowPattern.getLength())) {	    while (num > 0) {		if (num < 3) {		    compPattern += c;		    if (num == 2) {			compPattern += c;		    }		    num = 0;		} else {		    oaUInt4 thisNum = num % 16;		    char	buf[3];		    sprintf(buf, "R%X", thisNum);		    compPattern += buf;		    compPattern += c;		    num -= thisNum;		}	    }	}	num++;	c = rowPattern[i];    }}// *****************************************************************************// LefDefOut::initLib()//// This function clears the member variables of LefDefOut// *****************************************************************************voidLefDefOut::init(){    LefDefBase::init();        clearGenVias();    file = NULL;}// *****************************************************************************// LefDefOut::initLib()//// This function tries to find the library with the given name. If it is not// found (in the lib.defs file) an exception is thrown.// *****************************************************************************voidLefDefOut::initLib(const oaScalarName	&scalarLibName){    lib() = oaLib::find(scalarLibName);    if (!lib()) {	oaString    libName;	scalarLibName.get(libName);	throw LefDefError(cLibNotFound, (const char*) libName);    }    lib()->getAccess(oacReadLibAccess);}// *****************************************************************************// LefDefOut::initTechDB()//// This function initializes the technology database for the library.// *****************************************************************************voidLefDefOut::initTechDB(){    tech() = oaTech::open(lib());    defRules() = NULL;}// *****************************************************************************// LefDefOut::initFile()//// This function initializes the file pointer.// *****************************************************************************voidLefDefOut::initFile(FILE    *fileIn){    file = fileIn;}// *****************************************************************************// LefDefOut::close()// // This function closes the technology database and releases library access.// *****************************************************************************voidLefDefOut::close(){    LefDefBase::close();    lib()->releaseAccess();}// *****************************************************************************// LefDefOut::isLefDefRule()//// This function returns true if the given constraint group is a valid LEF/DEF// (non-default) rule.// *****************************************************************************oaBooleanLefDefOut::isLefDefRule(oaConstraintGroup   *group){    // Only leaf constraint groups are valid for LEF/DEF    oaIter<oaConstraintGroupMem> cgmIter(group->getMembers());    while (oaConstraintGroupMem *cgm = cgmIter.getNext()) {	if (cgm->getObject()->getType() == oacConstraintGroupHeaderType	    || cgm->getObject()->getType() == oacConstraintGroupType) {	    return false;	}    }    // Check all layers for this constraint are LEF layers    oaValue *v = getConstraint(group, oacValidRoutingLayers);

⌨️ 快捷键说明

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