From 3d09907286dfac74e06bc45a269d6d0097486547 Mon Sep 17 00:00:00 2001 From: Jean-Manuel Caba Date: Tue, 17 Aug 2010 11:09:26 +0000 Subject: [PATCH] oaPinFig and oaVia creation ... --- .../src/ccore/openaccess/OpenAccessCommon.h | 2 +- .../src/ccore/openaccess/OpenAccessDriver.cpp | 1146 +++++++++-------- .../ccore/openaccess/testDriver/src/main.cpp | 4 +- 3 files changed, 597 insertions(+), 555 deletions(-) diff --git a/crlcore/src/ccore/openaccess/OpenAccessCommon.h b/crlcore/src/ccore/openaccess/OpenAccessCommon.h index 8a7d503e..6d9fa8dd 100644 --- a/crlcore/src/ccore/openaccess/OpenAccessCommon.h +++ b/crlcore/src/ccore/openaccess/OpenAccessCommon.h @@ -1,5 +1,5 @@ // -*-compile-command:"cd ../../../../.. && make"-*- -// Time-stamp: "2010-08-12 23:50:52" - OpenAccessCommon.h +// Time-stamp: "2010-08-16 16:52:02" - OpenAccessCommon.h // x-----------------------------------------------------------------x // | This file is part of the hurricaneAMS Software. | // | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | diff --git a/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp b/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp index f98dde9c..2c7bec12 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-08-16 13:05:27" - OpenAccessDriver.cpp +// Time-stamp: "2010-08-17 13:07:48" - OpenAccessDriver.cpp // x-----------------------------------------------------------------x // | This file is part of the hurricaneAMS Software. | // | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | @@ -27,6 +27,7 @@ using namespace std; #include "hurricane/Instance.h" #include "hurricane/Component.h" #include "hurricane/Segment.h" +#include "hurricane/Horizontal.h" #include "hurricane/Vertical.h" #include "hurricane/Pad.h" // Layer @@ -56,9 +57,9 @@ namespace { typedef map Cell2OACellMap; typedef map Instance2OAInstsMap; typedef map Layer2OALayerMap; - typedef map ViaLayer2OAViaDefMap; - typedef map Pad2OARectMap; - typedef map Component2OAPathSegMap; + typedef map ViaLayer2OAViaDefMap; + typedef map Component2OARectMap; + typedef map Segment2OAPathSegMap; string _path; oaTech* _oaTech; @@ -71,8 +72,8 @@ namespace { Instance2OAInstsMap _instance2OAInst; Layer2OALayerMap _layer2OALayer; ViaLayer2OAViaDefMap _viaLayer2OAViaDef; - Pad2OARectMap _pad2OARect; - Component2OAPathSegMap _component2OAPathSeg; + Component2OARectMap _component2OARect; + Segment2OAPathSegMap _segment2OAPathSeg; set _layerIDS; int _layerID; oaLayer* _layerDev; @@ -94,8 +95,8 @@ namespace { _instance2OAInst(), _layer2OALayer(), _viaLayer2OAViaDef(), - _pad2OARect(), - _component2OAPathSeg(), + _component2OARect(), + _segment2OAPathSeg(), _layerIDS(), _layerID(0), _layerDev(NULL), @@ -168,7 +169,6 @@ namespace { end_for; } } - // 4) create, update library list file oaFuncs::createCDS(infos,_path); infos.second.clear(); @@ -229,14 +229,14 @@ namespace { /** helper function technology MUST exist first - */ + */ oaLayerNum toOALayerNum(const Layer* hLayer){ assert(hLayer); oaLayer* layer = toOALayer(hLayer,_oaTech); assert(layer); return layer->getNumber(); } - + /** convert oaLayer from a Layer ... */ @@ -261,8 +261,35 @@ namespace { if(!bLayer){ cerr << "NOT A BASICLAYER " << layerName; const ViaLayer* vLayer = dynamic_cast(layer); - if(vLayer) + if(vLayer){ cerr << " but is a ViaLayer" << endl; + + const Layer* hBottom=vLayer->getBottom(); + const Layer* hTop=vLayer->getTop(); + assert(hBottom); + assert(hTop); + + oaPhysicalLayer* bottom = static_cast(toOALayer(hBottom,theOATech)); + oaPhysicalLayer* top = static_cast(toOALayer(hTop,theOATech)); + oaLayer* cut = NULL; + for_each_basic_layer(l,vLayer->getBasicLayers()){ + if(l != vLayer->getTop() && l != vLayer->getBottom()){ + cut = toOALayer(l,theOATech); + break; + } + end_for; + } + assert(cut); + oaViaParam stdViaDefParam; + stdViaDefParam.setCutLayer(cut->getNumber()); + stdViaDefParam.setCutWidth(Hurricane::DbU::getDb(vLayer->getEnclosure())); + stdViaDefParam.setCutHeight(Hurricane::DbU::getDb(vLayer->getEnclosure())); + oaStdViaDef* vDef = oaStdViaDef::create(theOATech, layerName, + bottom, + top, + stdViaDefParam); + _viaLayer2OAViaDef[vLayer] = vDef; + } const ContactLayer* cLayer = dynamic_cast(layer); if(cLayer) cerr << " but is a ContactLayer" << endl; @@ -280,7 +307,7 @@ namespace { bLayer ? toOAMaterial(bLayer->getMaterial()) : oaMaterial(oacOtherMaterial)); assert(aOALayer); - + _layer2OALayer[layer] = aOALayer; //create and add layer constraint for Layer specific manufacturing rules @@ -303,13 +330,13 @@ namespace { return aOALayer; } - /** - create a oaTech from a Hurricane::Technology in it's Library - also create the oaLib corresponding to the Hurricane::Library - containing the Hurricane::Technology - @todo complete with technology info for layers - @see toOALib - */ + /** + create a oaTech from a Hurricane::Technology in it's Library + also create the oaLib corresponding to the Hurricane::Library + containing the Hurricane::Technology + @todo complete with technology info for layers + @see toOALib + */ oaTech* toOATech(const Technology* technology,const Library* lib) { cerr << "createOATechForTechnology" << endl; assert(technology); @@ -342,12 +369,8 @@ namespace { //create and add foundry constraint group for General manufacturing rules //and add oaSimpleConstraintType too assert(theOATech); - theOATech->getDefaultConstraintGroup(); + theOATech->getDefaultConstraintGroup();//add the constraint group for oa2lef oaConstraintGroup *cgFoundry = theOATech->getFoundryRules(); - - /* - add the constraint group LEFDefaultRouteSpec for oa2lef - */ } // get or create physical layer @@ -388,7 +411,7 @@ namespace { assert(_layerWire); _layerIDS.insert(_layerWire->getNumber()); }catch(oaException&e ){ - cerr << "OA:" << e.getMsg() << endl; + cerr << "OA_TEST:" << e.getMsg() << endl; exit(-2); }catch(std::exception&e ){ cerr << "STD:" << e.what() << endl; @@ -400,580 +423,597 @@ namespace { return theOATech; } - /** - convert the orientation of a transformation - */ - static oaOrient toOAOrient(const Transformation::Orientation& orientation) { - switch (orientation) { - case Transformation::Orientation::ID: - return oacR0; - case Transformation::Orientation::R1: - return oacR90; - case Transformation::Orientation::R2: - return oacR180; - case Transformation::Orientation::R3: - return oacR270; - case Transformation::Orientation::MX: - return oacMX; - case Transformation::Orientation::XR: - return oacMXR90; - case Transformation::Orientation::MY: - return oacMY; - case Transformation::Orientation::YR: - return oacMYR90; - default: - throw Error("Unrecognized orientation"); + /** + convert the orientation of a transformation + */ + static oaOrient toOAOrient(const Transformation::Orientation& orientation) { + switch (orientation) { + case Transformation::Orientation::ID: + return oacR0; + case Transformation::Orientation::R1: + return oacR90; + case Transformation::Orientation::R2: + return oacR180; + case Transformation::Orientation::R3: + return oacR270; + case Transformation::Orientation::MX: + return oacMX; + case Transformation::Orientation::XR: + return oacMXR90; + case Transformation::Orientation::MY: + return oacMY; + case Transformation::Orientation::YR: + return oacMYR90; + default: + throw Error("Unrecognized orientation"); + } } - } - /** - create a oaTransform for instanciation of cells - */ - static oaTransform toOATransform(const Transformation& transformation) { - oaTransform transform; - transform.set(transformation.getTx(), - transformation.getTy(), - toOAOrient(transformation.getOrientation())); - return transform; - } - - /** - convert Hurricane::Instance to oaInst ... - */ - oaInst* toOAInst(Instance* instance,oaBlock* topBlock) { - cerr << "toOAInst " << instance << endl; - assert(instance); - Instance2OAInstsMap::iterator it = _instance2OAInst.find(instance); - if (it != _instance2OAInst.end()) { - return it->second; + /** + create a oaTransform for instanciation of cells + */ + static oaTransform toOATransform(const Transformation& transformation) { + oaTransform transform; + transform.set(transformation.getTx(), + transformation.getTy(), + toOAOrient(transformation.getOrientation())); + return transform; } - assert(topBlock); - // 1) get the master cell for the instance - Cell* masterCell = instance->getMasterCell(); - assert(masterCell); - oaDesign* masterDesign = toOADesign(masterCell); - assert(masterDesign); + /** + convert Hurricane::Instance to oaInst ... + */ + oaInst* toOAInst(Instance* instance,oaBlock* topBlock) { + cerr << "toOAInst " << instance << endl; + assert(instance); + Instance2OAInstsMap::iterator it = _instance2OAInst.find(instance); + if (it != _instance2OAInst.end()) + return it->second; - oaNativeNS ns; - oaScalarName scMasterName; - masterDesign->getCellName(scMasterName); - oaString strMasterName; - scMasterName.get(strMasterName); - oaScalarName scInstName(ns, getString(instance->getName()).c_str()); + // 1) get the master cell for the instance + Cell* masterCell = instance->getMasterCell(); + assert(masterCell); + oaDesign* masterDesign = toOADesign(masterCell); + assert(masterDesign); - - oaScalarInst* blockInst = oaScalarInst::find(topBlock, - scInstName); - if(!blockInst){ - oaTransform transform = toOATransform(instance->getTransformation()); - blockInst = oaScalarInst::create(topBlock, masterDesign, scInstName, transform); + oaNativeNS ns; + oaScalarName scMasterName; + masterDesign->getCellName(scMasterName); + oaString strMasterName; + scMasterName.get(strMasterName); + oaScalarName scInstName(ns, getString( instance->getName()).c_str()); + oaScalarInst* blockInst = oaScalarInst::find(topBlock, + scInstName); + if(!blockInst){ + oaTransform transform = toOATransform(instance->getTransformation()); + blockInst = oaScalarInst::create(topBlock, + masterDesign, scInstName, transform); + } + _instance2OAInst[instance] = blockInst; + return blockInst; } - _instance2OAInst[instance] = blockInst; - return blockInst; - } - /** - convert Hurricane::plug to oaInstTerm - and add it to if connected. - always return a non NULL value - */ - oaInstTerm* toOAInstTerm(Plug* plug,oaNet* net){ - cerr << "toOAInstTerm " << plug << endl; - assert(plug); - Instance* instance = plug->getInstance(); - Instance2OAInstsMap::iterator it = _instance2OAInst.find(instance); - assert(it != _instance2OAInst.end()); - oaInst* blockInst = it->second; + /** + convert Hurricane::plug to oaInstTerm + and add it to if connected. + always return a non NULL value + */ + oaInstTerm* toOAInstTerm(Plug* plug,oaNet* net){ + cerr << "toOAInstTerm " << plug << endl; + assert(plug); + Instance* instance = plug->getInstance(); + Instance2OAInstsMap::iterator it = _instance2OAInst.find(instance); + assert(it != _instance2OAInst.end()); + oaInst* blockInst = it->second; - oaName instTermName(toOAName( getString(plug->getMasterNet()->getName()) )); - oaInstTerm* instTerm = oaInstTerm::find(blockInst, instTermName); - if (instTerm) + oaName instTermName(toOAName( plug->getMasterNet()->getName() )); + oaInstTerm* instTerm = oaInstTerm::find(blockInst, instTermName); + if (instTerm) + return instTerm; + + oaDesign* design = blockInst->getMaster(); + assert(design); + oaBlock* masterBlock = design->getTopBlock(); + oaTerm* term = oaTerm::find(masterBlock, instTermName); + assert(term); + + cerr << "looking for " << plug->getName() << endl; + oaFuncs::printOABlockTerms(masterBlock); + cerr << "oaInstTerm::create" << endl; + instTerm = oaInstTerm::create(net, blockInst, term); + + assert(instTerm); return instTerm; - - oaDesign* design = blockInst->getMaster(); - assert(design); - oaBlock* masterBlock = design->getTopBlock(); - oaTerm* term = oaTerm::find(masterBlock, instTermName); - assert(term); - - cerr << "looking for " << plug->getName() << endl; - oaFuncs::printOABlockTerms(masterBlock); - cerr << "oaInstTerm::create" << endl; - instTerm = oaInstTerm::create(net, blockInst, term); - - assert(instTerm); - return instTerm; - } - - static oaName toOAName(const Name& n){ - oaNativeNS ns; - oaScalarName scN(ns, getString(n).c_str()); - return oaName(scN); - } - - /** - convert to OAPoint - */ - static oaPoint toOAPoint(const Point& p) { - oaPoint point; - point.set(p.getX(), p.getY()); - return point; - } - - /** - convert to OABox - */ - static oaBox toOABox(const Box& b) { - oaBox box; - box.set(b.getXMin(), b.getYMin(), b.getXMax(), b.getYMax()); - return box; - } - - - - /** - Used to convert Pad - */ - oaRect* toOARect(Pad* pad,oaNet* blockNet){ - cerr << "toOARect" << endl; - assert(pad); - assert(blockNet); - - Pad2OARectMap::iterator it = _pad2OARect.find(pad); - if (it != _pad2OARect.end()) - return it->second; - - oaRect* rect = oaRect::create(blockNet->getBlock(), - toOALayerNum( pad->getLayer() ), - oacDrawingPurposeType, - toOABox(pad->getBoundingBox()) ); - return rect; - } - - /** - Used to convert Segment - */ - oaPathSeg* toOAPathSeg(Segment* segment,oaNet* blockNet){ - cerr << "toOAPathSeg" << endl; - assert(segment); - assert(blockNet); - - Component2OAPathSegMap::iterator it = _component2OAPathSeg.find(segment); - if (it != _component2OAPathSeg.end()) - return it->second; - - oaSegStyle style(segment->getWidth(), oacTruncateEndStyle, oacTruncateEndStyle); - oaPathSeg* res = oaPathSeg::create(blockNet->getBlock(), - toOALayerNum( segment->getLayer() ), - oacDrawingPurposeType, - toOAPoint(segment->getSourcePosition()), - toOAPoint(segment->getTargetPosition()), - style); - return res; - } - - /** - Used to convert Pin - */ - oaPin* toOAPin(Pin* hpin,oaNet* blockNet){ - cerr << "toOAPin" << endl; - assert(hpin); - assert(blockNet); - oaName pinName; - blockNet->getName(pinName); - oaString sPinName; - pinName.get(sPinName); - oaTerm* term = oaTerm::find(blockNet->getBlock(), pinName); - assert(term); - oaPin* pin = oaPin::find(term, sPinName); - if(!pin) - pin = oaPin::create(term); - - return pin; - } - - /** - used to convert Via - @todo implement me ... - */ - oaVia* toOAVia(Contact* contact,oaNet* blockNet){ - //TODO -#if 0 - // Get via layers from the technology database oaPhysicalLayer *poly = oaPhysicalLayer::find(tech, "Poly"); - ViaLayer::ViaLayer - oaPhysicalLayer *imp1 = oaPhysicalLayer::find(_oaTech, "Nimp"); - oaPhysicalLayer *imp2 = oaPhysicalLayer::find(_oaTech, "Pimp"); - oaPhysicalLayer *metal1 = oaPhysicalLayer::find(tech, "Metal1"); - oaPhysicalLayer *cut = oaPhysicalLayer::find(tech, "Via1"); - - - // Set up the oaStdViaDef parameters - oaViaParam stdViaDefParam; - stdViaDefParam.setCutLayer(cut->getNumber()); - stdViaDefParam.setCutWidth(1000); - stdViaDefParam.setCutHeight(1000); - stdViaDefParam.setCutSpacing(100); - stdViaDefParam.setCutColumns(4); - - - // Create the oaStdViaDef oaStdViaDef *myStdViaDef = - oaStdViaDef::create(tech, oaString("myStdViaDef"), poly, metal1, - stdViaDefParam, imp1, imp2); - - - // Create the oaStdViaDef - oaTransform zeroTrans(oaPoint(0, 0), oacR0); - oaStdVia* via = oaStdVia::create(blk, myStdViaDef, zeroTrans); - - return via; -#endif - return NULL; - } - - /** - Convertion helper for Net convertion ... - @todo verify - */ - static oaTermType toOATermType(const Net::Direction& direction) { - switch (direction) { - case Net::Direction::IN: - return oacInputTermType; - case Net::Direction::OUT: - return oacOutputTermType; - case Net::Direction::INOUT: - return oacInputOutputTermType; - case Net::Direction::TRISTATE: - return oacTristateTermType; - case Net::Direction::UNDEFINED: - return oacUnusedTermType;// is it OK ? - default: - throw Error("Unrecognized direction"); } - } - /** - Convertion helper for Net convertion ... - @todo verify - */ - static oaSigType toOASigType(const Net::Type& type) { - 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"); + static oaName toOAName(const Name& n){ + oaNativeNS ns; + oaScalarName scN(ns, getString(n).c_str()); + return oaName(scN); } - } - /** - convert Hurricane::Net to oaNet - always return a non NULL value - */ - oaNet* toOANet(Net* net,oaBlock* topBlock) { - cerr << "toOANet " << net << endl; - assert(net); - oaNativeNS ns; - oaScalarName scNetName(ns, getString(net->getName()).c_str()); - oaScalarNet* blockNet = NULL; - blockNet = oaScalarNet::find(topBlock, scNetName); - if(blockNet) + /** + convert to OAPoint + */ + static oaPoint toOAPoint(const Point& p) { + oaPoint point; + point.set(p.getX(), p.getY()); + return point; + } + + /** + convert to OABox + */ + static oaBox toOABox(const Box& b) { + oaBox box; + box.set(b.getXMin(), b.getYMin(), b.getXMax(), b.getYMax()); + return box; + } + + + + /** + Used to convert Pad + */ + oaRect* toOARect(Component* component,oaNet* blockNet){ + cerr << "toOARect" << endl; + assert(component); + assert(blockNet); + + Component2OARectMap::iterator it = _component2OARect.find(component); + if (it != _component2OARect.end()) + return it->second; + + oaRect* rect = oaRect::create(blockNet->getBlock(), + toOALayerNum( component->getLayer() ), + oacDrawingPurposeType, + toOABox(component->getBoundingBox()) ); + return rect; + } + + /** + Used to convert Segment + */ + oaPathSeg* toOAPathSeg(Segment* segment,oaNet* blockNet){ + cerr << "toOAPathSeg" << endl; + assert(segment); + assert(blockNet); + + Segment2OAPathSegMap::iterator it = _segment2OAPathSeg.find(segment); + if (it != _segment2OAPathSeg.end()) + return it->second; + oaPathSeg* res = NULL; + try{ + Horizontal* hSeg = dynamic_cast(segment); + if(hSeg) + cerr << "Horizontal" << endl; + Vertical* vSeg = dynamic_cast(segment); + if(vSeg) + cerr << "Vertical" << endl; + + oaSegStyle style(segment->getWidth(), oacTruncateEndStyle, oacTruncateEndStyle); + oaPathSeg* res = oaPathSeg::create(blockNet->getBlock(), + toOALayerNum( segment->getLayer() ), + oacDrawingPurposeType, + toOAPoint(segment->getSourcePosition()), + toOAPoint(segment->getTargetPosition()), + style); + }catch (oaException &e) { + cerr << "OA::ERROR => " << e.getMsg() << endl; + exit(1); + } + assert(res); + return res; + } + + /** + Used to convert Pin + */ + oaPin* toOAPin(oaNet* blockNet){ + cerr << "toOAPin" << endl; + assert(blockNet); + oaName pinName; + blockNet->getName(pinName); + oaString sPinName; + pinName.get(sPinName); + oaTerm* term = oaTerm::find(blockNet->getBlock(), pinName); + assert(term); + oaPin* pin = oaPin::find(term, sPinName); + if(!pin) + pin = oaPin::create(term); + + return pin; + } + + /** + used to convert Via + @todo implement me ... + */ + oaVia* toOAVia(Contact* contact,oaNet* blockNet){ + cerr << "toOAVia" << endl; + assert(contact); + assert(blockNet); + + // Create the oaStdVia + const Layer* layer = contact->getLayer(); + const ViaLayer* vLayer = dynamic_cast(layer); + assert(vLayer); + + oaStdViaDef* myStdViaDef = NULL; + ViaLayer2OAViaDefMap::iterator it = _viaLayer2OAViaDef.find(vLayer); + if (it != _viaLayer2OAViaDef.end()) + myStdViaDef = it->second; + assert(myStdViaDef); + + oaTransform zeroTrans(oaPoint(0, 0), oacR0); + oaStdVia* via = oaStdVia::create(blockNet->getBlock(), myStdViaDef, zeroTrans); + + return via; + } + + /** + Convertion helper for Net convertion ... + @todo verify + */ + static oaTermType toOATermType(const Net::Direction& direction) { + switch (direction) { + case Net::Direction::IN: + return oacInputTermType; + case Net::Direction::OUT: + return oacOutputTermType; + case Net::Direction::INOUT: + return oacInputOutputTermType; + case Net::Direction::TRISTATE: + return oacTristateTermType; + case Net::Direction::UNDEFINED: + return oacUnusedTermType;// is it OK ? + default: + throw Error("Unrecognized direction"); + } + } + + /** + Convertion helper for Net convertion ... + @todo verify + */ + static oaSigType toOASigType(const Net::Type& type) { + 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"); + } + } + + oaPinFig* toOAPinFig(Component* component,oaNet* blockNet){ + Contact* hContact = dynamic_cast(component); + Segment* hSegment = dynamic_cast(component); + if(hContact) + return toOAVia(hContact,blockNet); + if(hSegment) + return toOAPathSeg(hSegment,blockNet); + return toOARect(component,blockNet); + } + + + /** + convert Hurricane::Net to oaNet + always return a non NULL value + */ + oaNet* toOANet(Net* net,oaBlock* topBlock) { + cerr << "toOANet " << net << endl; + assert(net); + oaNativeNS ns; + oaScalarName scNetName(ns, getString(net->getName()).c_str()); + oaScalarNet* blockNet = NULL; + blockNet = oaScalarNet::find(topBlock, scNetName); + if(blockNet) + return blockNet; + assert(!blockNet); + blockNet = oaScalarNet::create(topBlock, scNetName, toOASigType(net->getType())); + assert(blockNet); + oaScalarTerm::create(blockNet, scNetName, toOATermType(net->getDirection())); + blockNet->setGlobal(net->isGlobal()); + blockNet->scalarize();//ensure we can add shape .. + + cerr << " o transformation of plugs" << endl; + for_each_plug(plug, net->getPlugs()) { + oaInstTerm* term = toOAInstTerm(plug, blockNet); + term->addToNet(blockNet); + end_for; + } + + if(net->isExternal()){ + oaPin* pin = toOAPin(blockNet); + Components externalComponents = NetExternalComponents::get(net); + for_each_component(component, externalComponents) { + oaPinFig* pinFig = toOAPinFig(component,blockNet); + pinFig->addToPin(pin); + end_for; + } + }else{ + cerr << " o transformation of contacts" << endl; + for_each_contact(contact, net->getContacts()) { + oaVia* via = toOAVia(contact, blockNet); + if(via){ + via->addToNet(blockNet); + }else{ + oaRect* rect = toOARect(contact,blockNet); + rect->addToNet(blockNet); + } + end_for; + } + cerr << " o transformation of pads" << endl; + for_each_pad(pad, net->getPads()){ + oaRect* rect = toOARect(pad, blockNet); + rect->addToNet(blockNet); + end_for; + } + cerr << " o transformation of segments" << endl; + for_each_segment(component, net->getSegments()) { + oaPathSeg* shape = toOAPathSeg(component,blockNet); + shape->addToNet(blockNet); + end_for; + } + } return blockNet; - assert(!blockNet); - blockNet = oaScalarNet::create(topBlock, scNetName, toOASigType(net->getType())); - assert(blockNet); - oaScalarTerm::create(blockNet, scNetName, toOATermType(net->getDirection())); - blockNet->setGlobal(net->isGlobal()); - blockNet->scalarize();//ensure we can add shape .. - - //logical part - cerr << " o transformation of plugs" << endl; - for_each_plug(plug, net->getPlugs()) { - oaInstTerm* term = toOAInstTerm(plug, blockNet); - term->addToNet(blockNet); - end_for; - } - cerr << " o transformation of contacts" << endl; - for_each_contact(contact, net->getContacts()) { - Pin* hPin = dynamic_cast(contact); - oaPin* pin = NULL; - if(hPin) - pin = toOAPin(hPin, blockNet); -#if 0 - oaVia* via = toOAVia(contact, blockNet); - via->addToNet(blockNet); -#endif - end_for; - } - cerr << " o transformation of pads" << endl; - for_each_pad(pad, net->getPads()){ - oaRect* rect = toOARect(pad, blockNet); - rect->addToNet(blockNet); - end_for; - } - cerr << " o transformation of segments" << endl; - for_each_segment(component, net->getSegments()) { - oaPathSeg* shape = toOAPathSeg(component,blockNet); - shape->addToNet(blockNet); - end_for; - } - return blockNet; - } - - /** - Add netlist view to previous view ... - */ - oaDesign* addNetlist(const Cell* cell,oaDesign* previous) { - cerr << "createNetlist " << cell << endl; - assert(cell); - assert(previous); - Cell2OADesignMap::iterator it = _cell2OADesign4Netlist.find(cell); - if (it != _cell2OADesign4Netlist.end()) { - return it->second; } - // 1) get the lib containing the cell - oaNativeNS ns; - oaLib* lib = toOALib(cell->getLibrary()); - assert(lib); + /** + Add netlist view to previous view ... + */ + oaDesign* addNetlist(const Cell* cell,oaDesign* previous) { + cerr << "createNetlist " << cell << endl; + assert(cell); + assert(previous); + Cell2OADesignMap::iterator it = _cell2OADesign4Netlist.find(cell); + if (it != _cell2OADesign4Netlist.end()) { + return it->second; + } - // 2) create a netlist CellView of the cell - oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); - oaScalarName scNameView(ns, "netlist"); - oaScalarName scNameLib; - lib->getName(scNameLib); - cerr << "oaDesign::open for netlist view" << endl; - oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, oaViewType::get(oacNetlist), 'a'); - _cell2OADesign4Netlist[cell] = designCellView; + // 1) get the lib containing the cell + oaNativeNS ns; + oaLib* lib = toOALib(cell->getLibrary()); + assert(lib); - // get module or embed previous module - oaModule* topMod = NULL; - topMod = designCellView->getTopModule(); - if(!topMod){ - topMod = oaModule::embed(designCellView, previous); - designCellView->setTopModule(topMod); - } - oaBlock *topBlock = designCellView->getTopBlock(); - assert(topBlock); + // 2) create a netlist CellView of the cell + oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); + oaScalarName scNameView(ns, "netlist"); + oaScalarName scNameLib; + lib->getName(scNameLib); + cerr << "oaDesign::open for netlist view" << endl; + oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, oaViewType::get(oacNetlist), 'a'); + _cell2OADesign4Netlist[cell] = designCellView; - return designCellView; - } + // get module or embed previous module + oaModule* topMod = NULL; + topMod = designCellView->getTopModule(); + if(!topMod){ + topMod = oaModule::embed(designCellView, previous); + designCellView->setTopModule(topMod); + } + oaBlock *topBlock = designCellView->getTopBlock(); + assert(topBlock); - /** - Add symbol view to previous view ... - */ - oaDesign* addSymbol(const Cell* cell,oaDesign* previous) { - cerr << "addSymbol" << cell << endl; - assert(cell); - assert(previous); - Cell2OADesignMap::iterator it = _cell2OADesign4Symbolic.find(cell); - if (it != _cell2OADesign4Symbolic.end()) { - return it->second; - } - oaNativeNS ns; - oaLib* lib = toOALib(cell->getLibrary()); - assert(lib); - oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); - oaScalarName scNameView(ns, "symbolic"); - oaScalarName scNameLib; - lib->getName(scNameLib); - - // create a symbolic CellView of the cell - oaViewType* vType = oaViewType::get(oacSchematicSymbol); - cerr << "oaDesign::open for symbolic view" << endl; - oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, vType, 'a'); - _cell2OADesign4Symbolic[cell] = designCellView; - - // get module or embed previous module - oaModule* topMod = NULL; - topMod = designCellView->getTopModule(); - if(!topMod){ - topMod = oaModule::embed(designCellView, previous); - designCellView->setTopModule(topMod); - } - oaBlock *topBlock = designCellView->getTopBlock(); - assert(topBlock); - - return designCellView; - } - - /** - Add schematic view to previous view ... - */ - oaDesign* addSchematic(const Cell* cell,oaDesign* previous) { - cerr << "addSchematic" << cell << endl; - assert(cell); - assert(previous); - Cell2OADesignMap::iterator it = _cell2OADesign4Schematic.find(cell); - if (it != _cell2OADesign4Schematic.end()) - return it->second; - - oaNativeNS ns; - oaLib* lib = toOALib(cell->getLibrary()); - assert(lib); - oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); - oaScalarName scNameView(ns, "schematic"); - oaScalarName scNameLib; - lib->getName(scNameLib); - - // create a schematic CellView of the cell - oaViewType* vType = oaViewType::get(oacSchematic); - cerr << "oaDesign::open for schematic view" << endl; - oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, vType, 'a'); - _cell2OADesign4Schematic[cell] = designCellView; - - // get module or embed previous module - oaModule* topMod = NULL; - topMod = designCellView->getTopModule(); - if(!topMod){ - topMod = oaModule::embed(designCellView, previous); - designCellView->setTopModule(topMod); - } - oaBlock *topBlock = designCellView->getTopBlock(); - assert(topBlock); - - return designCellView; - } - - /** - Create initial oaDesign from the cell and save it as a layout (abstract) view - */ - oaDesign* addLayout(const Cell* cell) { - cerr << "addLayout" << cell << endl; - assert(cell); - Cell2OADesignMap::iterator it = _cell2OADesign4Layout.find(cell); - if (it != _cell2OADesign4Layout.end()) { - return it->second; + return designCellView; } - oaNativeNS ns; - oaLib* lib = toOALib(cell->getLibrary()); - assert(lib); - oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); - oaScalarName scNameView(ns, "layout"); - oaScalarName scNameLib; - lib->getName(scNameLib); + /** + Add symbol view to previous view ... + */ + oaDesign* addSymbol(const Cell* cell,oaDesign* previous) { + cerr << "addSymbol" << cell << endl; + assert(cell); + assert(previous); + Cell2OADesignMap::iterator it = _cell2OADesign4Symbolic.find(cell); + if (it != _cell2OADesign4Symbolic.end()) { + return it->second; + } + oaNativeNS ns; + oaLib* lib = toOALib(cell->getLibrary()); + assert(lib); + oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); + oaScalarName scNameView(ns, "symbolic"); + oaScalarName scNameLib; + lib->getName(scNameLib); - // create a layout CellView of the cell - oaViewType* vType = oaViewType::get(oacMaskLayout); - cerr << "oaDesign::open for layout view" << endl; - oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, vType, 'a'); - _cell2OADesign4Layout[cell] = designCellView; + // create a symbolic CellView of the cell + oaViewType* vType = oaViewType::get(oacSchematicSymbol); + cerr << "oaDesign::open for symbolic view" << endl; + oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, vType, 'a'); + _cell2OADesign4Symbolic[cell] = designCellView; - // create oaBlock singleton where we will do all the work - oaBlock* topBlock = designCellView->getTopBlock(); - if(!topBlock){ - cerr << "oaBlock::create for netlist view" << endl; - topBlock = oaBlock::create(designCellView); - } - assert(topBlock); + // get module or embed previous module + oaModule* topMod = NULL; + topMod = designCellView->getTopModule(); + if(!topMod){ + topMod = oaModule::embed(designCellView, previous); + designCellView->setTopModule(topMod); + } + oaBlock *topBlock = designCellView->getTopBlock(); + assert(topBlock); - // 4) convert each instance, net to OA - cerr << "transformation of instances" << endl; - for_each_instance(instance, cell->getInstances()){ - toOAInst(instance,topBlock); - end_for; - } - cerr << "transformation of nets" << endl; - for_each_net(net, cell->getNets()){ - toOANet(net,topBlock); - end_for; + return designCellView; } - //get and update boundingBox and set abutment box - Box bBox = cell->getBoundingBox(); - cerr << "Hurricane bounding box" << bBox << " in cell " << cell << endl; - Box aBox = cell->getAbutmentBox(); - cerr << "Hurricane abutment box" << aBox << " in cell " << cell << endl; + /** + Add schematic view to previous view ... + */ + oaDesign* addSchematic(const Cell* cell,oaDesign* previous) { + cerr << "addSchematic" << cell << endl; + assert(cell); + assert(previous); + Cell2OADesignMap::iterator it = _cell2OADesign4Schematic.find(cell); + if (it != _cell2OADesign4Schematic.end()) + return it->second; - // create abutment in oa - if(!aBox.isEmpty()) - if(!oaSnapBoundary::find(topBlock)) - oaSnapBoundary::create(topBlock, toOABox(aBox)); + oaNativeNS ns; + oaLib* lib = toOALib(cell->getLibrary()); + assert(lib); + oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); + oaScalarName scNameView(ns, "schematic"); + oaScalarName scNameLib; + lib->getName(scNameLib); - oaBox boundingBox = toOABox(bBox); - topBlock->getBBox(boundingBox); + // create a schematic CellView of the cell + oaViewType* vType = oaViewType::get(oacSchematic); + cerr << "oaDesign::open for schematic view" << endl; + oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, vType, 'a'); + _cell2OADesign4Schematic[cell] = designCellView; - return designCellView; - } + // get module or embed previous module + oaModule* topMod = NULL; + topMod = designCellView->getTopModule(); + if(!topMod){ + topMod = oaModule::embed(designCellView, previous); + designCellView->setTopModule(topMod); + } + oaBlock *topBlock = designCellView->getTopBlock(); + assert(topBlock); - /** - Convert a Cell to OA designs ... - */ - oaDesign* toOADesign(const Cell* cell) { - cerr << "toOADesign " << cell << endl; - assert(cell); + return designCellView; + } - // 1) get technology - if(!_oaTech) - _oaTech = toOATech(_technology,cell->getLibrary()); + /** + Create initial oaDesign from the cell and save it as a layout (abstract) view + */ + oaDesign* addLayout(const Cell* cell) { + cerr << "addLayout" << cell << endl; + assert(cell); + Cell2OADesignMap::iterator it = _cell2OADesign4Layout.find(cell); + if (it != _cell2OADesign4Layout.end()) { + return it->second; + } - // 2) create OA structure ... - oaDesign* layoutView = addLayout(cell); - assert(layoutView); + oaNativeNS ns; + oaLib* lib = toOALib(cell->getLibrary()); + assert(lib); + oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); + oaScalarName scNameView(ns, "layout"); + oaScalarName scNameLib; + lib->getName(scNameLib); - oaCell* c1 = toOACell(layoutView); - assert(c1); + // create a layout CellView of the cell + oaViewType* vType = oaViewType::get(oacMaskLayout); + cerr << "oaDesign::open for layout view" << endl; + oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, vType, 'a'); + _cell2OADesign4Layout[cell] = designCellView; - oaDesign* netlistView = addNetlist(cell,layoutView); - assert(netlistView); + // create oaBlock singleton where we will do all the work + oaBlock* topBlock = designCellView->getTopBlock(); + if(!topBlock){ + cerr << "oaBlock::create for netlist view" << endl; + topBlock = oaBlock::create(designCellView); + } + assert(topBlock); - oaCell* c2 = toOACell(netlistView); - assert(c2); + // 4) convert each instance, net to OA + cerr << "transformation of instances" << endl; + for_each_instance(instance, cell->getInstances()){ + toOAInst(instance,topBlock); + end_for; + } + cerr << "transformation of nets" << endl; + for_each_net(net, cell->getNets()){ + toOANet(net,topBlock); + end_for; + } - oaDesign* symbolicView = addSymbol(cell,netlistView); - assert(symbolicView); + //get and update boundingBox and set abutment box + Box bBox = cell->getBoundingBox(); + cerr << "Hurricane bounding box" << bBox << " in cell " << cell << endl; + Box aBox = cell->getAbutmentBox(); + cerr << "Hurricane abutment box" << aBox << " in cell " << cell << endl; - oaCell* c3 = toOACell(symbolicView); - assert(c3); + // create abutment in oa + if(!aBox.isEmpty()) + if(!oaSnapBoundary::find(topBlock)) + oaSnapBoundary::create(topBlock, toOABox(aBox)); - oaDesign* schematicView = addSchematic(cell,symbolicView); - assert(schematicView); + oaBox boundingBox = toOABox(bBox); + topBlock->getBBox(boundingBox); - oaCell* c4 = toOACell(schematicView); - assert(c4); + return designCellView; + } - //3) we check it's the same oaCell for all designs - assert(c1 == c2 && c2 == c3 && c3 == c4); + /** + Convert a Cell to OA designs ... + */ + oaDesign* toOADesign(const Cell* cell) { + cerr << "toOADesign " << cell << endl; + assert(cell); - return netlistView; - } + // 1) get technology + if(!_oaTech) + _oaTech = toOATech(_technology,cell->getLibrary()); - /** - given a oaDesign get the oaCell corresponding - */ - static oaCell* toOACell(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; - } + // 2) create OA structure ... + oaDesign* layoutView = addLayout(cell); + assert(layoutView); - oaCell* toOACell(const Cell* cell) { - Cell2OACellMap::iterator it = _cell2OAcell.find(cell); - if (it != _cell2OAcell.end()) - return it->second; + oaCell* c1 = toOACell(layoutView); + assert(c1); - oaCell* c1 = toOACell( toOADesign(cell) ); - _cell2OAcell[cell] = c1; + oaDesign* netlistView = addNetlist(cell,layoutView); + assert(netlistView); - return c1; - } -};//OADriver class + oaCell* c2 = toOACell(netlistView); + assert(c2); + + oaDesign* symbolicView = addSymbol(cell,netlistView); + assert(symbolicView); + + oaCell* c3 = toOACell(symbolicView); + assert(c3); + + oaDesign* schematicView = addSchematic(cell,symbolicView); + assert(schematicView); + + oaCell* c4 = toOACell(schematicView); + assert(c4); + + //3) we check it's the same oaCell for all designs + assert(c1 == c2 && c2 == c3 && c3 == c4); + + return layoutView; + } + + /** + given a oaDesign get the oaCell corresponding + */ + static oaCell* toOACell(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; + } + + oaCell* toOACell(const Cell* cell) { + Cell2OACellMap::iterator it = _cell2OAcell.find(cell); + if (it != _cell2OAcell.end()) + return it->second; + + oaCell* c1 = toOACell( toOADesign(cell) ); + _cell2OAcell[cell] = c1; + + return c1; + } + };//OADriver class #endif }//namespace CRL_OA diff --git a/crlcore/src/ccore/openaccess/testDriver/src/main.cpp b/crlcore/src/ccore/openaccess/testDriver/src/main.cpp index fa4cd970..c3ff5d1d 100755 --- a/crlcore/src/ccore/openaccess/testDriver/src/main.cpp +++ b/crlcore/src/ccore/openaccess/testDriver/src/main.cpp @@ -102,7 +102,7 @@ int main(int argc,char** argv) { if(argc != 3) exit(-5); - testAnalog(argv[1],argv[2]); + testNum(argv[1],argv[2],"a2_x2"); testNum(argv[1],argv[2],"a2_x4"); @@ -200,6 +200,8 @@ int main(int argc,char** argv) { testNum(argv[1],argv[2],"xr2_x4"); testNum(argv[1],argv[2],"zero_x0"); + testAnalog(argv[1],argv[2]); + DataBase::getDB()->destroy(); cerr << "ending normally" << endl; return 0;