* ./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,18 +37,101 @@ using namespace std;
|
||||||
#include "vlsisapd/openChams/DDP.h"
|
#include "vlsisapd/openChams/DDP.h"
|
||||||
#include "vlsisapd/openChams/DesignerCstrOC.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 {
|
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 readSubCircuitsPathsDone = false;
|
||||||
static bool readCircuitParametersDone = false;
|
static bool readCircuitParametersDone = false;
|
||||||
static bool readSimulModelsDone = false;
|
static bool readSimulModelsDone = 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) {
|
||||||
|
@ -196,22 +268,17 @@ namespace OpenChams {
|
||||||
}
|
}
|
||||||
if (node->type == XML_ELEMENT_NODE && node->children) {
|
if (node->type == XML_ELEMENT_NODE && node->children) {
|
||||||
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")) {
|
} else {
|
||||||
string eqStr = "";
|
cerr << "[WARNING] Only 'parameter' and 'parameterEq' nodes are allowed under 'parameters' node." << endl;
|
||||||
Name paramName = readParameterEq(paramNode, eqStr);
|
return;
|
||||||
if (paramName == Name("")) return; // error
|
}
|
||||||
addParameter(paramName, eqStr);
|
}
|
||||||
} else {
|
|
||||||
cerr << "[WARNING] Only 'parameter' and 'parameterEq' nodes are allowed under 'parameters' node." << endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
readCircuitParametersDone = true;
|
readCircuitParametersDone = true;
|
||||||
|
@ -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,50 +23,32 @@ 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 !";
|
||||||
throw OpenChamsException(error);
|
throw OpenChamsException(error);
|
||||||
}
|
}
|
||||||
_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()) {
|
||||||
error += name.getString();
|
string error("[ERROR] No parameters named ");
|
||||||
error += " because it already exists !";
|
error += name.getString();
|
||||||
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,118 +29,151 @@
|
||||||
#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 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:
|
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
|
||||||
inline void setSizing(Sizing*);
|
, SimulModel::Version
|
||||||
inline void setLayout(Layout*);
|
, std::string );
|
||||||
|
inline void setSizing ( Sizing* );
|
||||||
Netlist* createNetlist();
|
inline void setLayout ( Layout* );
|
||||||
Schematic* createSchematic();
|
Netlist* createNetlist ();
|
||||||
Sizing* createSizing();
|
Schematic* createSchematic ();
|
||||||
Layout* createLayout();
|
Sizing* createSizing ();
|
||||||
|
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 readParameterEq(xmlNode*, std::string&);
|
Name readParameter ( xmlNode*, const xmlChar*& );
|
||||||
Name readConnector(xmlNode*);
|
Name readParameterEq ( xmlNode*, std::string& );
|
||||||
void readSubCircuitsPaths(xmlNode*);
|
Name readConnector ( xmlNode* );
|
||||||
void readCircuitParameters(xmlNode*);
|
void readSubCircuitsPaths ( xmlNode* );
|
||||||
void readSimulModels(xmlNode*);
|
void readCircuitParameters ( xmlNode* );
|
||||||
void readNetList(xmlNode*);
|
void readSimulModels ( xmlNode* );
|
||||||
void readInstances(xmlNode*, Netlist*);
|
void readNetList ( xmlNode* );
|
||||||
Instance* readInstance (xmlNode*, Netlist*);
|
void readInstances ( xmlNode*, Netlist* );
|
||||||
void readInstanceParameters(xmlNode*, Instance*);
|
Instance* readInstance ( xmlNode*, Netlist* );
|
||||||
void readInstanceConnectors(xmlNode*, Instance*);
|
void readInstanceParameters ( xmlNode*, Instance* );
|
||||||
void readInstanceTransistors(xmlNode*, Device*);
|
void readInstanceConnectors ( xmlNode*, Instance* );
|
||||||
void readTransistor(xmlNode*, Device*);
|
void readInstanceTransistors ( xmlNode*, Device* );
|
||||||
void readTransistorConnection(xmlNode*, Transistor*);
|
void readTransistor ( xmlNode*, Device* );
|
||||||
void readNets(xmlNode*, Netlist*);
|
void readTransistorConnection ( xmlNode*, Transistor* );
|
||||||
Net* readNet (xmlNode*, Netlist*);
|
void readNets ( xmlNode*, Netlist* );
|
||||||
void readNetConnector(xmlNode*, Net*);
|
Net* readNet ( xmlNode*, Netlist* );
|
||||||
void readSchematic(xmlNode*);
|
void readNetConnector ( xmlNode*, Net* );
|
||||||
void readInstanceSchematic(xmlNode*, Schematic*);
|
void readSchematic ( xmlNode* );
|
||||||
void readNetSchematic(xmlNode*, Circuit*);
|
void readInstanceSchematic ( xmlNode*, Schematic* );
|
||||||
void readPortSchematic(xmlNode*, Net*);
|
void readNetSchematic ( xmlNode*, Circuit* );
|
||||||
void readWireSchematic(xmlNode*, Net*);
|
void readPortSchematic ( xmlNode*, Net* );
|
||||||
void readSizing(xmlNode*);
|
void readWireSchematic ( xmlNode*, Net* );
|
||||||
void readInstanceSizing(xmlNode*, Sizing*);
|
void readSizing ( xmlNode* );
|
||||||
void readConstraint(xmlNode*, Operator*);
|
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 );
|
||||||
|
|
||||||
void readEquations(xmlNode*, Sizing*);
|
private:
|
||||||
void readEquation_CircuitLevel(xmlNode*, Sizing*);
|
Name _name;
|
||||||
void readEquation_NRC(xmlNode*, Sizing*);
|
std::string _absolutePath;
|
||||||
void readEquation_DDPs(xmlNode*, Sizing*);
|
Name _techno;
|
||||||
void readEquation_DesignerCstr(xmlNode*, Sizing*);
|
Parameters _params;
|
||||||
|
Netlist* _netlist;
|
||||||
void readLayout(xmlNode*);
|
Schematic* _schematic;
|
||||||
void readInstanceLayout(xmlNode*, Layout*);
|
Sizing* _sizing;
|
||||||
void readHBTree(xmlNode*, Layout*);
|
Layout* _layout;
|
||||||
Node* readNodeOrBloc(xmlNode*, Node* parent = NULL);
|
std::vector<std::string> _subCircuitsPaths;
|
||||||
void setAbsolutePath(const std::string filePath);
|
std::map<unsigned, SimulModel*> _simulModels;
|
||||||
|
};
|
||||||
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);
|
|
||||||
|
|
||||||
Name _name;
|
|
||||||
std::string _absolutePath;
|
|
||||||
Name _techno;
|
|
||||||
Parameters _params;
|
|
||||||
Netlist* _netlist;
|
|
||||||
Schematic* _schematic;
|
|
||||||
Sizing* _sizing;
|
|
||||||
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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,63 +1,76 @@
|
||||||
/*
|
|
||||||
* 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 Net;
|
|
||||||
class Instance {
|
|
||||||
public:
|
|
||||||
Instance(Name name, Name model, unsigned, Netlist*);
|
|
||||||
|
|
||||||
virtual ~Instance() {};
|
class Netlist;
|
||||||
|
class Net;
|
||||||
|
|
||||||
void addConnector(Name);
|
class Instance {
|
||||||
void connect(Name connectorName, Name netName);
|
public:
|
||||||
|
Instance (Name name, Name model, unsigned, Netlist*);
|
||||||
|
virtual ~Instance ();
|
||||||
|
|
||||||
inline void addParameter(Name, double);
|
void addConnector (Name);
|
||||||
inline void addParameter(Name, std::string);
|
void connect (Name connectorName, Name netName);
|
||||||
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();
|
|
||||||
|
|
||||||
private:
|
inline void addParameter (Name, const char* );
|
||||||
Name _name;
|
inline void addParameter (Name, const std::string& );
|
||||||
Name _model;
|
inline Name getName () const;
|
||||||
unsigned _order;
|
inline Name getModel ();
|
||||||
Netlist* _netlist;
|
inline unsigned getOrder ();
|
||||||
Parameters _params;
|
inline Netlist* getNetlist ();
|
||||||
std::map<Name, Net*> _netMap; //map associant nom de connecteur a un net
|
inline Parameters getParameters ();
|
||||||
};
|
inline bool hasNoConnectors ();
|
||||||
|
inline const std::map<Name, Net*>& getConnectors ();
|
||||||
|
|
||||||
inline void Instance::addParameter(Name name, double value) { _params.addParameter(name, value); };
|
private:
|
||||||
inline void Instance::addParameter(Name name, std::string eqStr) { _params.addParameter(name, eqStr); };
|
Name _name;
|
||||||
inline Name Instance::getName() const { return _name; };
|
Name _model;
|
||||||
inline Name Instance::getModel() { return _model; };
|
unsigned _order;
|
||||||
inline unsigned Instance::getOrder() { return _order; };
|
Netlist* _netlist;
|
||||||
inline Netlist* Instance::getNetlist() { return _netlist; };
|
Parameters _params;
|
||||||
inline Parameters Instance::getParameters() { return _params; };
|
std::map<Name, Net*> _netMap;
|
||||||
inline bool Instance::hasNoConnectors() { return (_netMap.size() == 0)? true : false; };
|
};
|
||||||
inline const std::map<Name, Net*>& Instance::getConnectors() { return _netMap; };
|
|
||||||
|
|
||||||
|
inline void Instance::addParameter (Name name, const char* value) { _params.addParameter(name,value); };
|
||||||
|
inline void Instance::addParameter (Name name, const std::string& value) { _params.addParameter(name,value); };
|
||||||
|
inline Name Instance::getName () const { return _name; };
|
||||||
|
inline Name Instance::getModel () { return _model; };
|
||||||
|
inline unsigned Instance::getOrder () { return _order; };
|
||||||
|
inline Netlist* Instance::getNetlist () { return _netlist; };
|
||||||
|
inline Parameters Instance::getParameters () { return _params; };
|
||||||
|
inline bool Instance::hasNoConnectors () { return _netMap.empty(); };
|
||||||
|
inline const std::map<Name, Net*>& Instance::getConnectors () { return _netMap; };
|
||||||
|
|
||||||
|
|
||||||
|
} // OpenChams namespace.
|
||||||
|
|
||||||
} // 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 ();
|
||||||
|
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);
|
private:
|
||||||
std::string getEqValue(Name);
|
std::map<Name,std::string> _params;
|
||||||
void addParameter(Name, double);
|
};
|
||||||
void addParameter(Name, std::string);
|
|
||||||
|
|
||||||
// pour parcourir la map :
|
|
||||||
inline bool isEmpty();
|
|
||||||
inline const std::map<Name, double>& getValues();
|
|
||||||
inline const std::map<Name, std::string>& getEqValues();
|
|
||||||
|
|
||||||
private:
|
inline Parameters::Parameters () { }
|
||||||
std::map<Name, double> _params;
|
inline bool Parameters::isEmpty () { return (_params.size() == 0); }
|
||||||
std::map<Name, std::string> _paramsEq;
|
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
|
#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,49 +23,54 @@
|
||||||
#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 Net;
|
|
||||||
class Transistor {
|
|
||||||
public:
|
|
||||||
Transistor(Name, Instance*);
|
|
||||||
|
|
||||||
inline void addParameter(Name, double);
|
class Instance;
|
||||||
inline void addParameter(Name, std::string);
|
class Net;
|
||||||
inline Parameters getParameters();
|
|
||||||
inline void setName(Name);
|
|
||||||
inline Name getName();
|
|
||||||
inline Name getGate();
|
|
||||||
inline Name getSource();
|
|
||||||
inline Name getDrain();
|
|
||||||
inline Name getBulk();
|
|
||||||
|
|
||||||
void setGate (Name);
|
|
||||||
void setSource(Name);
|
|
||||||
void setDrain (Name);
|
|
||||||
void setBulk (Name);
|
|
||||||
|
|
||||||
private:
|
class Transistor {
|
||||||
bool checkConnector(Name);
|
public:
|
||||||
|
Transistor (Name, Instance*);
|
||||||
|
inline void addParameter (Name, const char*);
|
||||||
|
inline void addParameter (Name, const std::string&);
|
||||||
|
inline Parameters getParameters ();
|
||||||
|
inline void setName (Name);
|
||||||
|
inline Name getName ();
|
||||||
|
inline Name getGate ();
|
||||||
|
inline Name getSource ();
|
||||||
|
inline Name getDrain ();
|
||||||
|
inline Name getBulk ();
|
||||||
|
void setGate (Name);
|
||||||
|
void setSource (Name);
|
||||||
|
void setDrain (Name);
|
||||||
|
void setBulk (Name);
|
||||||
|
private:
|
||||||
|
bool checkConnector (Name);
|
||||||
|
private:
|
||||||
|
Name _name;
|
||||||
|
Name _gate; // le nom du connecteur de _instance auquel la gate est reliée
|
||||||
|
Name _source; // le nom du connecteur de _instance auquel la source est reliée
|
||||||
|
Name _drain; // le nom du connecteur de _instance auquel le drain est relié
|
||||||
|
Name _bulk; // le nom du connecteur de _instance auquel le bulk est relié
|
||||||
|
Instance* _instance;
|
||||||
|
Parameters _params;
|
||||||
|
};
|
||||||
|
|
||||||
Name _name;
|
|
||||||
Name _gate; // le nom du connecteur de _instance auquel la gate est reliée
|
|
||||||
Name _source; // le nom du connecteur de _instance auquel la source est reliée
|
|
||||||
Name _drain; // le nom du connecteur de _instance auquel le drain est relié
|
|
||||||
Name _bulk; // le nom du connecteur de _instance auquel le bulk est relié
|
|
||||||
Instance* _instance;
|
|
||||||
Parameters _params;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline void Transistor::addParameter(Name name, double value) { _params.addParameter(name, value); };
|
inline void Transistor::addParameter (Name name, const char* 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 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; };
|
||||||
inline Name Transistor::getGate() { return _gate; };
|
inline Name Transistor::getGate () { return _gate; };
|
||||||
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