From ea9a1f3710f07dfcd2050fc0f451a0afa054988f Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Fri, 8 Jun 2018 12:02:49 +0200 Subject: [PATCH] CRL::Blif parser now able to load both non-Alliance & Alliance design. * Change: In CRL::Blif, we now can add a list of Hurricane library for the parser to look for standart cells. If the library list is *empty* we look use the Alliance mechanism, if not, we look *only* in this library list. This behavior is implemented in Subckt::createModel(). I To add a library, use CRL::Blif::add(Library*). This allow to manage symbolic or real mode loading, it may need some rework to clarify the interface. --- crlcore/src/ccore/blif/BlifParser.cpp | 58 ++++++++++++++++++--------- crlcore/src/ccore/crlcore/Blif.h | 19 ++++++--- crlcore/src/pyCRL/PyBlif.cpp | 31 +++++++++++++- 3 files changed, 83 insertions(+), 25 deletions(-) diff --git a/crlcore/src/ccore/blif/BlifParser.cpp b/crlcore/src/ccore/blif/BlifParser.cpp index e728a1d9..7cd1a182 100644 --- a/crlcore/src/ccore/blif/BlifParser.cpp +++ b/crlcore/src/ccore/blif/BlifParser.cpp @@ -26,10 +26,11 @@ using namespace std; #include "vlsisapd/configuration/Configuration.h" #include "hurricane/Warning.h" -#include "hurricane/Net.h" -#include "hurricane/Cell.h" #include "hurricane/Plug.h" +#include "hurricane/Net.h" #include "hurricane/Instance.h" +#include "hurricane/Cell.h" +#include "hurricane/Library.h" #include "hurricane/UpdateSession.h" using namespace Hurricane; @@ -220,6 +221,7 @@ namespace { typedef vector< pair > Connections; public: Subckt ( string modelName, string instanceName ); + static Model* createModel ( string modelName ); inline string getModelName () const; inline string getInstanceName () const; inline const Connections& getConnections () const; @@ -286,28 +288,39 @@ namespace { // Class : "::Subckt" (implementation). + Model* Subckt::createModel ( string modelName ) + { + Cell* cell = NULL; + Model* model = NULL; + if (Blif::getLibraries().empty()) { + AllianceFramework* af = AllianceFramework::get(); + if (af->isInCatalog(modelName)) { + model = Model::find( modelName ); + if (not model) { + model = new Model ( af->getCell( modelName, Catalog::State::Views, 0 ) ); + } + } + } else { + for ( Library* library : Blif::getLibraries() ) { + cell = library->getCell( modelName ); + if (cell) { + model = new Model ( cell ); + break; + } + } + } + + return model; + } + + Subckt::Subckt ( string modelName, string instanceName ) : _modelName (modelName) , _instanceName(instanceName) , _connections () - , _model (NULL) - { - AllianceFramework* af = AllianceFramework::get(); - if (af->isInCatalog(modelName)) { - _model = Model::find( modelName ); - if (not _model) { - _model = new Model ( af->getCell( modelName, Catalog::State::Views, 0 ) ); - } - } + , _model (createModel(modelName)) + { } - // Cell* cell = AllianceFramework::get()->getCell( modelName, Catalog::State::Views|Catalog::State::Foreign, 0 ); - // if (cell) { - // _model = Model::find( getString(cell->getName()) ); - // if (not _model) { - // _model = new Model ( cell ); - // } - // } - } inline Model* Subckt::getModel () const { return _model; } inline string Subckt::getModelName () const { return _modelName; } @@ -643,6 +656,13 @@ namespace { namespace CRL { + vector Blif::_libraries; + + + void Blif::add ( Library* library ) + { if (library) _libraries.push_back( library ); } + + Cell* Blif::load ( string cellPath ) { using namespace std; diff --git a/crlcore/src/ccore/crlcore/Blif.h b/crlcore/src/ccore/crlcore/Blif.h index f326f203..ef644e77 100644 --- a/crlcore/src/ccore/crlcore/Blif.h +++ b/crlcore/src/ccore/crlcore/Blif.h @@ -38,26 +38,35 @@ #ifndef CRL_BLIF_H #define CRL_BLIF_H -# include +#include +#include namespace Hurricane { class Cell; + class Library; } namespace CRL { using Hurricane::Cell; + using Hurricane::Library; class Blif { public: - static Cell* load ( std::string netlist ); + static Cell* load ( std::string netlist ); + static void add ( Library* ); + static inline const std::vector& getLibraries (); + private: + static std::vector _libraries; }; - -} // End of CRL namespace. + + inline const std::vector& Blif::getLibraries () { return _libraries; } -# endif +} // CRL namespace. + +#endif // CRL_BLIF_H diff --git a/crlcore/src/pyCRL/PyBlif.cpp b/crlcore/src/pyCRL/PyBlif.cpp index 16215048..45f67954 100644 --- a/crlcore/src/pyCRL/PyBlif.cpp +++ b/crlcore/src/pyCRL/PyBlif.cpp @@ -16,6 +16,7 @@ #include "crlcore/PyBlif.h" #include "hurricane/isobar/PyCell.h" +#include "hurricane/isobar/PyLibrary.h" #include #include @@ -40,7 +41,12 @@ namespace CRL { using Isobar::ParseOneArg; using Isobar::ParseTwoArg; using Isobar::__cs; + using Isobar::PyCell; using Isobar::PyCell_Link; + using Isobar::PyTypeCell; + using Isobar::PyLibrary; + using Isobar::PyLibrary_Link; + using Isobar::PyTypeLibrary; extern "C" { @@ -53,6 +59,27 @@ extern "C" { // +=================================================================+ + static PyObject* PyBlif_add ( PyObject*, PyObject* args ) + { + cdebug_log(30,0) << "PyBlif_add()" << endl; + + HTRY + PyObject* pyLibrary = NULL; + if (PyArg_ParseTuple( args, "O:Blif.add", &pyLibrary )) { + if (not IsPyLibrary(pyLibrary)) { + PyErr_SetString( ConstructorError, "Blif.add(): Argument is not of Library type." ); + return NULL; + } + Blif::add( PYLIBRARY_O(pyLibrary) ); + } else { + PyErr_SetString( ConstructorError, "Blif.add(): bad number of parameters." ); + return NULL; + } + HCATCH + Py_RETURN_NONE; + } + + static PyObject* PyBlif_load ( PyObject*, PyObject* args ) { cdebug_log(30,0) << "PyBlif_load()" << endl; @@ -80,6 +107,8 @@ extern "C" { PyMethodDef PyBlif_Methods[] = { { "load" , (PyCFunction)PyBlif_load , METH_VARARGS|METH_STATIC , "Load a complete Blif design." } + , { "add" , (PyCFunction)PyBlif_add , METH_VARARGS|METH_STATIC + , "Add a Library into which lookup master cells.." } //, { "destroy" , (PyCFunction)PyBlif_destroy , METH_VARARGS // , "Destroy the associated hurricane object. The python object remains." } , {NULL, NULL, 0, NULL} /* sentinel */ @@ -94,7 +123,7 @@ extern "C" { // +=================================================================+ -// | "PyBlif" Shared Library Code Part | +// | "PyBlif" Shared Library Code Part | // +=================================================================+ // Type Definition.