Commit c0f0e145 by Alan Mishchenko

Improving the criteria to select representative gates in 'map' with…

Improving the criteria to select representative gates in 'map' with floating-point-delay libraries having more than one gate in some functionality classes.
parent 3be417ae
......@@ -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++ )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment