diff --git a/crlcore/src/ccore/AllianceFramework.cpp b/crlcore/src/ccore/AllianceFramework.cpp index acb3885f..6465b77a 100644 --- a/crlcore/src/ccore/AllianceFramework.cpp +++ b/crlcore/src/ccore/AllianceFramework.cpp @@ -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 ; igetCells() ) { + 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; diff --git a/crlcore/src/ccore/SearchPath.cpp b/crlcore/src/ccore/SearchPath.cpp index e89fe613..501ae88b 100644 --- a/crlcore/src/ccore/SearchPath.cpp +++ b/crlcore/src/ccore/SearchPath.cpp @@ -104,7 +104,6 @@ namespace CRL { return; } } - _selected = _selectFailed; _index = npos; } diff --git a/crlcore/src/ccore/crlcore/AllianceFramework.h b/crlcore/src/ccore/crlcore/AllianceFramework.h index b93c3dba..7c7122e9 100644 --- a/crlcore/src/ccore/crlcore/AllianceFramework.h +++ b/crlcore/src/ccore/crlcore/AllianceFramework.h @@ -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* ); diff --git a/crlcore/src/pyCRL/PyAllianceFramework.cpp b/crlcore/src/pyCRL/PyAllianceFramework.cpp index 99002d2a..f2e99f0d 100644 --- a/crlcore/src/pyCRL/PyAllianceFramework.cpp +++ b/crlcore/src/pyCRL/PyAllianceFramework.cpp @@ -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