O correct bug : don't always create an oaScalarInst, when the instance already exist (saved to disk and reading), just find it.

O integration of old parser
 O and more, more cleaning.
This commit is contained in:
Jean-Manuel Caba 2010-07-27 15:38:16 +00:00
parent 2ac25af062
commit 2b78ecef1a
16 changed files with 1080 additions and 2137 deletions

View File

@ -42,6 +42,7 @@
crlcore/COptions.h crlcore/COptions.h
crlcore/XmlParser.h crlcore/XmlParser.h
crlcore/GdsDriver.h crlcore/GdsDriver.h
crlcore/OAParser.h
crlcore/OADriver.h crlcore/OADriver.h
crlcore/CifDriver.h crlcore/CifDriver.h
crlcore/SearchPath.h crlcore/SearchPath.h
@ -75,7 +76,7 @@
COptions.cpp COptions.cpp
XmlParser.cpp XmlParser.cpp
GdsDriver.cpp GdsDriver.cpp
OADriver.cpp OAParserDriver.cpp
CifDriver.cpp CifDriver.cpp
SearchPath.cpp SearchPath.cpp
Environment.cpp Environment.cpp
@ -133,7 +134,8 @@
if ( OA_FOUND ) if ( OA_FOUND )
include_directories ( ${OA_INCLUDE_DIR} ) include_directories ( ${OA_INCLUDE_DIR} )
endif ( OA_FOUND ) endif ( OA_FOUND )
set (openaccess_cpps openaccess/OpenAccessDriver.cpp ) set (openaccess_cpps openaccess/OpenAccessDriver.cpp
openaccess/OpenAccessParser.cpp )
set ( VstParserSourceDir ${CRLCORE_SOURCE_DIR}/src/ccore/alliance/vst ) set ( VstParserSourceDir ${CRLCORE_SOURCE_DIR}/src/ccore/alliance/vst )
set ( VstParserBinaryDir ${CRLCORE_BINARY_DIR}/src/ccore/alliance/vst ) set ( VstParserBinaryDir ${CRLCORE_BINARY_DIR}/src/ccore/alliance/vst )

View File

@ -1,15 +0,0 @@
// -*- C++ -*-
#include "hurricane/Cell.h"
using namespace Hurricane;
#include "crlcore/OADriver.h"
#include "openaccess/OpenAccessDriver.h"
namespace CRL {
OADriver::OADriver(Cell* cell) : _cell(cell) {}
void OADriver::save(const string& filePath) {
CRL::OpenAccessWrapper::oaDriver(filePath, _cell);
}
}// namespace CRL

View File

@ -0,0 +1,25 @@
// -*- C++ -*-
#include "hurricane/Cell.h"
using namespace Hurricane;
#include "crlcore/OADriver.h"
#include "crlcore/OAParser.h"
#include "openaccess/OpenAccess.h"
namespace CRL {
OADriver::OADriver(Cell* cell) : _cell(cell) {}
void OADriver::save(const string& filePath) {
CRL::OpenAccess::oaDriver(filePath, _cell);
}
OAParser::OAParser(const string& libPath,const string& cellName)
: _libPath(libPath), _cellName(cellName) {}
Cell* OAParser::open() {
//dummy for now
return NULL;
}
}// namespace CRL

View File

@ -62,7 +62,7 @@
# include "Spice.h" # include "Spice.h"
# include "Bookshelf.h" # include "Bookshelf.h"
# include "LefDef.h" # include "LefDef.h"
# include "openaccess/OpenAccessDriver.h" # include "openaccess/OpenAccess.h"
namespace { namespace {
@ -219,8 +219,8 @@ namespace CRL {
registerSlot ( "spi", (CellParser_t*)spiceParser , "spi" ); registerSlot ( "spi", (CellParser_t*)spiceParser , "spi" );
registerSlot ( "def", (CellParser_t*)defParser , "def" ); registerSlot ( "def", (CellParser_t*)defParser , "def" );
registerSlot ( "def", (LibraryParser_t*)lefParser , "lef" ); registerSlot ( "def", (LibraryParser_t*)lefParser , "lef" );
// registerSlot ( "oa", (CellParser_t*)OpenAccessWrapper::oaDesignLoader , "oa" ); registerSlot ( "oa", (CellParser_t*)OpenAccess::oaCellParser , "oa" );
// registerSlot ( "oa", (LibraryParser_t*)OpenAccessWrapper::oaLibLoader , "oa" ); registerSlot ( "oa", (LibraryParser_t*)OpenAccess::oaLibParser , "oa" );
registerSlot ( "aux", (CellParser_t*)bookshelfParser, "aux" ); registerSlot ( "aux", (CellParser_t*)bookshelfParser, "aux" );
} }
@ -334,7 +334,7 @@ namespace CRL {
registerSlot ( "def", (CellDriver_t*)defDriver , "def" ); registerSlot ( "def", (CellDriver_t*)defDriver , "def" );
registerSlot ( "aux", (CellDriver_t*)bookshelfDriver, "test.aux" ); registerSlot ( "aux", (CellDriver_t*)bookshelfDriver, "test.aux" );
registerSlot ( "spi", (CellDriver_t*)spiceDriver , "spi" ); registerSlot ( "spi", (CellDriver_t*)spiceDriver , "spi" );
registerSlot ( "oa" , (CellDriver_t*)OpenAccessWrapper::oaDriver, ""); registerSlot ( "oa" , (CellDriver_t*)OpenAccess::oaDriver, "oa");
} }

View File

@ -11,12 +11,11 @@ namespace Hurricane {
namespace CRL { namespace CRL {
class OADriver { class OADriver {
private:
Hurricane::Cell* _cell;
public: public:
OADriver(Hurricane::Cell*); OADriver(Hurricane::Cell*);
void save(const std::string& path); void save(const std::string& path);
private:
Hurricane::Cell* _cell;
}; };
} // End of CRL namespace. } // End of CRL namespace.

View File

@ -0,0 +1,23 @@
// -*- C++ -*-
#ifndef __OA_PARSER_H__
#define __OA_PARSER_H__
#include <string>
namespace Hurricane {
class Cell;
}
namespace CRL {
class OAParser {
private:
std::string _libPath;
std::string _cellName;
public:
OAParser(const string& libPath,const string& cellName);
Hurricane::Cell* open();
};
} // End of CRL namespace.
#endif//__OA_PARSER_H__

View File

@ -1,5 +1,5 @@
// -*-compile-command:"cd ../../../../.. && make"-*- // -*-compile-command:"cd ../../../../.. && make"-*-
// Time-stamp: "2010-07-07 13:37:14" - OpenAccessWrapper.h // Time-stamp: "2010-07-26 16:16:41" - OpenAccess.h
// x-----------------------------------------------------------------x // x-----------------------------------------------------------------x
// | This file is part of the hurricaneAMS Software. | // | This file is part of the hurricaneAMS Software. |
// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | // | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved |
@ -11,8 +11,8 @@
// | E-mail : Jean-Manuel.Caba@asim.lip6.fr | // | E-mail : Jean-Manuel.Caba@asim.lip6.fr |
// x-----------------------------------------------------------------x // x-----------------------------------------------------------------x
#ifndef __OPENACCESSWRAPPER_H__ #ifndef __OPENACCESS_H__
#define __OPENACCESSWRAPPER_H__ #define __OPENACCESS_H__
#include <string> #include <string>
@ -21,11 +21,23 @@ namespace Hurricane {
class Cell; class Cell;
} }
namespace CRL { #ifdef HAVE_OPENACCESS
class OpenAccessWrapper { #include "oa/oaDesignDB.h"
public: using namespace oa;
static void oaDriver(const std::string& cellPath, Cell* cell); #else
}; namespace oa {
class oaCell;
class oaLib;
} }
#endif
#endif /*__OPENACCESSWRAPPER_H__ */ namespace CRL {
class OpenAccess {
public:
static Hurricane::Cell* oaCellParser(oa::oaCell* cell);
static Hurricane::Library* oaLibParser(oa::oaLib* lib);
static oa::oaCell* oaDriver(const std::string& libPath, Hurricane::Cell* cell);
};
}//namespace CRL
#endif /*__OPENACCESS_H__ */

View File

