keep cleaning/enhancing and completed test to drive all sxlib cells ...

This commit is contained in:
Jean-Manuel Caba 2010-07-23 14:48:12 +00:00
parent 3455776742
commit 2ac25af062
3 changed files with 218 additions and 76 deletions

View File

@ -1,5 +1,5 @@
// -*-compile-command:"cd ../../../../.. && make"-*- // -*-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 // x-----------------------------------------------------------------x
// | This file is part of the hurricaneAMS Software. | // | This file is part of the hurricaneAMS Software. |
// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | // | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved |
@ -116,30 +116,9 @@ namespace {
} }
// 1) create or open library // 1) create or open library
oaNativeNS ns; pair<oaScalarName,string> infos=libInfos(_path,
const char* strNameLib = getString(library->getName()).c_str(); getString(library->getName()));
string strPathLib = _path + '/' + strNameLib; oaLib *lib = openOALib(infos);
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());
_library2OALib[library] = lib; _library2OALib[library] = lib;
#if 0 #if 0
@ -156,23 +135,8 @@ namespace {
} }
#endif #endif
// 4) create, update library list file // 4) create, update library list file
try{ createCDS(infos);
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);
}
return lib; return lib;
} }
@ -632,15 +596,36 @@ namespace {
// 2) create OA structure ... // 2) create OA structure ...
oaDesign* netlistView = createOAasNetlist(cell); oaDesign* netlistView = createOAasNetlist(cell);
assert(netlistView); assert(netlistView);
oaCell* c1 = OADesignToOACell(netlistView);
assert(c1);
oaDesign* symbolicView = addSymbol(cell,netlistView); oaDesign* symbolicView = addSymbol(cell,netlistView);
assert(symbolicView); assert(symbolicView);
oaCell* c2 = OADesignToOACell(symbolicView);
assert(c2);
oaDesign* schematicView = addSchematic(cell,symbolicView); oaDesign* schematicView = addSchematic(cell,symbolicView);
assert(schematicView); assert(schematicView);
oaCell* c3 = OADesignToOACell(schematicView);
assert(c3);
oaDesign* layoutView = addLayout(cell,schematicView); oaDesign* layoutView = addLayout(cell,schematicView);
assert(layoutView); assert(layoutView);
oaCell* c4 = OADesignToOACell(layoutView);
assert(c4);
assert(c1 == c2 && c2 == c3 && c3 == c4);
return netlistView; return netlistView;
} }
oaCell* getOACellForCell(const Cell* cell) {
return OADesignToOACell( getOADesignForCell(cell) );
}
}; };
#endif #endif
} }
@ -658,9 +643,7 @@ namespace CRL {
oacDataModelRevNumber); oacDataModelRevNumber);
OADriver oaDriver(path); OADriver oaDriver(path);
oaDesign* design = oaDriver.getOADesignForCell(cell); oaCell* convertedCell = oaDriver.getOACellForCell(cell);
if(design)
cerr << "DONE ->" << getDesignName(design) << endl;
}catch (oaException &e) { }catch (oaException &e) {
cerr << "OA::ERROR => " << e.getMsg() << endl; cerr << "OA::ERROR => " << e.getMsg() << endl;
exit(1); exit(1);

View File

@ -23,7 +23,7 @@ namespace {
giving a oaDesign pointer that should be not NULL giving a oaDesign pointer that should be not NULL
return the oaString representing its name return the oaString representing its name
*/ */
oaString getDesignName(oaDesign* design) { inline oaString getDesignName(oaDesign* design) {
cerr << "getDesignName" << endl; cerr << "getDesignName" << endl;
assert(design); assert(design);
oaNativeNS ns; oaNativeNS ns;
@ -40,7 +40,7 @@ namespace {
print the connectivity, mainly used for debug purpose ... print the connectivity, mainly used for debug purpose ...
@todo remove when not needed anymore @todo remove when not needed anymore
*/ */
void printBlockTerms(oaBlock* block) { inline void printBlockTerms(oaBlock* block) {
cerr << "printBlockTerms" << endl; cerr << "printBlockTerms" << endl;
assert(block); assert(block);
oaNativeNS ns; oaNativeNS ns;
@ -59,7 +59,7 @@ namespace {
Convert material from Hurricane to OA ... Convert material from Hurricane to OA ...
@todo verify @todo verify
*/ */
oaMaterial getOAMaterial(const BasicLayer::Material& material) { inline oaMaterial getOAMaterial(const BasicLayer::Material& material) {
cerr << "getOAMaterial" << endl; cerr << "getOAMaterial" << endl;
switch ( material.getCode() ) { switch ( material.getCode() ) {
case BasicLayer::Material::nWell: return oacNWellMaterial; case BasicLayer::Material::nWell: return oacNWellMaterial;
@ -83,7 +83,7 @@ namespace {
Convertion helper for Net convertion ... Convertion helper for Net convertion ...
@todo verify @todo verify
*/ */
oaTermType getOATermType(const Net::Direction& direction) { inline oaTermType getOATermType(const Net::Direction& direction) {
cerr << "getOATermType" << endl; cerr << "getOATermType" << endl;
switch (direction) { switch (direction) {
case Net::Direction::IN: case Net::Direction::IN:
@ -105,7 +105,7 @@ namespace {
Convertion helper for Net convertion ... Convertion helper for Net convertion ...
@todo verify @todo verify
*/ */
oaSigType getOASigType(const Net::Type& type) { inline oaSigType getOASigType(const Net::Type& type) {
cerr << "getOASigType" << endl; cerr << "getOASigType" << endl;
switch (type.getCode()) { switch (type.getCode()) {
case Net::Type::LOGICAL: case Net::Type::LOGICAL:
@ -126,7 +126,7 @@ namespace {
/** /**
Convertion helper ... Convertion helper ...
*/ */
oaOrient getOAOrientFromOrientation(const Transformation::Orientation& orientation) { inline oaOrient getOAOrientFromOrientation(const Transformation::Orientation& orientation) {
cerr << "getOAOrientFromOrientation" << endl; cerr << "getOAOrientFromOrientation" << endl;
switch (orientation) { switch (orientation) {
case Transformation::Orientation::ID: case Transformation::Orientation::ID:
@ -153,7 +153,7 @@ namespace {
/** /**
Convertion helper ... Convertion helper ...
*/ */
void getOATransformFromTransformation(oaTransform& transform, const Transformation& transformation) { inline void getOATransformFromTransformation(oaTransform& transform, const Transformation& transformation) {
cerr << "getOATransformFromTransformation" << endl; cerr << "getOATransformFromTransformation" << endl;
transform.set(transformation.getTx(), transform.set(transformation.getTx(),
transformation.getTy(), transformation.getTy(),
@ -163,7 +163,7 @@ namespace {
/** /**
Convertion helper ... Convertion helper ...
*/ */
void getOABoxForBox(oaBox& box, const Box& hbox) { inline void getOABoxForBox(oaBox& box, const Box& hbox) {
cerr << "getOABoxForBox" << endl; cerr << "getOABoxForBox" << endl;
box.set(hbox.getXMin(), hbox.getYMin(), hbox.getXMax(), hbox.getYMax()); box.set(hbox.getXMin(), hbox.getYMin(), hbox.getXMax(), hbox.getYMax());
} }
@ -172,7 +172,7 @@ namespace {
Create InstTerm representing connection of nets ... Create InstTerm representing connection of nets ...
always return a non NULL value 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; cerr << "getInstTerm" << endl;
assert(inst); assert(inst);
assert(plug); assert(plug);
@ -199,7 +199,7 @@ namespace {
/** /**
save design stored in a map save design stored in a map
*/ */
void saveDesignsInMap(map<const Cell*, oaDesign*> cell2OAdesign){ inline void saveDesignsInMap(map<const Cell*, oaDesign*> cell2OAdesign){
for (map<const Cell*, oaDesign*>::iterator it = cell2OAdesign.begin(); for (map<const Cell*, oaDesign*>::iterator it = cell2OAdesign.begin();
it != cell2OAdesign.end(); it != cell2OAdesign.end();
++it) { ++it) {
@ -213,7 +213,7 @@ namespace {
/** /**
print the oaLayera in a oaTech ... print the oaLayera in a oaTech ...
*/ */
void printOALayers(oaTech* theOATech){ inline void printOALayers(oaTech* theOATech){
cerr << "printOALayers" << endl; cerr << "printOALayers" << endl;
assert(theOATech); assert(theOATech);
oaIter<oaLayer> lIter(theOATech->getLayers()); oaIter<oaLayer> lIter(theOATech->getLayers());
@ -227,7 +227,7 @@ namespace {
/** /**
@todo complete,verify ... @todo complete,verify ...
*/ */
BasicLayer::Material::Code oaMaterialToBasicLayerType(const oaMaterial& material) { inline BasicLayer::Material::Code oaMaterialToBasicLayerType(const oaMaterial& material) {
switch(material) { switch(material) {
case oacNWellMaterial: case oacNWellMaterial:
return BasicLayer::Material::nWell; return BasicLayer::Material::nWell;
@ -249,6 +249,70 @@ namespace {
} }
} }
/**
generate info from library name
*/
inline pair<oaScalarName,string> 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<oaScalarName,string>(scNameLib,strPathLib);
}
/**
open oaLib with the info gathered by libPath function
*/
inline oaLib* openOALib(const pair<oaScalarName,string>& 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<oaScalarName,string>& 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 }//end anonymous namespace

View File

@ -38,22 +38,22 @@ namespace {
void testCell(Cell* dev,char* pathToTest){ void testCell(Cell* dev,char* pathToTest){
if(dev){ if(dev){
cout << "Cell created" << endl; cerr << "Cell created" << endl;
}else{ }else{
cout << "Cell not created" << endl; cerr << "Cell not created" << endl;
return; return;
} }
system((string("mkdir -p ") + string(pathToTest)).c_str()); system((string("mkdir -p ") + string(pathToTest)).c_str());
cout << "driving GDS" << endl; /* cerr << "driving GDS" << endl;
GdsDriver(dev).save(string(pathToTest) + "/GDSdrive"); GdsDriver(dev).save(string(pathToTest) + "/GDSdrive");
*/
cout << "driving OA" << endl; cerr << "driving OA" << endl;
OADriver(dev).save(string(pathToTest) + "/OAdrive"); OADriver(dev).save(string(pathToTest) + "/OAdrive");
} }
void testAnalog(char* pathToConf,char* pathToTest){ void testAnalog(char* pathToConf,char* pathToTest){
AnalogEnv::create(pathToConf);//create Database ... 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(); DataBase* db = DataBase::getDB();
assert(db != NULL); assert(db != NULL);
Library* rootLib = db->getRootLibrary(); Library* rootLib = db->getRootLibrary();
@ -73,25 +73,25 @@ void testAnalog(char* pathToConf,char* pathToTest){
design = Cell::create(workLibrary, designName); design = Cell::create(workLibrary, designName);
assert(design != NULL); assert(design != NULL);
cout << "creating cell myCM" << endl; cerr << "creating cell myCM" << endl;
bool bulkConnected = true;//bulk connected to source bool bulkConnected = true;//bulk connected to source
Cell* dev = SimpleCurrentMirror::create(workLibrary, Name("myCM"), Cell* dev = SimpleCurrentMirror::create(workLibrary, Name("myCM"),
TransistorFamily::NMOS, TransistorFamily::NMOS,
bulkConnected); bulkConnected);
cout << "testing cell myCM" << endl; cerr << "testing cell myCM" << endl;
testCell(dev,pathToTest); testCell(dev,pathToTest);
db->destroy(); db->destroy();
} }
void testNum(char* pathToConf,char* pathToTest){ void testNum(char* pathToConf,char* pathToTest,char* cellName){
cout << "creating cell from sxlib inv_x1" << endl; cerr << "creating cell from sxlib " << cellName << endl;
dbo_ptr<DataBase> db ( DataBase::create() ); DataBase* db = DataBase::getDB();
dbo_ptr<AllianceFramework> af ( AllianceFramework::create() ); AllianceFramework* af = AllianceFramework::get();
Cell* cell = NULL; Cell* cell = NULL;
cell = af->getCell("inv_x1", Catalog::State::Views ); cell = af->getCell(cellName, Catalog::State::Views );
cout << "testing cell from sxlib inv_x1" << endl; cerr << "testing cell from sxlib "<< cellName << endl;
testCell(cell,pathToTest); testCell(cell,pathToTest);
} }
@ -99,9 +99,104 @@ int main(int argc,char** argv) {
if(argc != 3) if(argc != 3)
exit(-5); exit(-5);
// testAnalog(argv[1],argv[2]); testAnalog(argv[1],argv[2]);
testNum(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; return 0;
} }