summaryrefslogtreecommitdiffstats
path: root/src/misc/util
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2021-09-30 18:02:33 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2021-09-30 18:02:33 -0700
commit674bcbee379b9dcef418ddb62655ee0d3d59f96c (patch)
tree91d26a826f548a21b4f86aed82782121f0717744 /src/misc/util
parenta8b5da820df6c008fd02f514a8c93a48ecfe3620 (diff)
downloadabc-674bcbee379b9dcef418ddb62655ee0d3d59f96c.tar.gz
abc-674bcbee379b9dcef418ddb62655ee0d3d59f96c.tar.bz2
abc-674bcbee379b9dcef418ddb62655ee0d3d59f96c.zip
Various changes.
Diffstat (limited to 'src/misc/util')
-rw-r--r--src/misc/util/utilTruth.h48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/misc/util/utilTruth.h b/src/misc/util/utilTruth.h
index 6a98c40f..dbc0e5a0 100644
--- a/src/misc/util/utilTruth.h
+++ b/src/misc/util/utilTruth.h
@@ -356,6 +356,12 @@ static inline void Abc_TtOrAnd( word * pOut, word * pIn1, word * pIn2, int nWord
for ( w = 0; w < nWords; w++ )
pOut[w] |= pIn1[w] & pIn2[w];
}
+static inline void Abc_TtSharpOr( word * pOut, word * pIn1, word * pIn2, int nWords )
+{
+ int w;
+ for ( w = 0; w < nWords; w++ )
+ pOut[w] = (pOut[w] & ~pIn1[w]) | pIn2[w];
+}
static inline void Abc_TtXor( word * pOut, word * pIn1, word * pIn2, int nWords, int fCompl )
{
int w;
@@ -2104,18 +2110,25 @@ static inline int Abc_TtCountOnesVec( word * x, int nWords )
{
int w, Count = 0;
for ( w = 0; w < nWords; w++ )
- Count += Abc_TtCountOnes( x[w] );
+ if ( x[w] )
+ Count += Abc_TtCountOnes( x[w] );
return Count;
}
static inline int Abc_TtCountOnesVecMask( word * x, word * pMask, int nWords, int fCompl )
{
int w, Count = 0;
if ( fCompl )
+ {
for ( w = 0; w < nWords; w++ )
- Count += Abc_TtCountOnes( pMask[w] & ~x[w] );
+ if ( pMask[w] & ~x[w] )
+ Count += Abc_TtCountOnes( pMask[w] & ~x[w] );
+ }
else
+ {
for ( w = 0; w < nWords; w++ )
- Count += Abc_TtCountOnes( pMask[w] & x[w] );
+ if ( pMask[w] & x[w] )
+ Count += Abc_TtCountOnes( pMask[w] & x[w] );
+ }
return Count;
}
static inline int Abc_TtCountOnesVecMask2( word * x0, word * x1, int fComp0, int fComp1, word * pMask, int nWords )
@@ -2139,7 +2152,8 @@ static inline int Abc_TtCountOnesVecXor( word * x, word * y, int nWords )
{
int w, Count = 0;
for ( w = 0; w < nWords; w++ )
- Count += Abc_TtCountOnes( x[w] ^ y[w] );
+ if ( x[w] ^ y[w] )
+ Count += Abc_TtCountOnes( x[w] ^ y[w] );
return Count;
}
static inline int Abc_TtCountOnesVecXorMask( word * x, word * y, int fCompl, word * pMask, int nWords )
@@ -2163,6 +2177,16 @@ static inline int Abc_TtAndXorSum( word * pOut, word * pIn1, word * pIn2, int nW
}
return Count;
}
+static inline void Abc_TtIsfPrint( word * pOff, word * pOn, int nWords )
+{
+ int nTotal = 64*nWords;
+ int nOffset = Abc_TtCountOnesVec(pOff, nWords);
+ int nOnset = Abc_TtCountOnesVec(pOn, nWords);
+ int nDcset = nTotal - nOffset - nOnset;
+ printf( "OFF =%6d (%6.2f %%) ", nOffset, 100.0*nOffset/nTotal );
+ printf( "ON =%6d (%6.2f %%) ", nOnset, 100.0*nOnset/nTotal );
+ printf( "DC =%6d (%6.2f %%)", nDcset, 100.0*nDcset/nTotal );
+}
/**Function*************************************************************
@@ -2263,6 +2287,22 @@ static inline int Abc_TtFindLastDiffBit2( word * pIn1, word * pIn2, int nWords )
return 64*w + Abc_Tt6LastBit(pIn1[w] ^ pIn2[w]);
return -1;
}
+static inline int Abc_TtFindFirstAndBit2( word * pIn1, word * pIn2, int nWords )
+{
+ int w;
+ for ( w = 0; w < nWords; w++ )
+ if ( pIn1[w] & pIn2[w] )
+ return 64*w + Abc_Tt6FirstBit(pIn1[w] & pIn2[w]);
+ return -1;
+}
+static inline int Abc_TtFindLastAndBit2( word * pIn1, word * pIn2, int nWords )
+{
+ int 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_TtFindFirstZero( word * pIn, int nVars )
{
int w, nWords = Abc_TtWordNum(nVars);