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.
This commit is contained in:
Jean-Paul Chaput 2018-06-08 12:02:49 +02:00
parent c5034a9156
commit ea9a1f3710
3 changed files with 83 additions and 25 deletions

View File

@ -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<string,string> > 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<Library*> Blif::_libraries;
void Blif::add ( Library* library )
{ if (library) _libraries.push_back( library ); }
Cell* Blif::load ( string cellPath )
{
using namespace std;

View File

@ -38,26 +38,35 @@
#ifndef CRL_BLIF_H
#define CRL_BLIF_H
# include <string>
#include <string>
#include <vector>
namespace Hurricane {
class Cell;
class Library;
}
namespace CRL {
using Hurricane::Cell;
using Hurricane::Library;
class Blif {
public:
static Cell* load ( std::string netlist );
static void add ( Library* );
static inline const std::vector<Library*>& getLibraries ();
private:
static std::vector<Library*> _libraries;
};
} // End of CRL namespace.
inline const std::vector<Library*>& Blif::getLibraries () { return _libraries; }
# endif
} // CRL namespace.
#endif // CRL_BLIF_H

View File

@ -16,6 +16,7 @@
#include "crlcore/PyBlif.h"
#include "hurricane/isobar/PyCell.h"
#include "hurricane/isobar/PyLibrary.h"
#include <string>
#include <sstream>
@ -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 */