Commit 95e14cd7 by Alan Mishchenko

Select for mapping smallest-area gates for each functionality.

parent 889ed19c
...@@ -231,78 +231,45 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, ...@@ -231,78 +231,45 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay,
{ {
Mio_Gate_t * pGate; Mio_Gate_t * pGate;
Mio_Gate_t ** ppGates; Mio_Gate_t ** ppGates;
/* st_table * tFuncs; */ int i, nGates, iGate;
/* st_generator * gen; */
// DdNode * bFunc;
// DdManager * dd;
int nGates, iGate;
// dd = Mio_LibraryReadDd( pLib );
nGates = Mio_LibraryReadGateNum( pLib ); nGates = Mio_LibraryReadGateNum( pLib );
/*
// for each functionality select one gate; skip constants and buffers
tFuncs = st_init_table( st_ptrcmp, st_ptrhash );
Mio_LibraryForEachGate( pLib, pGate )
{
bFunc = Mio_GateReadFunc(pGate);
if ( pGate->nInputs > nInputs )
continue;
if ( pGate->dDelayMax > (double)tDelay )
continue;
if ( bFunc == b0 || bFunc == b1 )
continue;
if ( bFunc == dd->vars[0] )
continue;
if ( bFunc == Cudd_Not(dd->vars[0]) && fSkipInv )
continue;
if ( st_is_member( tFuncs, (char *)bFunc ) )
continue;
st_insert( tFuncs, (char *)bFunc, (char *)pGate );
}
// collect the gates into the array
ppGates = ABC_ALLOC( Mio_Gate_t *, nGates );
iGate = 0;
st_foreach_item( tFuncs, gen, (char **)&bFunc, (char **)&pGate )
ppGates[ iGate++ ] = pGate;
assert( iGate <= nGates );
st_free_table( tFuncs );
*/
ppGates = ABC_ALLOC( Mio_Gate_t *, nGates ); ppGates = ABC_ALLOC( Mio_Gate_t *, nGates );
iGate = 0; iGate = 0;
// for each functionality, select gate with the smallest area
// if equal areas, select gate with lexicographically smaller name
Mio_LibraryForEachGate( pLib, pGate ) Mio_LibraryForEachGate( pLib, pGate )
{ {
// bFunc = Mio_GateReadFunc(pGate);
if ( pGate->nInputs > nInputs ) if ( pGate->nInputs > nInputs )
continue; continue;
if ( pGate->dDelayMax > (double)tDelay ) if ( pGate->dDelayMax > (double)tDelay )
continue; continue;
// if ( bFunc == b0 || bFunc == b1 )
if ( pGate->uTruth == 0 || pGate->uTruth == ~0 ) if ( pGate->uTruth == 0 || pGate->uTruth == ~0 )
continue; continue;
// if ( bFunc == dd->vars[0] )
if ( pGate->uTruth == 0xAAAAAAAAAAAAAAAA ) if ( pGate->uTruth == 0xAAAAAAAAAAAAAAAA )
continue; continue;
// if ( bFunc == Cudd_Not(dd->vars[0]) && fSkipInv )
if ( pGate->uTruth == ~0xAAAAAAAAAAAAAAAA && fSkipInv ) if ( pGate->uTruth == ~0xAAAAAAAAAAAAAAAA && fSkipInv )
continue; continue;
// check if the gate with this functionality already exists
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) )
ppGates[i] = pGate;
break;
}
if ( i < iGate )
continue;
assert( iGate < nGates ); assert( iGate < nGates );
ppGates[ iGate++ ] = pGate; ppGates[ iGate++ ] = pGate;
} }
// sort by delay
if ( iGate > 0 ) if ( iGate > 0 )
{ {
// sort the gates by delay
qsort( (void *)ppGates, iGate, sizeof(Mio_Gate_t *), qsort( (void *)ppGates, iGate, sizeof(Mio_Gate_t *),
(int (*)(const void *, const void *)) Mio_DelayCompare ); (int (*)(const void *, const void *)) Mio_DelayCompare );
assert( Mio_DelayCompare( ppGates, ppGates + iGate - 1 ) <= 0 ); assert( Mio_DelayCompare( ppGates, ppGates + iGate - 1 ) <= 0 );
} }
if ( pnGates ) if ( pnGates )
*pnGates = iGate; *pnGates = iGate;
return ppGates; return ppGates;
......
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