📄 oalefdefin.cpp
字号:
// *****************************************************************************// *****************************************************************************// LefDef.cpp//// This file contains the member functions specific to the LefDefIn 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.25 $// $Date: 2005/06/20 13:42:50 $// $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaLefDef.h"BEGIN_LEFDEF_NAMESPACE// *****************************************************************************// Initialize Static Members// *****************************************************************************const oaString LefDefIn::hexBits[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};// *****************************************************************************// LefDefIn::LefDefIn()//// This is the default constructor for the LefDefIn class.// *****************************************************************************LefDefIn::LefDefIn(oaUtil::MsgAdapter &msgAdapterIn, oaLefNS &nsIn): LefDefBase(msgAdapterIn, nsIn){}// *****************************************************************************// LefDefIn::~LefDefIn()//// This is the default destructor for the LefDefIn class.// *****************************************************************************LefDefIn::~LefDefIn(){}// *****************************************************************************// LefDefIn::getOrient()//// This function converts a parser orientation code into a db orientation enum// (used for foreign, rows, pins & components).// *****************************************************************************oaOrientEnumLefDefIn::getOrient(int orient){ switch (orient) { case 0: return oacR0; case 1: return oacR90; case 2: return oacR180; case 3: return oacR270; case 4: return oacMY; case 5: return oacMXR90; case 6: return oacMX; case 7: return oacMYR90; } return oacR0;}// *****************************************************************************// LefDefIn::getSigType()//// This function returns an oaSigTypeEnum corresponding to the specified "USE"// value.// 'oacTieHiSigType' and 'oacTieLoSigType' are purposely ignored since they// are not legal USE values in NETS, SPECIALNETS and PINS constructs.// This function is used both by DefInNet and DefInPin classes.// *****************************************************************************oaSigTypeEnumLefDefIn::getSigType(oaString use){ if (use == "SIGNAL") { return oacSignalSigType; } else if (use == "POWER") { return oacPowerSigType; } else if (use == "GROUND") { return oacGroundSigType; } else if (use == "CLOCK") { return oacClockSigType; } else if (use == "TIEOFF") { return oacTieoffSigType; } else if (use == "ANALOG") { return oacAnalogSigType; } else if (use == "SCAN") { // from 5.4 syntax return oacScanSigType; } else if (use == "RESET") { // from 5.4 syntax return oacResetSigType; } return oacSignalSigType;}// *****************************************************************************// LefDefIn::addGenVia()//// This function adds the via name and the standard via to the list of generated// vias.// *****************************************************************************voidLefDefIn::addGenVia(const oaString &name, oaViaDef *viaDef, const oaViaParam &viaParam){ LefDefInGenVia genVia; genVia.viaDef = viaDef; genVia.params = viaParam; genViaTbl.insert(name, genVia);}// *****************************************************************************// LefDefIn::getGenVia()//// This function finds the named via in the list of generated vias.// *****************************************************************************oaViaDef*LefDefIn::getGenVia(const oaString &name, oaViaParam &viaParam){ LefDefInGenVia genVia; if (genViaTbl.find(name, genVia)) { viaParam = genVia.params; return genVia.viaDef; } return NULL;}// *****************************************************************************// LefDefIn::clearGenVias()//// This function clears the list of generated vias.// *****************************************************************************voidLefDefIn::clearGenVias(){ genViaTbl.clear();}// *****************************************************************************// LefDefIn::setViaCutPattern()//// This function decodes the cutPattern part of the patternName.// *****************************************************************************voidLefDefIn::setViaCutPattern(const oaString &cutPattern, oaViaParam &viaParams, const oaString &viaName){ oaUInt4 numTokens = getNumTokens(cutPattern, '_'); oaUInt4 numRowPatterns = numTokens / 2; oaUInt4 *numRowCache = new oaUInt4[numRowPatterns]; oaString *bitCache = new oaString[numRowPatterns]; oaUInt4 numRows = 0; oaUInt4 numCols = 0; for (oaUInt4 i = 0; i < numRowPatterns; i++) { oaString rowPattern; getToken(cutPattern, i * 2, rowPattern, '_'); rowPattern.toUpper(); // find the multiplier for the rownum and store in cache numRowCache[i] = hexToInt(rowPattern); numRows += numRowCache[i]; // convert the rest of the pattern to bits and store in cache oaString bitPattern; getToken(cutPattern, i * 2 + 1, bitPattern, '_'); hexToBits(bitPattern, bitCache[i]); if (bitCache[i].getLength() > numCols) { numCols = bitCache[i].getLength(); } } // Verify the correct number of rows and columns. if (numRows < viaParams.getCutRows() || numCols < viaParams.getCutColumns()) { throw LefDefError(cViaInvalidCutPattern, (const char*) viaName); } // Set cutpattern in the viaParams. oaUInt4 rowNum = 0; for (oaUInt4 i = 0; i < numRowPatterns; i++) { for (oaUInt4 j = 0; j < numRowCache[i]; j++) { for (oaUInt4 colNum = 0; colNum < viaParams.getCutColumns(); colNum++) { if (bitCache[i][colNum] == '1') { viaParams.setCutPatternVal(rowNum, colNum, true); } else { viaParams.setCutPatternVal(rowNum, colNum, false); } } rowNum++; if (rowNum == viaParams.getCutRows()) { break; } } } delete[] bitCache; delete[] numRowCache;}// *****************************************************************************// LefDefIn::getNumTokens// LefDefIn::getToken//// These functions handle splitting strings into tokens.// *****************************************************************************oaUInt4LefDefIn::getNumTokens(const oaString &pattern, const char sep){ if (!pattern.getLength()) { return 0; } // get the number of tokens oaUInt4 token = 1; oaUInt4 i; for (i = 1; i < pattern.getLength() - 1; i++) { if (pattern[i] == sep) { token++; } } return token;}oaBooleanLefDefIn::getToken(const oaString &pattern, oaUInt4 num, oaString &token, const char sep){ oaString sepStr(&sep, 1); oaUInt4 t = 0; for (oaUInt4 i = 0; i < num; i++) { t = pattern.substr(sepStr, t) + 1; if (t >= pattern.getLength()) { return false; } } token = oaString(&pattern[t], pattern.substr(sepStr, t) - t); return true;}// *****************************************************************************// LefDefIn::hexToInt//// This function converts a hexadecimal number to an integer.// *****************************************************************************oaUInt4LefDefIn::hexToInt(const oaString &str){ oaUInt4 val = 0; oaUInt4 numChars = str.getLength(); for (oaUInt4 i = 0; i < numChars; i++) { oaUInt4 digit = 0; if (str[i] > 0x29 && str[i] < 0x40 ) { digit = str[i] & 0x0f; } else if (str[i] >='a' && str[i] <= 'f') { digit = (str[i] & 0x0f) + 9; } else if (str[i] >='A' && str[i] <= 'F') { digit = (str[i] & 0x0f) + 9; } val += oaUInt4(pow(16., int(numChars - i - 1)) * digit); } return val;}// *****************************************************************************// LefDefIn::hexToBits//// This function translates/appends a cutpattern "hex" string to a bit string// including any possible base20 multiplier// *****************************************************************************voidLefDefIn::hexToBits(const oaString &hex, oaString &bits){ for (oaUInt4 i = 0; i < hex.getLength(); i++) { oaUInt4 mult = 1; if (hex[i] == 'R') { mult = hexToInt(oaString(&hex[++i], 1)); i++; } for (oaUInt4 j = 0; j < mult; j++) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -