From b9abf9c00c02feb52a2c796199343acebe20d8ef Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 9 Dec 2006 08:01:00 -0800 Subject: Version abc61209 --- src/map/if/ifCut.c | 81 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 23 deletions(-) (limited to 'src/map/if/ifCut.c') diff --git a/src/map/if/ifCut.c b/src/map/if/ifCut.c index 56e354ce..06a020a6 100644 --- a/src/map/if/ifCut.c +++ b/src/map/if/ifCut.c @@ -96,7 +96,9 @@ int If_CutFilter( If_Man_t * p, If_Cut_t * pCut ) pTemp = p->ppCuts[i]; if ( pTemp->nLeaves > pCut->nLeaves ) { -// continue; + // do not fiter the first cut + if ( i == 0 ) + continue; // skip the non-contained cuts if ( (pTemp->uSign & pCut->uSign) != pCut->uSign ) continue; @@ -368,6 +370,10 @@ int If_CutCompareArea( If_Cut_t ** ppC0, If_Cut_t ** ppC1 ) return -1; if ( pC0->Area > pC1->Area + 0.0001 ) return 1; + if ( pC0->AveRefs > pC1->AveRefs ) + return -1; + if ( pC0->AveRefs < pC1->AveRefs ) + return 1; if ( pC0->nLeaves < pC1->nLeaves ) return -1; if ( pC0->nLeaves > pC1->nLeaves ) @@ -403,7 +409,7 @@ void If_ManSortCuts( If_Man_t * p, int Mode ) /**Function************************************************************* - Synopsis [Computes delay.] + Synopsis [Computes area flow.] Description [] @@ -412,21 +418,29 @@ void If_ManSortCuts( If_Man_t * p, int Mode ) SeeAlso [] ***********************************************************************/ -float If_CutDelay( If_Man_t * p, If_Cut_t * pCut ) +float If_CutFlow( If_Man_t * p, If_Cut_t * pCut ) { If_Obj_t * pLeaf; - float Delay; + float Flow; int i; assert( pCut->nLeaves > 1 ); - Delay = -IF_FLOAT_LARGE; + Flow = If_CutLutArea(p, pCut); If_CutForEachLeaf( p, pCut, pLeaf, i ) - Delay = IF_MAX( Delay, If_ObjCutBest(pLeaf)->Delay ); - return Delay + If_CutLutDelay(p, pCut); + { + if ( pLeaf->nRefs == 0 ) + Flow += If_ObjCutBest(pLeaf)->Area; + else + { + assert( pLeaf->EstRefs > p->fEpsilon ); + Flow += If_ObjCutBest(pLeaf)->Area / pLeaf->EstRefs; + } + } + return Flow; } /**Function************************************************************* - Synopsis [Computes area flow.] + Synopsis [Average number of references of the leaves.] Description [] @@ -435,24 +449,15 @@ float If_CutDelay( If_Man_t * p, If_Cut_t * pCut ) SeeAlso [] ***********************************************************************/ -float If_CutFlow( If_Man_t * p, If_Cut_t * pCut ) +float If_CutAverageRefs( If_Man_t * p, If_Cut_t * pCut ) { If_Obj_t * pLeaf; - float Flow; - int i; + int nRefsTotal, i; assert( pCut->nLeaves > 1 ); - Flow = If_CutLutArea(p, pCut); + nRefsTotal = 0; If_CutForEachLeaf( p, pCut, pLeaf, i ) - { - if ( pLeaf->nRefs == 0 ) - Flow += If_ObjCutBest(pLeaf)->Area; - else - { - assert( pLeaf->EstRefs > p->fEpsilon ); - Flow += If_ObjCutBest(pLeaf)->Area / pLeaf->EstRefs; - } - } - return Flow; + nRefsTotal += pLeaf->nRefs; + return ((float)nRefsTotal)/pCut->nLeaves; } /**Function************************************************************* @@ -529,6 +534,27 @@ void If_CutPrint( If_Man_t * p, If_Cut_t * pCut ) printf( " }\n" ); } +/**Function************************************************************* + + Synopsis [Prints one cut.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void If_CutPrintTiming( If_Man_t * p, If_Cut_t * pCut ) +{ + If_Obj_t * pLeaf; + unsigned i; + printf( "{" ); + If_CutForEachLeaf( p, pCut, pLeaf, i ) + printf( " %d(%.2f/%.2f)", pLeaf->Id, If_ObjCutBest(pLeaf)->Delay, pLeaf->Required ); + printf( " }\n" ); +} + /**Function************************************************************* Synopsis [Computes area of the first level.] @@ -585,15 +611,24 @@ float If_CutAreaRefed( If_Man_t * p, If_Cut_t * pCut, int nLevels ) void If_CutCopy( If_Cut_t * pCutDest, If_Cut_t * pCutSrc ) { int * pLeaves; + char * pPerm; unsigned * pTruth; + // save old arrays pLeaves = pCutDest->pLeaves; + pPerm = pCutDest->pPerm; pTruth = pCutDest->pTruth; + // copy the cut info *pCutDest = *pCutSrc; + // restore the arrays pCutDest->pLeaves = pLeaves; + pCutDest->pPerm = pPerm; pCutDest->pTruth = pTruth; + // copy the array data memcpy( pCutDest->pLeaves, pCutSrc->pLeaves, sizeof(int) * pCutSrc->nLeaves ); + if ( pCutSrc->pPerm ) + memcpy( pCutDest->pPerm, pCutSrc->pPerm, sizeof(unsigned) * If_CutPermWords(pCutSrc->nLimit) ); if ( pCutSrc->pTruth ) - memcpy( pCutDest->pTruth, pCutSrc->pTruth, sizeof(unsigned) * If_CutTruthWords(pCutSrc->nLimit) ); + memcpy( pCutDest->pTruth, pCutSrc->pTruth, sizeof(unsigned) * If_CutTruthWords(pCutSrc->nLimit) ); } //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3