summaryrefslogtreecommitdiffstats
path: root/src/map/mio
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-08-26 17:31:23 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2012-08-26 17:31:23 -0700
commit95e14cd72c9da6b2d051818806084c791702ff4b (patch)
treee9dd3bbc4ddeccca99abe2981f6b587ca64ce899 /src/map/mio
parent889ed19c1c8c56e0d888876ed0b011275eafcaf8 (diff)
downloadabc-95e14cd72c9da6b2d051818806084c791702ff4b.tar.gz
abc-95e14cd72c9da6b2d051818806084c791702ff4b.tar.bz2
abc-95e14cd72c9da6b2d051818806084c791702ff4b.zip
Select for mapping smallest-area gates for each functionality.
Diffstat (limited to 'src/map/mio')
-rw-r--r--src/map/mio/mioUtils.c65
1 files changed, 16 insertions, 49 deletions
diff --git a/src/map/mio/mioUtils.c b/src/map/mio/mioUtils.c
index 36dd1291..d7f6c329 100644
--- a/src/map/mio/mioUtils.c
+++ b/src/map/mio/mioUtils.c
@@ -231,78 +231,45 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay,
{
Mio_Gate_t * pGate;
Mio_Gate_t ** ppGates;
- /* st_table * tFuncs; */
- /* st_generator * gen; */
-// DdNode * bFunc;
-// DdManager * dd;
- int nGates, iGate;
-
-// dd = Mio_LibraryReadDd( pLib );
+ int i, nGates, iGate;
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 );
iGate = 0;
+ // for each functionality, select gate with the smallest area
+ // if equal areas, select gate with lexicographically smaller name
Mio_LibraryForEachGate( pLib, pGate )
{
-// bFunc = Mio_GateReadFunc(pGate);
if ( pGate->nInputs > nInputs )
continue;
if ( pGate->dDelayMax > (double)tDelay )
continue;
-// if ( bFunc == b0 || bFunc == b1 )
if ( pGate->uTruth == 0 || pGate->uTruth == ~0 )
continue;
-// if ( bFunc == dd->vars[0] )
if ( pGate->uTruth == 0xAAAAAAAAAAAAAAAA )
continue;
-// if ( bFunc == Cudd_Not(dd->vars[0]) && fSkipInv )
if ( pGate->uTruth == ~0xAAAAAAAAAAAAAAAA && fSkipInv )
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 );
ppGates[ iGate++ ] = pGate;
}
-
- if ( iGate > 0 )
+ // sort by delay
+ if ( iGate > 0 )
{
- // sort the gates by delay
qsort( (void *)ppGates, iGate, sizeof(Mio_Gate_t *),
(int (*)(const void *, const void *)) Mio_DelayCompare );
assert( Mio_DelayCompare( ppGates, ppGates + iGate - 1 ) <= 0 );
}
-
if ( pnGates )
*pnGates = iGate;
return ppGates;