diff options
| author | Alan Mishchenko <alanmi@berkeley.edu> | 2015-04-25 14:58:29 -0700 | 
|---|---|---|
| committer | Alan Mishchenko <alanmi@berkeley.edu> | 2015-04-25 14:58:29 -0700 | 
| commit | c0f0e145c46291db88fea7ae1251637b97f48e29 (patch) | |
| tree | 9d6715d1eca81dbb6ec0b749a8e1ae0a4f257e9a /src | |
| parent | 3be417ae1c4a45e81a76da7816addbac9d47bbde (diff) | |
| download | abc-c0f0e145c46291db88fea7ae1251637b97f48e29.tar.gz abc-c0f0e145c46291db88fea7ae1251637b97f48e29.tar.bz2 abc-c0f0e145c46291db88fea7ae1251637b97f48e29.zip  | |
Improving the criteria to select representative gates in 'map' with floating-point-delay libraries having more than one gate in some functionality classes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/map/mio/mioUtils.c | 107 | 
1 files changed, 60 insertions, 47 deletions
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;              } @@ -355,30 +411,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.]    Description [Only collects the gates with unique functionality,  @@ -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++ )  | 
