From a516708ed41a3229456b214481bdcedeeb8ff528 Mon Sep 17 00:00:00 2001 From: Jean-Manuel Caba Date: Wed, 21 Jul 2010 17:31:19 +0000 Subject: [PATCH] cleaning, begin parser implementation, generate cds.lib ... --- crlcore/cmake_modules/FindOPENACCESS.cmake | 15 +- crlcore/src/ccore/CMakeLists.txt | 2 +- crlcore/src/ccore/OADriver.cpp | 2 +- crlcore/src/ccore/ParsersDrivers.cpp | 2 +- .../src/ccore/openaccess/OpenAccessDriver.cpp | 642 ++++++++++++ ...OpenAccessWrapper.h => OpenAccessDriver.h} | 0 .../src/ccore/openaccess/OpenAccessUtils.h | 257 +++++ .../ccore/openaccess/OpenAccessWrapper.cpp | 969 ------------------ .../obsolete/COpenAccessBridgeLayer.cpp | 22 - .../obsolete/COpenAccessBridgeLayer.h | 26 - .../src/ccore/openaccess/script/cadence_oa.sh | 36 + crlcore/src/ccore/openaccess/test/Makefile | 15 +- .../src/ccore/openaccess/test/src/main.cpp | 38 +- 13 files changed, 974 insertions(+), 1052 deletions(-) create mode 100644 crlcore/src/ccore/openaccess/OpenAccessDriver.cpp rename crlcore/src/ccore/openaccess/{OpenAccessWrapper.h => OpenAccessDriver.h} (100%) create mode 100644 crlcore/src/ccore/openaccess/OpenAccessUtils.h delete mode 100644 crlcore/src/ccore/openaccess/OpenAccessWrapper.cpp delete mode 100644 crlcore/src/ccore/openaccess/obsolete/COpenAccessBridgeLayer.cpp delete mode 100644 crlcore/src/ccore/openaccess/obsolete/COpenAccessBridgeLayer.h create mode 100755 crlcore/src/ccore/openaccess/script/cadence_oa.sh diff --git a/crlcore/cmake_modules/FindOPENACCESS.cmake b/crlcore/cmake_modules/FindOPENACCESS.cmake index 213db3ce..3b8944ce 100644 --- a/crlcore/cmake_modules/FindOPENACCESS.cmake +++ b/crlcore/cmake_modules/FindOPENACCESS.cmake @@ -46,7 +46,7 @@ # # The OpenAccess oaPlugin library: OA_PLUGIN_LIBRARY # OA_PLUGIN_LIBRARY_RELEASE -# OA_PLUGIN_DEBUG# +# OA_PLUGIN_DEBUG # # Cadence version of OpenAccess has also # @@ -132,6 +132,10 @@ IF(UNIX) FIND_LIBRARY(OA_OADM_LIBRARY_RELEASE NAMES oaDM PATHS ${OA_LIBRARY_DIR} NO_DEFAULT_PATH ) FIND_LIBRARY(OA_OADM_LIBRARY_DEBUG NAMES oaDMD PATHS ${OA_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set OA_OAPLUGIN_LIBRARY + FIND_LIBRARY(OA_OAPLUGIN_LIBRARY_RELEASE NAMES oaPlugIn PATHS ${OA_LIBRARY_DIR} NO_DEFAULT_PATH ) + FIND_LIBRARY(OA_OAPLUGIN_LIBRARY_DEBUG NAMES oaPlugInD PATHS ${OA_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set OA_OATECH_LIBRARY FIND_LIBRARY(OA_OATECH_LIBRARY_RELEASE NAMES oaTech PATHS ${OA_LIBRARY_DIR} NO_DEFAULT_PATH ) FIND_LIBRARY(OA_OATECH_LIBRARY_DEBUG NAMES oaTechD PATHS ${OA_LIBRARY_DIR} NO_DEFAULT_PATH) @@ -144,10 +148,6 @@ IF(UNIX) FIND_LIBRARY(OA_OAWAFER_LIBRARY_RELEASE NAMES oaWafer PATHS ${OA_LIBRARY_DIR} NO_DEFAULT_PATH ) FIND_LIBRARY(OA_OAWAFER_LIBRARY_DEBUG NAMES oaWaferD PATHS ${OA_LIBRARY_DIR} NO_DEFAULT_PATH) - # Set OA_OAPLUGIN_LIBRARY - FIND_LIBRARY(OA_OAPLUGIN_LIBRARY_RELEASE NAMES oaPlugIn PATHS ${OA_LIBRARY_DIR} NO_DEFAULT_PATH ) - FIND_LIBRARY(OA_OAPLUGIN_LIBRARY_DEBUG NAMES oaPlugInD PATHS ${OA_LIBRARY_DIR} NO_DEFAULT_PATH) - ############################################ # # Check the existence of the libraries. @@ -195,11 +195,10 @@ IF(UNIX) _OA_ADJUST_LIB_VARS(OABASE) _OA_ADJUST_LIB_VARS(OACM) _OA_ADJUST_LIB_VARS(OADM) + _OA_ADJUST_LIB_VARS(OAPLUGIN) _OA_ADJUST_LIB_VARS(OATECH) _OA_ADJUST_LIB_VARS(OADESIGN) _OA_ADJUST_LIB_VARS(OAWAFER) - _OA_ADJUST_LIB_VARS(OAPLUGIN) - IF (OA_INCLUDE_PATH AND OA_OACOMMON_LIBRARY AND OA_OABASE_LIBRARY AND OA_OADM_LIBRARY AND OA_OATECH_LIBRARY AND OA_OADESIGN_LIBRARY @@ -216,10 +215,10 @@ IF(UNIX) ${OA_OABASE_LIBRARY} ${OA_OACM_LIBRARY} ${OA_OADM_LIBRARY} + ${OA_OAPLUGIN_LIBRARY} ${OA_OATECH_LIBRARY} ${OA_OADESIGN_LIBRARY} ${OA_OAWAFER_LIBRARY} - ${OA_OAPLUGIN_LIBRARY} ) ELSE (OA_INCLUDE_PATH AND OA_LIBRARY_PATH) SET(OA_FOUND "NO") diff --git a/crlcore/src/ccore/CMakeLists.txt b/crlcore/src/ccore/CMakeLists.txt index e4018f05..dd0c6057 100644 --- a/crlcore/src/ccore/CMakeLists.txt +++ b/crlcore/src/ccore/CMakeLists.txt @@ -133,7 +133,7 @@ if ( OA_FOUND ) include_directories ( ${OA_INCLUDE_DIR} ) endif ( OA_FOUND ) - set (openaccess_cpps openaccess/OpenAccessWrapper.cpp ) + set (openaccess_cpps openaccess/OpenAccessDriver.cpp ) set ( VstParserSourceDir ${CRLCORE_SOURCE_DIR}/src/ccore/alliance/vst ) set ( VstParserBinaryDir ${CRLCORE_BINARY_DIR}/src/ccore/alliance/vst ) diff --git a/crlcore/src/ccore/OADriver.cpp b/crlcore/src/ccore/OADriver.cpp index 8d5d8856..46e827d7 100644 --- a/crlcore/src/ccore/OADriver.cpp +++ b/crlcore/src/ccore/OADriver.cpp @@ -4,7 +4,7 @@ using namespace Hurricane; #include "crlcore/OADriver.h" -#include "openaccess/OpenAccessWrapper.h" +#include "openaccess/OpenAccessDriver.h" namespace CRL { OADriver::OADriver(Cell* cell) : _cell(cell) {} diff --git a/crlcore/src/ccore/ParsersDrivers.cpp b/crlcore/src/ccore/ParsersDrivers.cpp index b6872bb3..5e36b353 100644 --- a/crlcore/src/ccore/ParsersDrivers.cpp +++ b/crlcore/src/ccore/ParsersDrivers.cpp @@ -62,7 +62,7 @@ # include "Spice.h" # include "Bookshelf.h" # include "LefDef.h" -# include "openaccess/OpenAccessWrapper.h" +# include "openaccess/OpenAccessDriver.h" namespace { diff --git a/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp b/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp new file mode 100644 index 00000000..78388807 --- /dev/null +++ b/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp @@ -0,0 +1,642 @@ +// -*-compile-command:"cd ../../../../.. && make"-*- +// Time-stamp: "2010-07-21 19:21:12" - OpenAccessWrapper.cpp +// x-----------------------------------------------------------------x +// | This file is part of the hurricaneAMS Software. | +// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | +// | =============================================================== | +// | Author : Chistophe Alexandre | +// | E-mail : Christophe.Alexandre@asim.lip6.fr | +// x-----------------------------------------------------------------x +// | Author : Jean-Manuel Caba | +// | E-mail : Jean-Manuel.Caba@asim.lip6.fr | +// x-----------------------------------------------------------------x + +#include +#include +#include +using namespace std; + +#ifdef HAVE_OPENACCESS +#include "oa/oaDesignDB.h" +using namespace oa; +#endif + +#include "hurricane/DataBase.h" +#include "hurricane/Technology.h" +#include "hurricane/Library.h" +#include "hurricane/Cell.h" +#include "hurricane/NetExternalComponents.h" +#include "hurricane/Segment.h" +#include "hurricane/Pad.h" +#include "hurricane/BasicLayer.h" +#include "hurricane/Slice.h" +using namespace Hurricane; + +#include "OpenAccessDriver.h" +#include "OpenAccessUtils.h" + +namespace { + +#ifdef HAVE_OPENACCESS + + /** + Class to drive OA to Hurricane + */ + class OADriver { + private: + typedef map Library2OALibMap; + typedef map Cell2OADesignMap; + typedef pair OAInstPair; + typedef map Instance2OAInstsMap; + typedef map Layer2OAPhysicalLayerMap; + + string _path; + oaTech* _oaTech; + Library2OALibMap _library2OALib; + Cell2OADesignMap _cell2OADesign4Netlist; + Cell2OADesignMap _cell2OADesign4Schematic; + Cell2OADesignMap _cell2OADesign4Symbolic; + Cell2OADesignMap _cell2OADesign4Layout; + Instance2OAInstsMap _instance2OAInst; + Layer2OAPhysicalLayerMap _layer2OAPhysicalLayer; + DataBase* _db; + Technology* _technology; + int _layerID; + public: + OADriver(const string& path): + _path(path), + _oaTech(NULL), + _library2OALib(), + _cell2OADesign4Netlist(), + _cell2OADesign4Schematic(), + _cell2OADesign4Symbolic(), + _cell2OADesign4Layout(), + _instance2OAInst(), + _layer2OAPhysicalLayer(), + _db(NULL), + _technology(NULL), + _layerID(0) { + _db = DataBase::getDB(); + if (!_db) { + throw Error("no database"); + } + _technology = _db->getTechnology(); + if (!_technology) { + throw Error("no technology"); + } + } + + ~OADriver() { + cerr << "SAVING ALL" << endl; + _oaTech->save(); + _oaTech->close(); + saveDesignsInMap(_cell2OADesign4Netlist); + saveDesignsInMap(_cell2OADesign4Schematic); + saveDesignsInMap(_cell2OADesign4Symbolic); + saveDesignsInMap(_cell2OADesign4Layout); + for (Library2OALibMap::iterator it = _library2OALib.begin(); + it != _library2OALib.end(); + ++it) { + oaLib* lib = it->second; + lib->close(); + } + cerr << "ALL SAVED" << endl; + } + + /** + Create an empty oaLib from a Library + no cells are added in this oaLib + all sub Library are also converted. + */ + oaLib* getOALibForLibrary(const Library* library) { + cerr << "getOALibForLibrary" << endl; + assert(library); + Library2OALibMap::iterator it = _library2OALib.find(library); + if (it != _library2OALib.end()) { + return it->second; + } + + // 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()); + _library2OALib[library] = lib; + + // 2) for each cell convert them too : if it's a standard cell library for example + for_each_cell(c ,library->getCells()){ + getOADesignForCell(c); + end_for; + } + + // 3) also convert each contained library if any + for_each_library(l ,library->getLibraries()){ + getOALibForLibrary(l); + end_for; + } + + // 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()); + 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); + }catch(...){ + cerr << "ERROR cds: [UNKNOWN]" << endl; + exit(-1); + } + + return lib; + } + + /** + convert oaLayer from a Layer ... + */ + oaLayer* getOALayerFromLayer(Layer* layer,oaTech* theOATech) { + cerr << "getOALayerFromLayer" << endl; + assert(layer); + assert(theOATech); + oaString layerName = getString(layer->getName()).c_str(); + 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); + + _layer2OAPhysicalLayer[layer] = aOALayer; + + //create and add layer constraint for Layer specific manufacturing rules + cerr << " o get value for constraint" << endl; + long minSize = Hurricane::DbU::getDb(layer->getMinimalSize()); + long minSpace = Hurricane::DbU::getDb(layer->getMinimalSpacing()); + long pitch = Hurricane::DbU::getDb(layer->getPitch()); + +/* + cerr << " o create constraint for min size : " << pitch << endl; + oaLayerConstraint* cMinSize = NULL; + try{ + cMinSize = oaLayerConstraint::create(aOALayer->getNumber(), + oaLayerConstraintDef::get(oacMinSize), + oaIntValue::create(theOATech,500)) + }catch(oaException& e){ + cerr << "ERROR oaLayer: " << e.getMsg() << endl; + exit(-2); + }catch(...){ + cerr << "ERROR oaLayer: [UNKNOWN]" << endl; + exit(-1); + } + assert(cMinSize); + cerr << " o create constraint for min space" << endl; + oaLayerConstraint* cMinSpace = oaLayerConstraint::create(aOALayer->getNumber(), + oaLayerConstraintDef::get(oacMinSpacing), + oaIntValue::create(theOATech->getLib(),minSpace)); + assert(cMinSpace); + cerr << " o create constraint for pitchH" << endl; + oaLayerConstraint* cPitchH = oaLayerConstraint::create(aOALayer->getNumber(), + oaLayerConstraintDef::get(oacHorizontalRouteGridPitch), + oaIntValue::create(theOATech->getLib(),pitch)); + assert(cPitchH); + + cerr << " o create constraint for pitchV" << endl; + oaLayerConstraint* cPitchV = oaLayerConstraint::create(aOALayer->getNumber(), + oaLayerConstraintDef::get(oacVerticalRouteGridPitch), + oaIntValue::create(theOATech->getLib(),pitch)); + assert(cPitchV); +*/ + if(bLayer){ + unsigned gdsIInumber = bLayer->getExtractNumber(); + } + 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 getOALibForLibrary + */ + oaTech* getOATechForTechnology(const Technology* technology) { + cerr << "createOATechForTechnology" << endl; + assert(technology); + + //get or create Library for the techno + DataBase* db = technology->getDataBase(); + assert(db); + Library* lib = db->getRootLibrary(); + assert(lib); + oaLib* techOAlib = getOALibForLibrary(lib); + assert(techOAlib); + + cerr << "oaTech::find" << endl; + oaTech* theOATech = oaTech::find(techOAlib); + if(!theOATech){ + if (oaTech::exists(techOAlib)){ + cerr << "oaTech::open" << endl; + theOATech = oaTech::open(techOAlib,'a'); + } + if(!theOATech){ + cerr << "oaTech::create" << endl; + theOATech = oaTech::create(techOAlib); + }else{ + return theOATech; + } + }else{ + return theOATech; + } + assert(techOAlib); + theOATech->setDefaultManufacturingGrid(10); + theOATech->setDBUPerUU(oaViewType::get(oacMaskLayout), 2000); + + //create and add foundry constraint group for General manufacturing rules + //and add oaSimpleConstraintType too + oaConstraintGroup *cgFoundry = theOATech->getFoundryRules(); + + //TODO: add this layer + //first create "utility" layers + //strLayerDev ( "device" ); + //strLayerText( "text" ); + //strLayerPin ( "pin" ); + //strLayerWire( "wire" ); + + //create physical layer + for_each_layer(layer, technology->getLayers()) { + getOALayerFromLayer(layer,theOATech); + end_for; + } + + printOALayers(theOATech); + + return theOATech; + } + + /** + convert Hurricane::Instance to oaInst ... + */ + oaInst* getOAInstForInstance(Instance* instance,oaBlock* topBlock) { + cerr << "getOAInstForInstance " << instance << endl; + assert(instance); + Instance2OAInstsMap::iterator it = _instance2OAInst.find(instance); + if (it != _instance2OAInst.end()) { + return it->second; + } + assert(topBlock); + + // 1) get the master cell for the instance + Cell* masterCell = instance->getMasterCell(); + assert(masterCell); + oaDesign* masterDesign = getOADesignForCell(masterCell); + assert(masterDesign); + + oaNativeNS ns; + 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(topBlock, masterDesign, scInstName, transform); + _instance2OAInst[instance] = blockInst; + return blockInst; + } + + /** + convert Hurricane::plug to oaInstTerm + and add it to if connected. + always return a non NULL value + */ + oaInstTerm* getOAInstTermFromPlug(Plug* plug,oaNet* net){ + cerr << "getOAInstTermFromPlug " << plug << endl; + assert(plug); + Instance* instance = plug->getInstance(); + Instance2OAInstsMap::iterator it = _instance2OAInst.find(instance); + assert(it != _instance2OAInst.end()); + oaInst* blockInst = it->second; + oaInstTerm* instTerm = getInstTerm(blockInst, plug,net); + assert(instTerm); + return instTerm; + } + + oaPin* getOAPinFromNet(Net* net,oaNet* blockNet){ + cerr << "getOAPinFromNet" << endl; + assert(net); + assert(net->isExternal()); + assert(blockNet); + oaNativeNS ns; + oaScalarName scNetName(ns, getString(net->getName()).c_str()); + oaTerm* term = oaTerm::create(blockNet, scNetName, getOATermType(net->getDirection())); + assert(term); + oaPin* pin = oaPin::create(term); + assert(pin); +/* + oaLayerNum layer; + oaPurposeNum purpose; + getLayerPurpose(block->getDesign(), "pin", "drawing", layer, purpose); + oaPinFig *fig = oaPolygon::create(block, layer, purpose, points); +*/ + return pin; + } + + oaRect* getOARectFromComponent(Component* component,oaBlock* topBlock){ + cerr << "getOARectFromComponent" << endl; + assert(component); + assert(topBlock); + oaBox box; + getOABoxForBox(box, component->getBoundingBox()); + Layer* layer = (Layer*) component->getLayer(); + assert(layer); + oaPhysicalLayer* physLayer = NULL; + Layer2OAPhysicalLayerMap::iterator it = _layer2OAPhysicalLayer.find(layer); + if (it != _layer2OAPhysicalLayer.end()) { + physLayer = it->second; + } + assert(physLayer); + oaLayerNum layerNum = physLayer->getNumber(); + oaRect* rect = oaRect::create(topBlock, layerNum, + oaPurpose::get(_oaTech, oacDrawingPurposeType)->getNumber(), + box); + return rect; + } + + /** + convert Hurricane::Net to oaNet only at + the logical abstraction point of view + always return a non NULL value + */ + oaNet* getOANetFromNet(Net* net,oaBlock* topBlock) { + cerr << "getOANetFromNet " << net << endl; + assert(net); + oaNativeNS ns; + oaScalarName scNetName(ns, getString(net->getName()).c_str()); + oaScalarNet* blockNet = oaScalarNet::create(topBlock, scNetName, getOASigType(net->getType())); + assert(blockNet); + if (net->isExternal()) { + oaPin* pin = getOAPinFromNet(net,blockNet); + Components externalComponents = NetExternalComponents::get(net); + for_each_component(component, externalComponents) { + oaRect* rect = getOARectFromComponent(component,topBlock); + rect->addToPin(pin); + end_for; + } + } + cerr << " o transformation of plugs" << endl; + for_each_plug(plug, net->getPlugs()) { + getOAInstTermFromPlug(plug,blockNet); + end_for; + } + return blockNet; + } + + /** + create oaRect for slice ... + */ + void getOARectFromSlice(Slice* slice,oaBlock* topBlock){ + cerr << "getOARectFromSlice" << endl; + assert(slice); + assert(topBlock); + for_each_component(component, slice->getComponents()) { + oaRect* rect = getOARectFromComponent(component,topBlock); + end_for; + } + } + + /** + Create initial oaDesign from the cell and save it as a netlist view + */ + oaDesign* createOAasNetlist(const Cell* cell) { + cerr << "createNetlist " << cell << endl; + assert(cell); + Cell2OADesignMap::iterator it = _cell2OADesign4Netlist.find(cell); + if (it != _cell2OADesign4Netlist.end()) { + return it->second; + } + + // 1) get the lib containing the cell + oaNativeNS ns; + oaLib* lib = getOALibForLibrary(cell->getLibrary()); + assert(lib); + + // 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; + + // 3) create oaBlock singleton where we will do all the work + cerr << "oaBlock::create for netlist view" << endl; + oaBlock* topBlock = oaBlock::create(designCellView); + assert(topBlock); + + // 4) convert each OA object + cerr << "transformation of slices" << endl; + for_each_slice(slice, cell->getSlices()){ + getOARectFromSlice(slice,topBlock); + end_for; + } + cerr << "transformation of instances" << endl; + for_each_instance(instance, cell->getInstances()){ + getOAInstForInstance(instance,topBlock); + end_for; + } + cerr << "transformation of nets" << endl; + for_each_net(net, cell->getNets()){ + getOANetFromNet(net,topBlock); + end_for; + } + return designCellView; + } + + /** + 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 = getOALibForLibrary(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; + + // embed previous module + oaModule *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 = getOALibForLibrary(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; + + // embed previous module + oaModule *topMod = oaModule::embed(designCellView, previous); + designCellView->setTopModule(topMod); + oaBlock *topBlock = designCellView->getTopBlock(); + assert(topBlock); + + return designCellView; + } + + /** + Add layout view to previous view ... + */ + oaDesign* addLayout(const Cell* cell,oaDesign* previous) { + cerr << "addLayout" << cell << endl; + assert(cell); + assert(previous); + Cell2OADesignMap::iterator it = _cell2OADesign4Layout.find(cell); + if (it != _cell2OADesign4Layout.end()) { + return it->second; + } + + oaNativeNS ns; + oaLib* lib = getOALibForLibrary(cell->getLibrary()); + assert(lib); + oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); + oaScalarName scNameView(ns, "layout"); + 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; + + // embed previous module + oaModule *topMod = oaModule::embed(designCellView, previous); + designCellView->setTopModule(topMod); + oaBlock *topBlock = designCellView->getTopBlock(); + assert(topBlock); + + return designCellView; + } + + /** + Convert a Cell to OA designs ... + */ + oaDesign* getOADesignForCell(const Cell* cell) { + cerr << "getOADesignForCell " << cell << endl; + assert(cell); + + // 1) get technology + if(!_oaTech) + _oaTech = getOATechForTechnology(_technology); + + // 2) create OA structure ... + oaDesign* netlistView = createOAasNetlist(cell); + assert(netlistView); + oaDesign* symbolicView = addSymbol(cell,netlistView); + assert(symbolicView); + oaDesign* schematicView = addSchematic(cell,symbolicView); + assert(schematicView); + oaDesign* layoutView = addLayout(cell,schematicView); + assert(layoutView); + + return netlistView; + } + }; +#endif +} + +namespace CRL { + void OpenAccessWrapper::oaDriver(const string& path, Cell* cell) { +#ifdef HAVE_OPENACCESS + //for the moment a driver for hurricaneAMS + //save the Cell only and all used Cells + cerr << "Saving " << cell << " in " << path << endl; + try { + oaDesignInit(oacAPIMajorRevNumber, + oacAPIMinorRevNumber, + oacDataModelRevNumber); + + OADriver oaDriver(path); + oaDesign* design = oaDriver.getOADesignForCell(cell); + if(design) + cerr << "DONE ->" << getDesignName(design) << endl; + }catch (oaException &e) { + cerr << "OA::ERROR => " << e.getMsg() << endl; + exit(1); + }catch(std::exception& e){ + cerr << "STD::ERROR => " << e.what() << endl; + exit(2); + } +#else + cerr << "\nDummy OpenAccess driver call for " << path << endl; +#endif + } +} diff --git a/crlcore/src/ccore/openaccess/OpenAccessWrapper.h b/crlcore/src/ccore/openaccess/OpenAccessDriver.h similarity index 100% rename from crlcore/src/ccore/openaccess/OpenAccessWrapper.h rename to crlcore/src/ccore/openaccess/OpenAccessDriver.h diff --git a/crlcore/src/ccore/openaccess/OpenAccessUtils.h b/crlcore/src/ccore/openaccess/OpenAccessUtils.h new file mode 100644 index 00000000..5418aa3d --- /dev/null +++ b/crlcore/src/ccore/openaccess/OpenAccessUtils.h @@ -0,0 +1,257 @@ + +#ifndef __OPENACCESSUTILS_H__ +#define __OPENACCESSUTILS_H__ + +#include +using namespace std; + +#ifdef HAVE_OPENACCESS +#include "oa/oaDesignDB.h" +using namespace oa; + +#include "hurricane/Cell.h" +#include "hurricane/BasicLayer.h" +using namespace Hurricane; + +#undef assert +#define assert(cond) if (! (cond) ) throw Error("assertion failed : " + string( #cond ) ) +//#define assert(cond) + +namespace { + + /** + giving a oaDesign pointer that should be not NULL + return the oaString representing its name + */ + oaString getDesignName(oaDesign* design) { + cerr << "getDesignName" << endl; + assert(design); + oaNativeNS ns; + oaString libName, cellName, viewName; + design->getLibName(ns, libName); + design->getCellName(ns, cellName); + design->getViewName(ns, viewName); + oaString designName = "<" + libName + "," + cellName + "," + viewName + ">"; + return designName; + } + + /** + giving a oaBlock + print the connectivity, mainly used for debug purpose ... + @todo remove when not needed anymore + */ + void printBlockTerms(oaBlock* block) { + cerr << "printBlockTerms" << endl; + assert(block); + oaNativeNS ns; + oaDesign* design = block->getDesign(); + cerr << " o Printing " << getDesignName(design) << " terms" << endl; + oaIter termIter(block->getTerms()); + while (oaTerm* term = termIter.getNext()) { + oaString termName; + term->getName(ns, termName); + cerr << " - " << termName << endl; + } + cerr << endl; + } + + /** + Convert material from Hurricane to OA ... + @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: + //there is no blockage type but a specific oaLayerBlockage class + return oacOtherMaterial; + case BasicLayer::Material::other: return oacOtherMaterial; + default: + throw Error("Unrecognized material"); + } + } + + /** + Convertion helper for Net convertion ... + @todo verify + */ + oaTermType getOATermType(const Net::Direction& direction) { + cerr << "getOATermType" << endl; + 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 + */ + 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"); + } + } + + /** + Convertion helper ... + */ + oaOrient getOAOrientFromOrientation(const Transformation::Orientation& orientation) { + cerr << "getOAOrientFromOrientation" << endl; + 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"); + } + } + + /** + Convertion helper ... + */ + void getOATransformFromTransformation(oaTransform& transform, const Transformation& transformation) { + cerr << "getOATransformFromTransformation" << endl; + transform.set(transformation.getTx(), + transformation.getTy(), + getOAOrientFromOrientation(transformation.getOrientation())); + } + + /** + Convertion helper ... + */ + void getOABoxForBox(oaBox& box, const Box& hbox) { + cerr << "getOABoxForBox" << endl; + box.set(hbox.getXMin(), hbox.getYMin(), hbox.getXMax(), hbox.getYMax()); + } + + /** + Create InstTerm representing connection of nets ... + always return a non NULL value + */ + oaInstTerm* getInstTerm(oaInst* inst, Plug* plug,oaNet* net) { + cerr << "getInstTerm" << endl; + assert(inst); + assert(plug); + oaNativeNS ns; + oaScalarName scPlugName(ns, getString(plug->getMasterNet()->getName()).c_str()); + oaName instTermName(scPlugName); + oaInstTerm* instTerm = oaInstTerm::find(inst, instTermName); + if (instTerm) { + return instTerm; + } + oaDesign* design = inst->getMaster(); + assert(design); + oaBlock* masterBlock = design->getTopBlock(); + oaTerm* term = oaTerm::find(masterBlock, instTermName); + assert(term); + cerr << "looking for " << plug->getName() << endl; + printBlockTerms(masterBlock); + cerr << "oaInstTerm::create" << endl; + instTerm = oaInstTerm::create(net, inst, term); + assert(instTerm); + return instTerm; + } + + /** + save design stored in a map + */ + void saveDesignsInMap(map cell2OAdesign){ + for (map::iterator it = cell2OAdesign.begin(); + it != cell2OAdesign.end(); + ++it) { + cerr << it->first << endl; + oaDesign* design = it->second; + design->save(); + design->close(); + } + } + + /** + print the oaLayera in a oaTech ... + */ + void printOALayers(oaTech* theOATech){ + cerr << "printOALayers" << endl; + assert(theOATech); + oaIter lIter(theOATech->getLayers()); + while(oaLayer* l = lIter.getNext()){ + oaString layerName; + l->getName(layerName); + cerr << " o created oaLayer " << layerName << endl; + } + } + + /** + @todo complete,verify ... + */ + BasicLayer::Material::Code oaMaterialToBasicLayerType(const oaMaterial& material) { + switch(material) { + case oacNWellMaterial: + return BasicLayer::Material::nWell; + case oacPWellMaterial: + return BasicLayer::Material::pWell; + case oacNImplantMaterial: + return BasicLayer::Material::nImplant; + case oacPImplantMaterial: + return BasicLayer::Material::pImplant; + case oacPolyMaterial: + return BasicLayer::Material::poly; + case oacCutMaterial: + return BasicLayer::Material::cut; + case oacMetalMaterial: + case oacContactlessMetalMaterial: + return BasicLayer::Material::metal; + default: + return BasicLayer::Material::other; + } + } + + +}//end anonymous namespace + +#endif//HAVE_OPENACCESS + +#endif//__OPENACCESSUTILS_H__ diff --git a/crlcore/src/ccore/openaccess/OpenAccessWrapper.cpp b/crlcore/src/ccore/openaccess/OpenAccessWrapper.cpp deleted file mode 100644 index 2ca45739..00000000 --- a/crlcore/src/ccore/openaccess/OpenAccessWrapper.cpp +++ /dev/null @@ -1,969 +0,0 @@ -// -*-compile-command:"cd ../../../../.. && make"-*- -// Time-stamp: "2010-07-15 19:28:28" - OpenAccessWrapper.cpp -// x-----------------------------------------------------------------x -// | This file is part of the hurricaneAMS Software. | -// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | -// | =============================================================== | -// | Author : Chistophe Alexandre | -// | E-mail : Christophe.Alexandre@asim.lip6.fr | -// x-----------------------------------------------------------------x -// | Author : Jean-Manuel Caba | -// | E-mail : Jean-Manuel.Caba@asim.lip6.fr | -// x-----------------------------------------------------------------x - -#include -#include -#include -using namespace std; - -#ifdef HAVE_OPENACCESS -#include "oa/oaDesignDB.h" -using namespace oa; -#endif - -#include "hurricane/DataBase.h" -#include "hurricane/Technology.h" -#include "hurricane/Library.h" -#include "hurricane/Cell.h" -#include "hurricane/NetExternalComponents.h" -#include "hurricane/Segment.h" -#include "hurricane/Pad.h" -#include "hurricane/BasicLayer.h" -#include "hurricane/Slice.h" -using namespace Hurricane; - -#include "OpenAccessWrapper.h" - -#undef assert -#define assert(cond) if (! (cond) ) throw Error("assertion failed : " + string( #cond ) ) -//#define assert(cond) - - -namespace { - -#ifdef HAVE_OPENACCESS - - /** - giving a oaDesign pointer that should be not NULL - return the oaString representing its name - */ - oaString getDesignName(oaDesign* design) { - cerr << "getDesignName" << endl; - assert(design); - oaNativeNS ns; - oaString libName, cellName, viewName; - design->getLibName(ns, libName); - design->getCellName(ns, cellName); - design->getViewName(ns, viewName); - oaString designName = "<" + libName + "," + cellName + "," + viewName + ">"; - return designName; - } - - /** - giving a oaBlock - print the connectivity, mainly used for debug purpose ... - @todo remove when not needed anymore - */ - void printBlockTerms(oaBlock* block) { - cerr << "printBlockTerms" << endl; - assert(block); - oaNativeNS ns; - oaDesign* design = block->getDesign(); - cerr << " o Printing " << getDesignName(design) << " terms" << endl; - oaIter termIter(block->getTerms()); - while (oaTerm* term = termIter.getNext()) { - oaString termName; - term->getName(ns, termName); - cerr << " - " << termName << endl; - } - cerr << endl; - } - - /** - Convert material from Hurricane to OA ... - @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"); - } - } - - /** - Convertion helper for Net convertion ... - @todo verify - */ - oaTermType getOATermType(const Net::Direction& direction) { - cerr << "getOATermType" << endl; - 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 - */ - 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 << "getOAOrientFromOrientation" << endl; - 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"); - } - } - - 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()); - } - - /** - Create InstTerm representing connection of nets ... - always return a non NULL value - */ - oaInstTerm* getInstTerm(oaInst* inst, Plug* plug,oaNet* net) { - cerr << "getInstTerm" << endl; - assert(inst); - assert(plug); - oaNativeNS ns; - oaScalarName scPlugName(ns, getString(plug->getMasterNet()->getName()).c_str()); - oaName instTermName(scPlugName); - oaInstTerm* instTerm = oaInstTerm::find(inst, instTermName); - if (instTerm) { - return instTerm; - } - oaDesign* design = inst->getMaster(); - assert(design); - oaBlock* masterBlock = design->getTopBlock(); - oaTerm* term = oaTerm::find(masterBlock, instTermName); - assert(term); - cerr << "looking for " << plug->getName() << endl; - printBlockTerms(masterBlock); - cerr << "oaInstTerm::create" << endl; - instTerm = oaInstTerm::create(net, inst, term); - assert(instTerm); - return instTerm; - } - - /** - save design stored in a map - */ - void saveDesignsInMap(map cell2OAdesign){ - for (map::iterator it = cell2OAdesign.begin(); - it != cell2OAdesign.end(); - ++it) { - cerr << it->first << endl; - oaDesign* design = it->second; - design->save(); - design->close(); - } - } - - class OADriver { - private: - typedef map Library2OALibMap; - typedef map Cell2OADesignMap; - typedef pair OAInstPair; - typedef map Instance2OAInstsMap; - typedef map Layer2OAPhysicalLayerMap; - - string _path; - oaTech* _oaTech; - Library2OALibMap _library2OALib; - Cell2OADesignMap _cell2OADesign4Netlist; - Cell2OADesignMap _cell2OADesign4Schematic; - Cell2OADesignMap _cell2OADesign4Symbolic; - Cell2OADesignMap _cell2OADesign4Layout; - Instance2OAInstsMap _instance2OAInst; - Layer2OAPhysicalLayerMap _layer2OAPhysicalLayer; - DataBase* _db; - Technology* _technology; - int _layerID; - public: - OADriver(const string& path): - _path(path), - _oaTech(NULL), - _library2OALib(), - _cell2OADesign4Netlist(), - _cell2OADesign4Schematic(), - _cell2OADesign4Symbolic(), - _cell2OADesign4Layout(), - _instance2OAInst(), - _layer2OAPhysicalLayer(), - _db(NULL), - _technology(NULL), - _layerID(0) { - _db = DataBase::getDB(); - if (!_db) { - throw Error("no database"); - } - _technology = _db->getTechnology(); - if (!_technology) { - throw Error("no technology"); - } - } - - ~OADriver() { - cerr << "SAVING ALL" << endl; - _oaTech->save(); - _oaTech->close(); - saveDesignsInMap(_cell2OADesign4Netlist); - saveDesignsInMap(_cell2OADesign4Schematic); - saveDesignsInMap(_cell2OADesign4Symbolic); - saveDesignsInMap(_cell2OADesign4Layout); - for (Library2OALibMap::iterator it = _library2OALib.begin(); - it != _library2OALib.end(); - ++it) { - oaLib* lib = it->second; - lib->close(); - } - cerr << "ALL SAVED" << endl; - } - - /** - Create an empty oaLib from a Library - no cells are added in this oaLib - all sub Library are also converted. - */ - oaLib* getOALibForLibrary(const Library* library) { - cerr << "getOALibForLibrary" << endl; - assert(library); - Library2OALibMap::iterator it = _library2OALib.find(library); - if (it != _library2OALib.end()) { - return it->second; - } - oaNativeNS ns; - const char* strNameLib = getString(library->getName()).c_str(); - if (!strcmp(strNameLib, ".")) - strNameLib = "worklib"; - string strPathLib = _path + '/' + strNameLib; - cerr << "Creating new Library for Lib name=" - << strNameLib << " to filesystem path=" << strPathLib << endl; - oaScalarName scNameLib(ns, strNameLib); - cerr << "Creating new 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{ - 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; - - for_each_library(l ,library->getLibraries()){ - getOALibForLibrary(l); - end_for; - } -/* - cerr << "Overwriting cds.lib file" << endl; - oaLibDefList *ldl = oaLibDefList::get( "cds.lib", 'a' ); - assert(ldl); - oaLibDef::create( ldl, scNameLib, strPathLib.c_str() ); - ldl->save(); - ldl->destroy(); - ldl = NULL; - cerr << "Overwrited cds.lib file" << endl; -*/ - return lib; - } - - /** - convert oaLayer from a Layer ... - */ - oaLayer* getOALayerFromLayer(Layer* layer,oaTech* theOATech) { - cerr << "getOALayerFromLayer" << endl; - assert(layer); - oaString layerName = getString(layer->getName()).c_str(); - 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); - - _layer2OAPhysicalLayer[layer] = aOALayer; - - //TODO: add oaConstraint and oaConstraintGroup defined by technology -/* cerr << " o get value for constraint" << endl; - DbU::Unit minSize = layer->getMinimalSize(); - DbU::Unit minSpace = layer->getMinimalSpacing(); - DbU::Unit pitch = layer->getPitch(); - cerr << " o create constraint for min size" << endl; - oaLayerConstraint* cMinSize = oaLayerConstraint::create(aOALayer->getNumber(), - oaLayerConstraintDef::get(oacMinSize), - oaIntValue::create(theOATech->getLib(),minSize)); - assert(cMinSize); - cerr << " o create constraint for min space" << endl; - oaLayerConstraint* cMinSpace = oaLayerConstraint::create(aOALayer->getNumber(), - oaLayerConstraintDef::get(oacMinSpacing), - oaIntValue::create(theOATech->getLib(),minSpace)); - assert(cMinSpace); - cerr << " o create constraint for pitchH" << endl; - oaLayerConstraint* cPitchH = oaLayerConstraint::create(aOALayer->getNumber(), - oaLayerConstraintDef::get(oacHorizontalRouteGridPitch), - oaIntValue::create(theOATech->getLib(),pitch)); - assert(cPitchH); - - cerr << " o create constraint for pitchV" << endl; - oaLayerConstraint* cPitchV = oaLayerConstraint::create(aOALayer->getNumber(), - oaLayerConstraintDef::get(oacVerticalRouteGridPitch), - oaIntValue::create(theOATech->getLib(),pitch)); - assert(cPitchV); -*/ - if(bLayer){ - unsigned gdsIInumber = bLayer->getExtractNumber(); - } - return aOALayer; - } - - /** - print the oaLayera in a oaTech ... - */ - void printOALayers(oaTech* theOATech){ - cerr << "printOALayers" << endl; - assert(theOATech); - oaIter lIter(theOATech->getLayers()); - while(oaLayer* l = lIter.getNext()){ - oaString layerName; - l->getName(layerName); - cerr << " o created oaLayer " << layerName << endl; - } - } - - /** - 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 getOALibForLibrary - */ - oaTech* getOATechForTechnology(const Technology* technology) { - cerr << "createOATechForTechnology" << endl; - assert(technology); - if(_oaTech != NULL) - return _oaTech; - else - cerr << "working in createOATechForTechnology" << endl; - - //get or create Library for the techno - DataBase* db = technology->getDataBase(); - assert(db); - Library* lib = db->getRootLibrary(); - assert(lib); - oaLib* techOAlib = getOALibForLibrary(lib); - assert(techOAlib); - - cerr << "oaTech::find" << endl; - oaTech* theOATech = oaTech::find(techOAlib); - if(!theOATech){ - if (oaTech::exists(techOAlib)){ - cerr << "oaTech::open" << endl; - theOATech = oaTech::open(techOAlib,'a'); - } - if(!theOATech){ - cerr << "oaTech::create" << endl; - theOATech = oaTech::create(techOAlib); - }else{ - _oaTech = theOATech; - return theOATech; - } - }else{ - _oaTech = theOATech; - return theOATech; - } - assert(techOAlib); - theOATech->setDefaultManufacturingGrid(10); - theOATech->setDBUPerUU(oaViewType::get(oacMaskLayout), 1000); - - //TODO: add this layer - //first create "utility" layers - //strLayerDev ( "device" ); - //strLayerText( "text" ); - //strLayerPin ( "pin" ); - //strLayerWire( "wire" ); - - //create physical layer - for_each_layer(layer, technology->getLayers()) { - getOALayerFromLayer(layer,theOATech); - end_for; - } - - printOALayers(theOATech); - - _oaTech = theOATech; - return theOATech; - } - - /** - convert Hurricane::Instance to oaInst ... - */ - oaInst* getOAInstForInstance(Instance* instance,oaBlock* topBlock) { - cerr << "getOAInstForInstance " << instance << endl; - assert(instance); - Instance2OAInstsMap::iterator it = _instance2OAInst.find(instance); - if (it != _instance2OAInst.end()) { - return it->second; - } - assert(topBlock); - Cell* masterCell = instance->getMasterCell(); - assert(masterCell); - oaDesign* masterDesign = createNetlist(masterCell); - assert(masterDesign); - - - oaNativeNS ns; - 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(topBlock, masterDesign, scInstName, transform); - _instance2OAInst[instance] = blockInst; - return blockInst; - } - - /** - convert Hurricane::plug to oaInstTerm - and add it to if connected. - always return a non NULL value - */ - oaInstTerm* getOAInstTermFromPlug(Plug* plug,oaNet* net){ - cerr << "getOAInstTermFromPlug " << plug << endl; - assert(plug); - Instance* instance = plug->getInstance(); - Instance2OAInstsMap::iterator it = _instance2OAInst.find(instance); - assert(it != _instance2OAInst.end()); - oaInst* blockInst = it->second; - oaInstTerm* instTerm = getInstTerm(blockInst, plug,net); - assert(instTerm); - return instTerm; - } - - oaPin* getOAPinFromNet(Net* net,oaNet* blockNet){ - cerr << "getOAPinFromNet" << endl; - assert(net); - assert(net->isExternal()); - assert(blockNet); - oaNativeNS ns; - oaScalarName scNetName(ns, getString(net->getName()).c_str()); - oaTerm* term = oaTerm::create(blockNet, scNetName, getOATermType(net->getDirection())); - assert(term); - oaPin* pin = oaPin::create(term); - assert(pin); - -/* oaLayerNum layer; - oaPurposeNum purpose; - getLayerPurpose(block->getDesign(), "pin", "drawing", layer, purpose); - oaPinFig *fig = oaPolygon::create(block, layer, purpose, points); -*/ - return pin; - } - - oaRect* getOARectFromComponent(Component* component,oaBlock* topBlock){ - cerr << "getOARectFromComponent" << endl; - assert(component); - assert(topBlock); - oaBox box; - getOABoxForBox(box, component->getBoundingBox()); - Layer* layer = (Layer*) component->getLayer(); - assert(layer); - oaPhysicalLayer* physLayer = NULL; - Layer2OAPhysicalLayerMap::iterator it = _layer2OAPhysicalLayer.find(layer); - if (it != _layer2OAPhysicalLayer.end()) { - physLayer = it->second; - } - assert(physLayer); - oaLayerNum layerNum = physLayer->getNumber(); - oaRect* rect = oaRect::create(topBlock, layerNum, - oaPurpose::get(_oaTech, oacDrawingPurposeType)->getNumber(), - box); - return rect; - } - - /** - convert Hurricane::Net to oaNet only at - the logical abstraction point of view - always return a non NULL value - */ - oaNet* getOANetFromNet(Net* net,oaBlock* topBlock) { - cerr << "getOANetFromNet " << net << endl; - assert(net); - oaNativeNS ns; - oaScalarName scNetName(ns, getString(net->getName()).c_str()); - oaScalarNet* blockNet = oaScalarNet::create(topBlock, scNetName, getOASigType(net->getType())); - assert(blockNet); - if (net->isExternal()) { - oaPin* pin = getOAPinFromNet(net,blockNet); - Components externalComponents = NetExternalComponents::get(net); - for_each_component(component, externalComponents) { - oaRect* rect = getOARectFromComponent(component,topBlock); - rect->addToPin(pin); - end_for; - } - } - cerr << " o transformation of plugs" << endl; - for_each_plug(plug, net->getPlugs()) { - getOAInstTermFromPlug(plug,blockNet); - end_for; - } - return blockNet; - } - - /** - create oaRect for slice ... - */ - oaRect* getOARectFromSlice(Slice* slice,oaBlock* topBlock){ - cerr << "getOARectFromSlice" << endl; - assert(slice); - assert(topBlock); - for_each_component(component, slice->getComponents()) { - oaRect* rect = getOARectFromComponent(component,topBlock); - end_for; - } - } - - /** - Create oaDesign for netlist Cell View from the cell - */ - oaDesign* createNetlist(const Cell* cell) { - cerr << "createNetlist " << cell << endl; - assert(cell); - Cell2OADesignMap::iterator it = _cell2OADesign4Netlist.find(cell); - if (it != _cell2OADesign4Netlist.end()) { - return it->second; - } - - getOATechForTechnology(_technology); - oaNativeNS ns; - oaLib* lib = getOALibForLibrary(cell->getLibrary()); - assert(lib); - oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); - oaScalarName scNameView(ns, "netlist"); - oaScalarName scNameLib; - lib->getName(scNameLib); - - // create a netlist CellView of the cell - cerr << "oaDesign::open for netlist view" << endl; - oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, oaViewType::get(oacNetlist), 'w'); - _cell2OADesign4Netlist[cell] = designCellView; - cerr << "oaBlock::create for netlist view" << endl; - oaBlock* topBlock = oaBlock::create(designCellView); - assert(topBlock); - - cerr << "transformation of slices" << endl; - for_each_slice(slice, cell->getSlices()){ - getOARectFromSlice(slice,topBlock); - end_for; - } - cerr << "transformation of instances" << endl; - for_each_instance(instance, cell->getInstances()){ - getOAInstForInstance(instance,topBlock); - end_for; - } - cerr << "transformation of nets" << endl; - for_each_net(net, cell->getNets()){ - getOANetFromNet(net,topBlock); - end_for; - } - return designCellView; - } - - 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; - } - - getOATechForTechnology(_technology); - oaNativeNS ns; - oaLib* lib = getOALibForLibrary(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 - cerr << "oaDesign::open for schematic view" << endl; - oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, oaViewType::get(oacSchematic), 'w'); - _cell2OADesign4Schematic[cell] = designCellView; - - return designCellView; - } - - 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; - } - - getOATechForTechnology(_technology); - oaNativeNS ns; - oaLib* lib = getOALibForLibrary(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 - cerr << "oaDesign::open for symbolic view" << endl; - oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, oaViewType::get(oacSchematicSymbol), 'w'); - _cell2OADesign4Symbolic[cell] = designCellView; - - return designCellView; - } - - - /** - from genPhysical in OAGear - */ - double findArea(oaBlock *block) { - double totalArea = 0.0; - oaIter instIter(block->getInsts()); - while (oaInst *i = instIter.getNext()) { - oaDesign *master = i->getMaster(); - if (!master) { - oaString nameString; - i->getName(oaNativeNS(), nameString); - std::cerr << "Warning: black box found, assuming zero area:" - << nameString << std::endl; - } else { - oaBlock *masterBlock = master->getTopBlock(); - assert(masterBlock); - oaPRBoundary *bound = oaPRBoundary::find(masterBlock); - assert(bound); - oaBox bbox; - bound->getBBox(bbox); - oaUInt8 cellArea = static_cast(bbox.getWidth()) * - static_cast(bbox.getHeight()); - oaTech *tech = master->getTech(); - assert(tech); - totalArea += tech->dbuToUUArea(oaViewType::get(oacMaskLayout), cellArea); - } - } - return totalArea; - } - - /** - from genPhysical in OAGear - */ - oaSiteDef * findSiteDef(oaTech *tech){ - oaSiteDef *r = 0; - oaIter siteIter(tech->getSiteDefs()); - while (oaSiteDef *i = siteIter.getNext()) { - if (i->getSiteDefType() == oacCoreSiteDefType) { - if (!r || r->getWidth() > i->getWidth()) { - r = i; - } - } - } - return r; - } - - /** - from genPhysical in OAGear - */ - oaLayer * findMetal3(oaTech *tech){ - oaIter oaLayerIter(tech->getLayers()); - while (oaLayer *i = oaLayerIter.getNext()) { - if (i->getType() != oacPhysicalLayerType) { - continue; - } - oaMaterial m = (static_cast(i))->getMaterial(); - if (m != oacMetalMaterial) { - continue; - } - int metalLayersBelow = 0; - oaPhysicalLayer *belowLayer = (static_cast(i)) - ->getLayerBelow(oacMetalMaterial); - while (belowLayer) { - metalLayersBelow++; - belowLayer = - belowLayer->getLayerBelow(oacMetalMaterial); - } - if (metalLayersBelow == 2) { - return i; - } - } - return 0; - } - - /** - from genPhysical main in OAGear - */ - void genPhysical(oaDesign* physCV,oaDesign* netlistCV){ - double utilization = 0.70; - - // merge logically equivalent nets in original netlist view - oaBlock *topNetlistBlock = netlistCV->getTopBlock(); - assert(topNetlistBlock); - oaIter netIter(topNetlistBlock->getNets( - oacNetIterSingleBit | oacNetIterNotImplicit)); - while (oaNet *n = netIter.getNext()) { - oaBitNet *bn = static_cast(n); - oaBitNet *en = bn->getPreferredEquivalent(); - if (en != bn) { - en->merge(bn); - } - } - - // embed netlist into physical view - oaModule *topMod = oaModule::embed(physCV, netlistCV); - physCV->setTopModule(topMod); - oaBlock *topBlock = physCV->getTopBlock(); - assert(topBlock); - double totalArea = findArea(topBlock); - if (totalArea == 0.0) { - std::cerr << "ERROR : Design has zero area" << std::endl; - return ; - } - unsigned int numTerms = topBlock->getTerms().getCount(); - if (!numTerms) { - std::cerr << "ERROR : Design has no terms" << std::endl; - return ; - } - oaSiteDef *mySiteDef = findSiteDef(_oaTech); - assert(mySiteDef); - // compute die width and height - double width = sqrt(totalArea / utilization); - oaInt4 dbWidth = _oaTech->uuToDBUDistance(oaViewType::get(oacMaskLayout), width); - oaInt4 numSites = dbWidth / mySiteDef->getWidth() + 1; - dbWidth = numSites * mySiteDef->getWidth(); - double height = sqrt(totalArea / utilization); - oaInt4 dbHeight = _oaTech->uuToDBUDistance(oaViewType::get(oacMaskLayout), height); - oaInt4 numRows = dbHeight / mySiteDef->getHeight() + 1; - dbHeight = numRows * mySiteDef->getHeight(); - oaConstraintGroup *cg = oaConstraintGroup::find(_oaTech, "LEFDefaultRouteSpec"); - assert(cg); - // generate pins for terms and assign to boundary - double jump = (static_cast(dbWidth) + dbHeight) - * 2.0 / numTerms; - jump = static_cast(jump / mySiteDef->getWidth()); - assert(jump >= 1.0); - jump *= mySiteDef->getWidth(); - double pos = 0.0; - std::vector posVector(numTerms); - for (unsigned int i = 0; i < numTerms; ++i) { - posVector[i] = pos; - pos += jump; - } - std::random_shuffle(posVector.begin(), posVector.end()); - // find the route layer - Metal3 - oaLayer *routeLayer = findMetal3(_oaTech); - assert(routeLayer); - oaLayerNum routeLayerNum(routeLayer->getNumber()); - // get route width constraint for metal 3 to compute size of pins - oaConstraint *cons = oaLayerConstraint::find(cg, routeLayerNum, - oaLayerConstraintDef::get(oacMinWidth)); - oaValue *val = cons->getValue(); - oaInt4 m3Width = static_cast(val)->get(); - oaIter termIter(topBlock->getTerms()); - while (oaTerm *i = termIter.getNext()) { - pos = posVector.back(); - double x, y; - if (pos < dbWidth) { - x = pos; - y = 0.0; - } else if (pos < dbWidth + dbHeight) { - x = dbWidth; - y = pos - dbWidth; - } else if (pos < 2.0 * dbWidth + dbHeight) { - x = 2.0 * dbWidth + dbHeight - pos; - y = dbHeight; - } else { - x = 0.0; - y = 2.0 * dbWidth + 2.0 * dbHeight - pos; - } - oaInt4 ux = static_cast(x); - oaInt4 uy = static_cast(y); - oaBox pinBox(ux - m3Width / 2, uy - m3Width / 2, - ux + m3Width / 2, uy + m3Width / 2); - oaRect *pinRect = oaRect::create(topBlock, routeLayerNum, - oavPurposeNumberDrawing, pinBox); - assert(pinRect); - oaPin *pin = oaPin::create(i); - assert(pin); - pinRect->addToPin(pin); - pin->setPlacementStatus(oacFixedPlacementStatus); - posVector.pop_back(); - } - oaPointArray prBoundPoints(4); - oaPoint p0(0, 0); - prBoundPoints.append(p0); - oaPoint p1(0, dbHeight); - prBoundPoints.append(p1); - oaPoint p2(dbWidth, dbHeight); - prBoundPoints.append(p2); - oaPoint p3(dbWidth, 0); - prBoundPoints.append(p3); - oaPRBoundary *boundary = oaPRBoundary::create(topBlock, prBoundPoints); - oaBox cBox(p0, p2); - oaCoreBoxSpec coreSpec(cBox); - } - - oaDesign* addLayout(const Cell* cell,oaDesign* previous) { - cerr << "addLayout" << cell << endl; - assert(cell); - assert(previous); - Cell2OADesignMap::iterator it = _cell2OADesign4Layout.find(cell); - if (it != _cell2OADesign4Layout.end()) { - return it->second; - } - - getOATechForTechnology(_technology); - oaNativeNS ns; - oaLib* lib = getOALibForLibrary(cell->getLibrary()); - assert(lib); - oaScalarName scNameDesign(ns, getString(cell->getName()).c_str()); - oaScalarName scNameView(ns, "layout"); - oaScalarName scNameLib; - lib->getName(scNameLib); - - // create a layout CellView of the cell - cerr << "oaDesign::open for layout view" << endl; - oaDesign* designCellView = oaDesign::open(scNameLib, scNameDesign, scNameView, oaViewType::get(oacMaskLayout), 'w'); - _cell2OADesign4Layout[cell] = designCellView; - - -// genPhysical(designCellView,previous); - - return designCellView; - } - - oaDesign* getOADesignForCell(const Cell* cell) { - cerr << "getOADesignForCell " << cell << endl; - assert(cell); - - oaDesign* netlistView = createNetlist(cell); - assert(netlistView); - -/* - oaDesign* symbolicView = addSymbol(cell,netlistView); - assert(symbolicView); - - oaDesign* schematicView = addSchematic(cell,netlistView); - assert(schematicView); - - oaDesign* layoutView = addLayout(cell,schematicView); - assert(layoutView); -*/ - return netlistView; - } - }; -#endif -} - - -namespace CRL { - void OpenAccessWrapper::oaDriver(const string& path, Cell* cell) { -#ifdef HAVE_OPENACCESS - //for the moment a driver for hurricaneAMS - //save the Cell only and all used Cells - cerr << "Saving " << cell << " in " << path << endl; - try { - oaDesignInit(oacAPIMajorRevNumber, - oacAPIMinorRevNumber, - oacDataModelRevNumber); - - OADriver oaDriver(path); - oaDesign* design = oaDriver.getOADesignForCell(cell); - if(design) - cerr << "DONE ->" << getDesignName(design) << endl; - } catch (oaException &excp) { - cerr << "ERROR: " << excp.getMsg() << endl; - exit(1); - } -#else - cerr << "\nDummy OpenAccess driver call for " << path << endl; -#endif - } -} diff --git a/crlcore/src/ccore/openaccess/obsolete/COpenAccessBridgeLayer.cpp b/crlcore/src/ccore/openaccess/obsolete/COpenAccessBridgeLayer.cpp deleted file mode 100644 index 629d39ab..00000000 --- a/crlcore/src/ccore/openaccess/obsolete/COpenAccessBridgeLayer.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// x-----------------------------------------------------------------x -// | This file is part of the hurricaneAMS Software. | -// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | -// | =============================================================== | -// | Author : Chistophe Alexandre | -// | E-mail : Christophe.Alexandre@asim.lip6.fr | -// x-----------------------------------------------------------------x -#include "COpenAccessBridgeLayer.h" - -namespace CRL { - -BasicLayer::Material::Code COpenAccessBridgeLayer::oaMaterialToBasicLayerType(const oaMaterial& material) { - switch(material) { - case oacMetalMaterial: - case oacContactlessMetalMaterial: - return BasicLayer::Material::metal; - default: - return BasicLayer::Material::other; - } -} - -} diff --git a/crlcore/src/ccore/openaccess/obsolete/COpenAccessBridgeLayer.h b/crlcore/src/ccore/openaccess/obsolete/COpenAccessBridgeLayer.h deleted file mode 100644 index 8192fd0f..00000000 --- a/crlcore/src/ccore/openaccess/obsolete/COpenAccessBridgeLayer.h +++ /dev/null @@ -1,26 +0,0 @@ -// x-----------------------------------------------------------------x -// | This file is part of the hurricaneAMS Software. | -// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | -// | =============================================================== | -// | Author : Chistophe Alexandre | -// | E-mail : Christophe.Alexandre@asim.lip6.fr | -// x-----------------------------------------------------------------x -#ifndef __COPENACCESS_BRIDGE_LAYER_H__ -#define __COPENACCESS_BRIDGE_LAYER_H__ - -#include "hurricane/BasicLayer.h" -using namespace Hurricane; - -#include "oa/oaDesignDB.h" -using namespace oa; - -namespace CRL { - -class COpenAccessBridgeLayer { - public: - static BasicLayer::Material::Code oaMaterialToBasicLayerType(const oaMaterial& material); -}; - -} - -#endif /* __COPENACCESS_BRIDGE_LAYER_H__ */ diff --git a/crlcore/src/ccore/openaccess/script/cadence_oa.sh b/crlcore/src/ccore/openaccess/script/cadence_oa.sh new file mode 100755 index 00000000..5e01c0ea --- /dev/null +++ b/crlcore/src/ccore/openaccess/script/cadence_oa.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# +# we assume that the directory pointed by OPENACCESS_TOP is like in other project of the lab +# to do so we should have : +# - included symbolic link to bin data lib and license directories from cadence OA +# - included doc and example from si2.org OA +# - included a symbolic link to an installation of headers from si2.org OA +# +# this script set environment variable for crlcore compilation with cadence OA +# with these hypothesis +# +#OA_VERSION=oa_v22.04.057 +#ARCH=linux_rhel40_64 +# + +export OPENACCESS_TOP=$TEMP/CADENCE_OA + +#get OPUS_TOP and tools +#from virtuoso editor +source $TEMP/IC613.sh + +# we need oa + specific cadence libs ... +export OA_LIB_PATH=$OPENACCESS_TOP/lib:$OPUS_TOP/tools.lnx86/lib/64bit +echo $OA_LIB_PATH + +export OA_INCLUDE_PATH=$OPENACCESS_TOP/include +echo $OA_INCLUDE_PATH + +export LD_LIBRARY_PATH=$OA_LIB_PATH:$LD_LIBRARY_PATH + +#for plugins .plg files +export OA_PLUGIN_PATH=$OPENACCESS_TOP/data/plugins + +#get encouter router too +source $TEMP/EDI910.sh + diff --git a/crlcore/src/ccore/openaccess/test/Makefile b/crlcore/src/ccore/openaccess/test/Makefile index e8def15c..a13a34c1 100644 --- a/crlcore/src/ccore/openaccess/test/Makefile +++ b/crlcore/src/ccore/openaccess/test/Makefile @@ -3,14 +3,17 @@ all: ./compile.sh -run: - cd x86_64/usr/local/bin && ./testOAWrapper /asim/chams/etc/chams/config.freePDK45.xml +run: + cd x86_64/usr/local/bin && ./testOAWrapper /asim/chams/etc/chams/config.freePDK45.xml /tmp/testOA -debug: - cd x86_64/usr/local/bin && gdb -args ./testOAWrapper /asim/chams/etc/chams/config.freePDK45.xml +debug: + cd x86_64/usr/local/bin && gdb -args ./testOAWrapper /asim/chams/etc/chams/config.freePDK45.xml /tmp/testOA -ddd: - cd x86_64/usr/local/bin && ddd -args ./testOAWrapper /asim/chams/etc/chams/config.freePDK45.xml +ddd: + cd x86_64/usr/local/bin && ddd -args ./testOAWrapper /asim/chams/etc/chams/config.freePDK45.xml /tmp/testOA + +rmtmp: + rm -rf /tmp/* clean: rm -rf x86_64 diff --git a/crlcore/src/ccore/openaccess/test/src/main.cpp b/crlcore/src/ccore/openaccess/test/src/main.cpp index d471558d..bd7cabd8 100755 --- a/crlcore/src/ccore/openaccess/test/src/main.cpp +++ b/crlcore/src/ccore/openaccess/test/src/main.cpp @@ -23,6 +23,8 @@ using namespace Hurricane; #include "crlcore/SymbolicTechnologyParser.h" #include "crlcore/AllianceFramework.h" +using namespace CRL; + #include "hurricaneAMS/environment/AnalogEnv.h" #include "hurricaneAMS/devices/SimpleCurrentMirror.h" @@ -34,23 +36,24 @@ namespace { static string libName = "WorkLibrary"; }; -void testCell(Cell* dev){ +void testCell(Cell* dev,char* pathToTest){ if(dev){ cout << "Cell created" << endl; }else{ cout << "Cell not created" << endl; return; } -// cout << "driving GDS" << endl; -// CRL::GdsDriver(dev).save("/tmp/testGDS"); + system((string("mkdir -p ") + string(pathToTest)).c_str()); + cout << "driving GDS" << endl; + GdsDriver(dev).save(string(pathToTest) + "/GDSdrive"); cout << "driving OA" << endl; - CRL::OADriver(dev).save("/tmp/testOA"); + OADriver(dev).save(string(pathToTest) + "/OAdrive"); } -void testAnalog(char* pathToConf){ +void testAnalog(char* pathToConf,char* pathToTest){ AnalogEnv::create(pathToConf);//create Database ... - cout << "analog environment loaded and database created" << endl; + cout << "analog environment loaded and database created" << endl; DataBase* db = DataBase::getDB(); assert(db != NULL); Library* rootLib = db->getRootLibrary(); @@ -77,28 +80,27 @@ void testAnalog(char* pathToConf){ TransistorFamily::NMOS, bulkConnected); - cout << "testing cell myCM" << endl; - testCell(dev); + cout << "testing cell myCM" << endl; + testCell(dev,pathToTest); db->destroy(); } -void testNum(){ +void testNum(char* pathToConf,char* pathToTest){ cout << "creating cell from sxlib inv_x1" << endl; - DataBase* db = NULL; - Cell* mySxlibCell = CRL::AllianceFramework::get()->getCell( "inv_x1", CRL::Catalog::State::Views ); + 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; - testCell(mySxlibCell); - db = DataBase::getDB(); - assert(db != NULL); - db->destroy(); + testCell(cell,pathToTest); } int main(int argc,char** argv) { - if(argc != 2) + if(argc != 3) exit(-5); - testAnalog(argv[1]); -// testNum(); + // testAnalog(argv[1],argv[2]); + testNum(argv[1],argv[2]); cout << "ending normally" << endl; return 0;