From 5fc116f4b7a8a6f9b11cc575817edf00abb82ace Mon Sep 17 00:00:00 2001 From: Damien Dupuis Date: Tue, 15 Jun 2010 08:58:29 +0000 Subject: [PATCH] adding examples for DTR format --- vlsisapd/examples/CMakeLists.txt | 1 + vlsisapd/examples/dtr/CMakeLists.txt | 4 +++ .../examples/dtr/cplusplus/CMakeLists.txt | 8 ++++++ vlsisapd/examples/dtr/cplusplus/cmake.ex | 19 ++++++++++++++ vlsisapd/examples/dtr/cplusplus/driveDtr.cpp | 25 ++++++++++++++++++ vlsisapd/examples/dtr/cplusplus/parseDtr.cpp | 26 +++++++++++++++++++ vlsisapd/examples/dtr/example.dtr.xml | 21 +++++++++++++++ vlsisapd/examples/dtr/python/CMakeLists.txt | 1 + vlsisapd/examples/dtr/python/driveDtr.py | 16 ++++++++++++ vlsisapd/examples/dtr/python/parseDtr.py | 21 +++++++++++++++ 10 files changed, 142 insertions(+) create mode 100644 vlsisapd/examples/dtr/CMakeLists.txt create mode 100644 vlsisapd/examples/dtr/cplusplus/CMakeLists.txt create mode 100644 vlsisapd/examples/dtr/cplusplus/cmake.ex create mode 100644 vlsisapd/examples/dtr/cplusplus/driveDtr.cpp create mode 100644 vlsisapd/examples/dtr/cplusplus/parseDtr.cpp create mode 100644 vlsisapd/examples/dtr/example.dtr.xml create mode 100644 vlsisapd/examples/dtr/python/CMakeLists.txt create mode 100644 vlsisapd/examples/dtr/python/driveDtr.py create mode 100644 vlsisapd/examples/dtr/python/parseDtr.py diff --git a/vlsisapd/examples/CMakeLists.txt b/vlsisapd/examples/CMakeLists.txt index 2246d576..62d94d73 100644 --- a/vlsisapd/examples/CMakeLists.txt +++ b/vlsisapd/examples/CMakeLists.txt @@ -1,2 +1,3 @@ ADD_SUBDIRECTORY(cif) ADD_SUBDIRECTORY(agds) +ADD_SUBDIRECTORY(dtr) diff --git a/vlsisapd/examples/dtr/CMakeLists.txt b/vlsisapd/examples/dtr/CMakeLists.txt new file mode 100644 index 00000000..ea1ef6c9 --- /dev/null +++ b/vlsisapd/examples/dtr/CMakeLists.txt @@ -0,0 +1,4 @@ +ADD_SUBDIRECTORY(cplusplus) +ADD_SUBDIRECTORY(python) + +INSTALL ( FILES example.dtr.xml DESTINATION share/doc/coriolis2/examples/vlsisapd/dtr ) diff --git a/vlsisapd/examples/dtr/cplusplus/CMakeLists.txt b/vlsisapd/examples/dtr/cplusplus/CMakeLists.txt new file mode 100644 index 00000000..31568b8d --- /dev/null +++ b/vlsisapd/examples/dtr/cplusplus/CMakeLists.txt @@ -0,0 +1,8 @@ +INCLUDE_DIRECTORIES ( ${VLSISAPD_SOURCE_DIR}/src/dtr/src ${LIBXML2_INCLUDE_DIR}) +ADD_EXECUTABLE ( driveDtr driveDtr.cpp ) +ADD_EXECUTABLE ( parseDtr parseDtr.cpp ) +TARGET_LINK_LIBRARIES ( driveDtr dtr ${LIBXML_LIBRARIES}) # 'driveDtr' is the name of the executable and 'dtr' the name of the target library in dtr/src/CMakeLists.txt +TARGET_LINK_LIBRARIES ( parseDtr dtr ${LIBXML_LIBRARIES}) +INSTALL ( TARGETS driveDtr parseDtr DESTINATION share/doc/coriolis2/examples/vlsisapd/dtr ) +INSTALL ( FILES driveDtr.cpp parseDtr.cpp DESTINATION share/doc/coriolis2/examples/vlsisapd/dtr ) +INSTALL ( FILES cmake.ex DESTINATION share/doc/coriolis2/examples/vlsisapd/dtr RENAME CMakeLists.txt ) diff --git a/vlsisapd/examples/dtr/cplusplus/cmake.ex b/vlsisapd/examples/dtr/cplusplus/cmake.ex new file mode 100644 index 00000000..e83b47ad --- /dev/null +++ b/vlsisapd/examples/dtr/cplusplus/cmake.ex @@ -0,0 +1,19 @@ +PROJECT(PARSEDRIVEDTR) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0) + +SET(CMAKE_MODULE_PATH "$ENV{VLSISAPD_USER_TOP}/share/cmake/Modules" + "$ENV{VLSISAPD_TOP}/share/cmake/Modules" + ) + +FIND_PACKAGE(VLSISAPD REQUIRED) +FIND_PACKAGE(Libxml2 REQUIRED) + +IF(DTR_FOUND) + INCLUDE_DIRECTORIES(${DTR_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}) + ADD_EXECUTABLE(driveDtr driveDtr.cpp) + ADD_EXECUTABLE(parseDtr parseDtr.cpp) + TARGET_LINK_LIBRARIES(driveDtr ${DTR_LIBRARY} ${LIBXML2_LIBRARIES}) + TARGET_LINK_LIBRARIES(parseDtr ${DTR_LIBRARY} ${LIBXML2_LIBRARIES}) + INSTALL(TARGETS driveDtr parseDtr DESTINATION .) +ENDIF(DTR_FOUND) diff --git a/vlsisapd/examples/dtr/cplusplus/driveDtr.cpp b/vlsisapd/examples/dtr/cplusplus/driveDtr.cpp new file mode 100644 index 00000000..e33d74e3 --- /dev/null +++ b/vlsisapd/examples/dtr/cplusplus/driveDtr.cpp @@ -0,0 +1,25 @@ +#include +using namespace std; + +#include "vlsisapd/dtr/Techno.h" +#include "vlsisapd/dtr/Rules.h" +#include "vlsisapd/dtr/Name.h" + +int main(int argc, char * argv[]) { + DTR::Techno* techno = new DTR::Techno(DTR::Name("MyTech"), DTR::Name("micro")); + + techno->addRule (DTR::Name("transistorMinL"), 0.1 , DTR::Name("0.10"), DTR::Name("ref1")); + techno->addRule (DTR::Name("transistorMinW"), 0.2 , DTR::Name("0.20"), DTR::Name("ref2")); + techno->addRule (DTR::Name("minWidth") , 0.15, DTR::Name("0.15"), DTR::Name("ref3"), DTR::Name("metal1")); + techno->addRule (DTR::Name("minSpacing") , 0.2 , DTR::Name("0.20"), DTR::Name("ref4"), DTR::Name("metal1")); + techno->addRule (DTR::Name("minSpacing") , 0.1 , DTR::Name("0.10"), DTR::Name("ref5"), DTR::Name("active"), DTR::Name("poly")); + techno->addARule(DTR::Name("minExtension") , 0.2 , DTR::Name("0.20"), DTR::Name("ref6"), DTR::Name("poly") , DTR::Name("active")); + + DTR::Rule* rule = techno->addRule(DTR::Name("minArea"), 0.1, DTR::Name("0.10"), DTR::Name("ref7"), DTR::Name("metal1")); + rule->setType(DTR::Name("area")); + + techno->writeToFile("./out.dtr.xml"); + + return 0; +} + diff --git a/vlsisapd/examples/dtr/cplusplus/parseDtr.cpp b/vlsisapd/examples/dtr/cplusplus/parseDtr.cpp new file mode 100644 index 00000000..f760cc4d --- /dev/null +++ b/vlsisapd/examples/dtr/cplusplus/parseDtr.cpp @@ -0,0 +1,26 @@ +#include +#include +using namespace std; + +#include "vlsisapd/dtr/Techno.h" +#include "vlsisapd/dtr/Name.h" + +int main(int argc, char * argv[]) { + DTR::Techno* techno = DTR::Techno::readFromFile("./example.dtr.xml"); + + cerr << "+-----------------------------+" << endl + << "| technology: " << techno->getName().getString() << " |" << endl + << "| units: " << techno->getUnit().getString() << " |" << endl + << "+-----------------------------+" << endl << endl; + + cerr << "transistorMinL = " << techno->getValue(DTR::Name("transistorMinL")) << endl + << "transistorMinW = " << techno->getValueAsString(DTR::Name("transistorMinW")) << endl + << "minWidth of metal1 = " << techno->getValue(DTR::Name("minWidth"), DTR::Name("metal1")) << endl + << "minSpacing of metal1 = " << techno->getValue(DTR::Name("minWidth"), DTR::Name("metal1")) << endl + << "minSpacing of active vs poly = " << techno->getValue(DTR::Name("minSpacing"), DTR::Name("active"), DTR::Name("poly")) << endl + << "minExtension active over poly = " << techno->getValue(DTR::Name("minExtension"), DTR::Name("poly"), DTR::Name("active")) << endl + << "minArea of metal1 = " << techno->getValue(DTR::Name("minArea"), DTR::Name("metal1")) << endl; + + return 0; +} + diff --git a/vlsisapd/examples/dtr/example.dtr.xml b/vlsisapd/examples/dtr/example.dtr.xml new file mode 100644 index 00000000..fb0d5602 --- /dev/null +++ b/vlsisapd/examples/dtr/example.dtr.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/vlsisapd/examples/dtr/python/CMakeLists.txt b/vlsisapd/examples/dtr/python/CMakeLists.txt new file mode 100644 index 00000000..9208e576 --- /dev/null +++ b/vlsisapd/examples/dtr/python/CMakeLists.txt @@ -0,0 +1 @@ +INSTALL ( FILES driveDtr.py parseDtr.py DESTINATION share/doc/coriolis2/examples/vlsisapd/dtr ) diff --git a/vlsisapd/examples/dtr/python/driveDtr.py b/vlsisapd/examples/dtr/python/driveDtr.py new file mode 100644 index 00000000..e5258135 --- /dev/null +++ b/vlsisapd/examples/dtr/python/driveDtr.py @@ -0,0 +1,16 @@ +from pyDTR import * +import sys + +techno = Techno(Name("myTech"), Name("micro")) + +techno.addRule (Name("transistorMinL"), 0.1 , Name("0.10"), Name("ref1")) +techno.addRule (Name("transistorMinW"), 0.2 , Name("0.20"), Name("ref2")) +techno.addRule (Name("minWidth") , 0.15, Name("0.15"), Name("ref3"), Name("metal1")) +techno.addRule (Name("minSpacing") , 0.2 , Name("0.20"), Name("ref4"), Name("metal1")) +techno.addRule (Name("minSpacing") , 0.1 , Name("0.10"), Name("ref5"), Name("active"), Name("poly")) +techno.addARule(Name("minExtension") , 0.2 , Name("0.20"), Name("ref6"), Name("poly"), Name("active")) + +rule = techno.addRule(Name("minArea"), 0.1, Name("0.10"), Name("ref7"), Name("metal1")) +rule.setType(Name("area")) + +techno.writeToFile("./out.dtr.xml") diff --git a/vlsisapd/examples/dtr/python/parseDtr.py b/vlsisapd/examples/dtr/python/parseDtr.py new file mode 100644 index 00000000..e07ff615 --- /dev/null +++ b/vlsisapd/examples/dtr/python/parseDtr.py @@ -0,0 +1,21 @@ +from pyDTR import * +from decimal import Decimal + +techno = Techno.readFromFile("./example.dtr.xml") + +print "+-----------------------------+" +print "| technology: "+techno.getName().getString()+" |" +print "| units: "+techno.getUnit().getString()+" |" +print "+-----------------------------+\n\n" + +print "transistorMinL = %s"%techno.getValue(Name("transistorMinL")) +print "transistorMinW = %s"%Decimal(techno.getValueAsString(Name("transistorMinW"))) +print "minWidth of metal1 = %s"%techno.getValue(Name("minWidth"), Name("metal1")) +print "minSpacing of metal1 = %s"%techno.getValue(Name("minWidth"), Name("metal1")) +print "minSpacing of active vs poly = %s"%techno.getValue(Name("minSpacing"), Name("active"), Name("poly")) +print "minExtension active over poly = %s"%techno.getValue(Name("minExtension"), Name("poly"), Name("active")) +print "minArea of metal1 = %s"%techno.getValue(Name("minArea"), Name("metal1")) + +# 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 Decimal(techno.getValueAsString(Name("minArea"), Name("metal1")))*3-Decimal('0.3') # returns 0.000