From eefb15127a4a529b26778fd8216f8e48916cca16 Mon Sep 17 00:00:00 2001 From: Damien Dupuis Date: Thu, 3 Jun 2010 11:53:18 +0000 Subject: [PATCH] ADDS: - access to Sizing object in Circuit object (method getSizing()) - now driver is deterministic since it sorts names in alphabetical order (cannot use name's id since names are destroyed when converted to hurricane and then recreated before drive but with totaly unknow/uncontroled ids) --- vlsisapd/openChams/Circuit.cpp | 25 ++++++++++++++++++++++--- vlsisapd/openChams/Circuit.h | 2 ++ vlsisapd/openChams/Instance.h | 6 +++--- vlsisapd/openChams/Name.cpp | 5 +++-- vlsisapd/openChams/Name.h | 4 ++-- vlsisapd/openChams/Net.h | 6 +++--- vlsisapd/openChams/Sizing.h | 6 +++--- 7 files changed, 38 insertions(+), 16 deletions(-) diff --git a/vlsisapd/openChams/Circuit.cpp b/vlsisapd/openChams/Circuit.cpp index c7d1b807..6c8b7b6c 100644 --- a/vlsisapd/openChams/Circuit.cpp +++ b/vlsisapd/openChams/Circuit.cpp @@ -45,6 +45,19 @@ Circuit::Circuit(Name name, Name techno) : _name(name), _techno(techno), _netlis readSizingDone = false; } +// COMPARISON FUNCTION // +bool ConnectionsSort(const pair& p1, const pair& p2) { + return p1.first < p2.first; +} + +bool InstanceNameSort(const Instance* i1, const Instance* i2) { + return i1->getName() < i2->getName(); +} + +bool NetNameSort(const Net* n1, const Net* n2) { + return n1->getName() < n2->getName(); +} + // USEFUL // void Circuit::check_uppercase(string& str, vector& compares, string message) { transform(str.begin(), str.end(), str.begin(), ::toupper); @@ -640,7 +653,9 @@ bool Circuit::writeToFile(string filePath) { } file << " " << endl << " " << endl; - for (vector::const_iterator it = _netlist->getInstances().begin() ; it != _netlist->getInstances().end() ; ++it) { + vector instances = _netlist->getInstances(); + sort(instances.begin(), instances.end(), InstanceNameSort); // sort based on instances' names + for (vector::iterator it = instances.begin() ; it != instances.end() ; ++it) { Instance* inst = (*it); if (inst->hasNoConnectors()) { string error("[ERROR] Cannot writeToFile since instance ("); @@ -682,7 +697,9 @@ bool Circuit::writeToFile(string filePath) { } file << " " << endl << " " << endl; - for (vector::const_iterator it = _netlist->getNets().begin() ; it != _netlist->getNets().end() ; ++it) { + vector nets = _netlist->getNets(); + sort(nets.begin(), nets.end(), NetNameSort); // sort based on nets' names + for (vector::iterator it = nets.begin() ; it != nets.end() ; ++it) { Net* net = (*it); if (net->hasNoConnectors()) { string error("[ERROR] Cannot writeToFile since net ("); @@ -693,7 +710,9 @@ bool Circuit::writeToFile(string filePath) { } string externStr = (net->isExternal()) ? "True" : "False"; file << " getName().getString() << "\" type=\"" << net->getType().getString() << "\" isExternal=\"" << externStr << "\">" << endl; - for (vector >::const_iterator it = net->getConnections().begin() ; it != net->getConnections().end() ; ++it) { + vector > connections = net->getConnections(); + sort(connections.begin(), connections.end(), ConnectionsSort); + for (vector >::iterator it = connections.begin() ; it != connections.end() ; ++it) { file << " " << endl; } file << " " << endl; diff --git a/vlsisapd/openChams/Circuit.h b/vlsisapd/openChams/Circuit.h index bcf6a5ef..5d7b1657 100644 --- a/vlsisapd/openChams/Circuit.h +++ b/vlsisapd/openChams/Circuit.h @@ -35,6 +35,7 @@ class Circuit { inline double getValue(Name); inline Netlist* getNetlist(); inline Schematic* getSchematic(); + inline Sizing* getSizing(); inline void addParameter(Name, double); inline void addParameter(Name, std::string); inline Parameters getParameters(); @@ -86,6 +87,7 @@ inline Name Circuit::getTechno() { return _techno; }; inline double Circuit::getValue(Name name) { return _params.getValue(name); }; inline Netlist* Circuit::getNetlist() { return _netlist; }; inline Schematic* Circuit::getSchematic() { return _schematic; }; +inline Sizing* Circuit::getSizing() { return _sizing; }; inline void Circuit::addParameter(Name name, double value) { _params.addParameter(name, value); }; inline void Circuit::addParameter(Name name, std::string eqStr) { _params.addParameter(name, eqStr); }; inline Parameters Circuit::getParameters() { return _params; }; diff --git a/vlsisapd/openChams/Instance.h b/vlsisapd/openChams/Instance.h index cc256822..b032f151 100644 --- a/vlsisapd/openChams/Instance.h +++ b/vlsisapd/openChams/Instance.h @@ -32,7 +32,7 @@ class Instance { inline void addParameter(Name, double); inline void addParameter(Name, std::string); inline void addTransistor(Transistor*); - inline Name getName(); + inline Name getName() const; inline Name getModel(); inline Name getMosType(); inline bool isSourceBulkConnected(); @@ -43,7 +43,7 @@ class Instance { // pour parcourir les transistors inline bool hasNoTransistors(); inline const std::vector& getTransistors(); - + private: Name _name; Name _model; @@ -58,7 +58,7 @@ class Instance { inline void Instance::addParameter(Name name, double value) { _params.addParameter(name, value); }; inline void Instance::addParameter(Name name, std::string eqStr) { _params.addParameter(name, eqStr); }; inline void Instance::addTransistor(Transistor* tr) { _trans.push_back(tr); }; -inline Name Instance::getName() { return _name; }; +inline Name Instance::getName() const { return _name; }; inline Name Instance::getModel() { return _model; }; inline Name Instance::getMosType() { return _mosType; }; inline bool Instance::isSourceBulkConnected() { return _sourceBulkConnected; }; diff --git a/vlsisapd/openChams/Name.cpp b/vlsisapd/openChams/Name.cpp index dcd973a8..a9aca241 100644 --- a/vlsisapd/openChams/Name.cpp +++ b/vlsisapd/openChams/Name.cpp @@ -48,8 +48,9 @@ bool Name::operator==(const string& str) { Name n(str); return (_id == n._id); } -bool Name::operator<(const Name n) const { - return (_id < n._id); +bool Name::operator<(const Name& n) const { + //return (_id < n._id); // does not assert determinism in driving since hurricane do not care about name's ID --> need an alphabetical check on string + return (*_str < n.getString()); } } // namespace diff --git a/vlsisapd/openChams/Name.h b/vlsisapd/openChams/Name.h index bad4d10d..c382bb44 100644 --- a/vlsisapd/openChams/Name.h +++ b/vlsisapd/openChams/Name.h @@ -23,7 +23,7 @@ class Name { bool operator==(const Name&); bool operator==(const std::string&); - bool operator<(const Name) const; + bool operator<(const Name&) const; inline const std::string& getString() const; @@ -32,7 +32,7 @@ class Name { const std::string *_str; static std::map _dict; - static unsigned long _globalId; + static unsigned long _globalId; }; inline const std::string& Name::getString() const{ diff --git a/vlsisapd/openChams/Net.h b/vlsisapd/openChams/Net.h index e3252752..50b3d53a 100644 --- a/vlsisapd/openChams/Net.h +++ b/vlsisapd/openChams/Net.h @@ -23,7 +23,7 @@ class Net { void connectTo(Name instanceName, Name connectorName); - inline Name getName(); + inline Name getName() const; inline Name getType(); inline bool isExternal(); inline Netlist* getNetlist(); @@ -31,7 +31,7 @@ class Net { //inline vector >::iterator getFirstConnectionIt(); //inline vector >::iterator getLastConnectionIt(); inline const std::vector >& getConnections(); - + private: Name _name; Name _typeName; @@ -40,7 +40,7 @@ class Net { std::vector > _connections; // }; -inline Name Net::getName() { return _name; }; +inline Name Net::getName() const { return _name; }; inline Name Net::getType() { return _typeName; }; inline bool Net::isExternal() { return _isExternal; }; inline Netlist* Net::getNetlist() { return _netlist; }; diff --git a/vlsisapd/openChams/Sizing.h b/vlsisapd/openChams/Sizing.h index 47d1f7b7..665e56f8 100644 --- a/vlsisapd/openChams/Sizing.h +++ b/vlsisapd/openChams/Sizing.h @@ -3,7 +3,7 @@ * openChams * * Created by damien dupuis on 08/02/10. - * Copyright 2010 UPMC / LIP6. All rights reserved. + * Copyright 2008-2010 UPMC / LIP6. All rights reserved. * */ @@ -31,8 +31,8 @@ namespace OpenChams { private: Circuit* _circuit; - std::map _operators; //instanceName <-> operator - std::map _equations; //equationName <-> equation (string) + std::map _operators; // instanceName <-> operator + std::map _equations; // equationName <-> equation (string) }; inline bool Sizing::hasNoOperators() { return (_operators.size() == 0) ? true : false; };