diff options
Diffstat (limited to 'src/misc/util')
-rw-r--r-- | src/misc/util/abc_global.h | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h index b798961e..6e112bb8 100644 --- a/src/misc/util/abc_global.h +++ b/src/misc/util/abc_global.h @@ -80,6 +80,7 @@ #include <time.h> #include <stdarg.h> #include <stdlib.h> +#include <assert.h> //////////////////////////////////////////////////////////////////////// /// NAMESPACES /// @@ -260,20 +261,30 @@ static inline void Abc_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1< static inline void Abc_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= (1<<((i) & 31)); } static inline unsigned Abc_InfoMask( int nVar ) { return (~(unsigned)0) >> (32-nVar); } -static inline int Abc_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; } -static inline int Abc_Lit2Var( int Lit ) { return Lit >> 1; } -static inline int Abc_LitIsCompl( int Lit ) { return Lit & 1; } -static inline int Abc_LitNot( int Lit ) { return Lit ^ 1; } -static inline int Abc_LitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); } -static inline int Abc_LitRegular( int Lit ) { return Lit & ~01; } -static inline int Abc_Lit2LitV( int * pMap, int Lit ) { return Abc_Var2Lit( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) ); } -static inline int Abc_Lit2LitL( int * pMap, int Lit ) { return Abc_LitNotCond( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) ); } +static inline int Abc_Var2Lit( int Var, int c ) { assert(Var >= 0 && !(c >> 1)); return Var + Var + c; } +static inline int Abc_Lit2Var( int Lit ) { assert(Lit >= 0); return Lit >> 1; } +static inline int Abc_LitIsCompl( int Lit ) { assert(Lit >= 0); return Lit & 1; } +static inline int Abc_LitNot( int Lit ) { assert(Lit >= 0); return Lit ^ 1; } +static inline int Abc_LitNotCond( int Lit, int c ) { assert(Lit >= 0); return Lit ^ (int)(c > 0); } +static inline int Abc_LitRegular( int Lit ) { assert(Lit >= 0); return Lit & ~01; } +static inline int Abc_Lit2LitV( int * pMap, int Lit ) { assert(Lit >= 0); return Abc_Var2Lit( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) ); } +static inline int Abc_Lit2LitL( int * pMap, int Lit ) { assert(Lit >= 0); return Abc_LitNotCond( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) ); } static inline int Abc_Ptr2Int( void * p ) { return (int)(ABC_PTRINT_T)p; } static inline void * Abc_Int2Ptr( int i ) { return (void *)(ABC_PTRINT_T)i; } static inline word Abc_Ptr2Wrd( void * p ) { return (word)(ABC_PTRUINT_T)p; } static inline void * Abc_Wrd2Ptr( word i ) { return (void *)(ABC_PTRUINT_T)i; } +static inline int Abc_Var2Lit2( int Var, int Att ) { assert(!(Att >> 2)); return (Var << 2) + Att; } +static inline int Abc_Lit2Var2( int Lit ) { assert(Lit >= 0); return Lit >> 2; } +static inline int Abc_Lit2Att2( int Lit ) { assert(Lit >= 0); return Lit & 3; } +static inline int Abc_Var2Lit3( int Var, int Att ) { assert(!(Att >> 3)); return (Var << 3) + Att; } +static inline int Abc_Lit2Var3( int Lit ) { assert(Lit >= 0); return Lit >> 3; } +static inline int Abc_Lit2Att3( int Lit ) { assert(Lit >= 0); return Lit & 7; } +static inline int Abc_Var2Lit4( int Var, int Att ) { assert(!(Att >> 4)); return (Var << 4) + Att; } +static inline int Abc_Lit2Var4( int Lit ) { assert(Lit >= 0); return Lit >> 4; } +static inline int Abc_Lit2Att4( int Lit ) { assert(Lit >= 0); return Lit & 15; } + // time counting typedef ABC_INT64_T abctime; static inline abctime Abc_Clock() |