From 5fb64e6da5e2bf55605f57f7a9fec9dd728c9caf Mon Sep 17 00:00:00 2001 From: Jean-Manuel Caba Date: Tue, 6 Jul 2010 15:40:11 +0000 Subject: [PATCH] add Net::Type conversion and more ... --- .../ccore/openaccess/OpenAccessWrapper.cpp | 212 ++++++++++++------ 1 file changed, 142 insertions(+), 70 deletions(-) diff --git a/crlcore/src/ccore/openaccess/OpenAccessWrapper.cpp b/crlcore/src/ccore/openaccess/OpenAccessWrapper.cpp index 03781f57..0364271c 100644 --- a/crlcore/src/ccore/openaccess/OpenAccessWrapper.cpp +++ b/crlcore/src/ccore/openaccess/OpenAccessWrapper.cpp @@ -1,5 +1,5 @@ // -*-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 // | This file is part of the hurricaneAMS Software. | // | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | @@ -28,11 +28,17 @@ using namespace Hurricane; #include "OpenAccessWrapper.h" +#define assert(cond) if (! (cond) ) throw Error("assertion failed") +//#define assert(cond) + + namespace { #ifdef HAVE_OPENACCESS oaString getDesignName(oaDesign* design) { + cerr << "getDesignName" << endl; + assert(design); oaNativeNS ns; oaString libName, cellName, viewName; design->getLibName(ns, libName); @@ -44,6 +50,7 @@ namespace { void printBlockTerms(oaBlock* block) { cerr << "printBlockTerms" << endl; + assert(block); oaNativeNS ns; oaDesign* design = block->getDesign(); cerr << " o Printing " << getDesignName(design) << " terms" << endl; @@ -56,7 +63,32 @@ namespace { 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) { + cerr << "getOATermType" << endl; switch (direction) { case Net::Direction::IN: return oacInputTermType; @@ -69,12 +101,33 @@ namespace { case Net::Direction::UNDEFINED: return oacUnusedTermType;// is it OK ? 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) { - cerr << orientation << endl; + cerr << "getOAOrientFromOrientation" << endl; switch (orientation) { case Transformation::Orientation::ID: return oacR0; @@ -98,17 +151,21 @@ namespace { } void getOATransformFromTransformation(oaTransform& transform, const Transformation& transformation) { + cerr << "getOATransformFromTransformation" << endl; transform.set(transformation.getTx(), transformation.getTy(), getOAOrientFromOrientation(transformation.getOrientation())); } void getOABoxForBox(oaBox& box, const Box& hbox) { + cerr << "getOABoxForBox" << endl; box.set(hbox.getXMin(), hbox.getYMin(), hbox.getXMax(), hbox.getYMax()); } oaInstTerm* getInstTerm(oaInst* inst, Plug* plug) { cerr << "getInstTerm" << endl; + assert(inst); + assert(plug); oaNativeNS ns; oaScalarName scPlugName(ns, getString(plug->getMasterNet()->getName()).c_str()); oaName instTermName(scPlugName); @@ -137,9 +194,9 @@ namespace { string _path; oaTech* _oaTech; - oaBlock* _oaBlock; Library2OALibMap _library2OALibMap; - Cell2OADesignMap _cell2OADesignMap; + Cell2OADesignMap _cell2OADesign4SchematicMap; + Cell2OADesignMap _cell2OADesign4LayoutMap; Instance2OAInstsMap _instance2OAInstMap; Layer2OAPhysicalLayerMap _layer2OAPhysicalLayerMap; DataBase* _db; @@ -148,9 +205,9 @@ namespace { OADriver(const string& path): _path(path), _oaTech(NULL), - _oaBlock(NULL), _library2OALibMap(), - _cell2OADesignMap(), + _cell2OADesign4SchematicMap(), + _cell2OADesign4LayoutMap(), _instance2OAInstMap(), _layer2OAPhysicalLayerMap(), _db(NULL), @@ -166,15 +223,25 @@ namespace { } ~OADriver() { - cerr << "SAVING ALL" << endl; - for (Cell2OADesignMap::iterator it = _cell2OADesignMap.begin(); - it != _cell2OADesignMap.end(); + cerr << "SAVING ALL" << endl; + for (Cell2OADesignMap::iterator it = _cell2OADesign4SchematicMap.begin(); + it != _cell2OADesign4SchematicMap.end(); ++it) { cerr << it->first << endl; oaDesign* design = it->second; design->save(); 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(); it != _library2OALibMap.end(); ++it) { @@ -185,6 +252,7 @@ namespace { } oaLib* getOALibForLibrary(const Library* library) { + cerr << "getOALibForLibrary" << endl; Library2OALibMap::iterator it = _library2OALibMap.find(library); if (it != _library2OALibMap.end()) { return it->second; @@ -200,61 +268,51 @@ namespace { cerr << "Creating new Library for Lib name=" << strNameLib << " to filesystem path=" << strPathLib << endl; - string cmd = "rm -rf "+strPathLib+"; mkdir -p "+strPathLib; - system(cmd.c_str()); - oaLib* lib = oaLib::create(scNameLib, strPathLib.c_str(), oacSharedLibMode, "oaDMFileSys"); + oaLib *lib = oaLib::find(scNameLib); + if (!lib) { + 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->isValid()); - assert(_oaTech == NULL); - _oaTech = createOATechForTechnology(_technology,lib); + if(!_oaTech) + _oaTech = createOATechForTechnology(_technology,lib); + + assert(_oaTech); _library2OALibMap[library] = 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 */ oaTech* createOATechForTechnology(const Technology* technology,oaLib* lib) { - oaTech* oaTech = oaTech::create(lib); - oaTech->setDefaultManufacturingGrid(10); - oaTech->setDBUPerUU(oaViewType::get(oacMaskLayout), 1000); + cerr << "createOATechForTechnology" << endl; + oaTech* theOATech = oaTech::create(lib); + theOATech->setDefaultManufacturingGrid(10); + theOATech->setDBUPerUU(oaViewType::get(oacMaskLayout), 1000); int layerID=0; for_each_layer(layer, technology->getLayers()) { oaString layerName = getString(layer->getName()).c_str(); - oaPhysicalLayer* oaLayer = NULL; - { - BasicLayer* bLayer = dynamic_cast(layer); - if(bLayer) - oaLayer = oaPhysicalLayer::create(oaTech, layerName, layerID++,basicLayerMaterial2oaMaterial(bLayer->getMaterial())); - else - oaLayer = oaPhysicalLayer::create(oaTech, layerName, layerID++); - } - assert(oaLayer); - _layer2OAPhysicalLayerMap[layer] = oaLayer; + oaPhysicalLayer* aOALayer = NULL; + BasicLayer* bLayer = dynamic_cast(layer); + if(bLayer) + aOALayer = oaPhysicalLayer::create(theOATech, layerName, layerID++,getOAMaterial(bLayer->getMaterial())); + else + aOALayer = oaPhysicalLayer::create(theOATech, layerName, layerID++); + assert(aOALayer); + + _layer2OAPhysicalLayerMap[layer] = aOALayer; DbU::Unit minSize = layer->getMinimalSize(); DbU::Unit minSpace = layer->getMinimalSpacing(); DbU::Unit pitch = layer->getPitch(); @@ -270,50 +328,58 @@ namespace { end_for; } - assert(oaTech != NULL); - return oaTech; + assert(theOATech != NULL); + oaIter 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) { cerr << "getOADesignForCell " << cell << endl; - Cell2OADesignMap::iterator it = _cell2OADesignMap.find(cell); - if (it != _cell2OADesignMap.end()) { + assert(cell); + Cell2OADesignMap::iterator it = _cell2OADesign4SchematicMap.find(cell); + if (it != _cell2OADesign4SchematicMap.end()) { return it->second; } oaNativeNS ns; - cerr << "getOALibForLibrary" << endl; oaLib* lib = getOALibForLibrary(cell->getLibrary()); + assert(lib); + assert(_oaTech); oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); oaScalarName scNameViewSchematic(ns, "schematic"); - oaScalarName scNameView(ns, "layout"); + oaScalarName scNameViewLayout(ns, "layout"); oaScalarName scNameLib; lib->getName(scNameLib); - oaDesign* designSch = oaDesign::open(scNameLib, scNameDesign, scNameViewSchematic, oaViewType::get(oacSchematic), 'w'); - oaDesign* design = oaDesign::open(scNameLib, scNameDesign, scNameView, oaViewType::get(oacMaskLayout), 'w'); - oaBlock* block = oaBlock::create(design); + oaDesign* design4Schematic = oaDesign::open(scNameLib, scNameDesign, scNameViewSchematic, oaViewType::get(oacSchematic), 'w'); + _cell2OADesign4SchematicMap[cell] = design4Schematic; + oaBlock* designBlock4Layout = oaBlock::create(design4Schematic); - cerr << "transformation of instance" << endl; + cerr << "transformation of instances" << endl; for_each_instance(instance, cell->getInstances()) { Cell* masterCell = instance->getMasterCell(); oaDesign* masterDesign = getOADesignForCell(masterCell); - oaScalarName scDesignName; - masterDesign->getCellName(scDesignName); - oaString strDesignName; - scDesignName.get(strDesignName); + oaScalarName scMasterName; + masterDesign->getCellName(scMasterName); + oaString strMasterName; + scMasterName.get(strMasterName); oaScalarName scInstName(ns, getString(instance->getName()).c_str()); oaTransform transform; getOATransformFromTransformation(transform, instance->getTransformation()); - oaScalarInst* blockInst = oaScalarInst::create(block, masterDesign, scInstName, transform); + oaScalarInst* blockInst = oaScalarInst::create(designBlock4Layout, masterDesign, scInstName, transform); _instance2OAInstMap[instance] = blockInst; end_for; } - cerr << "transformation of net" << endl; + cerr << "transformation of nets" << endl; for_each_net(net, cell->getNets()) { 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()) { oaTerm* term = oaTerm::create(blockNet, scNetName, getOATermType(net->getDirection())); oaPin* pin = oaPin::create(term); @@ -321,14 +387,14 @@ namespace { for_each_component(component, externalComponents) { oaBox box; getOABoxForBox(box, component->getBoundingBox()); - oaRect* rect = oaRect::create(block, 0, + oaRect* rect = oaRect::create(designBlock4Layout, 0, oaPurpose::get(_oaTech, oacDrawingPurposeType)->getNumber(), box); rect->addToPin(pin); end_for; } } - cerr << "transformation of plug" << endl; + cerr << " o transformation of plugs" << endl; for_each_plug(plug, net->getPlugs()) { Instance* instance = plug->getInstance(); Instance2OAInstsMap::iterator it = _instance2OAInstMap.find(instance); @@ -341,8 +407,14 @@ namespace { } end_for; } - _cell2OADesignMap[cell] = design; - return design; + // create a Layout View of the 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 @@ -363,7 +435,7 @@ namespace CRL { OADriver oaDriver(path); oaDesign* design = oaDriver.getOADesignForCell(cell); if(design) - cerr << getDesignName(design) << endl; + cerr << "DONE ->" << getDesignName(design) << endl; } catch (oaException &excp) { cerr << "ERROR: " << excp.getMsg() << endl; exit(1);