@ -0,0 +1,624 @@
// -*-compile-command:"cd ../../../../.. && make"-*-
// Time-stamp: "2010-07-26 16:09:36" - OpenAccessCommon.h
// 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
#ifndef __OPENACCESSCOMMON_H__
#define __OPENACCESSCOMMON_H__
#include <iostream>
using namespace std;
#ifdef HAVE_OPENACCESS
#include "hurricane/Cell.h"
#include "hurricane/BasicLayer.h"
using namespace Hurricane;
#include "oa/oaDesignDB.h"
using namespace oa;
#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
*/
inline 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
*/
inline void printBlockTerms(oaBlock* block) {
cerr << "printBlockTerms" << endl;
assert(block);
oaNativeNS ns;
oaDesign* design = block->getDesign();
cerr << " o Printing " << getDesignName(design) << " terms" << endl;
oaIter<oaTerm> 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
*/
inline 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
*/
inline 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
*/
inline 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 ...
*/
inline 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 ...
*/
inline void getOATransformFromTransformation(oaTransform& transform, const Transformation& transformation) {
cerr << "getOATransformFromTransformation" << endl;
transform.set(transformation.getTx(),
transformation.getTy(),
getOAOrientFromOrientation(transformation.getOrientation()));
}
/**
Convertion helper ...
*/
inline 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
*/
inline 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
*/
inline void saveDesignsInMap(map<const Cell*, oaDesign*> cell2OAdesign){
for (map<const Cell*, oaDesign*>::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 ...
*/
inline void printOALayers(oaTech* theOATech){
cerr << "printOALayers" << endl;
assert(theOATech);
oaIter<oaLayer> lIter(theOATech->getLayers());
while(oaLayer* l = lIter.getNext()){
oaString layerName;
l->getName(layerName);
cerr << " o created oaLayer " << layerName << endl;
}
}
/**
@todo complete,verify ...
*/
inline 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;
}
}
/**
generate info from library name
*/
inline pair<oaScalarName,string> libInfos(const string& path,
const string& libName){
oaNativeNS ns;
const char* strNameLib = libName.c_str();
oaScalarName scNameLib(ns, strNameLib);
string strPathLib = path + '/' + strNameLib;
return make_pair<oaScalarName,string>(scNameLib,strPathLib);
}
/**
open oaLib with the info gathered by libPath function
*/
inline oaLib* openOALib(const pair<oaScalarName,string>& infos){
oaLib *lib = oaLib::find(infos.first);
const char* pathLib = infos.second.c_str();
if (!lib) {
if (oaLib::exists(pathLib)){
lib = oaLib::open(infos.first, pathLib);
}else{
string cmd = "mkdir -p "+ infos.second;
system(cmd.c_str());
}
if(!lib){
lib = oaLib::create(infos.first, pathLib);
}
}
return lib;
}
inline void createCDS(const pair<oaScalarName,string>& infos){
try{
cerr << "Overwriting cds.lib file begin" << endl;
string cdsPath = infos.second + "/cds.lib";
oaLibDefList* ldl = oaLibDefList::get( cdsPath.c_str(), 'a');
assert(ldl);
assert(ldl->isValid());
if(!oaLibDef::find(ldl, infos.first))
oaLibDef::create(ldl, infos.first, infos.second.c_str());
ldl->save();
ldl->destroy();//claim memory
ldl = NULL;
cerr << "Overwrited cds.lib file end" << endl;
}catch(oaException& e){
cerr << "ERROR cds: " << e.getMsg() << endl;
exit(-2);
}
}
inline oaCell* OADesignToOACell(oaDesign* design){
assert(design);
oaScalarName cellName;
design->getCellName(cellName);
oaLib* lib = design->getLib();
oaBoolean gotAccess = false;
gotAccess = lib->getAccess(oacReadLibAccess);
oaCell* cell = oaCell::find(lib,cellName);
if(gotAccess)
lib->releaseAccess();
assert(cell);
return cell;
}
//multiplicator of BBOX coordinates
static int convertFactor = 1;
//for namespaces in Hurricane
static const Name OACellLibrariesName("OACellLibraries");
static const Name OADesignLibrariesName("OADesignLibraries");
inline Library* findLibraryByNameInLibrary(const Library* rootLibrary, const Name& libraryName) {
for_each_library(library, rootLibrary->getLibraries()) {
if (library->getName() == libraryName) {
return library;
}
Library* foundLibrary = findLibraryByNameInLibrary(library, libraryName);
if (foundLibrary) {
return foundLibrary;
}
end_for;
}
return NULL;
}
inline Library* findLibraryByNameInDB(const DataBase* db, const Name& libraryName) {
Library* rootLibrary = db->getRootLibrary();
if (rootLibrary->getName() == libraryName) {
return rootLibrary;
}
return findLibraryByNameInLibrary(rootLibrary, libraryName);
}
inline void getAllCells(Library* rootLibrary, set<Cell*>& cellSet) {
for_each_cell(cell, rootLibrary->getCells()) {
cellSet.insert(cell);
end_for;
}
for_each_library(library, rootLibrary->getLibraries()) {
getAllCells(library, cellSet);
end_for;
}
}
inline Cell* findCellInLibraries(const Library* rootLibrary, const Name& cellName) {
for_each_cell(cell, rootLibrary->getCells()) {
if (cell->getName() == cellName) {
return cell;
}
end_for;
}
for_each_library(library, rootLibrary->getLibraries()) {
Cell* cell = findCellInLibraries(library, cellName);
if (cell) {
return cell;
}
end_for;
}
return NULL;
}
inline Library* getRootLibrary() {
DataBase* db = DataBase::getDB();
if (!db) {
return NULL;
}
return db->getRootLibrary();
}
/**
function helper
*/
inline Library* getOACellLibraries() {
Library* rootLibrary = getRootLibrary();
if (!rootLibrary) {
return NULL;
}
for_each_library(library, rootLibrary->getLibraries()) {
if (library->getName() == OACellLibrariesName) {
return library;
}
end_for;
}
return NULL;
}
/**
helper function
*/
inline Library* getOADesignLibraries() {
Library* rootLibrary = getRootLibrary();
if (!rootLibrary) {
return NULL;
}
for_each_library(library, rootLibrary->getLibraries()) {
if (library->getName() == OADesignLibrariesName) {
return library;
}
end_for;
}
return NULL;
}
/**
utility to open a design by name
*/
inline oaView* pickView(oaCell* oa_Cell) {
//oacMaskLayout Type is first
oaView* toReturnView = NULL;
oaCollection<oaCellView, oaCell> cellViews = oa_Cell->getCellViews();
oaIter<oaCellView> cellViewIter(cellViews);
while (oaCellView* cellView = cellViewIter.getNext()) {
oaView* view = cellView->getView();
oaViewType* viewType = view->getViewType();
oaScalarName viewName;
view->getName(viewName);
if (viewType == oaViewType::get(oacMaskLayout)) {
return view;
}
if (viewType == oaViewType::get(oacSchematic) ||
viewType == oaViewType::get(oacNetlist) ||
viewType == oaViewType::get(oacSchematicSymbol)) {
toReturnView = view;
}
}
return toReturnView;
}
/**
utility to open a design by name
*/
inline oaDesign* openDesign(const oaNameSpace& oaNS, oaCell* oa_Cell) {
oaView* view = pickView(oa_Cell);
if (view != NULL) {
oaScalarName libName;
oaLib* cellLib = oa_Cell->getLib();
cellLib->getName(libName);
oaScalarName cellName;
oa_Cell->getName(cellName);
oaViewType* viewType = view->getViewType();
oaScalarName viewName;
view->getName(viewName);
return oaDesign::open(libName, cellName, viewName, viewType, 'r');
}
return NULL;
}
void loadOACellInCell(oaCell* oa_Cell, Cell* cell) {
oaNativeNS oaNS;
oaDesign* cellDesign = openDesign(oaNS, oa_Cell);
if (cellDesign != NULL) {
oaModule* module = cellDesign->getTopModule();
oaCollection<oaModInst, oaModule> oaModInsts = module->getInsts();
oaIter<oaModInst> modInstIter(oaModInsts);
while (oaModInst* modInst = modInstIter.getNext()) {
oaString oaModInstStr;
modInst->getName(oaNS, oaModInstStr);
//cerr << "inst : " << oaModInstStr << endl;
oaModule* masterModule = modInst->getMasterModule();
if (masterModule) {
oaString oaModuleStr;
masterModule->getName(oaNS, oaModuleStr);
//cerr << "master : " << oaModuleStr << endl;
//find hurricane Cell
Cell* masterCell = findCellInLibraries(getRootLibrary(), Name(oaModuleStr));
if (!masterCell) {
cout << "\n***Quitting. Cannot get MasterCell :" ;
cout << oaModuleStr << endl;
exit(8);
}
Instance* instance = Instance::create(cell, Name(oaModInstStr) ,masterCell);
//cerr << instance << endl;
} else {
cerr << "master : NULL" << endl;
}
}//end while
//now treat nets
oaCollection<oaModNet, oaModule> oaModNets = module->getNets();
oaIter<oaModNet> oaModNetIter(oaModNets);
while (oaModNet* oa_ModNet = oaModNetIter.getNext()) {
oaString oaModNetStr;
oa_ModNet->getName(oaNS, oaModNetStr);
//cerr << oaModNetStr << endl;
Net* net = cell->getNet(Name(oaModNetStr));
if (!net) {
net = Net::create(cell, Name(oaModNetStr));
}
oaCollection<oaModInstTerm, oaModNet> oaModInstTerms = oa_ModNet->getInstTerms();
oaIter<oaModInstTerm> oaModInstTermIter(oaModInstTerms);
while (oaModInstTerm* oa_ModInstTerm = oaModInstTermIter.getNext()) {
oaModInst* modInst = oa_ModInstTerm->getInst();
oaString oaModInstStr;
modInst->getName(oaNS, oaModInstStr);
//find hurricane instance
Instance* instance = cell->getInstance(Name(oaModInstStr));
if (!instance) {
cout << "\n***Quitting. Cannot get Instance :" ;
cout << oaModInstStr << endl;
exit(8);
}
oaModTerm* oa_ModTerm = oa_ModInstTerm->getTerm();
oaString oaModTermStr;
oa_ModTerm->getName(oaNS, oaModTermStr);
Net* masterNet = instance->getMasterCell()->getNet(Name(oaModTermStr));
if (!masterNet) {
cout << "\n***Quitting. Cannot get Master Net :" ;
cout << oaModTermStr << endl;
exit(8);
}
Plug* plug = instance->getPlug(masterNet);
plug->setNet(net);
//cerr << plug << endl;
}
//cerr << net << endl;
}
oaScalarName cellName;
oa_Cell->getName(cellName);
oaString cellNameString;
cellName.get(cellNameString);
cell->setName(Name(cellNameString));
cell->setTerminal(false);
//physical part
oaBlock* block = cellDesign->getTopBlock();
if (block) {
oaBox oa_box;
block->getBBox(oa_box);
Point lowerLeft(DbU::db(oa_box.lowerLeft().x()), DbU::db(oa_box.lowerLeft().y()));
Point upperRight(DbU::db(oa_box.upperRight().x()), DbU::db(oa_box.upperRight().y()));
cell->setAbutmentBox(Box(lowerLeft, upperRight));
oaCollection<oaInst, oaBlock> oaInsts = block->getInsts();
oaIter<oaInst> oaInstIter(oaInsts);
while (oaInst* oa_Inst = oaInstIter.getNext()) {
oaString oaInstStr;
oa_Inst->getName(oaNS, oaInstStr);
Instance* instance = cell->getInstance(Name(oaInstStr));
if (instance) {
//cerr << "found " << instance << endl;
oaPlacementStatus placementStatus= oa_Inst->getPlacementStatus();
//switch (placementStatus) {
// case oacNonePlacementStatus :
// cerr << " none" << endl;
// break;
// case oacUnplacedPlacementStatus :
// cerr << " unplaced" << endl;
// break;
// case oacPlacedPlacementStatus :
// cerr << " placed" << endl;
// break;
// case oacFixedPlacementStatus :
// cerr << " fixed" << endl;
// break;
// default :
// cerr << "other" << endl;
//}
oaPoint instOrigin;
oa_Inst->getOrigin(instOrigin);
//cerr << instOrigin.x() << " " << instOrigin.y() << endl;
} else {
cerr << "cannot find " << oaInstStr << endl;
}
}
oaSitePattern sitePattern;
block->getSitePattern(sitePattern);
for (int i = 0; i < sitePattern.getNumElements(); i++) {
const oaSiteRef& siteRef = sitePattern.get(i);
cerr << "site : " << siteRef.siteName() << endl;
}
oaCollection<oaRow, oaBlock> oaRows = block->getRows();
oaIter<oaRow> oaRowIter(oaRows);
while (oaRow* oa_Row = oaRowIter.getNext()) {
cerr << "row" << endl;
oaString siteName;
oa_Row->getSiteDefName(siteName);
cerr << siteName << endl;
}
oaCollection<oaAreaBoundary, oaBlock> oaAreaBoundaries = block->getBoundaries();
oaIter<oaBoundary> oaBoundaryIter(oaAreaBoundaries);
while (oaBoundary* oa_Boundary = oaBoundaryIter.getNext()) {
cerr << "boundary" << endl;
}
} else {
cerr << "no block view " << endl;
}
}//end if (cellDesign != NULL)
}
}//end anonymous namespace
#endif//HAVE_OPENACCESS
#endif//__OPENACCESSCOMMON_H__

