summaryrefslogtreecommitdiffstats
path: root/src/misc
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2021-08-02 16:46:56 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2021-08-02 16:46:56 -0700
commit5f8d4e72d1d99539d100ca5c190c56c5901976e6 (patch)
tree920c21100eaab65f24ea8649cfccb52822328996 /src/misc
parent03bb1e49bfcc148faaa4981bb3d758514adfeb4d (diff)
downloadabc-5f8d4e72d1d99539d100ca5c190c56c5901976e6.tar.gz
abc-5f8d4e72d1d99539d100ca5c190c56c5901976e6.tar.bz2
abc-5f8d4e72d1d99539d100ca5c190c56c5901976e6.zip
Experiments with LUT mapping for small functions.
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/util/utilTruth.h56
1 files changed, 55 insertions, 1 deletions
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;
@@ -1804,6 +1837,25 @@ static inline word Abc_Tt6Permute_rec( word t, int * pPerm, int nVars )
}
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 );
for ( v = 0; v < nVars; v++ )
@@ -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*************************************************************