* ./vlsisapd/openChams:

- Change: In Parameters, suppress the two separate maps, one for double
        and another for string (equations). We shouldn't suppose what kind
        of data an user can put in the parameter's value. Now that the
        parameters for the HB-Tree are to be integrated, we have not only
        double but boolean, integers and a direction string. The value are
        now stored in a raw fashion as strings. It is up to the parser/drivers
        (i.e OpenChamsParser/OpenChamsDriver) to give meaning to those strings
        and interpret them accordingly.
    - Change: In Circuit, helper templates (and some non-template) functions
        to cast a string into various types. All the POD through stringAs<>
        template, plus stringAsDirection() & stringAsBool(). Reverse functions
        templates asString<> are also avalaible.
        Note: Those helpers are of more general interest, we should displace
              them sooner or later into a common "Utility" sub-tool.
This commit is contained in:
Jean-Paul Chaput 2012-03-22 14:37:22 +00:00
parent 0bec26f739
commit e7011ad480
11 changed files with 518 additions and 395 deletions

View File

@ -205,12 +205,13 @@ int main(int argc, char * argv[]) {
}
}
}
if (!sizing->hasNoEquations()) {
cerr << " | + equations" << endl;
for (map<OpenChams::Name, string>::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<OpenChams::Name, string>::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) {

View File

@ -14,6 +14,8 @@
#include <algorithm>
using namespace std;
#include <boost/algorithm/string.hpp>
#include "vlsisapd/openChams/Circuit.h"
#include "vlsisapd/openChams/Netlist.h"
#include "vlsisapd/openChams/Instance.h"
@ -35,18 +37,101 @@ using namespace std;
#include "vlsisapd/openChams/DDP.h"
#include "vlsisapd/openChams/DesignerCstrOC.h"
namespace {
template<class T> 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<string>& tokens )
{
string work;
// First: remove all white spaces.
for ( size_t i=0 ; i<value.size() ; ++i ) {
switch ( value[i] ) {
case ' ':
case '\n':
case '\t':
continue;
}
work += value[i];
}
boost::algorithm::to_lower(work);
// Second: tokenize, special characters being ",".
size_t tokenStart = 0;
size_t tokenLength = 1;
for ( size_t i=0 ; i<work.size() ; ++i, ++tokenLength ) {
switch ( work[i] ) {
case ',':
// The previous token.
if ( tokenLength > 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<string> tokens;
tokenize(s,tokens);
long directions = 0;
for ( size_t i=0 ; i<tokens.size() ; ++i ) {
if ( headCompare("west" ,tokens[i]) ) directions |= (1<<0);
else if ( headCompare("east" ,tokens[i]) ) directions |= (1<<1);
else if ( headCompare("south",tokens[i]) ) directions |= (1<<2);
else if ( headCompare("north",tokens[i]) ) directions |= (1<<3);
else
cerr << "[WARNING] Unknown direction value <" << tokens[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<<i) ) {
if (not directions.empty() ) directions += ",";
directions += directionNames[i];
}
}
return directions;
}
static bool readSubCircuitsPathsDone = false;
static bool readCircuitParametersDone = false;
static bool readSimulModelsDone = false;
@ -124,30 +209,17 @@ namespace OpenChams {
_simulModels[id] = sim;
}
Name Circuit::readParameter(xmlNode* node, double& value) {
Name Circuit::readParameter(xmlNode* node, const xmlChar*& value) {
xmlChar* paramNameC = xmlGetProp(node, (xmlChar*)"name");
xmlChar* valueC = xmlGetProp(node, (xmlChar*)"value");
if (paramNameC && valueC) {
value = xmlGetProp(node, (xmlChar*)"value");
if (paramNameC and value) {
Name name((const char*)paramNameC);
value = ::getValue<double>(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) {
@ -198,15 +270,10 @@ namespace OpenChams {
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;
const xmlChar* value = NULL;
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);
addParameter(paramName, (const char*)value);
} else {
cerr << "[WARNING] Only 'parameter' and 'parameterEq' nodes are allowed under 'parameters' node." << endl;
return;
@ -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<unsigned>(mIdC);
unsigned id = stringAs<unsigned>(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<unsigned>(iOrderC);
unsigned order = stringAs<unsigned>(iOrderC);
string mosStr((const char*)iMOSC);
string mosComp[2] = {"NMOS", "PMOS"};
vector<string> 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<unsigned>(iOrderC);
unsigned order = stringAs<unsigned>(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<double>(xC);
double y = ::getValue<double>(yC);
double x = stringAs<double>((const char*)xC);
double y = stringAs<double>((const char*)yC);
string orientStr((const char*)orientC);
string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"};
vector<string> 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<unsigned>(idxC);
double x = ::getValue<double>(xC);
double y = ::getValue<double>(yC);
unsigned idx = stringAs<unsigned>(idxC);
double x = stringAs<double>(xC);
double y = stringAs<double>(yC);
string orientStr((const char*)orientC);
string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"};
vector<string> 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<unsigned>(idxC);
unsigned idx = stringAs<unsigned>(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<double>(xC);
double y = ::getValue<double>(yC);
double x = stringAs<double>(xC);
double y = stringAs<double>(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<double>(factorC);
factor = stringAs<double>(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<double>(factorC);
factor = stringAs<double>(factorC);
}
op->addConstraint(param, refEq, factor);
} else {
@ -1224,14 +1286,10 @@ namespace OpenChams {
}
if (!_params.isEmpty()) {
file << " <parameters>" << endl;
for (map<Name, double>::const_iterator it = _params.getValues().begin() ; it != _params.getValues().end() ; ++it) {
for (map<Name,string>::const_iterator it = _params.getValues().begin() ; it != _params.getValues().end() ; ++it) {
file << " <parameter name=\"" << (*it).first.getString() << "\" value=\"" << (*it).second << "\"/>" << endl;
}
cerr << "_params.getValues().size() = " << _params.getValues().size() << endl;
cerr << "_params.getEqValues().size() = " << _params.getEqValues().size() << endl;
for (map<Name, string>::const_iterator it2 = _params.getEqValues().begin() ; it2 != _params.getEqValues().end() ; ++it2) {
file << " <parameterEq name=\"" << (*it2).first.getString() << "\" equation=\"" << (*it2).second << "\"/>" << endl;
}
file << " </parameters>" << endl;
}
file << " <netlist>" << endl
@ -1278,12 +1336,9 @@ namespace OpenChams {
if (!inst->getParameters().isEmpty()) {
Parameters params = inst->getParameters();
file << " <parameters>" << endl;
for (map<Name, double>::const_iterator it = params.getValues().begin() ; it != params.getValues().end() ; ++it) {
for (map<Name,string>::const_iterator it = params.getValues().begin() ; it != params.getValues().end() ; ++it) {
file << " <parameter name=\"" << (*it).first.getString() << "\" value=\"" << (*it).second << "\"/>" << endl;
}
for(map<Name, string>::const_iterator it = params.getEqValues().begin() ; it != params.getEqValues().end() ; ++it) {
file << " <parameterEq name=\"" << (*it).first.getString() << "\" equation=\"" << (*it).second << "\"/>" << endl;
}
file << " </parameters>" << endl;
}
file << " </instance>" << endl;

View File

@ -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<Name, Net*>::iterator it = _netMap.find(name);

View File

@ -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);
}

View File

@ -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 <iostream>
#include <string>
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<Name, double>::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<Name, string>::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<Name, double>::iterator it = _params.find(name);
map<Name, string>::iterator it2 = _paramsEq.find(name);
if ( it != _params.end() || it2 != _paramsEq.end() ) {
void Parameters::addParameter ( Name name, const char* value )
{
map<Name,string>::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<Name, double>::iterator it = _params.find(name);
map<Name, string>::iterator it2 = _paramsEq.find(name);
if ( it != _params.end() || it2 != _paramsEq.end() ) {
string error("[ERROR] Cannot addParameter ");
const string& Parameters::getValue ( Name name )
{
map<Name,string>::iterator it = _params.find(name);
if (it == _params.end()) {
string error("[ERROR] No parameters named ");
error += name.getString();
error += " because it already exists !";
throw OpenChamsException(error);
}
_paramsEq[name] = eqStr;
cerr << "987* _paramsEq.size() = " << _paramsEq.size() << endl;
}
} // namespace
return (*it).second;
}
} // OpenChams namespace.

View File

@ -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<std::string, Name>();
// 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>("Parameters", init<>())
// accessors
.def("getValue" , &Parameters::getValue )
.def("getEqValue" , &Parameters::getEqValue)
.def("getValue" , &Parameters::getValue, return_value_policy<copy_const_reference>())
.def("isEmpty" , &Parameters::isEmpty )
// modifiers
.def("addParameter", static_cast<void(Parameters::*)(Name, double )>(&Parameters::addParameter))
.def("addParameter", static_cast<void(Parameters::*)(Name, std::string)>(&Parameters::addParameter))
.def("addParameter", static_cast<void(Parameters::*)(Name, const char*)>(&Parameters::addParameter))
.def("addParameter", static_cast<void(Parameters::*)(Name, const std::string&)>(&Parameters::addParameter))
// stl containers
.def("getValues" , &Parameters::getValues , return_value_policy<copy_const_reference>())
.def("getEqValues" , &Parameters::getEqValues, return_value_policy<copy_const_reference>())
;
{ //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<void(Transistor::*)(Name, double )>(&Transistor::addParameter))
.def("addParameter", static_cast<void(Transistor::*)(Name, std::string)>(&Transistor::addParameter))
.def("addParameter", static_cast<void(Transistor::*)(Name, const char*)>(&Transistor::addParameter))
.def("addParameter", static_cast<void(Transistor::*)(Name, const std::string&)>(&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<void(Transistor::*)(Name, double )>(&Transistor::addParameter))
.def("addParameter" , static_cast<void(Transistor::*)(Name, std::string)>(&Transistor::addParameter))
.def("addParameter" , static_cast<void(Transistor::*)(Name, const char*)>(&Transistor::addParameter))
.def("addParameter" , static_cast<void(Transistor::*)(Name, const std::string&)>(&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<reference_existing_object>()))
.add_property("layout" , make_function(&Circuit::getLayout , return_value_policy<reference_existing_object>()))
// accessors
.def("getValue", &Circuit::getValue)
.def("getValue", &Circuit::getValue, return_value_policy<copy_const_reference>() )
// modifiers
.def("createNetlist" , &Circuit::createNetlist , return_value_policy<reference_existing_object>())
.def("createSchematic", &Circuit::createSchematic, return_value_policy<reference_existing_object>())
.def("createSizing" , &Circuit::createSizing , return_value_policy<reference_existing_object>())
.def("createLayout" , &Circuit::createLayout , return_value_policy<reference_existing_object>())
.def("addParameter", static_cast<void(Circuit::*)(Name, double )>(&Circuit::addParameter))
.def("addParameter", static_cast<void(Circuit::*)(Name, std::string)>(&Circuit::addParameter))
.def("addParameter", static_cast<void(Circuit::*)(Name, const char*)>(&Circuit::addParameter))
.def("addParameter", static_cast<void(Circuit::*)(Name, const std::string&)>(&Circuit::addParameter))
// others
.def("readFromFile", &Circuit::readFromFile, return_value_policy<manage_new_object>())
.staticmethod("readFromFile")
@ -399,4 +397,6 @@ BOOST_PYTHON_MODULE(OPENCHAMS) {
register_exception_translator<OpenChamsException>(translator)
;
}
}
} // OpenChams namespace.

View File

@ -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 <vector>
#include <map>
#include <fstream>
#include <sstream>
#include <libxml/parser.h>
#include <libxml/tree.h>
@ -21,92 +29,95 @@
#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<std::string>& 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<std::string>& 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*);
void readEquations(xmlNode*, Sizing*);
void readEquation_CircuitLevel(xmlNode*, Sizing*);
void readEquation_NRC(xmlNode*, Sizing*);
void readEquation_DDPs(xmlNode*, Sizing*);
void readEquation_DesignerCstr(xmlNode*, Sizing*);
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<std::string>& compares, std::string message);
void check_lowercase(std::string& str, std::vector<std::string>& compares, std::string message);
// 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<std::string>& compares, std::string message );
void check_lowercase ( std::string& str, std::vector<std::string>& compares, std::string message );
private:
Name _name;
std::string _absolutePath;
Name _techno;
@ -117,22 +128,52 @@ class Circuit {
Layout* _layout;
std::vector<std::string> _subCircuitsPaths;
std::map<unsigned, SimulModel*> _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<std::string>& Circuit::getSubCircuitPaths() { return _subCircuitsPaths; }
};
} // namespace OpenChams
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<std::string>& Circuit::getSubCircuitPaths () { return _subCircuitsPaths; }
template<typename T>
inline std::string asString ( T value )
{ std::ostringstream output; output << value; return output.str(); }
std::string asStringBool ( bool );
std::string asStringDirection ( long );
template<typename T>
inline T stringAs ( const char* str )
{ T value; std::istringstream input(str); input >> value; return value; }
template<typename T>
inline T stringAs ( const xmlChar* str )
{ T value; std::istringstream input((const char*)str); input >> value; return value; }
template<typename T>
inline T stringAs ( const std::string& str )
{ return stringAs<T>(str.c_str()); }
bool stringAsBool ( const std::string& );
long stringAsDirection ( const std::string& );
} // namespace OpenChams.
#endif

View File

@ -1,43 +1,53 @@
/*
* 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 <map>
#include <vector>
#include <string>
#include "vlsisapd/openChams/Name.h"
#include "vlsisapd/openChams/Parameters.h"
namespace OpenChams {
class Netlist;
class Net;
class Instance {
class Netlist;
class Net;
class Instance {
public:
Instance(Name name, Name model, unsigned, Netlist*);
Instance (Name name, Name model, unsigned, Netlist*);
virtual ~Instance ();
virtual ~Instance() {};
void addConnector (Name);
void connect (Name connectorName, Name netName);
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<Name, Net*>& getConnectors();
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<Name, Net*>& getConnectors ();
private:
Name _name;
@ -45,19 +55,22 @@ class Instance {
unsigned _order;
Netlist* _netlist;
Parameters _params;
std::map<Name, Net*> _netMap; //map associant nom de connecteur a un net
};
std::map<Name, Net*> _netMap;
};
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<Name, Net*>& Instance::getConnectors() { return _netMap; };
} // namespace
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<Name, Net*>& Instance::getConnectors () { return _netMap; };
} // OpenChams namespace.
#endif

View File

@ -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;

View File

@ -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 <map>
#include <string>
namespace OpenChams {
class Name;
class Name;
class Parameters {
public:
Parameters() {};
class Parameters {
public:
inline Parameters ();
inline bool isEmpty ();
const std::string& getValue (Name);
inline const std::map<Name,std::string>& getValues ();
inline void addParameter (Name, const std::string&);
void addParameter (Name, const char*);
double getValue(Name);
std::string getEqValue(Name);
void addParameter(Name, double);
void addParameter(Name, std::string);
private:
std::map<Name,std::string> _params;
};
// pour parcourir la map :
inline bool isEmpty();
inline const std::map<Name, double>& getValues();
inline const std::map<Name, std::string>& getEqValues();
private:
std::map<Name, double> _params;
std::map<Name, std::string> _paramsEq;
};
inline Parameters::Parameters () { }
inline bool Parameters::isEmpty () { return (_params.size() == 0); }
inline const std::map<Name,std::string>& Parameters::getValues () { return _params; };
inline void Parameters::addParameter (Name name, const std::string& value) { addParameter(name,value.c_str()); }
inline bool Parameters::isEmpty() { return ((_params.size() == 0)&&(_paramsEq.size() == 0))? true : false; }
inline const std::map<Name, double>& Parameters::getValues() { return _params; };
inline const std::map<Name, std::string>& Parameters::getEqValues() { return _paramsEq; };
} // namespace
} // OpenChams namespace.
#endif

View File

@ -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,31 +23,32 @@
#include "vlsisapd/openChams/Name.h"
#include "vlsisapd/openChams/Parameters.h"
namespace OpenChams {
class Instance;
class Net;
class Transistor {
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();
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 setSource (Name);
void setDrain (Name);
void setBulk (Name);
private:
bool checkConnector(Name);
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
@ -50,15 +58,19 @@ class Transistor {
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::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; };
} // namespace
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