View File

@ -1,658 +0,0 @@
// -*-compile-command:"cd ../../../../.. && make"-*-
// Time-stamp: "2010-07-23 16:05:52" - 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 <iostream>
#include <algorithm>
#include <vector>
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<const Library*, oaLib*> Library2OALibMap;
typedef map<const Cell*, oaDesign*> Cell2OADesignMap;
typedef map<Instance*, oaInst*> Instance2OAInstsMap;
typedef map<Layer*, oaPhysicalLayer*> 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
pair<oaScalarName,string> infos=libInfos(_path,
getString(library->getName()));
oaLib *lib = openOALib(infos);
_library2OALib[library] = lib;
#if 0
// 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;
}
#endif
// 4) create, update library list file
createCDS(infos);
return lib;
}
/**
convert oaLayer from a Layer ...
*/
oaLayer* getOALayerFromLayer(Layer* layer,oaTech* theOATech) {
cerr << "getOALayerFromLayer" << endl;
assert(layer);
Layer2OAPhysicalLayerMap::iterator it = _layer2OAPhysicalLayer.find(layer);
if (it != _layer2OAPhysicalLayer.end()) {
return it->second;
}
assert(theOATech);
// 1) get or create layer
oaString layerName = getString(layer->getName()).c_str();
oaPhysicalLayer* aOALayer = NULL;
aOALayer = oaPhysicalLayer::find(theOATech, layerName, true);
if(aOALayer){
_layer2OAPhysicalLayer[layer] = aOALayer;
return aOALayer;
}
BasicLayer* bLayer = dynamic_cast<BasicLayer*>(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());
#if 0
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);
#endif
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,const Library* lib) {
cerr << "createOATechForTechnology" << endl;
assert(technology);
// 1) get or create Library for the techno
assert(lib);
oaLib* techOAlib = getOALibForLibrary(lib);
assert(techOAlib);
// 2) get or create oaTech container
bool created = false;
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);
created = true;
}
}
assert(techOAlib);
if(created){
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();
/*
add the constraint group LEFDefaultRouteSpec for oa2lef
*/
//TODO: add this layer
//first create "utility" layers
//strLayerDev ( "device" );
//strLayerText( "text" );
//strLayerPin ( "pin" );
//strLayerWire( "wire" );
}
// get or 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);
#if 0
oaLayerNum layer;
oaPurposeNum purpose;
getLayerPurpose(block->getDesign(), "pin", "drawing", layer, purpose);
oaPinFig *fig = oaPolygon::create(block, layer, purpose, points);
#endif
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 = NULL;
blockNet = oaScalarNet::find(topBlock, scNetName);
if(blockNet)
return blockNet;
assert(!blockNet);
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
oaBlock* topBlock = designCellView->getTopBlock();
if(!topBlock){
cerr << "oaBlock::create for netlist view" << endl;
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;
// 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 = 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;
// 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 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;
// 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;
}
/**
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,cell->getLibrary());
// 2) create OA structure ...
oaDesign* netlistView = createOAasNetlist(cell);
assert(netlistView);
oaCell* c1 = OADesignToOACell(netlistView);
assert(c1);
oaDesign* symbolicView = addSymbol(cell,netlistView);
assert(symbolicView);
oaCell* c2 = OADesignToOACell(symbolicView);
assert(c2);
oaDesign* schematicView = addSchematic(cell,symbolicView);
assert(schematicView);
oaCell* c3 = OADesignToOACell(schematicView);
assert(c3);
oaDesign* layoutView = addLayout(cell,schematicView);
assert(layoutView);
oaCell* c4 = OADesignToOACell(layoutView);
assert(c4);
assert(c1 == c2 && c2 == c3 && c3 == c4);
return netlistView;
}
oaCell* getOACellForCell(const Cell* cell) {
return OADesignToOACell( getOADesignForCell(cell) );
}
};
#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);
oaCell* convertedCell = oaDriver.getOACellForCell(cell);
}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
}
}

View File

@ -0,0 +1,374 @@
// -*-compile-command:"cd ../../../../.. && make"-*-
// Time-stamp: "2010-07-26 16:16:18" - OpenAccessParser.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 <iostream>
#include <set>
using namespace std;
#include "hurricane/DataBase.h"
#include "hurricane/Technology.h"
#include "hurricane/BasicLayer.h"
#include "hurricane/Library.h"
#include "hurricane/Horizontal.h"
#include "hurricane/Vertical.h"
#include "hurricane/NetExternalComponents.h"
using namespace Hurricane;
#include "OpenAccess.h"
#include "OpenAccessCommon.h"
namespace {
#ifdef HAVE_OPENACCESS
class OAParser {
typedef map<oaLib*, Library*> OALib2LibMap;
typedef map<Name, Library*> Name2LibMap;
typedef map<oaLayerNum, Layer*> OALayerNum2LayerMap;
typedef map<Cell*, oaCell*> Cell2OACellMap;
oaTech* _oaTechnology; // only one technology;
OALayerNum2LayerMap _oaLayerNum2LayerMap;
OALib2LibMap _oaLib2LibMap;
Name2LibMap _name2LibMap;
Cell2OACellMap _cell2OACellMap;
set<Cell*> _loadedCells;
OAParser():
_oaTechnology(NULL),
_oaLayerNum2LayerMap(),
_oaLib2LibMap(),
_name2LibMap(),
_cell2OACellMap(),
_loadedCells(){
try {
oaDesignInit(oacAPIMajorRevNumber,
oacAPIMinorRevNumber,
oacDataModelRevNumber);
} catch (oaException &excp) {
cout << "ERROR: " << excp.getMsg() << endl;
exit(1);
}
DataBase* db = DataBase::getDB();
if (!db) {
db = DataBase::create();
}
Library* rootLibrary = db->getRootLibrary();
if (!rootLibrary) {
rootLibrary = Library::create ( db, "RootLibrary" );
}
Library::create(rootLibrary, OACellLibrariesName);
Library::create(rootLibrary, OADesignLibrariesName);
}
~OAParser() {
for (OALib2LibMap::iterator lit = _oaLib2LibMap.begin();
lit != _oaLib2LibMap.end();
lit++) {
lit->first->close();
}
}
Cell* getCell(const string& cellNameStr) {
DataBase* db = DataBase::getDB();
if (!db || !db->getRootLibrary() ) {
return NULL;
}
Name cellName(cellNameStr);
Cell* cell = findCellInLibraries(getOADesignLibraries(), cellName);
if (!cell) {
return NULL;
}
set<Cell*>::const_iterator csit = _loadedCells.find(cell);
if (csit == _loadedCells.end()) {
Cell2OACellMap::const_iterator cit = _cell2OACellMap.find(cell);
if (cit == _cell2OACellMap.end()) {
cerr << "error : cannot find cell" << endl;
exit(8);
}
oaCell* oa_Cell = cit->second;
loadOACellInCell(oa_Cell, cell);
_loadedCells.insert(cell);
}
return cell;
}
void loadOALib(const string& libNameStr, const string& libPathStr, bool asDesignLibrary) {
Name libName(libNameStr);
Name2LibMap::const_iterator nit = _name2LibMap.find(libName);
if (nit != _name2LibMap.end()) {
Library* library = nit->second;
//verify that it's the same library : name and path
cerr << "already loaded" << endl;
return;
}
oaNativeNS oaNS;
oaString libNameOAStr(libNameStr.c_str());
oaScalarName libOAName(oaNS, libNameOAStr);
try {
oaLib* oaLibrary = oaLib::open(libOAName, libPathStr.c_str());
if (oaLibrary->isReadable()) {
if (!oaLibrary->getAccess(oacReadLibAccess)) {
cout << "\n***Quitting. Cannot get LibAccess\n" ;
exit(8);
}
oaTechnology2Technology(oaLibrary);
//create Hurricane library
Name libraryName = Name(libNameStr);
DataBase* db = DataBase::getDB();
if (!db) {
cerr << "No DataBase" << endl;
exit(8);
}
if (findLibraryByNameInDB(db, libraryName)) {
cerr << "ERROR" << endl;
exit(8);
}
Library* library;
if (asDesignLibrary) {
library = Library::create(getOADesignLibraries(), Name(libNameStr));
} else {
library = Library::create(getOACellLibraries(), Name(libNameStr));
}
cerr << library << endl;
oaCollection<oaCell, oaLib> cells = oaLibrary->getCells();
oaIter<oaCell> cellsIter(cells);
while (oaCell* cell = cellsIter.getNext()) {
oaScalarName cellOAName;
oaString cellNameString;
cell->getName(cellOAName);
cellOAName.get(cellNameString);
cerr << cellNameString << endl;
oaDesign* cellDesign = openDesign(oaNS, cell);
if (cellDesign != NULL) {
Cell* hCell = NULL;
//logic part
oaModule* module = cellDesign->getTopModule();
if (module) {
hCell = Cell::create(library, Name(cellNameString));
hCell->setTerminal(false);
if (!asDesignLibrary) {
hCell->setFlattenLeaf(true);
}
cerr << hCell << endl;
if (asDesignLibrary) {
_cell2OACellMap[hCell] = cell;
}
oaCollection<oaModTerm, oaModule> oaModTerms = module->getTerms();
oaIter<oaModTerm> oaModTermIter(oaModTerms);
while (oaModTerm* modTerm = oaModTermIter.getNext()) {
oaString oaModTermStr;
modTerm->getName(oaNS, oaModTermStr);
Net* net = Net::create(hCell, Name(oaModTermStr));
net->setExternal(true);
switch (modTerm->getTermType()) {
case oacInputTermType:
net->setDirection(Net::Direction::IN);
break;
case oacOutputTermType:
net->setDirection(Net::Direction::OUT);
break;
case oacInputOutputTermType:
net->setDirection(Net::Direction::INOUT);
break;
case oacTristateTermType:
net->setDirection(Net::Direction::TRISTATE);
break;
default:
net->setDirection(Net::Direction::UNDEFINED);
break;
}
cerr << net << endl;
oaModNet* oaNet = modTerm->getNet();
if (oaNet->isGlobal()) {
net->setGlobal(true);
cerr << "global" << endl;
}
if (oaNet->getSigType() == oacClockSigType) {
net->setType(Net::Type::CLOCK);
} else if (oaNet->getSigType() == oacPowerSigType) {
net->setGlobal(true);
net->setType(Net::Type::POWER);
} else if (oaNet->getSigType() == oacGroundSigType) {
net->setGlobal(true);
net->setType(Net::Type::GROUND);
} else {
net->setType(Net::Type::LOGICAL);
}
}
}
//physical part
oaBlock* block = cellDesign->getTopBlock();
if (block && hCell) {
oaBox oa_box;
block->getBBox(oa_box);
cerr << "box values" << endl;
cerr << oa_box.lowerLeft().x() << " , " << oa_box.lowerLeft().y() << endl;
cerr << oa_box.upperRight().x() << " , " << oa_box.upperRight().y() << endl;
cerr << endl;
Point lowerLeft(DbU::db(oa_box.lowerLeft().x()), DbU::db(oa_box.lowerLeft().y()));
Point upperRight(DbU::db(oa_box.upperRight().x()), DbU::db(oa_box.upperRight().y()));
hCell->setAbutmentBox(Box(lowerLeft, upperRight));
oaCollection<oaTerm, oaBlock> oaTerms = block->getTerms();
oaIter<oaTerm> oaTermIter(oaTerms);
while (oaTerm* term = oaTermIter.getNext()) {
oaString oaTermStr;
term->getName(oaNS, oaTermStr);
Net* net = hCell->getNet(Name(oaTermStr));
if (net) {
cerr << "found net : " << net << endl;
oaCollection<oaPin, oaTerm> oaPins(term->getPins());
oaIter<oaPin> oaPinIter(oaPins);
while (oaPin* pin = oaPinIter.getNext()) {
oaString oaPinStr;
pin->getName(oaPinStr);
cerr << "pin : " << oaPinStr << endl;
oaCollection<oaPinFig, oaPin> oaPinFigs(pin->getFigs());
oaIter<oaPinFig> oaPinFigIter(oaPinFigs);
while (oaPinFig* pinFig = oaPinFigIter.getNext()) {
cerr << "pinFig" << endl;
if (pinFig->getType() == oacRectType) {
oaRect* rect = static_cast<oaRect*>(pinFig);
OALayerNum2LayerMap::iterator layerMapIt = _oaLayerNum2LayerMap.find(rect->getLayerNum());
if (layerMapIt != _oaLayerNum2LayerMap.end()) {
Layer* layer = layerMapIt->second;
oaBox pinBBox;
rect->getBBox(pinBBox);
DbU::Unit width = DbU::db( (pinBBox.right() - pinBBox.left()) * (double)convertFactor);
DbU::Unit height = DbU::db( (pinBBox.top() - pinBBox.bottom()) * (double)convertFactor);
DbU::Unit cx = DbU::db(pinBBox.right() * (double)convertFactor) + width/2;
DbU::Unit cy = DbU::db(pinBBox.top() * (double)convertFactor) + height/2;
if (width > height) {
Horizontal* horizontal=Horizontal::create(net, layer, cy, height, DbU::db(pinBBox.right() * (double)convertFactor), DbU::db(pinBBox.left() * (double)convertFactor));
NetExternalComponents::setExternal(horizontal);
} else {
Vertical* vertical= Vertical::create(net, layer, cx, width, DbU::db(pinBBox.bottom() * (double)convertFactor), DbU::db(pinBBox.top() * (double)convertFactor));
NetExternalComponents::setExternal(vertical);
}
} else {
cerr << "cannot find layer..." << endl;
}
cerr << "rect " << rect->getLayerNum() << endl;
} else {
cerr << "no rect" << endl;
}
}
}
} else {
//TODO
}
}
} else {
cerr << "no block" << endl;
}
}
}
oaLibrary->releaseAccess();
//oaLibrary->close(); do not close !!
//FIXME save opened libraries ??
}
} catch (oaException &excp) {
cout << "ERROR: " << excp.getMsg() << endl;
exit(1);
}
}
void oaTechnology2Technology(oaLib* oaLibrary) {
try {
oaTech* tech = oaTech::open(oaLibrary);
if (!tech) {
cout << "ERROR" << endl;
exit(1);
}
if (_oaTechnology && tech != _oaTechnology) {
cout << "ERROR" << endl;
exit(1);
}
if (_oaTechnology) {
return;
}
_oaTechnology = tech;
DataBase* db = DataBase::getDB();
if (!db) {
cerr << "No DataBase" << endl;
exit(8);
}
Technology* technology = db->getTechnology();
if (!technology) {
technology = Technology::create(db, "OpenAccess");
}
oaCollection<oaLayer, oaTech> oaLayers(_oaTechnology->getLayers());
oaIter<oaLayer> oaLayerIt(oaLayers);
while (oaLayer* oaLayer = oaLayerIt.getNext()) {
oaString oaLayerStr;
oaLayer->getName(oaLayerStr);
Name layerName(oaLayerStr);
Layer* layer = technology->getLayer(layerName);
if (!layer) {
layer = BasicLayer::create(technology, layerName, BasicLayer::Material::other, oaLayer->getNumber());
}
cerr << layer << endl;
_oaLayerNum2LayerMap[oaLayer->getNumber()] = layer;
}
} catch (oaException &excp) {
cout << "ERROR: " << excp.getMsg() << endl;
exit(1);
}
}
void getDesigns(set<Cell*>& designCellSet) {
getAllCells(getOADesignLibraries(), designCellSet);
}
};//OAParser class
#endif
}//namespace
namespace CRL {
Cell* OpenAccess::oaCellParser(oaCell* cell){
#ifdef HAVE_OPENACCESS
cerr << "\nto implement ... " << endl;
#else
cerr << "\nDummy OpenAccess driver call for " << endl;
#endif
}
Library* OpenAccess::oaLibParser(oaLib* lib){
#ifdef HAVE_OPENACCESS
cerr << "\nto implement ... " << endl;
#else
cerr << "\nDummy OpenAccess driver call for " << path << endl;
#endif
}
}

View File

@ -1,321 +0,0 @@
#ifndef __OPENACCESSUTILS_H__
#define __OPENACCESSUTILS_H__
#include <iostream>
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
*/
inline 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
*/
inline void printBlockTerms(oaBlock* block) {
cerr << "printBlockTerms" << endl;
assert(block);
oaNativeNS ns;
oaDesign* design = block->getDesign();
cerr << " o Printing " << getDesignName(design) << " terms" << endl;
oaIter<oaTerm> 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
*/
inline 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
*/
inline 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
*/
inline 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 ...
*/
inline 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 ...
*/
inline void getOATransformFromTransformation(oaTransform& transform, const Transformation& transformation) {
cerr << "getOATransformFromTransformation" << endl;
transform.set(transformation.getTx(),
transformation.getTy(),
getOAOrientFromOrientation(transformation.getOrientation()));
}
/**
Convertion helper ...
*/
inline 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
*/
inline 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
*/
inline void saveDesignsInMap(map<const Cell*, oaDesign*> cell2OAdesign){
for (map<const Cell*, oaDesign*>::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 ...
*/
inline void printOALayers(oaTech* theOATech){
cerr << "printOALayers" << endl;
assert(theOATech);
oaIter<oaLayer> lIter(theOATech->getLayers());
while(oaLayer* l = lIter.getNext()){
oaString layerName;
l->getName(layerName);
cerr << " o created oaLayer " << layerName << endl;
}
}
/**
@todo complete,verify ...
*/
inline 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;
}
}
/**
generate info from library name
*/
inline pair<oaScalarName,string> libInfos(const string& path,
const string& libName){
oaNativeNS ns;
const char* strNameLib = libName.c_str();
oaScalarName scNameLib(ns, strNameLib);
string strPathLib = path + '/' + strNameLib;
return make_pair<oaScalarName,string>(scNameLib,strPathLib);
}
/**
open oaLib with the info gathered by libPath function
*/
inline oaLib* openOALib(const pair<oaScalarName,string>& infos){
oaLib *lib = oaLib::find(infos.first);
const char* pathLib = infos.second.c_str();
if (!lib) {
if (oaLib::exists(pathLib)){
lib = oaLib::open(infos.first, pathLib);
}else{
string cmd = "mkdir -p "+ infos.second;
system(cmd.c_str());
}
if(!lib){
lib = oaLib::create(infos.first, pathLib);
}
}
return lib;
}
inline void createCDS(const pair<oaScalarName,string>& infos){
try{
cerr << "Overwriting cds.lib file begin" << endl;
string cdsPath = infos.second + "/cds.lib";
oaLibDefList* ldl = oaLibDefList::get( cdsPath.c_str(), 'a');
assert(ldl);
assert(ldl->isValid());
if(!oaLibDef::find(ldl, infos.first))
oaLibDef::create(ldl, infos.first, infos.second.c_str());
ldl->save();
ldl->destroy();//claim memory
ldl = NULL;
cerr << "Overwrited cds.lib file end" << endl;
}catch(oaException& e){
cerr << "ERROR cds: " << e.getMsg() << endl;
exit(-2);
}
}
inline oaCell* OADesignToOACell(oaDesign* design){
assert(design);
oaScalarName cellName;
design->getCellName(cellName);
oaLib* lib = design->getLib();
oaBoolean gotAccess = false;
gotAccess = lib->getAccess(oacReadLibAccess);
oaCell* cell = oaCell::find(lib,cellName);
if(gotAccess)
lib->releaseAccess();
assert(cell);
return cell;
}
}//end anonymous namespace
#endif//HAVE_OPENACCESS
#endif//__OPENACCESSUTILS_H__

