2010-09-02 05:31:55 -05:00
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <vector>
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
#include "vlsisapd/openChams/Circuit.h"
|
|
|
|
|
#include "vlsisapd/openChams/Name.h"
|
|
|
|
|
#include "vlsisapd/openChams/Parameters.h"
|
|
|
|
|
#include "vlsisapd/openChams/Netlist.h"
|
|
|
|
|
#include "vlsisapd/openChams/Instance.h"
|
2010-11-22 04:22:04 -06:00
|
|
|
|
#include "vlsisapd/openChams/Device.h"
|
2010-09-02 05:31:55 -05:00
|
|
|
|
#include "vlsisapd/openChams/Net.h"
|
|
|
|
|
#include "vlsisapd/openChams/Transistor.h"
|
|
|
|
|
#include "vlsisapd/openChams/Schematic.h"
|
|
|
|
|
#include "vlsisapd/openChams/Sizing.h"
|
|
|
|
|
#include "vlsisapd/openChams/Operator.h"
|
|
|
|
|
#include "vlsisapd/openChams/Layout.h"
|
2011-09-14 03:13:46 -05:00
|
|
|
|
#include "vlsisapd/openChams/Node.h"
|
2011-02-15 07:57:39 -06:00
|
|
|
|
#include "vlsisapd/openChams/Port.h"
|
|
|
|
|
#include "vlsisapd/openChams/Wire.h"
|
2010-11-22 04:22:04 -06:00
|
|
|
|
#include "vlsisapd/openChams/OpenChamsException.h"
|
2010-09-02 05:31:55 -05:00
|
|
|
|
|
2011-09-14 03:13:46 -05:00
|
|
|
|
void printHBTree(OpenChams::Node* node, unsigned indent) {
|
|
|
|
|
if (!node) return; // since we pass nnode->getRight and node-getTop without checking for NULL
|
|
|
|
|
for (unsigned i = 0 ; i < indent ; i++) {
|
|
|
|
|
cerr << " |";
|
|
|
|
|
}
|
|
|
|
|
string pos = "";
|
|
|
|
|
switch(node->getPosition()) {
|
|
|
|
|
case OpenChams::Node::TOP:
|
|
|
|
|
pos = "top";
|
|
|
|
|
break;
|
|
|
|
|
case OpenChams::Node::RIGHT:
|
|
|
|
|
pos = "right";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
OpenChams::Bloc* bloc = dynamic_cast<OpenChams::Bloc*>(node);
|
|
|
|
|
if (bloc) {
|
|
|
|
|
cerr << " bloc: " << bloc->getName().getString() << " - " << pos << endl;
|
|
|
|
|
printHBTree(bloc->getTop() , indent+1);
|
|
|
|
|
printHBTree(bloc->getRight(), indent+1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
OpenChams::Group* group = dynamic_cast<OpenChams::Group*>(node);
|
|
|
|
|
if (group) {
|
|
|
|
|
string align = "none";
|
|
|
|
|
switch(group->getAlign()) {
|
|
|
|
|
case OpenChams::Group::VERTICAL:
|
|
|
|
|
align = "vertical";
|
|
|
|
|
break;
|
|
|
|
|
case OpenChams::Group::HORIZONTAL:
|
|
|
|
|
align = "horizontal";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
cerr << " group: " << group->getName().getString() << " - " << pos << " - align: " << align << " - isolated: " << group->isIsolated() << " - paired: " << group->isPaired() << endl;
|
|
|
|
|
printHBTree(group->getRootNode(), indent+1);
|
|
|
|
|
printHBTree(group->getTop() , indent+1);
|
|
|
|
|
printHBTree(group->getRight() , indent+1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
cerr << "[ERROR] printHBTree: node is nor a bloc nor a group !" << endl;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-02 05:31:55 -05:00
|
|
|
|
int main(int argc, char * argv[]) {
|
2010-10-08 02:52:15 -05:00
|
|
|
|
string file = "";
|
|
|
|
|
if (argc == 1)
|
|
|
|
|
file = "./inverter.xml";
|
|
|
|
|
else if (argc == 2)
|
|
|
|
|
file = argv[1];
|
|
|
|
|
else {
|
|
|
|
|
cerr << "Usage: openChamsParser [filename]" << endl;
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-22 04:22:04 -06:00
|
|
|
|
OpenChams::Circuit* circuit = NULL;
|
|
|
|
|
try {
|
|
|
|
|
circuit = OpenChams::Circuit::readFromFile(file);
|
|
|
|
|
} catch (OpenChams::OpenChamsException& e) {
|
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
|
exit(48);
|
|
|
|
|
}
|
2010-09-02 05:31:55 -05:00
|
|
|
|
|
|
|
|
|
cerr << circuit->getName().getString() << endl;
|
|
|
|
|
cerr << " + parameters" << endl;
|
|
|
|
|
OpenChams::Parameters params = circuit->getParameters();
|
|
|
|
|
if (!params.isEmpty()) {
|
|
|
|
|
for (map<OpenChams::Name, double>::const_iterator it = params.getValues().begin() ; it != params.getValues().end() ; ++it) {
|
|
|
|
|
cerr << " | | " << ((*it).first).getString() << " : " << (*it).second << endl;
|
|
|
|
|
}
|
|
|
|
|
for (map<OpenChams::Name, string>::const_iterator it = params.getEqValues().begin() ; it != params.getEqValues().end() ; ++it) {
|
|
|
|
|
cerr << " | | " << ((*it).first).getString() << " : " << (*it).second << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cerr << " + netlist" << endl;
|
|
|
|
|
cerr << " | + instances" << endl;
|
|
|
|
|
OpenChams::Netlist* netlist = circuit->getNetlist();
|
|
|
|
|
if (netlist && !netlist->hasNoInstances()) {
|
|
|
|
|
for (size_t i = 0 ; i < netlist->getInstances().size() ; i++) {
|
|
|
|
|
OpenChams::Instance* inst = netlist->getInstances()[i];
|
2010-11-22 04:22:04 -06:00
|
|
|
|
OpenChams::Device* dev = NULL;
|
|
|
|
|
if (dynamic_cast<OpenChams::Device*>(inst)) {
|
|
|
|
|
dev = static_cast<OpenChams::Device*>(inst);
|
2011-07-21 04:20:20 -05:00
|
|
|
|
cerr << " | | + " << dev->getName().getString() << " : " << dev->getModel().getString() << " - " << dev->getOrder() << " - " << dev->getMosType().getString() << " - " << (dev->isSourceBulkConnected()?"true":"false") << endl;
|
2010-11-22 04:22:04 -06:00
|
|
|
|
} else {
|
2011-07-21 04:20:20 -05:00
|
|
|
|
cerr << " | | + " << inst->getName().getString() << " : " << inst->getModel().getString() << " - " << inst->getOrder() << endl;
|
2010-11-22 04:22:04 -06:00
|
|
|
|
}
|
2010-09-02 05:31:55 -05:00
|
|
|
|
cerr << " | | | + connectors" << endl;
|
|
|
|
|
for (map<OpenChams::Name, OpenChams::Net*>::const_iterator cit = inst->getConnectors().begin() ; cit != inst->getConnectors().end() ; ++cit) {
|
2010-10-08 02:52:15 -05:00
|
|
|
|
if ((*cit).second)
|
|
|
|
|
cerr << " | | | | " << ((*cit).first).getString() << " : " << ((*cit).second)->getName().getString() << endl;
|
|
|
|
|
else
|
|
|
|
|
cerr << " | | | | " << ((*cit).first).getString() << endl; // no net connected !
|
2010-09-02 05:31:55 -05:00
|
|
|
|
}
|
2010-11-22 04:22:04 -06:00
|
|
|
|
if (dev) {
|
|
|
|
|
cerr << " | | | + transistors" << endl;
|
|
|
|
|
for (size_t j = 0 ; j < dev->getTransistors().size() ; j++) {
|
|
|
|
|
OpenChams::Transistor* tr = dev->getTransistors()[j];
|
|
|
|
|
cerr << " | | | | name: " << tr->getName().getString() << " - gate: " << tr->getGate().getString() << " - source: " << tr->getSource().getString() << " - drain: " << tr->getDrain().getString() << " - bulk: " << tr->getBulk().getString() << endl;
|
|
|
|
|
}
|
2010-09-02 05:31:55 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cerr << " | + nets" << endl;
|
2011-02-15 07:57:39 -06:00
|
|
|
|
bool schematicNet = false; // define wether net sections are needed in schematic section
|
2010-09-02 05:31:55 -05:00
|
|
|
|
if (!netlist->hasNoNets()) {
|
|
|
|
|
for (size_t i = 0 ; i < netlist->getNets().size() ; i++) {
|
|
|
|
|
OpenChams::Net* net = netlist->getNets()[i];
|
|
|
|
|
cerr << " | | + " << net->getName().getString() << " : " << net->getType().getString() << " - " << (net->isExternal()?"true":"false") << endl;
|
|
|
|
|
cerr << " | | | + connections" << endl;
|
|
|
|
|
for (size_t j = 0 ; j < net->getConnections().size() ; j++) {
|
|
|
|
|
OpenChams::Net::Connection* connect = net->getConnections()[j];
|
|
|
|
|
cerr << " | | | | " << connect->getInstanceName().getString() << "." << connect->getConnectorName().getString() << endl;
|
|
|
|
|
}
|
2011-02-15 07:57:39 -06:00
|
|
|
|
if (!net->hasNoPorts() || !net->hasNoWires())
|
|
|
|
|
schematicNet = true;
|
2010-09-02 05:31:55 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
OpenChams::Schematic* schematic = circuit->getSchematic();
|
|
|
|
|
if (schematic && !schematic->hasNoInstances()) {
|
2011-02-15 07:57:39 -06:00
|
|
|
|
cerr << " + schematic" << endl;
|
2010-09-02 05:31:55 -05:00
|
|
|
|
for (map<OpenChams::Name, OpenChams::Schematic::Infos*>::const_iterator sit = schematic->getInstances().begin() ; sit != schematic->getInstances().end() ; ++sit) {
|
|
|
|
|
OpenChams::Schematic::Infos* inf = (*sit).second;
|
2011-03-10 04:42:30 -06:00
|
|
|
|
cerr << " | + instance: name: " << ((*sit).first).getString() << " - x: " << inf->getX() << " - y: " << inf->getY() << " - orientation: " << inf->getOrientation().getString() << endl;
|
2010-09-02 05:31:55 -05:00
|
|
|
|
}
|
2011-02-15 07:57:39 -06:00
|
|
|
|
if (schematicNet) {
|
|
|
|
|
for (size_t i = 0 ; i < netlist->getNets().size() ; i++) {
|
|
|
|
|
OpenChams::Net* net = netlist->getNets()[i];
|
|
|
|
|
cerr << " | + net name: " << net->getName().getString() << endl;
|
|
|
|
|
if (!net->hasNoPorts()) {
|
|
|
|
|
for (size_t j = 0 ; j < net->getPorts().size() ; j++) {
|
|
|
|
|
OpenChams::Port* port = net->getPorts()[j];
|
2011-03-10 04:42:30 -06:00
|
|
|
|
cerr << " | | + port type: " << port->getType().getString() << " - idx: " << port->getIndex() << " - x: " << port->getX() << " - y: " << port->getY() << " - orientation: " << port->getOrientation().getString() << endl;
|
2011-02-15 07:57:39 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!net->hasNoWires()) {
|
|
|
|
|
for (size_t j = 0 ; j < net->getWires().size() ; j++) {
|
|
|
|
|
OpenChams::Wire* wire = net->getWires()[j];
|
|
|
|
|
cerr << " | | + wire ";
|
|
|
|
|
OpenChams::WirePoint* start = wire->getStartPoint();
|
|
|
|
|
if (dynamic_cast<OpenChams::InstancePoint*>(start)) {
|
|
|
|
|
OpenChams::InstancePoint* iP = static_cast<OpenChams::InstancePoint*>(start);
|
|
|
|
|
cerr << "<" << iP->getName().getString() << "," << iP->getPlug().getString() << "> ";
|
|
|
|
|
} else if (dynamic_cast<OpenChams::PortPoint*>(start)) {
|
|
|
|
|
OpenChams::PortPoint* pP = static_cast<OpenChams::PortPoint*>(start);
|
|
|
|
|
cerr << "<" << pP->getIndex() << "> ";
|
|
|
|
|
}
|
|
|
|
|
for (size_t k = 0 ; k < wire->getIntermediatePoints().size() ; k++) {
|
|
|
|
|
OpenChams::IntermediatePoint* iP = wire->getIntermediatePoints()[k];
|
|
|
|
|
cerr << "<" << iP->getX() << "," << iP->getY() << "> ";
|
|
|
|
|
}
|
|
|
|
|
OpenChams::WirePoint* end = wire->getEndPoint();
|
|
|
|
|
if (dynamic_cast<OpenChams::InstancePoint*>(end)) {
|
|
|
|
|
OpenChams::InstancePoint* iP = static_cast<OpenChams::InstancePoint*>(end);
|
|
|
|
|
cerr << "<" << iP->getName().getString() << "," << iP->getPlug().getString() << "> ";
|
|
|
|
|
} else if (dynamic_cast<OpenChams::PortPoint*>(end)) {
|
|
|
|
|
OpenChams::PortPoint* pP = static_cast<OpenChams::PortPoint*>(end);
|
|
|
|
|
cerr << "<" << pP->getIndex() << "> ";
|
|
|
|
|
}
|
|
|
|
|
cerr << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-02 05:31:55 -05:00
|
|
|
|
}
|
|
|
|
|
OpenChams::Sizing* sizing = circuit->getSizing();
|
|
|
|
|
if (sizing) {
|
|
|
|
|
cerr << " + sizing" << endl;
|
|
|
|
|
if (!sizing->hasNoOperators()) {
|
|
|
|
|
for (map<OpenChams::Name, OpenChams::Operator*>::const_iterator oit = sizing->getOperators().begin() ; oit != sizing->getOperators().end() ; ++oit) {
|
|
|
|
|
OpenChams::Operator* op = (*oit).second;
|
2011-07-21 04:20:20 -05:00
|
|
|
|
cerr << " | + instance name: " << ((*oit).first).getString() << " - operator: " << op->getName().getString() << " - simulModel: " << op->getSimulModel().getString() << endl;
|
2010-09-02 05:31:55 -05:00
|
|
|
|
if (!op->hasNoConstraints()) {
|
|
|
|
|
for (map<OpenChams::Name, OpenChams::Operator::Constraint*>::const_iterator cit = op->getConstraints().begin() ; cit != op->getConstraints().end() ; ++cit) {
|
|
|
|
|
OpenChams::Operator::Constraint* cstr = (*cit).second;
|
|
|
|
|
cerr << " | | + param: " << ((*cit).first).getString() << " - ref: " << cstr->getRef().getString() << " - refParam: " << cstr->getRefParam().getString() << " - factor: " << cstr->getFactor() << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-22 09:37:22 -05:00
|
|
|
|
// To update to the new equations.
|
|
|
|
|
// if (!sizing->hasNoEquations()) {
|
|
|
|
|
// cerr << " | + equations" << endl;
|
|
|
|
|
// for (map<OpenChams::Name, string>::const_iterator eit = sizing->getEquations().begin() ; eit != sizing->getEquations().end() ; ++eit) {
|
|
|
|
|
// cerr << " | | " << ((*eit).first).getString() << " : " << (*eit).second << endl;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2010-09-02 05:31:55 -05:00
|
|
|
|
}
|
|
|
|
|
OpenChams::Layout* layout = circuit->getLayout();
|
2011-09-14 03:13:46 -05:00
|
|
|
|
if (layout) {
|
|
|
|
|
if (!layout->hasNoInstance()) {
|
|
|
|
|
cerr << " + layout" << endl;
|
|
|
|
|
for (map<OpenChams::Name, OpenChams::Name>::const_iterator lit = layout->getInstances().begin() ; lit != layout->getInstances().end() ; ++lit) {
|
|
|
|
|
cerr << " | | instance name: " << ((*lit).first).getString() << " - style: " << ((*lit).second).getString() << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
OpenChams::Node* root = layout->getHBTreeRoot();
|
|
|
|
|
if (root) {
|
|
|
|
|
cerr << " | + hbtree" << endl;
|
|
|
|
|
printHBTree(root, 2);
|
|
|
|
|
}
|
2010-09-02 05:31:55 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|