diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2013-05-24 19:54:28 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2013-05-24 19:54:28 -0700 |
commit | 283abd4795bd5c45d7dc51abd2e097a1794bad5d (patch) | |
tree | a8e4eaccabb038f22cdb39d8c6048f1cc0a4d415 /src/opt/sfm/sfmWin.c | |
parent | ac037cbb966285b724c8bbf776195855dc4a558f (diff) | |
download | abc-283abd4795bd5c45d7dc51abd2e097a1794bad5d.tar.gz abc-283abd4795bd5c45d7dc51abd2e097a1794bad5d.tar.bz2 abc-283abd4795bd5c45d7dc51abd2e097a1794bad5d.zip |
New MFS package.
Diffstat (limited to 'src/opt/sfm/sfmWin.c')
-rw-r--r-- | src/opt/sfm/sfmWin.c | 124 |
1 files changed, 113 insertions, 11 deletions
diff --git a/src/opt/sfm/sfmWin.c b/src/opt/sfm/sfmWin.c index 078406ba..e0baa96f 100644 --- a/src/opt/sfm/sfmWin.c +++ b/src/opt/sfm/sfmWin.c @@ -33,6 +33,71 @@ ABC_NAMESPACE_IMPL_START /**Function************************************************************* + Synopsis [Returns the MFFC size.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Sfm_ObjRef_rec( Sfm_Ntk_t * p, int iObj ) +{ + int i, iFanin, Value, Count; + if ( Sfm_ObjIsPi(p, iObj) ) + return 0; + assert( Sfm_ObjIsNode(p, iObj) ); + Value = Sfm_ObjRefIncrement(p, iObj); + if ( Value > 1 ) + return 0; + assert( Value == 1 ); + Count = 1; + Sfm_ObjForEachFanin( p, iObj, iFanin, i ) + Count += Sfm_ObjRef_rec( p, iFanin ); + return Count; +} +int Sfm_ObjRef( Sfm_Ntk_t * p, int iObj ) +{ + int i, iFanin, Count = 1; + Sfm_ObjForEachFanin( p, iObj, iFanin, i ) + Count += Sfm_ObjRef_rec( p, iFanin ); + return Count; +} +int Sfm_ObjDeref_rec( Sfm_Ntk_t * p, int iObj ) +{ + int i, iFanin, Value, Count; + if ( Sfm_ObjIsPi(p, iObj) ) + return 0; + assert( Sfm_ObjIsNode(p, iObj) ); + Value = Sfm_ObjRefDecrement(p, iObj); + if ( Value > 0 ) + return 0; + assert( Value == 0 ); + Count = 1; + Sfm_ObjForEachFanin( p, iObj, iFanin, i ) + Count += Sfm_ObjDeref_rec( p, iFanin ); + return Count; +} +int Sfm_ObjDeref( Sfm_Ntk_t * p, int iObj ) +{ + int i, iFanin, Count = 1; + Sfm_ObjForEachFanin( p, iObj, iFanin, i ) + Count += Sfm_ObjDeref_rec( p, iFanin ); + return Count; +} +int Sfm_ObjMffcSize( Sfm_Ntk_t * p, int iObj ) +{ + int Count1, Count2; + assert( Sfm_ObjIsNode( p, iObj ) ); + Count1 = Sfm_ObjDeref( p, iObj ); + Count2 = Sfm_ObjRef( p, iObj ); + assert( Count1 == Count2 ); + return Count1; +} + +/**Function************************************************************* + Synopsis [Working with traversal IDs.] Description [] @@ -70,7 +135,7 @@ int Sfm_NtkCheckOverlap_rec( Sfm_Ntk_t * p, int iThis, int iNode ) if ( Sfm_ObjIsTravIdCurrent(p, iThis) ) return 1; Sfm_ObjSetTravIdCurrent2(p, iThis); - Sfm_NodeForEachFanin( p, iThis, iFanin, i ) + Sfm_ObjForEachFanin( p, iThis, iFanin, i ) if ( Sfm_NtkCheckOverlap_rec(p, iFanin, iNode) ) return 1; return 0; @@ -97,7 +162,7 @@ int Sfm_NtkCheckFanouts( Sfm_Ntk_t * p, int iNode ) int i, iFanout; if ( Sfm_ObjFanoutNum(p, iNode) >= p->pPars->nFanoutMax ) return 0; - Sfm_NodeForEachFanout( p, iNode, iFanout, i ) + Sfm_ObjForEachFanout( p, iNode, iFanout, i ) if ( !Sfm_NtkCheckOverlap( p, iFanout, iNode ) ) return 0; return 1; @@ -117,7 +182,7 @@ int Sfm_NtkCheckFanouts( Sfm_Ntk_t * p, int iNode ) void Sfm_NtkAddDivisors( Sfm_Ntk_t * p, int iNode ) { int i, iFanout; - Sfm_NodeForEachFanout( p, iNode, iFanout, i ) + Sfm_ObjForEachFanout( p, iNode, iFanout, i ) { // skip TFI nodes, PO nodes, and nodes with high fanout or nodes with high logic level if ( Sfm_ObjIsTravIdCurrent(p, iFanout) || Sfm_ObjIsPo(p, iFanout) || @@ -162,13 +227,14 @@ void Sfm_NtkCollectTfi_rec( Sfm_Ntk_t * p, int iNode ) Vec_IntPush( p->vLeaves, iNode ); return; } - Sfm_NodeForEachFanin( p, iNode, iFanin, i ) + Sfm_ObjForEachFanin( p, iNode, iFanin, i ) Sfm_NtkCollectTfi_rec( p, iFanin ); Vec_IntPush( p->vNodes, iNode ); } -int Sfm_NtkWindow( Sfm_Ntk_t * p, int iNode, int fVerbose ) +int Sfm_NtkCreateWindow( Sfm_Ntk_t * p, int iNode, int fVerbose ) { int i, iTemp; + clock_t clk = clock(); /* if ( iNode == 7 ) { @@ -187,7 +253,7 @@ int Sfm_NtkWindow( Sfm_Ntk_t * p, int iNode, int fVerbose ) Vec_IntClear( p->vTfo ); // roots if ( Sfm_NtkCheckFanouts(p, iNode) ) { - Sfm_NodeForEachFanout( p, iNode, iTemp, i ) + Sfm_ObjForEachFanout( p, iNode, iTemp, i ) { if ( Sfm_ObjIsPo(p, iTemp) ) continue; @@ -197,15 +263,16 @@ int Sfm_NtkWindow( Sfm_Ntk_t * p, int iNode, int fVerbose ) } else Vec_IntPush( p->vRoots, iNode ); + p->timeWin += clock() - clk; // collect divisors of the TFI nodes + clk = clock(); Vec_IntClear( p->vDivs ); + Vec_IntAppend( p->vDivs, p->vLeaves ); + Vec_IntAppend( p->vDivs, p->vNodes ); Sfm_NtkIncrementTravId2( p ); - Vec_IntForEachEntry( p->vLeaves, iTemp, i ) - Sfm_NtkAddDivisors( p, iTemp ); - Vec_IntForEachEntry( p->vNodes, iTemp, i ) - Sfm_NtkAddDivisors( p, iTemp ); Vec_IntForEachEntry( p->vDivs, iTemp, i ) Sfm_NtkAddDivisors( p, iTemp ); + p->timeDiv += clock() - clk; if ( !fVerbose ) return 1; @@ -222,7 +289,42 @@ void Sfm_NtkWindowTest( Sfm_Ntk_t * p, int iNode ) { int i; Sfm_NtkForEachNode( p, i ) - Sfm_NtkWindow( p, i, 1 ); + Sfm_NtkCreateWindow( p, i, 1 ); +} + +/**Function************************************************************* + + Synopsis [Removes node and its fanins from the array of divisors.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Sfm_NtkPrepareDivisors( Sfm_Ntk_t * p, int iNode ) +{ + int i, iFanin, k = 0; + // mark fanins + Sfm_NtkIncrementTravId( p ); + Sfm_ObjSetTravIdCurrent( p, iNode ); + Sfm_ObjForEachFanin( p, iNode, iFanin, i ) + Sfm_ObjSetTravIdCurrent( p, iFanin ); + // compact divisors + Vec_IntClear( p->vDivVars ); + Vec_IntForEachEntry( p->vDivs, iFanin, i ) + if ( !Sfm_ObjIsTravIdCurrent( p, iFanin ) ) + { + Vec_IntPush( p->vDivVars, Sfm_ObjSatVar(p, iFanin) ); + Vec_IntWriteEntry( p->vDivs, k++, iFanin ); + } + assert( Vec_IntSize(p->vDivs) == k + Sfm_ObjFaninNum(p, iNode) + 1 ); + Vec_IntShrink( p->vDivs, k ); + // collect fanins +// Vec_IntClear( p->vFans ); +// Sfm_ObjForEachFanin( p, iNode, iFanin, i ) +// Vec_IntPush( p->vFans, iFanin ); } //////////////////////////////////////////////////////////////////////// |