View File

@ -1,644 +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 <iostream>
using namespace std;
#include "hurricane/DataBase.h"
#include "hurricane/Technology.h"
#include "hurricane/BasicLayer.h"
#include "hurricane/Library.h"
#include "hurricane/Horizontal.h"
#include "hurricane/Vertical.h"
#include "hurricane/NetExternalComponents.h"
using namespace Hurricane;
#include "OAWrapper.h"
//open library
namespace {
static int convertFactor = 1;
void cantLock() {
cout << "\n***Quitting. Cannot get LibAccess\n" ;
exit(8);
}
Library* findLibraryByNameInLibrary(const Library* rootLibrary, const Name& libraryName) {
for_each_library(library, rootLibrary->getLibraries()) {
if (library->getName() == libraryName) {
return library;
}
Library* foundLibrary = findLibraryByNameInLibrary(library, libraryName);
if (foundLibrary) {
return foundLibrary;
}
end_for;
}
return NULL;
}
Library* findLibraryByNameInDB(const DataBase* db, const Name& libraryName) {
Library* rootLibrary = db->getRootLibrary();
if (rootLibrary->getName() == libraryName) {
return rootLibrary;
}
return findLibraryByNameInLibrary(rootLibrary, libraryName);
}
void getAllCells(Library* rootLibrary, set<Cell*>& cellSet) {
for_each_cell(cell, rootLibrary->getCells()) {
cellSet.insert(cell);
end_for;
}
for_each_library(library, rootLibrary->getLibraries()) {
getAllCells(library, cellSet);
end_for;
}
}
Cell* findCellInLibraries(const Library* rootLibrary, const Name& cellName) {
for_each_cell(cell, rootLibrary->getCells()) {
if (cell->getName() == cellName) {
return cell;
}
end_for;
}
for_each_library(library, rootLibrary->getLibraries()) {
Cell* cell = findCellInLibraries(library, cellName);
if (cell) {
return cell;
}
end_for;
}
return NULL;
}
Library* getRootLibrary() {
DataBase* db = DataBase::getDB();
if (!db) {
return NULL;
}
return db->getRootLibrary();
}
static const Name OACellLibrariesName("OACellLibraries");
static const Name OADesignLibrariesName("OADesignLibraries");
Library* getOACellLibraries() {
Library* rootLibrary = getRootLibrary();
if (!rootLibrary) {
return NULL;
}
for_each_library(library, rootLibrary->getLibraries()) {
if (library->getName() == OACellLibrariesName) {
return library;
}
end_for;
}
return NULL;
}
Library* getOADesignLibraries() {
Library* rootLibrary = getRootLibrary();
if (!rootLibrary) {
return NULL;
}
for_each_library(library, rootLibrary->getLibraries()) {
if (library->getName() == OADesignLibrariesName) {
return library;
}
end_for;
}
return NULL;
}
oaView* pickView(oaCell* oa_Cell) {
//oacMaskLayout Type is first
oaView* toReturnView = NULL;
oaCollection<oaCellView, oaCell> cellViews = oa_Cell->getCellViews();
oaIter<oaCellView> cellViewIter(cellViews);
while (oaCellView* cellView = cellViewIter.getNext()) {
oaView* view = cellView->getView();
oaViewType* viewType = view->getViewType();
oaScalarName viewName;
view->getName(viewName);
if (viewType == oaViewType::get(oacMaskLayout)) {
return view;
}
if (viewType == oaViewType::get(oacSchematic) ||
viewType == oaViewType::get(oacNetlist) ||
viewType == oaViewType::get(oacSchematicSymbol)) {
toReturnView = view;
}
}
return toReturnView;
}
oaDesign* openDesign(const oaNameSpace& oaNS, oaCell* oa_Cell) {
oaView* view = pickView(oa_Cell);
if (view != NULL) {
oaScalarName libName;
oaLib* cellLib = oa_Cell->getLib();
cellLib->getName(libName);
oaScalarName cellName;
oa_Cell->getName(cellName);
oaViewType* viewType = view->getViewType();
oaScalarName viewName;
view->getName(viewName);
return oaDesign::open(libName, cellName, viewName, viewType, 'r');
}
return NULL;
}
void loadOACellInCell(oaCell* oa_Cell, Cell* cell) {
oaNativeNS oaNS;
oaDesign* cellDesign = openDesign(oaNS, oa_Cell);
if (cellDesign != NULL) {
oaModule* module = cellDesign->getTopModule();
oaCollection<oaModInst, oaModule> oaModInsts = module->getInsts();
oaIter<oaModInst> modInstIter(oaModInsts);
while (oaModInst* modInst = modInstIter.getNext()) {
oaString oaModInstStr;
modInst->getName(oaNS, oaModInstStr);
//cerr << "inst : " << oaModInstStr << endl;
oaModule* masterModule = modInst->getMasterModule();
if (masterModule) {
oaString oaModuleStr;
masterModule->getName(oaNS, oaModuleStr);
//cerr << "master : " << oaModuleStr << endl;
//find hurricane Cell
Cell* masterCell = findCellInLibraries(getRootLibrary(), Name(oaModuleStr));
if (!masterCell) {
cout << "\n***Quitting. Cannot get MasterCell :" ;
cout << oaModuleStr << endl;
exit(8);
}
Instance* instance = Instance::create(cell, Name(oaModInstStr) ,masterCell);
//cerr << instance << endl;
} else {
cerr << "master : NULL" << endl;
}
}
//now treat nets
oaCollection<oaModNet, oaModule> oaModNets = module->getNets();
oaIter<oaModNet> oaModNetIter(oaModNets);
while (oaModNet* oa_ModNet = oaModNetIter.getNext()) {
oaString oaModNetStr;
oa_ModNet->getName(oaNS, oaModNetStr);
//cerr << oaModNetStr << endl;
Net* net = cell->getNet(Name(oaModNetStr));
if (!net) {
net = Net::create(cell, Name(oaModNetStr));
}
oaCollection<oaModInstTerm, oaModNet> oaModInstTerms = oa_ModNet->getInstTerms();
oaIter<oaModInstTerm> oaModInstTermIter(oaModInstTerms);
while (oaModInstTerm* oa_ModInstTerm = oaModInstTermIter.getNext()) {
oaModInst* modInst = oa_ModInstTerm->getInst();
oaString oaModInstStr;
modInst->getName(oaNS, oaModInstStr);
//find hurricane instance
Instance* instance = cell->getInstance(Name(oaModInstStr));
if (!instance) {
cout << "\n***Quitting. Cannot get Instance :" ;
cout << oaModInstStr << endl;
exit(8);
}
oaModTerm* oa_ModTerm = oa_ModInstTerm->getTerm();
oaString oaModTermStr;
oa_ModTerm->getName(oaNS, oaModTermStr);
Net* masterNet = instance->getMasterCell()->getNet(Name(oaModTermStr));
if (!masterNet) {
cout << "\n***Quitting. Cannot get Master Net :" ;
cout << oaModTermStr << endl;
exit(8);
}
Plug* plug = instance->getPlug(masterNet);
plug->setNet(net);
//cerr << plug << endl;
}
//cerr << net << endl;
}
oaScalarName cellName;
oa_Cell->getName(cellName);
oaString cellNameString;
cellName.get(cellNameString);
cell->setName(Name(cellNameString));
cell->setTerminal(false);
//physical part
oaBlock* block = cellDesign->getTopBlock();
if (block) {
oaBox oa_box;
block->getBBox(oa_box);
Point lowerLeft(DbU::db(oa_box.lowerLeft().x()), DbU::db(oa_box.lowerLeft().y()));
Point upperRight(DbU::db(oa_box.upperRight().x()), DbU::db(oa_box.upperRight().y()));
cell->setAbutmentBox(Box(lowerLeft, upperRight));
oaCollection<oaInst, oaBlock> oaInsts = block->getInsts();
oaIter<oaInst> oaInstIter(oaInsts);
while (oaInst* oa_Inst = oaInstIter.getNext()) {
oaString oaInstStr;
oa_Inst->getName(oaNS, oaInstStr);
Instance* instance = cell->getInstance(Name(oaInstStr));
if (instance) {
//cerr << "found " << instance << endl;
oaPlacementStatus placementStatus= oa_Inst->getPlacementStatus();
//switch (placementStatus) {
// case oacNonePlacementStatus :
// cerr << " none" << endl;
// break;
// case oacUnplacedPlacementStatus :
// cerr << " unplaced" << endl;
// break;
// case oacPlacedPlacementStatus :
// cerr << " placed" << endl;
// break;
// case oacFixedPlacementStatus :
// cerr << " fixed" << endl;
// break;
// default :
// cerr << "other" << endl;
//}
oaPoint instOrigin;
oa_Inst->getOrigin(instOrigin);
//cerr << instOrigin.x() << " " << instOrigin.y() << endl;
} else {
cerr << "cannot find " << oaInstStr << endl;
}
}
oaSitePattern sitePattern;
block->getSitePattern(sitePattern);
for (int i = 0; i < sitePattern.getNumElements(); i++) {
const oaSiteRef& siteRef = sitePattern.get(i);
cerr << "site : " << siteRef.siteName() << endl;
}
oaCollection<oaRow, oaBlock> oaRows = block->getRows();
oaIter<oaRow> oaRowIter(oaRows);
while (oaRow* oa_Row = oaRowIter.getNext()) {
cerr << "row" << endl;
oaString siteName;
oa_Row->getSiteDefName(siteName);
cerr << siteName << endl;
}
oaCollection<oaAreaBoundary, oaBlock> oaAreaBoundaries = block->getBoundaries();
oaIter<oaBoundary> oaBoundaryIter(oaAreaBoundaries);
while (oaBoundary* oa_Boundary = oaBoundaryIter.getNext()) {
cerr << "boundary" << endl;
}
} else {
cerr << "no block view " << endl;
}
}
}
}
namespace CRL {
OAWrapper* OAWrapper::_singleton = NULL;
OAWrapper::OAWrapper():
_oaTechnology(NULL),
_oaLayerNum2LayerMap(),
_oaLib2LibMap(),
_name2LibMap(),
_cell2OACellMap(),
_loadedCells()
{
try {
oaDesignInit(oacAPIMajorRevNumber,
oacAPIMinorRevNumber,
oacDataModelRevNumber);
} catch (oaException &excp) {
cout << "ERROR: " << excp.getMsg() << endl;
exit(1);
}
DataBase* db = DataBase::getDB();
if (!db) {
db = DataBase::create();
}
Library* rootLibrary = db->getRootLibrary();
if (!rootLibrary) {
rootLibrary = Library::create ( db, "RootLibrary" );
}
Library::create(rootLibrary, OACellLibrariesName);
Library::create(rootLibrary, OADesignLibrariesName);
}
OAWrapper* OAWrapper::getOAWrapper() {
if (!_singleton) {
_singleton = new OAWrapper();
}
return _singleton;
}
OAWrapper::~OAWrapper() {
for (OALib2LibMap::iterator lit = _oaLib2LibMap.begin();
lit != _oaLib2LibMap.end();
lit++) {
lit->first->close();
}
}
Cell* OAWrapper::getCell(const string& cellNameStr) {
DataBase* db = DataBase::getDB();
if (!db || !db->getRootLibrary() ) {
return NULL;
}
Name cellName(cellNameStr);
Cell* cell = findCellInLibraries(getOADesignLibraries(), cellName);
if (!cell) {
return NULL;
}
set<Cell*>::const_iterator csit = _loadedCells.find(cell);
if (csit == _loadedCells.end()) {
Cell2OACellMap::const_iterator cit = _cell2OACellMap.find(cell);
if (cit == _cell2OACellMap.end()) {
cerr << "error : cannot find cell" << endl;
exit(8);
}
oaCell* oa_Cell = cit->second;
loadOACellInCell(oa_Cell, cell);
_loadedCells.insert(cell);
}
return cell;
}
oaLib* OAWrapper::openOALib(const oaScalarName& libOAName, const string& libPathStr) {
try {
} catch (oaException &excp) {
cout << "ERROR: " << excp.getMsg() << endl;
exit(1);
}
}
void OAWrapper::loadOALib(const string& libNameStr, const string& libPathStr, bool asDesignLibrary) {
Name libName(libNameStr);
Name2LibMap::const_iterator nit = _name2LibMap.find(libName);
if (nit != _name2LibMap.end()) {
Library* library = nit->second;
//verify that it's the same library : name and path
cerr << "already loaded" << endl;
return;
}
oaNativeNS oaNS;
oaString libNameOAStr(libNameStr.c_str());
oaScalarName libOAName(oaNS, libNameOAStr);
try {
oaLib* oaLibrary = oaLib::open(libOAName, libPathStr.c_str());
if (oaLibrary->isReadable()) {
if (!oaLibrary->getAccess(oacReadLibAccess)) {
cantLock();
}
oaTechnology2Technology(oaLibrary);
//create Hurricane library
Name libraryName = Name(libNameStr);
DataBase* db = DataBase::getDB();
if (!db) {
cerr << "No DataBase" << endl;
exit(8);
}
if (findLibraryByNameInDB(db, libraryName)) {
cerr << "ERROR" << endl;
exit(8);
}
Library* library;
if (asDesignLibrary) {
library = Library::create(getOADesignLibraries(), Name(libNameStr));
} else {
library = Library::create(getOACellLibraries(), Name(libNameStr));
}
cerr << library << endl;
oaCollection<oaCell, oaLib> cells = oaLibrary->getCells();
oaIter<oaCell> cellsIter(cells);
while (oaCell* cell = cellsIter.getNext()) {
oaScalarName cellOAName;
oaString cellNameString;
cell->getName(cellOAName);
cellOAName.get(cellNameString);
cerr << cellNameString << endl;
oaDesign* cellDesign = openDesign(oaNS, cell);
if (cellDesign != NULL) {
Cell* hCell = NULL;
//logic part
oaModule* module = cellDesign->getTopModule();
if (module) {
hCell = Cell::create(library, Name(cellNameString));
hCell->setTerminal(false);
if (!asDesignLibrary) {
hCell->setFlattenLeaf(true);
}
cerr << hCell << endl;
if (asDesignLibrary) {
_cell2OACellMap[hCell] = cell;
}
oaCollection<oaModTerm, oaModule> oaModTerms = module->getTerms();
oaIter<oaModTerm> oaModTermIter(oaModTerms);
while (oaModTerm* modTerm = oaModTermIter.getNext()) {
oaString oaModTermStr;
modTerm->getName(oaNS, oaModTermStr);
Net* net = Net::create(hCell, Name(oaModTermStr));
net->setExternal(true);
switch (modTerm->getTermType()) {
case oacInputTermType:
net->setDirection(Net::Direction::IN);
break;
case oacOutputTermType:
net->setDirection(Net::Direction::OUT);
break;
case oacInputOutputTermType:
net->setDirection(Net::Direction::INOUT);
break;
case oacTristateTermType:
net->setDirection(Net::Direction::TRISTATE);
break;
default:
net->setDirection(Net::Direction::UNDEFINED);
break;
}
cerr << net << endl;
oaModNet* oaNet = modTerm->getNet();
if (oaNet->isGlobal()) {
net->setGlobal(true);
cerr << "global" << endl;
}
if (oaNet->getSigType() == oacClockSigType) {
net->setType(Net::Type::CLOCK);
} else if (oaNet->getSigType() == oacPowerSigType) {
net->setGlobal(true);
net->setType(Net::Type::POWER);
} else if (oaNet->getSigType() == oacGroundSigType) {
net->setGlobal(true);
net->setType(Net::Type::GROUND);
} else {
net->setType(Net::Type::LOGICAL);
}
}
}
//physical part
oaBlock* block = cellDesign->getTopBlock();
if (block && hCell) {
oaBox oa_box;
block->getBBox(oa_box);
cerr << "box values" << endl;
cerr << oa_box.lowerLeft().x() << " , " << oa_box.lowerLeft().y() << endl;
cerr << oa_box.upperRight().x() << " , " << oa_box.upperRight().y() << endl;
cerr << endl;
Point lowerLeft(DbU::db(oa_box.lowerLeft().x()), DbU::db(oa_box.lowerLeft().y()));
Point upperRight(DbU::db(oa_box.upperRight().x()), DbU::db(oa_box.upperRight().y()));
hCell->setAbutmentBox(Box(lowerLeft, upperRight));
oaCollection<oaTerm, oaBlock> oaTerms = block->getTerms();
oaIter<oaTerm> oaTermIter(oaTerms);
while (oaTerm* term = oaTermIter.getNext()) {
oaString oaTermStr;
term->getName(oaNS, oaTermStr);
Net* net = hCell->getNet(Name(oaTermStr));
if (net) {
cerr << "found net : " << net << endl;
oaCollection<oaPin, oaTerm> oaPins(term->getPins());
oaIter<oaPin> oaPinIter(oaPins);
while (oaPin* pin = oaPinIter.getNext()) {
oaString oaPinStr;
pin->getName(oaPinStr);
cerr << "pin : " << oaPinStr << endl;
oaCollection<oaPinFig, oaPin> oaPinFigs(pin->getFigs());
oaIter<oaPinFig> oaPinFigIter(oaPinFigs);
while (oaPinFig* pinFig = oaPinFigIter.getNext()) {
cerr << "pinFig" << endl;
if (pinFig->getType() == oacRectType) {
oaRect* rect = static_cast<oaRect*>(pinFig);
OALayerNum2LayerMap::iterator layerMapIt = _oaLayerNum2LayerMap.find(rect->getLayerNum());
if (layerMapIt != _oaLayerNum2LayerMap.end()) {
Layer* layer = layerMapIt->second;
oaBox pinBBox;
rect->getBBox(pinBBox);
DbU::Unit width = DbU::db( (pinBBox.right() - pinBBox.left()) * (double)convertFactor);
DbU::Unit height = DbU::db( (pinBBox.top() - pinBBox.bottom()) * (double)convertFactor);
DbU::Unit cx = DbU::db(pinBBox.right() * (double)convertFactor) + width/2;
DbU::Unit cy = DbU::db(pinBBox.top() * (double)convertFactor) + height/2;
if (width > height) {
Horizontal* horizontal=Horizontal::create(net, layer, cy, height, DbU::db(pinBBox.right() * (double)convertFactor), DbU::db(pinBBox.left() * (double)convertFactor));
NetExternalComponents::setExternal(horizontal);
} else {
Vertical* vertical= Vertical::create(net, layer, cx, width, DbU::db(pinBBox.bottom() * (double)convertFactor), DbU::db(pinBBox.top() * (double)convertFactor));
NetExternalComponents::setExternal(vertical);
}
} else {
cerr << "cannot find layer..." << endl;
}
cerr << "rect " << rect->getLayerNum() << endl;
} else {
cerr << "no rect" << endl;
}
}
}
} else {
//TODO
}
}
} else {
cerr << "no block" << endl;
}
}
}
oaLibrary->releaseAccess();
//oaLibrary->close(); do not close !!
//FIXME save opened libraries ??
}
} catch (oaException &excp) {
cout << "ERROR: " << excp.getMsg() << endl;
exit(1);
}
}
void OAWrapper::oaTechnology2Technology(oaLib* oaLibrary) {
try {
oaTech* tech = oaTech::open(oaLibrary);
if (!tech) {
cout << "ERROR" << endl;
exit(1);
}
if (_oaTechnology && tech != _oaTechnology) {
cout << "ERROR" << endl;
exit(1);
}
if (_oaTechnology) {
return;
}
_oaTechnology = tech;
DataBase* db = DataBase::getDB();
if (!db) {
cerr << "No DataBase" << endl;
exit(8);
}
Technology* technology = db->getTechnology();
if (!technology) {
technology = Technology::create(db, "OpenAccess");
}
oaCollection<oaLayer, oaTech> oaLayers(_oaTechnology->getLayers());
oaIter<oaLayer> oaLayerIt(oaLayers);
while (oaLayer* oaLayer = oaLayerIt.getNext()) {
oaString oaLayerStr;
oaLayer->getName(oaLayerStr);
Name layerName(oaLayerStr);
Layer* layer = technology->getLayer(layerName);
if (!layer) {
layer = BasicLayer::create(technology, layerName, BasicLayer::Material::other, oaLayer->getNumber());
}
cerr << layer << endl;
_oaLayerNum2LayerMap[oaLayer->getNumber()] = layer;
}
} catch (oaException &excp) {
cout << "ERROR: " << excp.getMsg() << endl;
exit(1);
}
}
void OAWrapper::getDesigns(set<Cell*>& designCellSet) {
getAllCells(getOADesignLibraries(), designCellSet);
}
}

