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

Go to the source code of this file.

Functions

static DdNodezdd_subset1_aux (DdManager *zdd, DdNode *P, DdNode *zvar)
 
static DdNodezdd_subset0_aux (DdManager *zdd, DdNode *P, DdNode *zvar)
 
static void zddVarToConst (DdNode *f, DdNode **gp, DdNode **hp, DdNode *base, DdNode *empty)
 
DdNodeCudd_zddIte (DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
 
DdNodeCudd_zddUnion (DdManager *dd, DdNode *P, DdNode *Q)
 
DdNodeCudd_zddIntersect (DdManager *dd, DdNode *P, DdNode *Q)
 
DdNodeCudd_zddDiff (DdManager *dd, DdNode *P, DdNode *Q)
 
DdNodeCudd_zddDiffConst (DdManager *zdd, DdNode *P, DdNode *Q)
 
DdNodeCudd_zddSubset1 (DdManager *dd, DdNode *P, int var)
 
DdNodeCudd_zddSubset0 (DdManager *dd, DdNode *P, int var)
 
DdNodeCudd_zddChange (DdManager *dd, DdNode *P, int var)
 
DdNodecuddZddIte (DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
 
DdNodecuddZddUnion (DdManager *zdd, DdNode *P, DdNode *Q)
 
DdNodecuddZddIntersect (DdManager *zdd, DdNode *P, DdNode *Q)
 
DdNodecuddZddDiff (DdManager *zdd, DdNode *P, DdNode *Q)
 
DdNodecuddZddChangeAux (DdManager *zdd, DdNode *P, DdNode *zvar)
 
DdNodecuddZddSubset1 (DdManager *dd, DdNode *P, int var)
 
DdNodecuddZddSubset0 (DdManager *dd, DdNode *P, int var)
 
DdNodecuddZddChange (DdManager *dd, DdNode *P, int var)
 

Variables

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

Function Documentation

DdNode* Cudd_zddChange ( DdManager dd,
DdNode P,
int  var 
)

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

Synopsis [Substitutes a variable with its complement in a ZDD.]

Description [Substitutes a variable with its complement in a ZDD. returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 392 of file cuddZddSetop.c.

396 {
397  DdNode *res;
398 
399  if ((unsigned int) var >= CUDD_MAXINDEX - 1) return(NULL);
400 
401  do {
402  dd->reordered = 0;
403  res = cuddZddChange(dd, P, var);
404  } while (dd->reordered == 1);
405  return(res);
406 
407 } /* end of Cudd_zddChange */
Definition: cudd.h:278
int var(Lit p)
Definition: SolverTypes.h:62
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddChange(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:971
#define CUDD_MAXINDEX
Definition: cudd.h:112
DdNode* Cudd_zddDiff ( DdManager dd,
DdNode P,
DdNode Q 
)

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

Synopsis [Computes the difference of two ZDDs.]

Description [Computes the difference of two ZDDs. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddDiffConst]

Definition at line 236 of file cuddZddSetop.c.

240 {
241  DdNode *res;
242 
243  do {
244  dd->reordered = 0;
245  res = cuddZddDiff(dd, P, Q);
246  } while (dd->reordered == 1);
247  return(res);
248 
249 } /* end of Cudd_zddDiff */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddDiff(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:717
DdNode* Cudd_zddDiffConst ( DdManager zdd,
DdNode P,
DdNode Q 
)

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

Synopsis [Performs the inclusion test for ZDDs (P implies Q).]

Description [Inclusion test for ZDDs (P implies Q). No new nodes are generated by this procedure. Returns empty if true; a valid pointer different from empty or DD_NON_CONSTANT otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddDiff]

Definition at line 266 of file cuddZddSetop.c.

270 {
271  int p_top, q_top;
272  DdNode *empty = DD_ZERO(zdd), *t, *res;
273  DdManager *table = zdd;
274 
275  statLine(zdd);
276  if (P == empty)
277  return(empty);
278  if (Q == empty)
279  return(P);
280  if (P == Q)
281  return(empty);
282 
283  /* Check cache. The cache is shared by cuddZddDiff(). */
284  res = cuddCacheLookup2Zdd(table, cuddZddDiff, P, Q);
285  if (res != NULL)
286  return(res);
287 
288  if (cuddIsConstant(P))
289  p_top = P->index;
290  else
291  p_top = zdd->permZ[P->index];
292  if (cuddIsConstant(Q))
293  q_top = Q->index;
294  else
295  q_top = zdd->permZ[Q->index];
296  if (p_top < q_top) {
297  res = DD_NON_CONSTANT;
298  } else if (p_top > q_top) {
299  res = Cudd_zddDiffConst(zdd, P, cuddE(Q));
300  } else {
301  t = Cudd_zddDiffConst(zdd, cuddT(P), cuddT(Q));
302  if (t != empty)
303  res = DD_NON_CONSTANT;
304  else
305  res = Cudd_zddDiffConst(zdd, cuddE(P), cuddE(Q));
306  }
307 
308  cuddCacheInsert2(table, cuddZddDiff, P, Q, res);
309 
310  return(res);
311 
312 } /* end of Cudd_zddDiffConst */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
Definition: cudd.h:278
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
int * permZ
Definition: cuddInt.h:387
#define statLine(dd)
Definition: cuddInt.h:1037
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdNode * Cudd_zddDiffConst(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:266
DdNode * cuddZddDiff(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:717
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_NON_CONSTANT
Definition: cuddInt.h:123
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_zddIntersect ( DdManager dd,
DdNode P,
DdNode Q 
)

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

Synopsis [Computes the intersection of two ZDDs.]

Description [Computes the intersection of two ZDDs. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 207 of file cuddZddSetop.c.

211 {
212  DdNode *res;
213 
214  do {
215  dd->reordered = 0;
216  res = cuddZddIntersect(dd, P, Q);
217  } while (dd->reordered == 1);
218  return(res);
219 
220 } /* end of Cudd_zddIntersect */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddIntersect(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:642
DdNode* Cudd_zddIte ( DdManager dd,
DdNode f,
DdNode g,
DdNode h 
)

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

Synopsis [Computes the ITE of three ZDDs.]

Description [Computes the ITE of three ZDDs. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 148 of file cuddZddSetop.c.

153 {
154  DdNode *res;
155 
156  do {
157  dd->reordered = 0;
158  res = cuddZddIte(dd, f, g, h);
159  } while (dd->reordered == 1);
160  return(res);
161 
162 } /* end of Cudd_zddIte */
DdNode * cuddZddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddZddSetop.c:427
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_zddSubset0 ( DdManager dd,
DdNode P,
int  var 
)

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

Synopsis [Computes the negative cofactor of a ZDD w.r.t. a variable.]

Description [Computes the negative cofactor of a ZDD w.r.t. a variable. In terms of combinations, the result is the set of all combinations in which the variable is negated. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddSubset1]

Definition at line 362 of file cuddZddSetop.c.

366 {
367  DdNode *r;
368 
369  do {
370  dd->reordered = 0;
371  r = cuddZddSubset0(dd, P, var);
372  } while (dd->reordered == 1);
373 
374  return(r);
375 
376 } /* end of Cudd_zddSubset0 */
Definition: cudd.h:278
int var(Lit p)
Definition: SolverTypes.h:62
DdNode * cuddZddSubset0(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:923
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_zddSubset1 ( DdManager dd,
DdNode P,
int  var 
)

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

Synopsis [Computes the positive cofactor of a ZDD w.r.t. a variable.]

Description [Computes the positive cofactor of a ZDD w.r.t. a variable. In terms of combinations, the result is the set of all combinations in which the variable is asserted. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddSubset0]

Definition at line 330 of file cuddZddSetop.c.

334 {
335  DdNode *r;
336 
337  do {
338  dd->reordered = 0;
339  r = cuddZddSubset1(dd, P, var);
340  } while (dd->reordered == 1);
341 
342  return(r);
343 
344 } /* end of Cudd_zddSubset1 */
Definition: cudd.h:278
int var(Lit p)
Definition: SolverTypes.h:62
DdNode * cuddZddSubset1(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:874
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_zddUnion ( DdManager dd,
DdNode P,
DdNode Q 
)

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

Synopsis [Computes the union of two ZDDs.]

Description [Computes the union of two ZDDs. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 178 of file cuddZddSetop.c.

182 {
183  DdNode *res;
184 
185  do {
186  dd->reordered = 0;
187  res = cuddZddUnion(dd, P, Q);
188  } while (dd->reordered == 1);
189  return(res);
190 
191 } /* end of Cudd_zddUnion */
Definition: cudd.h:278
DdNode * cuddZddUnion(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:553
int reordered
Definition: cuddInt.h:409
DdNode* cuddZddChange ( DdManager dd,
DdNode P,
int  var 
)

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

Synopsis [Substitutes a variable with its complement in a ZDD.]

Description [Substitutes a variable with its complement in a ZDD. returns a pointer to the result if successful; NULL otherwise. cuddZddChange performs the same function as Cudd_zddChange, but does not restart if reordering has taken place. Therefore it can be called from within a recursive procedure.]

SideEffects [None]

SeeAlso [Cudd_zddChange]

Definition at line 971 of file cuddZddSetop.c.

975 {
976  DdNode *zvar, *res;
977 
978  zvar = cuddUniqueInterZdd(dd, var, DD_ONE(dd), DD_ZERO(dd));
979  if (zvar == NULL) return(NULL);
980  cuddRef(zvar);
981 
982  res = cuddZddChangeAux(dd, P, zvar);
983  if (res == NULL) {
984  Cudd_RecursiveDerefZdd(dd,zvar);
985  return(NULL);
986  }
987  cuddRef(res);
988  Cudd_RecursiveDerefZdd(dd,zvar);
989  cuddDeref(res);
990  return(res);
991 
992 } /* end of cuddZddChange */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
int var(Lit p)
Definition: SolverTypes.h:62
DdNode * cuddUniqueInterZdd(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1343
DdNode * cuddZddChangeAux(DdManager *zdd, DdNode *P, DdNode *zvar)
Definition: cuddZddSetop.c:799
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddZddChangeAux ( DdManager zdd,
DdNode P,
DdNode zvar 
)

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

Synopsis [Performs the recursive step of Cudd_zddChange.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 799 of file cuddZddSetop.c.

803 {
804  int top_var, level;
805  DdNode *res, *t, *e;
806  DdNode *base = DD_ONE(zdd);
807  DdNode *empty = DD_ZERO(zdd);
808 
809  statLine(zdd);
810  if (P == empty)
811  return(empty);
812  if (P == base)
813  return(zvar);
814 
815  /* Check cache. */
816  res = cuddCacheLookup2Zdd(zdd, cuddZddChangeAux, P, zvar);
817  if (res != NULL)
818  return(res);
819 
820  top_var = zdd->permZ[P->index];
821  level = zdd->permZ[zvar->index];
822 
823  if (top_var > level) {
824  res = cuddZddGetNode(zdd, zvar->index, P, DD_ZERO(zdd));
825  if (res == NULL) return(NULL);
826  } else if (top_var == level) {
827  res = cuddZddGetNode(zdd, zvar->index, cuddE(P), cuddT(P));
828  if (res == NULL) return(NULL);
829  } else {
830  t = cuddZddChangeAux(zdd, cuddT(P), zvar);
831  if (t == NULL) return(NULL);
832  cuddRef(t);
833  e = cuddZddChangeAux(zdd, cuddE(P), zvar);
834  if (e == NULL) {
835  Cudd_RecursiveDerefZdd(zdd, t);
836  return(NULL);
837  }
838  cuddRef(e);
839  res = cuddZddGetNode(zdd, P->index, t, e);
840  if (res == NULL) {
841  Cudd_RecursiveDerefZdd(zdd, t);
842  Cudd_RecursiveDerefZdd(zdd, e);
843  return(NULL);
844  }
845  cuddDeref(t);
846  cuddDeref(e);
847  }
848 
849  cuddCacheInsert2(zdd, cuddZddChangeAux, P, zvar, res);
850 
851  return(res);
852 
853 } /* end of cuddZddChangeAux */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1041
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
int * permZ
Definition: cuddInt.h:387
#define statLine(dd)
Definition: cuddInt.h:1037
#define cuddT(node)
Definition: cuddInt.h:636
DdNode * cuddZddChangeAux(DdManager *zdd, DdNode *P, DdNode *zvar)
Definition: cuddZddSetop.c:799
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddZddDiff ( DdManager zdd,
DdNode P,
DdNode Q 
)

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

Synopsis [Performs the recursive step of Cudd_zddDiff.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 717 of file cuddZddSetop.c.

721 {
722  int p_top, q_top;
723  DdNode *empty = DD_ZERO(zdd), *t, *e, *res;
724  DdManager *table = zdd;
725 
726  statLine(zdd);
727  if (P == empty)
728  return(empty);
729  if (Q == empty)
730  return(P);
731  if (P == Q)
732  return(empty);
733 
734  /* Check cache. The cache is shared by Cudd_zddDiffConst(). */
735  res = cuddCacheLookup2Zdd(table, cuddZddDiff, P, Q);
736  if (res != NULL && res != DD_NON_CONSTANT)
737  return(res);
738 
739  if (cuddIsConstant(P))
740  p_top = P->index;
741  else
742  p_top = zdd->permZ[P->index];
743  if (cuddIsConstant(Q))
744  q_top = Q->index;
745  else
746  q_top = zdd->permZ[Q->index];
747  if (p_top < q_top) {
748  e = cuddZddDiff(zdd, cuddE(P), Q);
749  if (e == NULL) return(NULL);
750  cuddRef(e);
751  res = cuddZddGetNode(zdd, P->index, cuddT(P), e);
752  if (res == NULL) {
753  Cudd_RecursiveDerefZdd(table, e);
754  return(NULL);
755  }
756  cuddDeref(e);
757  } else if (p_top > q_top) {
758  res = cuddZddDiff(zdd, P, cuddE(Q));
759  if (res == NULL) return(NULL);
760  } else {
761  t = cuddZddDiff(zdd, cuddT(P), cuddT(Q));
762  if (t == NULL) return(NULL);
763  cuddRef(t);
764  e = cuddZddDiff(zdd, cuddE(P), cuddE(Q));
765  if (e == NULL) {
766  Cudd_RecursiveDerefZdd(table, t);
767  return(NULL);
768  }
769  cuddRef(e);
770  res = cuddZddGetNode(zdd, P->index, t, e);
771  if (res == NULL) {
772  Cudd_RecursiveDerefZdd(table, t);
773  Cudd_RecursiveDerefZdd(table, e);
774  return(NULL);
775  }
776  cuddDeref(t);
777  cuddDeref(e);
778  }
779 
780  cuddCacheInsert2(table, cuddZddDiff, P, Q, res);
781 
782  return(res);
783 
784 } /* end of cuddZddDiff */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1041
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
int * permZ
Definition: cuddInt.h:387
#define statLine(dd)
Definition: cuddInt.h:1037
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdNode * cuddZddDiff(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:717
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_NON_CONSTANT
Definition: cuddInt.h:123
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddZddIntersect ( DdManager zdd,
DdNode P,
DdNode Q 
)

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

Synopsis [Performs the recursive step of Cudd_zddIntersect.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 642 of file cuddZddSetop.c.

646 {
647  int p_top, q_top;
648  DdNode *empty = DD_ZERO(zdd), *t, *e, *res;
649  DdManager *table = zdd;
650 
651  statLine(zdd);
652  if (P == empty)
653  return(empty);
654  if (Q == empty)
655  return(empty);
656  if (P == Q)
657  return(P);
658 
659  /* Check cache. */
660  res = cuddCacheLookup2Zdd(table, cuddZddIntersect, P, Q);
661  if (res != NULL)
662  return(res);
663 
664  if (cuddIsConstant(P))
665  p_top = P->index;
666  else
667  p_top = zdd->permZ[P->index];
668  if (cuddIsConstant(Q))
669  q_top = Q->index;
670  else
671  q_top = zdd->permZ[Q->index];
672  if (p_top < q_top) {
673  res = cuddZddIntersect(zdd, cuddE(P), Q);
674  if (res == NULL) return(NULL);
675  } else if (p_top > q_top) {
676  res = cuddZddIntersect(zdd, P, cuddE(Q));
677  if (res == NULL) return(NULL);
678  } else {
679  t = cuddZddIntersect(zdd, cuddT(P), cuddT(Q));
680  if (t == NULL) return(NULL);
681  cuddRef(t);
682  e = cuddZddIntersect(zdd, cuddE(P), cuddE(Q));
683  if (e == NULL) {
684  Cudd_RecursiveDerefZdd(table, t);
685  return(NULL);
686  }
687  cuddRef(e);
688  res = cuddZddGetNode(zdd, P->index, t, e);
689  if (res == NULL) {
690  Cudd_RecursiveDerefZdd(table, t);
691  Cudd_RecursiveDerefZdd(table, e);
692  return(NULL);
693  }
694  cuddDeref(t);
695  cuddDeref(e);
696  }
697 
698  cuddCacheInsert2(table, cuddZddIntersect, P, Q, res);
699 
700  return(res);
701 
702 } /* end of cuddZddIntersect */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1041
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
int * permZ
Definition: cuddInt.h:387
#define statLine(dd)
Definition: cuddInt.h:1037
DdNode * cuddZddIntersect(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:642
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddZddIte ( DdManager dd,
DdNode f,
DdNode g,
DdNode h 
)

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

Synopsis [Performs the recursive step of Cudd_zddIte.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 427 of file cuddZddSetop.c.

432 {
434  DdNode *r,*Gv,*Gvn,*Hv,*Hvn,*t,*e;
435  unsigned int topf,topg,toph,v,top;
436  int index;
437 
438  statLine(dd);
439  /* Trivial cases. */
440  /* One variable cases. */
441  if (f == (empty = DD_ZERO(dd))) { /* ITE(0,G,H) = H */
442  return(h);
443  }
444  topf = cuddIZ(dd,f->index);
445  topg = cuddIZ(dd,g->index);
446  toph = cuddIZ(dd,h->index);
447  v = ddMin(topg,toph);
448  top = ddMin(topf,v);
449 
450  tautology = (top == CUDD_MAXINDEX) ? DD_ONE(dd) : dd->univ[top];
451  if (f == tautology) { /* ITE(1,G,H) = G */
452  return(g);
453  }
454 
455  /* From now on, f is known to not be a constant. */
456  zddVarToConst(f,&g,&h,tautology,empty);
457 
458  /* Check remaining one variable cases. */
459  if (g == h) { /* ITE(F,G,G) = G */
460  return(g);
461  }
462 
463  if (g == tautology) { /* ITE(F,1,0) = F */
464  if (h == empty) return(f);
465  }
466 
467  /* Check cache. */
468  r = cuddCacheLookupZdd(dd,DD_ZDD_ITE_TAG,f,g,h);
469  if (r != NULL) {
470  return(r);
471  }
472 
473  /* Recompute these because they may have changed in zddVarToConst. */
474  topg = cuddIZ(dd,g->index);
475  toph = cuddIZ(dd,h->index);
476  v = ddMin(topg,toph);
477 
478  if (topf < v) {
479  r = cuddZddIte(dd,cuddE(f),g,h);
480  if (r == NULL) return(NULL);
481  } else if (topf > v) {
482  if (topg > v) {
483  Gvn = g;
484  index = h->index;
485  } else {
486  Gvn = cuddE(g);
487  index = g->index;
488  }
489  if (toph > v) {
490  Hv = empty; Hvn = h;
491  } else {
492  Hv = cuddT(h); Hvn = cuddE(h);
493  }
494  e = cuddZddIte(dd,f,Gvn,Hvn);
495  if (e == NULL) return(NULL);
496  cuddRef(e);
497  r = cuddZddGetNode(dd,index,Hv,e);
498  if (r == NULL) {
500  return(NULL);
501  }
502  cuddDeref(e);
503  } else {
504  index = f->index;
505  if (topg > v) {
506  Gv = empty; Gvn = g;
507  } else {
508  Gv = cuddT(g); Gvn = cuddE(g);
509  }
510  if (toph > v) {
511  Hv = empty; Hvn = h;
512  } else {
513  Hv = cuddT(h); Hvn = cuddE(h);
514  }
515  e = cuddZddIte(dd,cuddE(f),Gvn,Hvn);
516  if (e == NULL) return(NULL);
517  cuddRef(e);
518  t = cuddZddIte(dd,cuddT(f),Gv,Hv);
519  if (t == NULL) {
521  return(NULL);
522  }
523  cuddRef(t);
524  r = cuddZddGetNode(dd,index,t,e);
525  if (r == NULL) {
528  return(NULL);
529  }
530  cuddDeref(t);
531  cuddDeref(e);
532  }
533 
534  cuddCacheInsert(dd,DD_ZDD_ITE_TAG,f,g,h,r);
535 
536  return(r);
537 
538 } /* end of cuddZddIte */
DdNode * cuddZddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddZddSetop.c:427
DdNode * cuddCacheLookupZdd(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddCache.c:435
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
#define cuddIZ(dd, index)
Definition: cuddInt.h:704
Definition: cudd.h:278
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1041
bool tautology()
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
static void zddVarToConst(DdNode *f, DdNode **gp, DdNode **hp, DdNode *base, DdNode *empty)
#define ddMin(x, y)
Definition: cuddInt.h:818
#define cuddT(node)
Definition: cuddInt.h:636
#define DD_ZDD_ITE_TAG
Definition: cuddInt.h:183
DdHalfWord index
Definition: cudd.h:279
#define CUDD_MAXINDEX
Definition: cudd.h:112
#define cuddE(node)
Definition: cuddInt.h:652
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode ** univ
Definition: cuddInt.h:392
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddZddSubset0 ( DdManager dd,
DdNode P,
int  var 
)

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

Synopsis [Computes the negative cofactor of a ZDD w.r.t. a variable.]

Description [Computes the negative cofactor of a ZDD w.r.t. a variable. In terms of combinations, the result is the set of all combinations in which the variable is negated. Returns a pointer to the result if successful; NULL otherwise. cuddZddSubset0 performs the same function as Cudd_zddSubset0, but does not restart if reordering has taken place. Therefore it can be called from within a recursive procedure.]

SideEffects [None]

SeeAlso [cuddZddSubset1 Cudd_zddSubset0]

Definition at line 923 of file cuddZddSetop.c.

927 {
928  DdNode *zvar, *r;
929  DdNode *base, *empty;
930 
931  base = DD_ONE(dd);
932  empty = DD_ZERO(dd);
933 
934  zvar = cuddUniqueInterZdd(dd, var, base, empty);
935  if (zvar == NULL) {
936  return(NULL);
937  } else {
938  cuddRef(zvar);
939  r = zdd_subset0_aux(dd, P, zvar);
940  if (r == NULL) {
941  Cudd_RecursiveDerefZdd(dd, zvar);
942  return(NULL);
943  }
944  cuddRef(r);
945  Cudd_RecursiveDerefZdd(dd, zvar);
946  }
947 
948  cuddDeref(r);
949  return(r);
950 
951 } /* end of cuddZddSubset0 */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
int var(Lit p)
Definition: SolverTypes.h:62
DdNode * cuddUniqueInterZdd(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1343
static DdNode * zdd_subset0_aux(DdManager *zdd, DdNode *P, DdNode *zvar)
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddZddSubset1 ( DdManager dd,
DdNode P,
int  var 
)

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

Synopsis [Computes the positive cofactor of a ZDD w.r.t. a variable.]

Description [Computes the positive cofactor of a ZDD w.r.t. a variable. In terms of combinations, the result is the set of all combinations in which the variable is asserted. Returns a pointer to the result if successful; NULL otherwise. cuddZddSubset1 performs the same function as Cudd_zddSubset1, but does not restart if reordering has taken place. Therefore it can be called from within a recursive procedure.]

SideEffects [None]

SeeAlso [cuddZddSubset0 Cudd_zddSubset1]

Definition at line 874 of file cuddZddSetop.c.

878 {
879  DdNode *zvar, *r;
880  DdNode *base, *empty;
881 
882  base = DD_ONE(dd);
883  empty = DD_ZERO(dd);
884 
885  zvar = cuddUniqueInterZdd(dd, var, base, empty);
886  if (zvar == NULL) {
887  return(NULL);
888  } else {
889  cuddRef(zvar);
890  r = zdd_subset1_aux(dd, P, zvar);
891  if (r == NULL) {
892  Cudd_RecursiveDerefZdd(dd, zvar);
893  return(NULL);
894  }
895  cuddRef(r);
896  Cudd_RecursiveDerefZdd(dd, zvar);
897  }
898 
899  cuddDeref(r);
900  return(r);
901 
902 } /* end of cuddZddSubset1 */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
int var(Lit p)
Definition: SolverTypes.h:62
static DdNode * zdd_subset1_aux(DdManager *zdd, DdNode *P, DdNode *zvar)
DdNode * cuddUniqueInterZdd(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1343
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddZddUnion ( DdManager zdd,
DdNode P,
DdNode Q 
)

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

Synopsis [Performs the recursive step of Cudd_zddUnion.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 553 of file cuddZddSetop.c.

557 {
558  int p_top, q_top;
559  DdNode *empty = DD_ZERO(zdd), *t, *e, *res;
560  DdManager *table = zdd;
561 
562  statLine(zdd);
563  if (P == empty)
564  return(Q);
565  if (Q == empty)
566  return(P);
567  if (P == Q)
568  return(P);
569 
570  /* Check cache */
571  res = cuddCacheLookup2Zdd(table, cuddZddUnion, P, Q);
572  if (res != NULL)
573  return(res);
574 
575  if (cuddIsConstant(P))
576  p_top = P->index;
577  else
578  p_top = zdd->permZ[P->index];
579  if (cuddIsConstant(Q))
580  q_top = Q->index;
581  else
582  q_top = zdd->permZ[Q->index];
583  if (p_top < q_top) {
584  e = cuddZddUnion(zdd, cuddE(P), Q);
585  if (e == NULL) return (NULL);
586  cuddRef(e);
587  res = cuddZddGetNode(zdd, P->index, cuddT(P), e);
588  if (res == NULL) {
589  Cudd_RecursiveDerefZdd(table, e);
590  return(NULL);
591  }
592  cuddDeref(e);
593  } else if (p_top > q_top) {
594  e = cuddZddUnion(zdd, P, cuddE(Q));
595  if (e == NULL) return(NULL);
596  cuddRef(e);
597  res = cuddZddGetNode(zdd, Q->index, cuddT(Q), e);
598  if (res == NULL) {
599  Cudd_RecursiveDerefZdd(table, e);
600  return(NULL);
601  }
602  cuddDeref(e);
603  } else {
604  t = cuddZddUnion(zdd, cuddT(P), cuddT(Q));
605  if (t == NULL) return(NULL);
606  cuddRef(t);
607  e = cuddZddUnion(zdd, cuddE(P), cuddE(Q));
608  if (e == NULL) {
609  Cudd_RecursiveDerefZdd(table, t);
610  return(NULL);
611  }
612  cuddRef(e);
613  res = cuddZddGetNode(zdd, P->index, t, e);
614  if (res == NULL) {
615  Cudd_RecursiveDerefZdd(table, t);
616  Cudd_RecursiveDerefZdd(table, e);
617  return(NULL);
618  }
619  cuddDeref(t);
620  cuddDeref(e);
621  }
622 
623  cuddCacheInsert2(table, cuddZddUnion, P, Q, res);
624 
625  return(res);
626 
627 } /* end of cuddZddUnion */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1041
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
DdNode * cuddZddUnion(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:553
int * permZ
Definition: cuddInt.h:387
#define statLine(dd)
Definition: cuddInt.h:1037
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_ZERO(dd)
Definition: cuddInt.h:927
static DdNode * zdd_subset0_aux ( DdManager zdd,
DdNode P,
DdNode zvar 
)
static

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

Synopsis [Performs the recursive step of Cudd_zddSubset0.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 1081 of file cuddZddSetop.c.

1085 {
1086  int top_var, level;
1087  DdNode *res, *t, *e;
1088 
1089  statLine(zdd);
1090 
1091  /* Check cache. */
1092  res = cuddCacheLookup2Zdd(zdd, zdd_subset0_aux, P, zvar);
1093  if (res != NULL)
1094  return(res);
1095 
1096  if (cuddIsConstant(P)) {
1097  res = P;
1098  cuddCacheInsert2(zdd, zdd_subset0_aux, P, zvar, res);
1099  return(res);
1100  }
1101 
1102  top_var = zdd->permZ[P->index];
1103  level = zdd->permZ[zvar->index];
1104 
1105  if (top_var > level) {
1106  res = P;
1107  }
1108  else if (top_var == level) {
1109  res = cuddE(P);
1110  }
1111  else {
1112  t = zdd_subset0_aux(zdd, cuddT(P), zvar);
1113  if (t == NULL) return(NULL);
1114  cuddRef(t);
1115  e = zdd_subset0_aux(zdd, cuddE(P), zvar);
1116  if (e == NULL) {
1117  Cudd_RecursiveDerefZdd(zdd, t);
1118  return(NULL);
1119  }
1120  cuddRef(e);
1121  res = cuddZddGetNode(zdd, P->index, t, e);
1122  if (res == NULL) {
1123  Cudd_RecursiveDerefZdd(zdd, t);
1124  Cudd_RecursiveDerefZdd(zdd, e);
1125  return(NULL);
1126  }
1127  cuddDeref(t);
1128  cuddDeref(e);
1129  }
1130 
1131  cuddCacheInsert2(zdd, zdd_subset0_aux, P, zvar, res);
1132 
1133  return(res);
1134 
1135 } /* end of zdd_subset0_aux */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1041
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
static byte P[256]
Definition: kitPerm.c:76
int * permZ
Definition: cuddInt.h:387
#define statLine(dd)
Definition: cuddInt.h:1037
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
static DdNode * zdd_subset0_aux(DdManager *zdd, DdNode *P, DdNode *zvar)
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
static DdNode * zdd_subset1_aux ( DdManager zdd,
DdNode P,
DdNode zvar 
)
static

AutomaticStart

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

Synopsis [Performs the recursive step of Cudd_zddSubset1.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 1012 of file cuddZddSetop.c.

1016 {
1017  int top_var, level;
1018  DdNode *res, *t, *e;
1019  DdNode *empty;
1020 
1021  statLine(zdd);
1022  empty = DD_ZERO(zdd);
1023 
1024  /* Check cache. */
1025  res = cuddCacheLookup2Zdd(zdd, zdd_subset1_aux, P, zvar);
1026  if (res != NULL)
1027  return(res);
1028 
1029  if (cuddIsConstant(P)) {
1030  res = empty;
1031  cuddCacheInsert2(zdd, zdd_subset1_aux, P, zvar, res);
1032  return(res);
1033  }
1034 
1035  top_var = zdd->permZ[P->index];
1036  level = zdd->permZ[zvar->index];
1037 
1038  if (top_var > level) {
1039  res = empty;
1040  } else if (top_var == level) {
1041  res = cuddT(P);
1042  } else {
1043  t = zdd_subset1_aux(zdd, cuddT(P), zvar);
1044  if (t == NULL) return(NULL);
1045  cuddRef(t);
1046  e = zdd_subset1_aux(zdd, cuddE(P), zvar);
1047  if (e == NULL) {
1048  Cudd_RecursiveDerefZdd(zdd, t);
1049  return(NULL);
1050  }
1051  cuddRef(e);
1052  res = cuddZddGetNode(zdd, P->index, t, e);
1053  if (res == NULL) {
1054  Cudd_RecursiveDerefZdd(zdd, t);
1055  Cudd_RecursiveDerefZdd(zdd, e);
1056  return(NULL);
1057  }
1058  cuddDeref(t);
1059  cuddDeref(e);
1060  }
1061 
1062  cuddCacheInsert2(zdd, zdd_subset1_aux, P, zvar, res);
1063 
1064  return(res);
1065 
1066 } /* end of zdd_subset1_aux */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1041
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
int * permZ
Definition: cuddInt.h:387
#define statLine(dd)
Definition: cuddInt.h:1037
static DdNode * zdd_subset1_aux(DdManager *zdd, DdNode *P, DdNode *zvar)
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_ZERO(dd)
Definition: cuddInt.h:927
static void zddVarToConst ( DdNode f,
DdNode **  gp,
DdNode **  hp,
DdNode base,
DdNode empty 
)
static

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

Synopsis [Replaces variables with constants if possible (part of canonical form).]

Description []

SideEffects [None]

SeeAlso []

Definition at line 1151 of file cuddZddSetop.c.

1157 {
1158  DdNode *g = *gp;
1159  DdNode *h = *hp;
1160 
1161  if (f == g) { /* ITE(F,F,H) = ITE(F,1,H) = F + H */
1162  *gp = base;
1163  }
1164 
1165  if (f == h) { /* ITE(F,G,F) = ITE(F,G,0) = F * G */
1166  *hp = empty;
1167  }
1168 
1169 } /* end of zddVarToConst */
Definition: cudd.h:278
static DdNode * empty
Definition: cuddZddLin.c:98

Variable Documentation

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

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

FileName [cuddZddSetop.c]

PackageName [cudd]

Synopsis [Set operations on ZDDs.]

Description [External procedures included in this module:

Internal procedures included in this module:

Static procedures included in this module:

]

SeeAlso []

Author [Hyong-Kyoon Shin, In-Ho Moon]

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 103 of file cuddZddSetop.c.