Python wrapper. (without example it seems ?)

This commit is contained in:
Sophie Belloeil 2010-10-14 11:01:16 +00:00
parent ec979ff2b8
commit 40a6d2e0da
22 changed files with 261 additions and 174 deletions

View File

@ -1,4 +1,4 @@
ADD_SUBDIRECTORY(cplusplus)
#ADD_SUBDIRECTORY(python)
ADD_SUBDIRECTORY(python)
INSTALL ( FILES testParse.lib DESTINATION share/doc/coriolis2/examples/vlsisapd/liberty )

View File

@ -35,7 +35,7 @@ int main ( int argc, char * argv[] ) {
// Cells
library->addCell(LIB::Name("inv"));
LIB::Cell* cell = library->getCell(LIB::Name("inv"));
valeur="1"; cell->addAttribute(LIB::Name("area"), LIB::Attribute::Double, valeur);
valeur="1"; cell->addAttribute(LIB::Name("area"), LIB::Attribute::Double, valeur);
valeur="inv"; cell->addAttribute(LIB::Name("cell_footprint"), LIB::Attribute::String, valeur);
LIB::Pin* pin;
@ -44,21 +44,20 @@ int main ( int argc, char * argv[] ) {
cell->addPin(LIB::Name("e"));
pin = cell->getPin(LIB::Name("e"));
valeur="0.008"; pin->addAttribute(LIB::Name("capacitance"), LIB::Attribute::Double, valeur);
valeur="input"; pin->addAttribute(LIB::Name("direction"), LIB::Attribute::String, valeur);
valeur="input"; pin->addAttribute(LIB::Name("direction"), LIB::Attribute::String, valeur);
cell->addPin(LIB::Name("s"));
pin = cell->getPin(LIB::Name("s"));
valeur="i'"; pin->addAttribute(LIB::Name("function"), LIB::Attribute::String, valeur);
valeur="i'"; pin->addAttribute(LIB::Name("function"), LIB::Attribute::String, valeur);
valeur="output"; pin->addAttribute(LIB::Name("direction"), LIB::Attribute::String, valeur);
// Timing
LIB::Timing * timing;
pin->addTiming();
timing = pin->getTimings().back();
valeur="negative_unate"; timing->addAttribute(LIB::Name("timing_sense"), LIB::Attribute::String, valeur);
valeur="e"; timing->addAttribute(LIB::Name("related_pin"), LIB::Attribute::String, valeur);
valeur="0.101"; timing->addAttribute(LIB::Name("intrinsic_rise"), LIB::Attribute::Double, valeur);
valeur="negative_unate"; timing->addAttribute(LIB::Name("timing_sense"), LIB::Attribute::String, valeur);
valeur="e"; timing->addAttribute(LIB::Name("related_pin"), LIB::Attribute::String, valeur);
valeur="0.101"; timing->addAttribute(LIB::Name("intrinsic_rise"), LIB::Attribute::Double, valeur);
// Write
valeur="testDrive.lib"; library->writeToFile(valeur);

View File

@ -4,6 +4,9 @@ using namespace std;
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Library.h"
#include "vlsisapd/liberty/Cell.h"
#include "vlsisapd/liberty/Pin.h"
#include "vlsisapd/liberty/Timing.h"
int main ( int argc, char * argv[] ) {
LIB::Library* library = LIB::Library::readFromFile("./testParse.lib");

View File

@ -1,63 +1,73 @@
include_directories ( ${VLSISAPD_SOURCE_DIR}/src/liberty/src
${PYTHON_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
)
include_directories ( ${VLSISAPD_SOURCE_DIR}/src/liberty/src
${PYTHON_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
)
set ( includes vlsisapd/liberty/Attribute.h
vlsisapd/liberty/Cell.h
vlsisapd/liberty/FlipFlop.h
vlsisapd/liberty/Library.h
vlsisapd/liberty/Name.h
vlsisapd/liberty/Pin.h
vlsisapd/liberty/Timing.h
vlsisapd/liberty/WireLoad.h
vlsisapd/liberty/WireLoadArea.h
vlsisapd/liberty/WireLoadSelection.h
)
set ( cpps Attribute.cpp
Cell.cpp
FlipFlop.cpp
Library.cpp
Name.cpp
Pin.cpp
Timing.cpp
WireLoad.cpp
WireLoadArea.cpp
WireLoadSelection.cpp
)
set ( LibertyParserScanner ${VLSISAPD_SOURCE_DIR}/src/liberty/src/LibertyParserScanner.ll )
set ( LibertyParserGrammar ${VLSISAPD_SOURCE_DIR}/src/liberty/src/LibertyParserGrammar.yy )
set ( LibertyParserScannerCpp LibertyParserScanner.cpp )
set ( LibertyParserGrammarCpp LibertyParserGrammar.cpp )
add_custom_target ( LibertyParser echo "Creating Liberty parser" )
add_custom_command ( SOURCE ${LibertyParserScanner}
COMMAND ${FLEX_EXECUTABLE}
ARGS -PLiberty_ -o${LibertyParserScannerCpp} ${LibertyParserScanner}
TARGET LibertyParser
OUTPUTS ${LibertyParserScannerCpp}
)
add_custom_command ( SOURCE ${LibertyParserGrammar}
COMMAND ${BISON_EXECUTABLE}
ARGS -d -v -p Liberty_ -y ${LibertyParserGrammar} -o ${LibertyParserGrammarCpp}
TARGET LibertyParser
DEPENDS ${LibertyParserScannerCpp}
OUTPUTS ${LibertyParserGrammarCpp}
)
set ( liberty_parser_cpps ${LibertyParserScannerCpp}
${LibertyParserGrammarCpp}
)
set_source_files_properties ( ${LibertyParserScannerCpp} GENERATED )
set_source_files_properties ( ${LibertyParserGrammarCpp} GENERATED )
set ( includes vlsisapd/liberty/Attribute.h
vlsisapd/liberty/Cell.h
vlsisapd/liberty/FlipFlop.h
vlsisapd/liberty/Library.h
vlsisapd/liberty/Name.h
vlsisapd/liberty/Pin.h
vlsisapd/liberty/Timing.h
vlsisapd/liberty/WireLoad.h
vlsisapd/liberty/WireLoadArea.h
vlsisapd/liberty/WireLoadSelection.h
)
set ( cpps Attribute.cpp
Cell.cpp
FlipFlop.cpp
Library.cpp
Name.cpp
Pin.cpp
Timing.cpp
WireLoad.cpp
WireLoadArea.cpp
WireLoadSelection.cpp
)
set ( pycpps PyLiberty.cpp
)
set ( LibertyParserScanner ${VLSISAPD_SOURCE_DIR}/src/liberty/src/LibertyParserScanner.ll )
set ( LibertyParserGrammar ${VLSISAPD_SOURCE_DIR}/src/liberty/src/LibertyParserGrammar.yy )
set ( LibertyParserScannerCpp LibertyParserScanner.cpp )
set ( LibertyParserGrammarCpp LibertyParserGrammar.cpp )
add_library ( liberty ${cpps}
${liberty_parser_cpps}
)
target_link_libraries ( liberty ${HURRICANE_PYTHON_LIBRARIES}
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
)
add_custom_target ( LibertyParser echo "Creating Liberty parser" )
add_custom_command ( SOURCE ${LibertyParserScanner}
COMMAND ${FLEX_EXECUTABLE}
ARGS -PLiberty_ -o${LibertyParserScannerCpp} ${LibertyParserScanner}
TARGET LibertyParser
OUTPUTS ${LibertyParserScannerCpp}
)
add_custom_command ( SOURCE ${LibertyParserGrammar}
COMMAND ${BISON_EXECUTABLE}
ARGS -d -v -p Liberty_ -y ${LibertyParserGrammar} -o ${LibertyParserGrammarCpp}
TARGET LibertyParser
DEPENDS ${LibertyParserScannerCpp}
OUTPUTS ${LibertyParserGrammarCpp}
)
set ( liberty_parser_cpps ${LibertyParserScannerCpp}
${LibertyParserGrammarCpp}
)
set_source_files_properties ( ${LibertyParserScannerCpp} GENERATED )
set_source_files_properties ( ${LibertyParserGrammarCpp} GENERATED )
install ( TARGETS liberty DESTINATION lib${LIB_SUFFIX} )
install ( FILES ${includes} DESTINATION include/vlsisapd/liberty )
add_library ( liberty ${cpps}
${liberty_parser_cpps}
)
target_link_libraries ( liberty ${Boost_LIBRARIES}
)
install ( TARGETS liberty DESTINATION lib${LIB_SUFFIX} )
install ( FILES ${includes} DESTINATION include/vlsisapd/liberty )
if ( Boost_FOUND )
add_library ( pyLIBERTY MODULE ${pycpps} )
set_target_properties ( pyLIBERTY PROPERTIES
OUTPUT_NAME "LIBERTY"
PREFIX ""
)
target_link_libraries ( pyLIBERTY liberty ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} )
install ( TARGETS pyLIBERTY DESTINATION ${PYTHON_SITE_PACKAGES} )
endif ( Boost_FOUND )

View File

@ -2,8 +2,6 @@
#include<fstream>
using namespace std;
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
#include "vlsisapd/liberty/Cell.h"
#include "vlsisapd/liberty/Pin.h"
#include "vlsisapd/liberty/FlipFlop.h"
@ -33,7 +31,7 @@ Pin* Cell::getPin(Name pinName) {
return pin;
}
void Cell::addAttribute(Name attrName, Attribute::Type attrType, string& attrValue) {
void Cell::addAttribute(Name attrName, Attribute::Type attrType, const string& attrValue) {
Attribute* attr = new Attribute(attrName, attrType, attrValue);
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it != _attributes.end()) {

View File

@ -2,8 +2,6 @@
#include<fstream>
using namespace std;
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
#include "vlsisapd/liberty/FlipFlop.h"
namespace LIB {
@ -20,7 +18,7 @@ Attribute* FlipFlop::getAttribute(Name attrName) {
return attr;
}
void FlipFlop::addAttribute(Name attrName, Attribute::Type attrType, string& attrValue) {
void FlipFlop::addAttribute(Name attrName, Attribute::Type attrType, const string& attrValue) {
Attribute* attr = new Attribute(attrName, attrType, attrValue);
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it != _attributes.end()) {

View File

@ -6,10 +6,13 @@ using namespace std;
#include<vector>
#include<boost/regex.hpp>
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Library.h"
#include "vlsisapd/liberty/Attribute.h"
#include "vlsisapd/liberty/WireLoad.h"
#include "vlsisapd/liberty/WireLoadSelection.h"
#include "vlsisapd/liberty/Cell.h"
#include "vlsisapd/liberty/Pin.h"
#include "vlsisapd/liberty/Timing.h"
#include "vlsisapd/liberty/FlipFlop.h"
#include "vlsisapd/liberty/Library.h"
using namespace LIB;
int Liberty_error ( const char* message );

View File

@ -3,21 +3,35 @@
#include<ctime>
using namespace std;
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
#include "vlsisapd/liberty/WireLoad.h"
#include "vlsisapd/liberty/WireLoadSelection.h"
#include "vlsisapd/liberty/WireLoadArea.h"
#include "vlsisapd/liberty/Cell.h"
#include "vlsisapd/liberty/Pin.h"
#include "vlsisapd/liberty/Timing.h"
#include "vlsisapd/liberty/FlipFlop.h"
#include "vlsisapd/liberty/Library.h"
namespace LIB {
Library::Library(Name name): _name(name), _attributes(), _wires_load(), _wire_load_selection(NULL), _cells() {};
Attribute* Library::getAttribute(Name attrName) {
Attribute* attr = NULL;
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it == _attributes.end()) {
cerr << "[ERROR] Library " << _name.getString() << " has no attribute named " << attrName.getString() << endl;
exit(1);
}
attr= (*it).second;
return attr;
}
Cell* Library::getCell(Name cellName) {
Cell* cell = NULL;
map<Name, Cell*>::iterator it = _cells.find(cellName);
if (it == _cells.end()) {
cerr << "[ERROR] No cell named " << cellName.getString() << endl;
cerr << "[ERROR] Library : No cell named " << cellName.getString() << endl;
exit(1);
}
cell= (*it).second;
@ -35,7 +49,7 @@ WireLoad* Library::getWireLoad(Name wireLoadName) {
return wire;
}
void Library::addAttribute(Name attrName, Attribute::Type attrType, string& attrValue, const string& attrUnit) {
void Library::addAttribute(Name attrName, Attribute::Type attrType, const string& attrValue, const string& attrUnit) {
Attribute* attr = new Attribute(attrName, attrType, attrValue, attrUnit);
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it != _attributes.end()) {
@ -73,7 +87,6 @@ void Library::addCell(Name cellName) {
void Library::print() {
cout << "+-----------------------------+" << endl
<< "| Library : " << _name.getString() << endl;
// Library's attributes
cout << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
@ -86,19 +99,13 @@ void Library::print() {
cout << endl;
}
map<Name, Attribute*> attributes;
map<Name, Pin*> pins;
vector<Timing*> timings;
FlipFlop* ff;
// WireLoad
for(map<Name, WireLoad*>::const_iterator it=_wires_load.begin() ; it!=_wires_load.end() ; ++it) {
// (*it).second->print();
cout << "| Wireload : " << (*it).first.getString() << endl;
// Wireload's attributes
cout << "| Attributes :" << endl;
attributes = (*it).second->getAttributes();
for(map<Name, Attribute*>::const_iterator it2=attributes.begin() ; it2 != attributes.end() ; ++it2) {
for(map<Name, Attribute*>::const_iterator it2=(*it).second->getAttributes().begin() ; it2 != (*it).second->getAttributes().end() ; ++it2) {
if ((*it2).second == NULL) {
cerr << "NULL attribute !" << endl;
exit(12);
@ -131,32 +138,27 @@ void Library::print() {
// Cell's attributes
cout << "| Attributes :" << endl;
attributes=(*it).second->getAttributes();
for(map<Name, Attribute*>::const_iterator it2=attributes.begin() ; it2!=attributes.end() ; ++it2) {
for(map<Name, Attribute*>::const_iterator it2=(*it).second->getAttributes().begin() ; it2!=(*it).second->getAttributes().end() ; ++it2) {
cout << "| name= " << (*it2).first.getString()
<< ", type= " << (*it2).second->typeToString()
<< ", value= " << (*it2).second->valueAsString() << endl;
}
// Cell's pins
pins=(*it).second->getPins();
for(map<Name, Pin*>::const_iterator it2=pins.begin() ; it2!=pins.end() ; ++it2) {
for(map<Name, Pin*>::const_iterator it2=(*it).second->getPins().begin() ; it2!=(*it).second->getPins().end() ; ++it2) {
// (*it2).second->print();
cout << "| Pin name= " << (*it2).first.getString() << endl;
// Pin's attributes
cout << "| Attributes :" << endl;
attributes=(*it2).second->getAttributes();
for(map<Name, Attribute*>::const_iterator it3=attributes.begin() ; it3!=attributes.end() ; ++it3) {
for(map<Name, Attribute*>::const_iterator it3=(*it2).second->getAttributes().begin() ; it3!=(*it2).second->getAttributes().end() ; ++it3) {
cout << "| name= " << (*it3).first.getString()
<< ", type= " << (*it3).second->typeToString()
<< ", value= " << (*it3).second->valueAsString() << endl;
}
// Timing
timings=(*it2).second->getTimings();
for (size_t i = 0 ; i < timings.size() ; i++) {
attributes=timings[i]->getAttributes();
for (size_t i = 0 ; i < (*it2).second->getTimings().size() ; i++) {
// Timing's attributes
cout << "| Timing's attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it3=attributes.begin() ; it3!=attributes.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()
<< ", type= " << (*it3).second->typeToString()
<< ", value= " << (*it3).second->valueAsString() << endl;
@ -166,15 +168,13 @@ void Library::print() {
// FF
// if(_ff)
// _ff->print();
ff = (*it).second->getFF();
if(ff) {
cout << "| FF noninverting= " << ff->getNonInverting().getString() << ", inverting= " << ff->getInverting().getString() << endl;
if((*it).second->getFF()) {
cout << "| FF noninverting= " << (*it).second->getFF()->getNonInverting().getString() << ", inverting= " << (*it).second->getFF()->getInverting().getString() << endl;
cout << "| Attributes :" << endl;
attributes=ff->getAttributes();
for(map<Name, Attribute*>::const_iterator it=attributes.begin() ; it!=attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString() << endl;
for(map<Name, Attribute*>::const_iterator it2=(*it).second->getFF()->getAttributes().begin() ; it2!=(*it).second->getFF()->getAttributes().end() ; ++it2) {
cout << "| name= " << (*it2).first.getString()
<< ", type= " << (*it2).second->typeToString()
<< ", value= " << (*it2).second->valueAsString() << endl;
}
}
// test_cell
@ -186,32 +186,27 @@ void Library::print() {
// Cell's attributes
cout << "| Attributes :" << endl;
attributes=testCell->getAttributes();
for(map<Name, Attribute*>::const_iterator it2=attributes.begin() ; it2!=attributes.end() ; ++it2) {
for(map<Name, Attribute*>::const_iterator it2=testCell->getAttributes().begin() ; it2!=testCell->getAttributes().end() ; ++it2) {
cout << "| name= " << (*it2).first.getString()
<< ", type= " << (*it2).second->typeToString()
<< ", value= " << (*it2).second->valueAsString() << endl;
}
// Cell's pins
pins=(*it).second->getPins();
for(map<Name, Pin*>::const_iterator it2=pins.begin() ; it2!=pins.end() ; ++it2) {
for(map<Name, Pin*>::const_iterator it2=(*it).second->getPins().begin() ; it2!=(*it).second->getPins().end() ; ++it2) {
// (*it2).second->print();
cout << "| Pin name= " << (*it2).first.getString() << endl;
// Pin's attributes
cout << "| Attributes :" << endl;
attributes=(*it2).second->getAttributes();
for(map<Name, Attribute*>::const_iterator it3=attributes.begin() ; it3!=attributes.end() ; ++it3) {
for(map<Name, Attribute*>::const_iterator it3=(*it2).second->getAttributes().begin() ; it3!=(*it2).second->getAttributes().end() ; ++it3) {
cout << "| name= " << (*it3).first.getString()
<< ", type= " << (*it3).second->typeToString()
<< ", value= " << (*it3).second->valueAsString() << endl;
}
// Timing
timings=(*it2).second->getTimings();
for (size_t i = 0 ; i < timings.size() ; i++) {
attributes=timings[i]->getAttributes();
for (size_t i = 0 ; i < (*it2).second->getTimings().size() ; i++) {
// Timing's attributes
cout << "| Timing's attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it3=attributes.begin() ; it3!=attributes.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()
<< ", type= " << (*it3).second->typeToString()
<< ", value= " << (*it3).second->valueAsString() << endl;
@ -221,12 +216,10 @@ void Library::print() {
// FF
// if(_ff)
// _ff->print();
ff = (*it).second->getFF();
if(ff) {
cout << "| FF noninverting= " << ff->getNonInverting().getString() << ", inverting= " << ff->getInverting().getString() << endl;
if((*it).second->getFF()) {
cout << "| FF noninverting= " << (*it).second->getFF()->getNonInverting().getString() << ", inverting= " << (*it).second->getFF()->getInverting().getString() << endl;
cout << "| Attributes :" << endl;
attributes=ff->getAttributes();
for(map<Name, Attribute*>::const_iterator it2=attributes.begin() ; it2!=attributes.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()
<< ", type= " << (*it2).second->typeToString()
<< ", value= " << (*it2).second->valueAsString() << endl;

View File

@ -2,8 +2,7 @@
#include<fstream>
using namespace std;
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
#include "vlsisapd/liberty/Timing.h"
#include "vlsisapd/liberty/Pin.h"
namespace LIB {
@ -30,7 +29,7 @@ Timing* Pin::getTiming(Name pinName) {
exit(1);
}
void Pin::addAttribute(Name attrName, Attribute::Type attrType, string& attrValue) {
void Pin::addAttribute(Name attrName, Attribute::Type attrType, const string& attrValue) {
Attribute* attr = new Attribute(attrName, attrType, attrValue);
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it != _attributes.end()) {

View File

@ -2,8 +2,6 @@
#include<fstream>
using namespace std;
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
#include "vlsisapd/liberty/Timing.h"
namespace LIB {
@ -20,7 +18,7 @@ Attribute* Timing::getAttribute(Name attrName) {
return attr;
}
void Timing::addAttribute(Name attrName, Attribute::Type attrType, string& attrValue) {
void Timing::addAttribute(Name attrName, Attribute::Type attrType, const string& attrValue) {
Attribute* attr = new Attribute(attrName, attrType, attrValue);
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it != _attributes.end()) {

View File

@ -2,8 +2,6 @@
#include<fstream>
using namespace std;
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
#include "vlsisapd/liberty/WireLoad.h"
namespace LIB {
@ -20,7 +18,7 @@ Attribute* WireLoad::getAttribute(Name attrName) {
return attr;
}
void WireLoad::addAttribute(Name attrName, Attribute::Type attrType, string& attrValue, const string& attrValue2) {
void WireLoad::addAttribute(Name attrName, Attribute::Type attrType, const string& attrValue, const string& attrValue2) {
Attribute* attr = new Attribute(attrName, attrType, attrValue, "", attrValue2);
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it != _attributes.end()) {

View File

@ -1,6 +1,5 @@
#include<fstream>
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/WireLoadArea.h"
namespace LIB {

View File

@ -2,7 +2,7 @@
#include<fstream>
using namespace std;
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/WireLoadArea.h"
#include "vlsisapd/liberty/WireLoadSelection.h"
namespace LIB {

View File

@ -3,6 +3,7 @@
#include<string>
#include<fstream>
#include "Name.h"
namespace LIB {

View File

@ -3,26 +3,25 @@
#include<fstream>
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
#include "vlsisapd/liberty/Pin.h"
#include "vlsisapd/liberty/FlipFlop.h"
namespace LIB {
class Pin;
class FlipFlop;
class Cell {
public:
Cell(Name name);
inline Name getName();
inline std::map<Name, Attribute*> getAttributes();
inline std::map<Name, Pin*> getPins();
inline std::map<Name, Attribute*>& getAttributes();
inline std::map<Name, Pin*>& getPins();
inline FlipFlop* getFF();
inline Cell* getTestCell();
Attribute* getAttribute(Name attrName);
Pin* getPin(Name pinName);
void addAttribute(Name attrName, Attribute::Type attrType, std::string& attrValue);
void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue);
void addPin(Name pinName);
void addFF(Name noninverting, Name inverting);
void setTestCell(Cell *cell);
@ -39,8 +38,8 @@ class Cell {
};
inline Name Cell::getName() { return _name; };
inline std::map<Name, Pin*> Cell::getPins() { return _pins; };
inline std::map<Name, Attribute*> Cell::getAttributes() { return _attributes; };
inline std::map<Name, Pin*>& Cell::getPins() { return _pins; };
inline std::map<Name, Attribute*>& Cell::getAttributes() { return _attributes; };
inline FlipFlop* Cell::getFF() { return _ff; };
inline Cell* Cell::getTestCell() { return _testCell; };

View File

@ -3,7 +3,6 @@
#include<fstream>
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
namespace LIB {
@ -14,10 +13,10 @@ class FlipFlop {
inline Name getNonInverting();
inline Name getInverting();
inline std::map<Name, Attribute*> getAttributes();
inline std::map<Name, Attribute*>& getAttributes();
Attribute* getAttribute(Name attrName);
void addAttribute(Name attrName, Attribute::Type attrType, std::string& attrValue);
void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue);
void print();
bool write(std::ofstream &file);
@ -30,7 +29,7 @@ class FlipFlop {
inline Name FlipFlop::getNonInverting() { return _noninverting; };
inline Name FlipFlop::getInverting() { return _inverting; };
inline std::map<Name, Attribute*> FlipFlop::getAttributes() { return _attributes; };
inline std::map<Name, Attribute*>& FlipFlop::getAttributes() { return _attributes; };
} // namespace LIB
#endif

View File

@ -1,24 +1,27 @@
#ifndef __LIB_LIBRARY_H__
#define __LIB_LIBRARY_H__
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
#include "vlsisapd/liberty/WireLoad.h"
#include "vlsisapd/liberty/WireLoadSelection.h"
#include "vlsisapd/liberty/Cell.h"
namespace LIB {
class WireLoad;
class WireLoadSelection;
class Cell;
class Library {
public:
Library(Name name);
inline Name getName();
Cell* getCell(Name cellName);
WireLoad* getWireLoad(Name wireLoadName);
inline std::map<Name, Attribute*>& getAttributes();
inline std::map<Name, WireLoad*>& getWiresLoad();
inline WireLoadSelection* getWireLoadSelection();
inline std::map<Name, Cell*>& getCells();
Attribute* getAttribute(Name attrName);
WireLoad* getWireLoad(Name wireLoadName);
Cell* getCell(Name cellName);
void addAttribute(Name attrName, Attribute::Type attrType, std::string& attrValue, const std::string& attrUnit="");
void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue, const std::string& attrUnit="");
void addWireLoad(Name wireLoadName);
void addWireLoadSelection(Name wireLoadSelectionName);
void addCell(Name cellName);
@ -36,8 +39,11 @@ class Library {
std::map<Name, Cell*> _cells;
};
inline Name Library::getName() { return _name; };
inline WireLoadSelection* Library::getWireLoadSelection() { return _wire_load_selection; };
inline Name Library::getName() { return _name; };
inline std::map<Name, Attribute*>& Library::getAttributes() { return _attributes; };
inline std::map<Name, WireLoad*>& Library::getWiresLoad() { return _wires_load; };
inline WireLoadSelection* Library::getWireLoadSelection() { return _wire_load_selection; };
inline std::map<Name, Cell*>& Library::getCells() { return _cells; };
} // namespace LIB
#endif

View File

@ -4,23 +4,22 @@
#include<fstream>
#include<vector>
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
#include "vlsisapd/liberty/Timing.h"
namespace LIB {
class Timing;
class Pin {
public:
Pin(Name name);
inline Name getName();
inline std::map<Name, Attribute*> getAttributes();
inline std::vector<Timing*> getTimings();
inline std::map<Name, Attribute*>& getAttributes();
inline std::vector<Timing*>& getTimings();
Attribute* getAttribute(Name attrName);
Timing* getTiming(Name pinName);
void addAttribute(Name attrName, Attribute::Type attrType, std::string& attrValue);
void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue);
void addTiming();
void print();
@ -32,9 +31,9 @@ class Pin {
std::vector<Timing*> _timings;
};
inline Name Pin::getName() { return _name; };
inline std::map<Name, Attribute*> Pin::getAttributes() { return _attributes; };
inline std::vector<Timing*> Pin::getTimings() { return _timings; };
inline Name Pin::getName() { return _name; };
inline std::map<Name, Attribute*>& Pin::getAttributes() { return _attributes; };
inline std::vector<Timing*>& Pin::getTimings() { return _timings; };
} // namespace LIB
#endif

View File

@ -0,0 +1,87 @@
#include <map>
#include <boost/python.hpp>
namespace LIB {
// since we want to wrap std::map<type, Class*> with cimple pointers (no boost::shared_ptr),
// we cannot use map_indexing_suite which has not the right return_value_policy.
// std::maps with no points value are wrapped using map_indexing_suite technique.
//
// This templated map_item struct is intended to be used for 'manual' wrapping:
template<class Key, class Val>
struct map_item {
typedef std::map<Key,Val> Map;
static Val get(Map & self, const Key idx) {
if (self.find(idx) == self.end()) {
PyErr_SetString(PyExc_KeyError,"Map key not found");
throw_error_already_set();
}
return self[idx];
}
static void set(Map& self, const Key idx, const Val val) { self[idx]=val; }
static void del(Map& self, const Key n) { self.erase(n); }
static bool in (Map const& self, const Key n) { return self.find(n) != self.end(); }
static list keys(Map const& self) {
list t;
for(typename Map::const_iterator it = self.begin() ; it!=self.end() ; ++it)
t.append(it->first);
return t;
}
static list values(Map const& self) {
list t;
for(typename Map::const_iterator it=self.begin(); it!=self.end(); ++it)
t.append(it->second);
return t;
}
static list items(Map const& self) {
list t;
for(typename Map::const_iterator it=self.begin(); it!=self.end(); ++it)
t.append( make_tuple(it->first, it->second) );
return t;
}
};
#define STL_MAP_WRAPPING_PTR(KEY_TYPE, VALUE_TYPE, PYTHON_TYPE_NAME) \
class_<std::pair<const KEY_TYPE, VALUE_TYPE> >((std::string(PYTHON_TYPE_NAME)+std::string("DATA")).c_str()) \
.def_readonly ("key" , &std::pair<const KEY_TYPE, VALUE_TYPE>::first ) \
.def_readwrite("value", &std::pair<const KEY_TYPE, VALUE_TYPE>::second) \
; \
class_<std::map<KEY_TYPE, VALUE_TYPE> >(PYTHON_TYPE_NAME) \
.def("__len__" , &std::map<KEY_TYPE, VALUE_TYPE>::size) \
.def("__iter__" , boost::python::iterator<std::map<KEY_TYPE, VALUE_TYPE>, return_internal_reference<> >()) \
.def("__getitem__" , &map_item<KEY_TYPE, VALUE_TYPE>().get, return_internal_reference<>()) \
.def("__setitem__" , &map_item<KEY_TYPE, VALUE_TYPE>().set ) \
.def("__delitem__" , &map_item<KEY_TYPE, VALUE_TYPE>().del ) \
.def("__contains__", &map_item<KEY_TYPE, VALUE_TYPE>().in ) \
.def("clear" , &std::map<KEY_TYPE, VALUE_TYPE>::clear ) \
.def("has_key" , &map_item<KEY_TYPE, VALUE_TYPE>().in ) \
.def("keys" , &map_item<KEY_TYPE, VALUE_TYPE>().keys ) \
.def("values" , &map_item<KEY_TYPE, VALUE_TYPE>().values) \
.def("items" , &map_item<KEY_TYPE, VALUE_TYPE>().items ) \
;
#define STL_MAP_WRAPPING(KEY_TYPE, VALUE_TYPE, PYTHON_TYPE_NAME) \
class_<std::pair<const KEY_TYPE, VALUE_TYPE> >((std::string(PYTHON_TYPE_NAME)+std::string("DATA")).c_str()) \
.def_readonly ("key" , &std::pair<const KEY_TYPE, VALUE_TYPE>::first ) \
.def_readwrite("value", &std::pair<const KEY_TYPE, VALUE_TYPE>::second) \
; \
class_<std::map<KEY_TYPE, VALUE_TYPE> >(PYTHON_TYPE_NAME) \
.def("__len__" , &std::map<KEY_TYPE, VALUE_TYPE>::size) \
.def("__iter__" , boost::python::iterator<std::map<KEY_TYPE, VALUE_TYPE>, return_internal_reference<> >()) \
.def("__getitem__" , &map_item<KEY_TYPE, VALUE_TYPE>().get ) \
.def("__setitem__" , &map_item<KEY_TYPE, VALUE_TYPE>().set ) \
.def("__delitem__" , &map_item<KEY_TYPE, VALUE_TYPE>().del ) \
.def("__contains__", &map_item<KEY_TYPE, VALUE_TYPE>().in ) \
.def("clear" , &std::map<KEY_TYPE, VALUE_TYPE>::clear ) \
.def("has_key" , &map_item<KEY_TYPE, VALUE_TYPE>().in ) \
.def("keys" , &map_item<KEY_TYPE, VALUE_TYPE>().keys ) \
.def("values" , &map_item<KEY_TYPE, VALUE_TYPE>().values) \
.def("items" , &map_item<KEY_TYPE, VALUE_TYPE>().items ) \
;
} // namespace

View File

@ -3,7 +3,6 @@
#include<fstream>
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
namespace LIB {
@ -12,10 +11,10 @@ class Timing {
public:
Timing();
inline std::map<Name, Attribute*> getAttributes();
inline std::map<Name, Attribute*>& getAttributes();
Attribute* getAttribute(Name attrName);
void addAttribute(Name attrName, Attribute::Type attrType, std::string& attrValue);
void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue);
void print();
bool write(std::ofstream &file);
@ -24,7 +23,7 @@ class Timing {
std::map<Name, Attribute*> _attributes;
};
inline std::map<Name, Attribute*> Timing::getAttributes() { return _attributes; };
inline std::map<Name, Attribute*>& Timing::getAttributes() { return _attributes; };
} // namespace LIB
#endif

View File

@ -1,7 +1,6 @@
#ifndef __LIB_WIRE_LOAD_H__
#define __LIB_WIRE_LOAD_H__
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/Attribute.h"
namespace LIB {
@ -11,10 +10,10 @@ class WireLoad {
WireLoad(Name name);
inline Name getName();
inline std::map<Name, Attribute*> getAttributes();
inline std::map<Name, Attribute*>& getAttributes();
Attribute* getAttribute(Name attrName);
void addAttribute(Name attrName, Attribute::Type attrType, std::string& attrValue, const std::string& attrValue2 = "");
void addAttribute(Name attrName, Attribute::Type attrType, const std::string& attrValue, const std::string& attrValue2 = "");
void print();
bool write(std::ofstream &file);
@ -24,8 +23,8 @@ class WireLoad {
std::map<Name, Attribute*> _attributes;
};
inline Name WireLoad::getName() { return _name; };
inline std::map<Name, Attribute*> WireLoad::getAttributes() { return _attributes; };
inline Name WireLoad::getName() { return _name; };
inline std::map<Name, Attribute*>& WireLoad::getAttributes() { return _attributes; };
} // namespace LIB
#endif

View File

@ -5,16 +5,16 @@
#include<fstream>
#include "vlsisapd/liberty/Name.h"
#include "vlsisapd/liberty/WireLoadArea.h"
namespace LIB {
class WireLoadArea;
class WireLoadSelection {
public:
WireLoadSelection(Name name);
inline Name getName();
inline std::vector<WireLoadArea*> getWiresLoadArea();
inline std::vector<WireLoadArea*>& getWiresLoadArea();
void addWireLoadArea(double min, double max, Name name);
void print();
@ -25,8 +25,8 @@ class WireLoadSelection {
std::vector<WireLoadArea*> _wires_load_area;
};
inline Name WireLoadSelection::getName() { return _name; };
inline std::vector<WireLoadArea*> WireLoadSelection::getWiresLoadArea() { return _wires_load_area; };
inline Name WireLoadSelection::getName() { return _name; };
inline std::vector<WireLoadArea*>& WireLoadSelection::getWiresLoadArea() { return _wires_load_area; };
} // namespace
#endif