From c0f0e145c46291db88fea7ae1251637b97f48e29 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 25 Apr 2015 14:58:29 -0700 Subject: Improving the criteria to select representative gates in 'map' with floating-point-delay libraries having more than one gate in some functionality classes. --- src/map/mio/mioUtils.c | 107 +++++++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 47 deletions(-) (limited to 'src/map/mio') diff --git a/src/map/mio/mioUtils.c b/src/map/mio/mioUtils.c index bc8e8993..5e3b8e4c 100644 --- a/src/map/mio/mioUtils.c +++ b/src/map/mio/mioUtils.c @@ -286,6 +286,18 @@ int Mio_DelayCompare( Mio_Gate_t ** ppG1, Mio_Gate_t ** ppG2 ) return 1; return 0; } +int Mio_AreaCompare( Mio_Cell_t * pG1, Mio_Cell_t * pG2 ) +{ + if ( (pG1)->nFanins < (pG2)->nFanins ) + return -1; + if ( (pG1)->nFanins > (pG2)->nFanins ) + return 1; + if ( (pG1)->Area < (pG2)->Area ) + return -1; + if ( (pG1)->Area > (pG2)->Area ) + return 1; + return 0; +} /**Function************************************************************* @@ -299,6 +311,51 @@ int Mio_DelayCompare( Mio_Gate_t ** ppG1, Mio_Gate_t ** ppG2 ) SeeAlso [] ***********************************************************************/ +static inline float Mio_CellDelayAve( Mio_Cell_t * pCell ) +{ + float CellDelay = 0; int k; + for ( k = 0; k < (int)pCell->nFanins; k++ ) + CellDelay += pCell->Delays[k]; + if ( pCell->nFanins ) + CellDelay /= pCell->nFanins; + return CellDelay; +} +static inline float Mio_GateDelayAve( Mio_Gate_t * pGate ) +{ + float GateDelay = 0; + Mio_Pin_t * pPin; + Mio_GateForEachPin( pGate, pPin ) + GateDelay += (float)(0.5 * pPin->dDelayBlockRise + 0.5 * pPin->dDelayBlockFall); + if ( pGate->nInputs ) + GateDelay /= pGate->nInputs; + return GateDelay; +} +static inline int Mio_CompareTwoGates( Mio_Gate_t * pCell, Mio_Gate_t * pGate ) +{ + int Comp; + float Eps = (float)0.01; + float CellDelay, GateDelay; + // compare areas + if ( pCell->dArea > (float)pGate->dArea + Eps ) + return 1; + if ( pCell->dArea < (float)pGate->dArea - Eps ) + return 0; + // compare delays + CellDelay = Mio_GateDelayAve( pCell ); + GateDelay = Mio_GateDelayAve( pGate ); + if ( CellDelay > GateDelay + Eps ) + return 1; + if ( CellDelay < GateDelay - Eps ) + return 0; + // compare names + Comp = strcmp( pCell->pName, pGate->pName ); + if ( Comp > 0 ) + return 1; + if ( Comp < 0 ) + return 0; + assert( 0 ); + return 0; +} Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, int fSkipInv, int * pnGates, int fVerbose ) { Mio_Gate_t * pGate; @@ -327,8 +384,7 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, for ( i = 0; i < iGate; i++ ) if ( ppGates[i]->uTruth == pGate->uTruth ) { - if ( ppGates[i]->dArea > pGate->dArea || - (ppGates[i]->dArea == pGate->dArea && strcmp(ppGates[i]->pName, pGate->pName) > 0) ) + if ( Mio_CompareTwoGates(ppGates[i], pGate) ) ppGates[i] = pGate; break; } @@ -353,30 +409,6 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, } -/**Function************************************************************* - - Synopsis [Compares the max delay of two gates.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Mio_DelayCompareNew( Mio_Cell_t * pG1, Mio_Cell_t * pG2 ) -{ - if ( (pG1)->nFanins < (pG2)->nFanins ) - return -1; - if ( (pG1)->nFanins > (pG2)->nFanins ) - return 1; - if ( (pG1)->Area < (pG2)->Area ) - return -1; - if ( (pG1)->Area > (pG2)->Area ) - return 1; - return 0; -} - /**Function************************************************************* Synopsis [Collects the set of root gates.] @@ -389,25 +421,6 @@ int Mio_DelayCompareNew( Mio_Cell_t * pG1, Mio_Cell_t * pG2 ) SeeAlso [] ***********************************************************************/ -static inline float Mio_CellDelayAve( Mio_Cell_t * pCell ) -{ - float CellDelay = 0; int k; - for ( k = 0; k < (int)pCell->nFanins; k++ ) - CellDelay += pCell->Delays[k]; - if ( pCell->nFanins ) - CellDelay /= pCell->nFanins; - return CellDelay; -} -static inline float Mio_GateDelayAve( Mio_Gate_t * pGate ) -{ - float GateDelay = 0; - Mio_Pin_t * pPin; - Mio_GateForEachPin( pGate, pPin ) - GateDelay += (float)(0.5 * pPin->dDelayBlockRise + 0.5 * pPin->dDelayBlockFall); - if ( pGate->nInputs ) - GateDelay /= pGate->nInputs; - return GateDelay; -} static inline int Mio_CompareTwo( Mio_Cell_t * pCell, Mio_Gate_t * pGate ) { int Comp; @@ -497,8 +510,8 @@ Mio_Cell_t * Mio_CollectRootsNew( Mio_Library_t * pLib, int nInputs, int * pnGat if ( iCell > 1 ) { qsort( (void *)(ppCells + 4), iCell - 4, sizeof(Mio_Cell_t), - (int (*)(const void *, const void *)) Mio_DelayCompareNew ); - assert( Mio_DelayCompareNew( ppCells + 4, ppCells + iCell - 1 ) <= 0 ); + (int (*)(const void *, const void *)) Mio_AreaCompare ); + assert( Mio_AreaCompare( ppCells + 4, ppCells + iCell - 1 ) <= 0 ); } // assign IDs for ( i = 0; i < iCell; i++ ) -- cgit v1.2.3