From 801615750079484c1ff105ca408a2452f376832d Mon Sep 17 00:00:00 2001 From: EricLaoGitHub Date: Fri, 17 Jun 2016 16:26:27 +0200 Subject: [PATCH 1/4] Temporary commit to pull and merge last commit. --- anabatic/src/Dijkstra.cpp | 43 ++++++++++++++++++++++++++ anabatic/src/GCell.cpp | 52 ++++++++++++++++++++++++++++++++ anabatic/src/anabatic/Dijkstra.h | 28 +++++++++++++++++ anabatic/src/anabatic/GCell.h | 5 +++ 4 files changed, 128 insertions(+) diff --git a/anabatic/src/Dijkstra.cpp b/anabatic/src/Dijkstra.cpp index 3088484f..7e28849a 100644 --- a/anabatic/src/Dijkstra.cpp +++ b/anabatic/src/Dijkstra.cpp @@ -113,6 +113,49 @@ namespace Anabatic { } + bool Dijkstra::isRestricted ( const Vertex* v1, const Vertex* v2 ) const + { + bool restricted = true; + GCell* c1 = v1->getGCell(); + GCell* c2 = v2->getGCell(); + + // Check from GCell 1 + if ( c1->isNorth(c2) ) { + if ( !v1->isNRestricted() ) restricted = false; + } else if ( c1->isSouth(c2) ) { + if ( !v1->isSRestricted() ) restricted = false; + } else if ( c1->isEast (c2) ) { + if ( !v1->isERestricted() ) restricted = false; + } else if ( c1->isWest (c2) ) { + if ( !v1->isWRestricted() ) restricted = false; + } else { + cerr << Error( "GCells are not side by side." ) << endl; + return true; + } + + if (restricted) return true; + else { + // Check from GCell 2 + if ( c2->isNorth(c1) ) { + if ( v2->isNRestricted() ) return true; + else return false; + } else if ( c2->isSouth(c1) ) { + if ( v2->isSRestricted() ) return true; + else return false; + } else if ( c2->isEast (c1) ) { + if ( v2->isERestricted() ) return true; + else return false; + } else if ( c2->isWest (c1) ) { + if ( v2->isWRestricted() ) return true; + else return false; + } else { + cerr << Error( "GCells are not side by side." ) << endl; + return true; + } + } + } + + Dijkstra::Dijkstra ( AnabaticEngine* anabatic ) : _anabatic (anabatic) , _vertexes () diff --git a/anabatic/src/GCell.cpp b/anabatic/src/GCell.cpp index 534c4c7d..779ff899 100644 --- a/anabatic/src/GCell.cpp +++ b/anabatic/src/GCell.cpp @@ -573,6 +573,58 @@ namespace Anabatic { } + bool GCell::isNorth ( GCell* c ) const + { + bool found = false; + for (vector::const_iterator it = _northEdges.begin(); it != _northEdges.end(); it++){ + if ( (*it)->getOpposite(this)->getId() == getId() ) { + found = true; + break; + } + } + return found; + } + + + bool GCell::isSouth ( GCell* c ) const + { + bool found = false; + for (vector::const_iterator it = _southEdges.begin(); it != _southEdges.end(); it++){ + if ( (*it)->getOpposite(this)->getId() == getId() ) { + found = true; + break; + } + } + return found; + } + + + bool GCell::isEast ( GCell* c ) const + { + bool found = false; + for (vector::const_iterator it = _eastEdges.begin(); it != _eastEdges.end(); it++){ + if ( (*it)->getOpposite(this)->getId() == getId() ) { + found = true; + break; + } + } + return found; + } + + + bool GCell::isWest ( GCell* c ) const + { + bool found = false; + for (vector::const_iterator it = _westEdges.begin(); it != _westEdges.end(); it++){ + if ( (*it)->getOpposite(this)->getId() == getId() ) { + found = true; + break; + } + } + return found; + } + + string GCell::_getTypeName () const { return getString(_extensionName); } diff --git a/anabatic/src/anabatic/Dijkstra.h b/anabatic/src/anabatic/Dijkstra.h index 721dbd1b..30452764 100644 --- a/anabatic/src/anabatic/Dijkstra.h +++ b/anabatic/src/anabatic/Dijkstra.h @@ -44,6 +44,13 @@ namespace Anabatic { public: inline bool operator() ( const Vertex* lhs, const Vertex* rhs ); }; + public: + enum FlagR { NoRestriction = 0 + , NRestricted = (1<<0) + , SRestricted = (1<<1) + , ERestricted = (1<<2) + , WRestricted = (1<<3) + }; public: static float unreached; public: @@ -67,6 +74,15 @@ namespace Anabatic { inline void setStamp ( int ); inline void setConnexId ( int ); inline void setFrom ( Edge* ); + + inline bool isNorth ( Vertex* ) const; + inline bool isSouth ( Vertex* ) const; + inline bool isEast ( Vertex* ) const; + inline bool isWest ( Vertex* ) const; + inline bool isNRestricted () const; + inline bool isSRestricted () const; + inline bool isERestricted () const; + inline bool isWRestricted () const; // Inspector support. string _getString () const; private: @@ -80,6 +96,7 @@ namespace Anabatic { int _stamp; float _distance; Edge* _from; + FlagR _flags; }; @@ -91,6 +108,7 @@ namespace Anabatic { , _stamp (-1) , _distance(unreached) , _from (NULL) + , _flags (NoRestriction) { gcell->setObserver( GCell::Observable::Vertex, &_observer ); } @@ -129,6 +147,15 @@ namespace Anabatic { typedef set VertexSet; + inline bool Vertex::isNorth ( Vertex* v ) const { return _gcell->isNorth(v->getGCell()); } + inline bool Vertex::isSouth ( Vertex* v ) const { return _gcell->isSouth(v->getGCell()); } + inline bool Vertex::isEast ( Vertex* v ) const { return _gcell->isEast (v->getGCell()); } + inline bool Vertex::isWest ( Vertex* v ) const { return _gcell->isWest (v->getGCell()); } + inline bool Vertex::isNRestricted () const { return (_flags & NRestricted); } + inline bool Vertex::isSRestricted () const { return (_flags & SRestricted); } + inline bool Vertex::isERestricted () const { return (_flags & ERestricted); } + inline bool Vertex::isWRestricted () const { return (_flags & WRestricted); } + // ------------------------------------------------------------------- // Class : "Anabatic::PriorityQueue". @@ -214,6 +241,7 @@ namespace Anabatic { public: float getDistance ( const Vertex*, const Vertex*, const Edge* ); + bool isRestricted ( const Vertex*, const Vertex* ) const; public: Dijkstra ( AnabaticEngine* ); ~Dijkstra (); diff --git a/anabatic/src/anabatic/GCell.h b/anabatic/src/anabatic/GCell.h index 1c742fef..7cab666e 100644 --- a/anabatic/src/anabatic/GCell.h +++ b/anabatic/src/anabatic/GCell.h @@ -101,6 +101,11 @@ namespace Anabatic { GCell* vcut ( DbU::Unit x ); bool doGrid (); Contact* getGContact ( Net* ); + + bool isNorth ( GCell* ) const; + bool isSouth ( GCell* ) const; + bool isEast ( GCell* ) const; + bool isWest ( GCell* ) const; // Misc. functions. inline const Flags& flags () const; inline Flags& flags (); From 3038d09b27012b570dcb6df371173d2b8f95a348 Mon Sep 17 00:00:00 2001 From: EricLaoGitHub Date: Fri, 17 Jun 2016 17:47:48 +0200 Subject: [PATCH 2/4] Another temporary commit to merge with last version. --- anabatic/src/anabatic/Dijkstra.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/anabatic/src/anabatic/Dijkstra.h b/anabatic/src/anabatic/Dijkstra.h index 5a026288..ed03a3d7 100644 --- a/anabatic/src/anabatic/Dijkstra.h +++ b/anabatic/src/anabatic/Dijkstra.h @@ -44,6 +44,13 @@ namespace Anabatic { public: inline bool operator() ( const Vertex* lhs, const Vertex* rhs ); }; + public: + enum FlagR { NoRestriction = 0 + , NRestricted = (1<<0) + , SRestricted = (1<<1) + , ERestricted = (1<<2) + , WRestricted = (1<<3) + }; public: static DbU::Unit unreached; public: @@ -248,6 +255,8 @@ namespace Anabatic { bool _propagate ( Flags enabledSides ); void _selectFirstSource (); void _toWires (); + + bool isRestricted ( const Vertex* v1, const Vertex* v2 ) const; private: AnabaticEngine* _anabatic; vector _vertexes; From da423ab308362f60a4b78a0cc325509d1e3be5ba Mon Sep 17 00:00:00 2001 From: EricLaoGitHub Date: Mon, 20 Jun 2016 18:36:00 +0200 Subject: [PATCH 3/4] in CMakeLists: - (Add) HurricaneAMS includes in Dijkstra: - (Add+Modify) Handle restriction rules in Vertex for analog devices in GCell: - (Add) Check neighboring cells (North/South/East/West) --- anabatic/CMakeLists.txt | 1 + anabatic/src/CMakeLists.txt | 2 ++ anabatic/src/Dijkstra.cpp | 36 ++++++++++++++++++++++++++++++-- anabatic/src/GCell.cpp | 8 +++---- anabatic/src/anabatic/Dijkstra.h | 28 ++++++++++++++++++++++++- 5 files changed, 68 insertions(+), 7 deletions(-) diff --git a/anabatic/CMakeLists.txt b/anabatic/CMakeLists.txt index 4187e409..e2baa825 100644 --- a/anabatic/CMakeLists.txt +++ b/anabatic/CMakeLists.txt @@ -22,6 +22,7 @@ find_package(VLSISAPD REQUIRED) find_package(HURRICANE REQUIRED) find_package(CORIOLIS REQUIRED) + find_package(HURRICANEAMS REQUIRED) add_subdirectory(src) add_subdirectory(cmake_modules) diff --git a/anabatic/src/CMakeLists.txt b/anabatic/src/CMakeLists.txt index e666a39a..999f55e9 100644 --- a/anabatic/src/CMakeLists.txt +++ b/anabatic/src/CMakeLists.txt @@ -11,6 +11,7 @@ endif ( CHECK_DETERMINISM ) ${Boost_INCLUDE_DIRS} ${QtX_INCLUDE_DIR} ${PYTHON_INCLUDE_PATH} + ${HURRICANEAMS_INCLUDE_DIR} ) set( includes anabatic/Constants.h anabatic/Configuration.h @@ -55,6 +56,7 @@ endif ( CHECK_DETERMINISM ) ${Boost_LIBRARIES} ${LIBXML2_LIBRARIES} ${PYTHON_LIBRARIES} -lutil + ${HURRICANEAMS_LIBRARIES} ) add_library( anabatic ${cpps} ${mocCpps} ) diff --git a/anabatic/src/Dijkstra.cpp b/anabatic/src/Dijkstra.cpp index a9f5ac15..4c4975e4 100644 --- a/anabatic/src/Dijkstra.cpp +++ b/anabatic/src/Dijkstra.cpp @@ -47,6 +47,7 @@ namespace Anabatic { DbU::Unit Vertex::unreached = std::numeric_limits::max(); + DbU::Unit Vertex::unreachable = std::numeric_limits::max()-1; bool Vertex::hasValidStamp () const @@ -64,10 +65,14 @@ namespace Anabatic { + " @(" + DbU::getValueString(_gcell->getXMin()) + "," + DbU::getValueString(_gcell->getYMin()) + ")" + " connexId:" + getString(_connexId) - + " d:" + ((_distance == unreached) ? "unreached" : DbU::getValueString(_distance) ) + + " d:" + ((_distance == unreached) ? "unreached" : ((_distance == unreachable) ? "unreachable" : DbU::getValueString(_distance)) ) + "+" + getString(_branchId) + " stamp:" + (hasValidStamp() ? "valid" : "outdated") + " from:" + ((_from) ? "set" : "NULL") + + " restricted:" + (isNRestricted() ? "N" : "-") + + (isSRestricted() ? "S" : "-") + + (isERestricted() ? "E" : "-") + + (isWRestricted() ? "W" : "-") + ">"; return s; } @@ -107,6 +112,9 @@ namespace Anabatic { { DbU::Unit distance = a->getDistance() + e->getDistance(); + if ( (a->isNotRestricted()) && (b->isNotRestricted()) ) { // A remplacer avec verification sur type IsDevice()?. + if (isRestricted(a, b)) distance = Vertex::unreachable; + } // Edge* aFrom = a->getFrom(); // if (aFrom) { // distance += (aFrom->isHorizontal() xor e->isHorizontal()) ? 3.0 : 0.0; @@ -115,7 +123,7 @@ namespace Anabatic { } - bool Dijkstra::isRestricted ( const Vertex* v1, const Vertex* v2 ) const + bool Dijkstra::isRestricted ( const Vertex* v1, const Vertex* v2 ) { bool restricted = true; GCell* c1 = v1->getGCell(); @@ -222,8 +230,32 @@ namespace Anabatic { vertex->setBranchId( 0 ); vertex->setFrom ( NULL ); _targets.insert( vertex ); + vertex->clearRestriction(); cdebug_log(112,0) << "Add Vertex: " << vertex << endl; } + // Analog Restrictions + Plug* plug = dynamic_cast(rp->getPlugOccurrence().getEntity()); + Cell* cell = plug->getInstance()->getMasterCell(); + Device* dev = dynamic_cast(cell); + TransistorFamily* tf = dynamic_cast(dev); + + if (tf){ + Transistor* t = dynamic_cast(tf); + SimpleCurrentMirror* scm = dynamic_cast(tf); + DifferentialPair* dp = dynamic_cast(tf); + CommonSourcePair* csp = dynamic_cast(tf); + + unsigned int rule = 0; + if (t) { rule = t->getRestriction(plug->getMasterNet()); + } else if (scm) { rule = scm->getRestriction(plug->getMasterNet()); + } else if (dp) { rule = dp->getRestriction(plug->getMasterNet()); + } else if (csp) { rule = csp->getRestriction(plug->getMasterNet()); + } + if (!(rule&0x3 )) vertex->setWRestricted(); + if (!(rule&0xC )) vertex->setERestricted(); + if (!(rule&0x30)) vertex->setSRestricted(); + if (!(rule&0xC0)) vertex->setNRestricted(); + } Contact* gcontact = vertex->getGContact( _net ); rp->getBodyHook()->detach(); diff --git a/anabatic/src/GCell.cpp b/anabatic/src/GCell.cpp index bd7eab55..df23bf34 100644 --- a/anabatic/src/GCell.cpp +++ b/anabatic/src/GCell.cpp @@ -577,7 +577,7 @@ namespace Anabatic { { bool found = false; for (vector::const_iterator it = _northEdges.begin(); it != _northEdges.end(); it++){ - if ( (*it)->getOpposite(this)->getId() == getId() ) { + if ( (*it)->getOpposite(this)->getId() == c->getId() ) { found = true; break; } @@ -590,7 +590,7 @@ namespace Anabatic { { bool found = false; for (vector::const_iterator it = _southEdges.begin(); it != _southEdges.end(); it++){ - if ( (*it)->getOpposite(this)->getId() == getId() ) { + if ( (*it)->getOpposite(this)->getId() == c->getId() ) { found = true; break; } @@ -603,7 +603,7 @@ namespace Anabatic { { bool found = false; for (vector::const_iterator it = _eastEdges.begin(); it != _eastEdges.end(); it++){ - if ( (*it)->getOpposite(this)->getId() == getId() ) { + if ( (*it)->getOpposite(this)->getId() == c->getId() ) { found = true; break; } @@ -616,7 +616,7 @@ namespace Anabatic { { bool found = false; for (vector::const_iterator it = _westEdges.begin(); it != _westEdges.end(); it++){ - if ( (*it)->getOpposite(this)->getId() == getId() ) { + if ( (*it)->getOpposite(this)->getId() == c->getId() ) { found = true; break; } diff --git a/anabatic/src/anabatic/Dijkstra.h b/anabatic/src/anabatic/Dijkstra.h index b94e1907..70d2df8e 100644 --- a/anabatic/src/anabatic/Dijkstra.h +++ b/anabatic/src/anabatic/Dijkstra.h @@ -25,6 +25,11 @@ namespace Hurricane { class RoutingPad; } #include "anabatic/GCell.h" +#include "hurricaneAMS/analogic/Device.h" +#include "hurricaneAMS/devices/Transistor.h" +#include "hurricaneAMS/devices/SimpleCurrentMirror.h" +#include "hurricaneAMS/devices/DifferentialPair.h" +#include "hurricaneAMS/devices/CommonSourcePair.h" namespace Anabatic { @@ -34,6 +39,7 @@ namespace Anabatic { using Hurricane::Observer; using Hurricane::Net; using Hurricane::RoutingPad; + using Hurricane::Plug; class AnabaticEngine; @@ -55,6 +61,7 @@ namespace Anabatic { }; public: static DbU::Unit unreached; + static DbU::Unit unreachable; public: static void notify ( Vertex*, unsigned flags ); public: @@ -90,6 +97,15 @@ namespace Anabatic { inline bool isSRestricted () const; inline bool isERestricted () const; inline bool isWRestricted () const; + inline bool isNotRestricted() const; + + inline void setRestricted (); + inline void clearRestriction (); + inline void setNRestricted (); + inline void setSRestricted (); + inline void setERestricted (); + inline void setWRestricted (); + inline unsigned int getFlags () const; // Inspector support. string _getString () const; @@ -105,6 +121,7 @@ namespace Anabatic { int _stamp; DbU::Unit _distance; Edge* _from; + unsigned int _flags; }; @@ -157,6 +174,15 @@ namespace Anabatic { inline bool Vertex::isSRestricted () const { return (_flags & SRestricted); } inline bool Vertex::isERestricted () const { return (_flags & ERestricted); } inline bool Vertex::isWRestricted () const { return (_flags & WRestricted); } + inline bool Vertex::isNotRestricted () const { return ((!_flags) & 0xF); } + + inline void Vertex::setRestricted () { _flags |= 0xF; } + inline void Vertex::clearRestriction () { _flags &= ~(0xF); } + inline void Vertex::setNRestricted () { _flags |= 0x1; } + inline void Vertex::setSRestricted () { _flags |= 0x2; } + inline void Vertex::setERestricted () { _flags |= 0x4; } + inline void Vertex::setWRestricted () { _flags |= 0x8; } + inline unsigned int Vertex::getFlags () const { return _flags; } // ------------------------------------------------------------------- @@ -262,7 +288,7 @@ namespace Anabatic { void _selectFirstSource (); void _toWires (); - bool isRestricted ( const Vertex* v1, const Vertex* v2 ) const; + static bool isRestricted ( const Vertex* v1, const Vertex* v2 ); private: AnabaticEngine* _anabatic; vector _vertexes; From d16d6d198801b3d831a179773ebd06658f3af743 Mon Sep 17 00:00:00 2001 From: EricLaoGitHub Date: Wed, 22 Jun 2016 13:36:17 +0200 Subject: [PATCH 4/4] - (Remove) Restrictions rules for analog devices are now set in hurricaneAMS --- anabatic/CMakeLists.txt | 1 - anabatic/src/CMakeLists.txt | 2 -- anabatic/src/Dijkstra.cpp | 23 ----------------------- anabatic/src/anabatic/Dijkstra.h | 5 ----- anabatic/src/anabatic/GCell.h | 2 ++ 5 files changed, 2 insertions(+), 31 deletions(-) diff --git a/anabatic/CMakeLists.txt b/anabatic/CMakeLists.txt index e2baa825..4187e409 100644 --- a/anabatic/CMakeLists.txt +++ b/anabatic/CMakeLists.txt @@ -22,7 +22,6 @@ find_package(VLSISAPD REQUIRED) find_package(HURRICANE REQUIRED) find_package(CORIOLIS REQUIRED) - find_package(HURRICANEAMS REQUIRED) add_subdirectory(src) add_subdirectory(cmake_modules) diff --git a/anabatic/src/CMakeLists.txt b/anabatic/src/CMakeLists.txt index 999f55e9..e666a39a 100644 --- a/anabatic/src/CMakeLists.txt +++ b/anabatic/src/CMakeLists.txt @@ -11,7 +11,6 @@ endif ( CHECK_DETERMINISM ) ${Boost_INCLUDE_DIRS} ${QtX_INCLUDE_DIR} ${PYTHON_INCLUDE_PATH} - ${HURRICANEAMS_INCLUDE_DIR} ) set( includes anabatic/Constants.h anabatic/Configuration.h @@ -56,7 +55,6 @@ endif ( CHECK_DETERMINISM ) ${Boost_LIBRARIES} ${LIBXML2_LIBRARIES} ${PYTHON_LIBRARIES} -lutil - ${HURRICANEAMS_LIBRARIES} ) add_library( anabatic ${cpps} ${mocCpps} ) diff --git a/anabatic/src/Dijkstra.cpp b/anabatic/src/Dijkstra.cpp index 4c4975e4..35fd67bf 100644 --- a/anabatic/src/Dijkstra.cpp +++ b/anabatic/src/Dijkstra.cpp @@ -233,29 +233,6 @@ namespace Anabatic { vertex->clearRestriction(); cdebug_log(112,0) << "Add Vertex: " << vertex << endl; } - // Analog Restrictions - Plug* plug = dynamic_cast(rp->getPlugOccurrence().getEntity()); - Cell* cell = plug->getInstance()->getMasterCell(); - Device* dev = dynamic_cast(cell); - TransistorFamily* tf = dynamic_cast(dev); - - if (tf){ - Transistor* t = dynamic_cast(tf); - SimpleCurrentMirror* scm = dynamic_cast(tf); - DifferentialPair* dp = dynamic_cast(tf); - CommonSourcePair* csp = dynamic_cast(tf); - - unsigned int rule = 0; - if (t) { rule = t->getRestriction(plug->getMasterNet()); - } else if (scm) { rule = scm->getRestriction(plug->getMasterNet()); - } else if (dp) { rule = dp->getRestriction(plug->getMasterNet()); - } else if (csp) { rule = csp->getRestriction(plug->getMasterNet()); - } - if (!(rule&0x3 )) vertex->setWRestricted(); - if (!(rule&0xC )) vertex->setERestricted(); - if (!(rule&0x30)) vertex->setSRestricted(); - if (!(rule&0xC0)) vertex->setNRestricted(); - } Contact* gcontact = vertex->getGContact( _net ); rp->getBodyHook()->detach(); diff --git a/anabatic/src/anabatic/Dijkstra.h b/anabatic/src/anabatic/Dijkstra.h index 70d2df8e..bcac1d92 100644 --- a/anabatic/src/anabatic/Dijkstra.h +++ b/anabatic/src/anabatic/Dijkstra.h @@ -25,11 +25,6 @@ namespace Hurricane { class RoutingPad; } #include "anabatic/GCell.h" -#include "hurricaneAMS/analogic/Device.h" -#include "hurricaneAMS/devices/Transistor.h" -#include "hurricaneAMS/devices/SimpleCurrentMirror.h" -#include "hurricaneAMS/devices/DifferentialPair.h" -#include "hurricaneAMS/devices/CommonSourcePair.h" namespace Anabatic { diff --git a/anabatic/src/anabatic/GCell.h b/anabatic/src/anabatic/GCell.h index b81201db..c79a08b3 100644 --- a/anabatic/src/anabatic/GCell.h +++ b/anabatic/src/anabatic/GCell.h @@ -90,6 +90,7 @@ namespace Anabatic { inline const vector& getEastEdges () const; inline const vector& getNorthEdges () const; inline const vector& getSouthEdges () const; + inline const vector& getContacts () const; inline Edges getEdges () const; inline GCell* getWest () const; inline GCell* getEast () const; @@ -174,6 +175,7 @@ namespace Anabatic { inline const vector& GCell::getEastEdges () const { return _eastEdges; } inline const vector& GCell::getNorthEdges () const { return _northEdges; } inline const vector& GCell::getSouthEdges () const { return _southEdges; } + inline const vector& GCell::getContacts () const { return _contacts; } inline GCell* GCell::getWest () const { return _westEdges.empty() ? NULL : _westEdges[0]->getOpposite(this); } inline GCell* GCell::getEast () const { return _eastEdges.empty() ? NULL : _eastEdges[0]->getOpposite(this); } inline GCell* GCell::getSouth () const { return _southEdges.empty() ? NULL : _southEdges[0]->getOpposite(this); }