abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cuddBddAbs.c File Reference
#include "misc/util/util_hack.h"
#include "cuddInt.h"

Go to the source code of this file.

Functions

static int bddCheckPositiveCube (DdManager *manager, DdNode *cube)
 
DdNodeCudd_bddExistAbstract (DdManager *manager, DdNode *f, DdNode *cube)
 
DdNodeCudd_bddXorExistAbstract (DdManager *manager, DdNode *f, DdNode *g, DdNode *cube)
 
DdNodeCudd_bddUnivAbstract (DdManager *manager, DdNode *f, DdNode *cube)
 
DdNodeCudd_bddBooleanDiff (DdManager *manager, DdNode *f, int x)
 
int Cudd_bddVarIsDependent (DdManager *dd, DdNode *f, DdNode *var)
 
DdNodecuddBddExistAbstractRecur (DdManager *manager, DdNode *f, DdNode *cube)
 
DdNodecuddBddXorExistAbstractRecur (DdManager *manager, DdNode *f, DdNode *g, DdNode *cube)
 
DdNodecuddBddBooleanDiffRecur (DdManager *manager, DdNode *f, DdNode *var)
 

Variables

static
ABC_NAMESPACE_IMPL_START char
rcsid[] 
DD_UNUSED = "$Id: cuddBddAbs.c,v 1.26 2004/08/13 18:04:46 fabio Exp $"
 

Function Documentation

static int bddCheckPositiveCube ( DdManager manager,
DdNode cube 
)
static

AutomaticStart

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

Synopsis [Checks whether cube is an BDD representing the product of positive literals.]

Description [Returns 1 in case of success; 0 otherwise.]

SideEffects [None]

Definition at line 708 of file cuddBddAbs.c.

711 {
712  if (Cudd_IsComplement(cube)) return(0);
713  if (cube == DD_ONE(manager)) return(1);
714  if (cuddIsConstant(cube)) return(0);
715  if (cuddE(cube) == Cudd_Not(DD_ONE(manager))) {
716  return(bddCheckPositiveCube(manager, cuddT(cube)));
717  }
718  return(0);
719 
720 } /* end of bddCheckPositiveCube */
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddE(node)
Definition: cuddInt.h:652
static int bddCheckPositiveCube(DdManager *manager, DdNode *cube)
Definition: cuddBddAbs.c:708
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode* Cudd_bddBooleanDiff ( DdManager manager,
DdNode f,
int  x 
)

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

Synopsis [Computes the boolean difference of f with respect to x.]

Description [Computes the boolean difference of f with respect to the variable with index x. Returns the BDD of the boolean difference if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 246 of file cuddBddAbs.c.

250 {
251  DdNode *res, *var;
252 
253  /* If the variable is not currently in the manager, f cannot
254  ** depend on it.
255  */
256  if (x >= manager->size) return(Cudd_Not(DD_ONE(manager)));
257  var = manager->vars[x];
258 
259  do {
260  manager->reordered = 0;
261  res = cuddBddBooleanDiffRecur(manager, Cudd_Regular(f), var);
262  } while (manager->reordered == 1);
263 
264  return(res);
265 
266 } /* end of Cudd_bddBooleanDiff */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
int var(Lit p)
Definition: SolverTypes.h:62
#define Cudd_Regular(node)
Definition: cudd.h:397
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddBooleanDiffRecur(DdManager *manager, DdNode *f, DdNode *var)
Definition: cuddBddAbs.c:636
DdNode ** vars
Definition: cuddInt.h:390
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode* Cudd_bddExistAbstract ( DdManager manager,
DdNode f,
DdNode cube 
)

AutomaticEnd Function********************************************************************

Synopsis [Existentially abstracts all the variables in cube from f.]

Description [Existentially abstracts all the variables in cube from f. Returns the abstracted BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddUnivAbstract Cudd_addExistAbstract]

Definition at line 130 of file cuddBddAbs.c.

134 {
135  DdNode *res;
136 
137  if (bddCheckPositiveCube(manager, cube) == 0) {
138  (void) fprintf(manager->err,
139  "Error: Can only abstract positive cubes\n");
140  manager->errorCode = CUDD_INVALID_ARG;
141  return(NULL);
142  }
143 
144  do {
145  manager->reordered = 0;
146  res = cuddBddExistAbstractRecur(manager, f, cube);
147  } while (manager->reordered == 1);
148 
149  return(res);
150 
151 } /* end of Cudd_bddExistAbstract */
DdNode * cuddBddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddBddAbs.c:352
Definition: cudd.h:278
FILE * err
Definition: cuddInt.h:442
int reordered
Definition: cuddInt.h:409
static int bddCheckPositiveCube(DdManager *manager, DdNode *cube)
Definition: cuddBddAbs.c:708
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_bddUnivAbstract ( DdManager manager,
DdNode f,
DdNode cube 
)

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

Synopsis [Universally abstracts all the variables in cube from f.]

Description [Universally abstracts all the variables in cube from f. Returns the abstracted BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddExistAbstract Cudd_addUnivAbstract]

Definition at line 207 of file cuddBddAbs.c.

211 {
212  DdNode *res;
213 
214  if (bddCheckPositiveCube(manager, cube) == 0) {
215  (void) fprintf(manager->err,
216  "Error: Can only abstract positive cubes\n");
217  manager->errorCode = CUDD_INVALID_ARG;
218  return(NULL);
219  }
220 
221  do {
222  manager->reordered = 0;
223  res = cuddBddExistAbstractRecur(manager, Cudd_Not(f), cube);
224  } while (manager->reordered == 1);
225  if (res != NULL) res = Cudd_Not(res);
226 
227  return(res);
228 
229 } /* end of Cudd_bddUnivAbstract */
DdNode * cuddBddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddBddAbs.c:352
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
FILE * err
Definition: cuddInt.h:442
int reordered
Definition: cuddInt.h:409
static int bddCheckPositiveCube(DdManager *manager, DdNode *cube)
Definition: cuddBddAbs.c:708
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_bddVarIsDependent ( DdManager dd,
DdNode f,
DdNode var 
)

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

Synopsis [Checks whether a variable is dependent on others in a function.]

Description [Checks whether a variable is dependent on others in a function. Returns 1 if the variable is dependent; 0 otherwise. No new nodes are created.]

SideEffects [None]

SeeAlso []

Definition at line 284 of file cuddBddAbs.c.

288 {
289  DdNode *F, *res, *zero, *ft, *fe;
290  unsigned topf, level;
291  DD_CTFP cacheOp;
292  int retval;
293 
294  zero = Cudd_Not(DD_ONE(dd));
295  if (Cudd_IsConstant(f)) return(f == zero);
296 
297  /* From now on f is not constant. */
298  F = Cudd_Regular(f);
299  topf = (unsigned) dd->perm[F->index];
300  level = (unsigned) dd->perm[var->index];
301 
302  /* Check terminal case. If topf > index of var, f does not depend on var.
303  ** Therefore, var is not dependent in f. */
304  if (topf > level) {
305  return(0);
306  }
307 
308  cacheOp = (DD_CTFP) Cudd_bddVarIsDependent;
309  res = cuddCacheLookup2(dd,cacheOp,f,var);
310  if (res != NULL) {
311  return(res != zero);
312  }
313 
314  /* Compute cofactors. */
315  ft = Cudd_NotCond(cuddT(F), f != F);
316  fe = Cudd_NotCond(cuddE(F), f != F);
317 
318  if (topf == level) {
319  retval = Cudd_bddLeq(dd,ft,Cudd_Not(fe));
320  } else {
321  retval = Cudd_bddVarIsDependent(dd,ft,var) &&
322  Cudd_bddVarIsDependent(dd,fe,var);
323  }
324 
325  cuddCacheInsert2(dd,cacheOp,f,var,Cudd_NotCond(zero,retval));
326 
327  return(retval);
328 
329 } /* Cudd_bddVarIsDependent */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define Cudd_Regular(node)
Definition: cudd.h:397
DdNode *(* DD_CTFP)(DdManager *, DdNode *, DdNode *)
Definition: cudd.h:321
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
int Cudd_bddVarIsDependent(DdManager *dd, DdNode *f, DdNode *var)
Definition: cuddBddAbs.c:284
#define cuddT(node)
Definition: cuddInt.h:636
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
#define DD_ONE(dd)
Definition: cuddInt.h:911
int * perm
Definition: cuddInt.h:386
static DdNode * zero
Definition: cuddApa.c:100
DdNode* Cudd_bddXorExistAbstract ( DdManager manager,
DdNode f,
DdNode g,
DdNode cube 
)

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

Synopsis [Takes the exclusive OR of two BDDs and simultaneously abstracts the variables in cube.]

Description [Takes the exclusive OR of two BDDs and simultaneously abstracts the variables in cube. The variables are existentially abstracted. Returns a pointer to the result is successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddUnivAbstract Cudd_bddExistAbstract Cudd_bddAndAbstract]

Definition at line 169 of file cuddBddAbs.c.

174 {
175  DdNode *res;
176 
177  if (bddCheckPositiveCube(manager, cube) == 0) {
178  (void) fprintf(manager->err,
179  "Error: Can only abstract positive cubes\n");
180  manager->errorCode = CUDD_INVALID_ARG;
181  return(NULL);
182  }
183 
184  do {
185  manager->reordered = 0;
186  res = cuddBddXorExistAbstractRecur(manager, f, g, cube);
187  } while (manager->reordered == 1);
188 
189  return(res);
190 
191 } /* end of Cudd_bddXorExistAbstract */
Definition: cudd.h:278
FILE * err
Definition: cuddInt.h:442
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddXorExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube)
Definition: cuddBddAbs.c:464
static int bddCheckPositiveCube(DdManager *manager, DdNode *cube)
Definition: cuddBddAbs.c:708
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* cuddBddBooleanDiffRecur ( DdManager manager,
DdNode f,
DdNode var 
)

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

Synopsis [Performs the recursive steps of Cudd_bddBoleanDiff.]

Description [Performs the recursive steps of Cudd_bddBoleanDiff. Returns the BDD obtained by XORing the cofactors of f with respect to var if successful; NULL otherwise. Exploits the fact that dF/dx = dF'/dx.]

SideEffects [None]

SeeAlso []

Definition at line 636 of file cuddBddAbs.c.

640 {
641  DdNode *T, *E, *res, *res1, *res2;
642 
643  statLine(manager);
644  if (cuddI(manager,f->index) > manager->perm[var->index]) {
645  /* f does not depend on var. */
646  return(Cudd_Not(DD_ONE(manager)));
647  }
648 
649  /* From now on, f is non-constant. */
650 
651  /* If the two indices are the same, so are their levels. */
652  if (f->index == var->index) {
653  res = cuddBddXorRecur(manager, cuddT(f), cuddE(f));
654  return(res);
655  }
656 
657  /* From now on, cuddI(manager,f->index) < cuddI(manager,cube->index). */
658 
659  /* Check the cache. */
660  res = cuddCacheLookup2(manager, cuddBddBooleanDiffRecur, f, var);
661  if (res != NULL) {
662  return(res);
663  }
664 
665  /* Compute the cofactors of f. */
666  T = cuddT(f); E = cuddE(f);
667 
668  res1 = cuddBddBooleanDiffRecur(manager, T, var);
669  if (res1 == NULL) return(NULL);
670  cuddRef(res1);
671  res2 = cuddBddBooleanDiffRecur(manager, Cudd_Regular(E), var);
672  if (res2 == NULL) {
673  Cudd_IterDerefBdd(manager, res1);
674  return(NULL);
675  }
676  cuddRef(res2);
677  /* ITE takes care of possible complementation of res1 and of the
678  ** case in which res1 == res2. */
679  res = cuddBddIteRecur(manager, manager->vars[f->index], res1, res2);
680  if (res == NULL) {
681  Cudd_IterDerefBdd(manager, res1);
682  Cudd_IterDerefBdd(manager, res2);
683  return(NULL);
684  }
685  cuddDeref(res1);
686  cuddDeref(res2);
687  cuddCacheInsert2(manager, cuddBddBooleanDiffRecur, f, var, res);
688  return(res);
689 
690 } /* end of cuddBddBooleanDiffRecur */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
#define Cudd_Regular(node)
Definition: cudd.h:397
#define statLine(dd)
Definition: cuddInt.h:1037
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
DdNode * cuddBddBooleanDiffRecur(DdManager *manager, DdNode *f, DdNode *var)
Definition: cuddBddAbs.c:636
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddI(dd, index)
Definition: cuddInt.h:686
DdHalfWord index
Definition: cudd.h:279
DdNode ** vars
Definition: cuddInt.h:390
DdNode * cuddBddXorRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:1017
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
int * perm
Definition: cuddInt.h:386
DdNode * cuddBddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:633
DdNode* cuddBddExistAbstractRecur ( DdManager manager,
DdNode f,
DdNode cube 
)

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

Synopsis [Performs the recursive steps of Cudd_bddExistAbstract.]

Description [Performs the recursive steps of Cudd_bddExistAbstract. Returns the BDD obtained by abstracting the variables of cube from f if successful; NULL otherwise. It is also used by Cudd_bddUnivAbstract.]

SideEffects [None]

SeeAlso [Cudd_bddExistAbstract Cudd_bddUnivAbstract]

Definition at line 352 of file cuddBddAbs.c.

356 {
357  DdNode *F, *T, *E, *res, *res1, *res2, *one;
358 
359  statLine(manager);
360  one = DD_ONE(manager);
361  F = Cudd_Regular(f);
362 
363  /* Cube is guaranteed to be a cube at this point. */
364  if (cube == one || F == one) {
365  return(f);
366  }
367  /* From now on, f and cube are non-constant. */
368 
369  /* Abstract a variable that does not appear in f. */
370  while (manager->perm[F->index] > manager->perm[cube->index]) {
371  cube = cuddT(cube);
372  if (cube == one) return(f);
373  }
374 
375  /* Check the cache. */
376  if (F->ref != 1 && (res = cuddCacheLookup2(manager, Cudd_bddExistAbstract, f, cube)) != NULL) {
377  return(res);
378  }
379 
380  /* Compute the cofactors of f. */
381  T = cuddT(F); E = cuddE(F);
382  if (f != F) {
383  T = Cudd_Not(T); E = Cudd_Not(E);
384  }
385 
386  /* If the two indices are the same, so are their levels. */
387  if (F->index == cube->index) {
388  if (T == one || E == one || T == Cudd_Not(E)) {
389  return(one);
390  }
391  res1 = cuddBddExistAbstractRecur(manager, T, cuddT(cube));
392  if (res1 == NULL) return(NULL);
393  if (res1 == one) {
394  if (F->ref != 1)
395  cuddCacheInsert2(manager, Cudd_bddExistAbstract, f, cube, one);
396  return(one);
397  }
398  cuddRef(res1);
399  res2 = cuddBddExistAbstractRecur(manager, E, cuddT(cube));
400  if (res2 == NULL) {
401  Cudd_IterDerefBdd(manager,res1);
402  return(NULL);
403  }
404  cuddRef(res2);
405  res = cuddBddAndRecur(manager, Cudd_Not(res1), Cudd_Not(res2));
406  if (res == NULL) {
407  Cudd_IterDerefBdd(manager, res1);
408  Cudd_IterDerefBdd(manager, res2);
409  return(NULL);
410  }
411  res = Cudd_Not(res);
412  cuddRef(res);
413  Cudd_IterDerefBdd(manager, res1);
414  Cudd_IterDerefBdd(manager, res2);
415  if (F->ref != 1)
416  cuddCacheInsert2(manager, Cudd_bddExistAbstract, f, cube, res);
417  cuddDeref(res);
418  return(res);
419  } else { /* if (cuddI(manager,F->index) < cuddI(manager,cube->index)) */
420  res1 = cuddBddExistAbstractRecur(manager, T, cube);
421  if (res1 == NULL) return(NULL);
422  cuddRef(res1);
423  res2 = cuddBddExistAbstractRecur(manager, E, cube);
424  if (res2 == NULL) {
425  Cudd_IterDerefBdd(manager, res1);
426  return(NULL);
427  }
428  cuddRef(res2);
429  /* ITE takes care of possible complementation of res1 and of the
430  ** case in which res1 == res2. */
431  res = cuddBddIteRecur(manager, manager->vars[F->index], res1, res2);
432  if (res == NULL) {
433  Cudd_IterDerefBdd(manager, res1);
434  Cudd_IterDerefBdd(manager, res2);
435  return(NULL);
436  }
437  cuddRef(res); //Added
438  Cudd_IterDerefBdd(manager, res1); //cuddDeref(res1);
439  Cudd_IterDerefBdd(manager, res2); //cuddDeref(res2);
440  cuddDeref(res); //Added
441  if (F->ref != 1)
442  cuddCacheInsert2(manager, Cudd_bddExistAbstract, f, cube, res);
443  return(res);
444  }
445 
446 } /* end of cuddBddExistAbstractRecur */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
DdHalfWord ref
Definition: cudd.h:280
DdNode * cuddBddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddBddAbs.c:352
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
#define Cudd_Regular(node)
Definition: cudd.h:397
#define statLine(dd)
Definition: cuddInt.h:1037
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
static DdNode * one
Definition: cuddDecomp.c:112
#define cuddT(node)
Definition: cuddInt.h:636
DdNode * Cudd_bddExistAbstract(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddBddAbs.c:130
DdHalfWord index
Definition: cudd.h:279
DdNode ** vars
Definition: cuddInt.h:390
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
int * perm
Definition: cuddInt.h:386
DdNode * cuddBddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:633
DdNode* cuddBddXorExistAbstractRecur ( DdManager manager,
DdNode f,
DdNode g,
DdNode cube 
)

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

Synopsis [Takes the exclusive OR of two BDDs and simultaneously abstracts the variables in cube.]

Description [Takes the exclusive OR of two BDDs and simultaneously abstracts the variables in cube. The variables are existentially abstracted. Returns a pointer to the result is successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddAndAbstract]

Definition at line 464 of file cuddBddAbs.c.

469 {
470  DdNode *F, *fv, *fnv, *G, *gv, *gnv;
471  DdNode *one, *zero, *r, *t, *e, *Cube;
472  unsigned int topf, topg, topcube, top, index;
473 
474  statLine(manager);
475  one = DD_ONE(manager);
476  zero = Cudd_Not(one);
477 
478  /* Terminal cases. */
479  if (f == g) {
480  return(zero);
481  }
482  if (f == Cudd_Not(g)) {
483  return(one);
484  }
485  if (cube == one) {
486  return(cuddBddXorRecur(manager, f, g));
487  }
488  if (f == one) {
489  return(cuddBddExistAbstractRecur(manager, Cudd_Not(g), cube));
490  }
491  if (g == one) {
492  return(cuddBddExistAbstractRecur(manager, Cudd_Not(f), cube));
493  }
494  if (f == zero) {
495  return(cuddBddExistAbstractRecur(manager, g, cube));
496  }
497  if (g == zero) {
498  return(cuddBddExistAbstractRecur(manager, f, cube));
499  }
500 
501  /* At this point f, g, and cube are not constant. */
502 
503  if (cuddF2L(f) > cuddF2L(g)) { /* Try to increase cache efficiency. */
504  DdNode *tmp = f;
505  f = g;
506  g = tmp;
507  }
508 
509  /* Check cache. */
510  r = cuddCacheLookup(manager, DD_BDD_XOR_EXIST_ABSTRACT_TAG, f, g, cube);
511  if (r != NULL) {
512  return(r);
513  }
514 
515  /* Here we can skip the use of cuddI, because the operands are known
516  ** to be non-constant.
517  */
518  F = Cudd_Regular(f);
519  topf = manager->perm[F->index];
520  G = Cudd_Regular(g);
521  topg = manager->perm[G->index];
522  top = ddMin(topf, topg);
523  topcube = manager->perm[cube->index];
524 
525  if (topcube < top) {
526  return(cuddBddXorExistAbstractRecur(manager, f, g, cuddT(cube)));
527  }
528  /* Now, topcube >= top. */
529 
530  if (topf == top) {
531  index = F->index;
532  fv = cuddT(F);
533  fnv = cuddE(F);
534  if (Cudd_IsComplement(f)) {
535  fv = Cudd_Not(fv);
536  fnv = Cudd_Not(fnv);
537  }
538  } else {
539  index = G->index;
540  fv = fnv = f;
541  }
542 
543  if (topg == top) {
544  gv = cuddT(G);
545  gnv = cuddE(G);
546  if (Cudd_IsComplement(g)) {
547  gv = Cudd_Not(gv);
548  gnv = Cudd_Not(gnv);
549  }
550  } else {
551  gv = gnv = g;
552  }
553 
554  if (topcube == top) {
555  Cube = cuddT(cube);
556  } else {
557  Cube = cube;
558  }
559 
560  t = cuddBddXorExistAbstractRecur(manager, fv, gv, Cube);
561  if (t == NULL) return(NULL);
562 
563  /* Special case: 1 OR anything = 1. Hence, no need to compute
564  ** the else branch if t is 1.
565  */
566  if (t == one && topcube == top) {
567  cuddCacheInsert(manager, DD_BDD_XOR_EXIST_ABSTRACT_TAG, f, g, cube, one);
568  return(one);
569  }
570  cuddRef(t);
571 
572  e = cuddBddXorExistAbstractRecur(manager, fnv, gnv, Cube);
573  if (e == NULL) {
574  Cudd_IterDerefBdd(manager, t);
575  return(NULL);
576  }
577  cuddRef(e);
578 
579  if (topcube == top) { /* abstract */
580  r = cuddBddAndRecur(manager, Cudd_Not(t), Cudd_Not(e));
581  if (r == NULL) {
582  Cudd_IterDerefBdd(manager, t);
583  Cudd_IterDerefBdd(manager, e);
584  return(NULL);
585  }
586  r = Cudd_Not(r);
587  cuddRef(r);
588  Cudd_IterDerefBdd(manager, t);
589  Cudd_IterDerefBdd(manager, e);
590  cuddDeref(r);
591  } else if (t == e) {
592  r = t;
593  cuddDeref(t);
594  cuddDeref(e);
595  } else {
596  if (Cudd_IsComplement(t)) {
597  r = cuddUniqueInter(manager,(int)index,Cudd_Not(t),Cudd_Not(e));
598  if (r == NULL) {
599  Cudd_IterDerefBdd(manager, t);
600  Cudd_IterDerefBdd(manager, e);
601  return(NULL);
602  }
603  r = Cudd_Not(r);
604  } else {
605  r = cuddUniqueInter(manager,(int)index,t,e);
606  if (r == NULL) {
607  Cudd_IterDerefBdd(manager, t);
608  Cudd_IterDerefBdd(manager, e);
609  return(NULL);
610  }
611  }
612  cuddDeref(e);
613  cuddDeref(t);
614  }
615  cuddCacheInsert(manager, DD_BDD_XOR_EXIST_ABSTRACT_TAG, f, g, cube, r);
616  return (r);
617 
618 } /* end of cuddBddXorExistAbstractRecur */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
DdNode * cuddBddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddBddAbs.c:352
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_Regular(node)
Definition: cudd.h:397
void cuddCacheInsert(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h, DdNode *data)
Definition: cuddCache.c:222
#define statLine(dd)
Definition: cuddInt.h:1037
#define Cudd_IsComplement(node)
Definition: cudd.h:425
static DdNode * one
Definition: cuddDecomp.c:112
#define DD_BDD_XOR_EXIST_ABSTRACT_TAG
Definition: cuddInt.h:174
#define cuddF2L(f)
Definition: cuddInt.h:718
#define ddMin(x, y)
Definition: cuddInt.h:818
#define cuddT(node)
Definition: cuddInt.h:636
DdNode * cuddBddXorExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube)
Definition: cuddBddAbs.c:464
DdHalfWord index
Definition: cudd.h:279
DdNode * cuddBddXorRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:1017
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
int * perm
Definition: cuddInt.h:386
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
static DdNode * zero
Definition: cuddApa.c:100
DdNode * cuddCacheLookup(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddCache.c:369

Variable Documentation

ABC_NAMESPACE_IMPL_START char rcsid [] DD_UNUSED = "$Id: cuddBddAbs.c,v 1.26 2004/08/13 18:04:46 fabio Exp $"
static

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

FileName [cuddBddAbs.c]

PackageName [cudd]

Synopsis [Quantification functions for BDDs.]

Description [External procedures included in this module:

Internal procedures included in this module:

Static procedures included in this module:

]

Author [Fabio Somenzi]

Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of the University of Colorado nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.]

Definition at line 93 of file cuddBddAbs.c.