From 95e14cd72c9da6b2d051818806084c791702ff4b Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 26 Aug 2012 17:31:23 -0700 Subject: Select for mapping smallest-area gates for each functionality. --- src/map/mio/mioUtils.c | 65 +++++++++++++------------------------------------- 1 file changed, 16 insertions(+), 49 deletions(-) (limited to 'src/map/mio') 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; -- cgit v1.2.3