30 #define MIO_EQN_SYM_OPEN '(' // opening paranthesis
31 #define MIO_EQN_SYM_CLOSE ')' // closing paranthesis
32 #define MIO_EQN_SYM_CONST0 '0' // constant 0
33 #define MIO_EQN_SYM_CONST1 '1' // constant 1
34 #define MIO_EQN_SYM_NEG '!' // negation before the variable
35 #define MIO_EQN_SYM_NEGAFT '\'' // negation after the variable
36 #define MIO_EQN_SYM_AND '*' // logic AND
37 #define MIO_EQN_SYM_AND2 '&' // logic AND
38 #define MIO_EQN_SYM_XOR '^' // logic XOR
39 #define MIO_EQN_SYM_OR '+' // logic OR
40 #define MIO_EQN_SYM_OR2 '|' // logic OR
43 #define MIO_EQN_OPER_NEG 10 // negation
44 #define MIO_EQN_OPER_AND 9 // logic AND
45 #define MIO_EQN_OPER_XOR 8 // logic XOR
46 #define MIO_EQN_OPER_OR 7 // logic OR
47 #define MIO_EQN_OPER_MARK 1 // OpStack token standing for an opening paranthesis
50 #define MIO_EQN_FLAG_START 1 // after the opening parenthesis
51 #define MIO_EQN_FLAG_VAR 2 // after operation is received
52 #define MIO_EQN_FLAG_OPER 3 // after operation symbol is received
53 #define MIO_EQN_FLAG_ERROR 4 // when error is detected
77 gFunc =
Exp_And( pMan, nVars, gArg1, gArg2, 0, 0 );
79 gFunc =
Exp_Or( pMan, nVars, gArg1, gArg2 );
81 gFunc =
Exp_Xor( pMan, nVars, gArg1, gArg2 );
108 int Man = nVars, * pMan = &Man;
112 char * pTemp, * pName;
113 int nParans, fFound, Flag;
114 int Oper, Oper1, Oper2;
119 for ( pTemp = pFormInit; *pTemp; pTemp++ )
122 else if ( *pTemp ==
')' )
126 fprintf( stdout,
"Mio_ParseFormula(): Different number of opening and closing parantheses ().\n" );
132 sprintf( pFormula,
"(%s)", pFormInit );
139 for ( pTemp = pFormula; *pTemp; pTemp++ )
153 fprintf( stdout,
"Mio_ParseFormula(): No operation symbol before constant 0.\n" );
163 fprintf( stdout,
"Mio_ParseFormula(): No operation symbol before constant 1.\n" );
180 fprintf( stdout,
"Mio_ParseFormula(): No variable is specified before the negation suffix.\n" );
194 fprintf( stdout,
"Mio_ParseFormula(): There is no variable before AND, EXOR, or OR.\n" );
225 fprintf( stdout,
"Mio_ParseFormula(): There is no opening paranthesis\n" );
236 fprintf( stdout,
"Mio_ParseFormula(): Unknown operation\n" );
246 fprintf( stdout,
"Mio_ParseFormula(): There is no opening paranthesis\n" );
257 for ( i = 0; pTemp[i] &&
258 pTemp[i] !=
' ' && pTemp[i] !=
'\t' && pTemp[i] !=
'\r' && pTemp[i] !=
'\n' &&
265 fprintf( stdout,
"Mio_ParseFormula(): The negation sign or an opening paranthesis inside the variable name.\n" );
273 for ( v = 0; v < nVars; v++ )
275 pName = ppVarNames[v];
276 if (
strncmp(pTemp, pName, i) == 0 &&
strlen(pName) == (
unsigned)i )
285 fprintf( stdout,
"Mio_ParseFormula(): The parser cannot find var \"%s\" in the input var list.\n", pTemp );
336 if ( Oper2 >= Oper1 )
340 fprintf( stdout,
"Mio_ParseFormula(): Unknown operation\n" );
372 fprintf( stdout,
"Mio_ParseFormula(): Something is left in the operation stack\n" );
374 fprintf( stdout,
"Mio_ParseFormula(): Something is left in the function stack\n" );
377 fprintf( stdout,
"Mio_ParseFormula(): The input string is empty\n" );
434 char * pNameBest = NULL;
441 *ppStr +=
strlen(pNameBest) - 1;
448 int i, iPin, fVisit[32] = {0};
462 for ( pStr = pForm; *pStr; pStr++ )
482 printf(
"Skipping gate \"%s\" because substring \"%s\" does not match with a pin name.\n", pGate->
pName, pStr );
490 if ( fVisit[i] == 0 )
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define MIO_EQN_SYM_CONST1
static Vec_Int_t * Exp_Var(int iVar)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
int Mio_ParseCheckFormula(Mio_Gate_t *pGate, char *pForm)
Vec_Int_t * Mio_ParseFormula(char *pFormInit, char **ppVarNames, int nVars)
static int Abc_Truth6WordNum(int nVars)
#define MIO_EQN_SYM_OPEN
DECLARATIONS ///.
void Mio_ParseFormulaTruthTest(char *pFormInit, char **ppVarNames, int nVars)
char * Mio_PinReadName(Mio_Pin_t *pPin)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
#define ABC_ALLOC(type, num)
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
static int Vec_PtrSize(Vec_Ptr_t *p)
static void * Vec_PtrPop(Vec_Ptr_t *p)
#define MIO_EQN_OPER_MARK
#define MIO_EQN_SYM_CLOSE
#define MIO_EQN_FLAG_ERROR
static Vec_Int_t * Exp_Or(int *pMan, int nVars, Vec_Int_t *p0, Vec_Int_t *p1)
static Vec_Int_t * Exp_And(int *pMan, int nVars, Vec_Int_t *p0, Vec_Int_t *p1, int fCompl0, int fCompl1)
static Vec_Int_t * Exp_Const0()
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static Vec_Int_t * Exp_Xor(int *pMan, int nVars, Vec_Int_t *p0, Vec_Int_t *p1)
#define MIO_EQN_SYM_CONST0
#define ABC_NAMESPACE_IMPL_END
static void Vec_WrdFree(Vec_Wrd_t *p)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static void Vec_IntFreeP(Vec_Int_t **p)
#define ABC_NAMESPACE_IMPL_START
static Vec_Wrd_t * Vec_WrdStart(int nSize)
static void Exp_Truth(int nVars, Vec_Int_t *p, word *pRes)
static Vec_Int_t * Exp_Reverse(Vec_Int_t *p)
static int Vec_IntSize(Vec_Int_t *p)
#define MIO_EQN_FLAG_START
int Mio_ParseCheckName(Mio_Gate_t *pGate, char **ppStr)
static word * Vec_WrdArray(Vec_Wrd_t *p)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
#define MIO_EQN_FLAG_OPER
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Vec_Wrd_t * Mio_ParseFormulaTruth(char *pFormInit, char **ppVarNames, int nVars)
static Vec_Int_t * Exp_Not(Vec_Int_t *p)
#define MIO_EQN_SYM_NEGAFT
Vec_Int_t * Mio_ParseFormulaOper(int *pMan, int nVars, Vec_Ptr_t *pStackFn, int Oper)
FUNCTION DEFINITIONS ///.
static void Vec_IntFree(Vec_Int_t *p)
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
static Vec_Int_t * Exp_Const1()