- No more <connectors> section in <instance> because it was redundant and useless
      - several bugs fixes
      - some minor adds to drive from hurricane
This commit is contained in:
Damien Dupuis 2010-02-02 09:55:35 +00:00
parent cf719d2a25
commit 91363d5cc7
2 changed files with 30 additions and 16 deletions

View File

@ -148,6 +148,7 @@ void Circuit::readInstances(xmlNode* node, Netlist* netlist) {
if (node->type == XML_ELEMENT_NODE) { if (node->type == XML_ELEMENT_NODE) {
if (xmlStrEqual(node->name, (xmlChar*)"instance")) { if (xmlStrEqual(node->name, (xmlChar*)"instance")) {
Instance* inst =readInstance(node, netlist); Instance* inst =readInstance(node, netlist);
if (inst)
netlist->addInstance(inst); netlist->addInstance(inst);
} else { } else {
cerr << "[WARNING] Only 'instance' nodes are allowed in 'instances', others will be ignored." << endl; cerr << "[WARNING] Only 'instance' nodes are allowed in 'instances', others will be ignored." << endl;
@ -184,19 +185,21 @@ Instance* Circuit::readInstance(xmlNode* node, Netlist* netlist) {
xmlNode* child = node->children; xmlNode* child = node->children;
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*)"connectors")) { //if (xmlStrEqual(node->name, (xmlChar*)"connectors")) {
readInstanceConnectors(node, inst); // readInstanceConnectors(node, inst);
} else if (xmlStrEqual(node->name, (xmlChar*)"parameters")) { //} else
if (xmlStrEqual(node->name, (xmlChar*)"parameters")) {
readInstanceParameters(node, inst); readInstanceParameters(node, inst);
} else { } else {
cerr << "[WARNING] Only 'conectors' and 'parameters' nodes are allowed in 'instance', others will be ignored." << endl; cerr << "[WARNING] Only 'parameters' node is allowed in 'instance', others will be ignored." << endl;
return NULL; //cerr << "[WARNING] Only 'conectors' and 'parameters' nodes are allowed in 'instance', others will be ignored." << endl;
} }
} }
} }
return inst; return inst;
} }
/*
void Circuit::readInstanceConnectors(xmlNode* node, Instance* inst) { void Circuit::readInstanceConnectors(xmlNode* node, Instance* inst) {
xmlNode* child = node->children; xmlNode* child = node->children;
for (xmlNode* node = child; node; node = node->next) { for (xmlNode* node = child; node; node = node->next) {
@ -209,6 +212,7 @@ void Circuit::readInstanceConnectors(xmlNode* node, Instance* inst) {
} }
} }
} }
*/
void Circuit::readInstanceParameters(xmlNode* node, Instance* inst) { void Circuit::readInstanceParameters(xmlNode* node, Instance* inst) {
xmlNode* child = node->children; xmlNode* child = node->children;
@ -295,7 +299,7 @@ void Circuit::readNetConnector(xmlNode* node, Net* net) {
throw OpenChamsException(error); throw OpenChamsException(error);
//return; //return;
} }
inst->connect(cName, net->getName()); //inst->connect(cName, net->getName());
net->connectTo(iName, cName); net->connectTo(iName, cName);
} else { } else {
throw OpenChamsException("[ERROR] 'connector' node must have 'instance' and 'name' properties (for net)."); throw OpenChamsException("[ERROR] 'connector' node must have 'instance' and 'name' properties (for net).");
@ -400,14 +404,17 @@ bool Circuit::writeToFile(string filePath) {
file.open(filePath.c_str()); file.open(filePath.c_str());
// checks before do anything // checks before do anything
if (!_netlist) { if (!_netlist) {
cerr << "no netlist" << endl; cerr.flush();
throw OpenChamsException("[ERROR] Cannot writeToFile since no netlist is defined !"); throw OpenChamsException("[ERROR] Cannot writeToFile since no netlist is defined !");
//return false; //return false;
} }
if (_netlist->hasNoInstances()) { if (_netlist->hasNoInstances()) {
cerr << "no instances" << endl; cerr.flush();
throw OpenChamsException("[ERROR] Cannot writeToFile since no instance is defined in netlist !"); throw OpenChamsException("[ERROR] Cannot writeToFile since no instance is defined in netlist !");
//return false; //return false;
} }
if (_netlist->hasNoNets()) { if (_netlist->hasNoNets()) {
cerr << "no nets" << endl; cerr.flush();
throw OpenChamsException("[ERROR] Cannot writeToFile since no net is defined in netlist !"); throw OpenChamsException("[ERROR] Cannot writeToFile since no net is defined in netlist !");
//return false; //return false;
} }
@ -425,20 +432,20 @@ bool Circuit::writeToFile(string filePath) {
<< " <instances>" << endl; << " <instances>" << endl;
for (vector<Instance*>::const_iterator it = _netlist->getInstances().begin() ; it != _netlist->getInstances().end() ; ++it) { for (vector<Instance*>::const_iterator it = _netlist->getInstances().begin() ; it != _netlist->getInstances().end() ; ++it) {
Instance* inst = (*it); Instance* inst = (*it);
if (inst->hasNoConnectors()) { /*if (inst->hasNoConnectors()) {
string error("[ERROR] Cannot writeToFile since instance ("); string error("[ERROR] Cannot writeToFile since instance (");
error += inst->getName().getString(); error += inst->getName().getString();
error += ") has no connectors !"; error += ") has no connectors !";
throw OpenChamsException(error); throw OpenChamsException(error);
//return false; //return false;
} }*/
string sourceBulkStr = (inst->isSourceBulkConnected()) ? "True" : "False"; string sourceBulkStr = (inst->isSourceBulkConnected()) ? "True" : "False";
file << " <instance name=\"" << inst->getName().getString() << "\" model=\"" << inst->getModel().getString() << "\" mostype=\"" << inst->getMosType().getString() << "\" sourceBulkConnected=\"" << sourceBulkStr << "\">" << endl; file << " <instance name=\"" << inst->getName().getString() << "\" model=\"" << inst->getModel().getString() << "\" mostype=\"" << inst->getMosType().getString() << "\" sourceBulkConnected=\"" << sourceBulkStr << "\">" << endl;
file << " <connectors>" << endl; /*file << " <connectors>" << endl;
for (map<Name, Net*>::const_iterator it = inst->getConnectors().begin() ; it != inst->getConnectors().end() ; ++it) { for (map<Name, Net*>::const_iterator it = inst->getConnectors().begin() ; it != inst->getConnectors().end() ; ++it) {
file << " <connector name=\"" << (*it).first.getString() << "\"/>" << endl; file << " <connector name=\"" << (*it).first.getString() << "\"/>" << endl;
} }
file << " </connectors>" << endl; file << " </connectors>" << endl;*/
if (!inst->getParameters().isEmpty()) { if (!inst->getParameters().isEmpty()) {
Parameters params = inst->getParameters(); Parameters params = inst->getParameters();
file << " <parameters>" << endl; file << " <parameters>" << endl;

View File

@ -31,6 +31,10 @@ class Circuit {
inline Netlist* getNetlist(); inline Netlist* getNetlist();
inline Schematic* getSchematic(); inline Schematic* getSchematic();
inline void addParameter(Name, double); inline void addParameter(Name, double);
inline Parameters getParameters();
inline void setNetlist(Netlist*);
inline void setSchematic(Schematic*);
bool writeToFile(string filePath); bool writeToFile(string filePath);
static Circuit* readFromFile(const string filePath); static Circuit* readFromFile(const string filePath);
@ -43,7 +47,7 @@ class Circuit {
void readInstances(xmlNode*, Netlist*); void readInstances(xmlNode*, Netlist*);
Instance* readInstance (xmlNode*, Netlist*); Instance* readInstance (xmlNode*, Netlist*);
void readInstanceParameters(xmlNode*, Instance*); void readInstanceParameters(xmlNode*, Instance*);
void readInstanceConnectors(xmlNode*, Instance*); //void readInstanceConnectors(xmlNode*, Instance*);
void readNets(xmlNode*, Netlist*); void readNets(xmlNode*, Netlist*);
Net* readNet (xmlNode*, Netlist*); Net* readNet (xmlNode*, Netlist*);
void readNetConnector(xmlNode*, Net*); void readNetConnector(xmlNode*, Net*);
@ -60,12 +64,15 @@ class Circuit {
Schematic* _schematic; Schematic* _schematic;
}; };
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 double 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 void Circuit::addParameter(Name name, double value) { _params.addParameter(name, value); } inline void Circuit::addParameter(Name name, double value) { _params.addParameter(name, value); };
inline Parameters Circuit::getParameters() { return _params; };
inline void Circuit::setNetlist(Netlist* netlist) { _netlist = netlist; };
inline void Circuit::setSchematic(Schematic* schem) { _schematic = schem; };
} // namespace IO } // namespace IO