31 #define VER_PARSE_SYM_OPEN '(' // opening paranthesis
32 #define VER_PARSE_SYM_CLOSE ')' // closing paranthesis
33 #define VER_PARSE_SYM_CONST0 '0' // constant 0
34 #define VER_PARSE_SYM_CONST1 '1' // constant 1
35 #define VER_PARSE_SYM_NEGBEF1 '!' // negation before the variable
36 #define VER_PARSE_SYM_NEGBEF2 '~' // negation before the variable
37 #define VER_PARSE_SYM_AND '&' // logic AND
38 #define VER_PARSE_SYM_OR '|' // logic OR
39 #define VER_PARSE_SYM_XOR '^' // logic XOR
40 #define VER_PARSE_SYM_MUX1 '?' // first symbol of MUX
41 #define VER_PARSE_SYM_MUX2 ':' // second symbol of MUX
44 #define VER_PARSE_OPER_NEG 7 // negation (highest precedence)
45 #define VER_PARSE_OPER_AND 6 // logic AND
46 #define VER_PARSE_OPER_XOR 5 // logic EXOR (a'b | ab')
47 #define VER_PARSE_OPER_OR 4 // logic OR
48 #define VER_PARSE_OPER_EQU 3 // equvalence (a'b'| ab )
49 #define VER_PARSE_OPER_MUX 2 // MUX(a,b,c) (ab | a'c )
50 #define VER_PARSE_OPER_MARK 1 // OpStack token standing for an opening paranthesis
53 #define VER_PARSE_FLAG_START 1 // after the opening parenthesis
54 #define VER_PARSE_FLAG_VAR 2 // after operation is received
55 #define VER_PARSE_FLAG_OPER 3 // after operation symbol is received
56 #define VER_PARSE_FLAG_ERROR 4 // when error is detected
81 int Oper, Oper1, Oper2;
89 if ( !
strcmp(pFormula,
"0") || !
strcmp(pFormula,
"1\'b0") )
91 if ( !
strcmp(pFormula,
"1") || !
strcmp(pFormula,
"1\'b1") )
96 for ( pTemp = pFormula; *pTemp; pTemp++ )
99 else if ( *pTemp ==
')' )
103 sprintf( pErrorMessage,
"Parse_FormulaParser(): Different number of opening and closing parantheses ()." );
108 pTemp = pFormula +
strlen(pFormula) + 2;
109 *pTemp-- = 0; *pTemp =
')';
110 while ( --pTemp != pFormula )
111 *pTemp = *(pTemp - 1);
116 for ( pTemp = pFormula; *pTemp; pTemp++ )
155 sprintf( pErrorMessage,
"Parse_FormulaParser(): Variable before negation." );
169 sprintf( pErrorMessage,
"Parse_FormulaParser(): There is no variable before AND, EXOR, or OR." );
189 sprintf( pErrorMessage,
"Parse_FormulaParser(): Variable before a paranthesis." );
205 sprintf( pErrorMessage,
"Parse_FormulaParser(): There is no opening paranthesis\n" );
222 sprintf( pErrorMessage,
"Parse_FormulaParser(): Unknown operation\n" );
229 sprintf( pErrorMessage,
"Parse_FormulaParser(): There is no opening paranthesis\n" );
241 if ( *pTemp ==
'\\' )
243 pTemp += (int)(ABC_PTRUINT_T)
Vec_PtrEntry( vNames, 2*v ) - 1;
248 sprintf( pErrorMessage,
"Parse_FormulaParser(): Incorrect state." );
293 sprintf( pErrorMessage,
"Parse_FormulaParser(): Unknown operation\n" );
319 sprintf( pErrorMessage,
"Parse_FormulaParser(): Something is left in the operation stack\n" );
321 sprintf( pErrorMessage,
"Parse_FormulaParser(): Something is left in the function stack\n" );
324 sprintf( pErrorMessage,
"Parse_FormulaParser(): The input string is empty\n" );
344 Hop_Obj_t * bArg0, * bArg1, * bArg2, * bFunc;
349 bFunc =
Hop_And( pMan, bArg1, bArg2 );
351 bFunc =
Hop_Exor( pMan, bArg1, bArg2 );
353 bFunc =
Hop_Or( pMan, bArg1, bArg2 );
360 bFunc =
Hop_Mux( pMan, bArg0, bArg1, bArg2 );
386 char * pTemp, * pTemp2;
387 int nLength, nLength2, i;
391 if ( *pTemp ==
'\\' )
394 while ( *pTemp && *pTemp !=
' ' )
399 while ( *pTemp && *pTemp !=
' ' && *pTemp !=
'\t' && *pTemp !=
'\r' && *pTemp !=
'\n' && *pTemp !=
',' && *pTemp !=
'}' &&
407 nLength = pTemp - pString;
410 nLength2 = (int)(ABC_PTRUINT_T)
Vec_PtrEntry( vNames, 2*i + 0 );
411 if ( nLength2 != nLength )
414 if (
strncmp( pString, pTemp2, nLength ) )
419 Vec_PtrPush( vNames, (
void *)(ABC_PTRUINT_T)nLength );
442 Symbol = *pFormula++;
443 fCompl = ( Symbol ==
'~' );
445 Symbol = *pFormula++;
447 if ( Symbol !=
'&' && Symbol !=
'|' && Symbol !=
'^' )
449 sprintf( pErrorMessage,
"Ver_FormulaReduction(): Unknown operation (%c)\n", Symbol );
453 while ( *pFormula++ !=
'{' );
456 while ( *pFormula !=
'}' )
459 pFormula += (int)(ABC_PTRUINT_T)
Vec_PtrEntry( vNames, 2*v );
460 while ( *pFormula ==
' ' || *pFormula ==
',' )
466 else if ( Symbol ==
'|' )
468 else if ( Symbol ==
'^' )
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Hop_Obj_t * Hop_Or(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Hop_Obj_t * Hop_CreateExor(Hop_Man_t *p, int nVars)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
static int Vec_PtrSize(Vec_Ptr_t *p)
static void * Vec_PtrPop(Vec_Ptr_t *p)
static Hop_Obj_t * Hop_Not(Hop_Obj_t *p)
Hop_Obj_t * Hop_Mux(Hop_Man_t *p, Hop_Obj_t *pC, Hop_Obj_t *p1, Hop_Obj_t *p0)
Hop_Obj_t * Hop_Exor(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Hop_Obj_t * Hop_CreateAnd(Hop_Man_t *p, int nVars)
#define ABC_NAMESPACE_IMPL_END
static void Vec_IntPush(Vec_Int_t *p, int Entry)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Hop_Obj_t * Hop_CreateOr(Hop_Man_t *p, int nVars)
static int Vec_IntSize(Vec_Int_t *p)
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
static void Vec_PtrClear(Vec_Ptr_t *p)
static Hop_Obj_t * Hop_ManConst0(Hop_Man_t *p)
static void Vec_IntClear(Vec_Int_t *p)
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.