From f3ccf31e48f70f2da1937faf4f2b221955ee634c Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sat, 12 Jun 2021 16:29:08 +0200 Subject: [PATCH] Fix incomplete GDS layer table in GdsParser. * Bug: In CRL::GdsParser(), the table of GDS layer was limited to 64, which is the maximum, according to the reference. But it is no longer true. Extend to 256. This was leading to GDS files missing some layers. --- crlcore/src/ccore/gds/GdsParser.cpp | 41 +++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/crlcore/src/ccore/gds/GdsParser.cpp b/crlcore/src/ccore/gds/GdsParser.cpp index e7042fb0..a965ece5 100644 --- a/crlcore/src/ccore/gds/GdsParser.cpp +++ b/crlcore/src/ccore/gds/GdsParser.cpp @@ -505,7 +505,7 @@ namespace { for ( ; _count<_length ; ++_count ) { _stream->get( c ); sprintf( _buffer, "0x%02x", c ); - cdebug_log(101,0) << setw(6) << hex << _offset++ << " | " << _buffer << endl; + cdebug_log(101,0) << tsetw(6) << hex << _offset++ << " | " << _buffer << endl; } if (showError) { cdebug_log(101,0) << Error( "GdsRecord type %s unsupported.", toStrType(_type).c_str() ) << endl; @@ -723,10 +723,10 @@ namespace { void GdsStream::_staticInit () { - _gdsLayerTable = vector( 64, NULL ); + _gdsLayerTable = vector( 256, NULL ); for ( const BasicLayer* layer : DataBase::getDB()->getTechnology()->getBasicLayers() ) { - unsigned int gdsNumber = layer->getGds2Layer(); - if (gdsNumber < 64) _gdsLayerTable[gdsNumber] = layer; + uint16_t gdsNumber = layer->getGds2Layer(); + if (gdsNumber < 256) _gdsLayerTable[gdsNumber] = layer; } } @@ -938,7 +938,7 @@ namespace { if (_record.isELFLAGS()) { _stream >> _record; } if (_record.isPLEX ()) { _stream >> _record; } if (_record.isLAYER ()) { - layer = gdsToLayer( _record.getInt16s()[0] ); + layer = gdsToLayer( (uint16_t)_record.getInt16s()[0] ); if (not layer) { cerr << Error( "GdsStream::readText(): No BasicLayer id:%d in GDS conversion table (skipped)." , _record.getInt16s()[0] @@ -1051,7 +1051,8 @@ namespace { if (_record.isPLEX ()) { _stream >> _record; } if (_record.isLAYER()) { - layer = gdsToLayer( _record.getInt16s()[0] ); + layer = gdsToLayer( (uint16_t)_record.getInt16s()[0] ); + cdebug_log(101,0) << "Layer id:" << ((uint32_t)_record.getInt16s()[0]) << " " << layer << endl; if (not layer) { cerr << Error( "GdsStream::readBoundary(): No BasicLayer id:%d in GDS conversion table (skipped)." , _record.getInt16s()[0] @@ -1099,7 +1100,7 @@ namespace { if (_record.isPLEX ()) { _stream >> _record; } if (_record.isLAYER()) { - layer = gdsToLayer( _record.getInt16s()[0] ); + layer = gdsToLayer( (uint16_t)_record.getInt16s()[0] ); if (not layer) { cerr << Error( "GdsStream::readPath(): No BasicLayer id \"%d\" in GDS conversion table (skipped)." , _record.getInt16s()[0] @@ -1285,7 +1286,16 @@ namespace { if (_record.isELFLAGS()) { _stream >> _record; } if (_record.isPLEX ()) { _stream >> _record; } - if (_record.isLAYER ()) { _stream >> _record; } + if (_record.isLAYER ()) { + layer = gdsToLayer( (uint16_t)_record.getInt16s()[0] ); + if (not layer) { + cerr << Error( "GdsStream::readNode(): No BasicLayer id \"%d\" in GDS conversion table (skipped)." + , _record.getInt16s()[0] + ) << endl; + } + _stream >> _record; + cdebug_log(101,0) << layer << endl; + } else { _validSyntax = false; return _validSyntax; } if (_record.isNODETYPE()) { @@ -1315,7 +1325,16 @@ namespace { if (_record.isELFLAGS()) { _stream >> _record; } if (_record.isPLEX ()) { _stream >> _record; } - if (_record.isLAYER ()) { _stream >> _record; } + if (_record.isLAYER ()) { + layer = gdsToLayer( (uint16_t)_record.getInt16s()[0] ); + if (not layer) { + cerr << Error( "GdsStream::readNode(): No BasicLayer id \"%d\" in GDS conversion table (skipped)." + , _record.getInt16s()[0] + ) << endl; + } + _stream >> _record; + cdebug_log(101,0) << layer << endl; + } else { _validSyntax = false; return _validSyntax; } if (_record.isBOXTYPE()) { @@ -1424,8 +1443,8 @@ namespace { } else { _component = Rectilinear::create( net, layer, points ); } - // cdebug(101,0) << "| " << net->getCell() << endl; - // cdebug(101,0) << "| " << _component << endl; + // cdebug_log(101,0) << "| " << net->getCell() << endl; + cdebug_log(101,0) << "| " << _component << endl; if (not net->isAutomatic()) NetExternalComponents::setExternal( _component ); }