diff --git a/vlsisapd/CMakeLists.txt b/vlsisapd/CMakeLists.txt index 76d8e414..be409acb 100644 --- a/vlsisapd/CMakeLists.txt +++ b/vlsisapd/CMakeLists.txt @@ -7,5 +7,6 @@ SET(CMAKE_MODULE_PATH "${IO_SOURCE_DIR}/cmake_modules/") FIND_PACKAGE(LibXml2 REQUIRED) ADD_SUBDIRECTORY(agds) +ADD_SUBDIRECTORY(cif) ADD_SUBDIRECTORY(openChams) ADD_SUBDIRECTORY(cmake_modules) diff --git a/vlsisapd/cif/CMakeLists.txt b/vlsisapd/cif/CMakeLists.txt new file mode 100644 index 00000000..69fcf807 --- /dev/null +++ b/vlsisapd/cif/CMakeLists.txt @@ -0,0 +1,9 @@ +INCLUDE_DIRECTORIES(${CHAMS_SOURCE_DIR}/cif) + +SET ( includes CifCircuit.h CifPolygon.h ) +SET ( cpps CifCircuit.cpp CifPolygon.cpp ) + +ADD_LIBRARY(cif ${cpps}) +INSTALL(TARGETS cif DESTINATION /lib) + +INSTALL(FILES ${includes} DESTINATION /include/io/cif) diff --git a/vlsisapd/cif/CifCircuit.cpp b/vlsisapd/cif/CifCircuit.cpp new file mode 100644 index 00000000..a7cd9aae --- /dev/null +++ b/vlsisapd/cif/CifCircuit.cpp @@ -0,0 +1,53 @@ +#include +#include +#include +using namespace std; + +#include "CifCircuit.h" +#include "CifPolygon.h" + +namespace IO { + +CifCircuit::CifCircuit(string name) : _name(name) {} + + +bool CifCircuit::addPolygon(CifPolygon* polygon) { + if(polygon) + _polygons.push_back(polygon); + else { + cerr << "[CIF DRIVE ERROR]: cannot add invalid polygon." << endl; + return false; + } + return true; +} + +bool CifCircuit::write(string filename) { + time_t curtime = time(0); + tm now = *localtime(&curtime); + char date[BUFSIZ]={0}; + const char format[]="%d-%b-%Y %H:%M:%S"; + if (!strftime(date, sizeof(date)-1, format, &now)>0) + cerr << "[CIF DRIVE ERROR]: cannot build current date." << endl; + + ofstream file; + file.open(filename.c_str(), ios::out); + // Header + file << "(CIF file written on " << date << " by IO_CIF_DRIVER);" << endl + << "DS 1 1 1;" << endl + << "9 " << _name << ";" << endl; + + // For each Polygon : write polygon. + for ( vector::iterator it = _polygons.begin() ; it < _polygons.end() ; it++ ) { + (*it)->write(file); + } + + // Footer + file << "DF;" << endl + << "C 1;" << endl + << "E" << endl; + + file.close(); + return true; +} +} // namespace + diff --git a/vlsisapd/cif/CifCircuit.h b/vlsisapd/cif/CifCircuit.h new file mode 100644 index 00000000..32d09699 --- /dev/null +++ b/vlsisapd/cif/CifCircuit.h @@ -0,0 +1,21 @@ +#ifndef __CIF_CIRCUIT_H +#define __CIF_CIRCUIT_H + +#include + +namespace IO { +class CifPolygon; +class CifCircuit { + public: + CifCircuit(string); + + bool addPolygon ( CifPolygon* ); + bool write ( string ); + + private: + string _name; + + std::vector _polygons; +}; +} // namespace +#endif diff --git a/vlsisapd/cif/CifPolygon.cpp b/vlsisapd/cif/CifPolygon.cpp new file mode 100644 index 00000000..7474e540 --- /dev/null +++ b/vlsisapd/cif/CifPolygon.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +using namespace std; + +#include "CifPolygon.h" + +namespace IO { + +CifPolygon::CifPolygon(long layer) : _layer(layer) {} + + +void CifPolygon::addPoint(long x, long y) { + _points.push_back(pair(x,y)); +} + +void CifPolygon::write(ofstream& file) { + file << "L " << _layer << "; P"; + + // For each point : write point. + for ( vector >::iterator it = _points.begin() ; it < _points.end() ; it++ ) { + file << " " << (*it).first << "," << (*it).second; + } + + file << ";" << endl; +} +} // namespace + + diff --git a/vlsisapd/cif/CifPolygon.h b/vlsisapd/cif/CifPolygon.h new file mode 100644 index 00000000..94b14e09 --- /dev/null +++ b/vlsisapd/cif/CifPolygon.h @@ -0,0 +1,20 @@ +#ifndef __CIF_POLYGON_H +#define __CIF_POLYGON_H + +#include +#include + +namespace IO { +class CifPolygon { + public: + CifPolygon(long); + + void addPoint (long, long); + void write ( ofstream& ); + + private: + long _layer; + std::vector > _points; +}; +} // namespace +#endif diff --git a/vlsisapd/cmake_modules/FindIO.cmake b/vlsisapd/cmake_modules/FindIO.cmake index 414dd916..1f72f656 100644 --- a/vlsisapd/cmake_modules/FindIO.cmake +++ b/vlsisapd/cmake_modules/FindIO.cmake @@ -28,6 +28,23 @@ ELSE(AGDS_INCLUDE_DIR AND AGDS_LIBRARY) # SET(IO_LIBRARIES) ENDIF(AGDS_INCLUDE_DIR AND AGDS_LIBRARY) +# CIF +FIND_PATH(CIF_INCLUDE_DIR + NAMES io/cif/CifCircuit.h + PATHS ${IO_DIR_SEARCH} + PATH_SUFFIXES include +) +FIND_LIBRARY(CIF_LIBRARY + NAMES cif + PATHS ${IO_DIR_SEARCH} + PATH_SUFFIXES lib +) +IF(CIF_INCLUDE_DIR AND CIF_LIBRARY) + SET(CIF_FOUND TRUE) +ELSE(CIF_INCLUDE_DIR AND CIF_LIBRARY) + SET(CIF_FOUND FALSE) +ENDIF(CIF_INCLUDE_DIR AND CIF_LIBRARY) + # OPENCHAMS FIND_PATH(OPENCHAMS_INCLUDE_DIR NAMES io/openChams/Circuit.h @@ -41,18 +58,15 @@ FIND_LIBRARY(OPENCHAMS_LIBRARY ) IF(OPENCHAMS_INCLUDE_DIR AND OPENCHAMS_LIBRARY) SET(OPENCHAMS_FOUND TRUE) - #SET(IO_FOUND TRUE) -# SET(IO_LIBRARIES ${OPENCHAMS_LIBRARY}) ELSE(OPENCHAMS_INCLUDE_DIR AND OPENCHAMS_LIBRARY) SET(OPENCHAMS_FOUND FALSE) -# SET(IO_LIBRARIES) ENDIF(OPENCHAMS_INCLUDE_DIR AND OPENCHAMS_LIBRARY) -IF(AGDS_FOUND AND OPENCHAMS_FOUND) +IF(AGDS_FOUND AND CIF_FOUND AND OPENCHAMS_FOUND) SET(IO_FOUND TRUE) -ELSE(AGDS_FOUND AND OPENCHAMS_FOUND) +ELSE(AGDS_FOUND AND CIF_FOUND AND OPENCHAMS_FOUND) SET(IO_FOUND FALSE) -ENDIF(AGDS_FOUND AND OPENCHAMS_FOUND) +ENDIF(AGDS_FOUND AND CIF_FOUND AND OPENCHAMS_FOUND) IF (NOT IO_FOUND) SET(IO_MESSAGE