33 #define AMAP_EQN_SYM_OPEN '(' // opening paranthesis
34 #define AMAP_EQN_SYM_CLOSE ')' // closing paranthesis
35 #define AMAP_EQN_SYM_CONST0 '0' // constant 0
36 #define AMAP_EQN_SYM_CONST1 '1' // constant 1
37 #define AMAP_EQN_SYM_NEG '!' // negation before the variable
38 #define AMAP_EQN_SYM_NEGAFT '\'' // negation after the variable
39 #define AMAP_EQN_SYM_AND '*' // logic AND
40 #define AMAP_EQN_SYM_AND2 '&' // logic AND
41 #define AMAP_EQN_SYM_XOR '^' // logic XOR
42 #define AMAP_EQN_SYM_OR '+' // logic OR
43 #define AMAP_EQN_SYM_OR2 '|' // logic OR
46 #define AMAP_EQN_OPER_NEG 10 // negation
47 #define AMAP_EQN_OPER_AND 9 // logic AND
48 #define AMAP_EQN_OPER_XOR 8 // logic XOR
49 #define AMAP_EQN_OPER_OR 7 // logic OR
50 #define AMAP_EQN_OPER_MARK 1 // OpStack token standing for an opening paranthesis
53 #define AMAP_EQN_FLAG_START 1 // after the opening parenthesis
54 #define AMAP_EQN_FLAG_VAR 2 // after operation is received
55 #define AMAP_EQN_FLAG_OPER 3 // after operation symbol is received
56 #define AMAP_EQN_FLAG_ERROR 4 // when error is detected
80 gFunc =
Hop_And( pMan, gArg1, gArg2 );
82 gFunc =
Hop_Or( pMan, gArg1, gArg2 );
84 gFunc =
Hop_Exor( pMan, gArg1, gArg2 );
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( pOutput,
"Amap_ParseFormula(): Different number of opening and closing parantheses ().\n" );
132 sprintf( pFormula,
"(%s)", pFormInit );
139 for ( pTemp = pFormula; *pTemp; pTemp++ )
153 fprintf( pOutput,
"Amap_ParseFormula(): No operation symbol before constant 0.\n" );
163 fprintf( pOutput,
"Amap_ParseFormula(): No operation symbol before constant 1.\n" );
180 fprintf( pOutput,
"Amap_ParseFormula(): No variable is specified before the negation suffix.\n" );
194 fprintf( pOutput,
"Amap_ParseFormula(): There is no variable before AND, EXOR, or OR.\n" );
225 fprintf( pOutput,
"Amap_ParseFormula(): There is no opening paranthesis\n" );
236 fprintf( pOutput,
"Amap_ParseFormula(): Unknown operation\n" );
246 fprintf( pOutput,
"Amap_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( pOutput,
"Amap_ParseFormula(): The negation sign or an opening paranthesis inside the variable name.\n" );
273 if (
strncmp(pTemp, pName, i) == 0 &&
strlen(pName) == (
unsigned)i )
281 fprintf( pOutput,
"Amap_ParseFormula(): The parser cannot find var \"%s\" in the input var list.\n", pTemp );
332 if ( Oper2 >= Oper1 )
336 fprintf( pOutput,
"Amap_ParseFormula(): Unknown operation\n" );
368 fprintf( pOutput,
"Amap_ParseFormula(): Something is left in the operation stack\n" );
370 fprintf( pOutput,
"Amap_ParseFormula(): Something is left in the function stack\n" );
373 fprintf( pOutput,
"Amap_ParseFormula(): The input string is empty\n" );
405 printf(
"Gates with more than %d inputs will be ignored.\n",
AMAP_MAXINS );
412 if ( pGate->
nPins == 0 )
418 pGate->
pFunc[0] = ~0;
421 printf(
"Cannot parse formula \"%s\" of gate \"%s\" with no pins.\n", pGate->
pForm, pGate->
pName );
438 printf(
"Skipping gate \"%s\" because its output \"%s\" does not depend on all input variables.\n", pGate->
pName, pGate->
pForm );
#define AMAP_EQN_SYM_OPEN
DECLARATIONS ///.
int Amap_LibNumPinsMax(Amap_Lib_t *p)
Amap_Lib_t * Amap_LibReadFile(char *pFileName, int fVerbose)
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)
#define AMAP_EQN_FLAG_VAR
#define AMAP_EQN_SYM_AND2
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
#define Amap_GateForEachPin(pGate, pPin)
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 ///.
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
#define ABC_ALLOC(type, num)
static int Abc_TruthWordNum(int nVars)
static abctime Abc_Clock()
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 * Amap_ParseFormulaOper(Hop_Man_t *pMan, Vec_Ptr_t *pStackFn, int Oper)
FUNCTION DEFINITIONS ///.
#define AMAP_EQN_FLAG_ERROR
Hop_Obj_t * Hop_Exor(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
void Hop_ManStop(Hop_Man_t *p)
#define AMAP_STRING_CONST0
Hop_Obj_t * Amap_ParseFormula(FILE *pOutput, char *pFormInit, Vec_Ptr_t *vVarNames, Hop_Man_t *pMan)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
#define AMAP_EQN_OPER_NEG
#define AMAP_STRING_CONST1
#define AMAP_EQN_FLAG_OPER
#define AMAP_EQN_SYM_CONST1
void Amap_LibFree(Amap_Lib_t *p)
#define AMAP_MAXINS
INCLUDES ///.
#define AMAP_EQN_OPER_MARK
#define ABC_NAMESPACE_IMPL_END
#define AMAP_EQN_FLAG_START
Hop_Man_t * Hop_ManStart()
DECLARATIONS ///.
static void Vec_IntPush(Vec_Int_t *p, int Entry)
#define AMAP_EQN_SYM_NEGAFT
static void Vec_IntFreeP(Vec_Int_t **p)
#define AMAP_EQN_OPER_AND
#define ABC_NAMESPACE_IMPL_START
static int Vec_IntSize(Vec_Int_t *p)
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
void Amap_LibParseTest(char *pFileName)
#define AMAP_EQN_SYM_CONST0
static void Vec_PtrFreeP(Vec_Ptr_t **p)
int Amap_LibParseEquations(Amap_Lib_t *p, int fVerbose)
unsigned * Hop_ManConvertAigToTruth(Hop_Man_t *p, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, int fMsbFirst)
static void Vec_PtrClear(Vec_Ptr_t *p)
static Hop_Obj_t * Hop_ManConst0(Hop_Man_t *p)
#define AMAP_EQN_SYM_CLOSE
static void Vec_IntFree(Vec_Int_t *p)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
#define AMAP_EQN_OPER_XOR
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 ///.
int Kit_TruthSupportSize(unsigned *pTruth, int nVars)
static void Vec_PtrFree(Vec_Ptr_t *p)