diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2014-09-12 13:40:48 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2014-09-12 13:40:48 -0700 |
commit | dcb7d0d3fcf7f8736031b6966e47d71efe79450f (patch) | |
tree | 0982ed27132f7e04edc400b0b912c25312471b6c /src/misc | |
parent | ae7e286213a03babd7db9ff155f702999bf60b0d (diff) | |
download | abc-dcb7d0d3fcf7f8736031b6966e47d71efe79450f.tar.gz abc-dcb7d0d3fcf7f8736031b6966e47d71efe79450f.tar.bz2 abc-dcb7d0d3fcf7f8736031b6966e47d71efe79450f.zip |
New word-level representation package.
Diffstat (limited to 'src/misc')
-rw-r--r-- | src/misc/util/utilTruth.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/misc/util/utilTruth.h b/src/misc/util/utilTruth.h index ee1784fb..8468ffcc 100644 --- a/src/misc/util/utilTruth.h +++ b/src/misc/util/utilTruth.h @@ -732,6 +732,13 @@ static inline char Abc_TtPrintDigit( int Digit ) return '0' + Digit; return 'A' + Digit-10; } +static inline char Abc_TtPrintDigitLower( int Digit ) +{ + assert( Digit >= 0 && Digit < 16 ); + if ( Digit < 10 ) + return '0' + Digit; + return 'a' + Digit-10; +} static inline int Abc_TtReadHexDigit( char HexChar ) { if ( HexChar >= '0' && HexChar <= '9' ) @@ -796,6 +803,12 @@ static inline int Abc_TtWriteHexRev( char * pStr, word * pTruth, int nVars ) *pStr++ = Abc_TtPrintDigit( (int)(pThis[0] >> (k << 2)) & 15 ); return pStr - pStrInit; } +static inline void Abc_TtPrintHexArrayRev( FILE * pFile, word * pTruth, int nDigits ) +{ + int k; + for ( k = nDigits - 1; k >= 0; k-- ) + fprintf( pFile, "%c", Abc_TtPrintDigitLower( Abc_TtGetHex(pTruth, k) ) ); +} /**Function************************************************************* @@ -848,6 +861,22 @@ static inline int Abc_TtReadHex( word * pTruth, char * pString ) pTruth[0] = Abc_Tt6Stretch( pTruth[0], nVars ); return nVars; } +static inline int Abc_TtReadHexNumber( word * pTruth, char * pString ) +{ + // count the number of hex digits + int k, Digit, nDigits = 0; + for ( k = 0; Abc_TtIsHexDigit(pString[k]); k++ ) + nDigits++; + // read hexadecimal digits in the reverse order + // (the last symbol in the string is the least significant digit) + for ( k = 0; k < nDigits; k++ ) + { + Digit = Abc_TtReadHexDigit( pString[nDigits - 1 - k] ); + assert( Digit >= 0 && Digit < 16 ); + Abc_TtSetHex( pTruth, k, Digit ); + } + return nDigits; +} /**Function************************************************************* |