From cabbab514035524b5c01471b4bebf8f803c2d060 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Fri, 13 Apr 2018 14:59:40 +0200 Subject: [PATCH] Correct interval capacity computation around zero in RoutingLayerGauge. * Bug: In CRL::RoutingLayerGauge::divide() & getTrackNumber(), the number of traks crossing an edge was wrongly computed for GCells around the zero coordinate, this was due to the change in rouding direction around zero. It was starting to show for routing gauges with an offset. Note: to simplificate the computation of the capacity of an interval, all the track over a Cell are computed from (0,0). The Cell abutment box has to be choosen relative to that. The tracks positions are fixed all over the Cell (or chip if it is one). --- crlcore/src/ccore/RoutingLayerGauge.cpp | 34 +++++++++++++++++-------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/crlcore/src/ccore/RoutingLayerGauge.cpp b/crlcore/src/ccore/RoutingLayerGauge.cpp index 0942efcd..aa4f6d12 100644 --- a/crlcore/src/ccore/RoutingLayerGauge.cpp +++ b/crlcore/src/ccore/RoutingLayerGauge.cpp @@ -174,19 +174,19 @@ namespace CRL { void RoutingLayerGauge::divide ( DbU::Unit dividend, long& quotient, long& modulo ) const { - quotient = ( dividend - _offset ) / _pitch; + quotient = ( dividend - _offset ) / _pitch - ((dividend < _offset) ? 1 : 0); modulo = ( dividend - _offset ) % _pitch; } unsigned RoutingLayerGauge::getTrackNumber ( DbU::Unit start, DbU::Unit stop ) const { - if ( start > stop ) - throw Error ( badInterval - , getString(this).c_str() - , DbU::getValueString(start).c_str() - , DbU::getValueString(stop).c_str() - ); + if (start > stop) + throw Error( badInterval + , getString(this).c_str() + , DbU::getValueString(start).c_str() + , DbU::getValueString(stop).c_str() + ); long startModulo; long startQuotient; @@ -194,14 +194,26 @@ namespace CRL { long stopQuotient; long trackNumber; - divide ( start, startQuotient, startModulo ); - divide ( stop , stopQuotient , stopModulo ); + divide( start, startQuotient, startModulo ); + divide( stop , stopQuotient , stopModulo ); - if ( startModulo != 0 ) startQuotient += 1; + // cerr << "getTrackNumber() " << getLayer()->getName() + // << " start:" << startQuotient << " modulo:" << startModulo + // << " stop:" << stopQuotient << " modulo:" << stopModulo + // << endl; + + if (startModulo != 0) startQuotient += 1; + if (stopModulo == 0) stopQuotient -= 1; trackNumber = stopQuotient - startQuotient + 1; - return ( (trackNumber>0) ? trackNumber : 0 ); + // cerr << "getTrackNumber() " << getLayer()->getName() + // << " [" << DbU::getValueString(start) << " " << DbU::getValueString(stop) + // << "] tracks:" << trackNumber + // << " start:" << startQuotient << " stop:" << stopQuotient + // << endl; + + return (trackNumber>0) ? trackNumber : 0; }