Fix bad index in Track::repair().

* Bug: In Track::repair(), when a same net gap has been found and closed,
    we display a warning. We display the two segments fused, but when it's
    the two first, we must not use index "i-1" (with i=0) ...
This commit is contained in:
Jean-Paul Chaput 2021-06-12 11:42:53 +02:00
parent ebe8ea64c6
commit 1733b5142a
1 changed files with 25 additions and 21 deletions

View File

@ -1003,7 +1003,7 @@ namespace Katana {
uint32_t Track::repair () const uint32_t Track::repair () const
{ {
//cerr << "Track::repair() " << this << endl; cerr << "Track::repair() " << this << endl;
if (_segments.empty()) return 0; if (_segments.empty()) return 0;
DbU::Unit minSpacing = getLayer()->getMinimalSpacing(); DbU::Unit minSpacing = getLayer()->getMinimalSpacing();
@ -1014,7 +1014,7 @@ namespace Katana {
GapSet gapsetCurr ( this ); GapSet gapsetCurr ( this );
for ( size_t i=0 ; i<_segments.size()-1 ; i++ ) { for ( size_t i=0 ; i<_segments.size()-1 ; i++ ) {
// if (getIndex() == 1750) // if (getIndex() == 1750)
// cerr << "[" << i << "] " << _segments[i] << endl; cerr << "[" << i << "] " << _segments[i] << endl;
netChange = false; netChange = false;
gapsetCurr.merge( i ); gapsetCurr.merge( i );
if ( (_segments[i]->getNet() != _segments[i+1]->getNet()) if ( (_segments[i]->getNet() != _segments[i+1]->getNet())
@ -1050,7 +1050,7 @@ namespace Katana {
if (netChange or (i+2 == _segments.size())) { if (netChange or (i+2 == _segments.size())) {
if (gapsetCurr.size() > 1) { if (gapsetCurr.size() > 1) {
// cerr << "potential gap around " << _segments[i] << endl; cerr << "potential gap around " << _segments[i] << endl;
for ( size_t j=0 ; j+1 < gapsetCurr.size() ; ++j ) { for ( size_t j=0 ; j+1 < gapsetCurr.size() ; ++j ) {
// cerr << j << "=[" << DbU::getValueString(gapsetCurr.sourceU(j)) // cerr << j << "=[" << DbU::getValueString(gapsetCurr.sourceU(j))
// << " " << DbU::getValueString(gapsetCurr.targetU(j)) << "], " // << " " << DbU::getValueString(gapsetCurr.targetU(j)) << "], "
@ -1063,24 +1063,28 @@ namespace Katana {
// << " " << DbU::getValueString(gapsetCurr.targetU(j)) << "], " // << " " << DbU::getValueString(gapsetCurr.targetU(j)) << "], "
// << j+1 << "=[" << DbU::getValueString(gapsetCurr.sourceU(j+1)) // << j+1 << "=[" << DbU::getValueString(gapsetCurr.sourceU(j+1))
// << " " << DbU::getValueString(gapsetCurr.targetU(j+1)) << "]" << endl; // << " " << DbU::getValueString(gapsetCurr.targetU(j+1)) << "]" << endl;
AutoSegment* first = _segments[gapsetCurr.span(j+1).first]->base(); if (gapsetCurr.span(j+1).first >= _segments.size()) {
cerr << Error("gapsetCurr.span(j+1).first >= _segments.size()") << endl;
// cerr << "spacing:" << DbU::getValueString(spacing) << " " << first << endl; } else {
if (first == NULL) { AutoSegment* first = _segments[gapsetCurr.span(j+1).first]->base();
cerr << Error("null first, NOT correcting gap") << endl;
} else { // cerr << "spacing:" << DbU::getValueString(spacing) << " " << first << endl;
for ( AutoSegment* segment : first->getAligneds() ) { if (first == NULL) {
if (segment->getSourcePosition() < first->getSourcePosition()) cerr << Error("null first, NOT correcting gap") << endl;
first = segment; } else {
} for ( AutoSegment* segment : first->getAligneds() ) {
// cerr << "duSource:" << DbU::getValueString(first->getDuSource()) << endl; if (segment->getSourcePosition() < first->getSourcePosition())
first->setDuSource( first->getDuSource() - spacing - minSpacing/2 ); first = segment;
} }
++gaps; // cerr << "duSource:" << DbU::getValueString(first->getDuSource()) << endl;
cerr << Warning( " Track::repair(): Closing same net gap in %s near:\n %s" first->setDuSource( first->getDuSource() - spacing - minSpacing/2 );
, getString(this).c_str() }
, getString(_segments[i-1]).c_str() ) << endl; ++gaps;
//cerr << first << endl; cerr << Warning( " Track::repair(): Closing same net gap in %s near:\n %s"
, getString(this).c_str()
, getString(_segments[(i) ? i-1 : 0]).c_str() ) << endl;
// cerr << first << endl;
}
} }
} }
} }