* ./vlsisapd/dtr:

- Change: Completly remove Name as std::string are shared, in library,
        boost::python, doxygen documentation & examples.
This commit is contained in:
Jean-Paul Chaput 2012-03-26 15:39:08 +00:00
parent 4c876122d1
commit 5c593f4161
18 changed files with 547 additions and 583 deletions

View File

@ -1,47 +0,0 @@
// -*- C++ -*-
namespace DTR {
/*! \class Name
*
* This class provides an automatic management of shared name.
*/
/*! \fn Name::Name(std::string str)
* \brief gets a shared Name, creates it if it does not exist.
*
* \param str the string associated to the name.
*/
/*! \fn Name::Name(const char* cstr)
* \brief gets a shared Name, creates it if it does not exist.
*
* \param cstr the character string associated to the name.
*
* \note this method is not yet available in python
*/
/*! \fn bool Name::operator==(const Name&)
* \brief redifines the '==' operator.
*/
/*! \fn bool Name::operator==(const std::string&)
* \brief redifines the '==' operator.
*/
/*! \fn bool Name::operator!=(const Name&)
* \brief redifines the '!=' operator.
*/
/*! \fn bool Name::operator!=(const std::string&)
* \brief redifines the '!=' operator.
*/
/*! \fn bool Name::operator<(const Name) const
* \brief redifines the '<' operator.
*/
/*! \fn inline const std::string& Name::getString() const
* \brief returns the string associated to the Name.
*/
}

View File

