Useful getters.

This commit is contained in:
Sophie Belloeil 2010-10-11 11:45:38 +00:00
parent 6660ae8663
commit 3db947d302
18 changed files with 273 additions and 40 deletions

View File

@ -54,7 +54,7 @@ int main ( int argc, char * argv[] ) {
// Timing
LIB::Timing * timing;
pin->addTiming();
timing = pin->getTiming().back();
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);

View File

@ -9,7 +9,11 @@ int main ( int argc, char * argv[] ) {
LIB::Library* library = LIB::Library::readFromFile("./testParse.lib");
if ( library ) {
// print of the library
library->print();
// print of one attribute in particular
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;
} else {
cerr << "library is NULL" << endl;
}

View File

@ -53,8 +53,8 @@ double Attribute::secondValueAsDouble() const {
return d;
}
string Attribute::typeToString(Attribute::Type type) {
switch(type) {
string Attribute::typeToString() {
switch(_type) {
case Unknown: return "unknown";
case String: return "string";
case Bool: return "bool";

View File

@ -9,7 +9,18 @@ using namespace std;
#include "vlsisapd/liberty/FlipFlop.h"
namespace LIB {
Cell::Cell(Name name): _name(name), _attributes(), _pins(), _ff(NULL), _test_cell(NULL) {};
Cell::Cell(Name name): _name(name), _attributes(), _pins(), _ff(NULL), _testCell(NULL) {};
Attribute* Cell::getAttribute(Name attrName) {
Attribute* attr = NULL;
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it == _attributes.end()) {
cerr << "[ERROR] Cell " << _name.getString() << " has no attribute named " << attrName.getString() << endl;
exit(1);
}
attr= (*it).second;
return attr;
}
Pin* Cell::getPin(Name pinName) {
Pin* pin = NULL;
@ -48,7 +59,7 @@ void Cell::addFF(Name noninverting, Name inverting) {
}
void Cell::setTestCell(Cell *cell) {
_test_cell = cell;
_testCell = cell;
}
void Cell::print() {
@ -58,7 +69,7 @@ void Cell::print() {
cout << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString((*it).second->getType())
<< ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString() << endl;
}
// Cell's pins
@ -69,8 +80,8 @@ void Cell::print() {
if(_ff)
_ff->print();
// test_cell
if(_test_cell)
_test_cell->print();
if(_testCell)
_testCell->print();
}
bool Cell::write(ofstream &file, bool test) {
@ -95,8 +106,8 @@ bool Cell::write(ofstream &file, bool test) {
if(_ff)
_ff->write(file);
// test_cell
if(_test_cell)
_test_cell->write(file, true);
if(_testCell)
_testCell->write(file, true);
file << " }" << endl;
return true;
}

View File

@ -9,6 +9,17 @@ using namespace std;
namespace LIB {
FlipFlop::FlipFlop(Name noninverting, Name inverting): _noninverting(noninverting), _inverting(inverting), _attributes() {};
Attribute* FlipFlop::getAttribute(Name attrName) {
Attribute* attr = NULL;
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it == _attributes.end()) {
cerr << "[ERROR] FlipFLop has no attribute named " << attrName.getString() << endl;
exit(1);
}
attr= (*it).second;
return attr;
}
void FlipFlop::addAttribute(Name attrName, Attribute::Type attrType, string& attrValue) {
Attribute* attr = new Attribute(attrName, attrType, attrValue);
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
@ -26,7 +37,7 @@ void FlipFlop::print() {
cout << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString((*it).second->getType())
<< ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString() << endl;
}
}

View File

@ -408,7 +408,7 @@ timing_header
: TIMING '(' ')'
{
library->getCell(currentCell)->getPin(listPins.back())->addTiming();
currentTiming=library->getCell(currentCell)->getPin(listPins.back())->getTiming().back();
currentTiming=library->getCell(currentCell)->getPin(listPins.back())->getTimings().back();
// only for 1 pin, not available for pins' list
if(listPins.size()>1)
cerr << "[Warning] timing information for a list of pins, not available." << endl;

View File

@ -72,28 +72,167 @@ void Library::addCell(Name cellName) {
void Library::print() {
cout << "+-----------------------------+" << endl
<< "| Library name= " << _name.getString() << endl;
<< "| Library : " << _name.getString() << endl;
// Library's attributes
cout << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString((*it).second->getType())
<< ", value= " << (*it).second->valueAsString();
cout << "| name=" << (*it).first.getString()
<< ", type=" << (*it).second->typeToString()
<< ", value=" << (*it).second->valueAsString();
string unit = (*it).second->getUnit();
if(!unit.empty())
cout << ", unit= " << unit;
cout << ", unit=" << unit;
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();
// (*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) {
if ((*it2).second == NULL) {
cerr << "NULL attribute !" << endl;
exit(12);
}
cout << "| name=" << (*it2).first.getString()
<< ", type=" << (*it2).second->typeToString()
<< ", value=" << (*it2).second->valueAsString();
string value2=(*it2).second->secondValueAsString();
if(!value2.empty())
cout << ", value2=" << value2;
cout << endl;
}
}
// WireLoadSelection
_wire_load_selection->print();
// _wire_load_selection->print();
cout << "| WireLoadSection name= " << _wire_load_selection->getName().getString() << endl;
vector<WireLoadArea*> wires_load_area = _wire_load_selection->getWiresLoadArea();
for(size_t i = 0 ; i < wires_load_area.size() ; i++) {
cout << "| wire_load_from_area name= " << wires_load_area[i]->getName().getString()
<< ", min= " << wires_load_area[i]->getMin()
<< ", max= " << wires_load_area[i]->getMax()
<< endl;
}
// Cell
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;
// Cell's attributes
cout << "| Attributes :" << endl;
attributes=(*it).second->getAttributes();
for(map<Name, Attribute*>::const_iterator it2=attributes.begin() ; it2!=attributes.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) {
// (*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) {
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();
// Timing's attributes
cout << "| Timing's attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it3=attributes.begin() ; it3!=attributes.end() ; ++it3) {
cout << "| name= " << (*it3).first.getString()
<< ", type= " << (*it3).second->typeToString()
<< ", value= " << (*it3).second->valueAsString() << endl;
}
}
}
// FF
// if(_ff)
// _ff->print();
ff = (*it).second->getFF();
if(ff) {
cout << "| FF noninverting= " << ff->getNonInverting().getString() << ", inverting= " << ff->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;
}
}
// test_cell
// if(_testCell)
// _testCell->print();
Cell* testCell = (*it).second->getTestCell();
if(testCell) {
cout << "| Test Cell" << endl;
// Cell's attributes
cout << "| Attributes :" << endl;
attributes=testCell->getAttributes();
for(map<Name, Attribute*>::const_iterator it2=attributes.begin() ; it2!=attributes.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) {
// (*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) {
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();
// Timing's attributes
cout << "| Timing's attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it3=attributes.begin() ; it3!=attributes.end() ; ++it3) {
cout << "| name= " << (*it3).first.getString()
<< ", type= " << (*it3).second->typeToString()
<< ", value= " << (*it3).second->valueAsString() << endl;
}
}
}
// FF
// if(_ff)
// _ff->print();
ff = (*it).second->getFF();
if(ff) {
cout << "| FF noninverting= " << ff->getNonInverting().getString() << ", inverting= " << ff->getInverting().getString() << endl;
cout << "| Attributes :" << endl;
attributes=ff->getAttributes();
for(map<Name, Attribute*>::const_iterator it2=attributes.begin() ; it2!=attributes.end() ; ++it2) {
cout << "| name= " << (*it2).first.getString()
<< ", type= " << (*it2).second->typeToString()
<< ", value= " << (*it2).second->valueAsString() << endl;
}
}
}
}
cout << "+-----------------------------+" << endl;
};

View File

@ -9,6 +9,27 @@ using namespace std;
namespace LIB {
Pin::Pin(Name name): _name(name), _attributes(), _timings() {};
Attribute* Pin::getAttribute(Name attrName) {
Attribute* attr = NULL;
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it == _attributes.end()) {
cerr << "[ERROR] Pin " << _name.getString() << " has no attribute named " << attrName.getString() << endl;
exit(1);
}
attr= (*it).second;
return attr;
}
Timing* Pin::getTiming(Name pinName) {
for (size_t i = 0 ; i < _timings.size() ; i++) {
if (pinName.getString() == _timings[i]->getAttribute(Name("related_pin"))->valueAsString()) {
return _timings[i];
}
}
cerr << "[ERROR] Pin " << _name.getString() << " has no timing related to pin named " << pinName.getString() << endl;
exit(1);
}
void Pin::addAttribute(Name attrName, Attribute::Type attrType, string& attrValue) {
Attribute* attr = new Attribute(attrName, attrType, attrValue);
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
@ -31,7 +52,7 @@ void Pin::print() {
cout << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString((*it).second->getType())
<< ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString() << endl;
}
// Timing

View File

@ -9,6 +9,17 @@ using namespace std;
namespace LIB {
Timing::Timing(): _attributes() {};
Attribute* Timing::getAttribute(Name attrName) {
Attribute* attr = NULL;
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it == _attributes.end()) {
cerr << "[ERROR] Timing has no attribute named " << attrName.getString() << endl;
exit(1);
}
attr= (*it).second;
return attr;
}
void Timing::addAttribute(Name attrName, Attribute::Type attrType, string& attrValue) {
Attribute* attr = new Attribute(attrName, attrType, attrValue);
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
@ -24,7 +35,7 @@ void Timing::print() {
cout << "| Timing's attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString((*it).second->getType())
<< ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString() << endl;
}
}

View File

@ -9,6 +9,17 @@ using namespace std;
namespace LIB {
WireLoad::WireLoad(Name name): _name(name), _attributes() {};
Attribute* WireLoad::getAttribute(Name attrName) {
Attribute* attr = NULL;
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
if (it == _attributes.end()) {
cerr << "[ERROR] WireLoad " << _name.getString() << " has no attribute named " << attrName.getString() << endl;
exit(1);
}
attr= (*it).second;
return attr;
}
void WireLoad::addAttribute(Name attrName, Attribute::Type attrType, string& attrValue, const string& attrValue2) {
Attribute* attr = new Attribute(attrName, attrType, attrValue, "", attrValue2);
map<Name, Attribute*>::iterator it = _attributes.find(attrName);
@ -25,7 +36,7 @@ void WireLoad::print() {
cout << "| Attributes :" << endl;
for(map<Name, Attribute*>::const_iterator it=_attributes.begin() ; it!=_attributes.end() ; ++it) {
cout << "| name= " << (*it).first.getString()
<< ", type= " << (*it).second->typeToString((*it).second->getType())
<< ", type= " << (*it).second->typeToString()
<< ", value= " << (*it).second->valueAsString();
string value2=(*it).second->secondValueAsString();
if(!value2.empty())

View File

@ -26,12 +26,12 @@ class Attribute {
inline const std::string& valueAsString() const;
inline const std::string& secondValueAsString() const;
bool valueAsBool() const;
int valueAsInt() const;
bool valueAsBool() const;
int valueAsInt() const;
double valueAsDouble() const;
double secondValueAsDouble() const;
std::string typeToString(Type type);
bool write(std::ofstream &file);
std::string typeToString();
bool write(std::ofstream &file);
private:
Name _name;

View File

@ -15,8 +15,12 @@ class Cell {
Cell(Name name);
inline Name getName();
Pin* getPin(Name pinName);
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 addPin(Name pinName);
@ -31,11 +35,14 @@ class Cell {
std::map<Name, Attribute*> _attributes;
std::map<Name, Pin*> _pins;
FlipFlop* _ff;
Cell* _test_cell;
Cell* _testCell;
};
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 FlipFlop* Cell::getFF() { return _ff; };
inline Cell* Cell::getTestCell() { return _testCell; };
} // namespace LIB
#endif

View File

@ -11,6 +11,11 @@ namespace LIB {
class FlipFlop {
public:
FlipFlop(Name noninverting, Name inverting);
inline Name getNonInverting();
inline Name getInverting();
inline std::map<Name, Attribute*> getAttributes();
Attribute* getAttribute(Name attrName);
void addAttribute(Name attrName, Attribute::Type attrType, std::string& attrValue);
@ -23,5 +28,9 @@ class FlipFlop {
std::map<Name, Attribute*> _attributes;
};
inline Name FlipFlop::getNonInverting() { return _noninverting; };
inline Name FlipFlop::getInverting() { return _inverting; };
inline std::map<Name, Attribute*> FlipFlop::getAttributes() { return _attributes; };
} // namespace LIB
#endif

View File

@ -1,12 +1,3 @@
/*
* Name.h
* openChams
*
* Created by damien dupuis on 18/12/09.
* Copyright 2009 UPMC / LIP6. All rights reserved.
*
*/
#ifndef __LIB_NAME_H__
#define __LIB_NAME_H__

View File

@ -15,7 +15,10 @@ class Pin {
Pin(Name name);
inline Name getName();
inline std::vector<Timing*> getTiming();
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 addTiming();
@ -30,7 +33,8 @@ class Pin {
};
inline Name Pin::getName() { return _name; };
inline std::vector<Timing*> Pin::getTiming() { return _timings; };
inline std::map<Name, Attribute*> Pin::getAttributes() { return _attributes; };
inline std::vector<Timing*> Pin::getTimings() { return _timings; };
} // namespace LIB
#endif

View File

@ -11,6 +11,9 @@ namespace LIB {
class Timing {
public:
Timing();
inline std::map<Name, Attribute*> getAttributes();
Attribute* getAttribute(Name attrName);
void addAttribute(Name attrName, Attribute::Type attrType, std::string& attrValue);
@ -21,5 +24,7 @@ class Timing {
std::map<Name, Attribute*> _attributes;
};
inline std::map<Name, Attribute*> Timing::getAttributes() { return _attributes; };
} // namespace LIB
#endif

View File

@ -11,6 +11,8 @@ class WireLoad {
WireLoad(Name name);
inline Name getName();
inline std::map<Name, Attribute*> getAttributes();
Attribute* getAttribute(Name attrName);
void addAttribute(Name attrName, Attribute::Type attrType, std::string& attrValue, const std::string& attrValue2 = "");
@ -23,6 +25,7 @@ class WireLoad {
};
inline Name WireLoad::getName() { return _name; };
inline std::map<Name, Attribute*> WireLoad::getAttributes() { return _attributes; };
} // namespace LIB
#endif

View File

@ -13,6 +13,9 @@ class WireLoadSelection {
public:
WireLoadSelection(Name name);
inline Name getName();
inline std::vector<WireLoadArea*> getWiresLoadArea();
void addWireLoadArea(double min, double max, Name name);
void print();
bool write(std::ofstream& file);
@ -21,6 +24,9 @@ class WireLoadSelection {
Name _name;
std::vector<WireLoadArea*> _wires_load_area;
};
inline Name WireLoadSelection::getName() { return _name; };
inline std::vector<WireLoadArea*> WireLoadSelection::getWiresLoadArea() { return _wires_load_area; };
} // namespace
#endif