View File

@ -1,49 +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 __OA_WRAPPER_H__
#define __OA_WRAPPER_H__
#include <set>
using namespace std;
#include "oa/oaDesignDB.h"
using namespace oa;
namespace CRL {
class OAWrapper {
public:
static OAWrapper* getOAWrapper();
void loadOALib(const string& libNameStr, const string& libPath, bool asDesignLibrary = false);
Cell* getCell(const string& cellName);
void getDesigns(set<Cell*>& designCellSet);
private:
OAWrapper();
~OAWrapper();
void openLib(string& libPath);
void oaTechnology2Technology(oaLib* lib);
oaLib* openOALib(const oaScalarName& libOAName, const string& libPath);
typedef map<oaLib*, Library*> OALib2LibMap;
typedef map<Name, Library*> Name2LibMap;
typedef map<oaLayerNum, Layer*> OALayerNum2LayerMap;
typedef map<Cell*, oaCell*> Cell2OACellMap;
static OAWrapper* _singleton;
oaTech* _oaTechnology; // only one technology;
OALayerNum2LayerMap _oaLayerNum2LayerMap;
OALib2LibMap _oaLib2LibMap;
Name2LibMap _name2LibMap;
Cell2OACellMap _cell2OACellMap;
set<Cell*> _loadedCells;
};
}
#endif /* __OA_WRAPPER_H__ */

