From ecef0bb7492b4d2ad0afb10d3d719ba97de79e5d Mon Sep 17 00:00:00 2001 From: Christophe Alexandre Date: Mon, 19 May 2008 19:32:21 +0000 Subject: [PATCH] Technology in progress --- chamsin/CMakeLists.txt | 19 ++++--- chamsin/src/analogic/Transistor.cpp | 10 +++- chamsin/src/analogic/Transistor.h | 4 ++ chamsin/src/technology/AEnv.cpp | 13 ++++- chamsin/src/technology/AEnv.h | 2 +- chamsin/src/technology/ATechnology.cpp | 57 +++++++++++++++---- chamsin/src/technology/ATechnology.h | 26 ++++++--- .../src/technology/ATechnologyXmlParser.cpp | 20 ++++++- chamsin/src/technology/CMakeLists.txt | 4 +- chamsin/src/tests/AnalogicTest.cpp | 11 +++- chamsin/src/tests/CMakeLists.txt | 10 ++-- 11 files changed, 133 insertions(+), 43 deletions(-) diff --git a/chamsin/CMakeLists.txt b/chamsin/CMakeLists.txt index e796131d..a62983c1 100644 --- a/chamsin/CMakeLists.txt +++ b/chamsin/CMakeLists.txt @@ -1,14 +1,15 @@ -PROJECT(CHAMSIN) +project(CHAMSIN) -CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0) +cmake_minimum_required(VERSION 2.4.0) -SET(CMAKE_MODULE_PATH "$ENV{HURRICANE_TOP}/share/cmake_modules/" +set(CMAKE_MODULE_PATH "$ENV{HURRICANE_TOP}/share/cmake_modules/" "$ENV{HURRICANE_TOP}/share/cmake_modules/") -FIND_PACKAGE(BISON REQUIRED) -FIND_PACKAGE(FLEX REQUIRED) -FIND_PACKAGE(HURRICANE REQUIRED) -FIND_PACKAGE(CORIOLIS REQUIRED) -FIND_PACKAGE(LibXml2 REQUIRED) +find_package(BISON REQUIRED) +find_package(FLEX REQUIRED) +find_package(HURRICANE REQUIRED) +find_package(CORIOLIS REQUIRED) +find_package(Qt4 REQUIRED) # find and setup Qt4 for this project +find_package(LibXml2 REQUIRED) -ADD_SUBDIRECTORY(src) +add_subdirectory(src) diff --git a/chamsin/src/analogic/Transistor.cpp b/chamsin/src/analogic/Transistor.cpp index bfd811ff..dc173a6b 100644 --- a/chamsin/src/analogic/Transistor.cpp +++ b/chamsin/src/analogic/Transistor.cpp @@ -19,7 +19,11 @@ Transistor::Transistor(Library* library, const Name& name, const Polarity& polar _polarity(polarity), _abutmentType(), _l(0.0), - _w(0.0) + _w(0.0), + _source20(NULL), + _source22(NULL), + _drain40(NULL), + _drain42(NULL) {} @@ -41,6 +45,10 @@ void Transistor::_postCreate() { _grid->setExternal(true); _bulk = Net::create(this, BulkName); _bulk->setExternal(true); + //_source20 = Contact::create(_source); + //_source22 = Contact::create(_source); + //_drain40 = Contact::create(_drain); + //_drain42 = Contact::create(_drain); } void Transistor::createLayout() { diff --git a/chamsin/src/analogic/Transistor.h b/chamsin/src/analogic/Transistor.h index 415f479d..ade76856 100644 --- a/chamsin/src/analogic/Transistor.h +++ b/chamsin/src/analogic/Transistor.h @@ -37,6 +37,10 @@ class Transistor : public Cell { AbutmentType _abutmentType; double _l; double _w; + Contact* _source20; + Contact* _source22; + Contact* _drain40; + Contact* _drain42; Transistor(Library* library, const Name& name, const Polarity& polarity); }; diff --git a/chamsin/src/technology/AEnv.cpp b/chamsin/src/technology/AEnv.cpp index a705933c..5823f964 100644 --- a/chamsin/src/technology/AEnv.cpp +++ b/chamsin/src/technology/AEnv.cpp @@ -3,20 +3,27 @@ #include "Technology.h" using namespace Hurricane; +#include "crlcore/GraphicsParser.h" +#include "crlcore/TechnologyParser.h" +using namespace CRL; + #include "ATechnology.h" #include "ATechnologyXmlParser.h" #include "AEnv.h" -void AEnv::create(const char* technoFilePath) { +void AEnv::create(const char* technoFilePath, const char* graphicFilePath, const char* analogTechnoFilePath) { DataBase* db = getDataBase(); if (db) { throw Error(""); } db = DataBase::create(); + TechnologyParser::load(db, technoFilePath); + GraphicsParser::load(graphicFilePath); + Library* rootLibrary = Library::create(db, Name("RootLibrary")); - Technology* techno = Technology::create(db, Name("AnalogicTechnology")); - ATechnologyXmlParser::parse(technoFilePath, techno); + Technology* techno = db->getTechnology(); + ATechnologyXmlParser::parse(analogTechnoFilePath, techno); } ATechnology* AEnv::getATechnology() { diff --git a/chamsin/src/technology/AEnv.h b/chamsin/src/technology/AEnv.h index 6a09a434..585f87ed 100644 --- a/chamsin/src/technology/AEnv.h +++ b/chamsin/src/technology/AEnv.h @@ -5,7 +5,7 @@ class ATechnology; class AEnv { public: - static void create(const char* technoFilePath); + static void create(const char* technoFilePath, const char* graphicFilePath, const char* analogTechnoFilePath); static ATechnology* getATechnology(); }; diff --git a/chamsin/src/technology/ATechnology.cpp b/chamsin/src/technology/ATechnology.cpp index e99153e9..7874c67e 100644 --- a/chamsin/src/technology/ATechnology.cpp +++ b/chamsin/src/technology/ATechnology.cpp @@ -1,11 +1,11 @@ #include "Technology.h" -#include "Property.h" using namespace Hurricane; #include "ATechnology.h" namespace { static Name ATechnologyPropertyName("ATechnologyProperty"); + } Name ATechnology::getName() const { @@ -16,13 +16,37 @@ string ATechnology::_getTypeName() const { return _TName("ATechnologyProperty"); } -void ATechnology::addPhysicalRule(const string& name, double value, const string& reference) { - PhysicalRules::iterator prit = _physicalRules.find(name); - if (prit != _physicalRules.end()) { +void ATechnology::addPhysicalRule(const Name& name, double value, const string& reference) { + PhysicalRules::iterator prit = _noLayerPhysicalRules.find(name); + if (prit != _noLayerPhysicalRules.end()) { throw Error(""); } PhysicalRule* newPhysicalRule = new PhysicalRule(name, value, reference); - _physicalRules[newPhysicalRule->_name] = newPhysicalRule; + _noLayerPhysicalRules[newPhysicalRule->_name] = newPhysicalRule; +} + +void ATechnology::addPhysicalRule(const Name& name, const Name& layerName, double value, const string& reference) { + Layer* layer = getLayer(layerName); + OneLayerPhysicalRules::iterator olprit = _oneLayerPhysicalRules.find(layer); + if (olprit == _oneLayerPhysicalRules.end()) { + pair result = + _oneLayerPhysicalRules.insert(make_pair(layer, PhysicalRules())); + assert(result.second); + olprit = result.first; + PhysicalRule* newPhysicalRule = new PhysicalRule(name, value, reference); + olprit->second[name] = newPhysicalRule; + } else { + PhysicalRules& physicalRules = olprit->second; + if (physicalRules.find(name) != physicalRules.end()) { + throw Error("duplicate rule"); + } + PhysicalRule* newPhysicalRule = new PhysicalRule(name, value, reference); + physicalRules[name] = newPhysicalRule; + } +} + +void ATechnology::addPhysicalRule(const Name& name, const Name& layer1Name, + const Name& layer2Name, double value, const string& reference) { } ATechnology* ATechnology::create(Technology* technology) { @@ -46,9 +70,9 @@ ATechnology* ATechnology::getATechnology(Technology* technology) { void ATechnology::print() { cout << "Printing ATechnology" << endl; - cout << " o Physical Rules" << endl; - for (PhysicalRules::iterator prit = _physicalRules.begin(); - prit != _physicalRules.end(); + cout << " o No Layer Physical Rules" << endl; + for (PhysicalRules::iterator prit = _noLayerPhysicalRules.begin(); + prit != _noLayerPhysicalRules.end(); prit++) { PhysicalRule* physicalRule = prit->second; cout << " - name = " << physicalRule->_name << @@ -57,10 +81,19 @@ void ATechnology::print() { } } -const ATechnology::PhysicalRule* ATechnology::getPhysicalRule(const string& name) { - PhysicalRules::iterator prit = _physicalRules.find(name); - if (prit == _physicalRules.end()) { - throw Error("Cannot find Physical Rule " + name); +const ATechnology::PhysicalRule* ATechnology::getPhysicalRule(const Name& name) { + PhysicalRules::iterator prit = _noLayerPhysicalRules.find(name); + if (prit == _noLayerPhysicalRules.end()) { + throw Error("Cannot find Physical Rule " + getString(name)); } return prit->second; } + +Layer* ATechnology::getLayer(const Name& layerName) { + Technology* technology = static_cast(getOwner()); + Layer* layer = technology->getLayer(layerName); + if (!layer) { + throw Error("cannot find layer"); + } + return layer; +} diff --git a/chamsin/src/technology/ATechnology.h b/chamsin/src/technology/ATechnology.h index c42f96db..35dc5847 100644 --- a/chamsin/src/technology/ATechnology.h +++ b/chamsin/src/technology/ATechnology.h @@ -6,6 +6,7 @@ using namespace Hurricane; namespace Hurricane { class Technology; + class Layer; } class ATechnology : public PrivateProperty { @@ -14,7 +15,7 @@ class ATechnology : public PrivateProperty { class PhysicalRule { public: - PhysicalRule(const string& name, + PhysicalRule(const Name& name, double value, const string& reference): _name(name), @@ -24,16 +25,23 @@ class ATechnology : public PrivateProperty { _name(physicalRule._name), _value(physicalRule._value), _reference(physicalRule._reference) {} - const string _name; + const Name _name; const double _value; const string _reference; double getValue() const { return _value; } }; - typedef map PhysicalRules; + typedef map PhysicalRules; + typedef map OneLayerPhysicalRules; + typedef pair LayerPair; + typedef map TwoLayersPhysicalRules; static ATechnology* create(Hurricane::Technology* technology); static ATechnology* getATechnology(Hurricane::Technology* technology); - const PhysicalRule* getPhysicalRule(const string& name); - void addPhysicalRule(const string& name, double value, const string& reference); + const PhysicalRule* getPhysicalRule(const Name& name); + void addPhysicalRule(const Name& name, double value, const string& reference); + void addPhysicalRule(const Name& name, const Name& layerName, double value, const string& reference); + void addPhysicalRule(const Name& name, const Name& layer1Name, + const Name& layer2Name, double value, const string& reference); + Layer* getLayer(const Name& layerName); void print(); virtual Name getName() const; @@ -42,10 +50,14 @@ class ATechnology : public PrivateProperty { ATechnology(): Inherit(), - _physicalRules() {} + _noLayerPhysicalRules(), + _oneLayerPhysicalRules(), + _twoLayersPhysicalRules() {} private: - PhysicalRules _physicalRules; + PhysicalRules _noLayerPhysicalRules; + OneLayerPhysicalRules _oneLayerPhysicalRules; + TwoLayersPhysicalRules _twoLayersPhysicalRules; }; #endif /* ATECHNOLOGY_H_*/ diff --git a/chamsin/src/technology/ATechnologyXmlParser.cpp b/chamsin/src/technology/ATechnologyXmlParser.cpp index 23c50155..abf758ee 100644 --- a/chamsin/src/technology/ATechnologyXmlParser.cpp +++ b/chamsin/src/technology/ATechnologyXmlParser.cpp @@ -11,6 +11,10 @@ using namespace Hurricane; namespace { +void syntaxError(const string& reason) { + throw Error(reason); +} + void readPhysicalRules(xmlNode* node, ATechnology* aTechnology) { if (node->type == XML_ELEMENT_NODE && node->children) { for (xmlNode* ruleNode = node->children; @@ -21,11 +25,25 @@ void readPhysicalRules(xmlNode* node, ATechnology* aTechnology) { xmlChar* ruleNameC = xmlGetProp(ruleNode, (xmlChar*)"name"); xmlChar* valueC = xmlGetProp(ruleNode, (xmlChar*)"value"); xmlChar* refC = xmlGetProp(ruleNode, (xmlChar*)"ref"); + xmlChar* layerC = xmlGetProp(ruleNode, (xmlChar*)"layer"); + xmlChar* layer1C = xmlGetProp(ruleNode, (xmlChar*)"layer1"); + xmlChar* layer2C = xmlGetProp(ruleNode, (xmlChar*)"layer2"); if (ruleNameC && valueC && refC) { string ruleName((const char*)ruleNameC); double value = atof((const char*)valueC); string reference((const char*)refC); - aTechnology->addPhysicalRule(ruleName, value, reference); + if (layerC) { + Name layerName((const char*)layerC); + aTechnology->addPhysicalRule(ruleName, layerName, value, reference); + } else if (layer1C && layer2C) { + Name layer1Name((const char*)layer1C); + Name layer2Name((const char*)layer2C); + aTechnology->addPhysicalRule(ruleName, layer1Name, layer2Name, value, reference); + } else { + aTechnology->addPhysicalRule(ruleName, value, reference); + } + } else { + syntaxError(""); } } } diff --git a/chamsin/src/technology/CMakeLists.txt b/chamsin/src/technology/CMakeLists.txt index d5790dcf..e12ea6e7 100644 --- a/chamsin/src/technology/CMakeLists.txt +++ b/chamsin/src/technology/CMakeLists.txt @@ -1,8 +1,8 @@ -INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${HURRICANE_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${HURRICANE_INCLUDE_DIR} ${CORIOLIS_INCLUDE_DIR}) ADD_LIBRARY(atechnology SHARED AEnv.cpp ATechnology.cpp ATechnologyXmlParser.cpp) -TARGET_LINK_LIBRARIES(atechnology ${HURRICANE_LIBRARIES} ${LIBXML2_LIBRARIES}) +TARGET_LINK_LIBRARIES(atechnology ${HURRICANE_LIBRARIES} ${CORIOLIS_LIBRARIES} ${LIBXML2_LIBRARIES}) INSTALL(TARGETS atechnology DESTINATION /lib) diff --git a/chamsin/src/tests/AnalogicTest.cpp b/chamsin/src/tests/AnalogicTest.cpp index 52cc57eb..a6a1e54a 100644 --- a/chamsin/src/tests/AnalogicTest.cpp +++ b/chamsin/src/tests/AnalogicTest.cpp @@ -1,5 +1,7 @@ #include +#include + #include "Warning.h" #include "Error.h" #include "DataBase.h" @@ -13,12 +15,15 @@ using namespace Hurricane; int main(int argc, char* argv[]) { try { + + QApplication* qa = new QApplication(argc, argv); + cout << "simple analogic test" << endl; - if (argc != 2) { - cerr << "atest techno.xml"; + if (argc != 4) { + cerr << "atest techno.xml graphic.xml anatechno.xml"; exit(56); } - AEnv::create(argv[1]); + AEnv::create(argv[1], argv[2], argv[3]); DataBase* db = getDataBase(); Library* rootLibrary = db->getRootLibrary(); Library* userLibrary = Library::create(rootLibrary, Name("USER")); diff --git a/chamsin/src/tests/CMakeLists.txt b/chamsin/src/tests/CMakeLists.txt index 838aaeb2..5a44d64e 100644 --- a/chamsin/src/tests/CMakeLists.txt +++ b/chamsin/src/tests/CMakeLists.txt @@ -1,9 +1,11 @@ -INCLUDE_DIRECTORIES(${HURRICANE_INCLUDE_DIR} ${CORIOLIS_INCLUDE_DIR} +include(${QT_USE_FILE}) + +include_directories(${HURRICANE_INCLUDE_DIR} ${CORIOLIS_INCLUDE_DIR} ${CHAMSIN_SOURCE_DIR}/src/technology ${CHAMSIN_SOURCE_DIR}/src/analogic ${CHAMSIN_SOURCE_DIR}/src/device) -ADD_EXECUTABLE(atest AnalogicTest.cpp) +add_executable(atest AnalogicTest.cpp) -TARGET_LINK_LIBRARIES(atest atechnology analogic ${HURRICANE_LIBRARIES}) +target_link_libraries(atest atechnology analogic ${HURRICANE_LIBRARIES} ${QT_LIBRARIES}) -INSTALL(TARGETS atest DESTINATION /bin) +install(TARGETS atest DESTINATION /bin)