diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2012-10-30 23:42:04 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2012-10-30 23:42:04 -0700 |
commit | 66c044c688282dc7c4dc1f6ca82358fe2958a86e (patch) | |
tree | ad9af510cdf8d7d3672d60fa55a017e63105b309 | |
parent | 32b09a1e7bfe61f34fe362c3f6c2e645feeb38cf (diff) | |
download | abc-66c044c688282dc7c4dc1f6ca82358fe2958a86e.tar.gz abc-66c044c688282dc7c4dc1f6ca82358fe2958a86e.tar.bz2 abc-66c044c688282dc7c4dc1f6ca82358fe2958a86e.zip |
Improvements to the truth table computations.
-rw-r--r-- | src/misc/util/utilTruth.h | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/misc/util/utilTruth.h b/src/misc/util/utilTruth.h index 476fd66b..7449cbac 100644 --- a/src/misc/util/utilTruth.h +++ b/src/misc/util/utilTruth.h @@ -1075,7 +1075,7 @@ static inline unsigned Abc_TtSemiCanonicize( word * pTruth, int nVars, char * pC { int pStore[16]; int nWords = Abc_TtWordNum( nVars ); - int i, Temp, fChange, nOnes; + int i, k, BestK, Temp, nOnes;//, nSwaps = 0;//, fChange; unsigned uCanonPhase = 0; assert( nVars <= 16 ); // normalize polarity @@ -1087,6 +1087,7 @@ static inline unsigned Abc_TtSemiCanonicize( word * pTruth, int nVars, char * pC uCanonPhase |= (1 << nVars); } // normalize phase +// Abc_TtCountOnesInCofsSlow( pTruth, nVars, pStore ); Abc_TtCountOnesInCofs( pTruth, nVars, pStore ); for ( i = 0; i < nVars; i++ ) { @@ -1096,7 +1097,7 @@ static inline unsigned Abc_TtSemiCanonicize( word * pTruth, int nVars, char * pC uCanonPhase |= (1 << i); pStore[i] = nOnes - pStore[i]; } - +/* do { fChange = 0; for ( i = 0; i < nVars-1; i++ ) @@ -1119,8 +1120,44 @@ static inline unsigned Abc_TtSemiCanonicize( word * pTruth, int nVars, char * pC } Abc_TtSwapAdjacent( pTruth, nWords, i ); fChange = 1; +// nSwaps++; } } while ( fChange ); +*/ + + for ( i = 0; i < nVars - 1; i++ ) + { + BestK = i + 1; + for ( k = i + 2; k < nVars; k++ ) + if ( pStore[BestK] > pStore[k] ) + BestK = k; + if ( pStore[BestK] >= pStore[i] ) + continue; + + Temp = pCanonPerm[i]; + pCanonPerm[i] = pCanonPerm[BestK]; + pCanonPerm[BestK] = Temp; + + Temp = pStore[i]; + pStore[i] = pStore[BestK]; + pStore[BestK] = Temp; + + if ( ((uCanonPhase >> i) & 1) != ((uCanonPhase >> BestK) & 1) ) + { + uCanonPhase ^= (1 << i); + uCanonPhase ^= (1 << BestK); + } + Abc_TtSwapVars( pTruth, nVars, i, BestK ); +// nSwaps++; + } +/* + printf( "%d ", nSwaps ); + + printf( "Minterms: " ); + for ( i = 0; i < nVars; i++ ) + printf( "%d ", pStore[i] ); + printf( "\n" ); +*/ return uCanonPhase; } |