diff --git a/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp b/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp index 2831a0d5..9ada8b70 100644 --- a/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp +++ b/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp @@ -1,5 +1,5 @@ // -*-compile-command:"cd ../../../../.. && make"-*- -// Time-stamp: "2010-07-22 15:38:03" - OpenAccessWrapper.cpp +// Time-stamp: "2010-07-23 16:05:52" - OpenAccessWrapper.cpp // x-----------------------------------------------------------------x // | This file is part of the hurricaneAMS Software. | // | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | @@ -116,30 +116,9 @@ namespace { } // 1) create or open library - oaNativeNS ns; - const char* strNameLib = getString(library->getName()).c_str(); - string strPathLib = _path + '/' + strNameLib; - oaScalarName scNameLib(ns, strNameLib); - cerr << "Library for Lib name=" - << strNameLib << " to filesystem path=" << strPathLib << endl; - cerr << "oaLib::find" << endl; - oaLib *lib = oaLib::find(scNameLib); - if (!lib) { - if (oaLib::exists(strPathLib.c_str())){ - cerr << "oaLib::open" << endl; - lib = oaLib::open(scNameLib, strPathLib.c_str()); - }else{ - cerr << "create directory for library" << endl; - string cmd = "mkdir -p "+strPathLib; - system(cmd.c_str()); - } - if(!lib){ - cerr << "oaLib::create" << endl; - lib = oaLib::create(scNameLib, strPathLib.c_str()); - } - } - assert(lib); - assert(lib->isValid()); + pair infos=libInfos(_path, + getString(library->getName())); + oaLib *lib = openOALib(infos); _library2OALib[library] = lib; #if 0 @@ -156,23 +135,8 @@ namespace { } #endif // 4) create, update library list file - try{ - cerr << "Overwriting cds.lib file begin" << endl; - string cdsPath = strPathLib + "/cds.lib"; - oaLibDefList* ldl = oaLibDefList::get( cdsPath.c_str(), 'a'); - assert(ldl); - assert(ldl->isValid()); - if(!oaLibDef::find(ldl, scNameLib)) - oaLibDef::create(ldl, scNameLib, strPathLib.c_str()); - ldl->save(); - ldl->destroy();//claim memory - ldl = NULL; - cerr << "Overwrited cds.lib file end" << endl; - }catch(oaException& e){ - cerr << "ERROR cds: " << e.getMsg() << endl; - exit(-2); - } - + createCDS(infos); + return lib; } @@ -632,15 +596,36 @@ namespace { // 2) create OA structure ... oaDesign* netlistView = createOAasNetlist(cell); assert(netlistView); + + oaCell* c1 = OADesignToOACell(netlistView); + assert(c1); + oaDesign* symbolicView = addSymbol(cell,netlistView); assert(symbolicView); + + oaCell* c2 = OADesignToOACell(symbolicView); + assert(c2); + oaDesign* schematicView = addSchematic(cell,symbolicView); assert(schematicView); + + oaCell* c3 = OADesignToOACell(schematicView); + assert(c3); + oaDesign* layoutView = addLayout(cell,schematicView); assert(layoutView); + oaCell* c4 = OADesignToOACell(layoutView); + assert(c4); + + assert(c1 == c2 && c2 == c3 && c3 == c4); + return netlistView; } + + oaCell* getOACellForCell(const Cell* cell) { + return OADesignToOACell( getOADesignForCell(cell) ); + } }; #endif } @@ -658,9 +643,7 @@ namespace CRL { oacDataModelRevNumber); OADriver oaDriver(path); - oaDesign* design = oaDriver.getOADesignForCell(cell); - if(design) - cerr << "DONE ->" << getDesignName(design) << endl; + oaCell* convertedCell = oaDriver.getOACellForCell(cell); }catch (oaException &e) { cerr << "OA::ERROR => " << e.getMsg() << endl; exit(1); diff --git a/crlcore/src/ccore/openaccess/OpenAccessUtils.h b/crlcore/src/ccore/openaccess/OpenAccessUtils.h index 5418aa3d..8be2583c 100644 --- a/crlcore/src/ccore/openaccess/OpenAccessUtils.h +++ b/crlcore/src/ccore/openaccess/OpenAccessUtils.h @@ -23,7 +23,7 @@ namespace { giving a oaDesign pointer that should be not NULL return the oaString representing its name */ - oaString getDesignName(oaDesign* design) { + inline oaString getDesignName(oaDesign* design) { cerr << "getDesignName" << endl; assert(design); oaNativeNS ns; @@ -40,7 +40,7 @@ namespace { print the connectivity, mainly used for debug purpose ... @todo remove when not needed anymore */ - void printBlockTerms(oaBlock* block) { + inline void printBlockTerms(oaBlock* block) { cerr << "printBlockTerms" << endl; assert(block); oaNativeNS ns; @@ -59,7 +59,7 @@ namespace { Convert material from Hurricane to OA ... @todo verify */ - oaMaterial getOAMaterial(const BasicLayer::Material& material) { + inline oaMaterial getOAMaterial(const BasicLayer::Material& material) { cerr << "getOAMaterial" << endl; switch ( material.getCode() ) { case BasicLayer::Material::nWell: return oacNWellMaterial; @@ -83,7 +83,7 @@ namespace { Convertion helper for Net convertion ... @todo verify */ - oaTermType getOATermType(const Net::Direction& direction) { + inline oaTermType getOATermType(const Net::Direction& direction) { cerr << "getOATermType" << endl; switch (direction) { case Net::Direction::IN: @@ -105,7 +105,7 @@ namespace { Convertion helper for Net convertion ... @todo verify */ - oaSigType getOASigType(const Net::Type& type) { + inline oaSigType getOASigType(const Net::Type& type) { cerr << "getOASigType" << endl; switch (type.getCode()) { case Net::Type::LOGICAL: @@ -126,7 +126,7 @@ namespace { /** Convertion helper ... */ - oaOrient getOAOrientFromOrientation(const Transformation::Orientation& orientation) { + inline oaOrient getOAOrientFromOrientation(const Transformation::Orientation& orientation) { cerr << "getOAOrientFromOrientation" << endl; switch (orientation) { case Transformation::Orientation::ID: @@ -153,7 +153,7 @@ namespace { /** Convertion helper ... */ - void getOATransformFromTransformation(oaTransform& transform, const Transformation& transformation) { + inline void getOATransformFromTransformation(oaTransform& transform, const Transformation& transformation) { cerr << "getOATransformFromTransformation" << endl; transform.set(transformation.getTx(), transformation.getTy(), @@ -163,7 +163,7 @@ namespace { /** Convertion helper ... */ - void getOABoxForBox(oaBox& box, const Box& hbox) { + inline void getOABoxForBox(oaBox& box, const Box& hbox) { cerr << "getOABoxForBox" << endl; box.set(hbox.getXMin(), hbox.getYMin(), hbox.getXMax(), hbox.getYMax()); } @@ -172,7 +172,7 @@ namespace { Create InstTerm representing connection of nets ... always return a non NULL value */ - oaInstTerm* getInstTerm(oaInst* inst, Plug* plug,oaNet* net) { + inline oaInstTerm* getInstTerm(oaInst* inst, Plug* plug,oaNet* net) { cerr << "getInstTerm" << endl; assert(inst); assert(plug); @@ -199,7 +199,7 @@ namespace { /** save design stored in a map */ - void saveDesignsInMap(map cell2OAdesign){ + inline void saveDesignsInMap(map cell2OAdesign){ for (map::iterator it = cell2OAdesign.begin(); it != cell2OAdesign.end(); ++it) { @@ -213,7 +213,7 @@ namespace { /** print the oaLayera in a oaTech ... */ - void printOALayers(oaTech* theOATech){ + inline void printOALayers(oaTech* theOATech){ cerr << "printOALayers" << endl; assert(theOATech); oaIter lIter(theOATech->getLayers()); @@ -227,7 +227,7 @@ namespace { /** @todo complete,verify ... */ - BasicLayer::Material::Code oaMaterialToBasicLayerType(const oaMaterial& material) { + inline BasicLayer::Material::Code oaMaterialToBasicLayerType(const oaMaterial& material) { switch(material) { case oacNWellMaterial: return BasicLayer::Material::nWell; @@ -249,6 +249,70 @@ namespace { } } + /** + generate info from library name + */ + inline pair libInfos(const string& path, + const string& libName){ + oaNativeNS ns; + const char* strNameLib = libName.c_str(); + oaScalarName scNameLib(ns, strNameLib); + string strPathLib = path + '/' + strNameLib; + return make_pair(scNameLib,strPathLib); + } + + /** + open oaLib with the info gathered by libPath function + */ + inline oaLib* openOALib(const pair& infos){ + oaLib *lib = oaLib::find(infos.first); + const char* pathLib = infos.second.c_str(); + if (!lib) { + if (oaLib::exists(pathLib)){ + lib = oaLib::open(infos.first, pathLib); + }else{ + string cmd = "mkdir -p "+ infos.second; + system(cmd.c_str()); + } + if(!lib){ + lib = oaLib::create(infos.first, pathLib); + } + } + return lib; + } + + inline void createCDS(const pair& infos){ + try{ + cerr << "Overwriting cds.lib file begin" << endl; + string cdsPath = infos.second + "/cds.lib"; + oaLibDefList* ldl = oaLibDefList::get( cdsPath.c_str(), 'a'); + assert(ldl); + assert(ldl->isValid()); + if(!oaLibDef::find(ldl, infos.first)) + oaLibDef::create(ldl, infos.first, infos.second.c_str()); + ldl->save(); + ldl->destroy();//claim memory + ldl = NULL; + cerr << "Overwrited cds.lib file end" << endl; + }catch(oaException& e){ + cerr << "ERROR cds: " << e.getMsg() << endl; + exit(-2); + } + } + + inline oaCell* OADesignToOACell(oaDesign* design){ + assert(design); + oaScalarName cellName; + design->getCellName(cellName); + oaLib* lib = design->getLib(); + oaBoolean gotAccess = false; + gotAccess = lib->getAccess(oacReadLibAccess); + oaCell* cell = oaCell::find(lib,cellName); + if(gotAccess) + lib->releaseAccess(); + assert(cell); + return cell; + } }//end anonymous namespace diff --git a/crlcore/src/ccore/openaccess/test/src/main.cpp b/crlcore/src/ccore/openaccess/test/src/main.cpp index bd7cabd8..1f2d413c 100755 --- a/crlcore/src/ccore/openaccess/test/src/main.cpp +++ b/crlcore/src/ccore/openaccess/test/src/main.cpp @@ -38,22 +38,22 @@ namespace { void testCell(Cell* dev,char* pathToTest){ if(dev){ - cout << "Cell created" << endl; + cerr << "Cell created" << endl; }else{ - cout << "Cell not created" << endl; + cerr << "Cell not created" << endl; return; } system((string("mkdir -p ") + string(pathToTest)).c_str()); - cout << "driving GDS" << endl; - GdsDriver(dev).save(string(pathToTest) + "/GDSdrive"); - - cout << "driving OA" << endl; +/* cerr << "driving GDS" << endl; + GdsDriver(dev).save(string(pathToTest) + "/GDSdrive"); +*/ + cerr << "driving OA" << endl; OADriver(dev).save(string(pathToTest) + "/OAdrive"); } void testAnalog(char* pathToConf,char* pathToTest){ AnalogEnv::create(pathToConf);//create Database ... - cout << "analog environment loaded and database created" << endl; + cerr << "analog environment loaded and database created" << endl; DataBase* db = DataBase::getDB(); assert(db != NULL); Library* rootLib = db->getRootLibrary(); @@ -73,25 +73,25 @@ void testAnalog(char* pathToConf,char* pathToTest){ design = Cell::create(workLibrary, designName); assert(design != NULL); - cout << "creating cell myCM" << endl; + cerr << "creating cell myCM" << endl; bool bulkConnected = true;//bulk connected to source Cell* dev = SimpleCurrentMirror::create(workLibrary, Name("myCM"), TransistorFamily::NMOS, bulkConnected); - cout << "testing cell myCM" << endl; + cerr << "testing cell myCM" << endl; testCell(dev,pathToTest); db->destroy(); } -void testNum(char* pathToConf,char* pathToTest){ - cout << "creating cell from sxlib inv_x1" << endl; - dbo_ptr db ( DataBase::create() ); - dbo_ptr af ( AllianceFramework::create() ); - Cell* cell = NULL; - cell = af->getCell("inv_x1", Catalog::State::Views ); - cout << "testing cell from sxlib inv_x1" << endl; +void testNum(char* pathToConf,char* pathToTest,char* cellName){ + cerr << "creating cell from sxlib " << cellName << endl; + DataBase* db = DataBase::getDB(); + AllianceFramework* af = AllianceFramework::get(); + Cell* cell = NULL; + cell = af->getCell(cellName, Catalog::State::Views ); + cerr << "testing cell from sxlib "<< cellName << endl; testCell(cell,pathToTest); } @@ -99,9 +99,104 @@ int main(int argc,char** argv) { if(argc != 3) exit(-5); - // testAnalog(argv[1],argv[2]); - testNum(argv[1],argv[2]); + testAnalog(argv[1],argv[2]); - cout << "ending normally" << endl; + testNum(argv[1],argv[2],"a2_x2"); + testNum(argv[1],argv[2],"a2_x4"); + testNum(argv[1],argv[2],"a3_x2"); + testNum(argv[1],argv[2],"a3_x4"); + testNum(argv[1],argv[2],"a4_x2"); + testNum(argv[1],argv[2],"a4_x4"); + testNum(argv[1],argv[2],"an12_x1"); + testNum(argv[1],argv[2],"an12_x4"); + testNum(argv[1],argv[2],"ao22_x2"); + testNum(argv[1],argv[2],"ao22_x4"); + testNum(argv[1],argv[2],"ao2o22_x2"); + testNum(argv[1],argv[2],"ao2o22_x4"); + testNum(argv[1],argv[2],"buf_x2"); + testNum(argv[1],argv[2],"buf_x4"); + testNum(argv[1],argv[2],"buf_x8"); + testNum(argv[1],argv[2],"fulladder_x2"); + testNum(argv[1],argv[2],"fulladder_x4"); + testNum(argv[1],argv[2],"halfadder_x2"); + testNum(argv[1],argv[2],"halfadder_x4"); + testNum(argv[1],argv[2],"inv_x1"); + testNum(argv[1],argv[2],"inv_x2"); + testNum(argv[1],argv[2],"inv_x4"); + testNum(argv[1],argv[2],"inv_x8"); + testNum(argv[1],argv[2],"mx2_x2"); + testNum(argv[1],argv[2],"mx2_x4"); + testNum(argv[1],argv[2],"mx3_x2"); + testNum(argv[1],argv[2],"mx3_x4"); + testNum(argv[1],argv[2],"na2_x1"); + testNum(argv[1],argv[2],"na2_x4"); + testNum(argv[1],argv[2],"na3_x1"); + testNum(argv[1],argv[2],"na3_x4"); + testNum(argv[1],argv[2],"na4_x1"); + testNum(argv[1],argv[2],"na4_x4"); + testNum(argv[1],argv[2],"nao22_x1"); + testNum(argv[1],argv[2],"nao22_x4"); + testNum(argv[1],argv[2],"nao2o22_x1"); + testNum(argv[1],argv[2],"nao2o22_x4"); + testNum(argv[1],argv[2],"nmx2_x1"); + testNum(argv[1],argv[2],"nmx2_x4"); + testNum(argv[1],argv[2],"nmx3_x1"); + testNum(argv[1],argv[2],"nmx3_x4"); + testNum(argv[1],argv[2],"no2_x1"); + testNum(argv[1],argv[2],"no2_x4"); + testNum(argv[1],argv[2],"no3_x1"); + testNum(argv[1],argv[2],"no3_x4"); + testNum(argv[1],argv[2],"no4_x1"); + testNum(argv[1],argv[2],"no4_x4"); + testNum(argv[1],argv[2],"noa22_x1"); + testNum(argv[1],argv[2],"noa22_x4"); + testNum(argv[1],argv[2],"noa2a22_x1"); + testNum(argv[1],argv[2],"noa2a22_x4"); + testNum(argv[1],argv[2],"noa2a2a23_x1"); + testNum(argv[1],argv[2],"noa2a2a23_x4"); + testNum(argv[1],argv[2],"noa2a2a2a24_x1"); + testNum(argv[1],argv[2],"noa2a2a2a24_x4"); + testNum(argv[1],argv[2],"noa2ao222_x1"); + testNum(argv[1],argv[2],"noa2ao222_x4"); + testNum(argv[1],argv[2],"noa3ao322_x1"); + testNum(argv[1],argv[2],"noa3ao322_x4"); + testNum(argv[1],argv[2],"nts_x1"); + testNum(argv[1],argv[2],"nts_x2"); + testNum(argv[1],argv[2],"nxr2_x1"); + testNum(argv[1],argv[2],"nxr2_x4"); + testNum(argv[1],argv[2],"o2_x2"); + testNum(argv[1],argv[2],"o2_x4"); + testNum(argv[1],argv[2],"o3_x2"); + testNum(argv[1],argv[2],"o3_x4"); + testNum(argv[1],argv[2],"o4_x2"); + testNum(argv[1],argv[2],"o4_x4"); + testNum(argv[1],argv[2],"oa22_x2"); + testNum(argv[1],argv[2],"oa22_x4"); + testNum(argv[1],argv[2],"oa2a22_x2"); + testNum(argv[1],argv[2],"oa2a22_x4"); + testNum(argv[1],argv[2],"oa2a2a23_x2"); + testNum(argv[1],argv[2],"oa2a2a23_x4"); + testNum(argv[1],argv[2],"oa2a2a2a24_x2"); + testNum(argv[1],argv[2],"oa2a2a2a24_x4"); + testNum(argv[1],argv[2],"oa2ao222_x2"); + testNum(argv[1],argv[2],"oa2ao222_x4"); + testNum(argv[1],argv[2],"oa3ao322_x2"); + testNum(argv[1],argv[2],"oa3ao322_x4"); + testNum(argv[1],argv[2],"on12_x1"); + testNum(argv[1],argv[2],"on12_x4"); + testNum(argv[1],argv[2],"one_x0"); + testNum(argv[1],argv[2],"powmid_x0"); + testNum(argv[1],argv[2],"rowend_x0"); + testNum(argv[1],argv[2],"sff1_x4"); + testNum(argv[1],argv[2],"sff2_x4"); + testNum(argv[1],argv[2],"sff3_x4"); + testNum(argv[1],argv[2],"tie_x0"); + testNum(argv[1],argv[2],"ts_x4"); + testNum(argv[1],argv[2],"ts_x8"); + testNum(argv[1],argv[2],"xr2_x1"); + testNum(argv[1],argv[2],"xr2_x4"); + testNum(argv[1],argv[2],"zero_x0"); + + cerr << "ending normally" << endl; return 0; }