- Improvment of parsing examples with examples of maps and vectors.

- No more pprint method in Python, now __repr__method encapsuling new c++ method getString.
This commit is contained in:
Sophie Belloeil 2010-10-15 11:13:53 +00:00
parent 2bc62b400b
commit 81d4d455bd
17 changed files with 216 additions and 122 deletions

View File

@ -14,9 +14,21 @@ int main ( int argc, char * argv[] ) {
if ( library ) { if ( library ) {
// print of the library // print of the library
library->print(); library->print();
// print of one attribute in particular // print of one attribute in particular of a cell
cout << "| area of inv_x1= " << library->getCell(LIB::Name("inv_x1"))->getAttribute(LIB::Name("area"))->valueAsString() << endl; cout << "Area of inv_x1 : " << library->getCell(LIB::Name("inv_x1"))->getAttribute(LIB::Name("area"))->valueAsString() << endl;
cout << "| timing intrinsic_rise of nq of inv_x1= " << library->getCell(LIB::Name("inv_x1"))->getPin(LIB::Name("nq"))->getTiming(LIB::Name("i"))->getAttribute(LIB::Name("intrinsic_rise"))->valueAsString() << endl; cout << "Timing intrinsic_rise of nq of inv_x1 : " << library->getCell(LIB::Name("inv_x1"))->getPin(LIB::Name("nq"))->getTiming(LIB::Name("i"))->getAttribute(LIB::Name("intrinsic_rise"))->valueAsString() << endl;
// print of all the attributes of a cell
cout << "Attributes of no2_x1 :" << endl;
for(map<LIB::Name, LIB::Attribute*>::const_iterator it=library->getCell(LIB::Name("no2_x1"))->getAttributes().begin() ; it!=library->getCell(LIB::Name("no2_x1"))->getAttributes().end() ; ++it) {
cout << " name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString() << endl;
}
// print of all the timings of a pin
cout << "Timing's atributes of pin nq of no2_x1 :" << endl;
for (size_t i = 0 ; i < library->getCell(LIB::Name("no2_x1"))->getPin(LIB::Name("nq"))->getTimings().size() ; i++) {
library->getCell(LIB::Name("no2_x1"))->getPin(LIB::Name("nq"))->getTimings()[i]->print();
}
} else { } else {
cerr << "library is NULL" << endl; cerr << "library is NULL" << endl;
} }

View File

@ -4,10 +4,20 @@ library = Library.readFromFile("./testParse.lib")
if ( library ) : if ( library ) :
# print of the library # print of the library
library.pprint() print library
# print of one attribute in particular # print of one attribute in particular of a cell
print "| area of inv_x1= ", library.getCell("inv_x1").getAttribute("area").valueAsString() print "Area of inv_x1 :", library.getCell("inv_x1").getAttribute("area").valueAsString()
print "| timing intrinsic_rise of nq of inv_x1= ", library.getCell("inv_x1").getPin("nq").getTiming("i").getAttribute("intrinsic_rise").valueAsString() print "Timing intrinsic_rise of nq of inv_x1 :", library.getCell("inv_x1").getPin("nq").getTiming("i").getAttribute("intrinsic_rise").valueAsString()
# print of all the attributes of a cell
print "Attributes of no2_x1 :"
for attr in library.getCell("no2_x1").getAttributes() :
print " name=", attr.key, \
", type=", attr.value.typeToString(), \
", value=", attr.value.valueAsString()
# print of all the timings of a pin
print "Timing's attributes of pin nq of no2_x1 :"
for timing in library.getCell("no2_x1").getPin("nq").getTimings() :
print timing
else : else :
raise ( "library is NULL" ) raise ( "library is NULL" )

View File

@ -1,5 +1,6 @@
#include<iostream> #include<iostream>
#include<fstream> #include<fstream>
#include<sstream>
using namespace std; using namespace std;
#include "vlsisapd/liberty/Cell.h" #include "vlsisapd/liberty/Cell.h"
@ -60,13 +61,14 @@ void Cell::setTestCell(Cell *cell) {
_testCell = cell; _testCell = cell;
} }
void Cell::print() { const string Cell::getString() const{
cout << "| Cell name= " << _name.getString() << endl; ostringstream chaine;
chaine << "| Cell name= " << _name.getString() << endl;
// Cell's attributes // Cell's attributes
cout << "| Attributes :" << endl; chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) { for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString() chaine << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString() << ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString() << endl; << ", value= " << (*it).second->valueAsString() << endl;
} }
@ -75,11 +77,26 @@ void Cell::print() {
(*it).second->print(); (*it).second->print();
} }
// FF // FF
if(_ff) if(_ff) {
_ff->print(); chaine << "| FF noninverting= " << _ff->getNonInverting().getString() << ", inverting= " << _ff->getInverting().getString() << endl;
// FlipFlop's attributes
chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_ff->getAttributes().begin() ; it!=_ff->getAttributes().end() ; ++it) {
chaine << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString() << endl;
}
}
// test_cell // test_cell
if(_testCell) if(_testCell)
_testCell->print(); chaine << _testCell->getString();
return chaine.str();
}
void Cell::print() {
cout << Cell::getString();
} }
bool Cell::write(ofstream &file, bool test) { bool Cell::write(ofstream &file, bool test) {

View File

@ -1,5 +1,6 @@
#include<iostream> #include<iostream>
#include<fstream> #include<fstream>
#include<sstream>
using namespace std; using namespace std;
#include "vlsisapd/liberty/FlipFlop.h" #include "vlsisapd/liberty/FlipFlop.h"
@ -28,16 +29,22 @@ void FlipFlop::addAttribute(Name attrName, Attribute::Type attrType, const strin
_attributes[attrName] = attr; _attributes[attrName] = attr;
} }
void FlipFlop::print() { const string FlipFlop::getString() const{
cout << "| FF noninverting= " << _noninverting.getString() << ", inverting= " << _inverting.getString() << endl; ostringstream chaine;
chaine << "| FF noninverting= " << _noninverting.getString() << ", inverting= " << _inverting.getString() << endl;
// FlipFlop's attributes // FlipFlop's attributes
cout << "| Attributes :" << endl; chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) { for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString() chaine << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString() << ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString() << endl; << ", value= " << (*it).second->valueAsString() << endl;
} }
return chaine.str();
}
void FlipFlop::print() {
cout << FlipFlop::getString();
} }
bool FlipFlop::write(ofstream &file) { bool FlipFlop::write(ofstream &file) {

View File

@ -1,5 +1,6 @@
#include<iostream> #include<iostream>
#include<fstream> #include<fstream>
#include<sstream>
#include<ctime> #include<ctime>
using namespace std; using namespace std;
@ -84,48 +85,49 @@ void Library::addCell(Name cellName) {
_cells[cellName] = cell; _cells[cellName] = cell;
} }
void Library::print() { const string Library::getString() const{
cout << "+-----------------------------+" << endl ostringstream chaine;
chaine << "+-----------------------------+" << endl
<< "| Library : " << _name.getString() << endl; << "| Library : " << _name.getString() << endl;
// Library's attributes // Library's attributes
cout << "| Attributes :" << endl; chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) { for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name=" << (*it).first.getString() chaine << "| name=" << (*it).first.getString()
<< ", type=" << (*it).second->typeToString() << ", type=" << (*it).second->typeToString()
<< ", value=" << (*it).second->valueAsString(); << ", value=" << (*it).second->valueAsString();
string unit = (*it).second->getUnit(); string unit = (*it).second->getUnit();
if(!unit.empty()) if(!unit.empty())
cout << ", unit=" << unit; chaine << ", unit=" << unit;
cout << endl; chaine << endl;
} }
// WireLoad // WireLoad
for(map<Name, WireLoad*>::const_iterator it=_wires_load.begin() ; it!=_wires_load.end() ; ++it) { for(map<Name, WireLoad*>::const_iterator it=_wires_load.begin() ; it!=_wires_load.end() ; ++it) {
// (*it).second->print(); // (*it).second->print();
cout << "| Wireload : " << (*it).first.getString() << endl; chaine << "| Wireload : " << (*it).first.getString() << endl;
// Wireload's attributes // Wireload's attributes
cout << "| Attributes :" << endl; chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it2=(*it).second->getAttributes().begin() ; it2 != (*it).second->getAttributes().end() ; ++it2) { for(map<Name, Attribute*>::const_iterator it2=(*it).second->getAttributes().begin() ; it2 != (*it).second->getAttributes().end() ; ++it2) {
if ((*it2).second == NULL) { if ((*it2).second == NULL) {
cerr << "NULL attribute !" << endl; cerr << "NULL attribute !" << endl;
exit(12); exit(12);
} }
cout << "| name=" << (*it2).first.getString() chaine << "| name=" << (*it2).first.getString()
<< ", type=" << (*it2).second->typeToString() << ", type=" << (*it2).second->typeToString()
<< ", value=" << (*it2).second->valueAsString(); << ", value=" << (*it2).second->valueAsString();
string value2=(*it2).second->secondValueAsString(); string value2=(*it2).second->secondValueAsString();
if(!value2.empty()) if(!value2.empty())
cout << ", value2=" << value2; chaine << ", value2=" << value2;
cout << endl; chaine << endl;
} }
} }
// WireLoadSelection // WireLoadSelection
// _wire_load_selection->print(); // _wire_load_selection->print();
cout << "| WireLoadSection name= " << _wire_load_selection->getName().getString() << endl; chaine << "| WireLoadSection name= " << _wire_load_selection->getName().getString() << endl;
vector<WireLoadArea*> wires_load_area = _wire_load_selection->getWiresLoadArea(); vector<WireLoadArea*> wires_load_area = _wire_load_selection->getWiresLoadArea();
for(size_t i = 0 ; i < wires_load_area.size() ; i++) { for(size_t i = 0 ; i < wires_load_area.size() ; i++) {
cout << "| wire_load_from_area name= " << wires_load_area[i]->getName().getString() chaine << "| wire_load_from_area name= " << wires_load_area[i]->getName().getString()
<< ", min= " << wires_load_area[i]->getMin() << ", min= " << wires_load_area[i]->getMin()
<< ", max= " << wires_load_area[i]->getMax() << ", max= " << wires_load_area[i]->getMax()
<< endl; << endl;
@ -134,32 +136,32 @@ void Library::print() {
// Cell // Cell
for(map<Name, Cell*>::const_iterator it=_cells.begin() ; it!=_cells.end() ; ++it) { for(map<Name, Cell*>::const_iterator it=_cells.begin() ; it!=_cells.end() ; ++it) {
// (*it).second->print(); // (*it).second->print();
cout << "| Cell name= " << (*it).first.getString() << endl; chaine << "| Cell name= " << (*it).first.getString() << endl;
// Cell's attributes // Cell's attributes
cout << "| Attributes :" << endl; chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it2=(*it).second->getAttributes().begin() ; it2!=(*it).second->getAttributes().end() ; ++it2) { for(map<Name, Attribute*>::const_iterator it2=(*it).second->getAttributes().begin() ; it2!=(*it).second->getAttributes().end() ; ++it2) {
cout << "| name= " << (*it2).first.getString() chaine << "| name= " << (*it2).first.getString()
<< ", type= " << (*it2).second->typeToString() << ", type= " << (*it2).second->typeToString()
<< ", value= " << (*it2).second->valueAsString() << endl; << ", value= " << (*it2).second->valueAsString() << endl;
} }
// Cell's pins // Cell's pins
for(map<Name, Pin*>::const_iterator it2=(*it).second->getPins().begin() ; it2!=(*it).second->getPins().end() ; ++it2) { for(map<Name, Pin*>::const_iterator it2=(*it).second->getPins().begin() ; it2!=(*it).second->getPins().end() ; ++it2) {
// (*it2).second->print(); // (*it2).second->print();
cout << "| Pin name= " << (*it2).first.getString() << endl; chaine << "| Pin name= " << (*it2).first.getString() << endl;
// Pin's attributes // Pin's attributes
cout << "| Attributes :" << endl; chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it3=(*it2).second->getAttributes().begin() ; it3!=(*it2).second->getAttributes().end() ; ++it3) { for(map<Name, Attribute*>::const_iterator it3=(*it2).second->getAttributes().begin() ; it3!=(*it2).second->getAttributes().end() ; ++it3) {
cout << "| name= " << (*it3).first.getString() chaine << "| name= " << (*it3).first.getString()
<< ", type= " << (*it3).second->typeToString() << ", type= " << (*it3).second->typeToString()
<< ", value= " << (*it3).second->valueAsString() << endl; << ", value= " << (*it3).second->valueAsString() << endl;
} }
// Timing // Timing
for (size_t i = 0 ; i < (*it2).second->getTimings().size() ; i++) { for (size_t i = 0 ; i < (*it2).second->getTimings().size() ; i++) {
// Timing's attributes // Timing's attributes
cout << "| Timing's attributes :" << endl; chaine << "| Timing's attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it3=(*it2).second->getTimings()[i]->getAttributes().begin() ; it3!=(*it2).second->getTimings()[i]->getAttributes().end() ; ++it3) { for(map<Name, Attribute*>::const_iterator it3=(*it2).second->getTimings()[i]->getAttributes().begin() ; it3!=(*it2).second->getTimings()[i]->getAttributes().end() ; ++it3) {
cout << "| name= " << (*it3).first.getString() chaine << "| name= " << (*it3).first.getString()
<< ", type= " << (*it3).second->typeToString() << ", type= " << (*it3).second->typeToString()
<< ", value= " << (*it3).second->valueAsString() << endl; << ", value= " << (*it3).second->valueAsString() << endl;
} }
@ -169,10 +171,10 @@ void Library::print() {
// if(_ff) // if(_ff)
// _ff->print(); // _ff->print();
if((*it).second->getFF()) { if((*it).second->getFF()) {
cout << "| FF noninverting= " << (*it).second->getFF()->getNonInverting().getString() << ", inverting= " << (*it).second->getFF()->getInverting().getString() << endl; chaine << "| FF noninverting= " << (*it).second->getFF()->getNonInverting().getString() << ", inverting= " << (*it).second->getFF()->getInverting().getString() << endl;
cout << "| Attributes :" << endl; chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it2=(*it).second->getFF()->getAttributes().begin() ; it2!=(*it).second->getFF()->getAttributes().end() ; ++it2) { for(map<Name, Attribute*>::const_iterator it2=(*it).second->getFF()->getAttributes().begin() ; it2!=(*it).second->getFF()->getAttributes().end() ; ++it2) {
cout << "| name= " << (*it2).first.getString() chaine << "| name= " << (*it2).first.getString()
<< ", type= " << (*it2).second->typeToString() << ", type= " << (*it2).second->typeToString()
<< ", value= " << (*it2).second->valueAsString() << endl; << ", value= " << (*it2).second->valueAsString() << endl;
} }
@ -182,32 +184,32 @@ void Library::print() {
// _testCell->print(); // _testCell->print();
Cell* testCell = (*it).second->getTestCell(); Cell* testCell = (*it).second->getTestCell();
if(testCell) { if(testCell) {
cout << "| Test Cell" << endl; chaine << "| Test Cell" << endl;
// Cell's attributes // Cell's attributes
cout << "| Attributes :" << endl; chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it2=testCell->getAttributes().begin() ; it2!=testCell->getAttributes().end() ; ++it2) { for(map<Name, Attribute*>::const_iterator it2=testCell->getAttributes().begin() ; it2!=testCell->getAttributes().end() ; ++it2) {
cout << "| name= " << (*it2).first.getString() chaine << "| name= " << (*it2).first.getString()
<< ", type= " << (*it2).second->typeToString() << ", type= " << (*it2).second->typeToString()
<< ", value= " << (*it2).second->valueAsString() << endl; << ", value= " << (*it2).second->valueAsString() << endl;
} }
// Cell's pins // Cell's pins
for(map<Name, Pin*>::const_iterator it2=(*it).second->getPins().begin() ; it2!=(*it).second->getPins().end() ; ++it2) { for(map<Name, Pin*>::const_iterator it2=(*it).second->getPins().begin() ; it2!=(*it).second->getPins().end() ; ++it2) {
// (*it2).second->print(); // (*it2).second->print();
cout << "| Pin name= " << (*it2).first.getString() << endl; chaine << "| Pin name= " << (*it2).first.getString() << endl;
// Pin's attributes // Pin's attributes
cout << "| Attributes :" << endl; chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it3=(*it2).second->getAttributes().begin() ; it3!=(*it2).second->getAttributes().end() ; ++it3) { for(map<Name, Attribute*>::const_iterator it3=(*it2).second->getAttributes().begin() ; it3!=(*it2).second->getAttributes().end() ; ++it3) {
cout << "| name= " << (*it3).first.getString() chaine << "| name= " << (*it3).first.getString()
<< ", type= " << (*it3).second->typeToString() << ", type= " << (*it3).second->typeToString()
<< ", value= " << (*it3).second->valueAsString() << endl; << ", value= " << (*it3).second->valueAsString() << endl;
} }
// Timing // Timing
for (size_t i = 0 ; i < (*it2).second->getTimings().size() ; i++) { for (size_t i = 0 ; i < (*it2).second->getTimings().size() ; i++) {
// Timing's attributes // Timing's attributes
cout << "| Timing's attributes :" << endl; chaine << "| Timing's attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it3=(*it2).second->getTimings()[i]->getAttributes().begin() ; it3!=(*it2).second->getTimings()[i]->getAttributes().end() ; ++it3) { for(map<Name, Attribute*>::const_iterator it3=(*it2).second->getTimings()[i]->getAttributes().begin() ; it3!=(*it2).second->getTimings()[i]->getAttributes().end() ; ++it3) {
cout << "| name= " << (*it3).first.getString() chaine << "| name= " << (*it3).first.getString()
<< ", type= " << (*it3).second->typeToString() << ", type= " << (*it3).second->typeToString()
<< ", value= " << (*it3).second->valueAsString() << endl; << ", value= " << (*it3).second->valueAsString() << endl;
} }
@ -217,18 +219,23 @@ void Library::print() {
// if(_ff) // if(_ff)
// _ff->print(); // _ff->print();
if((*it).second->getFF()) { if((*it).second->getFF()) {
cout << "| FF noninverting= " << (*it).second->getFF()->getNonInverting().getString() << ", inverting= " << (*it).second->getFF()->getInverting().getString() << endl; chaine << "| FF noninverting= " << (*it).second->getFF()->getNonInverting().getString() << ", inverting= " << (*it).second->getFF()->getInverting().getString() << endl;
cout << "| Attributes :" << endl; chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it2=(*it).second->getFF()->getAttributes().begin() ; it2!=(*it).second->getFF()->getAttributes().end() ; ++it2) { for(map<Name, Attribute*>::const_iterator it2=(*it).second->getFF()->getAttributes().begin() ; it2!=(*it).second->getFF()->getAttributes().end() ; ++it2) {
cout << "| name= " << (*it2).first.getString() chaine << "| name= " << (*it2).first.getString()
<< ", type= " << (*it2).second->typeToString() << ", type= " << (*it2).second->typeToString()
<< ", value= " << (*it2).second->valueAsString() << endl; << ", value= " << (*it2).second->valueAsString() << endl;
} }
} }
} }
} }
cout << "+-----------------------------+" << endl; chaine << "+-----------------------------+" << endl;
}; return chaine.str();
}
void Library::print() {
cout << Library::getString();
}
bool Library::writeToFile(string filename) { bool Library::writeToFile(string filename) {
time_t curtime = time(0); time_t curtime = time(0);

View File

@ -1,5 +1,6 @@
#include<iostream> #include<iostream>
#include<fstream> #include<fstream>
#include<sstream>
using namespace std; using namespace std;
#include "vlsisapd/liberty/Timing.h" #include "vlsisapd/liberty/Timing.h"
@ -44,20 +45,31 @@ void Pin::addTiming() {
_timings.push_back(timing); _timings.push_back(timing);
} }
void Pin::print() { const string Pin::getString() const{
cout << "| Pin name= " << _name.getString() << endl; ostringstream chaine;
chaine << "| Pin name= " << _name.getString() << endl;
// Pin's attributes // Pin's attributes
cout << "| Attributes :" << endl; chaine << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) { for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString() chaine << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString() << ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString() << endl; << ", value= " << (*it).second->valueAsString() << endl;
} }
// Timing // Timing
for (size_t i = 0 ; i < _timings.size() ; i++) { for (size_t i = 0 ; i < _timings.size() ; i++) {
_timings[i]->print(); chaine << "| Timing's attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_timings[i]->getAttributes().begin() ; it!=_timings[i]->getAttributes().end() ; ++it) {
chaine << "| name= " + (*it).first.getString()
<< ", type= " + (*it).second->typeToString()
<< ", value= " + (*it).second->valueAsString() << endl;
} }
}
return chaine.str();
}
void Pin::print() {
cout << Pin::getString();
} }
bool Pin::write(ofstream &file) { bool Pin::write(ofstream &file) {

View File

@ -88,7 +88,7 @@ BOOST_PYTHON_MODULE(LIBERTY) {
// class Liberty::WireLoad // class Liberty::WireLoad
////////////////////////// //////////////////////////
class_<WireLoad>("WireLoad", init<Name>()) class_<WireLoad, WireLoad*>("WireLoad", init<Name>())
// properties // properties
.add_property("name", &WireLoad::getName) // no setter => readonly .add_property("name", &WireLoad::getName) // no setter => readonly
// accessors // accessors
@ -97,13 +97,13 @@ BOOST_PYTHON_MODULE(LIBERTY) {
// modifiers // modifiers
.def("addAttribute", &WireLoad::addAttribute, addAttribute_overloads()) .def("addAttribute", &WireLoad::addAttribute, addAttribute_overloads())
// miscellaneous // miscellaneous
.def("pprint", &WireLoad::print) .def("__repr__", &WireLoad::getString)
.def("write", &WireLoad::write) .def("write", &WireLoad::write)
; ;
// class Liberty::WireLoadArea // class Liberty::WireLoadArea
////////////////////////////// //////////////////////////////
class_<WireLoadArea>("WireLoadArea", init<double, double, Name>()) class_<WireLoadArea, WireLoadArea*>("WireLoadArea", init<double, double, Name>())
// properties // properties
.add_property("min", &WireLoadArea::getMin) // no setter => readonly .add_property("min", &WireLoadArea::getMin) // no setter => readonly
.add_property("max", &WireLoadArea::getMax) // no setter => readonly .add_property("max", &WireLoadArea::getMax) // no setter => readonly
@ -114,7 +114,7 @@ BOOST_PYTHON_MODULE(LIBERTY) {
// class Liberty::WireLoadSelection // class Liberty::WireLoadSelection
/////////////////////////////////// ///////////////////////////////////
class_<WireLoadSelection>("WireLoadSelection", init<Name>()) class_<WireLoadSelection, WireLoadSelection*>("WireLoadSelection", init<Name>())
// properties // properties
.add_property("name", &WireLoadSelection::getName) // no setter => readonly .add_property("name", &WireLoadSelection::getName) // no setter => readonly
// accessors // accessors
@ -122,13 +122,13 @@ BOOST_PYTHON_MODULE(LIBERTY) {
// modifiers // modifiers
.def("addWireLoadArea", &WireLoadSelection::addWireLoadArea) .def("addWireLoadArea", &WireLoadSelection::addWireLoadArea)
// miscellaneous // miscellaneous
.def("pprint", &WireLoadSelection::print) .def("__repr__", &WireLoadSelection::getString)
.def("write", &WireLoadSelection::write) .def("write", &WireLoadSelection::write)
; ;
// class Liberty::Cell // class Liberty::Cell
////////////////////// //////////////////////
class_<Cell>("Cell", init<Name>()) class_<Cell, Cell*>("Cell", init<Name>())
// properties // properties
.add_property("name", &Cell::getName) // no setter => readonly .add_property("name", &Cell::getName) // no setter => readonly
// accessors // accessors
@ -144,13 +144,13 @@ BOOST_PYTHON_MODULE(LIBERTY) {
.def("addFF", &Cell::addFF) .def("addFF", &Cell::addFF)
.def("setTestCell", &Cell::setTestCell) .def("setTestCell", &Cell::setTestCell)
// miscellaneous // miscellaneous
.def("pprint", &Cell::print) .def("__repr__", &Cell::getString)
.def("write", &Cell::write) .def("write", &Cell::write)
; ;
// class Liberty::Pin // class Liberty::Pin
///////////////////// /////////////////////
class_<Pin>("Pin", init<Name>()) class_<Pin, Pin*>("Pin", init<Name>())
// properties // properties
.add_property("name", &Pin::getName) // no setter => readonly .add_property("name", &Pin::getName) // no setter => readonly
// accessors // accessors
@ -162,26 +162,26 @@ BOOST_PYTHON_MODULE(LIBERTY) {
.def("addAttribute", &Pin::addAttribute) .def("addAttribute", &Pin::addAttribute)
.def("addTiming", &Pin::addTiming) .def("addTiming", &Pin::addTiming)
// miscellaneous // miscellaneous
.def("pprint", &Pin::print) .def("__repr__", &Pin::getString)
.def("write", &Pin::write) .def("write", &Pin::write)
; ;
// class Liberty::Timing // class Liberty::Timing
//////////////////////// ////////////////////////
class_<Timing>("Timing", init<>()) class_<Timing, Timing*>("Timing", init<>())
// accessors // accessors
.def("getAttributes", &Timing::getAttributes, return_internal_reference<>()) .def("getAttributes", &Timing::getAttributes, return_internal_reference<>())
.def("getAttribute", &Timing::getAttribute, return_value_policy<reference_existing_object>()) .def("getAttribute", &Timing::getAttribute, return_value_policy<reference_existing_object>())
// modifiers // modifiers
.def("addAttribute", &Timing::addAttribute) .def("addAttribute", &Timing::addAttribute)
// miscellaneous // miscellaneous
.def("pprint", &Timing::print) .def("__repr__", &Timing::getString)
.def("write", &Timing::write) .def("write", &Timing::write)
; ;
// class Liberty::FlipFlop // class Liberty::FlipFlop
////////////////////////// //////////////////////////
class_<FlipFlop>("FlipFlop", init<Name, Name>()) class_<FlipFlop, FlipFlop*>("FlipFlop", init<Name, Name>())
// properties // properties
.add_property("noninverting", &FlipFlop::getNonInverting) // no setter => readonly .add_property("noninverting", &FlipFlop::getNonInverting) // no setter => readonly
.add_property("inverting", &FlipFlop::getInverting) // no setter => readonly .add_property("inverting", &FlipFlop::getInverting) // no setter => readonly
@ -191,13 +191,13 @@ BOOST_PYTHON_MODULE(LIBERTY) {
// modifiers // modifiers
.def("addAttribute", &FlipFlop::addAttribute) .def("addAttribute", &FlipFlop::addAttribute)
// miscellaneous // miscellaneous
.def("pprint", &FlipFlop::print) .def("__repr__", &FlipFlop::getString)
.def("write", &FlipFlop::write) .def("write", &FlipFlop::write)
; ;
// class Liberty::Library // class Liberty::Library
///////////////////////// /////////////////////////
class_<Library>("Library", init<Name>()) class_<Library, Library*>("Library", init<Name>())
// properties // properties
.add_property("name", &Library::getName) // no setter => readonly .add_property("name", &Library::getName) // no setter => readonly
// accessors // accessors
@ -214,7 +214,7 @@ BOOST_PYTHON_MODULE(LIBERTY) {
.def("addWireLoadSelection", &Library::addWireLoadSelection) .def("addWireLoadSelection", &Library::addWireLoadSelection)
.def("addCell", &Library::addCell) .def("addCell", &Library::addCell)
// miscellaneous // miscellaneous
.def("pprint", &Library::print ) // "print" does not work in Python .def("__repr__", &Library::getString)
.def("readFromFile", &Library::readFromFile, return_value_policy<reference_existing_object>()) .def("readFromFile", &Library::readFromFile, return_value_policy<reference_existing_object>())
.staticmethod("readFromFile") .staticmethod("readFromFile")
.def("writeToFile", &Library::writeToFile) .def("writeToFile", &Library::writeToFile)

View File

@ -1,5 +1,6 @@
#include<iostream> #include<iostream>
#include<fstream> #include<fstream>
#include<sstream>
using namespace std; using namespace std;
#include "vlsisapd/liberty/Timing.h" #include "vlsisapd/liberty/Timing.h"
@ -28,14 +29,20 @@ void Timing::addAttribute(Name attrName, Attribute::Type attrType, const string&
_attributes[attrName] = attr; _attributes[attrName] = attr;
} }
void Timing::print() { const string Timing::getString() const{
// Timing's attributes // Timing's attributes
cout << "| Timing's attributes :" << endl; ostringstream chaine;
chaine << "| Timing's attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) { for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString() chaine << "| name= " + (*it).first.getString()
<< ", type= " << (*it).second->typeToString() << ", type= " + (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString() << endl; << ", value= " + (*it).second->valueAsString() << endl;
} }
return chaine.str();
}
void Timing::print() {
cout << Timing::getString();
} }
bool Timing::write(ofstream &file) { bool Timing::write(ofstream &file) {

View File

@ -1,5 +1,6 @@
#include<iostream> #include<iostream>
#include<fstream> #include<fstream>
#include<sstream>
using namespace std; using namespace std;
#include "vlsisapd/liberty/WireLoad.h" #include "vlsisapd/liberty/WireLoad.h"
@ -28,19 +29,25 @@ void WireLoad::addAttribute(Name attrName, Attribute::Type attrType, const strin
_attributes[attrName] = attr; _attributes[attrName] = attr;
} }
void WireLoad::print() { const string WireLoad::getString() const{
ostringstream chaine;
// WireLoad's attributes // WireLoad's attributes
cout << "| Wireload : " << _name.getString() << endl; chaine << "| Wireload : " << _name.getString() << endl
cout << "| Attributes :" << endl; << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) { for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString() chaine << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString() << ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString(); << ", value= " << (*it).second->valueAsString();
string value2=(*it).second->secondValueAsString(); string value2=(*it).second->secondValueAsString();
if(!value2.empty()) if(!value2.empty())
cout << ", value2= " << value2; chaine << ", value2= " << value2;
cout << endl; chaine << endl;
} }
return chaine.str();
}
void WireLoad::print() {
cout << WireLoad::getString();
} }
bool WireLoad::write(ofstream &file) { bool WireLoad::write(ofstream &file) {

View File

@ -1,5 +1,6 @@
#include<iostream> #include<iostream>
#include<fstream> #include<fstream>
#include<sstream>
using namespace std; using namespace std;
#include "vlsisapd/liberty/WireLoadArea.h" #include "vlsisapd/liberty/WireLoadArea.h"
@ -13,14 +14,20 @@ void WireLoadSelection::addWireLoadArea(double min, double max, Name name) {
_wires_load_area.push_back(area); _wires_load_area.push_back(area);
} }
void WireLoadSelection::print() { const string WireLoadSelection::getString() const{
cout << "| WireLoadSection name= " << _name.getString() << endl; ostringstream chaine;
chaine << "| WireLoadSection name= " << _name.getString() << endl;
for(size_t i = 0 ; i < _wires_load_area.size() ; i++) { for(size_t i = 0 ; i < _wires_load_area.size() ; i++) {
cout << "| wire_load_from_area name= " << _wires_load_area[i]->getName().getString() chaine << "| wire_load_from_area name= " << _wires_load_area[i]->getName().getString()
<< ", min= " << _wires_load_area[i]->getMin() << ", min= " << _wires_load_area[i]->getMin()
<< ", max= " << _wires_load_area[i]->getMax() << ", max= " << _wires_load_area[i]->getMax()
<< endl; << endl;
} }
return chaine.str();
}
void WireLoadSelection::print() {
cout << WireLoadSelection::getString();
} }
bool WireLoadSelection::write(ofstream& file) { bool WireLoadSelection::write(ofstream& file) {

View File

@ -26,6 +26,7 @@ class Cell {
void addFF(Name noninverting, Name inverting); void addFF(Name noninverting, Name inverting);
void setTestCell(Cell *cell); void setTestCell(Cell *cell);
const std::string getString()const;
void print(); void print();
bool write(std::ofstream &file, bool test=false); bool write(std::ofstream &file, bool test=false);

View File

@ -18,6 +18,7 @@ class FlipFlop {
void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue); void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue);
const std::string getString()const;
void print(); void print();
bool write(std::ofstream &file); bool write(std::ofstream &file);

View File

@ -26,6 +26,7 @@ class Library {
void addWireLoadSelection(Name wireLoadSelectionName); void addWireLoadSelection(Name wireLoadSelectionName);
void addCell(Name cellName); void addCell(Name cellName);
const std::string getString()const;
void print(); void print();
static Library* readFromFile(std::string); static Library* readFromFile(std::string);

View File

@ -22,6 +22,7 @@ class Pin {
void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue); void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue);
void addTiming(); void addTiming();
const std::string getString()const;
void print(); void print();
bool write(std::ofstream &file); bool write(std::ofstream &file);

View File

@ -16,6 +16,7 @@ class Timing {
void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue); void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue);
const std::string getString() const;
void print(); void print();
bool write(std::ofstream &file); bool write(std::ofstream &file);

View File

@ -15,6 +15,7 @@ class WireLoad {
void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue, const std::string& attrValue2 = ""); void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue, const std::string& attrValue2 = "");
const std::string getString()const;
void print(); void print();
bool write(std::ofstream &file); bool write(std::ofstream &file);

View File

@ -17,6 +17,8 @@ class WireLoadSelection {
inline std::vector<WireLoadArea*>& getWiresLoadArea(); inline std::vector<WireLoadArea*>& getWiresLoadArea();
void addWireLoadArea(double min, double max, Name name); void addWireLoadArea(double min, double max, Name name);
const std::string getString()const;
void print(); void print();
bool write(std::ofstream& file); bool write(std::ofstream& file);