diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2006-08-12 08:01:00 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2006-08-12 08:01:00 -0700 |
commit | eb2a5b43a46b90f3c46b388f50ea0ca8918983aa (patch) | |
tree | 55a47e46ceefc8837d8a05807d8b7169d763e3f0 /src/misc | |
parent | 6b44b18e69f4e26249140e10c459615a77b32fc5 (diff) | |
download | abc-eb2a5b43a46b90f3c46b388f50ea0ca8918983aa.tar.gz abc-eb2a5b43a46b90f3c46b388f50ea0ca8918983aa.tar.bz2 abc-eb2a5b43a46b90f3c46b388f50ea0ca8918983aa.zip |
Version abc60812
Diffstat (limited to 'src/misc')
-rw-r--r-- | src/misc/extra/extra.h | 29 | ||||
-rw-r--r-- | src/misc/extra/extraUtil.h | 60 | ||||
-rw-r--r-- | src/misc/extra/extraUtilTruth.c | 20 |
3 files changed, 26 insertions, 83 deletions
diff --git a/src/misc/extra/extra.h b/src/misc/extra/extra.h index bdbc3d89..8b20daae 100644 --- a/src/misc/extra/extra.h +++ b/src/misc/extra/extra.h @@ -341,7 +341,7 @@ extern int Extra_MmStepReadMemUsage( Extra_MmStep_t * p ); /*=== extraUtilMisc.c ========================================================*/ -/* finds the smallest integer larger of equal than the logarithm. */ +/* finds the smallest integer larger or equal than the logarithm */ extern int Extra_Base2Log( unsigned Num ); extern int Extra_Base2LogDouble( double Num ); extern int Extra_Base10Log( unsigned Num ); @@ -400,7 +400,15 @@ static inline void Extra_ProgressBarUpdate( ProgressBar * p, int nItemsCur, char /*=== extraUtilTruth.c ================================================================*/ -static inline int Extra_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); } +static inline int Extra_Float2Int( float Val ) { return *((int *)&Val); } +static inline float Extra_Int2Float( int Num ) { return *((float *)&Num); } +static inline int Extra_BitWordNum( int nBits ) { return nBits/(8*sizeof(unsigned)) + ((nBits%(8*sizeof(unsigned))) > 0); } +static inline int Extra_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); } + +static inline void Extra_TruthSetBit( unsigned * p, int Bit ) { p[Bit>>5] |= (1<<(Bit & 31)); } +static inline void Extra_TruthXorBit( unsigned * p, int Bit ) { p[Bit>>5] ^= (1<<(Bit & 31)); } +static inline int Extra_TruthHasBit( unsigned * p, int Bit ) { return (p[Bit>>5] & (1<<(Bit & 31))) > 0; } + static inline int Extra_WordCountOnes( unsigned uWord ) { uWord = (uWord & 0x55555555) + ((uWord>>1) & 0x55555555); @@ -409,6 +417,13 @@ static inline int Extra_WordCountOnes( unsigned uWord ) uWord = (uWord & 0x00FF00FF) + ((uWord>>8) & 0x00FF00FF); return (uWord & 0x0000FFFF) + (uWord>>16); } +static inline int Extra_TruthCountOnes( unsigned * pIn, int nVars ) +{ + int w, Counter = 0; + for ( w = Extra_TruthWordNum(nVars)-1; w >= 0; w-- ) + Counter += Extra_WordCountOnes(pIn[w]); + return Counter; +} static inline int Extra_TruthIsEqual( unsigned * pIn0, unsigned * pIn1, int nVars ) { int w; @@ -504,18 +519,26 @@ extern void Extra_TruthForall( unsigned * pTruth, int nVars, int iVar ); extern void Extra_TruthMux( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar ); extern void Extra_TruthChangePhase( unsigned * pTruth, int nVars, int iVar ); extern int Extra_TruthMinCofSuppOverlap( unsigned * pTruth, int nVars, int * pVarMin ); -extern int Extra_TruthCountOnes( unsigned * pTruth, int nVars ); extern void Extra_TruthCountOnesInCofs( unsigned * pTruth, int nVars, short * pStore ); extern unsigned Extra_TruthHash( unsigned * pIn, int nWords ); extern unsigned Extra_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, int nVars, char * pCanonPerm, short * pStore ); /*=== extraUtilUtil.c ================================================================*/ +#ifndef ALLOC #define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) +#endif + +#ifndef FREE #define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) +#endif + +#ifndef REALLOC #define REALLOC(type, obj, num) \ ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ ((type *) malloc(sizeof(type) * (num)))) +#endif + extern long Extra_CpuTime(); extern int Extra_GetSoftDataLimit(); diff --git a/src/misc/extra/extraUtil.h b/src/misc/extra/extraUtil.h deleted file mode 100644 index d3f432c2..00000000 --- a/src/misc/extra/extraUtil.h +++ /dev/null @@ -1,60 +0,0 @@ -/**CFile**************************************************************** - - FileName [extraUtil.h] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [extra] - - Synopsis [Various reusable software utilities.] - - Description [] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: extraUtil.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#ifndef __EXTRA_UTIL_H__ -#define __EXTRA_UTIL_H__ - -/*---------------------------------------------------------------------------*/ -/* Nested includes */ -/*---------------------------------------------------------------------------*/ - -#include <string.h> -#include <time.h> - -/*---------------------------------------------------------------------------*/ -/* Constant declarations */ -/*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*/ -/* Stucture declarations */ -/*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*/ -/* Type declarations */ -/*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*/ -/* Variable declarations */ -/*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*/ -/* Macro declarations */ -/*---------------------------------------------------------------------------*/ - -/*===========================================================================*/ -/* Various Utilities */ -/*===========================================================================*/ - - -/**AutomaticEnd***************************************************************/ - -#endif /* __EXTRA_UTIL_H__ */ diff --git a/src/misc/extra/extraUtilTruth.c b/src/misc/extra/extraUtilTruth.c index 6b10813c..ab476f6f 100644 --- a/src/misc/extra/extraUtilTruth.c +++ b/src/misc/extra/extraUtilTruth.c @@ -782,26 +782,6 @@ void Extra_TruthChangePhase( unsigned * pTruth, int nVars, int iVar ) /**Function************************************************************* - Synopsis [Changes phase of the function w.r.t. one variable.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Extra_TruthCountOnes( unsigned * pTruth, int nVars ) -{ - int nWords = Extra_TruthWordNum( nVars ); - int i, Counter = 0; - for ( i = 0; i < nWords; i++ ) - Counter += Extra_WordCountOnes( pTruth[i] ); - return Counter; -} - -/**Function************************************************************* - Synopsis [Computes minimum overlap in supports of cofactors.] Description [] |