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 dba0342b..a9f5ac15 100644 --- a/anabatic/src/Dijkstra.cpp +++ b/anabatic/src/Dijkstra.cpp @@ -343,23 +343,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; } @@ -372,6 +356,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 ); @@ -406,7 +443,6 @@ namespace Anabatic { while ( not _targets.empty() and _propagate(enabledEdges) ); - _toWires(); _queue.clear(); cdebug_tabw(112,-1); @@ -414,47 +450,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 ed03a3d7..b94e1907 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; @@ -59,6 +61,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; @@ -76,6 +79,8 @@ namespace Anabatic { inline void setConnexId ( int ); inline void setBranchId ( int ); inline void setFrom ( Edge* ); + inline void add ( RoutingPad* ); + inline void clearRps (); inline bool isNorth ( Vertex* ) const; inline bool isSouth ( Vertex* ) const; @@ -85,21 +90,21 @@ namespace Anabatic { inline bool isSRestricted () const; inline bool isERestricted () const; inline bool isWRestricted () const; + // 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; - FlagR _flags; + size_t _id; + GCell* _gcell; + Observer _observer; + int _connexId; + int _branchId; + int _stamp; + DbU::Unit _distance; + Edge* _from; }; @@ -118,22 +123,22 @@ namespace Anabatic { } - 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; } @@ -253,9 +258,10 @@ 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 (); - + bool isRestricted ( const Vertex* v1, const Vertex* v2 ) const; private: AnabaticEngine* _anabatic; diff --git a/anabatic/src/anabatic/GCell.h b/anabatic/src/anabatic/GCell.h index 7cab666e..b81201db 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; @@ -158,6 +162,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; }