OpenChams:

symmetry becomes orientation and now supports symmetries AND rotations.
  
  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
This commit is contained in:
Damien Dupuis 2011-03-10 10:42:30 +00:00
parent 9f8de0144d
commit d89ebe3b4e
11 changed files with 75 additions and 75 deletions

View File

@ -44,10 +44,10 @@
</nets> </nets>
</netlist> </netlist>
<schematic> <schematic>
<instance name="inv1" x="2490" y="2600" sym="ID"/> <instance name="inv1" x="2490" y="2600" orient="ID"/>
<instance name="inv2" x="2490" y="2300" sym="ID"/> <instance name="inv2" x="2490" y="2300" orient="ID"/>
<net name="in"> <net name="in">
<port type="inV" idx="0" x="2415" y="2700" sym="MY"/> <port type="inV" idx="0" x="2415" y="2700" orient="MY"/>
<wire> <wire>
<connector name="inv1" plug="in"/> <connector name="inv1" plug="in"/>
<connector idx="0"/> <connector idx="0"/>
@ -60,14 +60,14 @@
</wire> </wire>
</net> </net>
<net name="out"> <net name="out">
<port type="outV" idx="0" x="2415" y="2200" sym="MY"/> <port type="outV" idx="0" x="2415" y="2200" orient="MY"/>
<wire> <wire>
<connector name="inv2" plug="out"/> <connector name="inv2" plug="out"/>
<connector idx="0"/> <connector idx="0"/>
</wire> </wire>
</net> </net>
<net name="vdd"> <net name="vdd">
<port type="inH" idx="0" x="2200" y="2500" sym="ID"/> <port type="inH" idx="0" x="2200" y="2500" orient="ID"/>
<wire> <wire>
<connector idx="0"/> <connector idx="0"/>
<connector name="inv2" plug="vdd"/> <connector name="inv2" plug="vdd"/>
@ -78,7 +78,7 @@
</wire> </wire>
</net> </net>
<net name="vss"> <net name="vss">
<port type="inH" idx="0" x="2700" y="2500" sym="MX"/> <port type="inH" idx="0" x="2700" y="2500" orient="MX"/>
<wire> <wire>
<connector idx="0"/> <connector idx="0"/>
<connector name="inv2" plug="vss"/> <connector name="inv2" plug="vss"/>

View File