View File

@ -1,397 +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
#ifdef HAVE_OPENACCESS
#include "oa/oaDesignDB.h"
using namespace oa;
#endif
#include "hurricane/DataBase.h"
#include "hurricane/Library.h"
#include "hurricane/Cell.h"
#include "hurricane/NetExternalComponents.h"
#include "hurricane/Segment.h"
#include "hurricane/Pad.h"
using namespace Hurricane;
#include "OpenAccessWrapper.h"
namespace {
#ifdef HAVE_OPENACCESS
#if 0
oaModInstTerm* getModInstTerm(oaModInst* modInst, Plug* plug) {
oaNativeNS ns;
oaScalarName scPlugName(ns, getString(plug->getName()).c_str());
oaName instTermName(scPlugName);
oaModInstTerm* instTerm = oaModInstTerm::find(modInst, instTermName);
if (instTerm) {
return instTerm;
}
oaModule* masterModule = modInst->getMasterModule();
oaModTerm* modTerm = oaModTerm::find(masterModule, instTermName);
assert(modTerm);
oaModNet* modNet = oaModNet::find(masterModule, instTermName);
assert(modNet);
instTerm = oaModInstTerm::create(modNet, modInst, instTermName);
return instTerm;
}
#endif
oaString getDesignName(oaDesign* 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;
}
void printBlockTerms(oaBlock* block) {
oaNativeNS ns;
oaDesign* design = block->getDesign();
cerr << " o Printing " << getDesignName(design) << " terms" << endl;
oaIter<oaTerm> termIter(block->getTerms());
while (oaTerm* term = termIter.getNext()) {
oaString termName;
term->getName(ns, termName);
cerr << " - " << termName << endl;
}
cerr << endl;
}
oaTermType getOATermType(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;
default:
throw Error("unrecognized direction");
}
}
oaOrient getOAOrientFromOrientation(const Transformation::Orientation& orientation) {
cerr << orientation << 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) {
transform.set(transformation.getTx(),
transformation.getTy(),
getOAOrientFromOrientation(transformation.getOrientation()));
}
void getOABoxForBox(oaBox& box, const Box& hbox) {
box.set(hbox.getXMin(), hbox.getYMin(), hbox.getXMax(), hbox.getYMax());
}
oaInstTerm* getInstTerm(oaInst* inst, Plug* 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);
if (!term) {
cerr << "looking for " << plug->getName() << endl;
printBlockTerms(masterBlock);
}
assert(term);
instTerm = oaInstTerm::create(NULL, inst, term);
return instTerm;
}
class OADriver {
private:
typedef map<const Library*, oaLib*> Library2OALibMap;
typedef map<const Cell*, oaDesign*> Cell2OADesignMap;
typedef pair<oaModInst*, oaInst*> OAInstPair;
typedef map<Instance*, oaInst*> Instance2OAInstsMap;
string _path;
oaTech* _oaTech;
oaBlock* _oaBlock;
Library2OALibMap _library2OALibMap;
Cell2OADesignMap _cell2OADesignMap;
Instance2OAInstsMap _instance2OAInstMap;
public:
OADriver(const string& path):
_path(path),
_oaTech(NULL),
_oaBlock(NULL),
_library2OALibMap(),
_cell2OADesignMap(),
_instance2OAInstMap() {
DataBase* db = DataBase::getDB();
if (!db) {
throw Error("no database");
}
Technology* technology = db->getTechnology();
//createOATechForTechnology(technology);
}
~OADriver() {
cerr << "SAVING ALL" << endl;
#if 0
oaNativeNS ns;
string fullPath = _path + "/lib.defs";
oaScalarName scPath(ns, fullPath.c_str());
oaString strPath;
scPath.get(strPath);
oaLibDefList* libDefList = oaLibDefList::get(strPath, 'w');
#endif
for (Cell2OADesignMap::iterator it = _cell2OADesignMap.begin();
it != _cell2OADesignMap.end();
++it) {
cerr << it->first << endl;
oaDesign* design = it->second;
design->save();
design->close();
}
for (Library2OALibMap::iterator it = _library2OALibMap.begin();
it != _library2OALibMap.end();
++it) {
oaLib* lib = it->second;
#if 0
oaScalarName libName;
lib->getName(libName);
oaString libPath;
lib->getFullPath(libPath);
oaLibDef* libDef = oaLibDef::create(libDefList, libName, libPath);
#endif
lib->close();
}
// libDefList->save();
cerr << "ALL SAVED" << endl;
}
oaLib* getOALibForLibrary(const Library* library) {
Library2OALibMap::iterator it = _library2OALibMap.find(library);
if (it != _library2OALibMap.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;
oaLib* lib = oaLib::create(scNameLib, strPathLib.c_str(), oacSharedLibMode, "oaDMFileSys");
//oaScalarName libName;
//_oaTech->getLibName(libName);
//oaTech::attach(lib, libName);
//assert(oaTech::find(lib));
oaTech* oaTech = oaTech::create(lib);
oaTech->setDefaultManufacturingGrid(10);
oaTech->setDBUPerUU(oaViewType::get(oacMaskLayout), 1000);
oaLayer* drawingLayer = oaPhysicalLayer::create(oaTech, "drawing", 0);
_library2OALibMap[library] = lib;
return lib;
}
void createOATechForTechnology(const Technology* technology) {
string strPathLib = _path + "/techlib";
oaNativeNS ns;
oaScalarName scNameLib(ns, "techlib");
oaLib* lib = oaLib::create(scNameLib, strPathLib.c_str(), oacSharedLibMode, "oaDMFileSys");
_oaTech = oaTech::create(lib);
oaLayer* drawingLayer = oaPhysicalLayer::create(_oaTech, "drawing", 0);
#if 0
for_each_layer(hlayer, technology->getLayers()) {
oaString strLayerName = getString(hlayer->getName()).c_str();
oaPhysicalLayer* layer = oaPhysicalLayer::create(techno, strLayerName, layerNum++);
end_for;
}
#endif
lib->close();
}
oaDesign* getOADesignForCell(const Cell* cell) {
cerr << "getOADesignForCell " << cell << endl;
Cell2OADesignMap::iterator it = _cell2OADesignMap.find(cell);
if (it != _cell2OADesignMap.end()) {
return it->second;
}
oaNativeNS ns;
oaLib* lib = getOALibForLibrary(cell->getLibrary());
oaScalarName scNameDesign(ns, getString(cell->getName()).c_str());
oaScalarName scNameView(ns, "layout");
oaScalarName scNameLib;
lib->getName(scNameLib);
oaDesign* design = oaDesign::open(scNameLib, scNameDesign, scNameView, oaViewType::get(oacSchematic), 'w');
//oaModule* module = oaModule::create(design);
oaBlock* block = oaBlock::create(design);
oaTech* tech = oaTech::find(lib);
assert(tech);
oaBox box;
getOABoxForBox(box, cell->getAbutmentBox());
cerr << cell << " " << cell->getAbutmentBox() << endl;
oaRect::create(block, 0, oaPurpose::get(tech, oacDrawingPurposeType)->getNumber(), box);
for_each_instance(instance, cell->getInstances()) {
Cell* masterCell = instance->getMasterCell();
oaDesign* masterDesign = getOADesignForCell(masterCell);
oaScalarName scDesignName;
masterDesign->getCellName(scDesignName);
oaString strDesignName;
scDesignName.get(strDesignName);
//oaModule* masterModule = masterDesign->getTopModule();
//assert(masterModule);
oaScalarName scInstName(ns, getString(instance->getName()).c_str());
//oaModScalarInst* modInst = oaModScalarInst::create(masterModule, masterDesign, scInstName);
oaTransform transform;
getOATransformFromTransformation(transform, instance->getTransformation());
oaScalarInst* blockInst = oaScalarInst::create(block, masterDesign, scInstName, transform);
_instance2OAInstMap[instance] = blockInst;
end_for;
}
for_each_net(net, cell->getNets()) {
oaScalarName scNetName(ns, getString(net->getName()).c_str());
//oaModNet* modNet = oaModScalarNet::create(module, scNetName, oacAnalogSigType);
oaScalarNet* blockNet = oaScalarNet::create(block, scNetName, oacAnalogSigType);
if (net->isExternal()) {
oaTerm* term = oaTerm::create(blockNet, scNetName, getOATermType(net->getDirection()));
oaPin* pin = oaPin::create(term);
oaTech* tech = oaTech::find(lib);
assert(tech);
Components externalComponents = NetExternalComponents::get(net);
for_each_component(component, externalComponents) {
oaBox box;
getOABoxForBox(box, component->getBoundingBox());
oaRect* rect = oaRect::create(block, 0,
oaPurpose::get(tech, oacDrawingPurposeType)->getNumber(),
box);
rect->addToPin(pin);
end_for;
}
}
for_each_plug(plug, net->getPlugs()) {
Instance* instance = plug->getInstance();
Instance2OAInstsMap::iterator it = _instance2OAInstMap.find(instance);
assert(it != _instance2OAInstMap.end());
//oaModInst* modInst = it->second.first;
oaInst* blockInst = it->second;
//oaModInstTerm* modInstTerm = getModInstTerm(modInst, plug);
oaInstTerm* instTerm = getInstTerm(blockInst, plug);
//modInstTerm->addToNet(modNet);
instTerm->addToNet(blockNet);
end_for;
}
for_each_component(component, net->getComponents()) {
end_for;
}
end_for;
}
_cell2OADesignMap[cell] = design;
return design;
}
};
#endif
}
namespace CRL {
void OpenAccessWrapper::oaLibLoader(const string& libPath, Library *lib, Catalog &catalog) {
cerr << "\nDummy OpenAccess lib loader call for " << libPath << endl;
}
void OpenAccessWrapper::oaDesignLoader(const string& path, Cell* cell) {
cerr << "\nDummy OpenAccess design loader call for " << path << endl;
}
void OpenAccessWrapper::oaDriver(const string& path, Cell* cell, unsigned int& saveState) {
#ifdef HAVE_OPENACCESS
//for the moment a driver for hurricaneAMS
//save the Cell and all used Cells
cerr << "Saving " << cell << " in " << path << endl;
try {
oaDesignInit(
oacAPIMajorRevNumber,
oacAPIMinorRevNumber,
oacDataModelRevNumber);
Library* library = cell->getLibrary();
string pathLib = path + "/" + getString(library->getName());
const char* strPathLib = pathLib.c_str();
// if (oaLib::exists(strPathLib)) {
// throw Error("impossible to drive Cell, there is an existing OpenAccess db");
// }
OADriver oaDriver(pathLib);
oaDesign* design = oaDriver.getOADesignForCell(cell);
} catch (oaException &excp) {
cerr << "ERROR: " << excp.getMsg() << endl;
exit(1);
}
#else
cerr << "\nDummy OpenAccess driver call for " << path << endl;
#endif
}
}

