From 5f8d4e72d1d99539d100ca5c190c56c5901976e6 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 2 Aug 2021 16:46:56 -0700 Subject: Experiments with LUT mapping for small functions. --- src/misc/util/utilTruth.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'src/misc/util') diff --git a/src/misc/util/utilTruth.h b/src/misc/util/utilTruth.h index 4c4b1422..7f3a7dd1 100644 --- a/src/misc/util/utilTruth.h +++ b/src/misc/util/utilTruth.h @@ -399,7 +399,23 @@ static inline int Abc_TtIntersect( word * pIn1, word * pIn2, int nWords, int fCo } return 0; } -static inline int Abc_TtIntersectOne( word * pOut, int fComp, word * pIn, int fComp0, int nWords ) +static inline int Abc_TtIntersectCare( word * pIn1, word * pIn2, word * pCare, int nWords, int fCompl ) +{ + int w; + if ( fCompl ) + { + for ( w = 0; w < nWords; w++ ) + if ( ~pIn1[w] & pIn2[w] & pCare[w] ) + return 1; + } + else + { + for ( w = 0; w < nWords; w++ ) + if ( pIn1[w] & pIn2[w] & pCare[w] ) + return 1; + } + return 0; +}static inline int Abc_TtIntersectOne( word * pOut, int fComp, word * pIn, int fComp0, int nWords ) { int w; if ( fComp0 ) @@ -542,6 +558,23 @@ static inline int Abc_TtEqual( word * pIn1, word * pIn2, int nWords ) return 0; return 1; } +static inline int Abc_TtEqualCare( word * pIn1, word * pIn2, word * pCare, int fComp, int nWords ) +{ + int w; + if ( fComp ) + { + for ( w = 0; w < nWords; w++ ) + if ( (~pIn1[w] ^ pIn2[w]) & pCare[w] ) + return 0; + } + else + { + for ( w = 0; w < nWords; w++ ) + if ( (pIn1[w] ^ pIn2[w]) & pCare[w] ) + return 0; + } + return 1; +} static inline int Abc_TtOpposite( word * pIn1, word * pIn2, int nWords ) { int w; @@ -1803,6 +1836,25 @@ static inline word Abc_Tt6Permute_rec( word t, int * pPerm, int nVars ) return (uRes0 & s_Truths6Neg[pPerm[Var]]) | (uRes1 & s_Truths6[pPerm[Var]]); } static inline void Abc_TtPermute( word * p, int * pPerm, int nVars ) +{ + int v, UnPerm[16], Perm[16]; + assert( nVars <= 16 ); + for ( v = 0; v < nVars; v++ ) + UnPerm[v] = Perm[v] = v; + for ( v = nVars-1; v >= 0; v-- ) + { + int Lev = UnPerm[pPerm[v]]; + if ( v == Lev ) + continue; + Abc_TtSwapVars( p, nVars, v, Lev ); + ABC_SWAP( int, Perm[v], Perm[Lev] ); + UnPerm[Perm[Lev]] = Lev; + UnPerm[Perm[v]] = v; + } + for ( v = 0; v < nVars; v++ ) + assert( Perm[v] == pPerm[v] ); +} +static inline void Abc_TtUnpermute( word * p, int * pPerm, int nVars ) { int v, Perm[16]; assert( nVars <= 16 ); @@ -1818,6 +1870,8 @@ static inline void Abc_TtPermute( word * p, int * pPerm, int nVars ) Perm[vCur]= vCur; } } + for ( v = 0; v < nVars; v++ ) + assert( Perm[v] == v ); } /**Function************************************************************* -- cgit v1.2.3