diff --git a/src/aig/gia/giaSpeedup.c b/src/aig/gia/giaSpeedup.c index 0c9d75098..0786bd559 100644 --- a/src/aig/gia/giaSpeedup.c +++ b/src/aig/gia/giaSpeedup.c @@ -333,6 +333,32 @@ float Gia_ManDelayTraceLut( Gia_Man_t * p ) Gia_ObjSetTimeArrival( p, i, tArrival ); } + // update levels of box output CIs to reflect box structure + // (Gia_ManLevelNum assigns level 0 to all CIs, but box output CIs + // need higher levels so that Gia_ManOrderReverse processes them + // before box input COs during the backward required-time pass) + if ( p->pManTime ) + { + Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime; + int iBox, nBoxes = Tim_ManBoxNum( pManTime ); + for ( iBox = 0; iBox < nBoxes; iBox++ ) + { + int nIns = Tim_ManBoxInputNum( pManTime, iBox ); + int nOuts = Tim_ManBoxOutputNum( pManTime, iBox ); + int iCoFirst = Tim_ManBoxInputFirst( pManTime, iBox ); + int iCiFirst = Tim_ManBoxOutputFirst( pManTime, iBox ); + int j, maxLevel = 0; + for ( j = 0; j < nIns; j++ ) + { + int coLevel = Gia_ObjLevel( p, Gia_ManCo(p, iCoFirst + j) ); + if ( coLevel > maxLevel ) + maxLevel = coLevel; + } + for ( j = 0; j < nOuts; j++ ) + Gia_ObjSetLevel( p, Gia_ManCi(p, iCiFirst + j), maxLevel + 1 ); + } + } + // get the latest arrival times tArrival = -TIM_ETERNITY; Gia_ManForEachCo( p, pObj, i ) diff --git a/src/misc/tim/timTime.c b/src/misc/tim/timTime.c index c766fb7f1..578eead31 100644 --- a/src/misc/tim/timTime.c +++ b/src/misc/tim/timTime.c @@ -249,7 +249,7 @@ float Tim_ManGetCoRequired( Tim_Man_t * p, int iCo ) Tim_ManBoxForEachOutput( p, pBox, pObj, k ) { pDelays = pTable + 3 + k * pBox->nInputs; - if ( pDelays[k] != -ABC_INFINITY ) + if ( pDelays[i] != -ABC_INFINITY ) DelayBest = Abc_MinFloat( DelayBest, pObj->timeReq - pDelays[i] ); } pObjRes->timeReq = DelayBest;