From dcb7d0d3fcf7f8736031b6966e47d71efe79450f Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 12 Sep 2014 13:40:48 -0700 Subject: New word-level representation package. --- src/misc/util/utilTruth.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/misc/util') 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************************************************************* -- cgit v1.2.3