Fix bug in LefImport that was preventing loading the GDS file (FOREIGN).

This commit is contained in:
Jean-Paul Chaput 2023-09-02 22:57:04 +02:00
parent c55654eb5f
commit 48bf2846e1
1 changed files with 14 additions and 9 deletions

View File

@ -85,7 +85,7 @@ namespace {
inline bool isVH () const; inline bool isVH () const;
bool isUnmatchedLayer ( string ); bool isUnmatchedLayer ( string );
Library* createLibrary (); Library* createLibrary ();
Cell* earlyGetCell ( string name="" ); Cell* earlyGetCell ( bool& created, string name="" );
Net* earlyGetNet ( string name ); Net* earlyGetNet ( string name );
inline string getLibraryName () const; inline string getLibraryName () const;
inline Library* getLibrary ( bool create=false ); inline Library* getLibrary ( bool create=false );
@ -352,22 +352,25 @@ namespace {
} }
Cell* LefParser::earlyGetCell ( string name ) Cell* LefParser::earlyGetCell ( bool& created, string name )
{ {
if (not _cell) { if (not _cell) {
if (name.empty()) if (name.empty())
name = "EarlyLEFCell"; name = "EarlyLEFCell";
_cell = getLibrary(true)->getCell( name ); _cell = getLibrary(true)->getCell( name );
if (not _cell) if (not _cell) {
created = true;
_cell = Cell::create( getLibrary(true), name ); _cell = Cell::create( getLibrary(true), name );
} }
}
return _cell; return _cell;
} }
Net* LefParser::earlyGetNet ( string name ) Net* LefParser::earlyGetNet ( string name )
{ {
if (not _cell) earlyGetCell(); bool created = false;
if (not _cell) earlyGetCell( created );
Net* net = _cell->getNet( name ); Net* net = _cell->getNet( name );
if (not net) if (not net)
net = Net::create( _cell, name ); net = Net::create( _cell, name );
@ -535,9 +538,10 @@ namespace {
{ {
LefParser* parser = (LefParser*)ud; LefParser* parser = (LefParser*)ud;
Cell* cell = parser->earlyGetCell( foreign->cellName() ); bool created = false;
Cell* cell = parser->earlyGetCell( created, foreign->cellName() );
if (cell->getName() == "EarlyLEFCell") { if (created) {
if (_gdsForeignDirectory.empty()) { if (_gdsForeignDirectory.empty()) {
cerr << Warning( "LefParser::_macroForeignCbk(): GDS directory *not* set, ignoring FOREIGN statement." ) << endl; cerr << Warning( "LefParser::_macroForeignCbk(): GDS directory *not* set, ignoring FOREIGN statement." ) << endl;
return 0; return 0;
@ -648,13 +652,13 @@ namespace {
parser->setCellGauge( nullptr ); parser->setCellGauge( nullptr );
bool created = false;
string cellName = macro->name(); string cellName = macro->name();
DbU::Unit width = 0; DbU::Unit width = 0;
DbU::Unit height = 0; DbU::Unit height = 0;
Cell* cell = parser->earlyGetCell(); Cell* cell = parser->earlyGetCell( created );
if (cell->getName() != Name(cellName)) { if (cell->getName() != Name(cellName)) {
cerr << cell << " -> " << cellName << endl;
cell->setName( cellName ); cell->setName( cellName );
} }
@ -720,7 +724,8 @@ namespace {
//cerr << " @ _pinCbk: " << pin->name() << endl; //cerr << " @ _pinCbk: " << pin->name() << endl;
parser->earlyGetCell(); bool created = false;
parser->earlyGetCell( created );
Net* net = nullptr; Net* net = nullptr;
Net::Type netType = Net::Type::UNDEFINED; Net::Type netType = Net::Type::UNDEFINED;