diff --git a/katabatic/src/AutoSegment.cpp b/katabatic/src/AutoSegment.cpp index f5e8d7fd..7febb34c 100644 --- a/katabatic/src/AutoSegment.cpp +++ b/katabatic/src/AutoSegment.cpp @@ -1303,8 +1303,9 @@ namespace Katabatic { { ltrace(200) << "AutoSegment::canMoveUp() " << flags << endl; - if ( isLayerChange() or isFixed() or isTerminal() ) return false; - if ( isLocal() and (not (flags & AllowLocal)) ) return false; + if ( isLayerChange() or isFixed() ) return false; + if ( isTerminal() and (not (flags & AllowTerminal)) ) return false; + if ( isLocal() and (not (flags & AllowLocal )) ) return false; size_t depth = Session::getRoutingGauge()->getLayerDepth(getLayer()) + 2; if ( depth >= Session::getConfiguration()->getAllowedDepth() ) return false; @@ -1355,6 +1356,76 @@ namespace Katabatic { } + bool AutoSegment::shearUp ( GCell* upGCell, AutoSegment*& movedUp, float reserve, unsigned int flags ) + { + ltrace(200) << "AutoSegment::shearUp() " << this << endl; + + movedUp = NULL; + + if ( isLayerChange() or isFixed() /*or isTerminal()*/ or isLocal() ) return false; + + size_t upDepth = Session::getRoutingGauge()->getLayerDepth(getLayer()) + 2; + if ( upDepth >= Session::getConfiguration()->getAllowedDepth() ) return false; + + vector gcells; + getGCells ( gcells ); + + size_t iupGCell = 0; + for ( ; iupGCellhasFreeTrack(upDepth,reserve) ) { + ltrace(200) << "Right shearing @ " << gcells[i] << endl; + rightShear = gcells[i]; + } + } + + GCell* leftShear = NULL; + if ( iupGCell > 0 ) { + size_t i = iupGCell; + do { + --i; + if ( not gcells[i]->hasFreeTrack(upDepth,reserve) ) { + ltrace(200) << "Left shearing @ " << gcells[i] << endl; + leftShear = gcells[i]; + } + } while (i > 0); + } + + AutoSegment* before = this; + const vector& doglegs = Session::getDogLegs(); + + if ( leftShear ) { + makeDogLeg ( leftShear, true ); + movedUp = doglegs[2]; + } else { + before = NULL; + movedUp = this; + } + + if ( rightShear ) makeDogLeg(rightShear,true); + + if ( movedUp->moveUp(flags) ) { + if ( rightShear or leftShear ) + cinfo << "Shearing Up " << this << "." << endl; + return true; + } + + movedUp = NULL; + return false; + } + + bool AutoSegment::canDogLeg ( Interval interval ) { ltrace(200) << "AutoSegment::canDogLeg(Interval) " << interval << endl; diff --git a/katabatic/src/GCell.cpp b/katabatic/src/GCell.cpp index 51005cee..390cc109 100644 --- a/katabatic/src/GCell.cpp +++ b/katabatic/src/GCell.cpp @@ -117,8 +117,6 @@ namespace Katabatic { , _cDensity (0.0) , _densities (new float [_depth]) , _saturateDensities (new float [_depth]) - , _segmentCount (0) - , _routedSegmentCount(0) , _saturated (false) , _invalid (true) , _key (0.0,_index) @@ -335,33 +333,15 @@ namespace Katabatic { if (_invalid and update) const_cast(this)->updateDensity(); float density = 0.0; - for ( size_t i=0 ; i<_depth ; i++ ) - density += _densities[i]; -#if defined(CHECK_DETERMINISM) - cerr << "Order: Sum density " << setprecision(9) << density << endl; + if ( getGCellGrid()->getDensityMode() == GCellGrid::AverageHVDensity ) { + // Average density of all layers mixeds together. + for ( size_t i=0 ; i<_depth ; i++ ) + density += _densities[i]; - density /= (float)(_depth-_pinDepth); - cerr << "Order: density " << setprecision(9) << density << endl; - - int intdensity = (int)roundfp(density); - cerr << "Order: rounded density *100 " << setprecision(9) << intdensity << endl; - - density = ((float)(intdensity)) / 100.0; - cerr << "Order: rounded density /100 " << setprecision(9) << density << endl; - - return density; -#else - return roundfp ( density/((float)(_depth-_pinDepth)) ); -#endif - } - - - float GCell::getMaxHVDensity ( bool update ) const - { - if (_invalid and update) const_cast(this)->updateDensity(); - - if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxHVDensity ) { + density = roundfp ( density/((float)(_depth-_pinDepth)) ); + } else if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxHVDensity ) { + // Maximum density between all horizontal vs. all vertical layers. size_t hplanes = 0; size_t vplanes = 0; float hdensity = 0.0; @@ -375,47 +355,54 @@ namespace Katabatic { if (hplanes) hdensity /= hplanes; if (vplanes) vdensity /= vplanes; - return roundfp ( (hdensity > vdensity) ? hdensity : vdensity ); - } + density = roundfp ( (hdensity > vdensity) ? hdensity : vdensity ); + } else if ( getGCellGrid()->getDensityMode() == GCellGrid::AverageHDensity ) { + // Average density between all horizontal layers. + size_t hplanes = 0; + float hdensity = 0.0; - if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxLayerDensity ) { - float density = 0.0; + for ( size_t i=_pinDepth ; i<_depth ; i++ ) { + if ( i%2 ) { hdensity += _densities[i]; ++hplanes; } + } + if (hplanes) hdensity /= hplanes; + + density = roundfp ( hdensity ); + } else if ( getGCellGrid()->getDensityMode() == GCellGrid::AverageVDensity ) { + // Average density between all vertical layers. + size_t vplanes = 0; + float vdensity = 0.0; + + for ( size_t i=_pinDepth ; i<_depth ; i++ ) { + if ( i%2 == 0 ) { vdensity += _densities[i]; ++vplanes; } + } + + if (vplanes) vdensity /= vplanes; + + density = roundfp ( vdensity ); + } else if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxDensity ) { + // Density of the most saturated layer. for ( size_t i=_pinDepth ; i<_depth ; i++ ) { if ( _densities[i] > density ) density = _densities[i]; } - return roundfp(density); + density = roundfp(density); + } else if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxHDensity ) { + // Density of the most saturated horizontal layer. + for ( size_t i=_pinDepth ; i<_depth ; i++ ) { + if ( (i%2) and (_densities[i] > density) ) density = _densities[i]; + } + density = roundfp(density); + } else if ( getGCellGrid()->getDensityMode() == GCellGrid::MaxVDensity ) { + // Density of the most saturated vertical layer. + for ( size_t i=_pinDepth ; i<_depth ; i++ ) { + if ( (i%2 == 0) and (_densities[i] > density) ) density = _densities[i]; + } + density = roundfp(density); } - float density = 0.0; - for ( size_t i=_pinDepth ; i<_depth ; i++ ) - density += _densities[i]; - - return roundfp ( density/((float)(_depth-_pinDepth)) ); - } - - - float GCell::getStiffness () const - { - if ( _segmentCount == 0 ) return 0.0; - return roundfp ( (float)_routedSegmentCount / (float)_segmentCount ); - } - - - void GCell::incSegmentCount ( int count ) - { - if ( (count < 0) and ((unsigned int)abs(count) > _segmentCount) ) - _segmentCount = 0; - else - _segmentCount += count; - } - - - void GCell::incRoutedCount ( int count ) - { - if ( (count < 0) and ((unsigned int)abs(count) > _routedSegmentCount) ) - _routedSegmentCount = 0; - else - _routedSegmentCount += count; +#if defined(CHECK_DETERMINISM) + cerr << "Order: density " << setprecision(9) << density << endl; +#endif + return density; } @@ -697,7 +684,6 @@ namespace Katabatic { #endif //cerr << "updateDensity() " << this << getVectorString(_densities,_depth) << endl; - //_segmentCount = _hsegments.size() + _vsegments.size() + processeds.size(); return ( _saturated ) ? 1 : 0 ; } @@ -813,7 +799,8 @@ namespace Katabatic { #endif updateDensity (); - float density = getDensity(); + //float density = getDensity(); + moved = NULL; //float density = _densities[depth]; //float densityUp = _densities[depth+2]; @@ -847,15 +834,16 @@ namespace Katabatic { #if defined(CHECK_DETERMINISM) cerr << "Order: Move up " << (*isegment) << endl; #endif - //cerr << "Move up " << (*isegment) << endl; - if ( not (*isegment)->canMoveUp(0.5,AutoSegment::Propagate) ) { - cinfo << Warning("Shear effect on: %s.",getString(*isegment).c_str()) << endl; - return false; - } + // cerr << "Move up " << (*isegment) << endl; + // if ( not (*isegment)->canMoveUp(0.5/*,AutoSegment::Propagate*/) ) { + // cinfo << Warning("Shear effect on: %s.",getString(*isegment).c_str()) << endl; + // return false; + // } - (*isegment)->changeDepth ( depth+2, false, false ); - moved = (*isegment); + // (*isegment)->changeDepth ( depth+2, false, false ); + // moved = (*isegment); + (*isegment)->shearUp ( this, moved, 0.5, AutoSegment::AllowTerminal ); updateDensity (); //cmess2 << " - GCell [" << getIndex() << "] @" << getColumn() << "x" << getRow() @@ -865,7 +853,7 @@ namespace Katabatic { // << " displaced:" << (*isegment) << "]." // << endl; - return true; + if ( moved ) return true; } return false; @@ -1019,11 +1007,11 @@ namespace Katabatic { s << "<" << _getTypeName() << " [" << _index << "] " << DbU::getValueString(box.getXMin()) << ":" << DbU::getValueString(box.getYMin()) << " " << DbU::getValueString(box.getXMax()) << ":" << DbU::getValueString(box.getYMax()) << " " - << setprecision(9) + << setprecision(3) #if not defined(CHECK_DETERMINISM) - << getDensity(false) + << getDensity(false) << " " #endif - << " S:" << _routedSegmentCount << "/" << _segmentCount + << getVectorString(_densities,_depth) << ">"; return s.str(); @@ -1041,8 +1029,6 @@ namespace Katabatic { record->add ( getSlot ( "_box" , &_box ) ); record->add ( getSlot ( "_depth" , &_depth ) ); record->add ( getSlot ( "_saturated" , _saturated ) ); - record->add ( getSlot ( "_segmentCount" , _segmentCount ) ); - record->add ( getSlot ( "_routedSegmentCount", _routedSegmentCount ) ); record->add ( getSlot ( "_invalid" , _invalid ) ); RoutingGauge* rg = getGCellGrid()->getKatabatic()->getRoutingGauge(); @@ -1168,7 +1154,7 @@ namespace Katabatic { { ostringstream s; - s << setprecision(9); + s << setprecision(3); for ( size_t i=0 ; i (ktbt->getCell()->getAbutmentBox()) , _katabatic (ktbt) - , _densityMode (MaxLayerDensity) + , _densityMode (MaxDensity) , _hEdgeCapacity(ktbt->getConfiguration()->getHEdgeCapacity()) , _vEdgeCapacity(ktbt->getConfiguration()->getVEdgeCapacity()) { } diff --git a/katabatic/src/GraphicKatabaticEngine.cpp b/katabatic/src/GraphicKatabaticEngine.cpp index 7e1f9f7e..b4ba3f8e 100644 --- a/katabatic/src/GraphicKatabaticEngine.cpp +++ b/katabatic/src/GraphicKatabaticEngine.cpp @@ -91,7 +91,7 @@ namespace Katabatic { QPainter& painter = widget->getPainter(); painter.setBrush - ( Graphics::getColorScale(ColorScale::Fire).getBrush((size_t)(gcell->getMaxHVDensity()*255.0) + ( Graphics::getColorScale(ColorScale::Fire).getBrush((size_t)(gcell->getDensity()*255.0) ,widget->getDarkening()) ); painter.drawRect ( widget->dbuToDisplayRect(gcell->getBoundingBox()) ); } diff --git a/katabatic/src/LayerAssign.cpp b/katabatic/src/LayerAssign.cpp index 57626f8e..a1f31ab4 100644 --- a/katabatic/src/LayerAssign.cpp +++ b/katabatic/src/LayerAssign.cpp @@ -109,6 +109,7 @@ namespace Katabatic { bool optimized = true; while ( optimized ) { + Session::revalidate (); optimized = false; //sort ( gcells.begin(), gcells.end(), GCell::CompareByDensity(depth) ); queue.revalidate (); diff --git a/katabatic/src/LoadGrByNet.cpp b/katabatic/src/LoadGrByNet.cpp index 4f92ff54..e9132b60 100644 --- a/katabatic/src/LoadGrByNet.cpp +++ b/katabatic/src/LoadGrByNet.cpp @@ -2127,7 +2127,7 @@ namespace { AutoContact* localContact = (_south) ? _southWestContact : _northEastContact; //localContact->setHAlignate ( true ); - bool doTurn = (_topology & GLOBAL_SPLIT) and (_routingPads.size() == 1); + bool doTurn = (_topology & GLOBAL_SPLIT) and (_state.fields.Pad == 1); for ( unsigned int i = 0 ; i < _routingPads.size() ; i++ ) { AutoContact* rpContact = _GCell_rp_Access ( _gcell, _routingPads[i], true, false ); AutoContact* turn1 diff --git a/katabatic/src/Session.cpp b/katabatic/src/Session.cpp index 423aa9bf..885ab6ca 100644 --- a/katabatic/src/Session.cpp +++ b/katabatic/src/Session.cpp @@ -303,11 +303,18 @@ namespace Katabatic { _autoContacts.clear (); ltrace(110) << "AutoSegments Revalidate (after canonize)." << endl; - for ( size_t i=0 ; i < _autoSegments.size() ; i++, count++ ) - _autoSegments[i]->revalidate (); - _revalidateds.clear (); - _autoSegments.swap ( _revalidateds ); + _dogLegs.clear (); + _revalidateds.clear (); + for ( size_t i=0 ; i < _autoSegments.size() ; i++, count++ ) { + _autoSegments[i]->revalidate (); + if ( not _destroyedSegments.empty() + and (_destroyedSegments.find(_autoSegments[i]) != _destroyedSegments.end()) ) + continue; + + _revalidateds.push_back ( _autoSegments[i] ); + } + _autoSegments.clear (); ltrace(110) << "AutoSegments/AutoContacts queued deletion." << endl; bool destroySegment = _katabatic->setDestroyBaseSegment ( true ); diff --git a/katabatic/src/katabatic/AutoSegment.h b/katabatic/src/katabatic/AutoSegment.h index 8a3564c1..353601bf 100644 --- a/katabatic/src/katabatic/AutoSegment.h +++ b/katabatic/src/katabatic/AutoSegment.h @@ -86,7 +86,7 @@ namespace Katabatic { , ParallelOrExpanded = (1<<2) , ParallelAndLayerChange = (1<<3) }; - enum Flags { Propagate=0x1, AllowLocal=0x2 }; + enum Flags { Propagate=0x1, AllowLocal=0x2, AllowTerminal=0x4 }; public: @@ -295,6 +295,10 @@ namespace Katabatic { virtual void _makeDogLeg ( GCell*, bool upLayer ) = 0; virtual void desalignate ( AutoContact* ) = 0; void desalignate (); + bool shearUp ( GCell* + , AutoSegment*& movedUp + , float reserve + , unsigned int flags ); bool _check () const; // Inspector Management. virtual Record* _getRecord () const = 0; diff --git a/katabatic/src/katabatic/GCell.h b/katabatic/src/katabatic/GCell.h index 60a0c145..1ded1826 100644 --- a/katabatic/src/katabatic/GCell.h +++ b/katabatic/src/katabatic/GCell.h @@ -134,11 +134,8 @@ namespace Katabatic { inline float getCDensity ( bool update=true ) const; inline float getDensity ( size_t depth, bool update=true ) const; float getDensity ( bool update=true ) const; - float getMaxHVDensity ( bool update=true ) const; inline float getBlockage ( unsigned int depth ) const; float getStiffness () const; - inline unsigned int getSegmentCount () const; - inline unsigned int getRoutedCount () const; inline vector* getVSegments (); inline vector* getHSegments (); inline vector* getContacts (); @@ -153,8 +150,6 @@ namespace Katabatic { size_t checkDensity () const; bool checkEdgeSaturation ( float threshold ) const; // Modifiers. - void incSegmentCount ( int count ); - void incRoutedCount ( int count ); void addBlockage ( unsigned int depth, float ); inline void addVSegment ( AutoSegment* ); inline void addHSegment ( AutoSegment* ); @@ -193,8 +188,6 @@ namespace Katabatic { float _cDensity; float* _densities; float* _saturateDensities; - unsigned int _segmentCount; - unsigned int _routedSegmentCount; bool _saturated; bool _invalid; Key _key; @@ -234,8 +227,6 @@ namespace Katabatic { inline vector* GCell::getVSegments () { return &_vsegments; } inline vector* GCell::getHSegments () { return &_hsegments; } inline vector* GCell::getContacts () { return &_contacts; } - inline unsigned int GCell::getSegmentCount () const { return _segmentCount; } - inline unsigned int GCell::getRoutedCount () const { return _routedSegmentCount; } inline string GCell::_getTypeName () const { return _TName("GCell"); } inline void GCell::invalidate () { _invalid = true; } inline const GCell::Key& GCell::getKey () const { return _key; } @@ -310,6 +301,9 @@ namespace Katabatic { string getVectorString ( float*, size_t ); + typedef std::vector GCellVector; + + } // End of Katabatic namespace. diff --git a/katabatic/src/katabatic/GCellGrid.h b/katabatic/src/katabatic/GCellGrid.h index 73b2027d..b45f0df4 100644 --- a/katabatic/src/katabatic/GCellGrid.h +++ b/katabatic/src/katabatic/GCellGrid.h @@ -49,9 +49,13 @@ namespace Katabatic { class GCellGrid : public Grid { public: - enum Flags { AverageDensity = 1 - , MaxHVDensity = 2 - , MaxLayerDensity = 3 + enum Flags { AverageHVDensity=1 // Average between all densities. + , AverageHDensity =2 // Average between all H densities. + , AverageVDensity =3 // Average between all V densities. + , MaxHVDensity =4 // Maximum between average H and average V. + , MaxVDensity =5 // Maximum of V densities. + , MaxHDensity =6 // Maximum of H densities. + , MaxDensity =7 // Maximum of H & V densities. }; public: