abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mioParse.c File Reference
#include "mioInt.h"
#include "exp.h"

Go to the source code of this file.

Macros

#define MIO_EQN_SYM_OPEN   '('
 DECLARATIONS ///. More...
 
#define MIO_EQN_SYM_CLOSE   ')'
 
#define MIO_EQN_SYM_CONST0   '0'
 
#define MIO_EQN_SYM_CONST1   '1'
 
#define MIO_EQN_SYM_NEG   '!'
 
#define MIO_EQN_SYM_NEGAFT   '\''
 
#define MIO_EQN_SYM_AND   '*'
 
#define MIO_EQN_SYM_AND2   '&'
 
#define MIO_EQN_SYM_XOR   '^'
 
#define MIO_EQN_SYM_OR   '+'
 
#define MIO_EQN_SYM_OR2   '|'
 
#define MIO_EQN_OPER_NEG   10
 
#define MIO_EQN_OPER_AND   9
 
#define MIO_EQN_OPER_XOR   8
 
#define MIO_EQN_OPER_OR   7
 
#define MIO_EQN_OPER_MARK   1
 
#define MIO_EQN_FLAG_START   1
 
#define MIO_EQN_FLAG_VAR   2
 
#define MIO_EQN_FLAG_OPER   3
 
#define MIO_EQN_FLAG_ERROR   4
 

Functions

Vec_Int_tMio_ParseFormulaOper (int *pMan, int nVars, Vec_Ptr_t *pStackFn, int Oper)
 FUNCTION DEFINITIONS ///. More...
 
Vec_Int_tMio_ParseFormula (char *pFormInit, char **ppVarNames, int nVars)
 
Vec_Wrd_tMio_ParseFormulaTruth (char *pFormInit, char **ppVarNames, int nVars)
 
void Mio_ParseFormulaTruthTest (char *pFormInit, char **ppVarNames, int nVars)
 
int Mio_ParseCheckName (Mio_Gate_t *pGate, char **ppStr)
 
int Mio_ParseCheckFormula (Mio_Gate_t *pGate, char *pForm)
 

Macro Definition Documentation

#define MIO_EQN_FLAG_ERROR   4

Definition at line 53 of file mioParse.c.

#define MIO_EQN_FLAG_OPER   3

Definition at line 52 of file mioParse.c.

#define MIO_EQN_FLAG_START   1

Definition at line 50 of file mioParse.c.

#define MIO_EQN_FLAG_VAR   2

Definition at line 51 of file mioParse.c.

#define MIO_EQN_OPER_AND   9

Definition at line 44 of file mioParse.c.

#define MIO_EQN_OPER_MARK   1

Definition at line 47 of file mioParse.c.

#define MIO_EQN_OPER_NEG   10

Definition at line 43 of file mioParse.c.

#define MIO_EQN_OPER_OR   7

Definition at line 46 of file mioParse.c.

#define MIO_EQN_OPER_XOR   8

Definition at line 45 of file mioParse.c.

#define MIO_EQN_SYM_AND   '*'

Definition at line 36 of file mioParse.c.

#define MIO_EQN_SYM_AND2   '&'

Definition at line 37 of file mioParse.c.

#define MIO_EQN_SYM_CLOSE   ')'

Definition at line 31 of file mioParse.c.

#define MIO_EQN_SYM_CONST0   '0'

Definition at line 32 of file mioParse.c.

#define MIO_EQN_SYM_CONST1   '1'

Definition at line 33 of file mioParse.c.

#define MIO_EQN_SYM_NEG   '!'

Definition at line 34 of file mioParse.c.

#define MIO_EQN_SYM_NEGAFT   '\''

Definition at line 35 of file mioParse.c.

#define MIO_EQN_SYM_OPEN   '('

DECLARATIONS ///.

CFile****************************************************************

FileName [mioParse.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [Parsing Boolean expressions.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 8, 2003.]

Revision [

Id:
mioParse.c,v 1.4 2004/06/28 14:20:25 alanmi Exp

]

Definition at line 30 of file mioParse.c.

#define MIO_EQN_SYM_OR   '+'

Definition at line 39 of file mioParse.c.

#define MIO_EQN_SYM_OR2   '|'

Definition at line 40 of file mioParse.c.

#define MIO_EQN_SYM_XOR   '^'

Definition at line 38 of file mioParse.c.

Function Documentation

int Mio_ParseCheckFormula ( Mio_Gate_t pGate,
char *  pForm 
)

Definition at line 444 of file mioParse.c.

445 {
446  Mio_Pin_t * pPin;
447  char * pStr;
448  int i, iPin, fVisit[32] = {0};
449  if ( Mio_GateReadPins(pGate) == NULL || !strcmp(Mio_PinReadName(Mio_GateReadPins(pGate)), "*") )
450  return 1;
451 /*
452  // find the equality sign
453  pForm = strstr( pForm, "=" );
454  if ( pForm == NULL )
455  {
456  printf( "Skipping gate \"%s\" because formula \"%s\" has not equality sign (=).\n", pGate->pName, pForm );
457  return 0;
458  }
459 */
460 //printf( "Checking gate %s\n", pGate->pName );
461 
462  for ( pStr = pForm; *pStr; pStr++ )
463  {
464  if ( *pStr == ' ' ||
465  *pStr == MIO_EQN_SYM_OPEN ||
466  *pStr == MIO_EQN_SYM_CLOSE ||
467  *pStr == MIO_EQN_SYM_CONST0 ||
468  *pStr == MIO_EQN_SYM_CONST1 ||
469  *pStr == MIO_EQN_SYM_NEG ||
470  *pStr == MIO_EQN_SYM_NEGAFT ||
471  *pStr == MIO_EQN_SYM_AND ||
472  *pStr == MIO_EQN_SYM_AND2 ||
473  *pStr == MIO_EQN_SYM_XOR ||
474  *pStr == MIO_EQN_SYM_OR ||
475  *pStr == MIO_EQN_SYM_OR2
476  )
477  continue;
478  // return the number of the pin which has this name
479  iPin = Mio_ParseCheckName( pGate, &pStr );
480  if ( iPin == -1 )
481  {
482  printf( "Skipping gate \"%s\" because substring \"%s\" does not match with a pin name.\n", pGate->pName, pStr );
483  return 0;
484  }
485  assert( iPin < 32 );
486  fVisit[iPin] = 1;
487  }
488  // check that all pins are used
489  for ( pPin = Mio_GateReadPins(pGate), i = 0; pPin; pPin = Mio_PinReadNext(pPin), i++ )
490  if ( fVisit[i] == 0 )
491  {
492 // printf( "Skipping gate \"%s\" because pin \"%s\" does not appear in the formula \"%s\".\n", pGate->pName, Mio_PinReadName(pPin), pForm );
493  return 0;
494  }
495  return 1;
496 }
#define MIO_EQN_SYM_XOR
Definition: mioParse.c:38
char * pName
Definition: mioInt.h:82
#define MIO_EQN_SYM_CONST1
Definition: mioParse.c:33
#define MIO_EQN_SYM_OR2
Definition: mioParse.c:40
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Definition: mioApi.c:147
#define MIO_EQN_SYM_OPEN
DECLARATIONS ///.
Definition: mioParse.c:30
char * Mio_PinReadName(Mio_Pin_t *pPin)
Definition: mioApi.c:170
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Definition: mioApi.c:179
#define MIO_EQN_SYM_OR
Definition: mioParse.c:39
#define MIO_EQN_SYM_CLOSE
Definition: mioParse.c:31
int strcmp()
#define MIO_EQN_SYM_CONST0
Definition: mioParse.c:32
#define MIO_EQN_SYM_AND
Definition: mioParse.c:36
int Mio_ParseCheckName(Mio_Gate_t *pGate, char **ppStr)
Definition: mioParse.c:429
#define MIO_EQN_SYM_AND2
Definition: mioParse.c:37
#define assert(ex)
Definition: util_old.h:213
#define MIO_EQN_SYM_NEGAFT
Definition: mioParse.c:35
#define MIO_EQN_SYM_NEG
Definition: mioParse.c:34
int Mio_ParseCheckName ( Mio_Gate_t pGate,
char **  ppStr 
)

Function*************************************************************

Synopsis [Checks if the gate's formula essentially depends on all variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 429 of file mioParse.c.

430 {
431  Mio_Pin_t * pPin;
432  int i, iBest = -1;
433  // find the longest pin name that matches substring
434  char * pNameBest = NULL;
435  for ( pPin = Mio_GateReadPins(pGate), i = 0; pPin; pPin = Mio_PinReadNext(pPin), i++ )
436  if ( !strncmp( *ppStr, Mio_PinReadName(pPin), strlen(Mio_PinReadName(pPin)) ) )
437  if ( pNameBest == NULL || strlen(pNameBest) < strlen(Mio_PinReadName(pPin)) )
438  pNameBest = Mio_PinReadName(pPin), iBest = i;
439  // if pin is not found, return -1
440  if ( pNameBest )
441  *ppStr += strlen(pNameBest) - 1;
442  return iBest;
443 }
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Definition: mioApi.c:147
char * Mio_PinReadName(Mio_Pin_t *pPin)
Definition: mioApi.c:170
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Definition: mioApi.c:179
int strncmp()
int strlen()
Vec_Int_t* Mio_ParseFormula ( char *  pFormInit,
char **  ppVarNames,
int  nVars 
)

Function*************************************************************

Synopsis [Derives the AIG corresponding to the equation.]

Description [Takes the stream to output messages, the formula, the vector of variable names and the AIG manager.]

SideEffects []

SeeAlso []

Definition at line 105 of file mioParse.c.

106 {
107  char * pFormula;
108  int Man = nVars, * pMan = &Man;
109  Vec_Ptr_t * pStackFn;
110  Vec_Int_t * pStackOp;
111  Vec_Int_t * gFunc;
112  char * pTemp, * pName;
113  int nParans, fFound, Flag;
114  int Oper, Oper1, Oper2;
115  int i, v;
116 
117  // make sure that the number of opening and closing parantheses is the same
118  nParans = 0;
119  for ( pTemp = pFormInit; *pTemp; pTemp++ )
120  if ( *pTemp == '(' )
121  nParans++;
122  else if ( *pTemp == ')' )
123  nParans--;
124  if ( nParans != 0 )
125  {
126  fprintf( stdout, "Mio_ParseFormula(): Different number of opening and closing parantheses ().\n" );
127  return NULL;
128  }
129 
130  // copy the formula
131  pFormula = ABC_ALLOC( char, strlen(pFormInit) + 3 );
132  sprintf( pFormula, "(%s)", pFormInit );
133 
134  // start the stacks
135  pStackFn = Vec_PtrAlloc( 100 );
136  pStackOp = Vec_IntAlloc( 100 );
137 
138  Flag = MIO_EQN_FLAG_START;
139  for ( pTemp = pFormula; *pTemp; pTemp++ )
140  {
141  switch ( *pTemp )
142  {
143  // skip all spaces, tabs, and end-of-lines
144  case ' ':
145  case '\t':
146  case '\r':
147  case '\n':
148  continue;
149  case MIO_EQN_SYM_CONST0:
150  Vec_PtrPush( pStackFn, Exp_Const0() ); // Cudd_Ref( b0 );
151  if ( Flag == MIO_EQN_FLAG_VAR )
152  {
153  fprintf( stdout, "Mio_ParseFormula(): No operation symbol before constant 0.\n" );
154  Flag = MIO_EQN_FLAG_ERROR;
155  break;
156  }
157  Flag = MIO_EQN_FLAG_VAR;
158  break;
159  case MIO_EQN_SYM_CONST1:
160  Vec_PtrPush( pStackFn, Exp_Const1() ); // Cudd_Ref( b1 );
161  if ( Flag == MIO_EQN_FLAG_VAR )
162  {
163  fprintf( stdout, "Mio_ParseFormula(): No operation symbol before constant 1.\n" );
164  Flag = MIO_EQN_FLAG_ERROR;
165  break;
166  }
167  Flag = MIO_EQN_FLAG_VAR;
168  break;
169  case MIO_EQN_SYM_NEG:
170  if ( Flag == MIO_EQN_FLAG_VAR )
171  {// if NEGBEF follows a variable, AND is assumed
172  Vec_IntPush( pStackOp, MIO_EQN_OPER_AND );
173  Flag = MIO_EQN_FLAG_OPER;
174  }
175  Vec_IntPush( pStackOp, MIO_EQN_OPER_NEG );
176  break;
177  case MIO_EQN_SYM_NEGAFT:
178  if ( Flag != MIO_EQN_FLAG_VAR )
179  {// if there is no variable before NEGAFT, it is an error
180  fprintf( stdout, "Mio_ParseFormula(): No variable is specified before the negation suffix.\n" );
181  Flag = MIO_EQN_FLAG_ERROR;
182  break;
183  }
184  else // if ( Flag == PARSE_FLAG_VAR )
185  Vec_PtrPush( pStackFn, Exp_Not( (Vec_Int_t *)Vec_PtrPop(pStackFn) ) );
186  break;
187  case MIO_EQN_SYM_AND:
188  case MIO_EQN_SYM_AND2:
189  case MIO_EQN_SYM_OR:
190  case MIO_EQN_SYM_OR2:
191  case MIO_EQN_SYM_XOR:
192  if ( Flag != MIO_EQN_FLAG_VAR )
193  {
194  fprintf( stdout, "Mio_ParseFormula(): There is no variable before AND, EXOR, or OR.\n" );
195  Flag = MIO_EQN_FLAG_ERROR;
196  break;
197  }
198  if ( *pTemp == MIO_EQN_SYM_AND || *pTemp == MIO_EQN_SYM_AND2 )
199  Vec_IntPush( pStackOp, MIO_EQN_OPER_AND );
200  else if ( *pTemp == MIO_EQN_SYM_OR || *pTemp == MIO_EQN_SYM_OR2 )
201  Vec_IntPush( pStackOp, MIO_EQN_OPER_OR );
202  else //if ( *pTemp == MIO_EQN_SYM_XOR )
203  Vec_IntPush( pStackOp, MIO_EQN_OPER_XOR );
204  Flag = MIO_EQN_FLAG_OPER;
205  break;
206  case MIO_EQN_SYM_OPEN:
207  if ( Flag == MIO_EQN_FLAG_VAR )
208  {
209  Vec_IntPush( pStackOp, MIO_EQN_OPER_AND );
210 // fprintf( stdout, "Mio_ParseFormula(): An opening paranthesis follows a var without operation sign.\n" );
211 // Flag = MIO_EQN_FLAG_ERROR;
212 // break;
213  }
214  Vec_IntPush( pStackOp, MIO_EQN_OPER_MARK );
215  // after an opening bracket, it feels like starting over again
216  Flag = MIO_EQN_FLAG_START;
217  break;
218  case MIO_EQN_SYM_CLOSE:
219  if ( Vec_IntSize( pStackOp ) != 0 )
220  {
221  while ( 1 )
222  {
223  if ( Vec_IntSize( pStackOp ) == 0 )
224  {
225  fprintf( stdout, "Mio_ParseFormula(): There is no opening paranthesis\n" );
226  Flag = MIO_EQN_FLAG_ERROR;
227  break;
228  }
229  Oper = Vec_IntPop( pStackOp );
230  if ( Oper == MIO_EQN_OPER_MARK )
231  break;
232 
233  // perform the given operation
234  if ( Mio_ParseFormulaOper( pMan, nVars, pStackFn, Oper ) == NULL )
235  {
236  fprintf( stdout, "Mio_ParseFormula(): Unknown operation\n" );
237  ABC_FREE( pFormula );
238  Vec_PtrFreeP( &pStackFn );
239  Vec_IntFreeP( &pStackOp );
240  return NULL;
241  }
242  }
243  }
244  else
245  {
246  fprintf( stdout, "Mio_ParseFormula(): There is no opening paranthesis\n" );
247  Flag = MIO_EQN_FLAG_ERROR;
248  break;
249  }
250  if ( Flag != MIO_EQN_FLAG_ERROR )
251  Flag = MIO_EQN_FLAG_VAR;
252  break;
253 
254 
255  default:
256  // scan the next name
257  for ( i = 0; pTemp[i] &&
258  pTemp[i] != ' ' && pTemp[i] != '\t' && pTemp[i] != '\r' && pTemp[i] != '\n' &&
259  pTemp[i] != MIO_EQN_SYM_AND && pTemp[i] != MIO_EQN_SYM_AND2 && pTemp[i] != MIO_EQN_SYM_OR && pTemp[i] != MIO_EQN_SYM_OR2 &&
260  pTemp[i] != MIO_EQN_SYM_XOR && pTemp[i] != MIO_EQN_SYM_NEGAFT && pTemp[i] != MIO_EQN_SYM_CLOSE;
261  i++ )
262  {
263  if ( pTemp[i] == MIO_EQN_SYM_NEG || pTemp[i] == MIO_EQN_SYM_OPEN )
264  {
265  fprintf( stdout, "Mio_ParseFormula(): The negation sign or an opening paranthesis inside the variable name.\n" );
266  Flag = MIO_EQN_FLAG_ERROR;
267  break;
268  }
269  }
270  // variable name is found
271  fFound = 0;
272 // Vec_PtrForEachEntry( char *, vVarNames, pName, v )
273  for ( v = 0; v < nVars; v++ )
274  {
275  pName = ppVarNames[v];
276  if ( strncmp(pTemp, pName, i) == 0 && strlen(pName) == (unsigned)i )
277  {
278  pTemp += i-1;
279  fFound = 1;
280  break;
281  }
282  }
283  if ( !fFound )
284  {
285  fprintf( stdout, "Mio_ParseFormula(): The parser cannot find var \"%s\" in the input var list.\n", pTemp );
286  Flag = MIO_EQN_FLAG_ERROR;
287  break;
288  }
289 /*
290  if ( Flag == MIO_EQN_FLAG_VAR )
291  {
292  fprintf( stdout, "Mio_ParseFormula(): The variable name \"%s\" follows another var without operation sign.\n", pTemp );
293  Flag = MIO_EQN_FLAG_ERROR;
294  break;
295  }
296 */
297  if ( Flag == MIO_EQN_FLAG_VAR )
298  Vec_IntPush( pStackOp, MIO_EQN_OPER_AND );
299 
300  Vec_PtrPush( pStackFn, Exp_Var(v) ); // Cudd_Ref( pbVars[v] );
301  Flag = MIO_EQN_FLAG_VAR;
302  break;
303  }
304 
305  if ( Flag == MIO_EQN_FLAG_ERROR )
306  break; // error exit
307  else if ( Flag == MIO_EQN_FLAG_START )
308  continue; // go on parsing
309  else if ( Flag == MIO_EQN_FLAG_VAR )
310  while ( 1 )
311  { // check if there are negations in the OpStack
312  if ( Vec_IntSize( pStackOp ) == 0 )
313  break;
314  Oper = Vec_IntPop( pStackOp );
315  if ( Oper != MIO_EQN_OPER_NEG )
316  {
317  Vec_IntPush( pStackOp, Oper );
318  break;
319  }
320  else
321  {
322  Vec_PtrPush( pStackFn, Exp_Not((Vec_Int_t *)Vec_PtrPop(pStackFn)) );
323  }
324  }
325  else // if ( Flag == MIO_EQN_FLAG_OPER )
326  while ( 1 )
327  { // execute all the operations in the OpStack
328  // with precedence higher or equal than the last one
329  Oper1 = Vec_IntPop( pStackOp ); // the last operation
330  if ( Vec_IntSize( pStackOp ) == 0 )
331  { // if it is the only operation, push it back
332  Vec_IntPush( pStackOp, Oper1 );
333  break;
334  }
335  Oper2 = Vec_IntPop( pStackOp ); // the operation before the last one
336  if ( Oper2 >= Oper1 )
337  { // if Oper2 precedence is higher or equal, execute it
338  if ( Mio_ParseFormulaOper( pMan, nVars, pStackFn, Oper2 ) == NULL )
339  {
340  fprintf( stdout, "Mio_ParseFormula(): Unknown operation\n" );
341  ABC_FREE( pFormula );
342  Vec_PtrFreeP( &pStackFn );
343  Vec_IntFreeP( &pStackOp );
344  return NULL;
345  }
346  Vec_IntPush( pStackOp, Oper1 ); // push the last operation back
347  }
348  else
349  { // if Oper2 precedence is lower, push them back and done
350  Vec_IntPush( pStackOp, Oper2 );
351  Vec_IntPush( pStackOp, Oper1 );
352  break;
353  }
354  }
355  }
356 
357  if ( Flag != MIO_EQN_FLAG_ERROR )
358  {
359  if ( Vec_PtrSize(pStackFn) != 0 )
360  {
361  gFunc = (Vec_Int_t *)Vec_PtrPop(pStackFn);
362  if ( Vec_PtrSize(pStackFn) == 0 )
363  if ( Vec_IntSize( pStackOp ) == 0 )
364  {
365 // Cudd_Deref( gFunc );
366  ABC_FREE( pFormula );
367  Vec_PtrFreeP( &pStackFn );
368  Vec_IntFreeP( &pStackOp );
369  return Exp_Reverse(gFunc);
370  }
371  else
372  fprintf( stdout, "Mio_ParseFormula(): Something is left in the operation stack\n" );
373  else
374  fprintf( stdout, "Mio_ParseFormula(): Something is left in the function stack\n" );
375  }
376  else
377  fprintf( stdout, "Mio_ParseFormula(): The input string is empty\n" );
378  }
379  ABC_FREE( pFormula );
380  Vec_PtrFreeP( &pStackFn );
381  Vec_IntFreeP( &pStackOp );
382  return NULL;
383 }
#define MIO_EQN_SYM_XOR
Definition: mioParse.c:38
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define MIO_EQN_SYM_CONST1
Definition: mioParse.c:33
static Vec_Int_t * Exp_Var(int iVar)
Definition: exp.h:72
#define MIO_EQN_SYM_OR2
Definition: mioParse.c:40
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define MIO_EQN_SYM_OPEN
DECLARATIONS ///.
Definition: mioParse.c:30
#define MIO_EQN_OPER_XOR
Definition: mioParse.c:45
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void * Vec_PtrPop(Vec_Ptr_t *p)
Definition: vecPtr.h:677
#define MIO_EQN_SYM_OR
Definition: mioParse.c:39
#define MIO_EQN_OPER_MARK
Definition: mioParse.c:47
#define MIO_EQN_SYM_CLOSE
Definition: mioParse.c:31
#define MIO_EQN_FLAG_ERROR
Definition: mioParse.c:53
static Vec_Int_t * Exp_Const0()
Definition: exp.h:46
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define MIO_EQN_SYM_CONST0
Definition: mioParse.c:32
static int Vec_IntPop(Vec_Int_t *p)
#define MIO_EQN_OPER_AND
Definition: mioParse.c:44
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
char * sprintf()
#define MIO_EQN_OPER_NEG
Definition: mioParse.c:43
#define MIO_EQN_SYM_AND
Definition: mioParse.c:36
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
static Vec_Int_t * Exp_Reverse(Vec_Int_t *p)
Definition: exp.h:124
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define MIO_EQN_FLAG_START
Definition: mioParse.c:50
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define MIO_EQN_FLAG_OPER
Definition: mioParse.c:52
#define MIO_EQN_FLAG_VAR
Definition: mioParse.c:51
int strncmp()
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
#define MIO_EQN_SYM_AND2
Definition: mioParse.c:37
int strlen()
static Vec_Int_t * Exp_Not(Vec_Int_t *p)
Definition: exp.h:93
#define MIO_EQN_SYM_NEGAFT
Definition: mioParse.c:35
Vec_Int_t * Mio_ParseFormulaOper(int *pMan, int nVars, Vec_Ptr_t *pStackFn, int Oper)
FUNCTION DEFINITIONS ///.
Definition: mioParse.c:70
static Vec_Int_t * Exp_Const1()
Definition: exp.h:53
#define MIO_EQN_SYM_NEG
Definition: mioParse.c:34
#define MIO_EQN_OPER_OR
Definition: mioParse.c:46
Vec_Int_t* Mio_ParseFormulaOper ( int *  pMan,
int  nVars,
Vec_Ptr_t pStackFn,
int  Oper 
)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Performs the operation on the top entries in the stack.]

Description []

SideEffects []

SeeAlso []

Definition at line 70 of file mioParse.c.

71 {
72  Vec_Int_t * gArg1, * gArg2, * gFunc;
73  // perform the given operation
74  gArg2 = (Vec_Int_t *)Vec_PtrPop( pStackFn );
75  gArg1 = (Vec_Int_t *)Vec_PtrPop( pStackFn );
76  if ( Oper == MIO_EQN_OPER_AND )
77  gFunc = Exp_And( pMan, nVars, gArg1, gArg2, 0, 0 );
78  else if ( Oper == MIO_EQN_OPER_OR )
79  gFunc = Exp_Or( pMan, nVars, gArg1, gArg2 );
80  else if ( Oper == MIO_EQN_OPER_XOR )
81  gFunc = Exp_Xor( pMan, nVars, gArg1, gArg2 );
82  else
83  return NULL;
84 // Cudd_Ref( gFunc );
85 // Cudd_RecursiveDeref( dd, gArg1 );
86 // Cudd_RecursiveDeref( dd, gArg2 );
87  Vec_IntFree( gArg1 );
88  Vec_IntFree( gArg2 );
89  Vec_PtrPush( pStackFn, gFunc );
90  return gFunc;
91 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define MIO_EQN_OPER_XOR
Definition: mioParse.c:45
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static void * Vec_PtrPop(Vec_Ptr_t *p)
Definition: vecPtr.h:677
static Vec_Int_t * Exp_Or(int *pMan, int nVars, Vec_Int_t *p0, Vec_Int_t *p1)
Definition: exp.h:150
static Vec_Int_t * Exp_And(int *pMan, int nVars, Vec_Int_t *p0, Vec_Int_t *p1, int fCompl0, int fCompl1)
Definition: exp.h:135
static Vec_Int_t * Exp_Xor(int *pMan, int nVars, Vec_Int_t *p0, Vec_Int_t *p1)
Definition: exp.h:154
#define MIO_EQN_OPER_AND
Definition: mioParse.c:44
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define MIO_EQN_OPER_OR
Definition: mioParse.c:46
Vec_Wrd_t* Mio_ParseFormulaTruth ( char *  pFormInit,
char **  ppVarNames,
int  nVars 
)

Function*************************************************************

Synopsis [Derives the TT corresponding to the equation.]

Description []

SideEffects []

SeeAlso []

Definition at line 396 of file mioParse.c.

397 {
398  Vec_Int_t * vExpr;
399  Vec_Wrd_t * vTruth;
400  // derive expression
401  vExpr = Mio_ParseFormula( pFormInit, ppVarNames, nVars );
402  if ( vExpr == NULL )
403  return NULL;
404  // convert it into a truth table
405  vTruth = Vec_WrdStart( Abc_Truth6WordNum(nVars) );
406  Exp_Truth( nVars, vExpr, Vec_WrdArray(vTruth) );
407  Vec_IntFree( vExpr );
408  return vTruth;
409 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Int_t * Mio_ParseFormula(char *pFormInit, char **ppVarNames, int nVars)
Definition: mioParse.c:105
static int Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
static void Exp_Truth(int nVars, Vec_Int_t *p, word *pRes)
Definition: exp.h:221
static word * Vec_WrdArray(Vec_Wrd_t *p)
Definition: vecWrd.h:316
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
void Mio_ParseFormulaTruthTest ( char *  pFormInit,
char **  ppVarNames,
int  nVars 
)

Definition at line 410 of file mioParse.c.

411 {
412  Vec_Wrd_t * vTruth;
413  vTruth = Mio_ParseFormulaTruth( pFormInit, ppVarNames, nVars );
414 // Kit_DsdPrintFromTruth( (unsigned *)Vec_WrdArray(vTruth), nVars ); printf( "\n" );
415  Vec_WrdFree( vTruth );
416 }
static void Vec_WrdFree(Vec_Wrd_t *p)
Definition: vecWrd.h:260
Vec_Wrd_t * Mio_ParseFormulaTruth(char *pFormInit, char **ppVarNames, int nVars)
Definition: mioParse.c:396
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42