From 91363d5cc7147520e80df95940a9ca5b14c3b2b3 Mon Sep 17 00:00:00 2001 From: Damien Dupuis Date: Tue, 2 Feb 2010 09:55:35 +0000 Subject: [PATCH] CHANGES - No more section in because it was redundant and useless - several bugs fixes - some minor adds to drive from hurricane --- vlsisapd/openChams/Circuit.cpp | 29 ++++++++++++++++++----------- vlsisapd/openChams/Circuit.h | 17 ++++++++++++----- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/vlsisapd/openChams/Circuit.cpp b/vlsisapd/openChams/Circuit.cpp index 5cbefdad..8fba85dd 100644 --- a/vlsisapd/openChams/Circuit.cpp +++ b/vlsisapd/openChams/Circuit.cpp @@ -148,7 +148,8 @@ void Circuit::readInstances(xmlNode* node, Netlist* netlist) { if (node->type == XML_ELEMENT_NODE) { if (xmlStrEqual(node->name, (xmlChar*)"instance")) { Instance* inst =readInstance(node, netlist); - netlist->addInstance(inst); + if (inst) + netlist->addInstance(inst); } else { 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; for (xmlNode* node = child; node; node = node->next) { if (node->type == XML_ELEMENT_NODE) { - if (xmlStrEqual(node->name, (xmlChar*)"connectors")) { - readInstanceConnectors(node, inst); - } else if (xmlStrEqual(node->name, (xmlChar*)"parameters")) { + //if (xmlStrEqual(node->name, (xmlChar*)"connectors")) { + // readInstanceConnectors(node, inst); + //} else + if (xmlStrEqual(node->name, (xmlChar*)"parameters")) { readInstanceParameters(node, inst); } else { - cerr << "[WARNING] Only 'conectors' and 'parameters' nodes are allowed in 'instance', others will be ignored." << endl; - return NULL; + cerr << "[WARNING] Only 'parameters' node is allowed in 'instance', others will be ignored." << endl; + //cerr << "[WARNING] Only 'conectors' and 'parameters' nodes are allowed in 'instance', others will be ignored." << endl; } } } return inst; } +/* void Circuit::readInstanceConnectors(xmlNode* node, Instance* inst) { xmlNode* child = node->children; 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) { xmlNode* child = node->children; @@ -295,7 +299,7 @@ void Circuit::readNetConnector(xmlNode* node, Net* net) { throw OpenChamsException(error); //return; } - inst->connect(cName, net->getName()); + //inst->connect(cName, net->getName()); net->connectTo(iName, cName); } else { 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()); // checks before do anything if (!_netlist) { + cerr << "no netlist" << endl; cerr.flush(); throw OpenChamsException("[ERROR] Cannot writeToFile since no netlist is defined !"); //return false; } if (_netlist->hasNoInstances()) { + cerr << "no instances" << endl; cerr.flush(); throw OpenChamsException("[ERROR] Cannot writeToFile since no instance is defined in netlist !"); //return false; } if (_netlist->hasNoNets()) { + cerr << "no nets" << endl; cerr.flush(); throw OpenChamsException("[ERROR] Cannot writeToFile since no net is defined in netlist !"); //return false; } @@ -425,20 +432,20 @@ bool Circuit::writeToFile(string filePath) { << " " << endl; for (vector::const_iterator it = _netlist->getInstances().begin() ; it != _netlist->getInstances().end() ; ++it) { Instance* inst = (*it); - if (inst->hasNoConnectors()) { + /*if (inst->hasNoConnectors()) { string error("[ERROR] Cannot writeToFile since instance ("); error += inst->getName().getString(); error += ") has no connectors !"; throw OpenChamsException(error); //return false; - } + }*/ string sourceBulkStr = (inst->isSourceBulkConnected()) ? "True" : "False"; file << " getName().getString() << "\" model=\"" << inst->getModel().getString() << "\" mostype=\"" << inst->getMosType().getString() << "\" sourceBulkConnected=\"" << sourceBulkStr << "\">" << endl; - file << " " << endl; + /*file << " " << endl; for (map::const_iterator it = inst->getConnectors().begin() ; it != inst->getConnectors().end() ; ++it) { file << " " << endl; } - file << " " << endl; + file << " " << endl;*/ if (!inst->getParameters().isEmpty()) { Parameters params = inst->getParameters(); file << " " << endl; diff --git a/vlsisapd/openChams/Circuit.h b/vlsisapd/openChams/Circuit.h index 5c194c65..fd5606b9 100644 --- a/vlsisapd/openChams/Circuit.h +++ b/vlsisapd/openChams/Circuit.h @@ -31,6 +31,10 @@ class Circuit { inline Netlist* getNetlist(); inline Schematic* getSchematic(); inline void addParameter(Name, double); + inline Parameters getParameters(); + + inline void setNetlist(Netlist*); + inline void setSchematic(Schematic*); bool writeToFile(string filePath); static Circuit* readFromFile(const string filePath); @@ -43,7 +47,7 @@ class Circuit { void readInstances(xmlNode*, Netlist*); Instance* readInstance (xmlNode*, Netlist*); void readInstanceParameters(xmlNode*, Instance*); - void readInstanceConnectors(xmlNode*, Instance*); + //void readInstanceConnectors(xmlNode*, Instance*); void readNets(xmlNode*, Netlist*); Net* readNet (xmlNode*, Netlist*); void readNetConnector(xmlNode*, Net*); @@ -60,12 +64,15 @@ class Circuit { Schematic* _schematic; }; -inline Name Circuit::getName() { return _name; } -inline Name Circuit::getTechno() { return _techno; } -inline double Circuit::getValue(Name name) { return _params.getValue(name); } +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 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