add Net::Type conversion and more ...

This commit is contained in:
Jean-Manuel Caba 2010-07-06 15:40:11 +00:00
parent 90527e4533
commit 5fb64e6da5
1 changed files with 142 additions and 70 deletions

View File

@ -1,5 +1,5 @@
// -*-compile-command:"cd ../../../../.. && make"-*- // -*-compile-command:"cd ../../../../.. && make"-*-
// Time-stamp: "2010-07-05 17:13:52" - OpenAccessWrapper.cpp // Time-stamp: "2010-07-06 17:24:31" - 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 |
@ -28,11 +28,17 @@ using namespace Hurricane;
#include "OpenAccessWrapper.h" #include "OpenAccessWrapper.h"
#define assert(cond) if (! (cond) ) throw Error("assertion failed")
//#define assert(cond)
namespace { namespace {
#ifdef HAVE_OPENACCESS #ifdef HAVE_OPENACCESS
oaString getDesignName(oaDesign* design) { oaString getDesignName(oaDesign* design) {
cerr << "getDesignName" << endl;
assert(design);
oaNativeNS ns; oaNativeNS ns;
oaString libName, cellName, viewName; oaString libName, cellName, viewName;
design->getLibName(ns, libName); design->getLibName(ns, libName);
@ -44,6 +50,7 @@ namespace {
void printBlockTerms(oaBlock* block) { void printBlockTerms(oaBlock* block) {
cerr << "printBlockTerms" << endl; cerr << "printBlockTerms" << endl;
assert(block);
oaNativeNS ns; oaNativeNS ns;
oaDesign* design = block->getDesign(); oaDesign* design = block->getDesign();
cerr << " o Printing " << getDesignName(design) << " terms" << endl; cerr << " o Printing " << getDesignName(design) << " terms" << endl;
@ -56,7 +63,32 @@ namespace {
cerr << endl; cerr << endl;
} }
/**
@todo verify
*/
oaMaterial getOAMaterial(const BasicLayer::Material& material) {
cerr << "getOAMaterial" << endl;
switch ( material.getCode() ) {
case BasicLayer::Material::nWell: return oacNWellMaterial;
case BasicLayer::Material::pWell: return oacPWellMaterial;
case BasicLayer::Material::nImplant: return oacNImplantMaterial;
case BasicLayer::Material::pImplant: return oacPImplantMaterial;
case BasicLayer::Material::active: return oacOtherMaterial;//is it OK?
case BasicLayer::Material::poly: return oacPolyMaterial;
case BasicLayer::Material::cut: return oacCutMaterial;
case BasicLayer::Material::metal: return oacMetalMaterial;
case BasicLayer::Material::blockage: return oacOtherMaterial;//is it OK?
case BasicLayer::Material::other: return oacOtherMaterial;
default:
throw Error("Unrecognized material");
}
}
/**
@todo verify
*/
oaTermType getOATermType(const Net::Direction& direction) { oaTermType getOATermType(const Net::Direction& direction) {
cerr << "getOATermType" << endl;
switch (direction) { switch (direction) {
case Net::Direction::IN: case Net::Direction::IN:
return oacInputTermType; return oacInputTermType;
@ -69,12 +101,33 @@ namespace {
case Net::Direction::UNDEFINED: case Net::Direction::UNDEFINED:
return oacUnusedTermType;// is it OK ? return oacUnusedTermType;// is it OK ?
default: default:
throw Error("unrecognized direction"); throw Error("Unrecognized direction");
}
}
/**
@todo verify
*/
oaSigType getOASigType(const Net::Type& type) {
cerr << "getOASigType" << endl;
switch (type.getCode()) {
case Net::Type::LOGICAL:
return oacSignalSigType;
case Net::Type::CLOCK:
return oacClockSigType;
case Net::Type::POWER:
return oacPowerSigType;
case Net::Type::GROUND:
return oacGroundSigType;
case Net::Type::UNDEFINED:
return oacAnalogSigType;// is it OK ?
default:
throw Error("Unrecognized net type");
} }
} }
oaOrient getOAOrientFromOrientation(const Transformation::Orientation& orientation) { oaOrient getOAOrientFromOrientation(const Transformation::Orientation& orientation) {
cerr << orientation << endl; cerr << "getOAOrientFromOrientation" << endl;
switch (orientation) { switch (orientation) {
case Transformation::Orientation::ID: case Transformation::Orientation::ID:
return oacR0; return oacR0;
@ -98,17 +151,21 @@ namespace {
} }
void getOATransformFromTransformation(oaTransform& transform, const Transformation& transformation) { void getOATransformFromTransformation(oaTransform& transform, const Transformation& transformation) {
cerr << "getOATransformFromTransformation" << endl;
transform.set(transformation.getTx(), transform.set(transformation.getTx(),
transformation.getTy(), transformation.getTy(),
getOAOrientFromOrientation(transformation.getOrientation())); getOAOrientFromOrientation(transformation.getOrientation()));
} }
void getOABoxForBox(oaBox& box, const Box& hbox) { void getOABoxForBox(oaBox& box, const Box& hbox) {
cerr << "getOABoxForBox" << endl;
box.set(hbox.getXMin(), hbox.getYMin(), hbox.getXMax(), hbox.getYMax()); box.set(hbox.getXMin(), hbox.getYMin(), hbox.getXMax(), hbox.getYMax());
} }
oaInstTerm* getInstTerm(oaInst* inst, Plug* plug) { oaInstTerm* getInstTerm(oaInst* inst, Plug* plug) {
cerr << "getInstTerm" << endl; cerr << "getInstTerm" << endl;
assert(inst);
assert(plug);
oaNativeNS ns; oaNativeNS ns;
oaScalarName scPlugName(ns, getString(plug->getMasterNet()->getName()).c_str()); oaScalarName scPlugName(ns, getString(plug->getMasterNet()->getName()).c_str());
oaName instTermName(scPlugName); oaName instTermName(scPlugName);
@ -137,9 +194,9 @@ namespace {
string _path; string _path;
oaTech* _oaTech; oaTech* _oaTech;
oaBlock* _oaBlock;
Library2OALibMap _library2OALibMap; Library2OALibMap _library2OALibMap;
Cell2OADesignMap _cell2OADesignMap; Cell2OADesignMap _cell2OADesign4SchematicMap;
Cell2OADesignMap _cell2OADesign4LayoutMap;
Instance2OAInstsMap _instance2OAInstMap; Instance2OAInstsMap _instance2OAInstMap;
Layer2OAPhysicalLayerMap _layer2OAPhysicalLayerMap; Layer2OAPhysicalLayerMap _layer2OAPhysicalLayerMap;
DataBase* _db; DataBase* _db;
@ -148,9 +205,9 @@ namespace {
OADriver(const string& path): OADriver(const string& path):
_path(path), _path(path),
_oaTech(NULL), _oaTech(NULL),
_oaBlock(NULL),
_library2OALibMap(), _library2OALibMap(),
_cell2OADesignMap(), _cell2OADesign4SchematicMap(),
_cell2OADesign4LayoutMap(),
_instance2OAInstMap(), _instance2OAInstMap(),
_layer2OAPhysicalLayerMap(), _layer2OAPhysicalLayerMap(),
_db(NULL), _db(NULL),
@ -166,15 +223,25 @@ namespace {
} }
~OADriver() { ~OADriver() {
cerr << "SAVING ALL" << endl; cerr << "SAVING ALL" << endl;
for (Cell2OADesignMap::iterator it = _cell2OADesignMap.begin(); for (Cell2OADesignMap::iterator it = _cell2OADesign4SchematicMap.begin();
it != _cell2OADesignMap.end(); it != _cell2OADesign4SchematicMap.end();
++it) { ++it) {
cerr << it->first << endl; cerr << it->first << endl;
oaDesign* design = it->second; oaDesign* design = it->second;
design->save(); design->save();
design->close(); design->close();
} }
for (Cell2OADesignMap::iterator it = _cell2OADesign4LayoutMap.begin();
it != _cell2OADesign4LayoutMap.end();
++it) {
cerr << it->first << endl;
oaDesign* design = it->second;
design->save();
design->close();
}
_oaTech->save();
_oaTech->close();
for (Library2OALibMap::iterator it = _library2OALibMap.begin(); for (Library2OALibMap::iterator it = _library2OALibMap.begin();
it != _library2OALibMap.end(); it != _library2OALibMap.end();
++it) { ++it) {
@ -185,6 +252,7 @@ namespace {
} }
oaLib* getOALibForLibrary(const Library* library) { oaLib* getOALibForLibrary(const Library* library) {
cerr << "getOALibForLibrary" << endl;
Library2OALibMap::iterator it = _library2OALibMap.find(library); Library2OALibMap::iterator it = _library2OALibMap.find(library);
if (it != _library2OALibMap.end()) { if (it != _library2OALibMap.end()) {
return it->second; return it->second;
@ -200,61 +268,51 @@ namespace {
cerr << "Creating new Library for Lib name=" cerr << "Creating new Library for Lib name="
<< strNameLib << " to filesystem path=" << strPathLib << endl; << strNameLib << " to filesystem path=" << strPathLib << endl;
string cmd = "rm -rf "+strPathLib+"; mkdir -p "+strPathLib; oaLib *lib = oaLib::find(scNameLib);
system(cmd.c_str()); if (!lib) {
oaLib* lib = oaLib::create(scNameLib, strPathLib.c_str(), oacSharedLibMode, "oaDMFileSys"); if (oaLib::exists(strPathLib.c_str())){
lib = oaLib::open(scNameLib, strPathLib.c_str());
}
// string cmd = "rm -rf "+strPathLib+"; mkdir -p "+strPathLib;
// system(cmd.c_str());
// oaLib* lib = oaLib::create(scNameLib, strPathLib.c_str(), oacSharedLibMode, "oaDMFileSys");
if(!lib)
lib = oaLib::create(scNameLib, strPathLib.c_str());
}
assert(lib); assert(lib);
assert(lib->isValid()); assert(lib->isValid());
assert(_oaTech == NULL); if(!_oaTech)
_oaTech = createOATechForTechnology(_technology,lib); _oaTech = createOATechForTechnology(_technology,lib);
assert(_oaTech);
_library2OALibMap[library] = lib; _library2OALibMap[library] = lib;
return lib; return lib;
} }
/**
@todo verify
*/
oaMaterial basicLayerMaterial2oaMaterial(const BasicLayer::Material& material){
switch ( material.getCode() ) {
case BasicLayer::Material::nWell: return oacNWellMaterial;
case BasicLayer::Material::pWell: return oacPWellMaterial;
case BasicLayer::Material::nImplant: return oacNImplantMaterial;
case BasicLayer::Material::pImplant: return oacPImplantMaterial;
case BasicLayer::Material::active: return oacOtherMaterial;//is it OK?
case BasicLayer::Material::poly: return oacPolyMaterial;
case BasicLayer::Material::cut: return oacCutMaterial;
case BasicLayer::Material::metal: return oacMetalMaterial;
case BasicLayer::Material::blockage: return oacOtherMaterial;//is it OK?
case BasicLayer::Material::other: return oacOtherMaterial;
}
throw Error("ERROR : unknow Material");
return oacOtherMaterial;
}
/** /**
@todo complete with technology info for layers @todo complete with technology info for layers
*/ */
oaTech* createOATechForTechnology(const Technology* technology,oaLib* lib) { oaTech* createOATechForTechnology(const Technology* technology,oaLib* lib) {
oaTech* oaTech = oaTech::create(lib); cerr << "createOATechForTechnology" << endl;
oaTech->setDefaultManufacturingGrid(10); oaTech* theOATech = oaTech::create(lib);
oaTech->setDBUPerUU(oaViewType::get(oacMaskLayout), 1000); theOATech->setDefaultManufacturingGrid(10);
theOATech->setDBUPerUU(oaViewType::get(oacMaskLayout), 1000);
int layerID=0; int layerID=0;
for_each_layer(layer, technology->getLayers()) { for_each_layer(layer, technology->getLayers()) {
oaString layerName = getString(layer->getName()).c_str(); oaString layerName = getString(layer->getName()).c_str();
oaPhysicalLayer* oaLayer = NULL; oaPhysicalLayer* aOALayer = NULL;
{ BasicLayer* bLayer = dynamic_cast<BasicLayer*>(layer);
BasicLayer* bLayer = dynamic_cast<BasicLayer*>(layer); if(bLayer)
if(bLayer) aOALayer = oaPhysicalLayer::create(theOATech, layerName, layerID++,getOAMaterial(bLayer->getMaterial()));
oaLayer = oaPhysicalLayer::create(oaTech, layerName, layerID++,basicLayerMaterial2oaMaterial(bLayer->getMaterial())); else
else aOALayer = oaPhysicalLayer::create(theOATech, layerName, layerID++);
oaLayer = oaPhysicalLayer::create(oaTech, layerName, layerID++); assert(aOALayer);
}
assert(oaLayer); _layer2OAPhysicalLayerMap[layer] = aOALayer;
_layer2OAPhysicalLayerMap[layer] = oaLayer;
DbU::Unit minSize = layer->getMinimalSize(); DbU::Unit minSize = layer->getMinimalSize();
DbU::Unit minSpace = layer->getMinimalSpacing(); DbU::Unit minSpace = layer->getMinimalSpacing();
DbU::Unit pitch = layer->getPitch(); DbU::Unit pitch = layer->getPitch();
@ -270,50 +328,58 @@ namespace {
end_for; end_for;
} }
assert(oaTech != NULL); assert(theOATech != NULL);
return oaTech; oaIter<oaLayer> lIter(theOATech->getLayers());
while(oaLayer* l = lIter.getNext()){
oaString layerName;
l->getName(layerName);
cerr << " o created oaLayer " << layerName << endl;
}
return theOATech;
} }
oaDesign* getOADesignForCell(const Cell* cell) { oaDesign* getOADesignForCell(const Cell* cell) {
cerr << "getOADesignForCell " << cell << endl; cerr << "getOADesignForCell " << cell << endl;
Cell2OADesignMap::iterator it = _cell2OADesignMap.find(cell); assert(cell);
if (it != _cell2OADesignMap.end()) { Cell2OADesignMap::iterator it = _cell2OADesign4SchematicMap.find(cell);
if (it != _cell2OADesign4SchematicMap.end()) {
return it->second; return it->second;
} }
oaNativeNS ns; oaNativeNS ns;
cerr << "getOALibForLibrary" << endl;
oaLib* lib = getOALibForLibrary(cell->getLibrary()); oaLib* lib = getOALibForLibrary(cell->getLibrary());
assert(lib);
assert(_oaTech);
oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); oaScalarName scNameDesign(ns, getString(cell->getName()).c_str());
oaScalarName scNameViewSchematic(ns, "schematic"); oaScalarName scNameViewSchematic(ns, "schematic");
oaScalarName scNameView(ns, "layout"); oaScalarName scNameViewLayout(ns, "layout");
oaScalarName scNameLib; oaScalarName scNameLib;
lib->getName(scNameLib); lib->getName(scNameLib);
oaDesign* designSch = oaDesign::open(scNameLib, scNameDesign, scNameViewSchematic, oaViewType::get(oacSchematic), 'w'); oaDesign* design4Schematic = oaDesign::open(scNameLib, scNameDesign, scNameViewSchematic, oaViewType::get(oacSchematic), 'w');
oaDesign* design = oaDesign::open(scNameLib, scNameDesign, scNameView, oaViewType::get(oacMaskLayout), 'w'); _cell2OADesign4SchematicMap[cell] = design4Schematic;
oaBlock* block = oaBlock::create(design); oaBlock* designBlock4Layout = oaBlock::create(design4Schematic);
cerr << "transformation of instance" << endl; cerr << "transformation of instances" << endl;
for_each_instance(instance, cell->getInstances()) { for_each_instance(instance, cell->getInstances()) {
Cell* masterCell = instance->getMasterCell(); Cell* masterCell = instance->getMasterCell();
oaDesign* masterDesign = getOADesignForCell(masterCell); oaDesign* masterDesign = getOADesignForCell(masterCell);
oaScalarName scDesignName; oaScalarName scMasterName;
masterDesign->getCellName(scDesignName); masterDesign->getCellName(scMasterName);
oaString strDesignName; oaString strMasterName;
scDesignName.get(strDesignName); scMasterName.get(strMasterName);
oaScalarName scInstName(ns, getString(instance->getName()).c_str()); oaScalarName scInstName(ns, getString(instance->getName()).c_str());
oaTransform transform; oaTransform transform;
getOATransformFromTransformation(transform, instance->getTransformation()); getOATransformFromTransformation(transform, instance->getTransformation());
oaScalarInst* blockInst = oaScalarInst::create(block, masterDesign, scInstName, transform); oaScalarInst* blockInst = oaScalarInst::create(designBlock4Layout, masterDesign, scInstName, transform);
_instance2OAInstMap[instance] = blockInst; _instance2OAInstMap[instance] = blockInst;
end_for; end_for;
} }
cerr << "transformation of net" << endl; cerr << "transformation of nets" << endl;
for_each_net(net, cell->getNets()) { for_each_net(net, cell->getNets()) {
oaScalarName scNetName(ns, getString(net->getName()).c_str()); oaScalarName scNetName(ns, getString(net->getName()).c_str());
oaScalarNet* blockNet = oaScalarNet::create(block, scNetName, oacAnalogSigType); oaScalarNet* blockNet = oaScalarNet::create(designBlock4Layout, scNetName, getOASigType(net->getType()));
if (net->isExternal()) { if (net->isExternal()) {
oaTerm* term = oaTerm::create(blockNet, scNetName, getOATermType(net->getDirection())); oaTerm* term = oaTerm::create(blockNet, scNetName, getOATermType(net->getDirection()));
oaPin* pin = oaPin::create(term); oaPin* pin = oaPin::create(term);
@ -321,14 +387,14 @@ namespace {
for_each_component(component, externalComponents) { for_each_component(component, externalComponents) {
oaBox box; oaBox box;
getOABoxForBox(box, component->getBoundingBox()); getOABoxForBox(box, component->getBoundingBox());
oaRect* rect = oaRect::create(block, 0, oaRect* rect = oaRect::create(designBlock4Layout, 0,
oaPurpose::get(_oaTech, oacDrawingPurposeType)->getNumber(), oaPurpose::get(_oaTech, oacDrawingPurposeType)->getNumber(),
box); box);
rect->addToPin(pin); rect->addToPin(pin);
end_for; end_for;
} }
} }
cerr << "transformation of plug" << endl; cerr << " o transformation of plugs" << endl;
for_each_plug(plug, net->getPlugs()) { for_each_plug(plug, net->getPlugs()) {
Instance* instance = plug->getInstance(); Instance* instance = plug->getInstance();
Instance2OAInstsMap::iterator it = _instance2OAInstMap.find(instance); Instance2OAInstsMap::iterator it = _instance2OAInstMap.find(instance);
@ -341,8 +407,14 @@ namespace {
} }
end_for; end_for;
} }
_cell2OADesignMap[cell] = design; // create a Layout View of the design
return design; oaDesign* design4Layout = oaDesign::open(scNameLib, scNameDesign, scNameViewLayout, oaViewType::get(oacMaskLayout), 'w');
_cell2OADesign4LayoutMap[cell] = design4Layout;
if(design4Layout == design4Schematic)
cerr << "design4Layout == design4Schematic" << endl;
else
cerr << "design4Layout != design4Schematic" << endl;
return design4Schematic;
} }
}; };
#endif #endif
@ -363,7 +435,7 @@ namespace CRL {
OADriver oaDriver(path); OADriver oaDriver(path);
oaDesign* design = oaDriver.getOADesignForCell(cell); oaDesign* design = oaDriver.getOADesignForCell(cell);
if(design) if(design)
cerr << getDesignName(design) << endl; cerr << "DONE ->" << getDesignName(design) << endl;
} catch (oaException &excp) { } catch (oaException &excp) {
cerr << "ERROR: " << excp.getMsg() << endl; cerr << "ERROR: " << excp.getMsg() << endl;
exit(1); exit(1);