Add ability to add non-symbolic library in AllianceFramework.

* New: In CRL::AllianceFramework::wrapLibrary(), can now add in the set
    of AllianceLibrary one which is wrapped around another one. All the
    cells must be already present and do attempt to save them with
    AllianceFramework (AP parser will drive nonsensical datas).
This commit is contained in:
Jean-Paul Chaput 2020-10-16 11:25:57 +02:00
parent 23f9ea052c
commit 158d8c717d
4 changed files with 88 additions and 1 deletions

View File

@ -479,6 +479,62 @@ namespace CRL {
}
AllianceLibrary* AllianceFramework::wrapLibrary ( Library* hlibrary, unsigned int flags )
{
if (not hlibrary) {
cerr << Error( "AllianceFramework::wrapLibrary(): NULL library argument." ) << endl;
return NULL;
}
flags &= ~HasCatalog;
string dupLibName = getString( hlibrary->getName() );
string path = "./wrapped/" + dupLibName;
for ( size_t duplicate=1 ; true ; ++duplicate ) {
AllianceLibrary* library = getAllianceLibrary( dupLibName, flags & ~CreateLibrary );
if (library == NULL) break;
ostringstream oss;
oss << hlibrary->getName() << "." << duplicate;
dupLibName = oss.str();
}
SearchPath& LIBRARIES = _environment.getLIBRARIES();
LIBRARIES.select( path );
if (not LIBRARIES.hasSelected()) {
if (not (flags & AppendLibrary)) LIBRARIES.prepend( path, dupLibName );
else LIBRARIES.append ( path, dupLibName );
}
AllianceLibrary* alibrary = new AllianceLibrary( path, hlibrary );
AllianceLibraries::iterator ilib = _libraries.begin();
if ( (LIBRARIES.getIndex() != SearchPath::npos)
and (LIBRARIES.getIndex() < _libraries.size()) )
for ( size_t i=0 ; i<LIBRARIES.getIndex() ; ++i, ++ilib );
else
ilib = _libraries.end();
_libraries.insert( ilib, alibrary );
for ( Cell* cell : hlibrary->getCells() ) {
Catalog::State* state = _catalog.getState ( getString(cell->getName()) );
if (state == NULL)
state = _catalog.getState( cell->getName(), true );
state->setDepth ( 1 );
state->setInMemory ( true );
state->setPhysical ( true );
state->setLogical ( true );
state->setTerminalNetlist( true );
state->setCell ( cell );
state->getCell ()->put( CatalogProperty::create(state) );
state->getCell ()->setTerminalNetlist( true );
}
notify( AddedLibrary );
return alibrary;
}
void AllianceFramework::saveLibrary ( Library* library )
{
if ( library == NULL ) return;

View File

@ -104,7 +104,6 @@ namespace CRL {
return;
}
}
_selected = _selectFailed;
_index = npos;
}

View File

@ -94,6 +94,7 @@ namespace CRL {
AllianceLibrary* getAllianceLibrary ( const Name& libName, unsigned int flags );
AllianceLibrary* getAllianceLibrary ( Library* );
AllianceLibrary* createLibrary ( const string& path, unsigned int flags, string libName="" );
AllianceLibrary* wrapLibrary ( Library*, unsigned int flags );
inline const AllianceLibraries& getAllianceLibraries () const;
void saveLibrary ( Library* );
void saveLibrary ( AllianceLibrary* );

View File

@ -299,6 +299,35 @@ extern "C" {
}
static PyObject* PyAllianceFramework_wrapLibrary ( PyAllianceFramework* self, PyObject* args )
{
cdebug_log(30,0) << "PyAllianceFramework_wrapLibrary()" << endl;
AllianceLibrary* alib = NULL;
HTRY
METHOD_HEAD("AllianceFramework.wrapLibrary()")
PyObject* arg0;
PyObject* arg1;
__cs.init( "AllianceFramework.wrapLibrary" );
if (not PyArg_ParseTuple( args
, "O&O&:AllianceFramework.wrapLibrary"
, Converter, &arg0
, Converter, &arg1
)) {
PyErr_SetString( ConstructorError, "AllianceFramework.wrapLibrary(): Takes exactly two arguments." );
return NULL;
}
if (__cs.getObjectIds() != ":library:int") {
PyErr_SetString( ConstructorError, "AllianceFramework.wrapLibrary(): Bad parameter()s type, must be (Library,int)." );
return NULL;
}
alib = af->wrapLibrary( PYLIBRARY_O(arg0), PyAny_AsLong(arg1) );
if (not alib) Py_RETURN_NONE;
HCATCH
return PyAllianceLibrary_Link(alib);
}
static PyObject* PyAllianceFramework_isPad ( PyAllianceFramework* self, PyObject* args )
{
cdebug_log(30,0) << "PyAllianceFramework_isPad ()" << endl;
@ -585,6 +614,8 @@ extern "C" {
, "Create a Cell in the Alliance framework." }
, { "createLibrary" , (PyCFunction)PyAllianceFramework_createLibrary , METH_VARARGS
, "Create a Library in the Alliance framework." }
, { "wrapLibrary" , (PyCFunction)PyAllianceFramework_wrapLibrary , METH_VARARGS
, "Wrap an Alliance Library around an existing Hurricane Library." }
, { "loadLibraryCells" , (PyCFunction)PyAllianceFramework_loadLibraryCells , METH_VARARGS
, "Load in memory all Cells from an Alliance Library." }
, { "isPad" , (PyCFunction)PyAllianceFramework_isPad , METH_VARARGS