diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2017-10-01 18:40:30 +0300 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2017-10-01 18:40:30 +0300 |
commit | ce8dbc4ac6b1e40e4d209d23c95e014417378f38 (patch) | |
tree | de7f702d90ab33fac17f24985ed6f73eb40784a0 /src/misc/util | |
parent | d3152aefa7af3a1173647b678959f70d935ae707 (diff) | |
download | abc-ce8dbc4ac6b1e40e4d209d23c95e014417378f38.tar.gz abc-ce8dbc4ac6b1e40e4d209d23c95e014417378f38.tar.bz2 abc-ce8dbc4ac6b1e40e4d209d23c95e014417378f38.zip |
Exact synthesis of majority gates.
Diffstat (limited to 'src/misc/util')
-rw-r--r-- | src/misc/util/utilTruth.h | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/misc/util/utilTruth.h b/src/misc/util/utilTruth.h index 3a9eb7c1..bd749795 100644 --- a/src/misc/util/utilTruth.h +++ b/src/misc/util/utilTruth.h @@ -1751,6 +1751,22 @@ static inline int Abc_TtFindFirstBit2( word * pIn, int nWords ) return 64*w + Abc_Tt6FirstBit(pIn[w]); return -1; } +static inline int Abc_TtFindLastBit( word * pIn, int nVars ) +{ + int w, nWords = Abc_TtWordNum(nVars); + for ( w = nWords - 1; w >= 0; w-- ) + if ( pIn[w] ) + return 64*w + Abc_Tt6LastBit(pIn[w]); + return -1; +} +static inline int Abc_TtFindLastBit2( word * pIn, int nWords ) +{ + int w; + for ( w = nWords - 1; w >= 0; w-- ) + if ( pIn[w] ) + return 64*w + Abc_Tt6LastBit(pIn[w]); + return -1; +} static inline int Abc_TtFindFirstDiffBit( word * pIn1, word * pIn2, int nVars ) { int w, nWords = Abc_TtWordNum(nVars); @@ -1767,20 +1783,28 @@ static inline int Abc_TtFindFirstDiffBit2( word * pIn1, word * pIn2, int nWords return 64*w + Abc_Tt6FirstBit(pIn1[w] ^ pIn2[w]); return -1; } -static inline int Abc_TtFindFirstZero( word * pIn, int nVars ) +static inline int Abc_TtFindLastDiffBit( word * pIn1, word * pIn2, int nVars ) { int w, nWords = Abc_TtWordNum(nVars); - for ( w = 0; w < nWords; w++ ) - if ( ~pIn[w] ) - return 64*w + Abc_Tt6FirstBit(~pIn[w]); + for ( w = nWords - 1; w >= 0; w-- ) + if ( pIn1[w] ^ pIn2[w] ) + return 64*w + Abc_Tt6LastBit(pIn1[w] ^ pIn2[w]); return -1; } -static inline int Abc_TtFindLastBit( word * pIn, int nVars ) +static inline int Abc_TtFindLastDiffBit2( word * pIn1, word * pIn2, int nWords ) { - int w, nWords = Abc_TtWordNum(nVars); + int w; for ( w = nWords - 1; w >= 0; w-- ) - if ( pIn[w] ) - return 64*w + Abc_Tt6LastBit(pIn[w]); + if ( pIn1[w] ^ pIn2[w] ) + return 64*w + Abc_Tt6LastBit(pIn1[w] ^ pIn2[w]); + return -1; +} +static inline int Abc_TtFindFirstZero( word * pIn, int nVars ) +{ + int w, nWords = Abc_TtWordNum(nVars); + for ( w = 0; w < nWords; w++ ) + if ( ~pIn[w] ) + return 64*w + Abc_Tt6FirstBit(~pIn[w]); return -1; } static inline int Abc_TtFindLastZero( word * pIn, int nVars ) |