SVF
Functions | Variables
cuddZddSetop.c File Reference
#include "CUDD/util.h"
#include "CUDD/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 char rcsid [] DD_UNUSED = "$Id: cuddZddSetop.c,v 1.26 2012/02/05 01:07:19 fabio Exp $"
 

Function Documentation

◆ Cudd_zddChange()

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

392 {
393  DdNode *res;
394 
395  if ((unsigned int) var >= CUDD_MAXINDEX - 1) return(NULL);
396 
397  do {
398  dd->reordered = 0;
399  res = cuddZddChange(dd, P, var);
400  } while (dd->reordered == 1);
401  return(res);
402 
403 } /* end of Cudd_zddChange */
Definition: cudd.h:270
int reordered
Definition: cuddInt.h:392
DdNode * cuddZddChange(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:967
#define CUDD_MAXINDEX
Definition: cudd.h:108

◆ Cudd_zddDiff()

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

236 {
237  DdNode *res;
238 
239  do {
240  dd->reordered = 0;
241  res = cuddZddDiff(dd, P, Q);
242  } while (dd->reordered == 1);
243  return(res);
244 
245 } /* end of Cudd_zddDiff */
Definition: cudd.h:270
int reordered
Definition: cuddInt.h:392
DdNode * cuddZddDiff(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:713

◆ Cudd_zddDiffConst()

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

266 {
267  int p_top, q_top;
268  DdNode *empty = DD_ZERO(zdd), *t, *res;
269  DdManager *table = zdd;
270 
271  statLine(zdd);
272  if (P == empty)
273  return(empty);
274  if (Q == empty)
275  return(P);
276  if (P == Q)
277  return(empty);
278 
279  /* Check cache. The cache is shared by cuddZddDiff(). */
280  res = cuddCacheLookup2Zdd(table, cuddZddDiff, P, Q);
281  if (res != NULL)
282  return(res);
283 
284  if (cuddIsConstant(P))
285  p_top = P->index;
286  else
287  p_top = zdd->permZ[P->index];
288  if (cuddIsConstant(Q))
289  q_top = Q->index;
290  else
291  q_top = zdd->permZ[Q->index];
292  if (p_top < q_top) {
293  res = DD_NON_CONSTANT;
294  } else if (p_top > q_top) {
295  res = Cudd_zddDiffConst(zdd, P, cuddE(Q));
296  } else {
297  t = Cudd_zddDiffConst(zdd, cuddT(P), cuddT(Q));
298  if (t != empty)
299  res = DD_NON_CONSTANT;
300  else
301  res = Cudd_zddDiffConst(zdd, cuddE(P), cuddE(Q));
302  }
303 
304  cuddCacheInsert2(table, cuddZddDiff, P, Q, res);
305 
306  return(res);
307 
308 } /* end of Cudd_zddDiffConst */
Definition: cudd.h:270
int * permZ
Definition: cuddInt.h:370
#define statLine(dd)
Definition: cuddInt.h:990
#define cuddIsConstant(node)
Definition: cuddInt.h:593
#define cuddT(node)
Definition: cuddInt.h:609
DdNode * Cudd_zddDiffConst(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:262
DdNode * cuddCacheLookup2Zdd(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g)
DdNode * cuddZddDiff(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:713
void cuddCacheInsert2(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g, DdNode *data)
DdHalfWord index
Definition: cudd.h:271
#define cuddE(node)
Definition: cuddInt.h:625
static DdNode * empty
Definition: cuddZddLin.c:94
#define DD_NON_CONSTANT
Definition: cuddInt.h:124
#define DD_ZERO(dd)
Definition: cuddInt.h:880

◆ Cudd_zddIntersect()

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

207 {
208  DdNode *res;
209 
210  do {
211  dd->reordered = 0;
212  res = cuddZddIntersect(dd, P, Q);
213  } while (dd->reordered == 1);
214  return(res);
215 
216 } /* end of Cudd_zddIntersect */
Definition: cudd.h:270
int reordered
Definition: cuddInt.h:392
DdNode * cuddZddIntersect(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:638

◆ Cudd_zddIte()

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

149 {
150  DdNode *res;
151 
152  do {
153  dd->reordered = 0;
154  res = cuddZddIte(dd, f, g, h);
155  } while (dd->reordered == 1);
156  return(res);
157 
158 } /* end of Cudd_zddIte */
DdNode * cuddZddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddZddSetop.c:423
Definition: cudd.h:270
int reordered
Definition: cuddInt.h:392

◆ Cudd_zddSubset0()

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

362 {
363  DdNode *r;
364 
365  do {
366  dd->reordered = 0;
367  r = cuddZddSubset0(dd, P, var);
368  } while (dd->reordered == 1);
369 
370  return(r);
371 
372 } /* end of Cudd_zddSubset0 */
Definition: cudd.h:270
DdNode * cuddZddSubset0(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:919
int reordered
Definition: cuddInt.h:392

◆ Cudd_zddSubset1()

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

330 {
331  DdNode *r;
332 
333  do {
334  dd->reordered = 0;
335  r = cuddZddSubset1(dd, P, var);
336  } while (dd->reordered == 1);
337 
338  return(r);
339 
340 } /* end of Cudd_zddSubset1 */
Definition: cudd.h:270
DdNode * cuddZddSubset1(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:870
int reordered
Definition: cuddInt.h:392

◆ Cudd_zddUnion()

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

178 {
179  DdNode *res;
180 
181  do {
182  dd->reordered = 0;
183  res = cuddZddUnion(dd, P, Q);
184  } while (dd->reordered == 1);
185  return(res);
186 
187 } /* end of Cudd_zddUnion */
Definition: cudd.h:270
DdNode * cuddZddUnion(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:549
int reordered
Definition: cuddInt.h:392

◆ cuddZddChange()

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

971 {
972  DdNode *zvar, *res;
973 
974  zvar = cuddUniqueInterZdd(dd, var, DD_ONE(dd), DD_ZERO(dd));
975  if (zvar == NULL) return(NULL);
976  cuddRef(zvar);
977 
978  res = cuddZddChangeAux(dd, P, zvar);
979  if (res == NULL) {
980  Cudd_RecursiveDerefZdd(dd,zvar);
981  return(NULL);
982  }
983  cuddRef(res);
984  Cudd_RecursiveDerefZdd(dd,zvar);
985  cuddDeref(res);
986  return(res);
987 
988 } /* end of cuddZddChange */
#define cuddRef(n)
Definition: cuddInt.h:557
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:381
#define cuddDeref(n)
Definition: cuddInt.h:577
Definition: cudd.h:270
DdNode * cuddUniqueInterZdd(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1372
DdNode * cuddZddChangeAux(DdManager *zdd, DdNode *P, DdNode *zvar)
Definition: cuddZddSetop.c:795
#define DD_ONE(dd)
Definition: cuddInt.h:864
#define DD_ZERO(dd)
Definition: cuddInt.h:880

◆ cuddZddChangeAux()

DdNode* cuddZddChangeAux ( DdManager zdd,
DdNode P,
DdNode zvar 
)

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

Synopsis [Performs the recursive step of Cudd_zddChange.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 795 of file cuddZddSetop.c.

799 {
800  int top_var, level;
801  DdNode *res, *t, *e;
802  DdNode *base = DD_ONE(zdd);
803  DdNode *empty = DD_ZERO(zdd);
804 
805  statLine(zdd);
806  if (P == empty)
807  return(empty);
808  if (P == base)
809  return(zvar);
810 
811  /* Check cache. */
812  res = cuddCacheLookup2Zdd(zdd, cuddZddChangeAux, P, zvar);
813  if (res != NULL)
814  return(res);
815 
816  top_var = zdd->permZ[P->index];
817  level = zdd->permZ[zvar->index];
818 
819  if (top_var > level) {
820  res = cuddZddGetNode(zdd, zvar->index, P, DD_ZERO(zdd));
821  if (res == NULL) return(NULL);
822  } else if (top_var == level) {
823  res = cuddZddGetNode(zdd, zvar->index, cuddE(P), cuddT(P));
824  if (res == NULL) return(NULL);
825  } else {
826  t = cuddZddChangeAux(zdd, cuddT(P), zvar);
827  if (t == NULL) return(NULL);
828  cuddRef(t);
829  e = cuddZddChangeAux(zdd, cuddE(P), zvar);
830  if (e == NULL) {
831  Cudd_RecursiveDerefZdd(zdd, t);
832  return(NULL);
833  }
834  cuddRef(e);
835  res = cuddZddGetNode(zdd, P->index, t, e);
836  if (res == NULL) {
837  Cudd_RecursiveDerefZdd(zdd, t);
838  Cudd_RecursiveDerefZdd(zdd, e);
839  return(NULL);
840  }
841  cuddDeref(t);
842  cuddDeref(e);
843  }
844 
845  cuddCacheInsert2(zdd, cuddZddChangeAux, P, zvar, res);
846 
847  return(res);
848 
849 } /* end of cuddZddChangeAux */
#define cuddRef(n)
Definition: cuddInt.h:557
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:381
#define cuddDeref(n)
Definition: cuddInt.h:577
Definition: cudd.h:270
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1050
int * permZ
Definition: cuddInt.h:370
#define statLine(dd)
Definition: cuddInt.h:990
#define cuddT(node)
Definition: cuddInt.h:609
DdNode * cuddCacheLookup2Zdd(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g)
DdNode * cuddZddChangeAux(DdManager *zdd, DdNode *P, DdNode *zvar)
Definition: cuddZddSetop.c:795
void cuddCacheInsert2(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g, DdNode *data)
DdHalfWord index
Definition: cudd.h:271
#define cuddE(node)
Definition: cuddInt.h:625
static DdNode * empty
Definition: cuddZddLin.c:94
#define DD_ONE(dd)
Definition: cuddInt.h:864
#define DD_ZERO(dd)
Definition: cuddInt.h:880

◆ cuddZddDiff()

DdNode* cuddZddDiff ( DdManager zdd,
DdNode P,
DdNode Q 
)

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

Synopsis [Performs the recursive step of Cudd_zddDiff.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 713 of file cuddZddSetop.c.

717 {
718  int p_top, q_top;
719  DdNode *empty = DD_ZERO(zdd), *t, *e, *res;
720  DdManager *table = zdd;
721 
722  statLine(zdd);
723  if (P == empty)
724  return(empty);
725  if (Q == empty)
726  return(P);
727  if (P == Q)
728  return(empty);
729 
730  /* Check cache. The cache is shared by Cudd_zddDiffConst(). */
731  res = cuddCacheLookup2Zdd(table, cuddZddDiff, P, Q);
732  if (res != NULL && res != DD_NON_CONSTANT)
733  return(res);
734 
735  if (cuddIsConstant(P))
736  p_top = P->index;
737  else
738  p_top = zdd->permZ[P->index];
739  if (cuddIsConstant(Q))
740  q_top = Q->index;
741  else
742  q_top = zdd->permZ[Q->index];
743  if (p_top < q_top) {
744  e = cuddZddDiff(zdd, cuddE(P), Q);
745  if (e == NULL) return(NULL);
746  cuddRef(e);
747  res = cuddZddGetNode(zdd, P->index, cuddT(P), e);
748  if (res == NULL) {
749  Cudd_RecursiveDerefZdd(table, e);
750  return(NULL);
751  }
752  cuddDeref(e);
753  } else if (p_top > q_top) {
754  res = cuddZddDiff(zdd, P, cuddE(Q));
755  if (res == NULL) return(NULL);
756  } else {
757  t = cuddZddDiff(zdd, cuddT(P), cuddT(Q));
758  if (t == NULL) return(NULL);
759  cuddRef(t);
760  e = cuddZddDiff(zdd, cuddE(P), cuddE(Q));
761  if (e == NULL) {
762  Cudd_RecursiveDerefZdd(table, t);
763  return(NULL);
764  }
765  cuddRef(e);
766  res = cuddZddGetNode(zdd, P->index, t, e);
767  if (res == NULL) {
768  Cudd_RecursiveDerefZdd(table, t);
769  Cudd_RecursiveDerefZdd(table, e);
770  return(NULL);
771  }
772  cuddDeref(t);
773  cuddDeref(e);
774  }
775 
776  cuddCacheInsert2(table, cuddZddDiff, P, Q, res);
777 
778  return(res);
779 
780 } /* end of cuddZddDiff */
#define cuddRef(n)
Definition: cuddInt.h:557
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:381
#define cuddDeref(n)
Definition: cuddInt.h:577
Definition: cudd.h:270
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1050
int * permZ
Definition: cuddInt.h:370
#define statLine(dd)
Definition: cuddInt.h:990
#define cuddIsConstant(node)
Definition: cuddInt.h:593
#define cuddT(node)
Definition: cuddInt.h:609
DdNode * cuddCacheLookup2Zdd(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g)
DdNode * cuddZddDiff(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:713
void cuddCacheInsert2(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g, DdNode *data)
DdHalfWord index
Definition: cudd.h:271
#define cuddE(node)
Definition: cuddInt.h:625
static DdNode * empty
Definition: cuddZddLin.c:94
#define DD_NON_CONSTANT
Definition: cuddInt.h:124
#define DD_ZERO(dd)
Definition: cuddInt.h:880

◆ cuddZddIntersect()

DdNode* cuddZddIntersect ( DdManager zdd,
DdNode P,
DdNode Q 
)

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

Synopsis [Performs the recursive step of Cudd_zddIntersect.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 638 of file cuddZddSetop.c.

642 {
643  int p_top, q_top;
644  DdNode *empty = DD_ZERO(zdd), *t, *e, *res;
645  DdManager *table = zdd;
646 
647  statLine(zdd);
648  if (P == empty)
649  return(empty);
650  if (Q == empty)
651  return(empty);
652  if (P == Q)
653  return(P);
654 
655  /* Check cache. */
656  res = cuddCacheLookup2Zdd(table, cuddZddIntersect, P, Q);
657  if (res != NULL)
658  return(res);
659 
660  if (cuddIsConstant(P))
661  p_top = P->index;
662  else
663  p_top = zdd->permZ[P->index];
664  if (cuddIsConstant(Q))
665  q_top = Q->index;
666  else
667  q_top = zdd->permZ[Q->index];
668  if (p_top < q_top) {
669  res = cuddZddIntersect(zdd, cuddE(P), Q);
670  if (res == NULL) return(NULL);
671  } else if (p_top > q_top) {
672  res = cuddZddIntersect(zdd, P, cuddE(Q));
673  if (res == NULL) return(NULL);
674  } else {
675  t = cuddZddIntersect(zdd, cuddT(P), cuddT(Q));
676  if (t == NULL) return(NULL);
677  cuddRef(t);
678  e = cuddZddIntersect(zdd, cuddE(P), cuddE(Q));
679  if (e == NULL) {
680  Cudd_RecursiveDerefZdd(table, t);
681  return(NULL);
682  }
683  cuddRef(e);
684  res = cuddZddGetNode(zdd, P->index, t, e);
685  if (res == NULL) {
686  Cudd_RecursiveDerefZdd(table, t);
687  Cudd_RecursiveDerefZdd(table, e);
688  return(NULL);
689  }
690  cuddDeref(t);
691  cuddDeref(e);
692  }
693 
694  cuddCacheInsert2(table, cuddZddIntersect, P, Q, res);
695 
696  return(res);
697 
698 } /* end of cuddZddIntersect */
#define cuddRef(n)
Definition: cuddInt.h:557
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:381
#define cuddDeref(n)
Definition: cuddInt.h:577
Definition: cudd.h:270
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1050
int * permZ
Definition: cuddInt.h:370
#define statLine(dd)
Definition: cuddInt.h:990
DdNode * cuddZddIntersect(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:638
#define cuddIsConstant(node)
Definition: cuddInt.h:593
#define cuddT(node)
Definition: cuddInt.h:609
DdNode * cuddCacheLookup2Zdd(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g)
void cuddCacheInsert2(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g, DdNode *data)
DdHalfWord index
Definition: cudd.h:271
#define cuddE(node)
Definition: cuddInt.h:625
static DdNode * empty
Definition: cuddZddLin.c:94
#define DD_ZERO(dd)
Definition: cuddInt.h:880

◆ cuddZddIte()

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

428 {
429  DdNode *tautology, *empty;
430  DdNode *r,*Gv,*Gvn,*Hv,*Hvn,*t,*e;
431  unsigned int topf,topg,toph,v,top;
432  int index;
433 
434  statLine(dd);
435  /* Trivial cases. */
436  /* One variable cases. */
437  if (f == (empty = DD_ZERO(dd))) { /* ITE(0,G,H) = H */
438  return(h);
439  }
440  topf = cuddIZ(dd,f->index);
441  topg = cuddIZ(dd,g->index);
442  toph = cuddIZ(dd,h->index);
443  v = ddMin(topg,toph);
444  top = ddMin(topf,v);
445 
446  tautology = (top == CUDD_MAXINDEX) ? DD_ONE(dd) : dd->univ[top];
447  if (f == tautology) { /* ITE(1,G,H) = G */
448  return(g);
449  }
450 
451  /* From now on, f is known to not be a constant. */
452  zddVarToConst(f,&g,&h,tautology,empty);
453 
454  /* Check remaining one variable cases. */
455  if (g == h) { /* ITE(F,G,G) = G */
456  return(g);
457  }
458 
459  if (g == tautology) { /* ITE(F,1,0) = F */
460  if (h == empty) return(f);
461  }
462 
463  /* Check cache. */
464  r = cuddCacheLookupZdd(dd,DD_ZDD_ITE_TAG,f,g,h);
465  if (r != NULL) {
466  return(r);
467  }
468 
469  /* Recompute these because they may have changed in zddVarToConst. */
470  topg = cuddIZ(dd,g->index);
471  toph = cuddIZ(dd,h->index);
472  v = ddMin(topg,toph);
473 
474  if (topf < v) {
475  r = cuddZddIte(dd,cuddE(f),g,h);
476  if (r == NULL) return(NULL);
477  } else if (topf > v) {
478  if (topg > v) {
479  Gvn = g;
480  index = h->index;
481  } else {
482  Gvn = cuddE(g);
483  index = g->index;
484  }
485  if (toph > v) {
486  Hv = empty; Hvn = h;
487  } else {
488  Hv = cuddT(h); Hvn = cuddE(h);
489  }
490  e = cuddZddIte(dd,f,Gvn,Hvn);
491  if (e == NULL) return(NULL);
492  cuddRef(e);
493  r = cuddZddGetNode(dd,index,Hv,e);
494  if (r == NULL) {
496  return(NULL);
497  }
498  cuddDeref(e);
499  } else {
500  index = f->index;
501  if (topg > v) {
502  Gv = empty; Gvn = g;
503  } else {
504  Gv = cuddT(g); Gvn = cuddE(g);
505  }
506  if (toph > v) {
507  Hv = empty; Hvn = h;
508  } else {
509  Hv = cuddT(h); Hvn = cuddE(h);
510  }
511  e = cuddZddIte(dd,cuddE(f),Gvn,Hvn);
512  if (e == NULL) return(NULL);
513  cuddRef(e);
514  t = cuddZddIte(dd,cuddT(f),Gv,Hv);
515  if (t == NULL) {
517  return(NULL);
518  }
519  cuddRef(t);
520  r = cuddZddGetNode(dd,index,t,e);
521  if (r == NULL) {
524  return(NULL);
525  }
526  cuddDeref(t);
527  cuddDeref(e);
528  }
529 
530  cuddCacheInsert(dd,DD_ZDD_ITE_TAG,f,g,h,r);
531 
532  return(r);
533 
534 } /* end of cuddZddIte */
DdNode * cuddZddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddZddSetop.c:423
#define cuddRef(n)
Definition: cuddInt.h:557
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:381
#define cuddDeref(n)
Definition: cuddInt.h:577
#define cuddIZ(dd, index)
Definition: cuddInt.h:677
Definition: cudd.h:270
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1050
#define statLine(dd)
Definition: cuddInt.h:990
static void zddVarToConst(DdNode *f, DdNode **gp, DdNode **hp, DdNode *base, DdNode *empty)
DdNode * cuddCacheLookupZdd(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddCache.c:409
#define ddMin(x, y)
Definition: cuddInt.h:771
#define cuddT(node)
Definition: cuddInt.h:609
#define DD_ZDD_ITE_TAG
Definition: cuddInt.h:184
DdHalfWord index
Definition: cudd.h:271
#define CUDD_MAXINDEX
Definition: cudd.h:108
#define cuddE(node)
Definition: cuddInt.h:625
void cuddCacheInsert(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h, DdNode *data)
Definition: cuddCache.c:217
static DdNode * empty
Definition: cuddZddLin.c:94
#define DD_ONE(dd)
Definition: cuddInt.h:864
DdNode ** univ
Definition: cuddInt.h:375
#define DD_ZERO(dd)
Definition: cuddInt.h:880

◆ cuddZddSubset0()

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

923 {
924  DdNode *zvar, *r;
925  DdNode *base, *empty;
926 
927  base = DD_ONE(dd);
928  empty = DD_ZERO(dd);
929 
930  zvar = cuddUniqueInterZdd(dd, var, base, empty);
931  if (zvar == NULL) {
932  return(NULL);
933  } else {
934  cuddRef(zvar);
935  r = zdd_subset0_aux(dd, P, zvar);
936  if (r == NULL) {
937  Cudd_RecursiveDerefZdd(dd, zvar);
938  return(NULL);
939  }
940  cuddRef(r);
941  Cudd_RecursiveDerefZdd(dd, zvar);
942  }
943 
944  cuddDeref(r);
945  return(r);
946 
947 } /* end of cuddZddSubset0 */
#define cuddRef(n)
Definition: cuddInt.h:557
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:381
#define cuddDeref(n)
Definition: cuddInt.h:577
Definition: cudd.h:270
DdNode * cuddUniqueInterZdd(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1372
static DdNode * zdd_subset0_aux(DdManager *zdd, DdNode *P, DdNode *zvar)
static DdNode * empty
Definition: cuddZddLin.c:94
#define DD_ONE(dd)
Definition: cuddInt.h:864
#define DD_ZERO(dd)
Definition: cuddInt.h:880

◆ cuddZddSubset1()

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

874 {
875  DdNode *zvar, *r;
876  DdNode *base, *empty;
877 
878  base = DD_ONE(dd);
879  empty = DD_ZERO(dd);
880 
881  zvar = cuddUniqueInterZdd(dd, var, base, empty);
882  if (zvar == NULL) {
883  return(NULL);
884  } else {
885  cuddRef(zvar);
886  r = zdd_subset1_aux(dd, P, zvar);
887  if (r == NULL) {
888  Cudd_RecursiveDerefZdd(dd, zvar);
889  return(NULL);
890  }
891  cuddRef(r);
892  Cudd_RecursiveDerefZdd(dd, zvar);
893  }
894 
895  cuddDeref(r);
896  return(r);
897 
898 } /* end of cuddZddSubset1 */
#define cuddRef(n)
Definition: cuddInt.h:557
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:381
#define cuddDeref(n)
Definition: cuddInt.h:577
Definition: cudd.h:270
static DdNode * zdd_subset1_aux(DdManager *zdd, DdNode *P, DdNode *zvar)
DdNode * cuddUniqueInterZdd(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1372
static DdNode * empty
Definition: cuddZddLin.c:94
#define DD_ONE(dd)
Definition: cuddInt.h:864
#define DD_ZERO(dd)
Definition: cuddInt.h:880

◆ cuddZddUnion()

DdNode* cuddZddUnion ( DdManager zdd,
DdNode P,
DdNode Q 
)

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

Synopsis [Performs the recursive step of Cudd_zddUnion.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 549 of file cuddZddSetop.c.

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

◆ zdd_subset0_aux()

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

1081 {
1082  int top_var, level;
1083  DdNode *res, *t, *e;
1084 
1085  statLine(zdd);
1086 
1087  /* Check cache. */
1088  res = cuddCacheLookup2Zdd(zdd, zdd_subset0_aux, P, zvar);
1089  if (res != NULL)
1090  return(res);
1091 
1092  if (cuddIsConstant(P)) {
1093  res = P;
1094  cuddCacheInsert2(zdd, zdd_subset0_aux, P, zvar, res);
1095  return(res);
1096  }
1097 
1098  top_var = zdd->permZ[P->index];
1099  level = zdd->permZ[zvar->index];
1100 
1101  if (top_var > level) {
1102  res = P;
1103  }
1104  else if (top_var == level) {
1105  res = cuddE(P);
1106  }
1107  else {
1108  t = zdd_subset0_aux(zdd, cuddT(P), zvar);
1109  if (t == NULL) return(NULL);
1110  cuddRef(t);
1111  e = zdd_subset0_aux(zdd, cuddE(P), zvar);
1112  if (e == NULL) {
1113  Cudd_RecursiveDerefZdd(zdd, t);
1114  return(NULL);
1115  }
1116  cuddRef(e);
1117  res = cuddZddGetNode(zdd, P->index, t, e);
1118  if (res == NULL) {
1119  Cudd_RecursiveDerefZdd(zdd, t);
1120  Cudd_RecursiveDerefZdd(zdd, e);
1121  return(NULL);
1122  }
1123  cuddDeref(t);
1124  cuddDeref(e);
1125  }
1126 
1127  cuddCacheInsert2(zdd, zdd_subset0_aux, P, zvar, res);
1128 
1129  return(res);
1130 
1131 } /* end of zdd_subset0_aux */
#define cuddRef(n)
Definition: cuddInt.h:557
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:381
#define cuddDeref(n)
Definition: cuddInt.h:577
Definition: cudd.h:270
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1050
int * permZ
Definition: cuddInt.h:370
#define statLine(dd)
Definition: cuddInt.h:990
#define cuddIsConstant(node)
Definition: cuddInt.h:593
#define cuddT(node)
Definition: cuddInt.h:609
DdNode * cuddCacheLookup2Zdd(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g)
static DdNode * zdd_subset0_aux(DdManager *zdd, DdNode *P, DdNode *zvar)
void cuddCacheInsert2(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g, DdNode *data)
DdHalfWord index
Definition: cudd.h:271
#define cuddE(node)
Definition: cuddInt.h:625

◆ zdd_subset1_aux()

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

1012 {
1013  int top_var, level;
1014  DdNode *res, *t, *e;
1015  DdNode *empty;
1016 
1017  statLine(zdd);
1018  empty = DD_ZERO(zdd);
1019 
1020  /* Check cache. */
1021  res = cuddCacheLookup2Zdd(zdd, zdd_subset1_aux, P, zvar);
1022  if (res != NULL)
1023  return(res);
1024 
1025  if (cuddIsConstant(P)) {
1026  res = empty;
1027  cuddCacheInsert2(zdd, zdd_subset1_aux, P, zvar, res);
1028  return(res);
1029  }
1030 
1031  top_var = zdd->permZ[P->index];
1032  level = zdd->permZ[zvar->index];
1033 
1034  if (top_var > level) {
1035  res = empty;
1036  } else if (top_var == level) {
1037  res = cuddT(P);
1038  } else {
1039  t = zdd_subset1_aux(zdd, cuddT(P), zvar);
1040  if (t == NULL) return(NULL);
1041  cuddRef(t);
1042  e = zdd_subset1_aux(zdd, cuddE(P), zvar);
1043  if (e == NULL) {
1044  Cudd_RecursiveDerefZdd(zdd, t);
1045  return(NULL);
1046  }
1047  cuddRef(e);
1048  res = cuddZddGetNode(zdd, P->index, t, e);
1049  if (res == NULL) {
1050  Cudd_RecursiveDerefZdd(zdd, t);
1051  Cudd_RecursiveDerefZdd(zdd, e);
1052  return(NULL);
1053  }
1054  cuddDeref(t);
1055  cuddDeref(e);
1056  }
1057 
1058  cuddCacheInsert2(zdd, zdd_subset1_aux, P, zvar, res);
1059 
1060  return(res);
1061 
1062 } /* end of zdd_subset1_aux */
#define cuddRef(n)
Definition: cuddInt.h:557
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:381
#define cuddDeref(n)
Definition: cuddInt.h:577
Definition: cudd.h:270
DdNode * cuddZddGetNode(DdManager *zdd, int id, DdNode *T, DdNode *E)
Definition: cuddTable.c:1050
int * permZ
Definition: cuddInt.h:370
#define statLine(dd)
Definition: cuddInt.h:990
static DdNode * zdd_subset1_aux(DdManager *zdd, DdNode *P, DdNode *zvar)
#define cuddIsConstant(node)
Definition: cuddInt.h:593
#define cuddT(node)
Definition: cuddInt.h:609
DdNode * cuddCacheLookup2Zdd(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g)
void cuddCacheInsert2(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g, DdNode *data)
DdHalfWord index
Definition: cudd.h:271
#define cuddE(node)
Definition: cuddInt.h:625
static DdNode * empty
Definition: cuddZddLin.c:94
#define DD_ZERO(dd)
Definition: cuddInt.h:880

◆ zddVarToConst()

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

1153 {
1154  DdNode *g = *gp;
1155  DdNode *h = *hp;
1156 
1157  if (f == g) { /* ITE(F,F,H) = ITE(F,1,H) = F + H */
1158  *gp = base;
1159  }
1160 
1161  if (f == h) { /* ITE(F,G,F) = ITE(F,G,0) = F * G */
1162  *hp = empty;
1163  }
1164 
1165 } /* end of zddVarToConst */
Definition: cudd.h:270
static DdNode * empty
Definition: cuddZddLin.c:94

Variable Documentation

◆ DD_UNUSED

char rcsid [] DD_UNUSED = "$Id: cuddZddSetop.c,v 1.26 2012/02/05 01:07:19 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-2012, 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 99 of file cuddZddSetop.c.