@ -99,7 +99,7 @@ int main(int argc, char * argv[]) {
cerr << " + schematic" << endl; cerr << " + schematic" << endl;
for (map<OpenChams::Name, OpenChams::Schematic::Infos*>::const_iterator sit = schematic->getInstances().begin() ; sit != schematic->getInstances().end() ; ++sit) { for (map<OpenChams::Name, OpenChams::Schematic::Infos*>::const_iterator sit = schematic->getInstances().begin() ; sit != schematic->getInstances().end() ; ++sit) {
OpenChams::Schematic::Infos* inf = (*sit).second; 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) { if (schematicNet) {
for (size_t i = 0 ; i < netlist->getNets().size() ; i++) { for (size_t i = 0 ; i < netlist->getNets().size() ; i++) {
@ -108,7 +108,7 @@ int main(int argc, char * argv[]) {
if (!net->hasNoPorts()) { if (!net->hasNoPorts()) {
for (size_t j = 0 ; j < net->getPorts().size() ; j++) { for (size_t j = 0 ; j < net->getPorts().size() ; j++) {
OpenChams::Port* port = net->getPorts()[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()) { if (!net->hasNoWires()) {

View File

@ -54,10 +54,10 @@
</nets> </nets>
</netlist> </netlist>
<schematic> <schematic>
<instance name="nmos1" x="2490" y="2600" sym="ID"/> <instance name="nmos1" x="2490" y="2600" orient="ID"/>
<instance name="pmos1" x="2490" y="2490" sym="ID"/> <instance name="pmos1" x="2490" y="2490" orient="ID"/>
<net name="vdd"> <net name="vdd">
<port type="inV" idx="0" x="2525" y="2430" sym="ID"/> <port type="inV" idx="0" x="2525" y="2430" orient="ID"/>
<wire> <wire>
<connector name="pmos1" plug="S"/> <connector name="pmos1" plug="S"/>
<!--point x="" y=""/--> <!--point x="" y=""/-->
@ -65,14 +65,14 @@
</wire> </wire>
</net> </net>
<net name="vss"> <net name="vss">
<port type="inV" idx="0" x="2525" y="2740" sym="MY"/> <port type="inV" idx="0" x="2525" y="2740" orient="MY"/>
<wire> <wire>
<connector name="nmos1" plug="S"/> <connector name="nmos1" plug="S"/>
<connector idx="0"/> <connector idx="0"/>
</wire> </wire>
</net> </net>
<net name="in"> <net name="in">
<port type="inH" idx="0" x="2415" y="2520" sym="ID"/> <port type="inH" idx="0" x="2415" y="2520" orient="ID"/>
<wire> <wire>
<connector name="pmos1" plug="G"/> <connector name="pmos1" plug="G"/>
<connector name="nmos1" plug="G"/> <connector name="nmos1" plug="G"/>
@ -83,7 +83,7 @@
</wire> </wire>
</net> </net>
<net name="out"> <net name="out">
<port type="outH" idx="0" x="2570" y="2590" sym="ID"/> <port type="outH" idx="0" x="2570" y="2590" orient="ID"/>
<wire> <wire>
<connector name="pmos1" plug="D"/> <connector name="pmos1" plug="D"/>
<connector name="nmos1" plug="D"/> <connector name="nmos1" plug="D"/>

View File

@ -40,14 +40,14 @@ def printContents(circuit):
if (circuit.schematic): if (circuit.schematic):
print " + schematic" print " + schematic"
for instance in circuit.schematic.getInstances(): 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: if schematicNet:
for net in circuit.netlist.getNets(): for net in circuit.netlist.getNets():
if net.hasNoPorts() and net.hasNoWires(): if net.hasNoPorts() and net.hasNoWires():
continue continue
print " | + net name:", net.name print " | + net name:", net.name
for port in net.getPorts(): 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(): for wire in net.getWires():
if isinstance(wire.startPoint, InstancePoint): if isinstance(wire.startPoint, InstancePoint):
print " | | + wire <" + wire.startPoint.name.getString() + "," + wire.startPoint.plug.getString() +">" print " | | + wire <" + wire.startPoint.name.getString() + "," + wire.startPoint.plug.getString() +">"

View File

@ -561,21 +561,21 @@ void Circuit::readSchematic(xmlNode* node) {
} }
void Circuit::readInstanceSchematic(xmlNode* node, Schematic* schematic) { void Circuit::readInstanceSchematic(xmlNode* node, Schematic* schematic) {
xmlChar* nameC = xmlGetProp(node, (xmlChar*)"name"); xmlChar* nameC = xmlGetProp(node, (xmlChar*)"name");
xmlChar* xC = xmlGetProp(node, (xmlChar*)"x"); xmlChar* xC = xmlGetProp(node, (xmlChar*)"x");
xmlChar* yC = xmlGetProp(node, (xmlChar*)"y"); xmlChar* yC = xmlGetProp(node, (xmlChar*)"y");
xmlChar* symC = xmlGetProp(node, (xmlChar*)"sym"); xmlChar* orientC = xmlGetProp(node, (xmlChar*)"orient");
if (nameC && xC && yC && symC) { if (nameC && xC && yC && orientC) {
Name iName((const char*)nameC); Name iName((const char*)nameC);
double x = ::getValue<double>(xC); double x = ::getValue<double>(xC);
double y = ::getValue<double>(yC); double y = ::getValue<double>(yC);
string symStr((const char*)symC); string orientStr((const char*)orientC);
string symComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"}; string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"};
vector<string> symComps (symComp, symComp+8); vector<string> orientComps (orientComp, orientComp+8);
check_uppercase(symStr, symComps, "[ERROR] In 'schematic'.'instance', 'sym' must be 'ID', 'R1', 'R2', 'R3', 'MX', 'XR', 'MY' or 'YR'."); 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(symStr)); schematic->addInstance(iName, x, y, Name(orientStr));
} else { } 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) { void Circuit::readPortSchematic(xmlNode* node, Net* net) {
xmlChar* typeC = xmlGetProp(node, (xmlChar*)"type"); xmlChar* typeC = xmlGetProp(node, (xmlChar*)"type");
xmlChar* idxC = xmlGetProp(node, (xmlChar*)"idx"); xmlChar* idxC = xmlGetProp(node, (xmlChar*)"idx");
xmlChar* xC = xmlGetProp(node, (xmlChar*)"x"); xmlChar* xC = xmlGetProp(node, (xmlChar*)"x");
xmlChar* yC = xmlGetProp(node, (xmlChar*)"y"); xmlChar* yC = xmlGetProp(node, (xmlChar*)"y");
xmlChar* symC = xmlGetProp(node, (xmlChar*)"sym"); xmlChar* orientC = xmlGetProp(node, (xmlChar*)"orient");
if (typeC && idxC && xC && yC && symC) { if (typeC && idxC && xC && yC && orientC) {
Name pType((const char*)typeC); Name pType((const char*)typeC);
unsigned idx = ::getValue<unsigned>(idxC); unsigned idx = ::getValue<unsigned>(idxC);
double x = ::getValue<double>(xC); double x = ::getValue<double>(xC);
double y = ::getValue<double>(yC); double y = ::getValue<double>(yC);
string symStr((const char*)symC); string orientStr((const char*)orientC);
string symComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"}; string orientComp[8] = {"ID", "R1", "R2", "R3", "MX", "XR", "MY", "YR"};
vector<string> symComps (symComp, symComp+8); vector<string> orientComps (orientComp, orientComp+8);
check_uppercase(symStr, symComps, "[ERROR] In 'schematic'.'port', 'sym' must be 'ID', 'R1', 'R2', 'R3', 'MX', 'XR', 'MY' or 'YR'."); 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(symStr)); net->addPort(pType, idx, x, y, Name(orientStr));
} else { } 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 << " <schematic>" << endl; file << " <schematic>" << endl;
for (map<Name, Schematic::Infos*>::const_iterator it = _schematic->getInstances().begin() ; it != _schematic->getInstances().end(); ++it ) { for (map<Name, Schematic::Infos*>::const_iterator it = _schematic->getInstances().begin() ; it != _schematic->getInstances().end(); ++it ) {
Schematic::Infos* infos = (*it).second; Schematic::Infos* infos = (*it).second;
file << " <instance name=\"" << ((*it).first).getString() << "\" x=\"" << infos->getX() << "\" y=\"" << infos->getY() << "\" sym=\"" << infos->getSymmetry().getString() << "\"/>" << endl; file << " <instance name=\"" << ((*it).first).getString() << "\" x=\"" << infos->getX() << "\" y=\"" << infos->getY() << "\" orient=\"" << infos->getOrientation().getString() << "\"/>" << endl;
} }
if (schematicNets) { if (schematicNets) {
for (size_t i = 0 ; i < nets.size() ; i++) { for (size_t i = 0 ; i < nets.size() ; i++) {
@ -1079,7 +1079,7 @@ bool Circuit::writeToFile(string filePath) {
Port* port = net->getPorts()[j]; Port* port = net->getPorts()[j];
if (!port) if (!port)
continue; continue;
file << " <port type=\"" << port->getType().getString() << "\" idx=\"" << port->getIndex() << "\" x=\"" << port->getX() << "\" y=\"" << port->getY() << "\" sym=\"" << port->getSymmetry().getString() << "\"/>" << endl; file << " <port type=\"" << port->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++) { for (size_t j = 0 ; j < net->getWires().size() ; j++) {
Wire* wire = net->getWires()[j]; Wire* wire = net->getWires()[j];

View File

@ -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) while (_ports.size() <= idx)
_ports.push_back(NULL); _ports.push_back(NULL);
if (_ports[idx]) if (_ports[idx])
throw OpenChamsException("[ERROR] Net::addPort: cannot add port since another one with the same id already exists."); 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]; return _ports[idx];
} }

View File

@ -138,11 +138,11 @@ BOOST_PYTHON_MODULE(OPENCHAMS) {
// class OpenChams::Port // class OpenChams::Port
class_<Port, Port*>("Port", init<Name, unsigned, double, double, Name>()) class_<Port, Port*>("Port", init<Name, unsigned, double, double, Name>())
// properties // properties
.add_property("type" , &Port::getType ) .add_property("type" , &Port::getType )
.add_property("index" , &Port::getIndex ) .add_property("index" , &Port::getIndex )
.add_property("x" , &Port::getX ) .add_property("x" , &Port::getX )
.add_property("y" , &Port::getY ) .add_property("y" , &Port::getY )
.add_property("symmetry", &Port::getSymmetry) .add_property("orientation", &Port::getOrientation)
; ;
// class OpenChams::WirePoint // class OpenChams::WirePoint
@ -264,9 +264,9 @@ BOOST_PYTHON_MODULE(OPENCHAMS) {
// class OpenChams::Schematic::Infos // class OpenChams::Schematic::Infos
class_<Schematic::Infos, Schematic::Infos*>("Infos", init<double, double, Name>()) class_<Schematic::Infos, Schematic::Infos*>("Infos", init<double, double, Name>())
.add_property("x" , &Schematic::Infos::getX ) .add_property("x" , &Schematic::Infos::getX )
.add_property("y" , &Schematic::Infos::getY ) .add_property("y" , &Schematic::Infos::getY )
.add_property("symmetry", &Schematic::Infos::getSymmetry) .add_property("orientation", &Schematic::Infos::getOrientation)
; ;
} // end schematicScope } // end schematicScope

View File

@ -15,7 +15,7 @@ using namespace std;
namespace OpenChams { namespace OpenChams {
Schematic::Schematic(Circuit* circuit): _circuit(circuit) {} 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<Name, Schematic::Infos*>::iterator it = _instances.find(instanceName); map<Name, Schematic::Infos*>::iterator it = _instances.find(instanceName);
if (it != _instances.end()) { if (it != _instances.end()) {
string error("[ERROR] Cannot set same instance twice in 'schematic' ("); 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 += ")."; error += ").";
throw OpenChamsException(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) : _x(x)
, _y(y) , _y(y)
, _sym(sym) {} , _orient(orient) {}
} // namespace } // namespace

View File

@ -47,7 +47,7 @@ class Net {
inline const std::vector<Net::Connection*>& getConnections(); inline const std::vector<Net::Connection*>& getConnections();
// schematic relative methods // 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(); Wire* addWire();
inline bool hasNoPorts(); inline bool hasNoPorts();
inline const std::vector<Port*>& getPorts(); inline const std::vector<Port*>& getPorts();

View File

@ -15,28 +15,28 @@
namespace OpenChams { namespace OpenChams {
class Port { class Port {
public: 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() {} ~Port() {}
inline Name getType() const; inline Name getType() const;
inline unsigned getIndex() const; inline unsigned getIndex() const;
inline double getX() const; inline double getX() const;
inline double getY() const; inline double getY() const;
inline Name getSymmetry() const; inline Name getOrientation() const;
private: private:
Name _type; Name _type;
unsigned _idx; unsigned _idx;
double _x; double _x;
double _y; double _y;
Name _sym; Name _orient;
}; };
inline Name Port::getType() const { return _type; } inline Name Port::getType() const { return _type; }
inline unsigned Port::getIndex() const { return _idx; } inline unsigned Port::getIndex() const { return _idx; }
inline double Port::getX() const { return _x; } inline double Port::getX() const { return _x; }
inline double Port::getY() const { return _y; } inline double Port::getY() const { return _y; }
inline Name Port::getSymmetry() const { return _sym; } inline Name Port::getOrientation() const { return _orient; }
} // namespace } // namespace
#endif #endif

View File

@ -21,21 +21,21 @@ class Schematic {
public: public:
class Infos { class Infos {
public: public:
Infos(double x, double y, Name sym); Infos(double x, double y, Name orient);
inline double getX(); inline double getX();
inline double getY(); inline double getY();
inline Name getSymmetry(); inline Name getOrientation();
private: private:
double _x; double _x;
double _y; double _y;
Name _sym; Name _orient;
}; };
public: public:
Schematic(Circuit*); 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 bool hasNoInstances();
inline const std::map<Name, Infos*>& getInstances(); inline const std::map<Name, Infos*>& getInstances();
@ -48,9 +48,9 @@ class Schematic {
inline bool Schematic::hasNoInstances() { return (_instances.size() == 0) ? true : false; }; inline bool Schematic::hasNoInstances() { return (_instances.size() == 0) ? true : false; };
inline const std::map<Name, Schematic::Infos*>& Schematic::getInstances() { return _instances; }; inline const std::map<Name, Schematic::Infos*>& Schematic::getInstances() { return _instances; };
inline double Schematic::Infos::getX() { return _x; }; inline double Schematic::Infos::getX() { return _x; };
inline double Schematic::Infos::getY() { return _y; }; inline double Schematic::Infos::getY() { return _y; };
inline Name Schematic::Infos::getSymmetry() { return _sym; }; inline Name Schematic::Infos::getOrientation() { return _orient; };
} // namespace } // namespace
#endif #endif