View File

@ -1,32 +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 __OPENACCESSWRAPPER_H
#define __OPENACCESSWRAPPER_H
#include <string>
using namespace std;
namespace Hurricane {
class Library;
class Cell;
}
namespace CRL {
class Catalog;
class OpenAccessWrapper {
public:
static void oaLibLoader(const string& libPath, Hurricane::Library* lib, Catalog& catalog);
static void oaDesignLoader(const string& path, Hurricane::Cell* cell);
static void oaDriver(const string& cellPath, Cell* cell, unsigned int& saveState);
};
}
#endif /*__OPENACCESSWRAPPER_H */

View File

@ -44,9 +44,9 @@ void testCell(Cell* dev,char* pathToTest){
return; return;
} }
system((string("mkdir -p ") + string(pathToTest)).c_str()); system((string("mkdir -p ") + string(pathToTest)).c_str());
/* cerr << "driving GDS" << endl; cerr << "driving GDS" << endl;
GdsDriver(dev).save(string(pathToTest) + "/GDSdrive"); GdsDriver(dev).save(string(pathToTest) + "/" + getString(dev->getName()) + ".gds");
*/
cerr << "driving OA" << endl; cerr << "driving OA" << endl;
OADriver(dev).save(string(pathToTest) + "/OAdrive"); OADriver(dev).save(string(pathToTest) + "/OAdrive");
} }