From 379effd92ca337325c90919107b2b54250b7c90b Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Fri, 17 Jun 2016 17:45:32 +0200 Subject: [PATCH] Anabatic transient commit 9. Dijkstra::_traceback() replaces _toWires(). * Change: In Anabatic: - In Dijkstra, replace _toWires() by _trackback() which is called immediatly on reaching a target. - In Constants & GCell, added flags for typing the GCells. We now have: * DeviceGCell, for analogic devices. * ChannelGCell, for resizable routing channels. * StrutGCell, for fixed spaces in analog designs. * MatrixGCell, for square tile in digital designs. --- anabatic/src/Constants.cpp | 21 +++--- anabatic/src/Dijkstra.cpp | 115 ++++++++++++++---------------- anabatic/src/anabatic/Constants.h | 12 ++-- anabatic/src/anabatic/Dijkstra.h | 71 +++++++++--------- anabatic/src/anabatic/GCell.h | 8 +++ 5 files changed, 121 insertions(+), 106 deletions(-) diff --git a/anabatic/src/Constants.cpp b/anabatic/src/Constants.cpp index 01072dfb..8e39a856 100644 --- a/anabatic/src/Constants.cpp +++ b/anabatic/src/Constants.cpp @@ -34,14 +34,19 @@ namespace Anabatic { string Flags::_getString () const { string s = ""; - s += (_flags & Horizontal ) ? 'h' : '-'; - s += (_flags & Vertical ) ? 'v' : '-'; - s += (_flags & SourceGCell) ? 's' : '-'; - s += (_flags & TargetGCell) ? 't' : '-'; - s += (_flags & Invalidated) ? 'i' : '-'; - s += (_flags & Destroy ) ? 'D' : '-'; - s += (_flags & PitchAbove ) ? 'A' : '-'; - s += (_flags & PitchBelow ) ? 'B' : '-'; + s += (_flags & Horizontal ) ? 'h' : '-'; + s += (_flags & Vertical ) ? 'v' : '-'; + s += (_flags & SourceGCell ) ? 'S' : '-'; + s += (_flags & TargetGCell ) ? 'T' : '-'; + s += (_flags & DeviceGCell ) ? 'd' : '-'; + s += (_flags & ChannelGCell) ? 'c' : '-'; + s += (_flags & StrutGCell ) ? 's' : '-'; + s += (_flags & MatrixGCell ) ? 'm' : '-'; + s += ","; + s += (_flags & Invalidated ) ? 'i' : '-'; + s += (_flags & Destroy ) ? 'D' : '-'; + s += (_flags & PitchAbove ) ? 'A' : '-'; + s += (_flags & PitchBelow ) ? 'B' : '-'; return s; } diff --git a/anabatic/src/Dijkstra.cpp b/anabatic/src/Dijkstra.cpp index 5775f487..4141cb11 100644 --- a/anabatic/src/Dijkstra.cpp +++ b/anabatic/src/Dijkstra.cpp @@ -300,23 +300,7 @@ namespace Anabatic { // We did reach another target (different ). // Tag back the path, with a higher . - int branchId = _sources.size(); - cdebug_log(112,0) << "Trace back branchId:" << branchId << endl; - _targets.erase( current ); - while ( current ) { - cdebug_log(112,0) << "| " << current << endl; - if (current->getConnexId() == _connectedsId) break; - - _sources.insert( current ); - current->setDistance( 0.0 ); - current->setConnexId( _connectedsId ); - current->setBranchId( branchId ); - _queue.push( current ); - - current = current->getPredecessor(); - } - - cdebug_tabw(112,-1); + _traceback( current ); return true; } @@ -329,6 +313,59 @@ namespace Anabatic { } + void Dijkstra::_traceback ( Vertex* current ) + { + cdebug_log(112,1) << "Dijkstra::_traceback() " << _net << " branchId:" << _sources.size() << endl; + + int branchId = _sources.size(); + _targets.erase( current ); + + while ( current ) { + cdebug_log(112,0) << "| " << current << endl; + if (current->getConnexId() == _connectedsId) break; + + Edge* from = current->getFrom(); + if (not from) break; + from->incRealOccupancy( 1 ); + + _sources.insert( current ); + current->setDistance( 0.0 ); + current->setConnexId( _connectedsId ); + current->setBranchId( branchId ); + _queue.push( current ); + + Vertex* source = current; + Vertex* target = source->getPredecessor(); + current = target; + + if ( (source->getGCell()->getXMin() > target->getGCell()->getXMin()) + or (source->getGCell()->getYMin() > target->getGCell()->getYMin()) ) + std::swap( source, target ); + + Contact* sourceContact = source->getGContact( _net ); + Contact* targetContact = target->getGContact( _net ); + + if (from->isHorizontal()) { + Horizontal::create( sourceContact + , targetContact + , _anabatic->getConfiguration()->getGHorizontalLayer() + , from->getAxis() + , DbU::fromLambda(2.0) + ); + } else { + Vertical::create( sourceContact + , targetContact + , _anabatic->getConfiguration()->getGVerticalLayer() + , from->getAxis() + , DbU::fromLambda(2.0) + ); + } + } + + cdebug_tabw(112,-1); + } + + void Dijkstra::run ( Dijkstra::Mode mode ) { DebugSession::open( _net, 112, 120 ); @@ -363,7 +400,6 @@ namespace Anabatic { while ( not _targets.empty() and _propagate(enabledEdges) ); - _toWires(); _queue.clear(); cdebug_tabw(112,-1); @@ -371,47 +407,4 @@ namespace Anabatic { } - void Dijkstra::_toWires () - { - cdebug_log(111,1) << "Dijkstra::toWires() " << _net << endl; - - for ( Vertex* vertex : _sources ) { - Edge* from = vertex->getFrom(); - if (not from) continue; - - cdebug_log(111,0) << "| " << vertex << endl; - - from->incRealOccupancy( 1 ); - - Vertex* source = vertex; - Vertex* target = source->getPredecessor(); - - if ( (source->getGCell()->getXMin() > target->getGCell()->getXMin()) - or (source->getGCell()->getYMin() > target->getGCell()->getYMin()) ) - std::swap( source, target ); - - Contact* sourceContact = source->getGContact( _net ); - Contact* targetContact = target->getGContact( _net ); - - if (from->isHorizontal()) { - Horizontal::create( sourceContact - , targetContact - , _anabatic->getConfiguration()->getGHorizontalLayer() - , from->getAxis() - , DbU::fromLambda(2.0) - ); - } else { - Vertical::create( sourceContact - , targetContact - , _anabatic->getConfiguration()->getGVerticalLayer() - , from->getAxis() - , DbU::fromLambda(2.0) - ); - } - } - - cdebug_tabw(111,-1); - } - - } // Anabatic namespace. diff --git a/anabatic/src/anabatic/Constants.h b/anabatic/src/anabatic/Constants.h index d3ccde41..28686899 100644 --- a/anabatic/src/anabatic/Constants.h +++ b/anabatic/src/anabatic/Constants.h @@ -29,15 +29,19 @@ namespace Anabatic { , Vertical = (1<<1) , SourceGCell = (1<<2) , TargetGCell = (1<<3) - , Invalidated = (1<<4) - , Destroy = (1<<5) + , DeviceGCell = (1<<4) + , ChannelGCell = (1<<5) + , StrutGCell = (1<<6) + , MatrixGCell = (1<<7) + , Invalidated = (1<<8) + , Destroy = (1<<9) , WestSide = Horizontal|TargetGCell , EastSide = Horizontal|SourceGCell , SouthSide = Vertical |TargetGCell , NorthSide = Vertical |SourceGCell , AllSides = WestSide|EastSide|SouthSide|NorthSide - , PitchAbove = (1<<6) - , PitchBelow = (1<<7) + , PitchAbove = (1<<10) + , PitchBelow = (1<<11) }; public: inline Flags ( unsigned int flags = NoFlags ); diff --git a/anabatic/src/anabatic/Dijkstra.h b/anabatic/src/anabatic/Dijkstra.h index 02d496f5..18e8a6e8 100644 --- a/anabatic/src/anabatic/Dijkstra.h +++ b/anabatic/src/anabatic/Dijkstra.h @@ -22,6 +22,7 @@ #include "hurricane/Observer.h" namespace Hurricane { class Net; + class RoutingPad; } #include "anabatic/GCell.h" @@ -32,6 +33,7 @@ namespace Anabatic { using std::multiset; using Hurricane::Observer; using Hurricane::Net; + using Hurricane::RoutingPad; class AnabaticEngine; @@ -52,6 +54,7 @@ namespace Anabatic { inline Vertex ( GCell* ); //inline Vertex ( size_t id ); inline ~Vertex (); + inline bool hasDoneAllRps () const; inline unsigned int getId () const; inline GCell* getGCell () const; inline AnabaticEngine* getAnabatic () const; @@ -69,53 +72,55 @@ namespace Anabatic { inline void setConnexId ( int ); inline void setBranchId ( int ); inline void setFrom ( Edge* ); + inline void add ( RoutingPad* ); + inline void clearRps (); // Inspector support. string _getString () const; private: Vertex ( const Vertex& ); Vertex& operator= ( const Vertex& ); private: - size_t _id; - GCell* _gcell; - Observer _observer; - int _connexId; - int _branchId; - int _stamp; - DbU::Unit _distance; - Edge* _from; + size_t _id; + GCell* _gcell; + Observer _observer; + int _connexId; + int _branchId; + int _stamp; + DbU::Unit _distance; + Edge* _from; }; inline Vertex::Vertex ( GCell* gcell ) - : _id (gcell->getId()) - , _gcell (gcell) - , _observer(this) - , _connexId(-1) - , _branchId( 0) - , _stamp (-1) - , _distance(unreached) - , _from (NULL) + : _id (gcell->getId()) + , _gcell (gcell) + , _observer (this) + , _connexId (-1) + , _branchId ( 0) + , _stamp (-1) + , _distance (unreached) + , _from (NULL) { gcell->setObserver( GCell::Observable::Vertex, &_observer ); } - inline Vertex::~Vertex () { } - inline unsigned int Vertex::getId () const { return _id; } - inline GCell* Vertex::getGCell () const { return _gcell; } - inline AnabaticEngine* Vertex::getAnabatic () const { return _gcell->getAnabatic(); } - inline Contact* Vertex::getGContact ( Net* net ) { return _gcell->getGContact(net); } - inline Point Vertex::getCenter () const { return _gcell->getBoundingBox().getCenter(); } - inline DbU::Unit Vertex::getDistance () const { return hasValidStamp() ? _distance : unreached; } - inline int Vertex::getStamp () const { return _stamp; } - inline int Vertex::getConnexId () const { return hasValidStamp() ? _connexId : -1; } - inline int Vertex::getBranchId () const { return hasValidStamp() ? _branchId : 0; } - inline Edge* Vertex::getFrom () const { return _from; } - inline void Vertex::setDistance ( DbU::Unit distance ) { _distance=distance; } - inline void Vertex::setFrom ( Edge* from ) { _from=from; } - inline void Vertex::setStamp ( int stamp ) { _stamp=stamp; } - inline void Vertex::setConnexId ( int id ) { _connexId=id; } - inline void Vertex::setBranchId ( int id ) { _branchId=id; } + inline Vertex::~Vertex () { } + inline unsigned int Vertex::getId () const { return _id; } + inline GCell* Vertex::getGCell () const { return _gcell; } + inline AnabaticEngine* Vertex::getAnabatic () const { return _gcell->getAnabatic(); } + inline Contact* Vertex::getGContact ( Net* net ) { return _gcell->getGContact(net); } + inline Point Vertex::getCenter () const { return _gcell->getBoundingBox().getCenter(); } + inline DbU::Unit Vertex::getDistance () const { return hasValidStamp() ? _distance : unreached; } + inline int Vertex::getStamp () const { return _stamp; } + inline int Vertex::getConnexId () const { return hasValidStamp() ? _connexId : -1; } + inline int Vertex::getBranchId () const { return hasValidStamp() ? _branchId : 0; } + inline Edge* Vertex::getFrom () const { return _from; } + inline void Vertex::setDistance ( DbU::Unit distance ) { _distance=distance; } + inline void Vertex::setFrom ( Edge* from ) { _from=from; } + inline void Vertex::setStamp ( int stamp ) { _stamp=stamp; } + inline void Vertex::setConnexId ( int id ) { _connexId=id; } + inline void Vertex::setBranchId ( int id ) { _branchId=id; } inline Vertex* Vertex::getPredecessor () const { return (hasValidStamp() and _from) ? _from->getOpposite(_gcell)->getObserver(GCell::Observable::Vertex) : NULL; } @@ -227,8 +232,8 @@ namespace Anabatic { Dijkstra& operator= ( const Dijkstra& ); static DbU::Unit _distance ( const Vertex*, const Vertex*, const Edge* ); bool _propagate ( Flags enabledSides ); + void _traceback ( Vertex* ); void _selectFirstSource (); - void _toWires (); private: AnabaticEngine* _anabatic; vector _vertexes; diff --git a/anabatic/src/anabatic/GCell.h b/anabatic/src/anabatic/GCell.h index 1c742fef..8833765c 100644 --- a/anabatic/src/anabatic/GCell.h +++ b/anabatic/src/anabatic/GCell.h @@ -75,6 +75,10 @@ namespace Anabatic { inline bool isHFlat () const; inline bool isVFlat () const; inline bool isFlat () const; + inline bool isDevice () const; + inline bool isChannel () const; + inline bool isStrut () const; + inline bool isMatrix () const; inline AnabaticEngine* getAnabatic () const; inline DbU::Unit getXMin () const; inline DbU::Unit getYMin () const; @@ -153,6 +157,10 @@ namespace Anabatic { inline bool GCell::isHFlat () const { return getYMin() == getYMax(); } inline bool GCell::isVFlat () const { return getXMin() == getXMax(); } inline bool GCell::isFlat () const { return isHFlat() or isVFlat(); } + inline bool GCell::isDevice () const { return _flags & Flags::DeviceGCell; } + inline bool GCell::isChannel () const { return _flags & Flags::ChannelGCell; } + inline bool GCell::isStrut () const { return _flags & Flags::StrutGCell; } + inline bool GCell::isMatrix () const { return _flags & Flags::MatrixGCell; } inline AnabaticEngine* GCell::getAnabatic () const { return _anabatic; } inline DbU::Unit GCell::getXMin () const { return _xmin; } inline DbU::Unit GCell::getYMin () const { return _ymin; }