diff --git a/vlsisapd/examples/openChams/cplusplus/parseOpenChams.cpp b/vlsisapd/examples/openChams/cplusplus/parseOpenChams.cpp index 734f25c3..bc49e696 100644 --- a/vlsisapd/examples/openChams/cplusplus/parseOpenChams.cpp +++ b/vlsisapd/examples/openChams/cplusplus/parseOpenChams.cpp @@ -205,12 +205,13 @@ int main(int argc, char * argv[]) { } } } - if (!sizing->hasNoEquations()) { - cerr << " | + equations" << endl; - for (map::const_iterator eit = sizing->getEquations().begin() ; eit != sizing->getEquations().end() ; ++eit) { - cerr << " | | " << ((*eit).first).getString() << " : " << (*eit).second << endl; - } - } + // To update to the new equations. + // if (!sizing->hasNoEquations()) { + // cerr << " | + equations" << endl; + // for (map::const_iterator eit = sizing->getEquations().begin() ; eit != sizing->getEquations().end() ; ++eit) { + // cerr << " | | " << ((*eit).first).getString() << " : " << (*eit).second << endl; + // } + // } } OpenChams::Layout* layout = circuit->getLayout(); if (layout) { diff --git a/vlsisapd/src/openChams/src/Circuit.cpp b/vlsisapd/src/openChams/src/Circuit.cpp index 36aa3e5f..0e93d27b 100644 --- a/vlsisapd/src/openChams/src/Circuit.cpp +++ b/vlsisapd/src/openChams/src/Circuit.cpp @@ -14,6 +14,8 @@ #include using namespace std; +#include + #include "vlsisapd/openChams/Circuit.h" #include "vlsisapd/openChams/Netlist.h" #include "vlsisapd/openChams/Instance.h" @@ -35,17 +37,100 @@ using namespace std; #include "vlsisapd/openChams/DDP.h" #include "vlsisapd/openChams/DesignerCstrOC.h" -namespace { - template T getValue(xmlChar* str) { - std::istringstream iss; - iss.str((const char*) str); - T res; - iss >> res; - return res; - } -} - namespace OpenChams { + + + void tokenize ( const string& value, vector& tokens ) + { + string work; + + // First: remove all white spaces. + for ( size_t i=0 ; i 1 ) + tokens.push_back ( work.substr(tokenStart,tokenLength-1) ); + tokenStart = i+1; + tokenLength = 0; + } + } + if ( tokenLength > 1 ) + tokens.push_back ( work.substr(tokenStart,tokenLength-1) ); + } + + + bool headCompare ( const char* keyword, const string& token ) + { + const string skeyword (keyword); + if ( skeyword.empty() or token.empty() ) return false; + return (skeyword.compare(0,token.size(),token) == 0); + } + + + bool stringAsBool ( const string& s ) + { + if ( headCompare("true" ,s) or headCompare("1",s) ) return true; + if ( headCompare("false",s) or headCompare("0",s) ) return false; + cerr << "[WARNING] Unknown booleean value <" << s << "> (treated as false)."<< endl; + return false; + } + + + long stringAsDirection ( const string& s ) + { + vector tokens; + tokenize(s,tokens); + + long directions = 0; + for ( size_t i=0 ; i (ignored)."<< endl; + } + + return directions; + } + + + string asStringBool ( bool b ) + { + return (b) ? "true" : "false"; + } + + + string asStringDirection ( long l ) + { + const char* directionNames[4] = { "west", "east", "south", "north" }; + + string directions; + for ( size_t i=0 ; i<4 ; ++i ) { + if ( l & (1<(valueC); return name; } else { throw OpenChamsException("[ERROR] 'parameter' node must have 'name' and 'value' properties."); } } - Name Circuit::readParameterEq(xmlNode* node, string& eqStr) { - xmlChar* paramNameC = xmlGetProp(node, (xmlChar*)"name"); - xmlChar* equationC = xmlGetProp(node, (xmlChar*)"equation"); - if (paramNameC && equationC) { - Name name((const char*)paramNameC); - eqStr = string ((const char*)equationC); - return name; - } else { - throw OpenChamsException("[ERROR] 'parameterEq' node must have 'name' and 'equation' properties."); - } - } - Name Circuit::readConnector(xmlNode* node) { xmlChar* connectorNameC = xmlGetProp(node, (xmlChar*)"name"); if (connectorNameC) { @@ -196,22 +268,17 @@ namespace OpenChams { } if (node->type == XML_ELEMENT_NODE && node->children) { for (xmlNode* paramNode = node->children ; paramNode ; paramNode = paramNode->next) { - if (paramNode->type == XML_ELEMENT_NODE) { - if (xmlStrEqual(paramNode->name, (xmlChar*)"parameter")) { - double value = 0.0; - Name paramName = readParameter(paramNode, value); - if (paramName == Name("")) return; // error - addParameter(paramName, value); - } else if (xmlStrEqual(paramNode->name, (xmlChar*)"parameterEq")) { - string eqStr = ""; - Name paramName = readParameterEq(paramNode, eqStr); - if (paramName == Name("")) return; // error - addParameter(paramName, eqStr); - } else { - cerr << "[WARNING] Only 'parameter' and 'parameterEq' nodes are allowed under 'parameters' node." << endl; - return; - } - } + if (paramNode->type == XML_ELEMENT_NODE) { + if (xmlStrEqual(paramNode->name, (xmlChar*)"parameter")) { + const xmlChar* value = NULL; + Name paramName = readParameter(paramNode, value); + if (paramName == Name("")) return; // error + addParameter(paramName, (const char*)value); + } else { + cerr << "[WARNING] Only 'parameter' and 'parameterEq' nodes are allowed under 'parameters' node." << endl; + return; + } + } } } readCircuitParametersDone = true; @@ -226,12 +293,12 @@ namespace OpenChams { for (xmlNode* modelNode = node->children ; modelNode ; modelNode = modelNode->next) { if (modelNode->type == XML_ELEMENT_NODE) { if (xmlStrEqual(modelNode->name, (xmlChar*)"model")) { - xmlChar* mIdC = xmlGetProp(modelNode, (xmlChar*)"id"); - xmlChar* mBaseC = xmlGetProp(modelNode, (xmlChar*)"base"); - xmlChar* mVersionC = xmlGetProp(modelNode, (xmlChar*)"version"); - xmlChar* mFilePathC = xmlGetProp(modelNode, (xmlChar*)"filePath"); + const xmlChar* mIdC = xmlGetProp(modelNode, (xmlChar*)"id"); + const xmlChar* mBaseC = xmlGetProp(modelNode, (xmlChar*)"base"); + const xmlChar* mVersionC = xmlGetProp(modelNode, (xmlChar*)"version"); + const xmlChar* mFilePathC = xmlGetProp(modelNode, (xmlChar*)"filePath"); if (mIdC && mBaseC && mVersionC && mFilePathC) { - unsigned id = ::getValue(mIdC); + unsigned id = stringAs(mIdC); SimulModel::Base base = SimulModel::BSIM3V3; string mBase((const char*)mBaseC); string baseComp[3] = { "BSIM3V3", "BSIM4", "PSP" }; @@ -332,7 +399,7 @@ namespace OpenChams { if (iNameC && iModelC && iOrderC && iMOSC && iSBCC) { // this is a device Name instanceName((const char*)iNameC); Name modelName((const char*)iModelC); - unsigned order = ::getValue(iOrderC); + unsigned order = stringAs(iOrderC); string mosStr((const char*)iMOSC); string mosComp[2] = {"NMOS", "PMOS"}; vector mosComps (mosComp, mosComp+2); @@ -346,7 +413,7 @@ namespace OpenChams { } else if (iNameC && iModelC && iOrderC && !iMOSC && !iSBCC) { // this is a subcircuit Name instanceName((const char*)iNameC); Name modelName((const char*)iModelC); - unsigned order = ::getValue(iOrderC); + unsigned order = stringAs(iOrderC); inst = netlist->addInstance(instanceName, modelName, order); } else { throw OpenChamsException("[ERROR] 'instance' node must have ('name', 'model' and 'order') or ('name', 'model', 'order', 'mostype' and 'sourceBulkConnected') properties."); @@ -391,15 +458,10 @@ namespace OpenChams { for (xmlNode* node = child; node; node = node->next) { if (node->type == XML_ELEMENT_NODE) { if (xmlStrEqual(node->name, (xmlChar*)"parameter")) { - double value = 0.0; + const xmlChar* value = NULL; Name paramName = readParameter(node, value); if (paramName == Name("")) return; // error - inst->addParameter(paramName, value); - } else if (xmlStrEqual(node->name, (xmlChar*)"parameterEq")) { - string eqStr = ""; - Name paramName = readParameterEq(node, eqStr); - if (paramName == Name("")) return; // error - inst->addParameter(paramName, eqStr); + inst->addParameter(paramName, (const char*)value); } else { cerr << "[WARNING] Only 'parameter' and 'parameterEq' nodes are allowed under 'instance' node." << endl; return; @@ -576,8 +638,8 @@ namespace OpenChams { xmlChar* orientC = xmlGetProp(node, (xmlChar*)"orient"); if (nameC && xC && yC && orientC) { Name iName((const char*)nameC); - double x = ::getValue(xC); - double y = ::getValue(yC); + double x = stringAs((const char*)xC); + double y = stringAs((const char*)yC); string orientStr((const char*)orientC); string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"}; vector orientComps (orientComp, orientComp+8); @@ -624,9 +686,9 @@ namespace OpenChams { xmlChar* orientC = xmlGetProp(node, (xmlChar*)"orient"); if (typeC && idxC && xC && yC && orientC) { Name pType((const char*)typeC); - unsigned idx = ::getValue(idxC); - double x = ::getValue(xC); - double y = ::getValue(yC); + unsigned idx = stringAs(idxC); + double x = stringAs(xC); + double y = stringAs(yC); string orientStr((const char*)orientC); string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"}; vector orientComps (orientComp, orientComp+8); @@ -657,7 +719,7 @@ namespace OpenChams { throw OpenChamsException("[ERROR] In 'schematic' a 'wire' must have exactly 2 connectors (not more)."); } } else if (idxC) { - unsigned idx = ::getValue(idxC); + unsigned idx = stringAs(idxC); if (!wire->getStartPoint()) { wire->setStartPoint(idx); } else if (!wire->getEndPoint()) { @@ -673,8 +735,8 @@ namespace OpenChams { xmlChar* xC = xmlGetProp(node, (xmlChar*)"x"); xmlChar* yC = xmlGetProp(node, (xmlChar*)"y"); if (xC && yC) { - double x = ::getValue(xC); - double y = ::getValue(yC); + double x = stringAs(xC); + double y = stringAs(yC); wire->addIntermediatePoint(x, y); // check is done inside the method (start/end points) } else { throw OpenChamsException("[ERROR] 'schematic'.'net'.'point' node must have 'x' and 'y' properties."); @@ -753,7 +815,7 @@ namespace OpenChams { Name refParam ((const char*)refParamC); double factor = 1.0; if (factorC) { - factor = ::getValue(factorC); + factor = stringAs(factorC); } op->addConstraint(param, ref, refParam, factor); } else if (paramC && refEqC) { @@ -761,7 +823,7 @@ namespace OpenChams { Name refEq ((const char*)refEqC); double factor = 1.0; if (factorC) { - factor = ::getValue(factorC); + factor = stringAs(factorC); } op->addConstraint(param, refEq, factor); } else { @@ -1224,14 +1286,10 @@ namespace OpenChams { } if (!_params.isEmpty()) { file << " " << endl; - for (map::const_iterator it = _params.getValues().begin() ; it != _params.getValues().end() ; ++it) { - file << " " << endl; + for (map::const_iterator it = _params.getValues().begin() ; it != _params.getValues().end() ; ++it) { + file << " " << endl; } cerr << "_params.getValues().size() = " << _params.getValues().size() << endl; - cerr << "_params.getEqValues().size() = " << _params.getEqValues().size() << endl; - for (map::const_iterator it2 = _params.getEqValues().begin() ; it2 != _params.getEqValues().end() ; ++it2) { - file << " " << endl; - } file << " " << endl; } file << " " << endl @@ -1278,12 +1336,9 @@ namespace OpenChams { if (!inst->getParameters().isEmpty()) { Parameters params = inst->getParameters(); file << " " << endl; - for (map::const_iterator it = params.getValues().begin() ; it != params.getValues().end() ; ++it) { + for (map::const_iterator it = params.getValues().begin() ; it != params.getValues().end() ; ++it) { file << " " << endl; } - for(map::const_iterator it = params.getEqValues().begin() ; it != params.getEqValues().end() ; ++it) { - file << " " << endl; - } file << " " << endl; } file << " " << endl; diff --git a/vlsisapd/src/openChams/src/Instance.cpp b/vlsisapd/src/openChams/src/Instance.cpp index fe53eb5e..517302d3 100644 --- a/vlsisapd/src/openChams/src/Instance.cpp +++ b/vlsisapd/src/openChams/src/Instance.cpp @@ -24,6 +24,11 @@ Instance::Instance(Name name, Name model, unsigned order, Netlist* netlist) , _params() , _netMap() {} + + Instance::~Instance () + { } + + void Instance::addConnector(Name name) { // si name n'est pas déjà présent dans la map on ajoute name, NULL (pas de net) map::iterator it = _netMap.find(name); diff --git a/vlsisapd/src/openChams/src/Name.cpp b/vlsisapd/src/openChams/src/Name.cpp index 20ee5e59..0ed88663 100644 --- a/vlsisapd/src/openChams/src/Name.cpp +++ b/vlsisapd/src/openChams/src/Name.cpp @@ -52,11 +52,11 @@ Name::Name(const char* c) : _str(NULL) { } } -bool Name::operator==(const Name& n) { +bool Name::operator==(const Name& n) const { return (_id == n._id); } -bool Name::operator==(const string& str) { +bool Name::operator==(const string& str) const { Name n(str); return (_id == n._id); } diff --git a/vlsisapd/src/openChams/src/Parameters.cpp b/vlsisapd/src/openChams/src/Parameters.cpp index 246f9f7e..e1a4a105 100644 --- a/vlsisapd/src/openChams/src/Parameters.cpp +++ b/vlsisapd/src/openChams/src/Parameters.cpp @@ -1,14 +1,21 @@ -/* - * Parameters.cpp - * openChams - * - * Created by damien dupuis on 18/12/09. - * Copyright 2009 UPMC / LIP6. All rights reserved. - * - */ + +// -*- C++ -*- +// +// This file is part of the VLSI SAPD Software. +// Copyright (c) UPMC/LIP6 2009-2012, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | V L S I S A P D | +// | OpenChams Circuit Data Base | +// | | +// | Author : Damien Dupuis | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./Parameters.cpp" | +// +-----------------------------------------------------------------+ + #include -#include using namespace std; #include "vlsisapd/openChams/Name.h" @@ -16,50 +23,32 @@ using namespace std; #include "vlsisapd/openChams/OpenChamsException.h" namespace OpenChams { -double Parameters::getValue(Name name) { - map::iterator it = _params.find(name); - if (it == _params.end()) { - string error("[ERROR] No parameters named "); - error += name.getString(); - throw OpenChamsException(error); - //return 0.0; - } - return (*it).second; -} - -std::string Parameters::getEqValue(Name name) { - map::iterator it = _paramsEq.find(name); - if (it == _paramsEq.end()) { - string error("[ERROR] No parameters named "); - error += name.getString(); - throw OpenChamsException(error); - } - return (*it).second; -} -void Parameters::addParameter(Name name, double value) { - map::iterator it = _params.find(name); - map::iterator it2 = _paramsEq.find(name); - if ( it != _params.end() || it2 != _paramsEq.end() ) { - string error("[ERROR] Cannot addParameter "); - error += name.getString(); - error += " because it already exists !"; - throw OpenChamsException(error); + + void Parameters::addParameter ( Name name, const char* value ) + { + map::iterator it = _params.find(name); + if ( it != _params.end() ) { + string error("[ERROR] Cannot addParameter "); + error += name.getString(); + error += " because it already exists !"; + throw OpenChamsException(error); } _params[name] = value; -} - -void Parameters::addParameter(Name name, string eqStr) { - map::iterator it = _params.find(name); - map::iterator it2 = _paramsEq.find(name); - if ( it != _params.end() || it2 != _paramsEq.end() ) { - string error("[ERROR] Cannot addParameter "); - error += name.getString(); - error += " because it already exists !"; - throw OpenChamsException(error); - } - _paramsEq[name] = eqStr; - cerr << "987* _paramsEq.size() = " << _paramsEq.size() << endl; -} -} // namespace + } + + + const string& Parameters::getValue ( Name name ) + { + map::iterator it = _params.find(name); + if (it == _params.end()) { + string error("[ERROR] No parameters named "); + error += name.getString(); + throw OpenChamsException(error); + } + return (*it).second; + } + + +} // OpenChams namespace. diff --git a/vlsisapd/src/openChams/src/PyOpenChams.cpp b/vlsisapd/src/openChams/src/PyOpenChams.cpp index a59f9f2c..66090c6e 100644 --- a/vlsisapd/src/openChams/src/PyOpenChams.cpp +++ b/vlsisapd/src/openChams/src/PyOpenChams.cpp @@ -25,6 +25,7 @@ using namespace boost::python; #include "vlsisapd/openChams/PySTLMapWrapper.h" namespace OpenChams { + void translator(OpenChamsException const& e) { PyErr_SetString(PyExc_UserWarning, e.what()); } @@ -45,20 +46,17 @@ BOOST_PYTHON_MODULE(OPENCHAMS) { implicitly_convertible(); // map wrapping for OpenChams::Parameters - STL_MAP_WRAPPING(Name, double , "ValuesMap" ) - STL_MAP_WRAPPING(Name, std::string, "EquationsMap") + STL_MAP_WRAPPING(Name, std::string, "ValuesMap") // class OpenChams::Parameters class_("Parameters", init<>()) // accessors - .def("getValue" , &Parameters::getValue ) - .def("getEqValue" , &Parameters::getEqValue) + .def("getValue" , &Parameters::getValue, return_value_policy()) .def("isEmpty" , &Parameters::isEmpty ) // modifiers - .def("addParameter", static_cast(&Parameters::addParameter)) - .def("addParameter", static_cast(&Parameters::addParameter)) + .def("addParameter", static_cast(&Parameters::addParameter)) + .def("addParameter", static_cast(&Parameters::addParameter)) // stl containers .def("getValues" , &Parameters::getValues , return_value_policy()) - .def("getEqValues" , &Parameters::getEqValues, return_value_policy()) ; { //this scope is used to define Base as a subenum of SimulModel @@ -95,8 +93,8 @@ BOOST_PYTHON_MODULE(OPENCHAMS) { .add_property("bulk" , &Transistor::getBulk , &Transistor::setBulk ) .add_property("parameters", &Transistor::getParameters ) // no setter => params will be readonly // modifiers - .def("addParameter", static_cast(&Transistor::addParameter)) - .def("addParameter", static_cast(&Transistor::addParameter)) + .def("addParameter", static_cast(&Transistor::addParameter)) + .def("addParameter", static_cast(&Transistor::addParameter)) ; // map wrapping and vector_indexing for OpenChams::Instance @@ -114,8 +112,8 @@ BOOST_PYTHON_MODULE(OPENCHAMS) { // modifiers .def("addConnector" , &Instance::addConnector ) .def("connect" , &Instance::connect ) - .def("addParameter" , static_cast(&Transistor::addParameter)) - .def("addParameter" , static_cast(&Transistor::addParameter)) + .def("addParameter" , static_cast(&Transistor::addParameter)) + .def("addParameter" , static_cast(&Transistor::addParameter)) // stl containers .def("getConnectors" , &Instance::getConnectors , return_internal_reference<>()) ; @@ -340,14 +338,14 @@ BOOST_PYTHON_MODULE(OPENCHAMS) { .add_property("sizing" , make_function(&Circuit::getSizing , return_value_policy())) .add_property("layout" , make_function(&Circuit::getLayout , return_value_policy())) // accessors - .def("getValue", &Circuit::getValue) + .def("getValue", &Circuit::getValue, return_value_policy() ) // modifiers .def("createNetlist" , &Circuit::createNetlist , return_value_policy()) .def("createSchematic", &Circuit::createSchematic, return_value_policy()) .def("createSizing" , &Circuit::createSizing , return_value_policy()) .def("createLayout" , &Circuit::createLayout , return_value_policy()) - .def("addParameter", static_cast(&Circuit::addParameter)) - .def("addParameter", static_cast(&Circuit::addParameter)) + .def("addParameter", static_cast(&Circuit::addParameter)) + .def("addParameter", static_cast(&Circuit::addParameter)) // others .def("readFromFile", &Circuit::readFromFile, return_value_policy()) .staticmethod("readFromFile") @@ -399,4 +397,6 @@ BOOST_PYTHON_MODULE(OPENCHAMS) { register_exception_translator(translator) ; } -} + + +} // OpenChams namespace. diff --git a/vlsisapd/src/openChams/src/vlsisapd/openChams/Circuit.h b/vlsisapd/src/openChams/src/vlsisapd/openChams/Circuit.h index 08c436cf..efa45e48 100644 --- a/vlsisapd/src/openChams/src/vlsisapd/openChams/Circuit.h +++ b/vlsisapd/src/openChams/src/vlsisapd/openChams/Circuit.h @@ -1,18 +1,26 @@ -/* - * Circuit.h - * openChams - * - * Created by damien dupuis on 18/12/09. - * Copyright 2009 UPMC / LIP6 All rights reserved. - * - */ + +// -*- C++ -*- +// +// This file is part of the VLSI SAPD Software. +// Copyright (c) UPMC/LIP6 2009-2012, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | V L S I S A P D | +// | OpenChams Circuit Data Base | +// | | +// | Author : Damien Dupuis | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./vlsisapd/openChams/Circuit.h" | +// +-----------------------------------------------------------------+ + #ifndef __OPENCHAMS_CIRCUIT_H__ #define __OPENCHAMS_CIRCUIT_H__ #include #include -#include +#include #include #include @@ -21,118 +29,151 @@ #include "vlsisapd/openChams/Parameters.h" #include "vlsisapd/openChams/SimulModel.h" + namespace OpenChams { -class Netlist; -class Instance; -class Device; -class Net; -class Schematic; -class Sizing; -class Transistor; -class Operator; -class Layout; -class Node; -class Circuit { + class Netlist; + class Instance; + class Device; + class Net; + class Schematic; + class Sizing; + class Transistor; + class Operator; + class Layout; + class Node; + + class Circuit { public: - Circuit(Name name, Name techno); - - inline Name getName(); - inline Name getTechno(); - inline double getValue(Name); - inline Netlist* getNetlist(); - inline Schematic* getSchematic(); - inline Sizing* getSizing(); - inline Layout* getLayout(); - inline void addParameter(Name, double); - inline void addParameter(Name, std::string); - inline Parameters getParameters(); - inline void addSubCircuitPath(std::string); - inline std::vector& getSubCircuitPaths(); - - void addSimulModel(unsigned, SimulModel::Base, SimulModel::Version, std::string); - - inline void setSizing(Sizing*); - inline void setLayout(Layout*); - - Netlist* createNetlist(); - Schematic* createSchematic(); - Sizing* createSizing(); - Layout* createLayout(); - - void driveHBTree(std::ofstream&, Node*, unsigned); - - bool writeToFile(std::string filePath); - static Circuit* readFromFile(const std::string filePath); + Circuit ( Name, Name techno ); + // Accessors. + inline Name getName (); + inline Name getTechno (); + inline const std::string& getValue ( Name ); + inline Netlist* getNetlist (); + inline Schematic* getSchematic (); + inline Sizing* getSizing (); + inline Layout* getLayout (); + inline void addParameter ( Name, const char* ); + inline void addParameter ( Name, const std::string& ); + inline Parameters getParameters (); + inline void addSubCircuitPath ( std::string ); + inline std::vector& getSubCircuitPaths (); + // Mutators. + void addSimulModel ( unsigned + , SimulModel::Base + , SimulModel::Version + , std::string ); + inline void setSizing ( Sizing* ); + inline void setLayout ( Layout* ); + Netlist* createNetlist (); + Schematic* createSchematic (); + Sizing* createSizing (); + Layout* createLayout (); + void driveHBTree ( std::ofstream&, Node*, unsigned ); + bool writeToFile ( std::string filePath ); + static Circuit* readFromFile ( const std::string filePath ); private: - Name readParameter(xmlNode*, double&); - Name readParameterEq(xmlNode*, std::string&); - Name readConnector(xmlNode*); - void readSubCircuitsPaths(xmlNode*); - void readCircuitParameters(xmlNode*); - void readSimulModels(xmlNode*); - void readNetList(xmlNode*); - void readInstances(xmlNode*, Netlist*); - Instance* readInstance (xmlNode*, Netlist*); - void readInstanceParameters(xmlNode*, Instance*); - void readInstanceConnectors(xmlNode*, Instance*); - void readInstanceTransistors(xmlNode*, Device*); - void readTransistor(xmlNode*, Device*); - void readTransistorConnection(xmlNode*, Transistor*); - void readNets(xmlNode*, Netlist*); - Net* readNet (xmlNode*, Netlist*); - void readNetConnector(xmlNode*, Net*); - void readSchematic(xmlNode*); - void readInstanceSchematic(xmlNode*, Schematic*); - void readNetSchematic(xmlNode*, Circuit*); - void readPortSchematic(xmlNode*, Net*); - void readWireSchematic(xmlNode*, Net*); - void readSizing(xmlNode*); - void readInstanceSizing(xmlNode*, Sizing*); - void readConstraint(xmlNode*, Operator*); + // Internal methods (XML parser). + Name readParameter ( xmlNode*, const xmlChar*& ); + Name readParameterEq ( xmlNode*, std::string& ); + Name readConnector ( xmlNode* ); + void readSubCircuitsPaths ( xmlNode* ); + void readCircuitParameters ( xmlNode* ); + void readSimulModels ( xmlNode* ); + void readNetList ( xmlNode* ); + void readInstances ( xmlNode*, Netlist* ); + Instance* readInstance ( xmlNode*, Netlist* ); + void readInstanceParameters ( xmlNode*, Instance* ); + void readInstanceConnectors ( xmlNode*, Instance* ); + void readInstanceTransistors ( xmlNode*, Device* ); + void readTransistor ( xmlNode*, Device* ); + void readTransistorConnection ( xmlNode*, Transistor* ); + void readNets ( xmlNode*, Netlist* ); + Net* readNet ( xmlNode*, Netlist* ); + void readNetConnector ( xmlNode*, Net* ); + void readSchematic ( xmlNode* ); + void readInstanceSchematic ( xmlNode*, Schematic* ); + void readNetSchematic ( xmlNode*, Circuit* ); + void readPortSchematic ( xmlNode*, Net* ); + void readWireSchematic ( xmlNode*, Net* ); + void readSizing ( xmlNode* ); + void readInstanceSizing ( xmlNode*, Sizing* ); + void readConstraint ( xmlNode*, Operator* ); + // Equation related XML methods. + void readEquations ( xmlNode*, Sizing* ); + void readEquation_CircuitLevel ( xmlNode*, Sizing* ); + void readEquation_NRC ( xmlNode*, Sizing* ); + void readEquation_DDPs ( xmlNode*, Sizing* ); + void readEquation_DesignerCstr ( xmlNode*, Sizing* ); + // Layout related XML methods. + void readLayout ( xmlNode* ); + void readInstanceLayout ( xmlNode*, Layout* ); + void readHBTree ( xmlNode*, Layout* ); + Node* readNodeOrBloc ( xmlNode*, Node* parent = NULL ); + void setAbsolutePath ( const std::string filePath ); + // Utilities methods. + void check_uppercase ( std::string& str, std::vector& compares, std::string message ); + void check_lowercase ( std::string& str, std::vector& compares, std::string message ); + + private: + Name _name; + std::string _absolutePath; + Name _techno; + Parameters _params; + Netlist* _netlist; + Schematic* _schematic; + Sizing* _sizing; + Layout* _layout; + std::vector _subCircuitsPaths; + std::map _simulModels; + }; + - void readEquations(xmlNode*, Sizing*); - void readEquation_CircuitLevel(xmlNode*, Sizing*); - void readEquation_NRC(xmlNode*, Sizing*); - void readEquation_DDPs(xmlNode*, Sizing*); - void readEquation_DesignerCstr(xmlNode*, Sizing*); + inline Name Circuit::getName () { return _name; } + inline Name Circuit::getTechno () { return _techno; } + inline const std::string& Circuit::getValue (Name name) { return _params.getValue(name); } + inline Netlist* Circuit::getNetlist () { return _netlist; } + inline Schematic* Circuit::getSchematic () { return _schematic; } + inline Sizing* Circuit::getSizing () { return _sizing; } + inline Layout* Circuit::getLayout () { return _layout; } + inline void Circuit::addParameter (Name name, const char* value) { _params.addParameter(name, value); } + inline void Circuit::addParameter (Name name, const std::string& value) { _params.addParameter(name, value); } + inline Parameters Circuit::getParameters () { return _params; } + inline void Circuit::addSubCircuitPath (std::string path) { _subCircuitsPaths.push_back(path); } + inline std::vector& Circuit::getSubCircuitPaths () { return _subCircuitsPaths; } - void readLayout(xmlNode*); - void readInstanceLayout(xmlNode*, Layout*); - void readHBTree(xmlNode*, Layout*); - Node* readNodeOrBloc(xmlNode*, Node* parent = NULL); - void setAbsolutePath(const std::string filePath); - - void check_uppercase(std::string& str, std::vector& compares, std::string message); - void check_lowercase(std::string& str, std::vector& compares, std::string message); - - Name _name; - std::string _absolutePath; - Name _techno; - Parameters _params; - Netlist* _netlist; - Schematic* _schematic; - Sizing* _sizing; - Layout* _layout; - std::vector _subCircuitsPaths; - std::map _simulModels; -}; - -inline Name Circuit::getName() { return _name; } -inline Name Circuit::getTechno() { return _techno; } -inline double Circuit::getValue(Name name) { return _params.getValue(name); } -inline Netlist* Circuit::getNetlist() { return _netlist; } -inline Schematic* Circuit::getSchematic() { return _schematic; } -inline Sizing* Circuit::getSizing() { return _sizing; } -inline Layout* Circuit::getLayout() { return _layout; } -inline void Circuit::addParameter(Name name, double value) { _params.addParameter(name, value); } -inline void Circuit::addParameter(Name name, std::string eqStr) { _params.addParameter(name, eqStr); } -inline Parameters Circuit::getParameters() { return _params; } -inline void Circuit::addSubCircuitPath(std::string path) { _subCircuitsPaths.push_back(path); } -inline std::vector& Circuit::getSubCircuitPaths() { return _subCircuitsPaths; } + + template + inline std::string asString ( T value ) + { std::ostringstream output; output << value; return output.str(); } + + + std::string asStringBool ( bool ); + std::string asStringDirection ( long ); + + + template + inline T stringAs ( const char* str ) + { T value; std::istringstream input(str); input >> value; return value; } + + + template + inline T stringAs ( const xmlChar* str ) + { T value; std::istringstream input((const char*)str); input >> value; return value; } + + + template + inline T stringAs ( const std::string& str ) + { return stringAs(str.c_str()); } + + + bool stringAsBool ( const std::string& ); + long stringAsDirection ( const std::string& ); -} // namespace OpenChams +} // namespace OpenChams. + #endif diff --git a/vlsisapd/src/openChams/src/vlsisapd/openChams/Instance.h b/vlsisapd/src/openChams/src/vlsisapd/openChams/Instance.h index 8c677427..ca540b68 100644 --- a/vlsisapd/src/openChams/src/vlsisapd/openChams/Instance.h +++ b/vlsisapd/src/openChams/src/vlsisapd/openChams/Instance.h @@ -1,63 +1,76 @@ -/* - * Instance.h - * openChams - * - * Created by damien dupuis on 12/01/10. - * Copyright 2010 UPMC / LIP6. All rights reserved. - * - */ + +// -*- C++ -*- +// +// This file is part of the VLSI SAPD Software. +// Copyright (c) UPMC/LIP6 2010-2012, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | V L S I S A P D | +// | OpenChams Circuit Data Base | +// | | +// | Author : Damien Dupuis | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./vlsisapd/openChams/Instance.h" | +// +-----------------------------------------------------------------+ + #ifndef __OPENCHAMS_INSTANCE_H__ #define __OPENCHAMS_INSTANCE_H__ #include #include +#include #include "vlsisapd/openChams/Name.h" #include "vlsisapd/openChams/Parameters.h" + namespace OpenChams { -class Netlist; -class Net; -class Instance { - public: - Instance(Name name, Name model, unsigned, Netlist*); - virtual ~Instance() {}; - - void addConnector(Name); - void connect(Name connectorName, Name netName); - - inline void addParameter(Name, double); - inline void addParameter(Name, std::string); - inline Name getName() const; - inline Name getModel(); - inline unsigned getOrder(); - inline Netlist* getNetlist(); - inline Parameters getParameters(); - // pour parcourir les connecteurs - inline bool hasNoConnectors(); - inline const std::map& getConnectors(); + class Netlist; + class Net; - private: - Name _name; - Name _model; - unsigned _order; - Netlist* _netlist; - Parameters _params; - std::map _netMap; //map associant nom de connecteur a un net -}; + class Instance { + public: + Instance (Name name, Name model, unsigned, Netlist*); + virtual ~Instance (); + + void addConnector (Name); + void connect (Name connectorName, Name netName); + + inline void addParameter (Name, const char* ); + inline void addParameter (Name, const std::string& ); + inline Name getName () const; + inline Name getModel (); + inline unsigned getOrder (); + inline Netlist* getNetlist (); + inline Parameters getParameters (); + inline bool hasNoConnectors (); + inline const std::map& getConnectors (); -inline void Instance::addParameter(Name name, double value) { _params.addParameter(name, value); }; -inline void Instance::addParameter(Name name, std::string eqStr) { _params.addParameter(name, eqStr); }; -inline Name Instance::getName() const { return _name; }; -inline Name Instance::getModel() { return _model; }; -inline unsigned Instance::getOrder() { return _order; }; -inline Netlist* Instance::getNetlist() { return _netlist; }; -inline Parameters Instance::getParameters() { return _params; }; -inline bool Instance::hasNoConnectors() { return (_netMap.size() == 0)? true : false; }; -inline const std::map& Instance::getConnectors() { return _netMap; }; + private: + Name _name; + Name _model; + unsigned _order; + Netlist* _netlist; + Parameters _params; + std::map _netMap; + }; + + + inline void Instance::addParameter (Name name, const char* value) { _params.addParameter(name,value); }; + inline void Instance::addParameter (Name name, const std::string& value) { _params.addParameter(name,value); }; + inline Name Instance::getName () const { return _name; }; + inline Name Instance::getModel () { return _model; }; + inline unsigned Instance::getOrder () { return _order; }; + inline Netlist* Instance::getNetlist () { return _netlist; }; + inline Parameters Instance::getParameters () { return _params; }; + inline bool Instance::hasNoConnectors () { return _netMap.empty(); }; + inline const std::map& Instance::getConnectors () { return _netMap; }; -} // namespace + +} // OpenChams namespace. + #endif diff --git a/vlsisapd/src/openChams/src/vlsisapd/openChams/Name.h b/vlsisapd/src/openChams/src/vlsisapd/openChams/Name.h index f220522f..e2874269 100644 --- a/vlsisapd/src/openChams/src/vlsisapd/openChams/Name.h +++ b/vlsisapd/src/openChams/src/vlsisapd/openChams/Name.h @@ -22,8 +22,8 @@ class Name { Name(std::string); Name(const char*); - bool operator==(const Name&); - bool operator==(const std::string&); + bool operator==(const Name&) const; + bool operator==(const std::string&) const; bool operator<(const Name&) const; inline const std::string& getString() const; diff --git a/vlsisapd/src/openChams/src/vlsisapd/openChams/Parameters.h b/vlsisapd/src/openChams/src/vlsisapd/openChams/Parameters.h index 6c47841b..61a151a9 100644 --- a/vlsisapd/src/openChams/src/vlsisapd/openChams/Parameters.h +++ b/vlsisapd/src/openChams/src/vlsisapd/openChams/Parameters.h @@ -1,43 +1,50 @@ -/* - * Parameters.h - * openChams - * - * Created by damien dupuis on 18/12/09. - * Copyright 2008-2010 UPMC / LIP6. All rights reserved. - * - */ + +// -*- C++ -*- +// +// This file is part of the VLSI SAPD Software. +// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | V L S I S A P D | +// | OpenChams Circuit Data Base | +// | | +// | Author : Damien Dupuis | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./vlsisapd/openChams/Parameters.h" | +// +-----------------------------------------------------------------+ + #ifndef __OPENCHAMS_PARAMETERS_H__ #define __OPENCHAMS_PARAMETERS_H__ #include +#include namespace OpenChams { -class Name; + class Name; -class Parameters { -public: - Parameters() {}; - - double getValue(Name); - std::string getEqValue(Name); - void addParameter(Name, double); - void addParameter(Name, std::string); - - // pour parcourir la map : - inline bool isEmpty(); - inline const std::map& getValues(); - inline const std::map& getEqValues(); - -private: - std::map _params; - std::map _paramsEq; -}; - -inline bool Parameters::isEmpty() { return ((_params.size() == 0)&&(_paramsEq.size() == 0))? true : false; } -inline const std::map& Parameters::getValues() { return _params; }; -inline const std::map& Parameters::getEqValues() { return _paramsEq; }; + class Parameters { + public: + inline Parameters (); + inline bool isEmpty (); + const std::string& getValue (Name); + inline const std::map& getValues (); + inline void addParameter (Name, const std::string&); + void addParameter (Name, const char*); + + private: + std::map _params; + }; + + + inline Parameters::Parameters () { } + inline bool Parameters::isEmpty () { return (_params.size() == 0); } + inline const std::map& Parameters::getValues () { return _params; }; + inline void Parameters::addParameter (Name name, const std::string& value) { addParameter(name,value.c_str()); } + + +} // OpenChams namespace. -} // namespace #endif diff --git a/vlsisapd/src/openChams/src/vlsisapd/openChams/Transistor.h b/vlsisapd/src/openChams/src/vlsisapd/openChams/Transistor.h index c8008668..2a1f8c46 100644 --- a/vlsisapd/src/openChams/src/vlsisapd/openChams/Transistor.h +++ b/vlsisapd/src/openChams/src/vlsisapd/openChams/Transistor.h @@ -1,11 +1,18 @@ -/* - * Transistor.h - * openChams - * - * Created by damien dupuis on 01/03/10. - * Copyright 2010 UPMC / LIP6. All rights reserved. - * - */ + +// -*- C++ -*- +// +// This file is part of the VLSI SAPD Software. +// Copyright (c) UPMC/LIP6 2010-2012, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | V L S I S A P D | +// | OpenChams Circuit Data Base | +// | | +// | Author : Damien Dupuis | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./vlsisapd/openChams/Instance.h" | +// +-----------------------------------------------------------------+ #ifndef __OPENCHAMS_TRANSISTOR_H__ @@ -16,49 +23,54 @@ #include "vlsisapd/openChams/Name.h" #include "vlsisapd/openChams/Parameters.h" + namespace OpenChams { -class Instance; -class Net; -class Transistor { - public: - Transistor(Name, Instance*); - - inline void addParameter(Name, double); - inline void addParameter(Name, std::string); - inline Parameters getParameters(); - inline void setName(Name); - inline Name getName(); - inline Name getGate(); - inline Name getSource(); - inline Name getDrain(); - inline Name getBulk(); - - void setGate (Name); - void setSource(Name); - void setDrain (Name); - void setBulk (Name); - - private: - bool checkConnector(Name); - - Name _name; - Name _gate; // le nom du connecteur de _instance auquel la gate est reliée - Name _source; // le nom du connecteur de _instance auquel la source est reliée - Name _drain; // le nom du connecteur de _instance auquel le drain est relié - Name _bulk; // le nom du connecteur de _instance auquel le bulk est relié - Instance* _instance; - Parameters _params; - }; - - inline void Transistor::addParameter(Name name, double value) { _params.addParameter(name, value); }; - inline void Transistor::addParameter(Name name, std::string eqStr) { _params.addParameter(name, eqStr); }; - inline Parameters Transistor::getParameters() { return _params; }; - inline void Transistor::setName (Name name) { _name = name; }; - inline Name Transistor::getName() { return _name; }; - inline Name Transistor::getGate() { return _gate; }; - inline Name Transistor::getSource() { return _source; }; - inline Name Transistor::getDrain() { return _drain; }; - inline Name Transistor::getBulk() { return _bulk; }; -} // namespace + + class Instance; + class Net; + + + class Transistor { + public: + Transistor (Name, Instance*); + inline void addParameter (Name, const char*); + inline void addParameter (Name, const std::string&); + inline Parameters getParameters (); + inline void setName (Name); + inline Name getName (); + inline Name getGate (); + inline Name getSource (); + inline Name getDrain (); + inline Name getBulk (); + void setGate (Name); + void setSource (Name); + void setDrain (Name); + void setBulk (Name); + private: + bool checkConnector (Name); + private: + Name _name; + Name _gate; // le nom du connecteur de _instance auquel la gate est reliée + Name _source; // le nom du connecteur de _instance auquel la source est reliée + Name _drain; // le nom du connecteur de _instance auquel le drain est relié + Name _bulk; // le nom du connecteur de _instance auquel le bulk est relié + Instance* _instance; + Parameters _params; + }; + + + inline void Transistor::addParameter (Name name, const char* value) { _params.addParameter(name,value); }; + inline void Transistor::addParameter (Name name, const std::string& value) { _params.addParameter(name,value); }; + inline Parameters Transistor::getParameters () { return _params; }; + inline void Transistor::setName (Name name) { _name = name; }; + inline Name Transistor::getName () { return _name; }; + inline Name Transistor::getGate () { return _gate; }; + inline Name Transistor::getSource () { return _source; }; + inline Name Transistor::getDrain () { return _drain; }; + inline Name Transistor::getBulk () { return _bulk; }; + + +} // OpenChams namespace. + #endif