diff --git a/anabatic/src/Dijkstra.cpp b/anabatic/src/Dijkstra.cpp index ed8e7ebe..d5d44d29 100644 --- a/anabatic/src/Dijkstra.cpp +++ b/anabatic/src/Dijkstra.cpp @@ -26,7 +26,6 @@ #include "crlcore/Utilities.h" #include "anabatic/AnabaticEngine.h" #include "anabatic/Dijkstra.h" - #include "hurricane/DataBase.h" #include "hurricane/viewer/CellViewer.h" #include "hurricane/Technology.h" @@ -50,38 +49,6 @@ namespace Anabatic { using Hurricane::NetRoutingExtension; - -// ------------------------------------------------------------------- -// Class : "Anabatic::Symmetry". - - - Symmetry::Symmetry( unsigned int type, DbU::Unit value ) - { - if (type == sHorizontal) setAsH(); - else if (type == sVertical ) setAsV(); - - _value = value; - } - - - Symmetry::~Symmetry() {} - - - Symmetry* Symmetry::create( unsigned int type, DbU::Unit value ) - { - return new Symmetry( type, value ); - } - - - unsigned int Symmetry::getType() const - { - if (_flags & sHorizontal) return sHorizontal; - else if (_flags & sVertical ) return sVertical; - else return 0; - } - - - // ------------------------------------------------------------------- // Class : "Anabatic::IntervalC". @@ -91,18 +58,31 @@ namespace Anabatic { _min = Vertex::unreached; _max = Vertex::unreached; _axis = Vertex::unreached; + _flags = 0; + } + + + IntervalC::IntervalC(IntervalC& i) + { + _min = i.getMin(); + _max = i.getMax(); + _axis = i.getAxis(); + setFlags(i.getFlags()); + } + + + IntervalC::IntervalC(const IntervalC& i) + { + _min = i.getMin(); + _max = i.getMax(); + _axis = i.getAxis(); + setFlags(i.getFlags()); } IntervalC::~IntervalC() {} - IntervalC* IntervalC::create() - { - return new IntervalC(); - } - - void IntervalC::set ( DbU::Unit min, DbU::Unit max, DbU::Unit axis ) { _min = min; @@ -137,9 +117,10 @@ namespace Anabatic { if (_max < vmax) _max = vmax; } + void IntervalC::print() const { - cerr << "[IntervalC]: min: " << DbU::getValueString(_min) << ", max:" << DbU::getValueString(_min) << ", axis:" << DbU::getValueString(_axis) << endl; + cdebug_log(112,0) << "[IntervalC]: min: " << DbU::getValueString(_min) << ", max:" << DbU::getValueString(_max) << ", axis:" << DbU::getValueString(_axis) << endl; } @@ -151,6 +132,37 @@ namespace Anabatic { _flags &= ~iSet; } +// ------------------------------------------------------------------- +// Class : "Anabatic::GRAData". + GRAData::GRAData () + : _intervfrom (IntervalC()) + , _interv (IntervalC()) + , _from2 (NULL) + , _intervfrom2 (IntervalC()) + {} + + + GRAData::~GRAData() {} + + + GRAData* GRAData::create() + { + return new GRAData(); + } + + + void GRAData::resetIntervals() + { + _interv.reset(); + _intervfrom.reset(); + } + + + void GRAData::clearFrom2 () + { + _from2 = NULL; + } + // ------------------------------------------------------------------- // Class : "Anabatic::Vertex". @@ -219,7 +231,7 @@ namespace Anabatic { } - bool Vertex::isRestricted ( const Vertex* v1, const Vertex* v2 ) + bool Vertex::isRestricted ( const Vertex* v1, const Vertex* v2, DbU::Unit hpitch, DbU::Unit vpitch ) { bool restricted = true; GCell* c1 = v1->getGCell(); @@ -238,299 +250,337 @@ namespace Anabatic { cerr << Error( "GCells are not side by side." ) << endl; return true; } - - if (restricted) return true; + + if ( (c1->getWidth() < hpitch) + ||(c1->getHeight() < vpitch) + ||(restricted) + ) return true; else { + restricted = true; // Check from GCell 2 if ( c2->isNorth(c1) ) { - if ( v2->isNRestricted() ) return true; - else return false; + if ( !v2->isNRestricted() ) restricted = false; } else if ( c2->isSouth(c1) ) { - if ( v2->isSRestricted() ) return true; - else return false; + if ( !v2->isSRestricted() ) restricted = false; } else if ( c2->isEast (c1) ) { - if ( v2->isERestricted() ) return true; - else return false; + if ( !v2->isERestricted() ) restricted = false; } else if ( c2->isWest (c1) ) { - if ( v2->isWRestricted() ) return true; - else return false; + if ( !v2->isWRestricted() ) restricted = false; } else { cerr << Error( "GCells are not side by side." ) << endl; return true; } + if ( (c2->getWidth() < hpitch) + ||(c2->getHeight() < vpitch) + ||(restricted) + ) return true; + else return false; } } - Point Vertex::getNextPathPoint2( const Vertex* vcurr, const Vertex* vnext ) + Point Vertex::getNextPathPoint( Point pcurr, const Vertex* vnext ) const { - //cdebug_log(112,0) << "Point Dijkstra::getNextPathPoint( const Vertex* current, const Vertex* next )" << endl; - if ((vcurr == NULL) || (vnext == NULL)){ - //cdebug_log(112,0) << "Error(Point Dijkstra::_getNextPathPoint( const Vertex*, const Vertex* )): Unvalid NULL argument."<< endl; + cdebug_log(112,1) << "Point Dijkstra::getNextPathPoint( Point pcurr, const Vertex* vnext )" << endl; + if (vnext == NULL){ + cdebug_tabw(112,-1); return Point(0,0); } if (vnext->getGCell()->isMatrix()) { + cdebug_tabw(112,-1); return Point(vnext->getGCell()->getXCenter(), vnext->getGCell()->getYCenter()); } - Point pcurr = vcurr->getPathPoint(vnext); GCell* gnext = vnext->getGCell(); - GCell* gcurr = vcurr->getGCell(); + GCell* gcurr = getGCell(); DbU::Unit x = 0; DbU::Unit y = 0; if (vnext->isV()){ - //cdebug_log(112,0) << "Case next: Vertical: " << vnext->isiSet() << endl; //", d:" << vnext->getDistance() << endl; + cdebug_log(112,0) << "Case next: Vertical: " << vnext->isiSet() << endl; //", d:" << vnext->getDistance() << endl; if ((vnext->isiSet())&&(vnext->hasValidStamp())){ - //cdebug_log(112,0) << "Case set" << endl; + cdebug_log(112,0) << "Case set" << endl; x = vnext->getIAxis(); - if (vcurr->isNorth(vnext)) y = vnext->getIMin(); - else if (vcurr->isSouth(vnext)) y = vnext->getIMax(); - else if ((vcurr->isWest(vnext))||(vcurr->isEast(vnext))) { + if (isNorth(vnext)) y = vnext->getIMin(); + else if (isSouth(vnext)) y = vnext->getIMax(); + else if ((isWest(vnext))||(isEast(vnext))) { if ( pcurr.getY() > vnext->getIMax() ) y = vnext->getIMax(); else if ( pcurr.getY() < vnext->getIMin() ) y = vnext->getIMin(); else y = pcurr.getY(); - } else cdebug_log(112,0) << "Error(Point Vertex::getNextPathPoint2(...) const: Something is wrong.1" << endl; + } else cdebug_log(112,0) << "[ERROR](Point Vertex::getNextPathPoint2(...) const: Something is wrong.1" << endl; } else { - //cdebug_log(112,0) << "Case not set" << endl; - if (vcurr->isNorth(vnext)){ + cdebug_log(112,0) << "Case not set" << endl; + if (isNorth(vnext)){ y = gcurr->getYMax(); if (pcurr.getX() < gnext->getXMin()) x = gnext->getXMin(); else if (pcurr.getX() > gnext->getXMax()) x = gnext->getXMax(); else x = pcurr.getX(); - } else if (vcurr->isSouth(vnext)){ + } else if (isSouth(vnext)){ y = gcurr->getYMin(); if (pcurr.getX() < gnext->getXMin()) x = gnext->getXMin(); else if (pcurr.getX() > gnext->getXMax()) x = gnext->getXMax(); else x = pcurr.getX(); - } else if (vcurr->isWest(vnext)){ + } else if (isWest(vnext)){ x = gcurr->getXMin(); if (pcurr.getY() < gnext->getYMin()) y = gnext->getYMin(); else if (pcurr.getY() > gnext->getYMax()) y = gnext->getYMax(); else y = pcurr.getY(); - } else if (vcurr->isEast(vnext)){ + } else if (isEast(vnext)){ x = gcurr->getXMax(); if (pcurr.getY() < gnext->getYMin()) y = gnext->getYMin(); else if (pcurr.getY() > gnext->getYMax()) y = gnext->getYMax(); else y = pcurr.getY(); - } else cdebug_log(112,0) << "Error(Point Vertex::getNextPathPoint2(...) const: Something is wrong.2" << endl; + } else cdebug_log(112,0) << "[ERROR](Point Vertex::getNextPathPoint2(...) const: Something is wrong.2" << endl; } } else if (vnext->isH()) { - //cdebug_log(112,0) << "Case next: Horizontal: " << vnext->isiSet() << endl; //", d:" << vnext->getDistance() << endl; + cdebug_log(112,0) << "Case next: Horizontal: " << vnext->isiSet() << endl; //", d:" << vnext->getDistance() << endl; if ((vnext->isiSet())&&(vnext->hasValidStamp())){ - //cdebug_log(112,0) << "Case set" << endl; + cdebug_log(112,0) << "Case set" << endl; y = vnext->getIAxis(); - if (vcurr->isEast (vnext)) x = vnext->getIMin(); - else if (vcurr->isWest (vnext)) x = vnext->getIMax(); - else if ((vcurr->isNorth(vnext))||(vcurr->isSouth(vnext))) { + if (isEast (vnext)) x = vnext->getIMin(); + else if (isWest (vnext)) x = vnext->getIMax(); + else if ((isNorth(vnext))||(isSouth(vnext))) { if ( pcurr.getX() > vnext->getIMax() ) x = vnext->getIMax(); else if ( pcurr.getX() < vnext->getIMin() ) x = vnext->getIMin(); else x = pcurr.getX(); - } else cdebug_log(112,0) << "Error(Point Vertex::getNextPathPoint2(...) const: Something is wrong.3" << endl; + } else cdebug_log(112,0) << "[ERROR](Point Vertex::getNextPathPoint2(...) const: Something is wrong.3" << endl; } else { - //cdebug_log(112,0) << "Case not set" << endl; - if (vcurr->isNorth(vnext)){ + cdebug_log(112,0) << "Case not set" << endl; + if (isNorth(vnext)){ y = gcurr->getYMax(); if (pcurr.getX() < gnext->getXMin()) x = gnext->getXMin(); else if (pcurr.getX() > gnext->getXMax()) x = gnext->getXMax(); else x = pcurr.getX(); - } else if (vcurr->isSouth(vnext)){ + } else if (isSouth(vnext)){ y = gcurr->getYMin(); if (pcurr.getX() < gnext->getXMin()) x = gnext->getXMin(); else if (pcurr.getX() > gnext->getXMax()) x = gnext->getXMax(); else x = pcurr.getX(); - } else if (vcurr->isWest(vnext)){ + } else if (isWest(vnext)){ x = gcurr->getXMin(); if (pcurr.getY() < gnext->getYMin()) y = gnext->getYMin(); else if (pcurr.getY() > gnext->getYMax()) y = gnext->getYMax(); else y = pcurr.getY(); - } else if (vcurr->isEast(vnext)){ + } else if (isEast(vnext)){ x = gcurr->getXMax(); if (pcurr.getY() < gnext->getYMin()) y = gnext->getYMin(); else if (pcurr.getY() > gnext->getYMax()) y = gnext->getYMax(); else y = pcurr.getY(); - } else cdebug_log(112,0) << "Error(Point Vertex::getNextPathPoint2(...) const: Something is wrong.4" << endl; + } else cdebug_log(112,0) << "[ERROR](Point Vertex::getNextPathPoint2(...) const: Something is wrong.4" << endl; } } else { - cdebug_log(112,0) << "Error(Point Vertex::getNextPathPoint2(...) const: Something is wrong.5" << endl; + cdebug_log(112,0) << "[ERROR](Point Vertex::getNextPathPoint2(...) const: Something is wrong.5" << endl; } + cdebug_tabw(112,-1); return Point(x,y); } - Point Vertex::getPathPoint( const Vertex* next ) const + Point Vertex::getStartPathPoint( const Vertex* next ) const { - //cdebug_log(112,0) << "Point Vertex::getPathPoint( const Vertex* next ) const:" << this << endl; - - GCell* gcurr = getGCell(); - GCell* gnext = next->getGCell(); - DbU::Unit x = 0; - DbU::Unit y = 0; + cdebug_log(112,1) << "Point Vertex::getStartPathPoint( const Vertex* next ) const:" << this << endl; + GCell* gcurr = getGCell(); + GCell* gnext = next->getGCell(); + DbU::Unit x = 0; + DbU::Unit y = 0; + IntervalC intervfrom = IntervalC(); + + if (_adata == NULL){ + cdebug_log(112,1) << "Point Vertex::getStartPathPoint( const Vertex* next ) const: GRAData unset." << endl; + return Point(0,0); + } if (gcurr->isDevice ()){ - //cdebug_log(112,0) << "Case device" << endl; + cdebug_log(112,0) << "Case device" << endl; if (isH()){ - //cdebug_log(112,0) << "hinterval: " << DbU::getValueString(_interv->getAxis()) << endl; - y = _interv->getAxis(); - if ((gnext->getXMax() < _interv->getMin())||(isWest (next))) x = _interv->getMin(); - else if ((gnext->getXMin() > _interv->getMax())||(isEast (next))) x = _interv->getMax(); - else x = (max(gnext->getXMin(), _interv->getMin())+min(gnext->getXMax(), _interv->getMax()))/2; + cdebug_log(112,0) << "hinterval: " << DbU::getValueString(getIAxis()) << endl; + y = getIAxis(); + if ((gnext->getXMax() < getIMin())||(isWest (next))) x = getIMin(); + else if ((gnext->getXMin() > getIMax())||(isEast (next))) x = getIMax(); + else x = (max(gnext->getXMin(), getIMin())+min(gnext->getXMax(), getIMax()))/2; } else if (isV()){ - //cdebug_log(112,0) << "vinterval" << endl; - x = _interv->getAxis(); - if ((gnext->getYMax() < _interv->getMin())||(isSouth(next))) y = _interv->getMin(); - else if ((gnext->getYMin() > _interv->getMax())||(isNorth(next))) y = _interv->getMax(); - else y = (max(gnext->getYMin(), _interv->getMin())+min(gnext->getYMax(), _interv->getMax()))/2 ; + cdebug_log(112,0) << "vinterval" << endl; + x = getIAxis(); + if ((gnext->getYMax() < getIMin())||(isSouth(next))) y = getIMin(); + else if ((gnext->getYMin() > getIMax())||(isNorth(next))) y = getIMax(); + else y = (max(gnext->getYMin(), getIMin())+min(gnext->getYMax(), getIMax()))/2 ; } else { - cdebug_log(112,0) << "Error(Point Vertex::getPathPoint( Vertex * vertex ) const: Something is wrong." << endl; + cdebug_log(112,0) << "[ERROR](Point Vertex::getStartPathPoint( const Vertex * next ) const: Something is wrong." << endl; + cdebug_tabw(112,-1); return Point(0,0); } } else if (isH()) { - //cdebug_log(112,0) << "Case horizontal: " << isiSet() << endl; - GCell* gprev = getFrom()->getOpposite(gcurr); - Vertex* prev = gprev->getObserver(GCell::Observable::Vertex); + cdebug_log(112,0) << "Case horizontal: " << isiSet() << endl; + GCell* gprev = getGPrev(Vertex::From2Mode); + intervfrom = getIntervFrom(From2Mode); + Vertex* prev = gprev->getObserver(GCell::Observable::Vertex); + cdebug_log(112,0) << "PREV: " << prev << " "; + intervfrom.print(); + if (isiSet()){ - //cdebug_log(112,0) << "isiSet" << endl; - y = _interv->getAxis(); - if ((gnext->getXMax() < _interv->getMin())||(isWest (next))) x = _interv->getMin(); - else if ((gnext->getXMin() > _interv->getMax())||(isEast (next))) x = _interv->getMax(); - else x = (max(gnext->getXMin(), _interv->getMin())+min(gnext->getXMax(), _interv->getMax()))/2; + cdebug_log(112,0) << "isiSet: "; + printInterv(); + y = getIAxis(); + if ((gnext->getXMax() < getIMin())||(isWest (next))) x = getIMin(); + else if ((gnext->getXMin() > getIMax())||(isEast (next))) x = getIMax(); + else x = (max(gnext->getXMin(), getIMin())+min(gnext->getXMax(), getIMax()))/2; } else { if (prev->isH()){ - //cdebug_log(112,0) << "prev is H" << endl; - if (isNorth(prev)){ - x = (max(_intervfrom->getMin(), gcurr->getXMin())+min(_intervfrom->getMax(), gcurr->getXMax()))/2 ; - y = gcurr->getYMax(); - } else if (isSouth(prev)){ - x = (max(_intervfrom->getMin(), gcurr->getXMin())+min(_intervfrom->getMax(), gcurr->getXMax()))/2 ; - y = gcurr->getYMin(); - } else if (isWest (prev)){ - x = gcurr->getXMin(); - y = _intervfrom->getAxis(); - } else if (isEast (prev)){ - x = gcurr->getXMax(); - y = _intervfrom->getAxis(); - } else { - cdebug_log(112,0) << "Error(Point Vertex::getPathPoint( Vertex * vertex ) const: Something is wrong." << endl; - return Point(0,0); - } + cdebug_log(112,0) << "prev is H" << endl; + if (gnext->getXMax() < intervfrom.getMin()) x = intervfrom.getMin(); + else if (gnext->getXMin() > intervfrom.getMax()) x = intervfrom.getMax(); + else x = (max(gnext->getXMin(), intervfrom.getMin())+min(gnext->getXMax(), intervfrom.getMax()))/2; + if (isNorth(prev)) y = gcurr->getYMax(); + else if (isSouth(prev)) y = gcurr->getYMin(); + else y = intervfrom.getAxis(); } else if (prev->isV()){ cdebug_log(112,0) << "prev is V" << endl; + if (isNorth(prev)){ //cdebug_log(112,0) << "1" << endl; - x = _intervfrom->getAxis(); + x = intervfrom.getAxis(); y = gcurr->getYMax(); } else if (isSouth(prev)){ //cdebug_log(112,0) << "2" << endl; - x = _intervfrom->getAxis(); + x = intervfrom.getAxis(); y = gcurr->getYMin(); } else if (isWest (prev)){ //cdebug_log(112,0) << "3" << endl; x = gcurr->getXMin(); - if ( _intervfrom->getMin() > gcurr->getYMax() ){ - y = gcurr->getYMax(); - } else if ( _intervfrom->getMax() < gcurr->getYMin() ){ - y = gcurr->getYMin(); - } else { - y = (max(_intervfrom->getMin(), gcurr->getYMin())+min(_intervfrom->getMax(), gcurr->getYMax()))/2 ; + if (isNorth(next)){ + if (intervfrom.getMax() > gcurr->getYMax()) y = gcurr->getYMax(); + else y = intervfrom.getMax(); + } else if (isSouth(next)){ + if (intervfrom.getMin() < gcurr->getYMin()) y = gcurr->getYMin(); + else y = intervfrom.getMin(); + } else { // East side + if ( intervfrom.getMin() < gcurr->getYMin() ){ y = gcurr->getYMin(); + } else if ( intervfrom.getMax() > gcurr->getYMax() ){ y = gcurr->getYMax(); + } else { y = (intervfrom.getMin() + intervfrom.getMax())/2 ; + } } } else if (isEast (prev)){ //cdebug_log(112,0) << "4" << endl; x = gcurr->getXMax(); - if ( _intervfrom->getMin() > gcurr->getYMax() ){ - y = gcurr->getYMax(); - } else if ( _intervfrom->getMax() < gcurr->getYMin() ){ - y = gcurr->getYMin(); - } else { - y = (max(_intervfrom->getMin(), gcurr->getYMin())+min(_intervfrom->getMax(), gcurr->getYMax()))/2 ; + if (isNorth(next)){ + if (intervfrom.getMax() > gcurr->getYMax()) y = gcurr->getYMax(); + else y = intervfrom.getMax(); + } else if (isSouth(next)){ + if (intervfrom.getMin() < gcurr->getYMin()) y = gcurr->getYMin(); + else y = intervfrom.getMin(); + } else { // West side + if ( intervfrom.getMin() < gcurr->getYMin() ){ y = gcurr->getYMin(); + } else if ( intervfrom.getMax() > gcurr->getYMax() ){ y = gcurr->getYMax(); + } else { y = (intervfrom.getMin() + intervfrom.getMax())/2 ; + } } } else { - cdebug_log(112,0) << "Error(Point Vertex::getPathPoint( Vertex * vertex ) const: Something is wrong." << endl; + cdebug_log(112,0) << "[ERROR](Point Vertex::getStartPathPoint() const: Something is wrong." << endl; + cdebug_tabw(112,-1); return Point(0,0); } cdebug_log(112,0) << "x: " << DbU::getValueString(x) << ", y:" << DbU::getValueString(y) << endl; } else { - cdebug_log(112,0) << "Error(Point Vertex::getPathPoint( Vertex * vertex ) const: Something is wrong." << endl; + cdebug_log(112,0) << "[ERROR](Point Vertex::getStartPathPoint() const: Something is wrong." << endl; + cdebug_tabw(112,-1); return Point(0,0); } } } else if (isV()) { - //cdebug_log(112,0) << "Case V: " << isiSet() << endl; - GCell* gprev = getFrom()->getOpposite(gcurr); - Vertex* prev = gprev->getObserver(GCell::Observable::Vertex); + cdebug_log(112,0) << "Case vertical: " << isiSet() << endl; + //GCell* gprev = NULL; + GCell* gprev = getGPrev(Vertex::From2Mode); + intervfrom = getIntervFrom(From2Mode); + Vertex* prev = gprev->getObserver(GCell::Observable::Vertex); + cdebug_log(112,0) << "PREV: " << prev << " "; + intervfrom.print(); + if (isiSet()){ - //cdebug_log(112,0) << "isiSet" << endl; - x = _interv->getAxis(); - if ((gnext->getYMax() < _interv->getMin())||(isSouth(next))) y = _interv->getMin(); - else if ((gnext->getYMin() > _interv->getMax())||(isNorth(next))) y = _interv->getMax(); - else y = (max(gnext->getYMin(), _interv->getMin())+min(gnext->getYMax(), _interv->getMax()))/2 ; + cdebug_log(112,0) << "isiSet: "; + printInterv(); + x = getIAxis(); + if ((gnext->getYMax() <= getIMin())||(isSouth(next))){ + y = getIMin(); + } + else if ((gnext->getYMin() >= getIMax())||(isNorth(next))){ + y = getIMax(); + } + else { + y = (max(gnext->getYMin(), getIMin())+min(gnext->getYMax(), getIMax()))/2 ; + } } else { if (prev->isH()){ - //cdebug_log(112,0) << "prev is H" << endl; + cdebug_log(112,0) << "prev is H" << endl; if (isNorth(prev)){ y = gcurr->getYMax(); - if ( _intervfrom->getMin() > gcurr->getXMax() ){ - x = gcurr->getXMax(); - } else if ( _intervfrom->getMax() < gcurr->getXMin() ){ - x = gcurr->getXMin(); - } else { - x = (max(_intervfrom->getMin(), gcurr->getXMin())+min(_intervfrom->getMax(), gcurr->getXMax()))/2 ; + if (isNorth(next)){ + if (intervfrom.getMax() > gcurr->getXMax()) x = gcurr->getXMax(); + else x = intervfrom.getMax(); + } else if (isSouth(next)){ + if (intervfrom.getMin() < gcurr->getXMin()) x = gcurr->getXMin(); + else x = intervfrom.getMin(); + } else { // West side + if ( intervfrom.getMin() < gcurr->getXMin() ){ x = gcurr->getXMin(); + } else if ( intervfrom.getMax() > gcurr->getXMax() ){ x = gcurr->getXMax(); + } else { x = (intervfrom.getMin() + intervfrom.getMax())/2 ; + } } } else if (isSouth(prev)){ y = gcurr->getYMin(); - if ( _intervfrom->getMin() > gcurr->getXMax() ){ - x = gcurr->getXMax(); - } else if ( _intervfrom->getMax() < gcurr->getXMin() ){ - x = gcurr->getXMin(); - } else { - x = (max(_intervfrom->getMin(), gcurr->getXMin())+min(_intervfrom->getMax(), gcurr->getXMax()))/2 ; + if (isEast(next)){ + if (intervfrom.getMax() > gcurr->getXMax()) x = gcurr->getXMax(); + else x = intervfrom.getMax(); + } else if (isWest(next)){ + if (intervfrom.getMin() < gcurr->getXMin()) x = gcurr->getXMin(); + else x = intervfrom.getMin(); + } else { // Northside + if ( intervfrom.getMin() < gcurr->getXMin() ){ x = gcurr->getXMin(); + } else if ( intervfrom.getMax() > gcurr->getXMax() ){ x = gcurr->getXMax(); + } else { x = (intervfrom.getMin() + intervfrom.getMax())/2 ; + } } } else if (isWest (prev)){ x = gcurr->getXMin(); - y = _intervfrom->getAxis(); + y = intervfrom.getAxis(); } else if (isEast (prev)){ x = gcurr->getXMax(); - y = _intervfrom->getAxis(); + y = intervfrom.getAxis(); } else { - cdebug_log(112,0) << "Error(Point Vertex::getPathPoint( Vertex * vertex ) const: Something is wrong." << endl; + cdebug_log(112,0) << "[ERROR](Point Vertex::getStartPathPoint() const: Something is wrong." << endl; + cdebug_tabw(112,-1); return Point(0,0); } } else if (prev->isV()){ - //cdebug_log(112,0) << "prev is V" << endl; - if (isNorth(prev)){ - x = _intervfrom->getAxis(); - y = gcurr->getYMax(); - } else if (isSouth(prev)){ - x = _intervfrom->getAxis(); - y = gcurr->getYMin(); - } else if (isWest (prev)){ - x = gcurr->getXMin(); - y = (max(_intervfrom->getMin(), gcurr->getYMin())+min(_intervfrom->getMax(), gcurr->getYMax()))/2 ; - } else if (isEast (prev)){ - x = gcurr->getXMax(); - y = (max(_intervfrom->getMin(), gcurr->getYMin())+min(_intervfrom->getMax(), gcurr->getYMax()))/2 ; - } else { - cdebug_log(112,0) << "Error(Point Vertex::getPathPoint( Vertex * vertex ) const: Something is wrong." << endl; - return Point(0,0); + cdebug_log(112,0) << "prev is V" << endl; + if (gnext->getYMax() < intervfrom.getMin()) { y = intervfrom.getMin(); + } else if (gnext->getYMin() > intervfrom.getMax()){ y = intervfrom.getMax(); + } else{ y = (max(gnext->getYMin(), intervfrom.getMin())+min(gnext->getYMax(), intervfrom.getMax()))/2; } + + if (isEast(prev)) x = gcurr->getXMax(); + else if (isWest(prev)) x = gcurr->getXMin(); + else x = intervfrom.getAxis(); } else { - cdebug_log(112,0) << "Error(Point Vertex::getPathPoint( Vertex * vertex ) const: Something is wrong." << endl; + cdebug_log(112,0) << "[ERROR](Point Vertex::getStartPathPoint() const: Something is wrong." << endl; + cdebug_tabw(112,-1); return Point(0,0); } } } else { - cdebug_log(112,0) << "Error(Point Vertex::getPathPoint( Vertex * vertex ) const: Something is wrong." << endl; - return Point(0,0); + cdebug_log(112,0) << "[ERROR](Point Vertex::getStartPathPoint() const: Something is wrong." << endl; + cdebug_tabw(112,-1); + return Point(0,0); } + cdebug_tabw(112,-1); return Point(x,y); } @@ -538,9 +588,9 @@ namespace Anabatic { bool Vertex::isH() const { GCell* gcell = getGCell(); - if (gcell->isDevice()) return _interv->isH(); + if (gcell->isDevice()) return isiHorizontal(); else if (gcell->isHChannel()) return true; - else if (gcell->isStrut()) return gcell->getWidth() > gcell->getHeight(); + else if (gcell->isStrut()) return ((gcell->getWidth() > gcell->getHeight())||(gcell->getWidth() == gcell->getHeight())); else return false; } @@ -548,7 +598,7 @@ namespace Anabatic { bool Vertex::isV() const { GCell* gcell = getGCell(); - if (gcell->isDevice()) return _interv->isV(); + if (gcell->isDevice()) return isiVertical(); else if (gcell->isVChannel()) return true; else if (gcell->isStrut()) return gcell->getWidth() < gcell->getHeight(); else return false; @@ -557,17 +607,24 @@ namespace Anabatic { void Vertex::setIntervals ( Vertex* vcurr ) { - Point pcurr = vcurr->getPathPoint(this); - Point pnext = Vertex::getNextPathPoint2( vcurr, this ); - //cdebug_log(112,0) << "void Vertex::setIntervals ( Vertex* vcurr )" << endl; + cdebug_log(112,1) << "!SETINTERVALS! ( Vertex* vcurr )" << endl; + Point pcurr; + if (isFromFrom2()){ + vcurr->setFlags(Vertex::From2Mode); + pcurr = vcurr->getStartPathPoint(this); + vcurr->unsetFlags(Vertex::From2Mode); + } else { + pcurr = vcurr->getStartPathPoint(this); + } + Point pnext = vcurr->getNextPathPoint( pcurr, this ); cdebug_log(112,0) << "Pcurrent : X:" << DbU::getValueString(pcurr.getX()) << ", Y:" << DbU::getValueString(pcurr.getY()) << endl; - //cdebug_log(112,0) << "Pneighbour: X:" << DbU::getValueString(pnext.getX()) << ", Y:" << DbU::getValueString(pnext.getY()) << endl; + cdebug_log(112,0) << "Pneighbour: X:" << DbU::getValueString(pnext.getX()) << ", Y:" << DbU::getValueString(pnext.getY()) << endl; DbU::Unit min, max, axis; if (vcurr->isH()){ - //cdebug_log(112,0) << "case vcurr: Horizontal" << endl; + cdebug_log(112,0) << "case vcurr: Horizontal" << endl; if ((vcurr->isiSet())&&(vcurr->hasValidStamp())){ - //cdebug_log(112,0) << "case set" << endl; + cdebug_log(112,0) << "case set" << endl; if (vcurr->getIMin() > pnext.getX()) { min = pnext.getX(); max = vcurr->getIMax(); @@ -582,22 +639,59 @@ namespace Anabatic { axis = vcurr->getIAxis(); } } else { - //cdebug_log(112,0) << "case not set" << endl; + cdebug_log(112,0) << "case not set" << endl; axis = pcurr.getY(); - if (pcurr.getX() < pnext.getX()){ - min = pcurr.getX(); - max = pnext.getX(); + bool hh = false; + if (vcurr->hasValidStamp() && (vcurr->getFrom() != NULL)){ + GCell* gprev = vcurr->getGPrev(Vertex::UseFromFrom2); + Vertex* vprev = gprev->getObserver(GCell::Observable::Vertex); + if (vprev->isH()) { + cdebug_log(112,0) << "----------------------------" << endl; + cdebug_log(112,0) << "HHCASE:" << endl; + cdebug_log(112,0) << "prev: " << vprev << endl; + cdebug_log(112,0) << "curr: " << vcurr << endl; + cdebug_log(112,0) << "next: " << this << endl; + cdebug_log(112,0) << "----------------------------" << endl; + hh = true; + } + } + if (hh){ + GCell* gcurr = vcurr->getGCell(); + GCell* gnext = getGCell(); + IntervalC intervfrom = vcurr->getIntervFrom(UseFromFrom2); + vcurr->printIntervfrom(); + + if (gnext->getXMin() > intervfrom.getMax()){ + //cdebug_log(112,0) << "1" << endl; + min = intervfrom.getMax(); + max = gnext->getXMin(); + } else if (gnext->getXMax() < intervfrom.getMin()){ + //cdebug_log(112,0) << "2" << endl; + min = gnext->getXMax(); + max = intervfrom.getMin(); + } else { + //cdebug_log(112,0) << "3" << endl; + min = std::max(gcurr->getXMin(), intervfrom.getMin()); + max = std::min(gcurr->getXMax(), intervfrom.getMax()); + } } else { - max = pcurr.getX(); - min = pnext.getX(); + if (pcurr.getX() < pnext.getX()){ + //cdebug_log(112,0) << "4" << endl; + min = pcurr.getX(); + max = pnext.getX(); + } else { + //cdebug_log(112,0) << "5" << endl; + max = pcurr.getX(); + min = pnext.getX(); + } } } } else if (vcurr->isV()){ - //cdebug_log(112,0) << "case vcurr: Vertical" << endl; + cdebug_log(112,0) << "case vcurr: Vertical" << endl; if ((vcurr->isiSet())&&(vcurr->hasValidStamp())){ - //cdebug_log(112,0) << "case set" << endl; + cdebug_log(112,0) << "case set" << endl; if (vcurr->getIMin() > pnext.getY()) { min = pnext.getY(); max = vcurr->getIMax(); @@ -612,41 +706,401 @@ namespace Anabatic { axis = vcurr->getIAxis(); } } else { - //cdebug_log(112,0) << "case not set" << endl; + cdebug_log(112,0) << "case not set" << endl; axis = pcurr.getX(); - if (pcurr.getY() < pnext.getY()){ - min = pcurr.getY(); - max = pnext.getY(); + bool vv = false; + if (vcurr->hasValidStamp() && (vcurr->getFrom() != NULL)){ + GCell* gprev = vcurr->getGPrev(Vertex::UseFromFrom2); + Vertex* vprev = gprev->getObserver(GCell::Observable::Vertex); + if ((vprev->isV())) { + cdebug_log(112,0) << "----------------------------" << endl; + cdebug_log(112,0) << "VVCASE:" << endl; + cdebug_log(112,0) << "prev: " << vprev << endl; + cdebug_log(112,0) << "curr: " << vcurr << endl; + cdebug_log(112,0) << "next: " << this << endl; + cdebug_log(112,0) << "----------------------------" << endl; + vv = true; + } + } + if (vv){ + GCell* gcurr = vcurr->getGCell(); + GCell* gnext = getGCell(); + IntervalC intervfrom = vcurr->getIntervFrom(UseFromFrom2); + if (gnext->getYMin() > intervfrom.getMax()){ + //cdebug_log(112,0) << "1" << endl; + min = intervfrom.getMax(); + max = gnext->getYMin(); + } else if (gnext->getYMax() < intervfrom.getMin()){ + //cdebug_log(112,0) << "2" << endl; + min = gnext->getYMax(); + max = intervfrom.getMin(); + } else { + //cdebug_log(112,0) << "3" << endl; + min = std::max(gcurr->getYMin(), intervfrom.getMin()); + max = std::min(gcurr->getYMax(), intervfrom.getMax()); + } } else { - max = pcurr.getY(); - min = pnext.getY(); + if (pcurr.getY() < pnext.getY()){ + //cdebug_log(112,0) << "4" << endl; + min = pcurr.getY(); + max = pnext.getY(); + } else { + //cdebug_log(112,0) << "5" << endl; + max = pcurr.getY(); + min = pnext.getY(); + } } } } else { - cdebug_log(112,0) << "Error(void Vertex::setIntervals(...)): Something is wrong." << endl; + cdebug_log(112,0) << "[ERROR](void Vertex::setIntervals(...)): Something is wrong." << endl; return; } cdebug_log(112,0) << "IntervFrom => min: " << DbU::getValueString(min) << ", max: " << DbU::getValueString(max) << ", axis:" << DbU::getValueString(axis) << endl; - _intervfrom->set( min, max, axis ); + if (isFrom2Mode()) { + cdebug_log(112,0) << "SetIntervfrom2" << endl; + setIntervfrom2(min, max, axis); + } + else { + cdebug_log(112,0) << "SetIntervfrom" << endl; + setIntervfrom(min, max, axis); + } + cdebug_tabw(112,-1); } - - void Vertex::resetIntervals() + + bool Vertex::areSameSide ( const Vertex* v1, const Vertex* v2 ) const { - _interv->reset(); - _intervfrom->reset(); + if ( (isNorth(v1) and isNorth(v2)) + || (isSouth(v1) and isSouth(v2)) + || (isWest (v1) and isWest (v2)) + || (isEast (v1) and isEast (v2)) + ) return true; + else return false; } + void Vertex::createAData() + { + if (_adata == NULL) _adata = GRAData::create(); + } + + + bool Vertex::isiSet() const + { + if (_adata){ + return _adata->isiSet(); + } else { + cdebug_log(112,1) << "bool Vertex::isiSet() const: Inappropriate usage of GRAData. " << endl; + return false; + } + } + + + DbU::Unit Vertex::getIAxis() const + { + if (_adata){ + return _adata->getIAxis(); + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getIAxis() const: Inappropriate usage of GRAData. " << endl; + return 0; + } + } + + + DbU::Unit Vertex::getIMax() const + { + if (_adata){ + return _adata->getIMax(); + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getIMax() const: Inappropriate usage of GRAData. " << endl; + return 0; + } + } + + + DbU::Unit Vertex::getIMin() const + { + if (_adata){ + return _adata->getIMin(); + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getIMin() const: Inappropriate usage of GRAData. " << endl; + return 0; + } + } + + + DbU::Unit Vertex::getPIAxis() const + { + if (_adata){ + return _adata->getPIAxis(); + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getPIAxis() const: Inappropriate usage of GRAData. " << endl; + return 0; + } + } + + + DbU::Unit Vertex::getPIMax() const + { + if (_adata){ + return _adata->getPIMax(); + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getPIMax() const: Inappropriate usage of GRAData. " << endl; + return 0; + } + } + + + DbU::Unit Vertex::getPIMin() const + { + if (_adata){ + return _adata->getPIMin(); + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getPIMin() const: Inappropriate usage of GRAData. " << endl; + return 0; + } + } + + + void Vertex::setInterv( DbU::Unit min, DbU::Unit max, DbU::Unit axis ) + { + if (_adata){ + _adata->setInterv(min, max, axis); + } else { + cdebug_log(112,1) << "void Vertex::setInterv( DbU::Unit min, DbU::Unit max, DbU::Unit axis ): Inappropriate usage of GRAData. " << endl; + } + } + + + void Vertex::setIntervfrom( DbU::Unit min, DbU::Unit max, DbU::Unit axis ) + { + if (_adata){ + _adata->setIntervfrom(min, max, axis); + } else { + cdebug_log(112,1) << "void Vertex::setIntervfrom( DbU::Unit min, DbU::Unit max, DbU::Unit axis ): Inappropriate usage of GRAData. " << endl; + } + } + + + void Vertex::setIntervfrom2( DbU::Unit min, DbU::Unit max, DbU::Unit axis ) + { + if (_adata){ + _adata->setIntervfrom2(min, max, axis); + } else { + cdebug_log(112,1) << "void Vertex::setIntervfrom2( DbU::Unit min, DbU::Unit max, DbU::Unit axis ): Inappropriate usage of GRAData. " << endl; + } + } + + + void Vertex::resetIntervals() + { + if (_adata){ + _adata->resetIntervals(); + } else { + cdebug_log(112,1) << "void Vertex::resetIntervals(): Inappropriate usage of GRAData. " << endl; + } + } + + + void Vertex::clearFrom2() + { + if (_adata){ + _adata->clearFrom2(); + } else { + cdebug_log(112,1) << "void Vertex::clearfrom2(): Inappropriate usage of GRAData. " << endl; + } + } + + + Edge* Vertex::getFrom2() const + { + if (_adata){ + return _adata->getFrom2(); + } else { + cdebug_log(112,1) << "Edge* Vertex::getFrom2() const: Inappropriate usage of GRAData. " << endl; + return NULL; + } + } + + + void Vertex::setFrom2( Edge* from ) + { + if (_adata){ + _adata->setFrom2(from); + } else { + cdebug_log(112,1) << "void Vertex::setFrom2( Edge* from ): Inappropriate usage of GRAData. " << endl; + } + } + + + void Vertex::createIntervFrom2() + { + if (_adata){ + //_adata->createIntervFrom2(); + } else { + cdebug_log(112,1) << "void Vertex::createIntervFrom2(): Inappropriate usage of GRAData. " << endl; + } + } + + + DbU::Unit Vertex::getPIMax2() const + { + if (_adata){ + return _adata->getPIMax2(); + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getPIMax2() const: Inappropriate usage of GRAData. " << endl; + return 0; + } + } + + + DbU::Unit Vertex::getPIMin2() const + { + if (_adata){ + return _adata->getPIMin2(); + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getPIMin2() const: Inappropriate usage of GRAData. " << endl; + return 0; + } + } + + + DbU::Unit Vertex::getPIAxis2() const + { + if (_adata){ + return _adata->getPIAxis2(); + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getPIAxis2() const: Inappropriate usage of GRAData. " << endl; + return 0; + } + } + + + IntervalC Vertex::getIntervFrom2() const + { + if (_adata){ + return _adata->getIntervFrom2(); + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getIntervFrom2() const: Inappropriate usage of GRAData. " << endl; + return IntervalC(); + } + } + + + IntervalC Vertex::getIntervFrom( unsigned int criteria ) const + { + if (_adata){ + switch (criteria){ + case Vertex::From2Mode: + if ((isFrom2Mode())&&(getFrom2() != NULL)){ + cdebug_log(112,0) << "getIntervFrom:From2Mode:UseFrom2. " << endl; + return _adata->getIntervFrom2(); + } else { + cdebug_log(112,0) << "getIntervFrom:From2Mode:UseFrom1. " << endl; + return _adata->getIntervFrom(); + } + case Vertex::UseFromFrom2: + if ((isFromFrom2())&&(getFrom2() != NULL)){ + cdebug_log(112,0) << "getIntervFrom:UseFromFrom2:UseFrom2. " << endl; + return _adata->getIntervFrom2(); + } else { + cdebug_log(112,0) << "getIntervFrom:UseFromFrom2:UseFrom1. " << endl; + return _adata->getIntervFrom(); + } + case 0: + cdebug_log(112,0) << "getIntervFrom:Default:UseFrom1. " << endl; + return _adata->getIntervFrom(); + default: + cdebug_log(112,0) << "getIntervFrom:Default:UseFrom1. " << endl; + return _adata->getIntervFrom(); + } + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getIntervFrom(unsigned int criteria) const: Inappropriate usage of GRAData. " << endl; + return IntervalC(); + } + } + + + GCell* Vertex::getGPrev( unsigned int criteria ) const + { + if (_adata){ + switch (criteria){ + case Vertex::From2Mode: + if ((isFrom2Mode())&&(getFrom2() != NULL)){ + cdebug_log(112,0) << "getGPrev:From2Mode:UseFrom2. " << endl; + return _adata->getFrom2()->getOpposite(getGCell()); + } else { + cdebug_log(112,0) << "getGPrev:From2Mode:UseFrom1. " << endl; + if (_from) return getFrom()->getOpposite(getGCell()); + else return NULL; + } + case Vertex::UseFromFrom2: + if ((isFromFrom2())&&(getFrom2() != NULL)){ + cdebug_log(112,0) << "getGPrev:UseFromFrom2:UseFrom2. " << endl; + return _adata->getFrom2()->getOpposite(getGCell()); + } else { + cdebug_log(112,0) << "getGPrev:UseFromFrom2:UseFrom1. " << endl; + if (_from) return getFrom()->getOpposite(getGCell()); + else return NULL; + } + case 0: + cdebug_log(112,0) << "getGPrev:Default:UseFrom1. " << endl; + if (_from) return getFrom()->getOpposite(getGCell()); + else return NULL; + default: + cdebug_log(112,0) << "getGPrev:Default:UseFrom1. " << endl; + if (_from) return getFrom()->getOpposite(getGCell()); + else return NULL; + } + } else { + if (_from) return getFrom()->getOpposite(getGCell()); + else return NULL; + } + } + + + IntervalC Vertex::getInterv() const + { + if (_adata){ + return _adata->getInterv(); + } else { + cdebug_log(112,1) << "DbU::Unit Vertex::getInterv() const: Inappropriate usage of GRAData. " << endl; + return IntervalC(); + } + } + + + void Vertex::printInterv() const + { + if (_adata){ + _adata->printInterv(); + } else { + cdebug_log(112,1) << "void Vertex::printInterv() const: Inappropriate usage of GRAData. " << endl; + } + } + + + void Vertex::printIntervfrom() const + { + if (_adata){ + _adata->printIntervfrom(); + } else { + cdebug_log(112,1) << "void Vertex::printIntervfrom() const: Inappropriate usage of GRAData. " << endl; + } + } + +//////////////////////////////////////////////////////////////////// + + + string Vertex::_getString () const { if (not _gcell) { string s = ""; return s; } - string s = "getXMin()) + "-" + DbU::getValueString(_gcell->getYMin()) @@ -661,11 +1115,12 @@ namespace Anabatic { /*+ "+" + getString(_branchId) + " stamp:" + (hasValidStamp() ? "valid" : "outdated")*/ + " from:" + ((_from) ? "set" : "NULL") + //+ " from2:" + ((_adata) ? _adata->getFrom2() : "NULL") + " restricted:" + (isNRestricted() ? "N" : "-") + (isSRestricted() ? "S" : "-") + (isERestricted() ? "E" : "-") + (isWRestricted() ? "W" : "-") - + " isiSet:" +(isiSet() ? "1" : "0") + //+ " isiSet:" +(isiSet() ? "1" : "0") + ">"; return s; } @@ -707,203 +1162,12 @@ namespace Anabatic { } - DbU::Unit Dijkstra::_getDistancetoRP( Point p ) - { - - cdebug_log(112,0) << "DbU::Unit Dijkstra::_getDistancetoRP( Point p ): " << p << endl; - RoutingPad* rp = NULL; - DbU::Unit dist = 0; - Cell* cell = _anabatic->getCell(); - int cpt = 0; - - /*for ( Vertex* vertex : _sources ) { - if (vertex->hasRP()){ - for ( Component* component : cell->getComponentsUnder(vertex->getGCell()->getBoundingBox()) ){ - rp = dynamic_cast( component ); - if (rp) break; - } - if (rp) { - cdebug_log(112,0) << "Vertex: " << vertex << endl; - dist += _estimatePtoRP(p, rp, vertex ); - } - } - }*/ - for ( Vertex* vertex : _targets ) { - if (vertex->hasRP(_net)){ - for ( Component* component : cell->getComponentsUnder(vertex->getGCell()->getBoundingBox()) ){ - rp = dynamic_cast( component ); - if (rp) { - if (rp->getNet() == _net) break; - } - } - if (rp) { - DbU::Unit distance = _estimatePtoRP(p, rp, vertex ); - cdebug_log(112,0) << "Dist to Vertex: " << vertex << " IS = " << DbU::getValueString(distance) << endl; - dist += distance; - cpt++; - } - } - } - if (cpt != 0) dist = dist/cpt; - else dist = Vertex::unreachable; - return dist; - } - - DbU::Unit calcDistance( Point p1, Point p2 ) { return abs(p1.getX()-p2.getX()) + abs(p1.getY()-p2.getY()); } - DbU::Unit Dijkstra::_estimatePtoRP( Point p, RoutingPad* rp, Vertex* vertex ) - { - Horizontal* h = dynamic_cast(rp->_getEntityAsSegment()); - Vertical* v = dynamic_cast(rp->_getEntityAsSegment()); - DbU::Unit d = Vertex::unreachable; - GCell* gvertex = vertex->getGCell(); - - if (h) { - cdebug_log(112,0) << "Case: Horizontal: " << endl; - if (p.getX() < rp->getSourceX()){ - cdebug_log(112,0) << "Case: p.getX() < rp->getSourceX()" << endl; - if (p.getY() < gvertex->getYMin()){ - cdebug_log(112,0) << "Case: West South" << endl; - if ( (!vertex->isSRestricted()) - || (!vertex->isWRestricted()) ) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())); - else if (!vertex->isNRestricted()) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())) + (gvertex->getYMax() - rp->getY())*2; - else if (!vertex->isERestricted()) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())); - else d = Vertex::unreachable; - } else if (p.getY() > gvertex->getYMax()){ - cdebug_log(112,0) << "Case: West North" << endl; - if ( (!vertex->isNRestricted()) - || (!vertex->isWRestricted()) ) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())); - else if (!vertex->isSRestricted()) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())) + (rp->getY() - gvertex->getYMin())*2; - else if (!vertex->isERestricted()) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())); - else d = Vertex::unreachable; - } else { - cdebug_log(112,0) << "Case: West" << endl; - if (!vertex->isWRestricted()) d = min(d, calcDistance (p, Point(rp->getSourceX(), rp->getSourceY()))); - if (!vertex->isNRestricted()) d = min(d, calcDistance (p, Point(rp->getSourceX(), rp->getSourceY()))+ (gvertex->getYMax() - rp->getY())*2); - if (!vertex->isSRestricted()) d = min(d, calcDistance (p, Point(rp->getSourceX(), rp->getSourceY()))+ (rp->getY() - gvertex->getYMin())*2); - if (!vertex->isERestricted()) d = min(d, calcDistance (p, Point(rp->getTargetX(), rp->getTargetY()))); - } - } else if (p.getX() > rp->getTargetX()){ - cdebug_log(112,0) << "Case: p.getX() > rp->getTargetX()" << endl; - if (p.getY() < gvertex->getYMin()){ - cdebug_log(112,0) << "Case: East South" << endl; - if ( (!vertex->isSRestricted()) - || (!vertex->isERestricted()) ) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())); - else if (!vertex->isNRestricted()) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())) + (gvertex->getYMax() - rp->getY())*2; - else if (!vertex->isWRestricted()) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())); - else d = Vertex::unreachable; - } else if (p.getY() > gvertex->getYMax()){ - cdebug_log(112,0) << "Case: East North" << endl; - if ( (!vertex->isNRestricted()) - || (!vertex->isERestricted()) ) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())); - else if (!vertex->isSRestricted()) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())) + (rp->getY() - gvertex->getYMin())*2; - else if (!vertex->isWRestricted()) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())); - else d = Vertex::unreachable; - } else { - cdebug_log(112,0) << "Case: East" << endl; - if (!vertex->isERestricted()) d = min(d, calcDistance (p, Point(rp->getTargetX(), rp->getTargetY()))); - if (!vertex->isNRestricted()) d = min(d, calcDistance (p, Point(rp->getTargetX(), rp->getTargetY()))+ (gvertex->getYMax() - rp->getY())*2); - if (!vertex->isSRestricted()) d = min(d, calcDistance (p, Point(rp->getTargetX(), rp->getTargetY()))+ (rp->getY() - gvertex->getYMin())*2); - if (!vertex->isWRestricted()) d = min(d, calcDistance (p, Point(rp->getSourceX(), rp->getSourceY()))); - } - } else if (p.getY() < gvertex->getYMin()){ - cdebug_log(112,0) << "Case: South" << endl; - if (!vertex->isSRestricted()) d = min(d, rp->getY()-p.getY()); - if (!vertex->isERestricted()) d = min(d, rp->getY()-p.getY()+ (gvertex->getXMax()-p.getX())*2); - if (!vertex->isWRestricted()) d = min(d, rp->getY()-p.getY()+ (p.getX()-gvertex->getXMin())*2); - if (!vertex->isNRestricted()) d = min(d, min ( gvertex->getXMax()-p.getX() + gvertex->getYMax()-p.getY() + gvertex->getYMax()-rp->getY() - , p.getX()-gvertex->getXMin() + gvertex->getYMax()-p.getY() + gvertex->getYMax()-rp->getY() - ) - ); - } else if (p.getY() > gvertex->getYMax()){ - cdebug_log(112,0) << "Case: North" << endl; - if (!vertex->isNRestricted()) d = min(d, p.getY()-rp->getY()); - if (!vertex->isERestricted()) d = min(d, p.getY()-rp->getY()+ (gvertex->getXMax()-p.getX())*2); - if (!vertex->isWRestricted()) d = min(d, p.getY()-rp->getY()+ (p.getX()-gvertex->getXMin())*2); - if (!vertex->isSRestricted()) d = min(d, min ( gvertex->getXMax()-p.getX() + p.getY()-gvertex->getYMin() + rp->getY()-gvertex->getYMin() - , p.getX()-gvertex->getXMin() + p.getY()-gvertex->getYMin() + rp->getY()-gvertex->getYMin() - ) - ); - } - } - - if (v) { - cdebug_log(112,0) << "Case: Vertical" << endl; - if (p.getY() < rp->getSourceY()){ - cdebug_log(112,0) << "Case: p.getY() < rp->getSourceY()" << endl; - if (p.getX() < gvertex->getXMin()){ - cdebug_log(112,0) << "Case: South West" << endl; - if ( (!vertex->isSRestricted()) - || (!vertex->isWRestricted()) ) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())); - else if (!vertex->isERestricted()) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())) + (gvertex->getXMax() - rp->getX())*2; - else if (!vertex->isNRestricted()) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())); - else d = Vertex::unreachable; - } else if (p.getX() > gvertex->getXMax()){ - cdebug_log(112,0) << "Case: South East" << endl; - if ( (!vertex->isSRestricted()) - || (!vertex->isERestricted()) ) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())); - else if (!vertex->isWRestricted()) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())) + (rp->getX() - gvertex->getXMin())*2; - else if (!vertex->isNRestricted()) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())); - else d = Vertex::unreachable; - } else { - cdebug_log(112,0) << "Case: South " << endl; - if (!vertex->isSRestricted()) d = min(d, calcDistance (p, Point(rp->getSourceX(), rp->getSourceY()))); - if (!vertex->isWRestricted()) d = min(d, calcDistance (p, Point(rp->getSourceX(), rp->getSourceY()))+ (gvertex->getXMax() - rp->getX())*2); - if (!vertex->isERestricted()) d = min(d, calcDistance (p, Point(rp->getSourceX(), rp->getSourceY()))+ (rp->getX() - gvertex->getXMin())*2); - if (!vertex->isNRestricted()) d = min(d, calcDistance (p, Point(rp->getTargetX(), rp->getTargetY()))); - } - } else if (p.getY() > rp->getTargetY()){ - cdebug_log(112,0) << "Case: p.getY() > rp->getTargetY()" << endl; - if (p.getX() < gvertex->getXMin()){ - cdebug_log(112,0) << "Case: North West" << endl; - if ( (!vertex->isNRestricted()) - || (!vertex->isWRestricted()) ) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())); - else if (!vertex->isERestricted()) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())) + (gvertex->getXMax() - rp->getX())*2; - else if (!vertex->isSRestricted()) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())); - else d = Vertex::unreachable; - } else if (p.getX() > gvertex->getXMax()){ - cdebug_log(112,0) << "Case: North East" << endl; - if ( (!vertex->isNRestricted()) - || (!vertex->isERestricted()) ) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())); - else if (!vertex->isWRestricted()) d = calcDistance (p, Point(rp->getTargetX(), rp->getTargetY())) + (rp->getX() - gvertex->getXMin())*2; - else if (!vertex->isSRestricted()) d = calcDistance (p, Point(rp->getSourceX(), rp->getSourceY())); - else d = Vertex::unreachable; - } else { - cdebug_log(112,0) << "Case: North" << endl; - if (!vertex->isNRestricted()) d = min(d, calcDistance (p, Point(rp->getTargetX(), rp->getTargetY()))); - if (!vertex->isWRestricted()) d = min(d, calcDistance (p, Point(rp->getTargetX(), rp->getTargetY()))+ (gvertex->getXMax() - rp->getX())*2); - if (!vertex->isERestricted()) d = min(d, calcDistance (p, Point(rp->getTargetX(), rp->getTargetY()))+ (rp->getX() - gvertex->getXMin())*2); - if (!vertex->isSRestricted()) d = min(d, calcDistance (p, Point(rp->getSourceX(), rp->getSourceY()))); - } - } else if (p.getX() < gvertex->getXMin()){ - cdebug_log(112,0) << "Case: West" << endl; - if (!vertex->isWRestricted()) d = min(d, rp->getX()-p.getX()); - if (!vertex->isNRestricted()) d = min(d, rp->getX()-p.getX()+ (gvertex->getYMax()-p.getY())*2); - if (!vertex->isSRestricted()) d = min(d, rp->getX()-p.getX()+ (p.getY()-gvertex->getYMin())*2); - if (!vertex->isERestricted()) d = min(d, min ( gvertex->getYMax()-p.getY() + gvertex->getXMax()-p.getX() + gvertex->getXMax()-rp->getX() - , p.getY()-gvertex->getYMin() + gvertex->getXMax()-p.getX() + gvertex->getXMax()-rp->getX() - ) - ); - } else if (p.getX() > gvertex->getXMax()){ - cdebug_log(112,0) << "Case: East" << endl; - if (!vertex->isERestricted()) d = min(d, p.getX()-rp->getX()); - if (!vertex->isNRestricted()) d = min(d, p.getX()-rp->getX()+ (gvertex->getYMax()-p.getY())*2); - if (!vertex->isSRestricted()) d = min(d, p.getX()-rp->getX()+ (p.getY()-gvertex->getYMin())*2); - if (!vertex->isWRestricted()) d = min(d, min ( gvertex->getYMax()-p.getY() + p.getX()-gvertex->getXMin() + rp->getX()-gvertex->getXMin() - , p.getY()-gvertex->getYMin() + p.getX()-gvertex->getXMin() + rp->getX()-gvertex->getXMin() - ) - ); - } - } - return d; - } - - Dijkstra::Dijkstra ( AnabaticEngine* anabatic ) : _anabatic (anabatic) , _vertexes () @@ -967,6 +1231,7 @@ namespace Anabatic { vector rps; NetRoutingState* state = NetRoutingExtension::get( _net ); + if (state){ if (state->isSelfSym()){ cdebug_log(112,0) << "Dijkstra::SELF SYMMETRY CASE " << _net << endl; @@ -976,21 +1241,7 @@ namespace Anabatic { for ( Component* component : _net->getComponents() ) { RoutingPad* rp = dynamic_cast( component ); if (rp) { - if (state){ - if (state->isSelfSym()){ - if ( ( (state->isSymHorizontal())&&(rp->getBoundingBox().getYMin() > state->getSymAxis()) ) - ||( (state->isSymVertical() )&&(rp->getBoundingBox().getXMin() > state->getSymAxis()) ) - ){ - Point center = rp->getBoundingBox().getCenter(); - GCell* gcell = _anabatic->getGCellUnder( center ); - Vertex* seed = gcell->getObserver(GCell::Observable::Vertex); - Contact* vcontact = seed->getGContact( _net ); - rp->getBodyHook()->detach(); - rp->getBodyHook()->attach( vcontact->getBodyHook() ); - continue; - } - } - } + if ( _attachSymContactsHook( rp ) ) continue; // ANALOG rps.push_back( rp ); cdebug_log(112,0) << "| " << rp << endl; continue; @@ -1001,25 +1252,7 @@ namespace Anabatic { Point center = rp->getBoundingBox().getCenter(); GCell* gcell = _anabatic->getGCellUnder( center ); - if (state){ - if (state->isSymHorizontal()){ - _searchArea.merge( Box( _net->getCell()->getAbutmentBox().getXMin() - , _net->getCell()->getAbutmentBox().getYMin() - , _net->getCell()->getAbutmentBox().getXMax() - , state->getSymAxis() - ) - ); - } else if (state->isSymVertical()){ - _searchArea.merge( Box( _net->getCell()->getAbutmentBox().getXMin() - , _net->getCell()->getAbutmentBox().getYMin() - , state->getSymAxis() - , _net->getCell()->getAbutmentBox().getYMax() - ) - ); - } - } else if (gcell->isDevice()){ - _searchArea.merge( _net->getCell()->getAbutmentBox() ); - } + _limitSymSearchArea(rp); // ANALOG cdebug_log(112,0) << "| " << rp << endl; @@ -1038,17 +1271,10 @@ namespace Anabatic { _searchArea.merge( gcell->getBoundingBox() ); cdebug_log(112,0) << "New Search area: " << _searchArea << endl; - Vertex* seed = gcell->getObserver(GCell::Observable::Vertex); - Horizontal* h = dynamic_cast(rp->_getEntityAsSegment()); - Vertical* v = dynamic_cast (rp->_getEntityAsSegment()); - if (h) { - seed->setIAsH(); - seed->setInterv(rp->getBoundingBox().getXMin(), rp->getBoundingBox().getXMax(), rp->getBoundingBox().getYCenter()); - } - if (v) { - seed->setIAsV(); - seed->setInterv(rp->getBoundingBox().getYMin(), rp->getBoundingBox().getYMax(), rp->getBoundingBox().getXCenter()); - } + Vertex* seed = gcell->getObserver(GCell::Observable::Vertex); + GCell* gseed = seed->getGCell(); + + if (!gseed->isMatrix()) _setSourcesGRAData( seed, rp ); // ANALOG if (seed->getConnexId() < 0) { VertexSet connecteds; @@ -1172,8 +1398,7 @@ namespace Anabatic { current->setDistance ( Vertex::unreached ); current->setStamp ( _stamp ); current->setConnexId( -1 ); - current->setAxisTarget(); - //cdebug_log(112,0) << "AxisTarget: " << current << endl; + current->setFlags(Vertex::AxisTarget); } if (state->isSymVertical()){ @@ -1286,103 +1511,72 @@ namespace Anabatic { bool Dijkstra::_propagate ( Flags enabledSides ) { cdebug_log(112,1) << "Dijkstra::_propagate() " << _net << endl; - while ( not _queue.empty() ) { _queue.dump(); + Vertex* current = _queue.top(); + GCell* gcurrent = current->getGCell(); - Vertex* current = _queue.top(); - cdebug_log(111,0) << endl; - cdebug_log(111,0) << "[Current Vertex]: " << current << ", current->getConnexId() == _connectedsId):" << (current->getConnexId() == _connectedsId)<< ", (current->getConnexId() < 0): " << current->getConnexId() << endl; + cdebug_log(111,0) << endl << "[Current Vertex]: " << current << ", current->getConnexId() == _connectedsId):" << (current->getConnexId() == _connectedsId)<< ", (current->getConnexId() < 0): " << current->getConnexId() << endl; _queue.pop(); - if ( current->isAxisTarget() - and needAxisTarget() - ){ - unsetFlags(Mode::AxisTarget); - } else if ((current->getConnexId() == _connectedsId) or (current->getConnexId() < 0)) { + if ( current->isAxisTarget() and needAxisTarget()) unsetFlags(Mode::AxisTarget); + else if ((current->getConnexId() == _connectedsId) or (current->getConnexId() < 0)) { for ( Edge* edge : current->getGCell()->getEdges() ) { + cdebug_log(111,0) << endl << "===================================================================================" << endl << endl; if (edge == current->getFrom()) { cdebug_log(111,0) << "edge == current->getFrom()" << endl; continue; - } + } else cdebug_log(111,0) << "edge != current->getFrom()" << endl; + + if (_checkFrom2(edge, current)) continue; // ANALOG + GCell* gneighbor = edge->getOpposite(current->getGCell()); - GCell* gcurrent = current->getGCell(); Vertex* vneighbor = gneighbor->getObserver(GCell::Observable::Vertex); + if (!gneighbor->isMatrix()) vneighbor->createAData(); if (vneighbor->getConnexId() == _connectedsId) { cdebug_log(111,0) << "ConnectedsId" << endl; continue; } - if (not _searchArea.intersect(gneighbor->getBoundingBox())) { cdebug_log(111,0) << "not in _searchArea: " << _searchArea << ", gneighbor area: " << gneighbor->getBoundingBox() << endl; continue; } - cdebug_log(111,0) << endl << "===================================================================================" << endl << endl; - cdebug_log(111,0) << "| Curr: " << current; - if (current->getFrom()){ + + ////////////////////////////////////// DEBUG ////////////////////////////////////// + cdebug_log(111,0) << "| Net : " << _net << endl; + cdebug_log(111,0) << "| [Curr]: " << current << endl; + if (current->getFrom()) { cdebug_log(111,0) << "| From: " << current->getFrom()->getOpposite(gcurrent) << endl; - } else { - cdebug_log(111,0) << endl; + current->getIntervFrom().print(); + } + if (current->getFrom2()) { + cdebug_log(111,0) << "| FROM2: " << current->getFrom2()->getOpposite(gcurrent) << endl; + current->getIntervFrom2().print(); } cdebug_log(111,0) << "| Edge " << edge << endl; - cdebug_log(111,0) << "+ Neighbor: " << vneighbor; - if (vneighbor->getFrom() != NULL) {cdebug_log(111,0) << "| Neighbor getfrom:" << vneighbor->getFrom()->getOpposite( gneighbor ) << endl;} - else {cdebug_log(111,0) << endl;} - + cdebug_log(111,0) << "+ Neighbor: " << vneighbor << endl; + if ((vneighbor->getFrom() != NULL)&&(vneighbor->hasValidStamp())) { + cdebug_log(111,0) << "| Neighbor GETFROM:" << vneighbor->getFrom()->getOpposite( gneighbor ) << endl; + cdebug_log(111,0) << "Distance prev : " << DbU::getValueString(vneighbor->getDistance()) << endl; + } + /////////////////////////////////////////////////////////////////////////////////// + // if has 2 from, 2 distances to calculate + cdebug_log(111,0) << "Calc distance1" << endl; DbU::Unit distance = _distanceCb( current, vneighbor, edge ); - cdebug_log(111,0) << "Distance curr: " << DbU::getValueString(distance) << endl; - cdebug_log(111,0) << "Distance prev: " << DbU::getValueString(vneighbor->getDistance()) << endl; - if ( (distance == vneighbor->getDistance()) - and ( (!gcurrent->isMatrix())||(!gneighbor->isMatrix()) ) - ){ - cdebug_log(111,0) << "Distance EQUAL" << endl; - cdebug_log(111,0) << "Previous getfrom:" << vneighbor->getFrom()->getOpposite( gneighbor ) << endl; - - GCell* gnext = vneighbor->getGCell(); - GCell* gprev = vneighbor->getFrom()->getOpposite(gnext); - Vertex* vprev = gprev->getObserver(GCell::Observable::Vertex); + bool isDistance2shorter = _isDistance2Shorter ( distance, current, vneighbor, edge ); // ANALOG + if ( (distance == vneighbor->getDistance()) and ((!gcurrent->isMatrix()) and (!gneighbor->isMatrix())) ){ + _pushEqualDistance( distance, isDistance2shorter, current, vneighbor, edge ); // ANALOG - Point pnext = Vertex::getNextPathPoint2( current, vneighbor ); - Point pprev = Vertex::getNextPathPoint2( vprev, vneighbor ); - Point ppond = _getPonderedPoint(); - DbU::Unit distcurr = this->_getDistancetoRP(pnext); - DbU::Unit distprev = this->_getDistancetoRP(pprev); - - cdebug_log(111,0) << "Pcurrent: X:" << DbU::getValueString(pnext.getX()) << ", Y:" << DbU::getValueString(pnext.getY()) << endl; - cdebug_log(111,0) << "Pprev : X:" << DbU::getValueString(pprev.getX()) << ", Y:" << DbU::getValueString(pprev.getY()) << endl; - - cdebug_log(111,0) << "distToTargets curr: " << DbU::getValueString(distcurr) << endl; - cdebug_log(111,0) << "distToTargets prev: " << DbU::getValueString(distprev) << endl; - - if ( ( distcurr < distprev ) - || ( ( distcurr == distprev ) - && ( calcDistance(ppond, pnext) < calcDistance(ppond, pprev) ) - ) - ){ - cdebug_log(111,0) << "BETTER GetFROM" << endl; - vneighbor->setBranchId( current->getBranchId() ); - vneighbor->setDistance( distance ); - //Point pathPoint = Vertex::getNextPathPoint( current, vneighbor ); - //vneighbor->setPathPoint( pathPoint.getX(), pathPoint.getY() ); - vneighbor->setFrom ( edge ); - _queue.push( vneighbor ); - - vneighbor->setIntervals( current ); - cdebug_log(111,0) << "Push: (size:" << _queue.size() << ") " << vneighbor << endl; - } - } else if ( ( (distance < vneighbor->getDistance()) and (distance != Vertex::unreachable) ) - or ( (distance == vneighbor->getDistance()) and (current->getBranchId() > vneighbor->getBranchId()) ) - ) { - if (vneighbor->getDistance() != Vertex::unreached) { - _queue.erase( vneighbor ); - } else { + } else if ( (distance < vneighbor->getDistance()) and (distance != Vertex::unreachable) ){ + if (vneighbor->getDistance() != Vertex::unreached) _queue.erase( vneighbor ); + else { if (not vneighbor->hasValidStamp()) { - cdebug_log(111,0) << "Distance FIRST" << endl; + cdebug_log(111,0) << "[case: Distance FIRST]" << endl; vneighbor->setConnexId( -1 ); vneighbor->setStamp ( _stamp ); vneighbor->setDegree ( 1 ); @@ -1390,14 +1584,13 @@ namespace Anabatic { vneighbor->unsetFlags(Vertex::AxisTarget); } } + cdebug_log(111,0) << "[case: Distance INFERIOR]" << endl; + _updateGRAData ( vneighbor, isDistance2shorter, current ); // ANALOG - cdebug_log(111,0) << "Distance INF" << endl; vneighbor->setBranchId( current->getBranchId() ); vneighbor->setDistance( distance ); - vneighbor->setFrom ( edge ); + vneighbor->setFrom ( edge ); _queue.push( vneighbor ); - - vneighbor->setIntervals( current ); cdebug_log(111,0) << "Push: (size:" << _queue.size() << ") " << vneighbor << endl; } } @@ -1418,7 +1611,6 @@ namespace Anabatic { for ( Vertex* v : _targets ) { cdebug_tabw(112, 0) << v << endl; - } cdebug_tabw(112,-1); @@ -1430,56 +1622,47 @@ namespace Anabatic { { cdebug_log(112,1) << "Dijkstra::_traceback() " << _net << " branchId:" << _sources.size() << endl; - int branchId = _sources.size(); + int branchId = _sources.size(); _toSources( current, _connectedsId ); - bool isfirst = true; + bool isfirst = true; + bool useFrom2 = false; if (!current->getGCell()->isMatrix()){ - GCell* gcurr = current->getGCell(); - GCell* gprev = current->getFrom()->getOpposite(gcurr); - Vertex* vprev = gprev->getObserver(GCell::Observable::Vertex); - Point pentry = Vertex::getNextPathPoint2( vprev, current ); - - cdebug_log(112,0) << "| " << current << " | " << endl; - if (current->isH()){ - if (pentry.getX() < current->getIMin()){ - current->setInterv(pentry.getX(), current->getIMax(), current->getIAxis()); - cdebug_log(112,0) << "[Interval update1]: min : " << DbU::getValueString(pentry.getX()); - cdebug_log(112,0) << ", max : " << DbU::getValueString(current->getIMax()); - cdebug_log(112,0) << ", axis: " << DbU::getValueString(current->getIAxis()) << endl; - } else if (pentry.getX() > current->getIMax()){ - current->setInterv(current->getIMin(), pentry.getX(), current->getIAxis()); - cdebug_log(112,0) << "[Interval update2]: min : " << DbU::getValueString(current->getIMin()); - cdebug_log(112,0) << ", max : " << DbU::getValueString(pentry.getX()); - cdebug_log(112,0) << ", axis: " << DbU::getValueString(current->getIAxis()) << endl; - } - } else if (current->isV()){ - if (pentry.getY() < current->getIMin()){ - current->setInterv(pentry.getY(), current->getIMax(), current->getIAxis()); - cdebug_log(112,0) << "[Interval update3]: min : " << DbU::getValueString(pentry.getY()); - cdebug_log(112,0) << ", max : " << DbU::getValueString(current->getIMax()); - cdebug_log(112,0) << ", axis: " << DbU::getValueString(current->getIAxis()) << endl; - } else if (pentry.getY() > current->getIMax()){ - current->setInterv(current->getIMin(), pentry.getY(), current->getIAxis()); - cdebug_log(112,0) << "[Interval update4]: min : " << DbU::getValueString(current->getIMin()); - cdebug_log(112,0) << ", max : " << DbU::getValueString(pentry.getY()); - cdebug_log(112,0) << ", axis: " << DbU::getValueString(current->getIAxis()) << endl; - } - } - cdebug_log(112,0) << "isiSet: " << current->isiSet() << ", " << current << endl; + _initiateUpdateIntervals ( current ); // ANALOG } else { current = current->getPredecessor(); isfirst = false; + } + cdebug_log(112,0) << "[Start WHILE]" << endl; + Edge* from = NULL; while ( current ) { + cdebug_log(112,0) << endl; cdebug_log(112,0) << "| " << current << " | " << endl; - if (!isfirst){ + if (!current->getGCell()->isMatrix()){ + //////////////////////////////////////////////////////////////////////////////////////////// ANALOG + if (_updateIntervals ( isfirst, current, useFrom2, branchId, from )) break; + Vertex* next = NULL; + next = current->getPredecessor(); + + if( current->isFromFrom2()) { + cdebug_log(112,0) << "ISFROMFROM2: " << current << endl; + useFrom2 = true; + current->unsetFlags(Vertex::UseFromFrom2); + } else { + cdebug_log(112,0) << "ISNOT FROMFROM2" << endl; + useFrom2 = false; + } + cdebug_log(112,0) << "next: " << next << endl; + current = next; + //////////////////////////////////////////////////////////////////////////////////////////// + } else { current->incDegree(); if (current->getConnexId() == _connectedsId) break; - Edge* from = current->getFrom(); + from = current->getFrom(); if (not from) break; current->setDistance( 0.0 ); @@ -1487,23 +1670,9 @@ namespace Anabatic { current->setBranchId( branchId ); _sources.insert( current ); _queue.push( current ); - } else { - isfirst = false; + current = current->getPredecessor(); } - - if (!current->getGCell()->isMatrix()){ - if (current->getPredecessor() != NULL){ - cdebug_log(112,0) << "[Interval update]: min : " << DbU::getValueString(current->getPIMin()); - cdebug_log(112,0) << ", max : " << DbU::getValueString(current->getPIMax()); - cdebug_log(112,0) << ", axis: " << DbU::getValueString(current->getPIAxis()) << endl; - current->getPredecessor()->setInterv(current->getPIMin(), current->getPIMax(), current->getPIAxis()); - cdebug_log(112,0) << "isiSet: " << current->getPredecessor()->isiSet() << ", " << current->getPredecessor() << endl; - } - } - - current = current->getPredecessor(); } - cdebug_tabw(112,-1); } @@ -1526,9 +1695,7 @@ namespace Anabatic { Vertex* source = startVertex; while ( source ) { - //////////////////////////////////////////// - source->resetIntervals(); - //////////////////////////////////////////// + source->resetIntervals(); // ANALOG cdebug_log(112,0) << "* " << source << endl; @@ -1609,7 +1776,9 @@ namespace Anabatic { cdebug_log(112,0) << "|| " << segment << endl; //cdebug_log(112,0) << "| " << "break (turn, branch or terminal)." << endl; + Vertex* stc = source; source = (target->getFrom()) ? target : NULL; + stc->clearFrom2(); } } @@ -1663,7 +1832,7 @@ namespace Anabatic { void Dijkstra::_toSources ( Vertex* source, int connexId ) { - //cdebug_log(112,1) << "Dijkstra::_toSources() " << endl; + cdebug_log(112,1) << "Dijkstra::_toSources() " << endl; //cdebug_log(112,0) << "* from: " << source << endl; source->setConnexId( connexId ); @@ -1852,5 +2021,249 @@ namespace Anabatic { } + bool Dijkstra::_checkFrom2 ( Edge* edge, Vertex* current ) + { + if (current->getFrom2()){ + if (edge == current->getFrom2()) { + cdebug_log(111,0) << "edge == current->getFrom2()" << endl; + return true; + } else { + cdebug_log(111,0) << "edge != current->getFrom2(): " << current->getFrom2() << endl; + return false; + } + } else { + cdebug_log(111,0) << "current->getFrom2() = NULL" << endl; + return false; + } + } + + + bool Dijkstra::_isDistance2Shorter ( DbU::Unit& distance, Vertex* current, Vertex* vneighbor, Edge* edge ) + { + DbU::Unit distance2 = Vertex::unreachable; + bool isDistance2shorter = false; + GCell* gneighbor = edge->getOpposite(current->getGCell()); + if (current->getFrom2()) { + cdebug_log(111,0) << "HAS 2nd getfrom" << edge << endl; + current->setFlags(Vertex::From2Mode); + cdebug_log(111,0) << "Calc distance2" << endl; + distance2 = _distanceCb( current, vneighbor, edge ); + current->unsetFlags(Vertex::From2Mode); + cdebug_log(111,0) << "Distance1 curr: " << DbU::getValueString(distance) << endl; + cdebug_log(111,0) << "Distance2 curr: " << DbU::getValueString(distance2) << endl; + if (distance > distance2){ + cdebug_log(111,0) << "=> distance2 is shorter" << endl; + isDistance2shorter = true; + distance = distance2; + } else if (distance == distance2) { + cdebug_log(111,0) << "distance == distance2" << endl; + Point pcurr = current->getStartPathPoint(vneighbor); + current->setFlags(Vertex::From2Mode); + Point pcurr2 = current->getStartPathPoint(vneighbor); + current->unsetFlags(Vertex::From2Mode); + Point pnext = gneighbor->getCenter(); + if (calcDistance(pcurr, pnext) > calcDistance(pcurr2, pnext)) { + cdebug_log(111,0) << "=> distance2 is shorter" << endl; + isDistance2shorter = true; + distance = distance2; + } else { + cdebug_log(111,0) << "=> distance1 is shorter" << endl; + } + } else { + cdebug_log(111,0) << "=> distance1 is shorter" << endl; + } + } else { + cdebug_log(111,0) << "NO 2nd getfrom" << endl; + cdebug_log(111,0) << "Distance1 curr: " << DbU::getValueString(distance) << endl; + } + return isDistance2shorter; + } + + + void Dijkstra::_pushEqualDistance ( DbU::Unit distance, bool isDistance2shorter, Vertex* current, Vertex* vneighbor, Edge* edge ) + { + GCell* gneighbor = edge->getOpposite(current->getGCell()); + cdebug_log(111,0) << "[case: Distance EQUAL + SameSide]" << endl; + cdebug_log(111,0) << "Previous getfrom:" << vneighbor->getFrom()->getOpposite( gneighbor ) << endl; + + GCell* gnext = vneighbor->getGCell(); + GCell* gprev = vneighbor->getFrom()->getOpposite(gnext); + Vertex* vprev = gprev->getObserver(GCell::Observable::Vertex); + + if ((distance == vneighbor->getDistance()) and vneighbor->areSameSide(vprev, current)){ + cdebug_log(111,0) << "[case: Other GetFROM]" << endl; + vneighbor->setFrom2 ( edge ); + vneighbor->setFlags(Vertex::From2Mode); + //vneighbor->createIntervFrom2(); + vneighbor->setIntervals( current ); + vneighbor->unsetFlags(Vertex::From2Mode); + if (isDistance2shorter) { + vneighbor->setFlags(Vertex::UseFromFrom2); + cdebug_log(111,0) << "setFromFrom2: " << vneighbor << endl; + } + cdebug_log(111,0) << "Push BIS : " << vneighbor << endl; + vneighbor->getIntervFrom().print(); + vneighbor->getIntervFrom2().print(); + } + } + + + void Dijkstra::_updateGRAData ( Vertex* vneighbor, bool isDistance2shorter, Vertex* current ) + { + vneighbor->unsetFlags(Vertex::UseFromFrom2); + cdebug_log(111,0) << "unsetFromFrom2: " << vneighbor << endl; + vneighbor->clearFrom2(); + if (isDistance2shorter) { + vneighbor->setFlags(Vertex::UseFromFrom2); + cdebug_log(111,0) << "setFromFrom2: " << vneighbor << endl; + } else cdebug_log(111,0) << "DON'T setFromFrom2: " << vneighbor << endl; + + vneighbor->setIntervals( current ); + vneighbor->getIntervFrom().print(); + } + + void Dijkstra::_initiateUpdateIntervals ( Vertex* current ) + { + GCell* gcurr = current->getGCell(); + GCell* gprev = current->getFrom()->getOpposite(gcurr); + Vertex* vprev = gprev->getObserver(GCell::Observable::Vertex); + Point pcurrent = vprev->getStartPathPoint(current); + Point pentry = vprev->getNextPathPoint( pcurrent, current ); + cdebug_log(112,0) << "current : " << gcurr << endl; + cdebug_log(112,0) << "previous: " << gprev << endl; + cdebug_log(112,0) << "pcurr : x: " << DbU::getValueString(pcurrent.getX()) << ", y: " << DbU::getValueString(pcurrent.getY()) << endl; + cdebug_log(112,0) << "pentry: x: " << DbU::getValueString(pentry.getX()) << ", y: " << DbU::getValueString(pentry.getY()) << endl; + + cdebug_log(112,0) << "| " << current << " | " << endl; + if (current->isH()){ + if (pentry.getX() < current->getIMin()){ + current->setInterv(pentry.getX(), current->getIMax(), current->getIAxis()); + cdebug_log(112,0) << "[Interval update1]: min : " << DbU::getValueString(pentry.getX()); + cdebug_log(112,0) << ", max : " << DbU::getValueString(current->getIMax()); + cdebug_log(112,0) << ", axis: " << DbU::getValueString(current->getIAxis()) << endl; + } else if (pentry.getX() > current->getIMax()){ + current->setInterv(current->getIMin(), pentry.getX(), current->getIAxis()); + cdebug_log(112,0) << "[Interval update2]: min : " << DbU::getValueString(current->getIMin()); + cdebug_log(112,0) << ", max : " << DbU::getValueString(pentry.getX()); + cdebug_log(112,0) << ", axis: " << DbU::getValueString(current->getIAxis()) << endl; + } + } else if (current->isV()){ + if (pentry.getY() < current->getIMin()){ + current->setInterv(pentry.getY(), current->getIMax(), current->getIAxis()); + cdebug_log(112,0) << "[Interval update3]: min : " << DbU::getValueString(pentry.getY()); + cdebug_log(112,0) << ", max : " << DbU::getValueString(current->getIMax()); + cdebug_log(112,0) << ", axis: " << DbU::getValueString(current->getIAxis()) << endl; + } else if (pentry.getY() > current->getIMax()){ + current->setInterv(current->getIMin(), pentry.getY(), current->getIAxis()); + cdebug_log(112,0) << "[Interval update4]: min : " << DbU::getValueString(current->getIMin()); + cdebug_log(112,0) << ", max : " << DbU::getValueString(pentry.getY()); + cdebug_log(112,0) << ", axis: " << DbU::getValueString(current->getIAxis()) << endl; + } + } + cdebug_log(112,0) << "isiSet: " << current->isiSet() << endl; + } + + + bool Dijkstra::_updateIntervals( bool& isfirst, Vertex* current, bool& useFrom2, int& branchId, Edge* from ) + { + if (!isfirst){ + cdebug_log(112,0) << "Is not first" << endl; + current->incDegree(); + if (current->getConnexId() == _connectedsId) return true; + from = NULL; + if (useFrom2) { + cdebug_log(112,0) << "USE FROM2: " << current->getFrom2() << endl; + current->setFrom(current->getFrom2()); + current->setIntervfrom(current->getPIMin2(), current->getPIMax2(), current->getPIAxis2()); + current->clearFrom2(); + } + from = current->getFrom(); + if (not from) return true; + + current->setDistance( 0.0 ); + current->setConnexId( _connectedsId ); + current->setBranchId( branchId ); + _sources.insert( current ); + _queue.push( current ); + } else isfirst = false; + + if (current->getPredecessor() != NULL){ + cdebug_log(112,0) << "Predecessor() : " << current->getPredecessor() << endl; + cdebug_log(112,0) << "[Interval update]: min : " << DbU::getValueString(current->getPIMin()); + cdebug_log(112,0) << ", max : " << DbU::getValueString(current->getPIMax()); + cdebug_log(112,0) << ", axis: " << DbU::getValueString(current->getPIAxis()) << endl; + current->getPredecessor()->setInterv(current->getPIMin(), current->getPIMax(), current->getPIAxis()); + current->getIntervFrom().print(); + } + return false; + } + + + bool Dijkstra::_attachSymContactsHook( RoutingPad* rp ) + { + NetRoutingState* state = NetRoutingExtension::get( _net ); + if (state){ + if (state->isSelfSym()){ + if ( ( (state->isSymHorizontal())&&(rp->getBoundingBox().getYMin() > state->getSymAxis()) ) + ||( (state->isSymVertical() )&&(rp->getBoundingBox().getXMin() > state->getSymAxis()) ) + ){ + Point center = rp->getBoundingBox().getCenter(); + GCell* gcell = _anabatic->getGCellUnder( center ); + Vertex* seed = gcell->getObserver(GCell::Observable::Vertex); + Contact* vcontact = seed->getGContact( _net ); + rp->getBodyHook()->detach(); + rp->getBodyHook()->attach( vcontact->getBodyHook() ); + return true; + } + } + } + return false; + } + + + void Dijkstra::_limitSymSearchArea( RoutingPad* rp ) + { + NetRoutingState* state = NetRoutingExtension::get( _net ); + Point center = rp->getBoundingBox().getCenter(); + GCell* gcell = _anabatic->getGCellUnder( center ); + if (state){ + if (state->isSymHorizontal()){ + _searchArea.merge( Box( _net->getCell()->getAbutmentBox().getXMin() + , _net->getCell()->getAbutmentBox().getYMin() + , _net->getCell()->getAbutmentBox().getXMax() + , state->getSymAxis() + ) + ); + } else if (state->isSymVertical()){ + _searchArea.merge( Box( _net->getCell()->getAbutmentBox().getXMin() + , _net->getCell()->getAbutmentBox().getYMin() + , state->getSymAxis() + , _net->getCell()->getAbutmentBox().getYMax() + ) + ); + } + } else if (gcell->isDevice()){ + _searchArea.merge( _net->getCell()->getAbutmentBox() ); + } + } + + + void Dijkstra::_setSourcesGRAData( Vertex* seed, RoutingPad* rp ) + { + Horizontal* h = dynamic_cast(rp->_getEntityAsSegment()); + Vertical* v = dynamic_cast (rp->_getEntityAsSegment()); + seed->createAData(); + if (h) { + seed->setFlags(Vertex::iHorizontal); + seed->setInterv(rp->getBoundingBox().getXMin(), rp->getBoundingBox().getXMax(), rp->getBoundingBox().getYCenter()); + } + if (v) { + seed->setFlags(Vertex::iVertical); + seed->setInterv(rp->getBoundingBox().getYMin(), rp->getBoundingBox().getYMax(), rp->getBoundingBox().getXCenter()); + } + } + + + } // Anabatic namespace. diff --git a/anabatic/src/anabatic/Dijkstra.h b/anabatic/src/anabatic/Dijkstra.h index 1b2cbe65..90f83397 100644 --- a/anabatic/src/anabatic/Dijkstra.h +++ b/anabatic/src/anabatic/Dijkstra.h @@ -38,43 +38,6 @@ namespace Anabatic { class AnabaticEngine; -// ------------------------------------------------------------------- -// Class : "Anabatic::Symmetry". - - class Symmetry - { - public: - enum iFlag { None = 0 - , sHorizontal = (1<<0) - , sVertical = (1<<1) - , sCFound = (1<<2) - }; - private: - Symmetry(unsigned int, DbU::Unit); - ~Symmetry(); - public: - static Symmetry* create(unsigned int, DbU::Unit); - - public: - unsigned int getType () const; - inline DbU::Unit getValue() const; - inline bool isCFound() const; - inline void setAsH(); - inline void setAsV(); - inline void setFound(); - - private: - unsigned int _flags; - DbU::Unit _value; - }; - - inline void Symmetry::setAsH () { _flags = ((_flags & ~(0x3)) | sHorizontal); } - inline void Symmetry::setAsV () { _flags = ((_flags & ~(0x3)) | sVertical ); } - inline void Symmetry::setFound () { _flags |= sCFound; } - inline DbU::Unit Symmetry::getValue () const { return _value; } - inline bool Symmetry::isCFound () const { return _flags & sCFound; } - - // ------------------------------------------------------------------- // Class : "Anabatic::IntervalC". @@ -86,30 +49,32 @@ namespace Anabatic { , iVertical = (1<<1) , iSet = (1<<2) }; - private: - IntervalC(); - ~IntervalC(); - public: - static IntervalC* create(); public: - void set ( DbU::Unit, DbU::Unit, DbU::Unit ); - void setRange ( DbU::Unit, DbU::Unit ); - void extendMin ( DbU::Unit ); - void extendMax ( DbU::Unit ); - void print () const; - inline bool isH () const; - inline bool isV () const; - inline void setAsH (); - inline void setAsV (); - inline DbU::Unit getMin () const; - inline DbU::Unit getMax () const; - inline DbU::Unit getCenter () const; - DbU::Unit getAxis () const; - inline void setAxis ( DbU::Unit ); - inline void setiSet (); - inline bool isiSet () const; - void reset (); + IntervalC(); + IntervalC(const IntervalC&); + IntervalC(IntervalC&); + ~IntervalC(); + void set ( DbU::Unit, DbU::Unit, DbU::Unit ); + void setRange ( DbU::Unit, DbU::Unit ); + void extendMin ( DbU::Unit ); + void extendMax ( DbU::Unit ); + void print () const; + inline bool isH () const; + inline bool isV () const; + inline void setAsH (); + inline void setAsV (); + inline DbU::Unit getMin () const; + inline DbU::Unit getMax () const; + inline DbU::Unit getCenter () const; + DbU::Unit getAxis () const; + inline void setAxis ( DbU::Unit ); + inline void setiSet (); + inline bool isiSet () const; + void reset (); + + unsigned int getFlags () const; + void setFlags (unsigned int); private: unsigned int _flags; @@ -118,17 +83,86 @@ namespace Anabatic { DbU::Unit _axis; }; - inline void IntervalC::setAsH () { _flags = ((_flags & ~(0x3)) | iHorizontal); } - inline void IntervalC::setAsV () { _flags = ((_flags & ~(0x3)) | iVertical ); } - inline void IntervalC::setAxis ( DbU::Unit axis ) { _axis = axis; } - inline DbU::Unit IntervalC::getAxis () const { return _axis; } - inline DbU::Unit IntervalC::getCenter() const { return getMin()+getMax(); } - inline DbU::Unit IntervalC::getMin () const { return _min; } - inline DbU::Unit IntervalC::getMax () const { return _max; } - inline void IntervalC::setiSet () { _flags |= iSet; } - inline bool IntervalC::isiSet () const { return _flags & iSet; } - inline bool IntervalC::isH () const { return _flags & iHorizontal; } - inline bool IntervalC::isV () const { return _flags & iVertical ; } + inline void IntervalC::setAsH () { _flags = ((_flags & ~(0x3)) | iHorizontal); } + inline void IntervalC::setAsV () { _flags = ((_flags & ~(0x3)) | iVertical ); } + inline void IntervalC::setAxis ( DbU::Unit axis ) { _axis = axis; } + inline DbU::Unit IntervalC::getAxis () const { return _axis; } + inline DbU::Unit IntervalC::getCenter() const { return getMin()+getMax(); } + inline DbU::Unit IntervalC::getMin () const { return _min; } + inline DbU::Unit IntervalC::getMax () const { return _max; } + inline void IntervalC::setiSet () { _flags |= iSet; } + inline bool IntervalC::isiSet () const { return _flags & iSet; } + inline bool IntervalC::isH () const { return _flags & iHorizontal; } + inline bool IntervalC::isV () const { return _flags & iVertical ; } + inline void IntervalC::setFlags ( unsigned int f ) { _flags = f ; } + inline unsigned int IntervalC::getFlags () const { return _flags; } + +// ------------------------------------------------------------------- +// Class : "Anabatic::GRAData". + + class GRAData + { + private: + GRAData(); + ~GRAData(); + public: + static GRAData* create(); + //////////////////////////////////////// GRDATA + inline bool isiSet () const; + inline IntervalC getInterv () const; + inline IntervalC getIntervFrom () const; + inline DbU::Unit getIAxis () const; + inline DbU::Unit getIMax () const; + inline DbU::Unit getIMin () const; + inline DbU::Unit getPIAxis () const; + inline DbU::Unit getPIMax () const; + inline DbU::Unit getPIMin () const; + + inline IntervalC getIntervFrom2 () const; + inline DbU::Unit getPIMax2 () const; + inline DbU::Unit getPIMin2 () const; + inline DbU::Unit getPIAxis2 () const; + + inline void setInterv ( DbU::Unit, DbU::Unit, DbU::Unit ); + inline void setIntervfrom ( DbU::Unit, DbU::Unit, DbU::Unit ); + inline void setIntervfrom2 ( DbU::Unit, DbU::Unit, DbU::Unit ); + void resetIntervals (); + void clearFrom2 (); + inline Edge* getFrom2 () const; + inline void setFrom2 ( Edge* ); + inline void printInterv () const; + inline void printIntervfrom () const; + + private: + IntervalC _intervfrom; + IntervalC _interv; + Edge* _from2; + IntervalC _intervfrom2; + }; + + inline bool GRAData::isiSet () const { return _interv.isiSet() ; } + inline IntervalC GRAData::getInterv () const { return _interv; } + inline IntervalC GRAData::getIntervFrom() const { return _intervfrom; } + inline DbU::Unit GRAData::getIAxis () const { return _interv.getAxis() ; } + inline DbU::Unit GRAData::getIMax () const { return _interv.getMax() ; } + inline DbU::Unit GRAData::getIMin () const { return _interv.getMin() ; } + inline DbU::Unit GRAData::getPIAxis () const { return _intervfrom.getAxis(); } + inline DbU::Unit GRAData::getPIMax () const { return _intervfrom.getMax() ; } + inline DbU::Unit GRAData::getPIMin () const { return _intervfrom.getMin() ; } + + inline DbU::Unit GRAData::getPIMax2 () const { return _intervfrom2.getMax() ; } + inline DbU::Unit GRAData::getPIMin2 () const { return _intervfrom2.getMin() ; } + inline DbU::Unit GRAData::getPIAxis2 () const { return _intervfrom2.getAxis(); } + inline IntervalC GRAData::getIntervFrom2 () const { return _intervfrom2; } + + inline void GRAData::setInterv ( DbU::Unit min, DbU::Unit max, DbU::Unit axis ) { _interv.set(min, max, axis); } + inline void GRAData::setIntervfrom ( DbU::Unit min, DbU::Unit max, DbU::Unit axis ) { _intervfrom.set(min, max, axis); } + inline void GRAData::setIntervfrom2( DbU::Unit min, DbU::Unit max, DbU::Unit axis ) { _intervfrom2.set(min, max, axis); } + + inline Edge* GRAData::getFrom2 () const { return _from2; } + inline void GRAData::setFrom2 ( Edge* from ) { _from2 = from; } + inline void GRAData::printInterv () const { _interv.print() ; } + inline void GRAData::printIntervfrom () const { _intervfrom.print(); } // ------------------------------------------------------------------- // Class : "Anabatic::Vertex". @@ -146,6 +180,11 @@ namespace Anabatic { , ERestricted = (1<<2) , WRestricted = (1<<3) , AxisTarget = (1<<4) + , From2Mode = (1<<5) + , UseFromFrom2 = (1<<6) + , iHorizontal = (1<<7) + , iVertical = (1<<8) + , iSet = (1<<9) }; public: static DbU::Unit unreached; @@ -185,6 +224,7 @@ namespace Anabatic { inline void clearRps (); inline Contact* breakGoThrough ( Net* ); + //////////////////////////////////////// Analog inline bool isNorth ( const Vertex* ) const; inline bool isSouth ( const Vertex* ) const; inline bool isEast ( const Vertex* ) const; @@ -201,44 +241,53 @@ namespace Anabatic { inline void setSRestricted (); inline void setERestricted (); inline void setWRestricted (); - inline unsigned int getFlags () const; - inline DbU::Unit getXPath () const; - inline DbU::Unit getYPath () const; bool hasRP ( Net* ) const; bool hasVRP ( Net* ) const; bool hasHRP ( Net* ) const; - static bool isRestricted ( const Vertex* v1, const Vertex* v2 ); - static Point getNextPathPoint2( const Vertex*, const Vertex* ); - Point getPathPoint ( const Vertex * ) const; - inline void setIAsH (); - inline void setIAsV (); - inline DbU::Unit getIAxis () const; - inline void setIAxis ( DbU::Unit ) ; - inline DbU::Unit getICenter () const; - inline DbU::Unit getIMax () const; - inline DbU::Unit getIMin () const; - inline void setPIAsH (); - inline void setPIAsV (); - inline DbU::Unit getPIAxis () const; - inline void setPIAxis ( DbU::Unit ) ; - inline DbU::Unit getPICenter () const; - inline DbU::Unit getPIMax () const; - inline DbU::Unit getPIMin () const; - bool isH () const; - bool isV () const; - inline bool isiSet () const; - inline void setInterv ( DbU::Unit, DbU::Unit, DbU::Unit ); - inline void setIRange ( DbU::Unit, DbU::Unit ); - inline void setIRangeFrom ( DbU::Unit, DbU::Unit ); - inline void printInterval () const ; - void setIntervals ( Vertex* ); - void resetIntervals (); - inline void setFlags ( unsigned int ); - inline bool isAxisTarget () const; - inline void unsetFlags ( unsigned int ); - inline void setAxisTarget (); - + static bool isRestricted ( const Vertex* v1, const Vertex* v2, DbU::Unit hpitch = 0, DbU::Unit vpitch = 0); + bool areSameSide ( const Vertex*, const Vertex* ) const; + inline bool isFromFrom2 () const; + inline bool isFrom2Mode () const; + inline bool isAxisTarget () const; + inline bool isiHorizontal() const; + inline bool isiVertical () const; + inline void setFlags ( unsigned int ); + inline void unsetFlags ( unsigned int ); + bool isH () const; + bool isV () const; + inline void createAData (); + //////////////////////////////////// + Point getStartPathPoint ( const Vertex* next ) const; + Point getNextPathPoint ( Point, const Vertex* ) const; + //////////////////////////////////////// GRDATA + void setIntervals ( Vertex* ); + + bool isiSet () const; + DbU::Unit getIAxis () const; + DbU::Unit getIMax () const; + DbU::Unit getIMin () const; + DbU::Unit getPIAxis () const; + DbU::Unit getPIMax () const; + DbU::Unit getPIMin () const; + void setInterv ( DbU::Unit, DbU::Unit, DbU::Unit ); + void setIntervfrom ( DbU::Unit, DbU::Unit, DbU::Unit ); + void setIntervfrom2 ( DbU::Unit, DbU::Unit, DbU::Unit ); + void resetIntervals (); + void clearFrom2 (); + Edge* getFrom2 () const; + void setFrom2 ( Edge* ); + void createIntervFrom2 (); + DbU::Unit getPIMax2 () const; + DbU::Unit getPIMin2 () const; + DbU::Unit getPIAxis2 () const; + IntervalC getIntervFrom2 () const; + IntervalC getIntervFrom ( unsigned int criteria = 0 ) const; + IntervalC getInterv () const; + void printInterv () const; + void printIntervfrom () const; + GCell* getGPrev ( unsigned int criteria = 0 ) const; + // Inspector support. string _getString () const; private: @@ -257,8 +306,7 @@ namespace Anabatic { DbU::Unit _distance; Edge* _from; unsigned int _flags; - IntervalC* _intervfrom; - IntervalC* _interv; + GRAData* _adata; }; @@ -274,9 +322,7 @@ namespace Anabatic { , _distance(unreached) , _from (NULL) , _flags (NoRestriction) - - , _intervfrom(IntervalC::create()) - , _interv (IntervalC::create()) + , _adata (NULL) { gcell->setObserver( GCell::Observable::Vertex, &_observer ); } @@ -332,32 +378,15 @@ namespace Anabatic { inline void Vertex::setSRestricted () { _flags |= SRestricted; } inline void Vertex::setERestricted () { _flags |= ERestricted; } inline void Vertex::setWRestricted () { _flags |= WRestricted; } - inline unsigned int Vertex::getFlags () const { return _flags; } - inline void Vertex::setIAxis ( DbU::Unit axis ) { _interv->setAxis(axis); } - inline DbU::Unit Vertex::getIAxis () const { return _interv->getAxis(); } - inline void Vertex::setIAsH () { _interv->setAsH(); } - inline void Vertex::setIAsV () { _interv->setAsV(); } - inline DbU::Unit Vertex::getICenter () const { return _interv->getCenter(); } - inline DbU::Unit Vertex::getIMax () const { return _interv->getMax(); } - inline DbU::Unit Vertex::getIMin () const { return _interv->getMin(); } - inline void Vertex::setPIAxis ( DbU::Unit axis ) { _intervfrom->setAxis(axis); } - inline DbU::Unit Vertex::getPIAxis () const { return _intervfrom->getAxis(); } - inline void Vertex::setPIAsH () { _intervfrom->setAsH(); } - inline void Vertex::setPIAsV () { _intervfrom->setAsV(); } - inline DbU::Unit Vertex::getPICenter() const { return _intervfrom->getCenter(); } - inline DbU::Unit Vertex::getPIMax () const { return _intervfrom->getMax(); } - inline DbU::Unit Vertex::getPIMin () const { return _intervfrom->getMin(); } - inline bool Vertex::isiSet () const { return _interv->isiSet(); } - - inline void Vertex::setInterv ( DbU::Unit min, DbU::Unit max, DbU::Unit axis ) { _interv->set(min, max, axis); } - inline void Vertex::setIRange ( DbU::Unit min, DbU::Unit max ) { _interv->setRange(min, max); } - inline void Vertex::setIRangeFrom( DbU::Unit min, DbU::Unit max ) { _intervfrom->setRange(min, max); } - inline void Vertex::printInterval() const { _interv->print(); } - - inline void Vertex::setAxisTarget() { _flags |= AxisTarget; } - inline bool Vertex::isAxisTarget () const { return (_flags & AxisTarget); } + inline bool Vertex::isFromFrom2 () const { return (_flags & Vertex::UseFromFrom2); } + inline bool Vertex::isFrom2Mode () const { return (_flags & Vertex::From2Mode ); } + inline bool Vertex::isAxisTarget () const { return (_flags & Vertex::AxisTarget ); } + inline bool Vertex::isiHorizontal() const { return (_flags & Vertex::iHorizontal ); } + inline bool Vertex::isiVertical () const { return (_flags & Vertex::iVertical ); } + inline void Vertex::setFlags ( unsigned int mask ) { _flags |= mask ; } inline void Vertex::unsetFlags ( unsigned int mask ) { _flags &= ~mask; } + // ------------------------------------------------------------------- // Class : "Anabatic::PriorityQueue". @@ -462,8 +491,6 @@ namespace Anabatic { Dijkstra ( const Dijkstra& ); Dijkstra& operator= ( const Dijkstra& ); static DbU::Unit _distance ( const Vertex*, const Vertex*, const Edge* ); - DbU::Unit _getDistancetoRP ( Point ); - DbU::Unit _estimatePtoRP ( Point, RoutingPad*, Vertex* ); Point _getPonderedPoint () const; void _cleanup (); bool _propagate ( Flags enabledSides ); @@ -475,12 +502,23 @@ namespace Anabatic { void _checkEdges () const; void _createSelfSymSeg ( Segment* ); - inline void setAxisTarget (); - inline bool needAxisTarget () const; - inline void setFlags ( unsigned int ); - inline void unsetFlags ( unsigned int ); - void setAxisTargets (); - void unsetAxisTargets (); + inline void setAxisTarget (); + inline bool needAxisTarget () const; + inline void setFlags ( unsigned int ); + inline void unsetFlags ( unsigned int ); + void setAxisTargets (); + void unsetAxisTargets (); + + bool _attachSymContactsHook ( RoutingPad* ); + void _limitSymSearchArea ( RoutingPad* rp ); + void _setSourcesGRAData ( Vertex*, RoutingPad*); + bool _checkFrom2 ( Edge*, Vertex* ); + bool _isDistance2Shorter ( DbU::Unit&, Vertex*, Vertex*, Edge* ); + void _pushEqualDistance ( DbU::Unit, bool, Vertex*, Vertex*, Edge* ); + void _updateGRAData ( Vertex*, bool, Vertex* ); + void _initiateUpdateIntervals ( Vertex* ); + bool _updateIntervals ( bool&, Vertex*, bool&, int&, Edge* ); + private: AnabaticEngine* _anabatic; vector _vertexes; @@ -511,7 +549,7 @@ namespace Anabatic { inline DistanceT* Dijkstra::setDistance ( DistanceT cb ) { _distanceCb = cb; return _distanceCb.target(); } inline void Dijkstra::setFlags ( unsigned int mask ) { _flags |= mask; } - inline bool Dijkstra::needAxisTarget () const { return (_flags & Mode::AxisTarget); } + inline bool Dijkstra::needAxisTarget () const { return (_flags & Mode::AxisTarget); } inline void Dijkstra::unsetFlags ( unsigned int mask ) { _flags &= ~mask; } } // Anabatic namespace. diff --git a/crlcore/etc/common/display.conf b/crlcore/etc/common/display.conf index 59a0ee07..7209b8e4 100644 --- a/crlcore/etc/common/display.conf +++ b/crlcore/etc/common/display.conf @@ -128,43 +128,43 @@ stylesTable = \ , (Drawing, 'spot' , { 'color':'White' , 'border':2, 'threshold':6.0*scale }) , (Drawing, 'ghost' , { 'color':'White' , 'border':1 }) , (Drawing, 'text.ruler' , { 'color':'White' , 'border':1, 'threshold':0.0 *scale }) - , (Drawing, 'text.instance' , { 'color':'White' , 'border':1, 'threshold':4.0 *scale }) - , (Drawing, 'text.reference', { 'color':'White' , 'border':1, 'threshold':20.0*scale }) + , (Drawing, 'text.instance' , { 'color':'White' , 'border':1, 'threshold':400.0 *scale }) + , (Drawing, 'text.reference', { 'color':'White' , 'border':1, 'threshold':200.0*scale }) , (Drawing, 'undef' , { 'color':'Violet' , 'border':0, 'pattern':'2244118822441188' }) # Active Layers. , (Group , 'Active Layers') - , (Drawing, 'nWell' , { 'color':'Tan' , 'pattern':'urgo.8' , 'border':1, 'threshold':1.50*scale }) - , (Drawing, 'pWell' , { 'color':'LightYellow', 'pattern':'urgo.8' , 'border':1, 'threshold':1.50*scale }) - , (Drawing, 'nImplant', { 'color':'LawnGreen' , 'pattern':'antihash0.8' , 'border':1, 'threshold':1.50*scale }) - , (Drawing, 'pImplant', { 'color':'Yellow' , 'pattern':'antihash0.8' , 'border':1, 'threshold':1.50*scale }) - , (Drawing, 'active' , { 'color':'White' , 'pattern':'antihash1.8' , 'border':1, 'threshold':1.50*scale }) - , (Drawing, 'poly' , { 'color':'Red' , 'pattern':'poids2.8' , 'border':1, 'threshold':1.50*scale }) - , (Drawing, 'poly2' , { 'color':poly2Color , 'pattern':'poids2.8' , 'border':1, 'threshold':1.50*scale }) + , (Drawing, 'nWell' , { 'color':'Tan' , 'pattern':'urgo.8' , 'border':1, 'threshold':0*scale }) + , (Drawing, 'pWell' , { 'color':'LightYellow', 'pattern':'urgo.8' , 'border':1, 'threshold':0*scale }) + , (Drawing, 'nImplant', { 'color':'LawnGreen' , 'pattern':'antihash0.8' , 'border':1, 'threshold':0*scale }) + , (Drawing, 'pImplant', { 'color':'Yellow' , 'pattern':'antihash0.8' , 'border':1, 'threshold':0*scale }) + , (Drawing, 'active' , { 'color':'White' , 'pattern':'antihash1.8' , 'border':1, 'threshold':0*scale }) + , (Drawing, 'poly' , { 'color':'Red' , 'pattern':'poids2.8' , 'border':1, 'threshold':0*scale }) + , (Drawing, 'poly2' , { 'color':poly2Color , 'pattern':'poids2.8' , 'border':1, 'threshold':0*scale }) # Routing Layers. , (Group , 'Routing Layers') #, (Drawing, 'metal1', { 'color':'Blue' , 'pattern':'light_antislash0.8', 'border':1, 'threshold':0.80*scale }) - , (Drawing, 'metal1', { 'color':'Blue' , 'pattern':'slash.8' , 'border':1, 'threshold':0.80*scale }) - , (Drawing, 'metal2', { 'color':'Aqua' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.02*scale }) - , (Drawing, 'metcap', { 'color':'DarkTurquoise', 'pattern':'poids2.8' , 'border':2, 'threshold':0.02*scale }) - , (Drawing, 'metal3', { 'color':'LightPink' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.02*scale }) - , (Drawing, 'metal4', { 'color':'Green' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.02*scale }) - , (Drawing, 'metal5', { 'color':'Yellow' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.02*scale }) - , (Drawing, 'metal6', { 'color':'Violet' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.02*scale }) - , (Drawing, 'metal7', { 'color':'Red' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.02*scale }) - , (Drawing, 'metal8', { 'color':'Blue' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.02*scale }) + , (Drawing, 'metal1', { 'color':'Blue' , 'pattern':'slash.8' , 'border':1, 'threshold':00*scale }) + , (Drawing, 'metal2', { 'color':'Aqua' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.0*scale }) + , (Drawing, 'metcap', { 'color':'DarkTurquoise', 'pattern':'poids2.8' , 'border':2, 'threshold':0.0*scale }) + , (Drawing, 'metal3', { 'color':'LightPink' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.0*scale }) + , (Drawing, 'metal4', { 'color':'Green' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.0*scale }) + , (Drawing, 'metal5', { 'color':'Yellow' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.0*scale }) + , (Drawing, 'metal6', { 'color':'Violet' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.0*scale }) + , (Drawing, 'metal7', { 'color':'Red' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.0*scale }) + , (Drawing, 'metal8', { 'color':'Blue' , 'pattern':'poids4.8' , 'border':1, 'threshold':0.0*scale }) # Cuts (VIA holes). , (Group , 'Cuts (VIA holes)') - , (Drawing, 'cut0', { 'color':'0,150,150', 'threshold':1.50*scale }) - , (Drawing, 'cut1', { 'color':'Aqua' , 'threshold':0.80*scale }) - , (Drawing, 'cut2', { 'color':'LightPink', 'threshold':0.80*scale }) - , (Drawing, 'cut3', { 'color':'Green' , 'threshold':0.80*scale }) - , (Drawing, 'cut4', { 'color':'Yellow' , 'threshold':0.80*scale }) - , (Drawing, 'cut5', { 'color':'Violet' , 'threshold':0.80*scale }) - , (Drawing, 'cut6', { 'color':'Red' , 'threshold':0.80*scale }) - , (Drawing, 'cut7', { 'color':'Blue' , 'threshold':0.80*scale }) + , (Drawing, 'cut0', { 'color':'0,150,150', 'threshold':0*scale }) + , (Drawing, 'cut1', { 'color':'Aqua' , 'threshold':0.0*scale }) + , (Drawing, 'cut2', { 'color':'LightPink', 'threshold':0.0*scale }) + , (Drawing, 'cut3', { 'color':'Green' , 'threshold':0.0*scale }) + , (Drawing, 'cut4', { 'color':'Yellow' , 'threshold':0.0*scale }) + , (Drawing, 'cut5', { 'color':'Violet' , 'threshold':0.0*scale }) + , (Drawing, 'cut6', { 'color':'Red' , 'threshold':0.0*scale }) + , (Drawing, 'cut7', { 'color':'Blue' , 'threshold':0.0*scale }) # MIM6. , (Group , 'MIM6') @@ -192,7 +192,7 @@ stylesTable = \ , (Drawing, 'gmetalv' , { 'color':'200,200,255', 'pattern':'light_antihash1.8', 'border':1 }) , (Drawing, 'gcut' , { 'color':'255,255,190', 'border':1 }) , (Drawing, 'Anabatic::Edge' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4, 'threshold':0.02*scale }) - , (Drawing, 'Anabatic::GCell', { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4, 'threshold':0.10*scale }) + , (Drawing, 'Anabatic::GCell', { 'color':'128,128,128', 'pattern':'0000000000000000', 'border':4, 'threshold':0.10*scale }) ) # ---------------------------------------------------------------------- diff --git a/hurricane/src/viewer/CellImage.cpp b/hurricane/src/viewer/CellImage.cpp index 5c037d57..81556723 100644 --- a/hurricane/src/viewer/CellImage.cpp +++ b/hurricane/src/viewer/CellImage.cpp @@ -126,7 +126,7 @@ namespace Hurricane { _flags = flags; - int scale = 4 * Cfg::getParamEnumerate("viewer.printer.mode")->asInt(); + int scale = 80 * Cfg::getParamEnumerate("viewer.printer.mode")->asInt(); _drawingWidth = _cellWidget->width ()*scale; _drawingHeight = _cellWidget->height()*scale;