From d89ebe3b4e78593df4966ff1e37c1bd0059ba5ac Mon Sep 17 00:00:00 2001 From: Damien Dupuis Date: Thu, 10 Mar 2011 10:42:30 +0000 Subject: [PATCH] OpenChams: symmetry becomes orientation and now supports symmetries AND rotations. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are 8 possible orientations: ID (identity) R1 (rotate 90° Counter Clock wise) R2 (symX and symY) R3 (rotate 90° Clock Wise) MX (symX) XR (symX then rotate 90° Counter Clock Wise) MY (symY) YR (symY then rotate 90° Counter Clock Wise) These orientations exactly copy Hurricane::Transformation::Orientation --- vlsisapd/examples/openChams/buffer.xml | 12 ++--- .../openChams/cplusplus/parseOpenChams.cpp | 4 +- vlsisapd/examples/openChams/inverter.xml | 12 ++--- .../openChams/python/parseOpenChams.py | 4 +- vlsisapd/src/openChams/src/Circuit.cpp | 50 +++++++++---------- vlsisapd/src/openChams/src/Net.cpp | 4 +- vlsisapd/src/openChams/src/PyOpenChams.cpp | 16 +++--- vlsisapd/src/openChams/src/Schematic.cpp | 8 +-- .../openChams/src/vlsisapd/openChams/Net.h | 2 +- .../openChams/src/vlsisapd/openChams/Port.h | 24 ++++----- .../src/vlsisapd/openChams/Schematic.h | 14 +++--- 11 files changed, 75 insertions(+), 75 deletions(-) diff --git a/vlsisapd/examples/openChams/buffer.xml b/vlsisapd/examples/openChams/buffer.xml index 7d8ecf4e..6cf15eb0 100644 --- a/vlsisapd/examples/openChams/buffer.xml +++ b/vlsisapd/examples/openChams/buffer.xml @@ -44,10 +44,10 @@ - - + + - + @@ -60,14 +60,14 @@ - + - + @@ -78,7 +78,7 @@ - + diff --git a/vlsisapd/examples/openChams/cplusplus/parseOpenChams.cpp b/vlsisapd/examples/openChams/cplusplus/parseOpenChams.cpp index d8f94622..af7cb964 100644 --- a/vlsisapd/examples/openChams/cplusplus/parseOpenChams.cpp +++ b/vlsisapd/examples/openChams/cplusplus/parseOpenChams.cpp @@ -99,7 +99,7 @@ int main(int argc, char * argv[]) { cerr << " + schematic" << endl; for (map::const_iterator sit = schematic->getInstances().begin() ; sit != schematic->getInstances().end() ; ++sit) { OpenChams::Schematic::Infos* inf = (*sit).second; - cerr << " | + instance: name: " << ((*sit).first).getString() << " - x: " << inf->getX() << " - y: " << inf->getY() << " - symmetry: " << inf->getSymmetry().getString() << endl; + cerr << " | + instance: name: " << ((*sit).first).getString() << " - x: " << inf->getX() << " - y: " << inf->getY() << " - orientation: " << inf->getOrientation().getString() << endl; } if (schematicNet) { for (size_t i = 0 ; i < netlist->getNets().size() ; i++) { @@ -108,7 +108,7 @@ int main(int argc, char * argv[]) { if (!net->hasNoPorts()) { for (size_t j = 0 ; j < net->getPorts().size() ; j++) { OpenChams::Port* port = net->getPorts()[j]; - cerr << " | | + port type: " << port->getType().getString() << " - idx: " << port->getIndex() << " - x: " << port->getX() << " - y: " << port->getY() << " - sym: " << port->getSymmetry().getString() << endl; + cerr << " | | + port type: " << port->getType().getString() << " - idx: " << port->getIndex() << " - x: " << port->getX() << " - y: " << port->getY() << " - orientation: " << port->getOrientation().getString() << endl; } } if (!net->hasNoWires()) { diff --git a/vlsisapd/examples/openChams/inverter.xml b/vlsisapd/examples/openChams/inverter.xml index c00022f8..83c93505 100644 --- a/vlsisapd/examples/openChams/inverter.xml +++ b/vlsisapd/examples/openChams/inverter.xml @@ -54,10 +54,10 @@ - - + + - + @@ -65,14 +65,14 @@ - + - + @@ -83,7 +83,7 @@ - + diff --git a/vlsisapd/examples/openChams/python/parseOpenChams.py b/vlsisapd/examples/openChams/python/parseOpenChams.py index b7ab58d8..e0203d51 100644 --- a/vlsisapd/examples/openChams/python/parseOpenChams.py +++ b/vlsisapd/examples/openChams/python/parseOpenChams.py @@ -40,14 +40,14 @@ def printContents(circuit): if (circuit.schematic): print " + schematic" for instance in circuit.schematic.getInstances(): - print " | + instance name:", instance.key, "- x:", instance.value.x, "- y:", instance.value.y, "- symmetry:", instance.value.symmetry + print " | + instance name:", instance.key, "- x:", instance.value.x, "- y:", instance.value.y, "- orientation:", instance.value.orientation if schematicNet: for net in circuit.netlist.getNets(): if net.hasNoPorts() and net.hasNoWires(): continue print " | + net name:", net.name for port in net.getPorts(): - print " | | + port type:", port.type, "- idx:", port.index, "- x:", port.x, "- y:", port.y, "- sym:", port.symmetry + print " | | + port type:", port.type, "- idx:", port.index, "- x:", port.x, "- y:", port.y, "- orientation:", port.orientation for wire in net.getWires(): if isinstance(wire.startPoint, InstancePoint): print " | | + wire <" + wire.startPoint.name.getString() + "," + wire.startPoint.plug.getString() +">" diff --git a/vlsisapd/src/openChams/src/Circuit.cpp b/vlsisapd/src/openChams/src/Circuit.cpp index 847c81a0..701a885b 100644 --- a/vlsisapd/src/openChams/src/Circuit.cpp +++ b/vlsisapd/src/openChams/src/Circuit.cpp @@ -561,21 +561,21 @@ void Circuit::readSchematic(xmlNode* node) { } void Circuit::readInstanceSchematic(xmlNode* node, Schematic* schematic) { - xmlChar* nameC = xmlGetProp(node, (xmlChar*)"name"); - xmlChar* xC = xmlGetProp(node, (xmlChar*)"x"); - xmlChar* yC = xmlGetProp(node, (xmlChar*)"y"); - xmlChar* symC = xmlGetProp(node, (xmlChar*)"sym"); - if (nameC && xC && yC && symC) { + xmlChar* nameC = xmlGetProp(node, (xmlChar*)"name"); + xmlChar* xC = xmlGetProp(node, (xmlChar*)"x"); + xmlChar* yC = xmlGetProp(node, (xmlChar*)"y"); + xmlChar* orientC = xmlGetProp(node, (xmlChar*)"orient"); + if (nameC && xC && yC && orientC) { Name iName((const char*)nameC); double x = ::getValue(xC); double y = ::getValue(yC); - string symStr((const char*)symC); - string symComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"}; - vector symComps (symComp, symComp+8); - check_uppercase(symStr, symComps, "[ERROR] In 'schematic'.'instance', 'sym' must be 'ID', 'R1', 'R2', 'R3', 'MX', 'XR', 'MY' or 'YR'."); - schematic->addInstance(iName, x, y, Name(symStr)); + string orientStr((const char*)orientC); + string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"}; + vector orientComps (orientComp, orientComp+8); + check_uppercase(orientStr, orientComps, "[ERROR] In 'schematic'.'instance', 'orient' must be 'ID', 'R1', 'R2', 'R3', 'MX', 'XR', 'MY' or 'YR'."); + schematic->addInstance(iName, x, y, Name(orientStr)); } else { - throw OpenChamsException("[ERROR] 'instance' node in 'schematic' must have 'name', 'x', 'y' and 'sym' properties."); + throw OpenChamsException("[ERROR] 'instance' node in 'schematic' must have 'name', 'x', 'y' and 'orient' properties."); } } @@ -608,23 +608,23 @@ void Circuit::readNetSchematic(xmlNode* node, Circuit* circuit) { } void Circuit::readPortSchematic(xmlNode* node, Net* net) { - xmlChar* typeC = xmlGetProp(node, (xmlChar*)"type"); - xmlChar* idxC = xmlGetProp(node, (xmlChar*)"idx"); - xmlChar* xC = xmlGetProp(node, (xmlChar*)"x"); - xmlChar* yC = xmlGetProp(node, (xmlChar*)"y"); - xmlChar* symC = xmlGetProp(node, (xmlChar*)"sym"); - if (typeC && idxC && xC && yC && symC) { + xmlChar* typeC = xmlGetProp(node, (xmlChar*)"type"); + xmlChar* idxC = xmlGetProp(node, (xmlChar*)"idx"); + xmlChar* xC = xmlGetProp(node, (xmlChar*)"x"); + xmlChar* yC = xmlGetProp(node, (xmlChar*)"y"); + xmlChar* orientC = xmlGetProp(node, (xmlChar*)"orient"); + if (typeC && idxC && xC && yC && orientC) { Name pType((const char*)typeC); unsigned idx = ::getValue(idxC); double x = ::getValue(xC); double y = ::getValue(yC); - string symStr((const char*)symC); - string symComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"}; - vector symComps (symComp, symComp+8); - check_uppercase(symStr, symComps, "[ERROR] In 'schematic'.'port', 'sym' must be 'ID', 'R1', 'R2', 'R3', 'MX', 'XR', 'MY' or 'YR'."); - net->addPort(pType, idx, x, y, Name(symStr)); + string orientStr((const char*)orientC); + string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"}; + vector orientComps (orientComp, orientComp+8); + check_uppercase(orientStr, orientComps, "[ERROR] In 'schematic'.'port', 'orient' must be 'ID', 'R1', 'R2', 'R3', 'MX', 'XR', 'MY' or 'YR'."); + net->addPort(pType, idx, x, y, Name(orientStr)); } else { - throw OpenChamsException("[ERROR] 'schematic'.'port' must have 'type', 'idx', 'x', 'y' and 'sym properties."); + throw OpenChamsException("[ERROR] 'schematic'.'port' must have 'type', 'idx', 'x', 'y' and 'orient' properties."); } } @@ -1067,7 +1067,7 @@ bool Circuit::writeToFile(string filePath) { file << " " << endl; for (map::const_iterator it = _schematic->getInstances().begin() ; it != _schematic->getInstances().end(); ++it ) { Schematic::Infos* infos = (*it).second; - file << " getX() << "\" y=\"" << infos->getY() << "\" sym=\"" << infos->getSymmetry().getString() << "\"/>" << endl; + file << " getX() << "\" y=\"" << infos->getY() << "\" orient=\"" << infos->getOrientation().getString() << "\"/>" << endl; } if (schematicNets) { for (size_t i = 0 ; i < nets.size() ; i++) { @@ -1079,7 +1079,7 @@ bool Circuit::writeToFile(string filePath) { Port* port = net->getPorts()[j]; if (!port) continue; - file << " getType().getString() << "\" idx=\"" << port->getIndex() << "\" x=\"" << port->getX() << "\" y=\"" << port->getY() << "\" sym=\"" << port->getSymmetry().getString() << "\"/>" << endl; + file << " getType().getString() << "\" idx=\"" << port->getIndex() << "\" x=\"" << port->getX() << "\" y=\"" << port->getY() << "\" orient=\"" << port->getOrientation().getString() << "\"/>" << endl; } for (size_t j = 0 ; j < net->getWires().size() ; j++) { Wire* wire = net->getWires()[j]; diff --git a/vlsisapd/src/openChams/src/Net.cpp b/vlsisapd/src/openChams/src/Net.cpp index c62b7408..c87162b5 100644 --- a/vlsisapd/src/openChams/src/Net.cpp +++ b/vlsisapd/src/openChams/src/Net.cpp @@ -42,12 +42,12 @@ void Net::connectTo(Name instanceName, Name connectorName) { } } -Port* Net::addPort(Name type, unsigned idx, double x, double y, Name sym) { +Port* Net::addPort(Name type, unsigned idx, double x, double y, Name orient) { while (_ports.size() <= idx) _ports.push_back(NULL); if (_ports[idx]) throw OpenChamsException("[ERROR] Net::addPort: cannot add port since another one with the same id already exists."); - _ports[idx] = new Port(type, idx, x, y, sym); + _ports[idx] = new Port(type, idx, x, y, orient); return _ports[idx]; } diff --git a/vlsisapd/src/openChams/src/PyOpenChams.cpp b/vlsisapd/src/openChams/src/PyOpenChams.cpp index b0a3b18e..ce0490c3 100644 --- a/vlsisapd/src/openChams/src/PyOpenChams.cpp +++ b/vlsisapd/src/openChams/src/PyOpenChams.cpp @@ -138,11 +138,11 @@ BOOST_PYTHON_MODULE(OPENCHAMS) { // class OpenChams::Port class_("Port", init()) // properties - .add_property("type" , &Port::getType ) - .add_property("index" , &Port::getIndex ) - .add_property("x" , &Port::getX ) - .add_property("y" , &Port::getY ) - .add_property("symmetry", &Port::getSymmetry) + .add_property("type" , &Port::getType ) + .add_property("index" , &Port::getIndex ) + .add_property("x" , &Port::getX ) + .add_property("y" , &Port::getY ) + .add_property("orientation", &Port::getOrientation) ; // class OpenChams::WirePoint @@ -264,9 +264,9 @@ BOOST_PYTHON_MODULE(OPENCHAMS) { // class OpenChams::Schematic::Infos class_("Infos", init()) - .add_property("x" , &Schematic::Infos::getX ) - .add_property("y" , &Schematic::Infos::getY ) - .add_property("symmetry", &Schematic::Infos::getSymmetry) + .add_property("x" , &Schematic::Infos::getX ) + .add_property("y" , &Schematic::Infos::getY ) + .add_property("orientation", &Schematic::Infos::getOrientation) ; } // end schematicScope diff --git a/vlsisapd/src/openChams/src/Schematic.cpp b/vlsisapd/src/openChams/src/Schematic.cpp index ff0bea6b..a042bb25 100644 --- a/vlsisapd/src/openChams/src/Schematic.cpp +++ b/vlsisapd/src/openChams/src/Schematic.cpp @@ -15,7 +15,7 @@ using namespace std; namespace OpenChams { Schematic::Schematic(Circuit* circuit): _circuit(circuit) {} -void Schematic::addInstance(Name instanceName, double x, double y, Name sym) { +void Schematic::addInstance(Name instanceName, double x, double y, Name orient) { map::iterator it = _instances.find(instanceName); if (it != _instances.end()) { string error("[ERROR] Cannot set same instance twice in 'schematic' ("); @@ -23,11 +23,11 @@ void Schematic::addInstance(Name instanceName, double x, double y, Name sym) { error += ")."; throw OpenChamsException(error); } - _instances[instanceName] = new Schematic::Infos(x, y, sym); + _instances[instanceName] = new Schematic::Infos(x, y, orient); } -Schematic::Infos::Infos(double x, double y, Name sym) +Schematic::Infos::Infos(double x, double y, Name orient) : _x(x) , _y(y) - , _sym(sym) {} + , _orient(orient) {} } // namespace diff --git a/vlsisapd/src/openChams/src/vlsisapd/openChams/Net.h b/vlsisapd/src/openChams/src/vlsisapd/openChams/Net.h index a4b0099e..9e38514c 100644 --- a/vlsisapd/src/openChams/src/vlsisapd/openChams/Net.h +++ b/vlsisapd/src/openChams/src/vlsisapd/openChams/Net.h @@ -47,7 +47,7 @@ class Net { inline const std::vector& getConnections(); // schematic relative methods - Port* addPort(Name type, unsigned idx, double x, double y, Name sym); + Port* addPort(Name type, unsigned idx, double x, double y, Name orient); Wire* addWire(); inline bool hasNoPorts(); inline const std::vector& getPorts(); diff --git a/vlsisapd/src/openChams/src/vlsisapd/openChams/Port.h b/vlsisapd/src/openChams/src/vlsisapd/openChams/Port.h index 703681e5..476be060 100644 --- a/vlsisapd/src/openChams/src/vlsisapd/openChams/Port.h +++ b/vlsisapd/src/openChams/src/vlsisapd/openChams/Port.h @@ -15,28 +15,28 @@ namespace OpenChams { class Port { public: - Port(Name type, unsigned idx , double x, double y, Name sym): _type(type), _idx(idx), _x(x), _y(y), _sym(sym) {} + Port(Name type, unsigned idx , double x, double y, Name orient): _type(type), _idx(idx), _x(x), _y(y), _orient(orient) {} ~Port() {} - inline Name getType() const; - inline unsigned getIndex() const; - inline double getX() const; - inline double getY() const; - inline Name getSymmetry() const; + inline Name getType() const; + inline unsigned getIndex() const; + inline double getX() const; + inline double getY() const; + inline Name getOrientation() const; private: Name _type; unsigned _idx; double _x; double _y; - Name _sym; + Name _orient; }; -inline Name Port::getType() const { return _type; } -inline unsigned Port::getIndex() const { return _idx; } -inline double Port::getX() const { return _x; } -inline double Port::getY() const { return _y; } -inline Name Port::getSymmetry() const { return _sym; } +inline Name Port::getType() const { return _type; } +inline unsigned Port::getIndex() const { return _idx; } +inline double Port::getX() const { return _x; } +inline double Port::getY() const { return _y; } +inline Name Port::getOrientation() const { return _orient; } } // namespace #endif diff --git a/vlsisapd/src/openChams/src/vlsisapd/openChams/Schematic.h b/vlsisapd/src/openChams/src/vlsisapd/openChams/Schematic.h index 0cc9d46e..7ee8fc03 100644 --- a/vlsisapd/src/openChams/src/vlsisapd/openChams/Schematic.h +++ b/vlsisapd/src/openChams/src/vlsisapd/openChams/Schematic.h @@ -21,21 +21,21 @@ class Schematic { public: class Infos { public: - Infos(double x, double y, Name sym); + Infos(double x, double y, Name orient); inline double getX(); inline double getY(); - inline Name getSymmetry(); + inline Name getOrientation(); private: double _x; double _y; - Name _sym; + Name _orient; }; public: Schematic(Circuit*); - void addInstance(Name instanceName, double x, double y, Name sym ); + void addInstance(Name instanceName, double x, double y, Name orient ); inline bool hasNoInstances(); inline const std::map& getInstances(); @@ -48,9 +48,9 @@ class Schematic { inline bool Schematic::hasNoInstances() { return (_instances.size() == 0) ? true : false; }; inline const std::map& Schematic::getInstances() { return _instances; }; -inline double Schematic::Infos::getX() { return _x; }; -inline double Schematic::Infos::getY() { return _y; }; -inline Name Schematic::Infos::getSymmetry() { return _sym; }; +inline double Schematic::Infos::getX() { return _x; }; +inline double Schematic::Infos::getY() { return _y; }; +inline Name Schematic::Infos::getOrientation() { return _orient; }; } // namespace #endif