@ -22,7 +22,7 @@ namespace DTR {
* *
*/ */
/*! \fn Rule::Rule(Name name, double value, Name ref, Name layer1, Name layer2) /*! \fn Rule::Rule(const char* name, double value, const char* ref, const char* layer1, const char* layer2)
* \brief creates a new rule. * \brief creates a new rule.
* *
* \param name the name of the rule. * \param name the name of the rule.
@ -32,11 +32,11 @@ namespace DTR {
* \param layer2 the second layer. * \param layer2 the second layer.
*/ */
/*! \fn inline Name Rule::getName() /*! \fn inline const std::string& Rule::getName()
* \brief returns the name of the rule. * \brief returns the name of the rule.
*/ */
/*! \fn inline Name Rule::getType() /*! \fn inline const std::string& Rule::getType()
* \brief returns the type of the rule. * \brief returns the type of the rule.
* *
* Rule's type allows to set a specific type for a rule especially the 'area' type to take into account that the value of the rule is to be considered in unit^2. * Rule's type allows to set a specific type for a rule especially the 'area' type to take into account that the value of the rule is to be considered in unit^2.
@ -50,24 +50,24 @@ namespace DTR {
* \brief returns the string corresponding to the value of the rule. * \brief returns the string corresponding to the value of the rule.
*/ */
/*! \fn inline Name Rule::getRef() /*! \fn inline const std::string& Rule::getRef()
* \brief returns the reference of the rule. * \brief returns the reference of the rule.
*/ */
/*! \fn inline Name Rule::getLayer1() /*! \fn inline const std::string& Rule::getLayer1()
* \brief returns the first layer of the rule. * \brief returns the first layer of the rule.
*/ */
/*! \fn inline Name Rule::getLayer2() /*! \fn inline const std::string& Rule::getLayer2()
* \brief returns the second layer of the rule. * \brief returns the second layer of the rule.
*/ */
/*! \fn inline void Rule::setType(Name type) /*! \fn inline void Rule::setType(const char* type)
* \brief sets the type of a rule. * \brief sets the type of a rule.
* *
* \param type the type of the rule. * \param type the type of the rule.
* *
* \note By default the type of a rule is Name(""). * \note By default the type of a rule is "".
*/ */
/*! \class ARule /*! \class ARule

View File

@ -6,18 +6,19 @@ namespace DTR {
* This class contains generic informations such as the name of the technology and the unit used, and the list of all technologic rules. * This class contains generic informations such as the name of the technology and the unit used, and the list of all technologic rules.
*/ */
/*! \fn Techno::Techno(Name name, Name unit) /*! \fn Techno::Techno(const char* name, const char* unit, const char* version)
* \brief creates a new technology * \brief creates a new technology
* *
* \param name the name of the technology. * \param name the name of the technology.
* \param unit the unit used for all values. * \param unit the unit used for all values.
* \param version the technology version/revision.
*/ */
/*! \fn inline Name Techno::getName() /*! \fn inline const std::string& Techno::getName() const
* \brief returns the name of the technology. * \brief returns the name of the technology.
*/ */
/*! \fn inline Name Techno::getUnit() /*! \fn inline const std::string& Techno::getUnit() const
* \brief returns the unit. * \brief returns the unit.
*/ */
@ -27,19 +28,19 @@ namespace DTR {
* \note this method is not yet available in python * \note this method is not yet available in python
*/ */
/*! \fn Rule* Techno::addRule(Name name, double value, Name ref, Name layer1, Name layer2) /*! \fn Rule* Techno::addRule(const char* name, double value, const char* ref, const char* layer1, const char* layer2)
* \brief creates a new Rule and adds it the to Techno object. * \brief creates a new Rule and adds it the to Techno object.
* *
* \param name the name of the rule. * \param name the name of the rule.
* \param value the value of the rule. * \param value the value of the rule.
* \param ref the reference of the rule (helpful to find the rule in design kit). * \param ref the reference of the rule (helpful to find the rule in design kit).
* \param layer1 the first layer. This is an optionnal argument, default value is Name(""). * \param layer1 the first layer. This is an optionnal argument, default value is "".
* \param layer2 the second layer. This is an optionnal argument, default value is Name(""). * \param layer2 the second layer. This is an optionnal argument, default value is "".
* *
* \return the newly created Rule object. * \return the newly created Rule object.
*/ */
/*! \fn Arule* Techno::addARule(Name name, double value, Name ref, Name layer1, Name layer2) /*! \fn Arule* Techno::addARule(const char* name, double value, const char* ref, const char* layer1, const char* layer2)
* \brief creates a new ARule and adds it to the Techno object. * \brief creates a new ARule and adds it to the Techno object.
* *
* \param name the name of the rule. * \param name the name of the rule.
@ -51,45 +52,45 @@ namespace DTR {
* \return the newly created ARule object. * \return the newly created ARule object.
*/ */
/*! \fn Rule* Techno::getRule(Name name, Name layer1, Name layer2) /*! \fn Rule* Techno::getRule(const char* name, const char* layer1, const char* layer2)
* \brief returns the rule uniquely identified by its name and layers. * \brief returns the rule uniquely identified by its name and layers.
* *
* \param name the name of the rule. * \param name the name of the rule.
* \param layer1 the first layer. This is an optionnal argument, default value is Name(""). * \param layer1 the first layer. This is an optionnal argument, default value is "".
* \param layer2 the second layer. This is an optionnal argument, default value is Name(""). * \param layer2 the second layer. This is an optionnal argument, default value is "".
* *
* \return the rule. * \return the rule.
*/ */
/*! \fn double Techno::getValue(Name name, Name layer1, Name layer2) /*! \fn double Techno::getValue(const char* name, const char* layer1, const char* layer2)
* \brief returns the value of a rule uniquely identified by its name and layers. * \brief returns the value of a rule uniquely identified by its name and layers.
* *
* \param name the name of the rule. * \param name the name of the rule.
* \param layer1 the first layer. This is an optionnal argument, default value is Name(""). * \param layer1 the first layer. This is an optionnal argument, default value is "".
* \param layer2 the second layer. This is an optionnal argument, default value is Name(""). * \param layer2 the second layer. This is an optionnal argument, default value is "".
* *
* \return the value of the rule. * \return the value of the rule.
*/ */
/*! \fn std::string Techno::getValueAsString(Name name, Name layer1, Name layer2) /*! \fn std::string Techno::getValueAsString(const char* name, const char* layer1, const char* layer2)
* \brief returns a string corresponding to the value of a rule uniquely identified by its name and layers. * \brief returns a string corresponding to the value of a rule uniquely identified by its name and layers.
* *
* \param name the name of the rule. * \param name the name of the rule.
* \param layer1 the first layer. This is an optionnal argument, default value is Name(""). * \param layer1 the first layer. This is an optionnal argument, default value is "".
* \param layer2 the second layer. This is an optionnal argument, default value is Name(""). * \param layer2 the second layer. This is an optionnal argument, default value is "".
* *
* \return the string corresponding to the value of the rule. * \return the string corresponding to the value of the rule.
* *
* \note this method is important for python module since to avoid rounding problems it is necessary to use Decimal object which is build based on a string. * \note this method is important for python module since to avoid rounding problems it is necessary to use Decimal object which is build based on a string.
*/ */
/*! \fn bool Techno::writeToFile(std::string filename) /*! \fn bool Techno::writeToFile(const char* filename)
* \brief writes the database to file. * \brief writes the database to file.
* *
* \param filename the destination file name. * \param filename the destination file name.
*/ */
/*! \fn static Techno* Techno::readFromFile(const std::string filename) /*! \fn static Techno* Techno::readFromFile(const char* filename)
* \brief creates and returns a Techno object based on a database source file. * \brief creates and returns a Techno object based on a database source file.
* *
* \param filename the source file name. * \param filename the source file name.

View File

@ -13,7 +13,6 @@
The database contains four object : The database contains four object :
- DTR::Techno contains generic informations such as the name of the technology and the unit used, and the list of all technologic rules. - DTR::Techno contains generic informations such as the name of the technology and the unit used, and the list of all technologic rules.
- DTR::Rule & DTR::ARule respectively describe a symmetrical and an asymmetrical rule. - DTR::Rule & DTR::ARule respectively describe a symmetrical and an asymmetrical rule.
- DTR::Name provides an automatic management of shared name.
The library also use the DTR::DTRException class to throw excptions. The library also use the DTR::DTRException class to throw excptions.

View File

@ -3,20 +3,19 @@ using namespace std;
#include "vlsisapd/dtr/Techno.h" #include "vlsisapd/dtr/Techno.h"
#include "vlsisapd/dtr/Rules.h" #include "vlsisapd/dtr/Rules.h"
#include "vlsisapd/dtr/Name.h"
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
DTR::Techno* techno = new DTR::Techno(DTR::Name("MyTech"), DTR::Name("micro"), DTR::Name("rev.A")); DTR::Techno* techno = new DTR::Techno("MyTech", "micro", "rev.A");
techno->addRule (DTR::Name("transistorMinL"), 0.1 , DTR::Name("ref1")); techno->addRule ("transistorMinL", 0.1 , "ref1");
techno->addRule (DTR::Name("transistorMinW"), 0.2 , DTR::Name("ref2")); techno->addRule ("transistorMinW", 0.2 , "ref2");
techno->addRule (DTR::Name("minWidth") , 0.15, DTR::Name("ref3"), DTR::Name("metal1")); techno->addRule ("minWidth" , 0.15, "ref3", "metal1");
techno->addRule (DTR::Name("minSpacing") , 0.2 , DTR::Name("ref4"), DTR::Name("metal1")); techno->addRule ("minSpacing" , 0.2 , "ref4", "metal1");
techno->addRule (DTR::Name("minSpacing") , 0.1 , DTR::Name("ref5"), DTR::Name("active"), DTR::Name("poly")); techno->addRule ("minSpacing" , 0.1 , "ref5", "active", "poly");
techno->addARule(DTR::Name("minExtension") , 0.2 , DTR::Name("ref6"), DTR::Name("poly") , DTR::Name("active")); techno->addARule("minExtension" , 0.2 , "ref6", "poly" , "active");
DTR::Rule* rule = techno->addRule(DTR::Name("minArea"), 0.1, DTR::Name("ref7"), DTR::Name("metal1")); DTR::Rule* rule = techno->addRule("minArea", 0.1, "ref7", "metal1");
rule->setType(DTR::Name("area")); rule->setType("area");
techno->writeToFile("./out.dtr.xml"); techno->writeToFile("./out.dtr.xml");

View File

@ -3,24 +3,23 @@
using namespace std; using namespace std;
#include "vlsisapd/dtr/Techno.h" #include "vlsisapd/dtr/Techno.h"
#include "vlsisapd/dtr/Name.h"
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
DTR::Techno* techno = DTR::Techno::readFromFile("./example.dtr.xml"); DTR::Techno* techno = DTR::Techno::readFromFile("./example.dtr.xml");
cerr << "+-----------------------------+" << endl cerr << "+-----------------------------+" << endl
<< "| technology: " << techno->getName().getString() << " |" << endl << "| technology: " << techno->getName() << " |" << endl
<< "| units: " << techno->getUnit().getString() << " |" << endl << "| units: " << techno->getUnit() << " |" << endl
<< "| version: " << techno->getVersion().getString() << " |" << endl << "| version: " << techno->getVersion() << " |" << endl
<< "+-----------------------------+" << endl << endl; << "+-----------------------------+" << endl << endl;
cerr << "transistorMinL = " << techno->getValue(DTR::Name("transistorMinL")) << endl cerr << "transistorMinL = " << techno->getValue("transistorMinL") << endl
<< "transistorMinW = " << techno->getValueAsString(DTR::Name("transistorMinW")) << endl << "transistorMinW = " << techno->getValueAsString("transistorMinW") << endl
<< "minWidth of metal1 = " << techno->getValue(DTR::Name("minWidth"), DTR::Name("metal1")) << endl << "minWidth of metal1 = " << techno->getValue("minWidth", "metal1") << endl
<< "minSpacing of metal1 = " << techno->getValue(DTR::Name("minWidth"), DTR::Name("metal1")) << endl << "minSpacing of metal1 = " << techno->getValue("minWidth", "metal1") << endl
<< "minSpacing of active vs poly = " << techno->getValue(DTR::Name("minSpacing"), DTR::Name("active"), DTR::Name("poly")) << endl << "minSpacing of active vs poly = " << techno->getValue("minSpacing", "active", "poly") << endl
<< "minExtension active over poly = " << techno->getValue(DTR::Name("minExtension"), DTR::Name("poly"), DTR::Name("active")) << endl << "minExtension active over poly = " << techno->getValue("minExtension", "poly", "active") << endl
<< "minArea of metal1 = " << techno->getValue(DTR::Name("minArea"), DTR::Name("metal1")) << endl; << "minArea of metal1 = " << techno->getValue("minArea", "metal1") << endl;
return 0; return 0;
} }

View File

@ -1,15 +1,15 @@
from DTR import * from DTR import *
techno = Techno(Name("myTech"), Name("micro"), Name("rev.A")) techno = Techno("myTech", "micro", "rev.A")
techno.addRule (Name("transistorMinL"), 0.1 , Name("ref1")) techno.addRule ("transistorMinL", 0.1 , "ref1")
techno.addRule (Name("transistorMinW"), 0.2 , Name("ref2")) techno.addRule ("transistorMinW", 0.2 , "ref2")
techno.addRule (Name("minWidth") , 0.15, Name("ref3"), Name("metal1")) techno.addRule ("minWidth" , 0.15, "ref3", "metal1")
techno.addRule (Name("minSpacing") , 0.2 , Name("ref4"), Name("metal1")) techno.addRule ("minSpacing" , 0.2 , "ref4", "metal1")
techno.addRule (Name("minSpacing") , 0.1 , Name("ref5"), Name("active"), Name("poly")) techno.addRule ("minSpacing" , 0.1 , "ref5", "active", "poly")
techno.addARule(Name("minExtension") , 0.2 , Name("ref6"), Name("poly"), Name("active")) techno.addARule("minExtension" , 0.2 , "ref6", "poly", "active")
rule = techno.addRule(Name("minArea"), 0.1, Name("ref7"), Name("metal1")) rule = techno.addRule("minArea", 0.1, "ref7", "metal1")
rule.setType(Name("area")) rule.setType("area")
techno.writeToFile("./out.dtr.xml") techno.writeToFile("./out.dtr.xml")

View File

@ -4,19 +4,19 @@ from decimal import Decimal
techno = Techno.readFromFile("./example.dtr.xml") techno = Techno.readFromFile("./example.dtr.xml")
print "+-----------------------------+" print "+-----------------------------+"
print "| technology: "+techno.getName().getString()+" |" print "| technology: "+techno.get) + " |"
print "| units: "+techno.getUnit().getString()+" |" print "| units: "+techno.getUnit() +" |"
print "| version: "+techno.getVersion().getString()+" |" print "| version: "+techno.getVersion()+" |"
print "+-----------------------------+\n\n" print "+-----------------------------+\n\n"
print "transistorMinL = %s"%techno.getValue(Name("transistorMinL")) print "transistorMinL = %s"%techno.getValue("transistorMinL")
print "transistorMinW = %s"%Decimal(techno.getValueAsString(Name("transistorMinW"))) print "transistorMinW = %s"%Decimal(techno.getValueAsString("transistorMinW"))
print "minWidth of metal1 = %s"%techno.getValue(Name("minWidth"), Name("metal1")) print "minWidth of metal1 = %s"%techno.getValue("minWidth", "metal1")
print "minSpacing of metal1 = %s"%techno.getValue(Name("minWidth"), Name("metal1")) print "minSpacing of metal1 = %s"%techno.getValue("minWidth", "metal1")
print "minSpacing of active vs poly = %s"%techno.getValue(Name("minSpacing"), Name("active"), Name("poly")) print "minSpacing of active vs poly = %s"%techno.getValue("minSpacing", "active", "poly")
print "minExtension active over poly = %s"%techno.getValue(Name("minExtension"), Name("poly"), Name("active")) print "minExtension active over poly = %s"%techno.getValue("minExtension", "poly", "active")
print "minArea of metal1 = %s"%techno.getValue(Name("minArea"), Name("metal1")) print "minArea of metal1 = %s"%techno.getValue("minArea", "metal1")
# an example of why it is important to use Decimal in python: # an example of why it is important to use Decimal in python:
print techno.getValue(Name("minArea"), Name("metal1"))*3-0.3 # returns 5.55111512313e-17 print techno.getValue("minArea", "metal1")*3-0.3 # returns 5.55111512313e-17
print Decimal(techno.getValueAsString(Name("minArea"), Name("metal1")))*3-Decimal('0.3') # returns 0.000 print Decimal(techno.getValueAsString("minArea", "metal1"))*3-Decimal('0.3') # returns 0.000

View File

@ -18,12 +18,12 @@ using namespace std;
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
OpenChams::Circuit* circuit = new OpenChams::Circuit(OpenChams::Name("design"), OpenChams::Name("myTech")); OpenChams::Circuit* circuit = new OpenChams::Circuit(OpenChams::Name("design"), OpenChams::Name("myTech"));
// value parameters // value parameters
circuit->addParameter(OpenChams::Name("temp"), 27.0 ); circuit->addParameter(OpenChams::Name("temp"), "27.0" );
circuit->addParameter(OpenChams::Name("Vdd") , 1.2 ); circuit->addParameter(OpenChams::Name("Vdd") , "1.2" );
circuit->addParameter(OpenChams::Name("Vss") , 0.0 ); circuit->addParameter(OpenChams::Name("Vss") , "0.0" );
circuit->addParameter(OpenChams::Name("L") , 0.1e-6); circuit->addParameter(OpenChams::Name("L") , "0.1e-6");
circuit->addParameter(OpenChams::Name("Ids") , 30e-6 ); circuit->addParameter(OpenChams::Name("Ids") , "30e-6" );
circuit->addParameter(OpenChams::Name("Veg") , 0.12 ); circuit->addParameter(OpenChams::Name("Veg") , "0.12" );
// equation parameters // equation parameters
circuit->addParameter(OpenChams::Name("complex"), "myEq"); circuit->addParameter(OpenChams::Name("complex"), "myEq");

View File

@ -90,10 +90,7 @@ int main(int argc, char * argv[]) {
cerr << " + parameters" << endl; cerr << " + parameters" << endl;
OpenChams::Parameters params = circuit->getParameters(); OpenChams::Parameters params = circuit->getParameters();
if (!params.isEmpty()) { if (!params.isEmpty()) {
for (map<OpenChams::Name, double>::const_iterator it = params.getValues().begin() ; it != params.getValues().end() ; ++it) { for (map<OpenChams::Name, string>::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 << " | | " << ((*it).first).getString() << " : " << (*it).second << endl;
} }
} }

View File

@ -2,12 +2,10 @@ INCLUDE_DIRECTORIES(${VLSISAPD_SOURCE_DIR}/src/dtr/src ${LIBXML2_INCLUDE_DIR} ${
SET ( hpps vlsisapd/dtr/Techno.h SET ( hpps vlsisapd/dtr/Techno.h
vlsisapd/dtr/Rules.h vlsisapd/dtr/Rules.h
vlsisapd/dtr/Name.h
vlsisapd/dtr/DTRException.h vlsisapd/dtr/DTRException.h
) )
SET ( cpps Techno.cpp SET ( cpps Techno.cpp
Name.cpp
) )
SET ( pycpps PyDtr.cpp SET ( pycpps PyDtr.cpp

View File

@ -1,65 +0,0 @@
/*
* Name.cpp
* DTR
*
* Created by damien dupuis on 01/04/10.
* Copyright 2010 UPMC / LIP6. All rights reserved.
*
*/
using namespace std;
#include "vlsisapd/dtr/Name.h"
namespace DTR {
unsigned long Name::_globalId = 0;
map<string, unsigned long> Name::_dict;
Name::Name(string str) : _str(NULL) {
map<string, unsigned long>::iterator it = _dict.find(str);
if (it != _dict.end()) {
_id = (*it).second;
_str = &((*it).first);
} else {
_id = _globalId++;
it = _dict.insert(_dict.begin(), make_pair(str, _id));
_str = &((*it).first);
}
}
Name::Name(const char* c) : _str(NULL) {
string str(c);
map<string, unsigned long>::iterator it = _dict.find(str);
if (it != _dict.end()) {
_id = (*it).second;
_str = &((*it).first);
} else {
_id = _globalId++;
it = _dict.insert(_dict.begin(), make_pair(str, _id));
_str = &((*it).first);
}
}
bool Name::operator==(const Name& n) {
return (_id == n._id);
}
bool Name::operator==(const string& str) {
Name n(str);
return (_id == n._id);
}
bool Name::operator!=(const Name& n) {
return (_id != n._id);
}
bool Name::operator!=(const string& str) {
Name n(str);
return (_id != n._id);
}
bool Name::operator<(const Name n) const {
return (_id < n._id);
}
} // namespace

View File

@ -1,3 +1,4 @@
using namespace std; using namespace std;
#include <boost/python.hpp> #include <boost/python.hpp>
@ -7,7 +8,9 @@ using namespace boost::python;
#include "vlsisapd/dtr/Rules.h" #include "vlsisapd/dtr/Rules.h"
#include "vlsisapd/dtr/DTRException.h" #include "vlsisapd/dtr/DTRException.h"
namespace DTR { namespace DTR {
void translator(DTRException const& e) { void translator(DTRException const& e) {
PyErr_SetString(PyExc_UserWarning, e.what()); PyErr_SetString(PyExc_UserWarning, e.what());
} }
@ -20,58 +23,47 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getValueAsString_overloads, getValueAsStr
// specify that Techno::addRule method has optional arguments // specify that Techno::addRule method has optional arguments
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(addRule_overloads, addRule, 3, 5); BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(addRule_overloads, addRule, 3, 5);
BOOST_PYTHON_MODULE(DTR) {
// class DTR::Name
class_<Name>("Name", init<std::string>())
.def("getString", &Name::getString, return_value_policy<copy_const_reference>()) // return_value_policy because this method return a reference on string
.def(self == self)
.def(self == std::string())
.def(self != self)
.def(self != std::string())
.def(self < self)
;
implicitly_convertible<std::string, Name>(); BOOST_PYTHON_MODULE(DTR) {
// class DTR::Rule // class DTR::Rule
class_<Rule>("Rule", init<Name, double, Name, Name, Name>()) class_<Rule>("Rule", init<const char*, double, const char*, const char*, const char*>())
// accessors // Accessors.
.def("getName" , &Rule::getName ) .def("getName" , &Rule::getName , return_value_policy<copy_const_reference>())
.def("getType" , &Rule::getType ) .def("getType" , &Rule::getType , return_value_policy<copy_const_reference>())
.def("getValue" , &Rule::getValue ) .def("getValue" , &Rule::getValue )
.def("getValueAsString", &Rule::getValueAsString, return_value_policy<copy_const_reference>()) .def("getValueAsString", &Rule::getValueAsString, return_value_policy<copy_const_reference>())
.def("getRef" , &Rule::getRef ) .def("getRef" , &Rule::getRef , return_value_policy<copy_const_reference>())
.def("getLayer1" , &Rule::getLayer1 ) .def("getLayer1" , &Rule::getLayer1 , return_value_policy<copy_const_reference>())
.def("getLayer2" , &Rule::getLayer2 ) .def("getLayer2" , &Rule::getLayer2 , return_value_policy<copy_const_reference>())
// Mutators.
// modifiers
.def("setType" , &Rule::setType ) .def("setType" , &Rule::setType )
.def("setValue" , &Rule::setValue ) .def("setValue" , &Rule::setValue )
.def("setRef" , &Rule::setRef ) .def("setRef" , &Rule::setRef )
; ;
// class DTR::ARule derived from DTR::Rule // class DTR::ARule derived from DTR::Rule
class_<ARule, bases<Rule> >("ARule", init<Name, double, Name, Name, Name>()) class_<ARule,bases<Rule> >("ARule", init<const char*, double, const char*, const char*, const char*>())
; ;
// class DTR::Techno // class DTR::Techno
class_<Techno>("Techno", init<Name, Name, Name>()) class_<Techno>("Techno", init<const char*, const char*, const char*>())
// accessors // Accessors
.def("getName" , &Techno::getName) .def("getName" , &Techno::getName , return_value_policy<copy_const_reference>())
.def("getUnit" , &Techno::getUnit) .def("getUnit" , &Techno::getUnit , return_value_policy<copy_const_reference>())
.def("getVersion" , &Techno::getVersion) .def("getVersion" , &Techno::getVersion , return_value_policy<copy_const_reference>())
.def("getRule" , &Techno::getRule , getRule_overloads()[return_value_policy<reference_existing_object>()]) .def("getRule" , &Techno::getRule , getRule_overloads()[return_value_policy<reference_existing_object>()])
.def("getValue" , &Techno::getValue , getValue_overloads()) .def("getValue" , &Techno::getValue , getValue_overloads())
.def("getValueAsString", &Techno::getValueAsString, getValueAsString_overloads()[return_value_policy<copy_const_reference>()]) .def("getValueAsString", &Techno::getValueAsString, getValueAsString_overloads()[return_value_policy<copy_const_reference>()])
// modifiers // Mutators.
.def("setName" , &Techno::setName) .def("setName" , &Techno::setName)
.def("setUnit" , &Techno::setUnit) .def("setUnit" , &Techno::setUnit)
.def("setVersion" , &Techno::setVersion) .def("setVersion" , &Techno::setVersion)
.def("addRule" , &Techno::addRule , addRule_overloads()[return_value_policy<reference_existing_object>()]) .def("addRule" , &Techno::addRule , addRule_overloads()[return_value_policy<reference_existing_object>()])
.def("addARule" , &Techno::addARule, return_value_policy<reference_existing_object>()) .def("addARule" , &Techno::addARule, return_value_policy<reference_existing_object>())
// others // Miscellaneous.
.def("readFromFile", &Techno::readFromFile, return_value_policy<reference_existing_object>()) .def("readFromFile", &Techno::readFromFile, return_value_policy<reference_existing_object>())
.staticmethod("readFromFile") .staticmethod("readFromFile")
.def("writeToFile" , &Techno::writeToFile) .def("writeToFile" , &Techno::writeToFile)
@ -80,5 +72,8 @@ BOOST_PYTHON_MODULE(DTR) {
// DTRException translator // DTRException translator
register_exception_translator<DTRException>(translator) register_exception_translator<DTRException>(translator)
; ;
}
} } // DTR boost::python module.
} // DTR namespace.

View File

@ -1,11 +1,19 @@
/*
* Techno.cpp // -*- C++ -*-
* DTR //
* // This file is part of the VLSI SAPD Software.
* Created by damien dupuis on 01/04/10. // Copyright (c) UPMC/LIP6 2010-2012, All Rights Reserved
* Copyright 2010 UPMC / LIP6. All rights reserved. //
* // +-----------------------------------------------------------------+
*/ // | V L S I S A P D |
// | Design Technological Rules (DTR) |
// | |
// | Author : Damien Dupuis |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./Techno.cpp" |
// +-----------------------------------------------------------------+
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
@ -23,8 +31,12 @@ using namespace std;
#include "vlsisapd/dtr/Rules.h" #include "vlsisapd/dtr/Rules.h"
#include "vlsisapd/dtr/DTRException.h" #include "vlsisapd/dtr/DTRException.h"
namespace { namespace {
template<class T> T getValue(xmlChar* str) {
template<class T> T getValue(xmlChar* str)
{
if (string((const char*)str).empty()) if (string((const char*)str).empty())
return numeric_limits<T>::quiet_NaN(); return numeric_limits<T>::quiet_NaN();
std::istringstream iss; std::istringstream iss;
@ -33,24 +45,56 @@ namespace {
iss >> res; iss >> res;
return res; return res;
} }
}
} // Anonymous namespace.
namespace DTR { namespace DTR {
Techno::Techno(Name name, Name unit, Name version) : _name(name), _unit(unit), _version(version) {}
Rule* Techno::addRule (Name name, double value, Name ref, Name layer1, Name layer2) {
Techno::Techno ( const string& name, const string& unit, const string& version )
: _name (name)
, _unit (unit)
, _version(version)
{ }
Techno::Techno ( const char* name, const char* unit, const char* version )
: _name (name)
, _unit (unit)
, _version((version) ? version : "")
{
// Cannot initialize a std::string from a NULL pointer.
}
Rule* Techno::addRule ( const char* name
, double value
, const char* ref
, const char* layer1
, const char* layer2 )
{
Rule* rule = new Rule(name, value, ref, layer1, layer2); Rule* rule = new Rule(name, value, ref, layer1, layer2);
_rules.push_back(rule); _rules.push_back(rule);
return rule; return rule;
} }
ARule* Techno::addARule (Name name, double value, Name ref, Name layer1, Name layer2) {
ARule* Techno::addARule ( const char* name
, double value
, const char* ref
, const char* layer1
, const char* layer2 )
{
ARule* arule = new ARule(name, value, ref, layer1, layer2); ARule* arule = new ARule(name, value, ref, layer1, layer2);
_rules.push_back(arule); _rules.push_back(arule);
return arule; return arule;
} }
Rule* Techno::getRule(Name name, Name layer1, Name layer2) {
Rule* Techno::getRule ( const char* name, const char* layer1, const char* layer2 )
{
for (size_t i = 0 ; i < _rules.size() ; i++) { for (size_t i = 0 ; i < _rules.size() ; i++) {
Rule* rule = _rules[i]; Rule* rule = _rules[i];
if ((rule->getName() == name) && (rule->getLayer1() == layer1) && (rule->getLayer2() == layer2)) if ((rule->getName() == name) && (rule->getLayer1() == layer1) && (rule->getLayer2() == layer2))
@ -59,33 +103,43 @@ Rule* Techno::getRule(Name name, Name layer1, Name layer2) {
return NULL; return NULL;
} }
double Techno::getValue(Name name, Name layer1, Name layer2) {
double Techno::getValue ( const char* name, const char* layer1, const char* layer2 )
{
Rule* r = getRule(name, layer1, layer2); Rule* r = getRule(name, layer1, layer2);
if(!r) { if(!r) {
string error = "[ERROR] Could not find rule: " + name.getString() + "." + layer1.getString() + "." + layer2.getString() + "."; ostringstream error;
throw DTRException(error); error << "[ERROR] Could not find rule: " << name << "." << layer1 << "." << layer2 << ".";
throw DTRException(error.str());
} }
return r->getValue(); return r->getValue();
} }
const string& Techno::getValueAsString(Name name, Name layer1, Name layer2) {
const string& Techno::getValueAsString ( const char* name, const char* layer1, const char* layer2 )
{
Rule* r = getRule(name, layer1, layer2); Rule* r = getRule(name, layer1, layer2);
if(!r) { if(!r) {
string error = "[ERROR] Could not find rule: " + name.getString() + "." + layer1.getString() + "." + layer2.getString() + "."; ostringstream error;
throw DTRException(error); error << "[ERROR] Could not find rule: " << name << "." << layer1 << "." << layer2 << ".";
throw DTRException(error.str());
} }
return r->getValueAsString(); return r->getValueAsString();
} }
Techno* Techno::readFromFile(const string filePath) {
Techno* Techno::readFromFile ( const char* filePath )
{
LIBXML_TEST_VERSION; LIBXML_TEST_VERSION;
Techno* techno = NULL; Techno* techno = NULL;
xmlDoc* doc = xmlReadFile(filePath.c_str(), NULL, 0); xmlDoc* doc = xmlReadFile(filePath, NULL, 0);
if (doc == NULL) { if (doc == NULL) {
string error ("[ERROR] Failed to parse: "); string error ("[ERROR] Failed to parse: ");
error += filePath; error += filePath;
throw DTRException(error); throw DTRException(error);
} }
xmlNode* rootElement = xmlDocGetRootElement(doc); xmlNode* rootElement = xmlDocGetRootElement(doc);
if (rootElement->type == XML_ELEMENT_NODE && xmlStrEqual(rootElement->name, (xmlChar*)"technology")) { if (rootElement->type == XML_ELEMENT_NODE && xmlStrEqual(rootElement->name, (xmlChar*)"technology")) {
xmlChar* technoNameC = xmlGetProp(rootElement, (xmlChar*)"name"); xmlChar* technoNameC = xmlGetProp(rootElement, (xmlChar*)"name");
@ -93,18 +147,12 @@ Techno* Techno::readFromFile(const string filePath) {
xmlChar* technoVersC = xmlGetProp(rootElement, (xmlChar*)"version"); xmlChar* technoVersC = xmlGetProp(rootElement, (xmlChar*)"version");
if (technoNameC && technoUnitC) { if (technoNameC && technoUnitC) {
Name name ((const char*)technoNameC); techno = new Techno((char*)technoNameC, (char*)technoUnitC, (char*)technoVersC);
Name unit ((const char*)technoUnitC);
Name vers = Name("");
if (technoVersC)
vers = Name((const char*)technoVersC);
techno = new Techno(name, unit, vers);
} else { } else {
throw DTRException("[ERROR] 'technology' node must have 'name' and 'unit' properties."); throw DTRException("[ERROR] 'technology' node must have 'name' and 'unit' properties.");
return NULL; return NULL;
} }
xmlNode* child = rootElement->children; xmlNode* child = rootElement->children;
for (xmlNode* node = child; node; node = node->next) { for (xmlNode* node = child; node; node = node->next) {
if (node->type == XML_ELEMENT_NODE) { if (node->type == XML_ELEMENT_NODE) {
@ -112,6 +160,7 @@ Techno* Techno::readFromFile(const string filePath) {
throw DTRException("[ERROR] only 'physical_rules' node is allowed under 'technology' node."); throw DTRException("[ERROR] only 'physical_rules' node is allowed under 'technology' node.");
return NULL; return NULL;
} }
for (xmlNode* subnode = node->children ; subnode ; subnode = subnode->next) { for (xmlNode* subnode = node->children ; subnode ; subnode = subnode->next) {
if (subnode->type == XML_ELEMENT_NODE) { if (subnode->type == XML_ELEMENT_NODE) {
if (xmlStrEqual(subnode->name, (xmlChar*)"rule")) { if (xmlStrEqual(subnode->name, (xmlChar*)"rule")) {
@ -124,31 +173,32 @@ Techno* Techno::readFromFile(const string filePath) {
xmlChar* typeC = xmlGetProp(subnode, (xmlChar*)"type" ); xmlChar* typeC = xmlGetProp(subnode, (xmlChar*)"type" );
Rule* rule = NULL; Rule* rule = NULL;
if (nameC && layer1C && layer2C && valueC && refC) { // rule with two layers if (nameC and layer1C and layer2C and valueC and refC) {
Name name ((const char*)nameC); // Rule with two layers
Name ref ((const char*)refC); rule = techno->addRule( (char*)nameC
Name layer1 ((const char*)layer1C); , ::getValue<double>(valueC)
Name layer2 ((const char*)layer2C); , (char*)refC
double value = ::getValue<double>(valueC); , (char*)layer1C
rule = techno->addRule(name, value, ref, layer1, layer2); , (char*)layer2C );
} else if (nameC && layerC && valueC && refC) {// rule with only one layer } else if (nameC and layerC and valueC and refC) {
Name name ((const char*)nameC); // Rule with only one layer
Name ref ((const char*)refC); rule = techno->addRule( (char*)nameC
Name layer ((const char*)layerC); , ::getValue<double>(valueC)
double value = ::getValue<double>(valueC); , (char*)refC
rule = techno->addRule(name, value, ref, layer); , (char*)layerC );
} else if (nameC && valueC && refC) { // rule without layer } else if (nameC and valueC and refC) {
Name name ((const char*)nameC); // Rule without layer
Name ref ((const char*)refC); rule = techno->addRule( (char*)nameC
double value = ::getValue<double>(valueC); , ::getValue<double>(valueC)
rule = techno->addRule(name, value, ref); , (char*)refC );
} else { // invalid case } else {
// Invalid case
throw DTRException("[ERROR] properties of 'rule' node must be ('name', 'value', 'ref') or ('name', 'layer', 'value', 'ref') or ('name', 'layer1', 'layer2', 'value', 'ref')."); throw DTRException("[ERROR] properties of 'rule' node must be ('name', 'value', 'ref') or ('name', 'layer', 'value', 'ref') or ('name', 'layer1', 'layer2', 'value', 'ref').");
return NULL; return NULL;
} }
if (typeC) { if (typeC) {
Name type ((const char*)typeC); rule->setType((const char*)typeC);
rule->setType(type);
} }
} else if (xmlStrEqual(subnode->name, (xmlChar*)"arule")) { } else if (xmlStrEqual(subnode->name, (xmlChar*)"arule")) {
xmlChar* nameC = xmlGetProp(subnode, (xmlChar*)"name" ); xmlChar* nameC = xmlGetProp(subnode, (xmlChar*)"name" );
@ -156,13 +206,13 @@ Techno* Techno::readFromFile(const string filePath) {
xmlChar* layer2C = xmlGetProp(subnode, (xmlChar*)"layer2"); xmlChar* layer2C = xmlGetProp(subnode, (xmlChar*)"layer2");
xmlChar* valueC = xmlGetProp(subnode, (xmlChar*)"value" ); xmlChar* valueC = xmlGetProp(subnode, (xmlChar*)"value" );
xmlChar* refC = xmlGetProp(subnode, (xmlChar*)"ref" ); xmlChar* refC = xmlGetProp(subnode, (xmlChar*)"ref" );
if (nameC && layer1C && layer2C && valueC && refC) { if (nameC && layer1C && layer2C && valueC && refC) {
Name name ((const char*)nameC); techno->addARule( (char*)nameC
Name layer1 ((const char*)layer1C); , ::getValue<double>(valueC)
Name layer2 ((const char*)layer2C); , (char*)refC
Name ref ((const char*)refC); , (char*)layer1C
double value = ::getValue<double>(valueC); , (char*)layer2C );
techno->addARule(name, value, ref, layer1, layer2);
} else { } else {
throw DTRException("[ERROR] 'arule' node must have 'name', 'layer1', 'layer2', 'value' and 'ref' properties."); throw DTRException("[ERROR] 'arule' node must have 'name', 'layer1', 'layer2', 'value' and 'ref' properties.");
return NULL; return NULL;
@ -178,42 +228,45 @@ Techno* Techno::readFromFile(const string filePath) {
return techno; return techno;
} }
bool Techno::writeToFile(string filePath) {
bool Techno::writeToFile ( const char* filePath )
{
ofstream file; ofstream file;
file.open(filePath.c_str()); file.open(filePath);
if (!file.is_open()) { if (!file.is_open()) {
string error("[ERROR] Cannot open file "); string error("[ERROR] Cannot open file ");
error += filePath; error += filePath;
error += " for writting."; error += " for writting.";
throw DTRException(error); throw DTRException(error);
} }
// checks before do anything // checks before do anything
if (_rules.size() == 0) { if (_rules.size() == 0) {
throw DTRException("[ERROR] Cannot writeToFile since no rule is defined!"); throw DTRException("[ERROR] Cannot writeToFile since no rule is defined!");
} }
file << "<technology name=\"" << _name.getString() << "\" unit=\"" << _unit.getString() << "\" version=\"" << _version.getString() << "\">" << endl file << "<technology name=\"" << _name << "\" unit=\"" << _unit << "\" version=\"" << _version << "\">" << endl
<< " <physical_rules>" << endl; << " <physical_rules>" << endl;
file.setf(ios::left, ios::adjustfield); file.setf(ios::left, ios::adjustfield);
for (size_t i = 0 ; i < _rules.size() ; i++) { for (size_t i = 0 ; i < _rules.size() ; i++) {
Rule* rule = _rules[i]; Rule* rule = _rules[i];
string name = "\""+rule->getName().getString()+"\""; string name = "\""+rule->getName()+"\"";
if (dynamic_cast<ARule*>(rule)) { if (dynamic_cast<ARule*>(rule)) {
file << " <arule name=" << setw(20) << name << " "; file << " <arule name=" << setw(20) << name << " ";
} else { } else {
file << " <rule name=" << setw(20) << name << " "; file << " <rule name=" << setw(20) << name << " ";
} }
int spacing = 18; int spacing = 18;
if (rule->getType() != Name("")) { if (not rule->getType().empty()) {
string type = "\""+rule->getType().getString()+"\""; string type = "\""+rule->getType()+"\"";
file << "type=" << setw(12) << type << " "; file << "type=" << setw(12) << type << " ";
spacing = 0; spacing = 0;
} }
if (rule->getLayer1() != Name("")) { if (not rule->getLayer1().empty()) {
string l1 = "\""+rule->getLayer1().getString()+"\""; string l1 = "\""+rule->getLayer1()+"\"";
if (rule->getLayer2() != Name("")) { if (not rule->getLayer2().empty()) {
string l2 = "\""+rule->getLayer2().getString()+"\""; string l2 = "\""+rule->getLayer2()+"\"";
file << "layer1=" << setw(10) << l1 << " layer2=" << setw(10) << l2 << " "; file << "layer1=" << setw(10) << l1 << " layer2=" << setw(10) << l2 << " ";
} else { } else {
file << "layer=" << setw(11+spacing) << l1 << " "; file << "layer=" << setw(11+spacing) << l1 << " ";
@ -221,9 +274,10 @@ bool Techno::writeToFile(string filePath) {
} else { } else {
file << setw(36) << " "; file << setw(36) << " ";
} }
ostringstream oss; ostringstream oss;
oss << "\"" << rule->getValue() <<"\""; oss << "\"" << rule->getValue() <<"\"";
file << "value=" << setw(7) << oss.str() << " ref=\"" << rule->getRef().getString() << "\"/>" << endl; file << "value=" << setw(7) << oss.str() << " ref=\"" << rule->getRef() << "\"/>" << endl;
} }
file << " </physical_rules>" << endl file << " </physical_rules>" << endl
<< "</technology>" << endl; << "</technology>" << endl;
@ -231,5 +285,6 @@ bool Techno::writeToFile(string filePath) {
return true; return true;
} }
}
} // DTR namespace.

View File

@ -1,11 +1,19 @@
/*
* DTRException.h // -*- C++ -*-
* DTR //
* // This file is part of the VLSI SAPD Software.
* Created by damien dupuis on 01/04/10. // Copyright (c) UPMC/LIP6 2010-2012, All Rights Reserved
* Copyright 2010 UPMC / LIP6. All rights reserved. //
* // +-----------------------------------------------------------------+
*/ // | V L S I S A P D |
// | Design Technological Rules (DTR) |
// | |
// | Author : Damien Dupuis |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./vlsisapd/dtr/Rule.h" |
// +-----------------------------------------------------------------+
#ifndef __DTR_EXCEPTION_H__ #ifndef __DTR_EXCEPTION_H__
#define __DTR_EXCEPTION_H__ #define __DTR_EXCEPTION_H__
@ -13,16 +21,26 @@
#include <exception> #include <exception>
#include <string> #include <string>
namespace DTR { namespace DTR {
class DTRException { class DTRException {
public: public:
DTRException(const std::string& what) throw() : _what(what) {} inline DTRException (const std::string& what) throw();
virtual const char* what() const throw() { return _what.c_str(); } inline virtual ~DTRException () throw();
virtual ~DTRException() throw() {} inline virtual const char* what () const throw();
private: private:
std::string _what; std::string _what;
}; };
} // namespace
inline DTRException::DTRException ( const std::string& what ) throw() : _what(what) {}
inline DTRException::~DTRException () throw() {}
inline const char* DTRException::what () const throw() { return _what.c_str(); }
} // DTR namespace.
#endif #endif

View File

@ -1,49 +0,0 @@
/*
* Name.h
* DTR
*
* Created by damien dupuis on 01/04/10.
* Copyright 2010 UPMC / LIP6. All rights reserved.
*
*/
#ifndef __DTR_NAME_H__
#define __DTR_NAME_H__
#include <string>
#include <map>
#include "vlsisapd/dtr/DTRException.h"
namespace DTR {
class Name {
public:
Name(std::string);
Name(const char*);
bool operator==(const Name&);
bool operator==(const std::string&);
bool operator!=(const Name&);
bool operator!=(const std::string&);
bool operator<(const Name) const;
inline const std::string& getString() const;
private:
unsigned long _id;
const std::string *_str;
static std::map<std::string, unsigned long> _dict;
static unsigned long _globalId;
};
inline const std::string& Name::getString() const{
if (!_str) {
throw DTRException("[ERROR] Name object has no string");
}
return *_str;
}
} // namespace
#endif

View File

@ -1,11 +1,19 @@
/*
* Rules.h // -*- C++ -*-
* DTR //
* // This file is part of the VLSI SAPD Software.
* Created by damien dupuis on 01/04/10. // Copyright (c) UPMC/LIP6 2010-2012, All Rights Reserved
* Copyright 2010 UPMC / LIP6 All rights reserved. //
* // +-----------------------------------------------------------------+
*/ // | V L S I S A P D |
// | Design Technological Rules (DTR) |
// | |
// | Author : Damien Dupuis |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./vlsisapd/dtr/Rule.h" |
// +-----------------------------------------------------------------+
#ifndef __DTR_RULES_H__ #ifndef __DTR_RULES_H__
#define __DTR_RULES_H__ #define __DTR_RULES_H__
@ -13,67 +21,99 @@
#include <string> #include <string>
#include <sstream> #include <sstream>
#include "vlsisapd/dtr/Name.h"
namespace DTR { namespace DTR {
template<typename T> template<typename T>
std::string to_string(T const& value) { inline std::string asString ( T value )
std::stringstream sstr; { std::ostringstream output; output << value; return output.str(); }
sstr << value;
return sstr.str();
}
class Rule { class Rule {
public: public:
Rule(Name name, double value, Name ref, Name layer1, Name layer2) // CTOR & DTOR.
: _name(name), _type(Name("")), _value(value), _valueStr(to_string(value)), _ref(ref), _layer1(layer1), _layer2(layer2) {}; inline Rule ( const char* name
, double value
virtual ~Rule() {} , const char* ref
, const char* layer1
// accessors , const char* layer2 );
inline Name getName(); inline virtual ~Rule ();
inline Name getType(); // Accessors.
inline const std::string& getName ();
inline const std::string& getType ();
inline double getValue (); inline double getValue ();
inline const std::string& getValueAsString (); inline const std::string& getValueAsString ();
inline Name getRef(); inline const std::string& getRef ();
inline Name getLayer1(); inline const std::string& getLayer1 ();
virtual inline Name getLayer2(); // add virtual so the Rule object is polymorphic inline virtual const std::string& getLayer2 ();
// Modifiers
// modifiers inline void setType ( const char* );
inline void setType(Name);
inline void setValue ( double ); inline void setValue ( double );
inline void setRef(Name); inline void setRef ( const char* );
// members // Attributes.
private: private:
Name _name; std::string _name;
Name _type; std::string _type;
double _value; double _value;
Name _valueStr; std::string _valueStr;
Name _ref; std::string _ref;
Name _layer1; std::string _layer1;
Name _layer2; std::string _layer2;
}; };
class ARule : public Rule { class ARule : public Rule {
public: public:
ARule(Name name, double value, Name ref, Name layer1, Name layer2) inline ARule ( const char* name
: Rule(name, value, ref, layer1, layer2) {}; , double value
, const char* ref
virtual ~ARule() {} , const char* layer1
, const char* layer2 );
inline virtual ~ARule ();
}; };
inline Name Rule::getName() { return _name; };
inline Name Rule::getType() { return _type; };
inline double Rule::getValue() { return _value; };
inline Name Rule::getRef() { return _ref; };
inline Name Rule::getLayer1() { return _layer1; };
inline Name Rule::getLayer2() { return _layer2; };
inline const std::string& Rule::getValueAsString() { return _valueStr.getString(); };
inline void Rule::setType(Name type) { _type = type; }; inline Rule::Rule ( const char* name
inline void Rule::setValue(double value) { _value = value; _valueStr = to_string(value); }; , double value
inline void Rule::setRef(Name ref) { _ref = ref; }; , const char* ref
, const char* layer1
, const char* layer2 )
: _name (name)
, _type ("")
, _value (value)
, _valueStr(asString(value))
, _ref (ref)
, _layer1 (layer1)
, _layer2 (layer2)
{ }
inline Rule::~Rule ()
{ }
inline const std::string& Rule::getName () { return _name; };
inline const std::string& Rule::getType () { return _type; };
inline double Rule::getValue () { return _value; };
inline const std::string& Rule::getRef () { return _ref; };
inline const std::string& Rule::getLayer1 () { return _layer1; };
inline const std::string& Rule::getLayer2 () { return _layer2; };
inline const std::string& Rule::getValueAsString () { return _valueStr; };
inline void Rule::setType ( const char* type ) { _type=type; };
inline void Rule::setValue ( double value ) { _value=value; _valueStr=asString(value); };
inline void Rule::setRef ( const char* ref ) { _ref=ref; };
inline ARule::ARule ( const char* name
, double value
, const char* ref
, const char* layer1
, const char* layer2 )
: Rule(name, value, ref, layer1, layer2)
{ }
inline ARule::~ARule ()
{ }
} // namespace DTR } // namespace DTR
#endif #endif

View File

@ -1,63 +1,87 @@
/*
* Techno.h // -*- C++ -*-
* DTR //
* // This file is part of the VLSI SAPD Software.
* Created by damien dupuis on 01/04/10. // Copyright (c) UPMC/LIP6 2010-2012, All Rights Reserved
* Copyright 2010 UPMC / LIP6 All rights reserved. //
* // +-----------------------------------------------------------------+
*/ // | V L S I S A P D |
// | Design Technological Rules (DTR) |
// | |
// | Author : Damien Dupuis |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./vlsisapd/dtr/Techno.h" |
// +-----------------------------------------------------------------+
#ifndef __DTR_TECHNO_H__ #ifndef __DTR_TECHNO_H__
#define __DTR_TECHNO_H__ #define __DTR_TECHNO_H__
#include <vector> #include <vector>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include "vlsisapd/dtr/Name.h"
namespace DTR { namespace DTR {
class Rule; class Rule;
class ARule; class ARule;
class Techno { class Techno {
public: public:
Techno(Name name, Name unit, Name version); Techno ( const std::string& name
, const std::string& unit
inline Name getName(); , const std::string& version );
inline Name getUnit(); Techno ( const char* name
inline Name getVersion(); , const char* unit
, const char* version );
inline const std::string& getName () const;
inline const std::string& getUnit () const;
inline const std::string& getVersion () const;
inline std::vector<Rule*>& getRules (); inline std::vector<Rule*>& getRules ();
inline void setName(Name); inline void setName ( const std::string&);
inline void setUnit(Name); inline void setUnit ( const std::string&);
inline void setVersion(Name); inline void setVersion ( const std::string&);
Rule* addRule ( const char* name
Rule* addRule (Name name, double value, Name ref, Name layer1=Name(""), Name layer2=Name("")); , double value
ARule* addARule(Name name, double value, Name ref, Name layer1 , Name layer2); , const char* ref
, const char* layer1=""
Rule* getRule(Name name, Name layer1=Name(""), Name layer2=Name("")); , const char* layer2="" );
double getValue(Name name, Name layer1=Name(""), Name layer2=Name("")); ARule* addARule ( const char* name
const std::string& getValueAsString(Name name, Name layer1=Name(""), Name layer2=Name("")); , double value
, const char* ref
bool writeToFile(std::string filePath); , const char* layer1
static Techno* readFromFile(const std::string filePath); , const char* layer2 );
Rule* getRule ( const char* name
Name _name; , const char* layer1=""
Name _unit; , const char* layer2="" );
Name _version; double getValue ( const char* name
, const char* layer1=""
, const char* layer2="" );
const std::string& getValueAsString ( const char* name
, const char* layer1=""
, const char* layer2="" );
bool writeToFile ( const char* filePath );
static Techno* readFromFile ( const char* filePath );
private:
std::string _name;
std::string _unit;
std::string _version;
std::vector<Rule*> _rules; std::vector<Rule*> _rules;
}; };
inline Name Techno::getName() { return _name; };
inline Name Techno::getUnit() { return _unit; }; inline const std::string& Techno::getName () const { return _name; };
inline Name Techno::getVersion() { return _version; }; inline const std::string& Techno::getUnit () const { return _unit; };
inline const std::string& Techno::getVersion() const { return _version; };
inline std::vector<Rule*>& Techno::getRules () { return _rules; }; inline std::vector<Rule*>& Techno::getRules () { return _rules; };
inline void Techno::setName (const std::string& name) { _name = name; };
inline void Techno::setUnit (const std::string& unit) { _unit = unit; };
inline void Techno::setVersion(const std::string& version) { _version = version; };
inline void Techno::setName (Name name) { _name = name; };
inline void Techno::setUnit (Name unit) { _unit = unit; };
inline void Techno::setVersion(Name version) { _version = version; };
} // namespace DTR } // namespace DTR.
#endif #endif