* ./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:
parent
0bec26f739
commit
e7011ad480
|
@ -205,12 +205,13 @@ int main(int argc, char * argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!sizing->hasNoEquations()) {
|
// To update to the new equations.
|
||||||
cerr << " | + equations" << endl;
|
// if (!sizing->hasNoEquations()) {
|
||||||
for (map<OpenChams::Name, string>::const_iterator eit = sizing->getEquations().begin() ; eit != sizing->getEquations().end() ; ++eit) {
|
// cerr << " | + equations" << endl;
|
||||||
cerr << " | | " << ((*eit).first).getString() << " : " << (*eit).second << 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();
|
OpenChams::Layout* layout = circuit->getLayout();
|
||||||
if (layout) {
|
if (layout) {
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include "vlsisapd/openChams/Circuit.h"
|
#include "vlsisapd/openChams/Circuit.h"
|
||||||
#include "vlsisapd/openChams/Netlist.h"
|
#include "vlsisapd/openChams/Netlist.h"
|
||||||
#include "vlsisapd/openChams/Instance.h"
|
#include "vlsisapd/openChams/Instance.h"
|
||||||
|
@ -35,17 +37,100 @@ using namespace std;
|
||||||
#include "vlsisapd/openChams/DDP.h"
|
#include "vlsisapd/openChams/DDP.h"
|
||||||
#include "vlsisapd/openChams/DesignerCstrOC.h"
|
#include "vlsisapd/openChams/DesignerCstrOC.h"
|
||||||
|
|
||||||
namespace {
|
namespace OpenChams {
|
||||||
template<class T> T getValue(xmlChar* str) {
|
|
||||||
std::istringstream iss;
|
|
||||||
iss.str((const char*) str);
|
void tokenize ( const string& value, vector<string>& tokens )
|
||||||
T res;
|
{
|
||||||
iss >> res;
|
string work;
|
||||||
return res;
|
|
||||||
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace OpenChams {
|
|
||||||
|
|
||||||
static bool readSubCircuitsPathsDone = false;
|
static bool readSubCircuitsPathsDone = false;
|
||||||
static bool readCircuitParametersDone = false;
|
static bool readCircuitParametersDone = false;
|
||||||
|
@ -124,30 +209,17 @@ namespace OpenChams {
|
||||||
_simulModels[id] = sim;
|
_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* paramNameC = xmlGetProp(node, (xmlChar*)"name");
|
||||||
xmlChar* valueC = xmlGetProp(node, (xmlChar*)"value");
|
value = xmlGetProp(node, (xmlChar*)"value");
|
||||||
if (paramNameC && valueC) {
|
if (paramNameC and value) {
|
||||||
Name name((const char*)paramNameC);
|
Name name((const char*)paramNameC);
|
||||||
value = ::getValue<double>(valueC);
|
|
||||||
return name;
|
return name;
|
||||||
} else {
|
} else {
|
||||||
throw OpenChamsException("[ERROR] 'parameter' node must have 'name' and 'value' properties.");
|
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) {
|
Name Circuit::readConnector(xmlNode* node) {
|
||||||
xmlChar* connectorNameC = xmlGetProp(node, (xmlChar*)"name");
|
xmlChar* connectorNameC = xmlGetProp(node, (xmlChar*)"name");
|
||||||
if (connectorNameC) {
|
if (connectorNameC) {
|
||||||
|
@ -198,15 +270,10 @@ namespace OpenChams {
|
||||||
for (xmlNode* paramNode = node->children ; paramNode ; paramNode = paramNode->next) {
|
for (xmlNode* paramNode = node->children ; paramNode ; paramNode = paramNode->next) {
|
||||||
if (paramNode->type == XML_ELEMENT_NODE) {
|
if (paramNode->type == XML_ELEMENT_NODE) {
|
||||||
if (xmlStrEqual(paramNode->name, (xmlChar*)"parameter")) {
|
if (xmlStrEqual(paramNode->name, (xmlChar*)"parameter")) {
|
||||||
double value = 0.0;
|
const xmlChar* value = NULL;
|
||||||
Name paramName = readParameter(paramNode, value);
|
Name paramName = readParameter(paramNode, value);
|
||||||
if (paramName == Name("")) return; // error
|
if (paramName == Name("")) return; // error
|
||||||
addParameter(paramName, value);
|
addParameter(paramName, (const char*)value);
|
||||||
} else if (xmlStrEqual(paramNode->name, (xmlChar*)"parameterEq")) {
|
|
||||||
string eqStr = "";
|
|
||||||
Name paramName = readParameterEq(paramNode, eqStr);
|
|
||||||
if (paramName == Name("")) return; // error
|
|
||||||
addParameter(paramName, eqStr);
|
|
||||||
} else {
|
} else {
|
||||||
cerr << "[WARNING] Only 'parameter' and 'parameterEq' nodes are allowed under 'parameters' node." << endl;
|
cerr << "[WARNING] Only 'parameter' and 'parameterEq' nodes are allowed under 'parameters' node." << endl;
|
||||||
return;
|
return;
|
||||||
|
@ -226,12 +293,12 @@ namespace OpenChams {
|
||||||
for (xmlNode* modelNode = node->children ; modelNode ; modelNode = modelNode->next) {
|
for (xmlNode* modelNode = node->children ; modelNode ; modelNode = modelNode->next) {
|
||||||
if (modelNode->type == XML_ELEMENT_NODE) {
|
if (modelNode->type == XML_ELEMENT_NODE) {
|
||||||
if (xmlStrEqual(modelNode->name, (xmlChar*)"model")) {
|
if (xmlStrEqual(modelNode->name, (xmlChar*)"model")) {
|
||||||
xmlChar* mIdC = xmlGetProp(modelNode, (xmlChar*)"id");
|
const xmlChar* mIdC = xmlGetProp(modelNode, (xmlChar*)"id");
|
||||||
xmlChar* mBaseC = xmlGetProp(modelNode, (xmlChar*)"base");
|
const xmlChar* mBaseC = xmlGetProp(modelNode, (xmlChar*)"base");
|
||||||
xmlChar* mVersionC = xmlGetProp(modelNode, (xmlChar*)"version");
|
const xmlChar* mVersionC = xmlGetProp(modelNode, (xmlChar*)"version");
|
||||||
xmlChar* mFilePathC = xmlGetProp(modelNode, (xmlChar*)"filePath");
|
const xmlChar* mFilePathC = xmlGetProp(modelNode, (xmlChar*)"filePath");
|
||||||
if (mIdC && mBaseC && mVersionC && mFilePathC) {
|
if (mIdC && mBaseC && mVersionC && mFilePathC) {
|
||||||
unsigned id = ::getValue<unsigned>(mIdC);
|
unsigned id = stringAs<unsigned>(mIdC);
|
||||||
SimulModel::Base base = SimulModel::BSIM3V3;
|
SimulModel::Base base = SimulModel::BSIM3V3;
|
||||||
string mBase((const char*)mBaseC);
|
string mBase((const char*)mBaseC);
|
||||||
string baseComp[3] = { "BSIM3V3", "BSIM4", "PSP" };
|
string baseComp[3] = { "BSIM3V3", "BSIM4", "PSP" };
|
||||||
|
@ -332,7 +399,7 @@ namespace OpenChams {
|
||||||
if (iNameC && iModelC && iOrderC && iMOSC && iSBCC) { // this is a device
|
if (iNameC && iModelC && iOrderC && iMOSC && iSBCC) { // this is a device
|
||||||
Name instanceName((const char*)iNameC);
|
Name instanceName((const char*)iNameC);
|
||||||
Name modelName((const char*)iModelC);
|
Name modelName((const char*)iModelC);
|
||||||
unsigned order = ::getValue<unsigned>(iOrderC);
|
unsigned order = stringAs<unsigned>(iOrderC);
|
||||||
string mosStr((const char*)iMOSC);
|
string mosStr((const char*)iMOSC);
|
||||||
string mosComp[2] = {"NMOS", "PMOS"};
|
string mosComp[2] = {"NMOS", "PMOS"};
|
||||||
vector<string> mosComps (mosComp, mosComp+2);
|
vector<string> mosComps (mosComp, mosComp+2);
|
||||||
|
@ -346,7 +413,7 @@ namespace OpenChams {
|
||||||
} else if (iNameC && iModelC && iOrderC && !iMOSC && !iSBCC) { // this is a subcircuit
|
} else if (iNameC && iModelC && iOrderC && !iMOSC && !iSBCC) { // this is a subcircuit
|
||||||
Name instanceName((const char*)iNameC);
|
Name instanceName((const char*)iNameC);
|
||||||
Name modelName((const char*)iModelC);
|
Name modelName((const char*)iModelC);
|
||||||
unsigned order = ::getValue<unsigned>(iOrderC);
|
unsigned order = stringAs<unsigned>(iOrderC);
|
||||||
inst = netlist->addInstance(instanceName, modelName, order);
|
inst = netlist->addInstance(instanceName, modelName, order);
|
||||||
} else {
|
} else {
|
||||||
throw OpenChamsException("[ERROR] 'instance' node must have ('name', 'model' and 'order') or ('name', 'model', 'order', 'mostype' and 'sourceBulkConnected') properties.");
|
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) {
|
for (xmlNode* node = child; node; node = node->next) {
|
||||||
if (node->type == XML_ELEMENT_NODE) {
|
if (node->type == XML_ELEMENT_NODE) {
|
||||||
if (xmlStrEqual(node->name, (xmlChar*)"parameter")) {
|
if (xmlStrEqual(node->name, (xmlChar*)"parameter")) {
|
||||||
double value = 0.0;
|
const xmlChar* value = NULL;
|
||||||
Name paramName = readParameter(node, value);
|
Name paramName = readParameter(node, value);
|
||||||
if (paramName == Name("")) return; // error
|
if (paramName == Name("")) return; // error
|
||||||
inst->addParameter(paramName, value);
|
inst->addParameter(paramName, (const char*)value);
|
||||||
} else if (xmlStrEqual(node->name, (xmlChar*)"parameterEq")) {
|
|
||||||
string eqStr = "";
|
|
||||||
Name paramName = readParameterEq(node, eqStr);
|
|
||||||
if (paramName == Name("")) return; // error
|
|
||||||
inst->addParameter(paramName, eqStr);
|
|
||||||
} else {
|
} else {
|
||||||
cerr << "[WARNING] Only 'parameter' and 'parameterEq' nodes are allowed under 'instance' node." << endl;
|
cerr << "[WARNING] Only 'parameter' and 'parameterEq' nodes are allowed under 'instance' node." << endl;
|
||||||
return;
|
return;
|
||||||
|
@ -576,8 +638,8 @@ namespace OpenChams {
|
||||||
xmlChar* orientC = xmlGetProp(node, (xmlChar*)"orient");
|
xmlChar* orientC = xmlGetProp(node, (xmlChar*)"orient");
|
||||||
if (nameC && xC && yC && orientC) {
|
if (nameC && xC && yC && orientC) {
|
||||||
Name iName((const char*)nameC);
|
Name iName((const char*)nameC);
|
||||||
double x = ::getValue<double>(xC);
|
double x = stringAs<double>((const char*)xC);
|
||||||
double y = ::getValue<double>(yC);
|
double y = stringAs<double>((const char*)yC);
|
||||||
string orientStr((const char*)orientC);
|
string orientStr((const char*)orientC);
|
||||||
string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"};
|
string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"};
|
||||||
vector<string> orientComps (orientComp, orientComp+8);
|
vector<string> orientComps (orientComp, orientComp+8);
|
||||||
|
@ -624,9 +686,9 @@ namespace OpenChams {
|
||||||
xmlChar* orientC = xmlGetProp(node, (xmlChar*)"orient");
|
xmlChar* orientC = xmlGetProp(node, (xmlChar*)"orient");
|
||||||
if (typeC && idxC && xC && yC && orientC) {
|
if (typeC && idxC && xC && yC && orientC) {
|
||||||
Name pType((const char*)typeC);
|
Name pType((const char*)typeC);
|
||||||
unsigned idx = ::getValue<unsigned>(idxC);
|
unsigned idx = stringAs<unsigned>(idxC);
|
||||||
double x = ::getValue<double>(xC);
|
double x = stringAs<double>(xC);
|
||||||
double y = ::getValue<double>(yC);
|
double y = stringAs<double>(yC);
|
||||||
string orientStr((const char*)orientC);
|
string orientStr((const char*)orientC);
|
||||||
string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"};
|
string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"};
|
||||||
vector<string> orientComps (orientComp, orientComp+8);
|
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).");
|
throw OpenChamsException("[ERROR] In 'schematic' a 'wire' must have exactly 2 connectors (not more).");
|
||||||
}
|
}
|
||||||
} else if (idxC) {
|
} else if (idxC) {
|
||||||
unsigned idx = ::getValue<unsigned>(idxC);
|
unsigned idx = stringAs<unsigned>(idxC);
|
||||||
if (!wire->getStartPoint()) {
|
if (!wire->getStartPoint()) {
|
||||||
wire->setStartPoint(idx);
|
wire->setStartPoint(idx);
|
||||||
} else if (!wire->getEndPoint()) {
|
} else if (!wire->getEndPoint()) {
|
||||||
|
@ -673,8 +735,8 @@ namespace OpenChams {
|
||||||
xmlChar* xC = xmlGetProp(node, (xmlChar*)"x");
|
xmlChar* xC = xmlGetProp(node, (xmlChar*)"x");
|
||||||
xmlChar* yC = xmlGetProp(node, (xmlChar*)"y");
|
xmlChar* yC = xmlGetProp(node, (xmlChar*)"y");
|
||||||
if (xC && yC) {
|
if (xC && yC) {
|
||||||
double x = ::getValue<double>(xC);
|
double x = stringAs<double>(xC);
|
||||||
double y = ::getValue<double>(yC);
|
double y = stringAs<double>(yC);
|
||||||
wire->addIntermediatePoint(x, y); // check is done inside the method (start/end points)
|
wire->addIntermediatePoint(x, y); // check is done inside the method (start/end points)
|
||||||
} else {
|
} else {
|
||||||
throw OpenChamsException("[ERROR] 'schematic'.'net'.'point' node must have 'x' and 'y' properties.");
|
throw OpenChamsException("[ERROR] 'schematic'.'net'.'point' node must have 'x' and 'y' properties.");
|
||||||
|
@ -753,7 +815,7 @@ namespace OpenChams {
|
||||||
Name refParam ((const char*)refParamC);
|
Name refParam ((const char*)refParamC);
|
||||||
double factor = 1.0;
|
double factor = 1.0;
|
||||||
if (factorC) {
|
if (factorC) {
|
||||||
factor = ::getValue<double>(factorC);
|
factor = stringAs<double>(factorC);
|
||||||
}
|
}
|
||||||
op->addConstraint(param, ref, refParam, factor);
|
op->addConstraint(param, ref, refParam, factor);
|
||||||
} else if (paramC && refEqC) {
|
} else if (paramC && refEqC) {
|
||||||
|
@ -761,7 +823,7 @@ namespace OpenChams {
|
||||||
Name refEq ((const char*)refEqC);
|
Name refEq ((const char*)refEqC);
|
||||||
double factor = 1.0;
|
double factor = 1.0;
|
||||||
if (factorC) {
|
if (factorC) {
|
||||||
factor = ::getValue<double>(factorC);
|
factor = stringAs<double>(factorC);
|
||||||
}
|
}
|
||||||
op->addConstraint(param, refEq, factor);
|
op->addConstraint(param, refEq, factor);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1224,14 +1286,10 @@ namespace OpenChams {
|
||||||
}
|
}
|
||||||
if (!_params.isEmpty()) {
|
if (!_params.isEmpty()) {
|
||||||
file << " <parameters>" << endl;
|
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;
|
file << " <parameter name=\"" << (*it).first.getString() << "\" value=\"" << (*it).second << "\"/>" << endl;
|
||||||
}
|
}
|
||||||
cerr << "_params.getValues().size() = " << _params.getValues().size() << 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 << " </parameters>" << endl;
|
||||||
}
|
}
|
||||||
file << " <netlist>" << endl
|
file << " <netlist>" << endl
|
||||||
|
@ -1278,12 +1336,9 @@ namespace OpenChams {
|
||||||
if (!inst->getParameters().isEmpty()) {
|
if (!inst->getParameters().isEmpty()) {
|
||||||
Parameters params = inst->getParameters();
|
Parameters params = inst->getParameters();
|
||||||
file << " <parameters>" << endl;
|
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;
|
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 << " </parameters>" << endl;
|
||||||
}
|
}
|
||||||
file << " </instance>" << endl;
|
file << " </instance>" << endl;
|
||||||
|
|
|
@ -24,6 +24,11 @@ Instance::Instance(Name name, Name model, unsigned order, Netlist* netlist)
|
||||||
, _params()
|
, _params()
|
||||||
, _netMap() {}
|
, _netMap() {}
|
||||||
|
|
||||||
|
|
||||||
|
Instance::~Instance ()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
|
||||||
void Instance::addConnector(Name name) {
|
void Instance::addConnector(Name name) {
|
||||||
// si name n'est pas déjà présent dans la map on ajoute name, NULL (pas de net)
|
// 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);
|
map<Name, Net*>::iterator it = _netMap.find(name);
|
||||||
|
|
|
@ -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);
|
return (_id == n._id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Name::operator==(const string& str) {
|
bool Name::operator==(const string& str) const {
|
||||||
Name n(str);
|
Name n(str);
|
||||||
return (_id == n._id);
|
return (_id == n._id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,21 @@
|
||||||
/*
|
|
||||||
* Parameters.cpp
|
// -*- C++ -*-
|
||||||
* openChams
|
//
|
||||||
*
|
// This file is part of the VLSI SAPD Software.
|
||||||
* Created by damien dupuis on 18/12/09.
|
// Copyright (c) UPMC/LIP6 2009-2012, All Rights Reserved
|
||||||
* Copyright 2009 UPMC / LIP6. 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 <iostream>
|
||||||
#include <string>
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "vlsisapd/openChams/Name.h"
|
#include "vlsisapd/openChams/Name.h"
|
||||||
|
@ -16,31 +23,12 @@ using namespace std;
|
||||||
#include "vlsisapd/openChams/OpenChamsException.h"
|
#include "vlsisapd/openChams/OpenChamsException.h"
|
||||||
|
|
||||||
namespace OpenChams {
|
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) {
|
void Parameters::addParameter ( Name name, const char* value )
|
||||||
map<Name, double>::iterator it = _params.find(name);
|
{
|
||||||
map<Name, string>::iterator it2 = _paramsEq.find(name);
|
map<Name,string>::iterator it = _params.find(name);
|
||||||
if ( it != _params.end() || it2 != _paramsEq.end() ) {
|
if ( it != _params.end() ) {
|
||||||
string error("[ERROR] Cannot addParameter ");
|
string error("[ERROR] Cannot addParameter ");
|
||||||
error += name.getString();
|
error += name.getString();
|
||||||
error += " because it already exists !";
|
error += " because it already exists !";
|
||||||
|
@ -49,17 +37,18 @@ void Parameters::addParameter(Name name, double value) {
|
||||||
_params[name] = value;
|
_params[name] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parameters::addParameter(Name name, string eqStr) {
|
|
||||||
map<Name, double>::iterator it = _params.find(name);
|
const string& Parameters::getValue ( Name name )
|
||||||
map<Name, string>::iterator it2 = _paramsEq.find(name);
|
{
|
||||||
if ( it != _params.end() || it2 != _paramsEq.end() ) {
|
map<Name,string>::iterator it = _params.find(name);
|
||||||
string error("[ERROR] Cannot addParameter ");
|
if (it == _params.end()) {
|
||||||
|
string error("[ERROR] No parameters named ");
|
||||||
error += name.getString();
|
error += name.getString();
|
||||||
error += " because it already exists !";
|
|
||||||
throw OpenChamsException(error);
|
throw OpenChamsException(error);
|
||||||
}
|
}
|
||||||
_paramsEq[name] = eqStr;
|
return (*it).second;
|
||||||
cerr << "987* _paramsEq.size() = " << _paramsEq.size() << endl;
|
|
||||||
}
|
}
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
} // OpenChams namespace.
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ using namespace boost::python;
|
||||||
#include "vlsisapd/openChams/PySTLMapWrapper.h"
|
#include "vlsisapd/openChams/PySTLMapWrapper.h"
|
||||||
|
|
||||||
namespace OpenChams {
|
namespace OpenChams {
|
||||||
|
|
||||||
void translator(OpenChamsException const& e) {
|
void translator(OpenChamsException const& e) {
|
||||||
PyErr_SetString(PyExc_UserWarning, e.what());
|
PyErr_SetString(PyExc_UserWarning, e.what());
|
||||||
}
|
}
|
||||||
|
@ -45,20 +46,17 @@ BOOST_PYTHON_MODULE(OPENCHAMS) {
|
||||||
implicitly_convertible<std::string, Name>();
|
implicitly_convertible<std::string, Name>();
|
||||||
|
|
||||||
// map wrapping for OpenChams::Parameters
|
// map wrapping for OpenChams::Parameters
|
||||||
STL_MAP_WRAPPING(Name, double , "ValuesMap" )
|
STL_MAP_WRAPPING(Name, std::string, "ValuesMap")
|
||||||
STL_MAP_WRAPPING(Name, std::string, "EquationsMap")
|
|
||||||
// class OpenChams::Parameters
|
// class OpenChams::Parameters
|
||||||
class_<Parameters>("Parameters", init<>())
|
class_<Parameters>("Parameters", init<>())
|
||||||
// accessors
|
// accessors
|
||||||
.def("getValue" , &Parameters::getValue )
|
.def("getValue" , &Parameters::getValue, return_value_policy<copy_const_reference>())
|
||||||
.def("getEqValue" , &Parameters::getEqValue)
|
|
||||||
.def("isEmpty" , &Parameters::isEmpty )
|
.def("isEmpty" , &Parameters::isEmpty )
|
||||||
// modifiers
|
// modifiers
|
||||||
.def("addParameter", static_cast<void(Parameters::*)(Name, double )>(&Parameters::addParameter))
|
.def("addParameter", static_cast<void(Parameters::*)(Name, const char*)>(&Parameters::addParameter))
|
||||||
.def("addParameter", static_cast<void(Parameters::*)(Name, std::string)>(&Parameters::addParameter))
|
.def("addParameter", static_cast<void(Parameters::*)(Name, const std::string&)>(&Parameters::addParameter))
|
||||||
// stl containers
|
// stl containers
|
||||||
.def("getValues" , &Parameters::getValues , return_value_policy<copy_const_reference>())
|
.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
|
{ //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("bulk" , &Transistor::getBulk , &Transistor::setBulk )
|
||||||
.add_property("parameters", &Transistor::getParameters ) // no setter => params will be readonly
|
.add_property("parameters", &Transistor::getParameters ) // no setter => params will be readonly
|
||||||
// modifiers
|
// modifiers
|
||||||
.def("addParameter", static_cast<void(Transistor::*)(Name, double )>(&Transistor::addParameter))
|
.def("addParameter", static_cast<void(Transistor::*)(Name, const char*)>(&Transistor::addParameter))
|
||||||
.def("addParameter", static_cast<void(Transistor::*)(Name, std::string)>(&Transistor::addParameter))
|
.def("addParameter", static_cast<void(Transistor::*)(Name, const std::string&)>(&Transistor::addParameter))
|
||||||
;
|
;
|
||||||
|
|
||||||
// map wrapping and vector_indexing for OpenChams::Instance
|
// map wrapping and vector_indexing for OpenChams::Instance
|
||||||
|
@ -114,8 +112,8 @@ BOOST_PYTHON_MODULE(OPENCHAMS) {
|
||||||
// modifiers
|
// modifiers
|
||||||
.def("addConnector" , &Instance::addConnector )
|
.def("addConnector" , &Instance::addConnector )
|
||||||
.def("connect" , &Instance::connect )
|
.def("connect" , &Instance::connect )
|
||||||
.def("addParameter" , static_cast<void(Transistor::*)(Name, double )>(&Transistor::addParameter))
|
.def("addParameter" , static_cast<void(Transistor::*)(Name, const char*)>(&Transistor::addParameter))
|
||||||
.def("addParameter" , static_cast<void(Transistor::*)(Name, std::string)>(&Transistor::addParameter))
|
.def("addParameter" , static_cast<void(Transistor::*)(Name, const std::string&)>(&Transistor::addParameter))
|
||||||
// stl containers
|
// stl containers
|
||||||
.def("getConnectors" , &Instance::getConnectors , return_internal_reference<>())
|
.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("sizing" , make_function(&Circuit::getSizing , return_value_policy<reference_existing_object>()))
|
||||||
.add_property("layout" , make_function(&Circuit::getLayout , return_value_policy<reference_existing_object>()))
|
.add_property("layout" , make_function(&Circuit::getLayout , return_value_policy<reference_existing_object>()))
|
||||||
// accessors
|
// accessors
|
||||||
.def("getValue", &Circuit::getValue)
|
.def("getValue", &Circuit::getValue, return_value_policy<copy_const_reference>() )
|
||||||
// modifiers
|
// modifiers
|
||||||
.def("createNetlist" , &Circuit::createNetlist , return_value_policy<reference_existing_object>())
|
.def("createNetlist" , &Circuit::createNetlist , return_value_policy<reference_existing_object>())
|
||||||
.def("createSchematic", &Circuit::createSchematic, 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("createSizing" , &Circuit::createSizing , return_value_policy<reference_existing_object>())
|
||||||
.def("createLayout" , &Circuit::createLayout , 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, const char*)>(&Circuit::addParameter))
|
||||||
.def("addParameter", static_cast<void(Circuit::*)(Name, std::string)>(&Circuit::addParameter))
|
.def("addParameter", static_cast<void(Circuit::*)(Name, const std::string&)>(&Circuit::addParameter))
|
||||||
// others
|
// others
|
||||||
.def("readFromFile", &Circuit::readFromFile, return_value_policy<manage_new_object>())
|
.def("readFromFile", &Circuit::readFromFile, return_value_policy<manage_new_object>())
|
||||||
.staticmethod("readFromFile")
|
.staticmethod("readFromFile")
|
||||||
|
@ -399,4 +397,6 @@ BOOST_PYTHON_MODULE(OPENCHAMS) {
|
||||||
register_exception_translator<OpenChamsException>(translator)
|
register_exception_translator<OpenChamsException>(translator)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
} // OpenChams namespace.
|
||||||
|
|
|
@ -1,18 +1,26 @@
|
||||||
/*
|
|
||||||
* Circuit.h
|
// -*- C++ -*-
|
||||||
* openChams
|
//
|
||||||
*
|
// This file is part of the VLSI SAPD Software.
|
||||||
* Created by damien dupuis on 18/12/09.
|
// Copyright (c) UPMC/LIP6 2009-2012, All Rights Reserved
|
||||||
* Copyright 2009 UPMC / LIP6 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__
|
#ifndef __OPENCHAMS_CIRCUIT_H__
|
||||||
#define __OPENCHAMS_CIRCUIT_H__
|
#define __OPENCHAMS_CIRCUIT_H__
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <fstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#include <libxml/tree.h>
|
#include <libxml/tree.h>
|
||||||
|
@ -21,7 +29,9 @@
|
||||||
#include "vlsisapd/openChams/Parameters.h"
|
#include "vlsisapd/openChams/Parameters.h"
|
||||||
#include "vlsisapd/openChams/SimulModel.h"
|
#include "vlsisapd/openChams/SimulModel.h"
|
||||||
|
|
||||||
|
|
||||||
namespace OpenChams {
|
namespace OpenChams {
|
||||||
|
|
||||||
class Netlist;
|
class Netlist;
|
||||||
class Instance;
|
class Instance;
|
||||||
class Device;
|
class Device;
|
||||||
|
@ -35,38 +45,38 @@ class Node;
|
||||||
|
|
||||||
class Circuit {
|
class Circuit {
|
||||||
public:
|
public:
|
||||||
Circuit(Name name, Name techno);
|
Circuit ( Name, Name techno );
|
||||||
|
// Accessors.
|
||||||
inline Name getName ();
|
inline Name getName ();
|
||||||
inline Name getTechno ();
|
inline Name getTechno ();
|
||||||
inline double getValue(Name);
|
inline const std::string& getValue ( Name );
|
||||||
inline Netlist* getNetlist ();
|
inline Netlist* getNetlist ();
|
||||||
inline Schematic* getSchematic ();
|
inline Schematic* getSchematic ();
|
||||||
inline Sizing* getSizing ();
|
inline Sizing* getSizing ();
|
||||||
inline Layout* getLayout ();
|
inline Layout* getLayout ();
|
||||||
inline void addParameter(Name, double);
|
inline void addParameter ( Name, const char* );
|
||||||
inline void addParameter(Name, std::string);
|
inline void addParameter ( Name, const std::string& );
|
||||||
inline Parameters getParameters ();
|
inline Parameters getParameters ();
|
||||||
inline void addSubCircuitPath ( std::string );
|
inline void addSubCircuitPath ( std::string );
|
||||||
inline std::vector<std::string>& getSubCircuitPaths ();
|
inline std::vector<std::string>& getSubCircuitPaths ();
|
||||||
|
// Mutators.
|
||||||
void addSimulModel(unsigned, SimulModel::Base, SimulModel::Version, std::string);
|
void addSimulModel ( unsigned
|
||||||
|
, SimulModel::Base
|
||||||
|
, SimulModel::Version
|
||||||
|
, std::string );
|
||||||
inline void setSizing ( Sizing* );
|
inline void setSizing ( Sizing* );
|
||||||
inline void setLayout ( Layout* );
|
inline void setLayout ( Layout* );
|
||||||
|
|
||||||
Netlist* createNetlist ();
|
Netlist* createNetlist ();
|
||||||
Schematic* createSchematic ();
|
Schematic* createSchematic ();
|
||||||
Sizing* createSizing ();
|
Sizing* createSizing ();
|
||||||
Layout* createLayout ();
|
Layout* createLayout ();
|
||||||
|
|
||||||
void driveHBTree ( std::ofstream&, Node*, unsigned );
|
void driveHBTree ( std::ofstream&, Node*, unsigned );
|
||||||
|
|
||||||
bool writeToFile ( std::string filePath );
|
bool writeToFile ( std::string filePath );
|
||||||
static Circuit* readFromFile ( const std::string filePath );
|
static Circuit* readFromFile ( const std::string filePath );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Name readParameter(xmlNode*, double&);
|
// Internal methods (XML parser).
|
||||||
|
Name readParameter ( xmlNode*, const xmlChar*& );
|
||||||
Name readParameterEq ( xmlNode*, std::string& );
|
Name readParameterEq ( xmlNode*, std::string& );
|
||||||
Name readConnector ( xmlNode* );
|
Name readConnector ( xmlNode* );
|
||||||
void readSubCircuitsPaths ( xmlNode* );
|
void readSubCircuitsPaths ( xmlNode* );
|
||||||
|
@ -91,22 +101,23 @@ class Circuit {
|
||||||
void readSizing ( xmlNode* );
|
void readSizing ( xmlNode* );
|
||||||
void readInstanceSizing ( xmlNode*, Sizing* );
|
void readInstanceSizing ( xmlNode*, Sizing* );
|
||||||
void readConstraint ( xmlNode*, Operator* );
|
void readConstraint ( xmlNode*, Operator* );
|
||||||
|
// Equation related XML methods.
|
||||||
void readEquations ( xmlNode*, Sizing* );
|
void readEquations ( xmlNode*, Sizing* );
|
||||||
void readEquation_CircuitLevel ( xmlNode*, Sizing* );
|
void readEquation_CircuitLevel ( xmlNode*, Sizing* );
|
||||||
void readEquation_NRC ( xmlNode*, Sizing* );
|
void readEquation_NRC ( xmlNode*, Sizing* );
|
||||||
void readEquation_DDPs ( xmlNode*, Sizing* );
|
void readEquation_DDPs ( xmlNode*, Sizing* );
|
||||||
void readEquation_DesignerCstr ( xmlNode*, Sizing* );
|
void readEquation_DesignerCstr ( xmlNode*, Sizing* );
|
||||||
|
// Layout related XML methods.
|
||||||
void readLayout ( xmlNode* );
|
void readLayout ( xmlNode* );
|
||||||
void readInstanceLayout ( xmlNode*, Layout* );
|
void readInstanceLayout ( xmlNode*, Layout* );
|
||||||
void readHBTree ( xmlNode*, Layout* );
|
void readHBTree ( xmlNode*, Layout* );
|
||||||
Node* readNodeOrBloc ( xmlNode*, Node* parent = NULL );
|
Node* readNodeOrBloc ( xmlNode*, Node* parent = NULL );
|
||||||
void setAbsolutePath ( const std::string filePath );
|
void setAbsolutePath ( const std::string filePath );
|
||||||
|
// Utilities methods.
|
||||||
void check_uppercase ( std::string& str, std::vector<std::string>& compares, std::string message );
|
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 );
|
void check_lowercase ( std::string& str, std::vector<std::string>& compares, std::string message );
|
||||||
|
|
||||||
|
private:
|
||||||
Name _name;
|
Name _name;
|
||||||
std::string _absolutePath;
|
std::string _absolutePath;
|
||||||
Name _techno;
|
Name _techno;
|
||||||
|
@ -119,20 +130,50 @@ class Circuit {
|
||||||
std::map<unsigned, SimulModel*> _simulModels;
|
std::map<unsigned, SimulModel*> _simulModels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline Name Circuit::getName () { return _name; }
|
inline Name Circuit::getName () { return _name; }
|
||||||
inline Name Circuit::getTechno () { return _techno; }
|
inline Name Circuit::getTechno () { return _techno; }
|
||||||
inline double Circuit::getValue(Name name) { return _params.getValue(name); }
|
inline const std::string& Circuit::getValue (Name name) { return _params.getValue(name); }
|
||||||
inline Netlist* Circuit::getNetlist () { return _netlist; }
|
inline Netlist* Circuit::getNetlist () { return _netlist; }
|
||||||
inline Schematic* Circuit::getSchematic () { return _schematic; }
|
inline Schematic* Circuit::getSchematic () { return _schematic; }
|
||||||
inline Sizing* Circuit::getSizing () { return _sizing; }
|
inline Sizing* Circuit::getSizing () { return _sizing; }
|
||||||
inline Layout* Circuit::getLayout () { return _layout; }
|
inline Layout* Circuit::getLayout () { return _layout; }
|
||||||
inline void Circuit::addParameter(Name name, double value) { _params.addParameter(name, value); }
|
inline void Circuit::addParameter (Name name, const char* value) { _params.addParameter(name, value); }
|
||||||
inline void Circuit::addParameter(Name name, std::string eqStr) { _params.addParameter(name, eqStr); }
|
inline void Circuit::addParameter (Name name, const std::string& value) { _params.addParameter(name, value); }
|
||||||
inline Parameters Circuit::getParameters () { return _params; }
|
inline Parameters Circuit::getParameters () { return _params; }
|
||||||
inline void Circuit::addSubCircuitPath (std::string path) { _subCircuitsPaths.push_back(path); }
|
inline void Circuit::addSubCircuitPath (std::string path) { _subCircuitsPaths.push_back(path); }
|
||||||
inline std::vector<std::string>& Circuit::getSubCircuitPaths () { return _subCircuitsPaths; }
|
inline std::vector<std::string>& Circuit::getSubCircuitPaths () { return _subCircuitsPaths; }
|
||||||
|
|
||||||
|
|
||||||
} // namespace OpenChams
|
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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,41 +1,51 @@
|
||||||
/*
|
|
||||||
* Instance.h
|
// -*- C++ -*-
|
||||||
* openChams
|
//
|
||||||
*
|
// This file is part of the VLSI SAPD Software.
|
||||||
* Created by damien dupuis on 12/01/10.
|
// Copyright (c) UPMC/LIP6 2010-2012, All Rights Reserved
|
||||||
* Copyright 2010 UPMC / LIP6. 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__
|
#ifndef __OPENCHAMS_INSTANCE_H__
|
||||||
#define __OPENCHAMS_INSTANCE_H__
|
#define __OPENCHAMS_INSTANCE_H__
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "vlsisapd/openChams/Name.h"
|
#include "vlsisapd/openChams/Name.h"
|
||||||
#include "vlsisapd/openChams/Parameters.h"
|
#include "vlsisapd/openChams/Parameters.h"
|
||||||
|
|
||||||
|
|
||||||
namespace OpenChams {
|
namespace OpenChams {
|
||||||
|
|
||||||
class Netlist;
|
class Netlist;
|
||||||
class Net;
|
class Net;
|
||||||
|
|
||||||
class Instance {
|
class Instance {
|
||||||
public:
|
public:
|
||||||
Instance (Name name, Name model, unsigned, Netlist*);
|
Instance (Name name, Name model, unsigned, Netlist*);
|
||||||
|
virtual ~Instance ();
|
||||||
virtual ~Instance() {};
|
|
||||||
|
|
||||||
void addConnector (Name);
|
void addConnector (Name);
|
||||||
void connect (Name connectorName, Name netName);
|
void connect (Name connectorName, Name netName);
|
||||||
|
|
||||||
inline void addParameter(Name, double);
|
inline void addParameter (Name, const char* );
|
||||||
inline void addParameter(Name, std::string);
|
inline void addParameter (Name, const std::string& );
|
||||||
inline Name getName () const;
|
inline Name getName () const;
|
||||||
inline Name getModel ();
|
inline Name getModel ();
|
||||||
inline unsigned getOrder ();
|
inline unsigned getOrder ();
|
||||||
inline Netlist* getNetlist ();
|
inline Netlist* getNetlist ();
|
||||||
inline Parameters getParameters ();
|
inline Parameters getParameters ();
|
||||||
// pour parcourir les connecteurs
|
|
||||||
inline bool hasNoConnectors ();
|
inline bool hasNoConnectors ();
|
||||||
inline const std::map<Name, Net*>& getConnectors ();
|
inline const std::map<Name, Net*>& getConnectors ();
|
||||||
|
|
||||||
|
@ -45,19 +55,22 @@ class Instance {
|
||||||
unsigned _order;
|
unsigned _order;
|
||||||
Netlist* _netlist;
|
Netlist* _netlist;
|
||||||
Parameters _params;
|
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 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::getName () const { return _name; };
|
||||||
inline Name Instance::getModel () { return _model; };
|
inline Name Instance::getModel () { return _model; };
|
||||||
inline unsigned Instance::getOrder () { return _order; };
|
inline unsigned Instance::getOrder () { return _order; };
|
||||||
inline Netlist* Instance::getNetlist () { return _netlist; };
|
inline Netlist* Instance::getNetlist () { return _netlist; };
|
||||||
inline Parameters Instance::getParameters () { return _params; };
|
inline Parameters Instance::getParameters () { return _params; };
|
||||||
inline bool Instance::hasNoConnectors() { return (_netMap.size() == 0)? true : false; };
|
inline bool Instance::hasNoConnectors () { return _netMap.empty(); };
|
||||||
inline const std::map<Name, Net*>& Instance::getConnectors () { return _netMap; };
|
inline const std::map<Name, Net*>& Instance::getConnectors () { return _netMap; };
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
} // OpenChams namespace.
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ class Name {
|
||||||
Name(std::string);
|
Name(std::string);
|
||||||
Name(const char*);
|
Name(const char*);
|
||||||
|
|
||||||
bool operator==(const Name&);
|
bool operator==(const Name&) const;
|
||||||
bool operator==(const std::string&);
|
bool operator==(const std::string&) const;
|
||||||
bool operator<(const Name&) const;
|
bool operator<(const Name&) const;
|
||||||
|
|
||||||
inline const std::string& getString() const;
|
inline const std::string& getString() const;
|
||||||
|
|
|
@ -1,43 +1,50 @@
|
||||||
/*
|
|
||||||
* Parameters.h
|
// -*- C++ -*-
|
||||||
* openChams
|
//
|
||||||
*
|
// This file is part of the VLSI SAPD Software.
|
||||||
* Created by damien dupuis on 18/12/09.
|
// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved
|
||||||
* Copyright 2008-2010 UPMC / LIP6. 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__
|
#ifndef __OPENCHAMS_PARAMETERS_H__
|
||||||
#define __OPENCHAMS_PARAMETERS_H__
|
#define __OPENCHAMS_PARAMETERS_H__
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace OpenChams {
|
namespace OpenChams {
|
||||||
class Name;
|
class Name;
|
||||||
|
|
||||||
class Parameters {
|
class Parameters {
|
||||||
public:
|
public:
|
||||||
Parameters() {};
|
inline 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 bool isEmpty ();
|
||||||
inline const std::map<Name, double>& getValues();
|
const std::string& getValue (Name);
|
||||||
inline const std::map<Name, std::string>& getEqValues();
|
inline const std::map<Name,std::string>& getValues ();
|
||||||
|
inline void addParameter (Name, const std::string&);
|
||||||
|
void addParameter (Name, const char*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<Name, double> _params;
|
std::map<Name,std::string> _params;
|
||||||
std::map<Name, std::string> _paramsEq;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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
|
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()); }
|
||||||
|
|
||||||
|
|
||||||
|
} // OpenChams namespace.
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
/*
|
|
||||||
* Transistor.h
|
// -*- C++ -*-
|
||||||
* openChams
|
//
|
||||||
*
|
// This file is part of the VLSI SAPD Software.
|
||||||
* Created by damien dupuis on 01/03/10.
|
// Copyright (c) UPMC/LIP6 2010-2012, All Rights Reserved
|
||||||
* Copyright 2010 UPMC / LIP6. 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__
|
#ifndef __OPENCHAMS_TRANSISTOR_H__
|
||||||
|
@ -16,15 +23,18 @@
|
||||||
#include "vlsisapd/openChams/Name.h"
|
#include "vlsisapd/openChams/Name.h"
|
||||||
#include "vlsisapd/openChams/Parameters.h"
|
#include "vlsisapd/openChams/Parameters.h"
|
||||||
|
|
||||||
|
|
||||||
namespace OpenChams {
|
namespace OpenChams {
|
||||||
|
|
||||||
class Instance;
|
class Instance;
|
||||||
class Net;
|
class Net;
|
||||||
|
|
||||||
|
|
||||||
class Transistor {
|
class Transistor {
|
||||||
public:
|
public:
|
||||||
Transistor (Name, Instance*);
|
Transistor (Name, Instance*);
|
||||||
|
inline void addParameter (Name, const char*);
|
||||||
inline void addParameter(Name, double);
|
inline void addParameter (Name, const std::string&);
|
||||||
inline void addParameter(Name, std::string);
|
|
||||||
inline Parameters getParameters ();
|
inline Parameters getParameters ();
|
||||||
inline void setName (Name);
|
inline void setName (Name);
|
||||||
inline Name getName ();
|
inline Name getName ();
|
||||||
|
@ -32,15 +42,13 @@ class Transistor {
|
||||||
inline Name getSource ();
|
inline Name getSource ();
|
||||||
inline Name getDrain ();
|
inline Name getDrain ();
|
||||||
inline Name getBulk ();
|
inline Name getBulk ();
|
||||||
|
|
||||||
void setGate (Name);
|
void setGate (Name);
|
||||||
void setSource (Name);
|
void setSource (Name);
|
||||||
void setDrain (Name);
|
void setDrain (Name);
|
||||||
void setBulk (Name);
|
void setBulk (Name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool checkConnector (Name);
|
bool checkConnector (Name);
|
||||||
|
private:
|
||||||
Name _name;
|
Name _name;
|
||||||
Name _gate; // le nom du connecteur de _instance auquel la gate est reliée
|
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 _source; // le nom du connecteur de _instance auquel la source est reliée
|
||||||
|
@ -50,8 +58,9 @@ class Transistor {
|
||||||
Parameters _params;
|
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 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 Parameters Transistor::getParameters () { return _params; };
|
||||||
inline void Transistor::setName (Name name) { _name = name; };
|
inline void Transistor::setName (Name name) { _name = name; };
|
||||||
inline Name Transistor::getName () { return _name; };
|
inline Name Transistor::getName () { return _name; };
|
||||||
|
@ -59,6 +68,9 @@ class Transistor {
|
||||||
inline Name Transistor::getSource () { return _source; };
|
inline Name Transistor::getSource () { return _source; };
|
||||||
inline Name Transistor::getDrain () { return _drain; };
|
inline Name Transistor::getDrain () { return _drain; };
|
||||||
inline Name Transistor::getBulk () { return _bulk; };
|
inline Name Transistor::getBulk () { return _bulk; };
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
} // OpenChams namespace.
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue