From dc0485935d47fa9f2d9933004fd25bb3720d93d8 Mon Sep 17 00:00:00 2001 From: Gabriel Gouvine Date: Sat, 2 May 2015 20:53:50 +0200 Subject: [PATCH] Better error messages * Error messages are more explicit in Ap and Blif parsers * Warns when not using tie cells * New layer synonym in ApParser for easier format conversion * Blif import is now on top --- crlcore/src/ccore/alliance/ap/ApParser.cpp | 1 + crlcore/src/ccore/blif/BlifParser.cpp | 83 +++++++++++++++++++--- unicorn/src/UnicornGui.cpp | 2 +- 3 files changed, 75 insertions(+), 11 deletions(-) diff --git a/crlcore/src/ccore/alliance/ap/ApParser.cpp b/crlcore/src/ccore/alliance/ap/ApParser.cpp index 2965e727..d36de617 100644 --- a/crlcore/src/ccore/alliance/ap/ApParser.cpp +++ b/crlcore/src/ccore/alliance/ap/ApParser.cpp @@ -249,6 +249,7 @@ namespace { _layerInformations.add ( "CONT_POLY" , "CONT_POLY" , false, false ); _layerInformations.add ( "CONT_POLY2" , "CONT_POLY2" , false, false ); _layerInformations.add ( "CONT_VIA" , "VIA12" , false, false ); + _layerInformations.add ( "CONT_VIA1" , "VIA12" , false, false ); _layerInformations.add ( "CONT_VIA2" , "VIA23" , false, false ); _layerInformations.add ( "CONT_VIA3" , "VIA34" , false, false ); _layerInformations.add ( "CONT_VIA4" , "VIA45" , false, false ); diff --git a/crlcore/src/ccore/blif/BlifParser.cpp b/crlcore/src/ccore/blif/BlifParser.cpp index 0f4a28f7..30ab3bda 100644 --- a/crlcore/src/ccore/blif/BlifParser.cpp +++ b/crlcore/src/ccore/blif/BlifParser.cpp @@ -338,8 +338,10 @@ namespace { void Model::connectModels () { - for ( Model* blifModel : _blifOrder ) + for ( Model* blifModel : _blifOrder ){ + cmess2 << "Handling model <" << blifModel->getCell()->getName() << ">" << endl; blifModel->connectSubckts(); + } } @@ -468,6 +470,9 @@ namespace { void Model::connectSubckts () { for ( Subckt* subckt : _subckts ) { + //cparanoid << "Creating instance <" << subckt->getInstanceName() << "> " + // << "of <" << subckt->getModelName() << "> " + // << endl; Instance* instance = Instance::create( _cell , subckt->getInstanceName() , subckt->getModel()->getCell() @@ -476,20 +481,62 @@ namespace { for ( auto connection : subckt->getConnections() ) { string masterNetName = connection.first; string netName = connection.second; + //cparanoid << "\tConnection " + // << "plug: <" << masterNetName << ">, " + // << "external: <" << netName << ">." + // << endl; Net* net = _cell->getNet( netName ); - Plug* plug = instance->getPlug( instance->getMasterCell()->getNet(masterNetName) ); - Net* plugNet = plug->getNet(); - if (not plugNet) { - if (not net) net = Net::create( _cell, netName ); - plug->setNet( net ); - continue; + Net* masterNet = instance->getMasterCell()->getNet(masterNetName); + if(not masterNet) { + ostringstream tmes; + tmes << "The master net <" << masterNetName << "> hasn't been found " + << "for instance <" << subckt->getInstanceName() << "> " + << "of model <" << subckt->getModelName() << ">" + << "in model <" << getCell()->getName() << ">" + << endl; + throw Error(tmes.str()); } - if (not net) { plugNet->addAlias( netName ); continue; } - if (plugNet == net) continue; + Plug* plug = instance->getPlug( masterNet ); + if(not plug) { + ostringstream tmes; + tmes << "The plug in net <" << netName << "> " + << "and master net <" << masterNetName << "> hasn't been found " + << "for instance <" << subckt->getInstanceName() << "> " + << "of model <" << subckt->getModelName() << ">" + << "in model <" << getCell()->getName() << ">" + << endl; + throw Error(tmes.str()); + } - plugNet->merge( net ); + + Net* plugNet = plug->getNet(); + + if (not plugNet) { // Plug not connected yet + if (not net) net = Net::create( _cell, netName ); + plug->setNet( net ); + plugNet = net; + } + else if (not net) { // Net doesn't exist yet + plugNet->addAlias( netName ); + } + else if (plugNet != net){ // Plus already connected to another net + plugNet->merge( net ); + } + + if( plugNet->getType() == Net::Type::POWER or plugNet->getType() == Net::Type::GROUND ){ + ostringstream tmes; + string powType = plugNet->getType() == Net::Type::POWER ? "power" : "ground"; + string plugName = plugNet->getName()._getString(); // Name of the original net + tmes << "Connecting instance <" << subckt->getInstanceName() << "> " + << "of <" << subckt->getModelName() << "> " + << "to the " << powType << " net <" << plugName << "> "; + if(netName != plugName) + tmes << "with the alias <" << netName << ">. "; + tmes << "Maybe you should use tie cells?"; + cerr << Warning(tmes.str()) << endl; + } } } } @@ -598,7 +645,23 @@ namespace CRL { if (tokenize.state() & Tokenize::CoverAlias) { blifModel->mergeAlias( blifLine[1], blifLine[2] ); } else if (tokenize.state() & Tokenize::CoverZero) { + cerr << Warning( "Blif::load() Definition of an alias <%s> of VSS in a \".names\". Maybe you should use tie cells?\n" + " File %s.blif at line %u." + , blifLine[1].c_str() + , blifFile.c_str() + , tokenize.lineno() + ) << endl; + //blifModel->mergeAlias( blifLine[1], "vss" ); + blifModel->getCell()->getNet( "vss" )->addAlias( blifLine[1] ); } else if (tokenize.state() & Tokenize::CoverOne ) { + cerr << Warning( "Blif::load() Definition of an alias <%s> of VDD in a \".names\". Maybe you should use tie cells?\n" + " File %s.blif at line %u." + , blifLine[1].c_str() + , blifFile.c_str() + , tokenize.lineno() + ) << endl; + //blifModel->mergeAlias( blifLine[1], "vdd" ); + blifModel->getCell()->getNet( "vdd" )->addAlias( blifLine[1] ); } else { cerr << Error( "Blif::load() Unsupported \".names\" cover construct.\n" " File %s.blif at line %u." diff --git a/unicorn/src/UnicornGui.cpp b/unicorn/src/UnicornGui.cpp index a5f12fb2..4d9d9ed6 100644 --- a/unicorn/src/UnicornGui.cpp +++ b/unicorn/src/UnicornGui.cpp @@ -86,10 +86,10 @@ namespace Unicorn { _runUnicornInit(); _importCell.setDialog( _importDialog ); + _importCell.addImporter( "BLIF (Yosys/ABC)" , std::bind( &Blif::load , placeholders::_1 ) ); _importCell.addImporter( "ACM/SIGDA (aka MCNC, .bench)", std::bind( &AcmSigda::load , placeholders::_1 ) ); _importCell.addImporter( "ISPD'04 (Bookshelf)" , std::bind( &Ispd04::load , placeholders::_1 ) ); _importCell.addImporter( "ISPD'05 (Bookshelf)" , std::bind( &Ispd05::load , placeholders::_1 ) ); - _importCell.addImporter( "BLIF (Yosys/ABC)" , std::bind( &Blif::load , placeholders::_1 ) ); _importCell.addImporter( "ICCAD'04 (LEF/DEF)" , std::bind( &Iccad04Lefdef::load, placeholders::_1, 0 ) ); _importCell.addImporter( "Alliance compliant DEF" , std::bind( &DefImport::load , placeholders::_1, DefImport::FitAbOnCells) ); }