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

Go to the source code of this file.

Functions

static DdNodeaddBddDoThreshold (DdManager *dd, DdNode *f, DdNode *val)
 
static DdNodeaddBddDoStrictThreshold (DdManager *dd, DdNode *f, DdNode *val)
 
static DdNodeaddBddDoInterval (DdManager *dd, DdNode *f, DdNode *l, DdNode *u)
 
static DdNodeaddBddDoIthBit (DdManager *dd, DdNode *f, DdNode *index)
 
static DdNodeddBddToAddRecur (DdManager *dd, DdNode *B)
 
static DdNodecuddBddTransferRecur (DdManager *ddS, DdManager *ddD, DdNode *f, st__table *table)
 
DdNodeCudd_addBddThreshold (DdManager *dd, DdNode *f, CUDD_VALUE_TYPE value)
 
DdNodeCudd_addBddStrictThreshold (DdManager *dd, DdNode *f, CUDD_VALUE_TYPE value)
 
DdNodeCudd_addBddInterval (DdManager *dd, DdNode *f, CUDD_VALUE_TYPE lower, CUDD_VALUE_TYPE upper)
 
DdNodeCudd_addBddIthBit (DdManager *dd, DdNode *f, int bit)
 
DdNodeCudd_BddToAdd (DdManager *dd, DdNode *B)
 
DdNodeCudd_addBddPattern (DdManager *dd, DdNode *f)
 
DdNodeCudd_bddTransfer (DdManager *ddSource, DdManager *ddDestination, DdNode *f)
 
DdNodecuddBddTransfer (DdManager *ddS, DdManager *ddD, DdNode *f)
 
DdNodecuddAddBddDoPattern (DdManager *dd, DdNode *f)
 

Variables

static
ABC_NAMESPACE_IMPL_START char
rcsid[] 
DD_UNUSED = "$Id: cuddBridge.c,v 1.19 2008/04/25 06:42:55 fabio Exp $"
 

Function Documentation

static DdNode * addBddDoInterval ( DdManager dd,
DdNode f,
DdNode l,
DdNode u 
)
static

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

Synopsis [Performs the recursive step for Cudd_addBddInterval.]

Description [Performs the recursive step for Cudd_addBddInterval. Returns a pointer to the BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [addBddDoThreshold addBddDoStrictThreshold]

Definition at line 716 of file cuddBridge.c.

721 {
722  DdNode *res, *T, *E;
723  DdNode *fv, *fvn;
724  int v;
725 
726  statLine(dd);
727  /* Check terminal case. */
728  if (cuddIsConstant(f)) {
729  return(Cudd_NotCond(DD_ONE(dd),cuddV(f) < cuddV(l) || cuddV(f) > cuddV(u)));
730  }
731 
732  /* Check cache. */
734  if (res != NULL) return(res);
735 
736  /* Recursive step. */
737  v = f->index;
738  fv = cuddT(f); fvn = cuddE(f);
739 
740  T = addBddDoInterval(dd,fv,l,u);
741  if (T == NULL) return(NULL);
742  cuddRef(T);
743 
744  E = addBddDoInterval(dd,fvn,l,u);
745  if (E == NULL) {
746  Cudd_RecursiveDeref(dd, T);
747  return(NULL);
748  }
749  cuddRef(E);
750  if (Cudd_IsComplement(T)) {
751  res = (T == E) ? Cudd_Not(T) : cuddUniqueInter(dd,v,Cudd_Not(T),Cudd_Not(E));
752  if (res == NULL) {
753  Cudd_RecursiveDeref(dd, T);
754  Cudd_RecursiveDeref(dd, E);
755  return(NULL);
756  }
757  res = Cudd_Not(res);
758  } else {
759  res = (T == E) ? T : cuddUniqueInter(dd,v,T,E);
760  if (res == NULL) {
761  Cudd_RecursiveDeref(dd, T);
762  Cudd_RecursiveDeref(dd, E);
763  return(NULL);
764  }
765  }
766  cuddDeref(T);
767  cuddDeref(E);
768 
769  /* Store result. */
771 
772  return(res);
773 
774 } /* end of addBddDoInterval */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
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 cuddV(node)
Definition: cuddInt.h:668
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
#define DD_ADD_BDD_DO_INTERVAL_TAG
Definition: cuddInt.h:176
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
static DdNode * addBddDoInterval(DdManager *dd, DdNode *f, DdNode *l, DdNode *u)
Definition: cuddBridge.c:716
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
DdNode * cuddCacheLookup(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddCache.c:369
static DdNode * addBddDoIthBit ( DdManager dd,
DdNode f,
DdNode index 
)
static

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

Synopsis [Performs the recursive step for Cudd_addBddIthBit.]

Description [Performs the recursive step for Cudd_addBddIthBit. Returns a pointer to the BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 790 of file cuddBridge.c.

794 {
795  DdNode *res, *T, *E;
796  DdNode *fv, *fvn;
797  int mask, value;
798  int v;
799 
800  statLine(dd);
801  /* Check terminal case. */
802  if (cuddIsConstant(f)) {
803  mask = 1 << ((int) cuddV(index));
804  value = (int) cuddV(f);
805  return(Cudd_NotCond(DD_ONE(dd),(value & mask) == 0));
806  }
807 
808  /* Check cache. */
809  res = cuddCacheLookup2(dd,addBddDoIthBit,f,index);
810  if (res != NULL) return(res);
811 
812  /* Recursive step. */
813  v = f->index;
814  fv = cuddT(f); fvn = cuddE(f);
815 
816  T = addBddDoIthBit(dd,fv,index);
817  if (T == NULL) return(NULL);
818  cuddRef(T);
819 
820  E = addBddDoIthBit(dd,fvn,index);
821  if (E == NULL) {
822  Cudd_RecursiveDeref(dd, T);
823  return(NULL);
824  }
825  cuddRef(E);
826  if (Cudd_IsComplement(T)) {
827  res = (T == E) ? Cudd_Not(T) : cuddUniqueInter(dd,v,Cudd_Not(T),Cudd_Not(E));
828  if (res == NULL) {
829  Cudd_RecursiveDeref(dd, T);
830  Cudd_RecursiveDeref(dd, E);
831  return(NULL);
832  }
833  res = Cudd_Not(res);
834  } else {
835  res = (T == E) ? T : cuddUniqueInter(dd,v,T,E);
836  if (res == NULL) {
837  Cudd_RecursiveDeref(dd, T);
838  Cudd_RecursiveDeref(dd, E);
839  return(NULL);
840  }
841  }
842  cuddDeref(T);
843  cuddDeref(E);
844 
845  /* Store result. */
846  cuddCacheInsert2(dd,addBddDoIthBit,f,index,res);
847 
848  return(res);
849 
850 } /* end of addBddDoIthBit */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
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 statLine(dd)
Definition: cuddInt.h:1037
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
static DdNode * addBddDoIthBit(DdManager *dd, DdNode *f, DdNode *index)
Definition: cuddBridge.c:790
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
int value
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
static DdNode * addBddDoStrictThreshold ( DdManager dd,
DdNode f,
DdNode val 
)
static

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

Synopsis [Performs the recursive step for Cudd_addBddStrictThreshold.]

Description [Performs the recursive step for Cudd_addBddStrictThreshold. Returns a pointer to the BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [addBddDoThreshold]

Definition at line 643 of file cuddBridge.c.

647 {
648  DdNode *res, *T, *E;
649  DdNode *fv, *fvn;
650  int v;
651 
652  statLine(dd);
653  /* Check terminal case. */
654  if (cuddIsConstant(f)) {
655  return(Cudd_NotCond(DD_ONE(dd),cuddV(f) <= cuddV(val)));
656  }
657 
658  /* Check cache. */
660  if (res != NULL) return(res);
661 
662  /* Recursive step. */
663  v = f->index;
664  fv = cuddT(f); fvn = cuddE(f);
665 
666  T = addBddDoStrictThreshold(dd,fv,val);
667  if (T == NULL) return(NULL);
668  cuddRef(T);
669 
670  E = addBddDoStrictThreshold(dd,fvn,val);
671  if (E == NULL) {
672  Cudd_RecursiveDeref(dd, T);
673  return(NULL);
674  }
675  cuddRef(E);
676  if (Cudd_IsComplement(T)) {
677  res = (T == E) ? Cudd_Not(T) : cuddUniqueInter(dd,v,Cudd_Not(T),Cudd_Not(E));
678  if (res == NULL) {
679  Cudd_RecursiveDeref(dd, T);
680  Cudd_RecursiveDeref(dd, E);
681  return(NULL);
682  }
683  res = Cudd_Not(res);
684  } else {
685  res = (T == E) ? T : cuddUniqueInter(dd,v,T,E);
686  if (res == NULL) {
687  Cudd_RecursiveDeref(dd, T);
688  Cudd_RecursiveDeref(dd, E);
689  return(NULL);
690  }
691  }
692  cuddDeref(T);
693  cuddDeref(E);
694 
695  /* Store result. */
697 
698  return(res);
699 
700 } /* end of addBddDoStrictThreshold */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
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 statLine(dd)
Definition: cuddInt.h:1037
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#define cuddIsConstant(node)
Definition: cuddInt.h:620
static DdNode * addBddDoStrictThreshold(DdManager *dd, DdNode *f, DdNode *val)
Definition: cuddBridge.c:643
#define cuddT(node)
Definition: cuddInt.h:636
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
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
static DdNode * addBddDoThreshold ( DdManager dd,
DdNode f,
DdNode val 
)
static

AutomaticStart

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

Synopsis [Performs the recursive step for Cudd_addBddThreshold.]

Description [Performs the recursive step for Cudd_addBddThreshold. Returns a pointer to the BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [addBddDoStrictThreshold]

Definition at line 570 of file cuddBridge.c.

574 {
575  DdNode *res, *T, *E;
576  DdNode *fv, *fvn;
577  int v;
578 
579  statLine(dd);
580  /* Check terminal case. */
581  if (cuddIsConstant(f)) {
582  return(Cudd_NotCond(DD_ONE(dd),cuddV(f) < cuddV(val)));
583  }
584 
585  /* Check cache. */
586  res = cuddCacheLookup2(dd,addBddDoThreshold,f,val);
587  if (res != NULL) return(res);
588 
589  /* Recursive step. */
590  v = f->index;
591  fv = cuddT(f); fvn = cuddE(f);
592 
593  T = addBddDoThreshold(dd,fv,val);
594  if (T == NULL) return(NULL);
595  cuddRef(T);
596 
597  E = addBddDoThreshold(dd,fvn,val);
598  if (E == NULL) {
599  Cudd_RecursiveDeref(dd, T);
600  return(NULL);
601  }
602  cuddRef(E);
603  if (Cudd_IsComplement(T)) {
604  res = (T == E) ? Cudd_Not(T) : cuddUniqueInter(dd,v,Cudd_Not(T),Cudd_Not(E));
605  if (res == NULL) {
606  Cudd_RecursiveDeref(dd, T);
607  Cudd_RecursiveDeref(dd, E);
608  return(NULL);
609  }
610  res = Cudd_Not(res);
611  } else {
612  res = (T == E) ? T : cuddUniqueInter(dd,v,T,E);
613  if (res == NULL) {
614  Cudd_RecursiveDeref(dd, T);
615  Cudd_RecursiveDeref(dd, E);
616  return(NULL);
617  }
618  }
619  cuddDeref(T);
620  cuddDeref(E);
621 
622  /* Store result. */
623  cuddCacheInsert2(dd,addBddDoThreshold,f,val,res);
624 
625  return(res);
626 
627 } /* end of addBddDoThreshold */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
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 statLine(dd)
Definition: cuddInt.h:1037
#define cuddV(node)
Definition: cuddInt.h:668
static DdNode * addBddDoThreshold(DdManager *dd, DdNode *f, DdNode *val)
Definition: cuddBridge.c:570
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#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
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
DdNode* Cudd_addBddInterval ( DdManager dd,
DdNode f,
CUDD_VALUE_TYPE  lower,
CUDD_VALUE_TYPE  upper 
)

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

Synopsis [Converts an ADD to a BDD.]

Description [Converts an ADD to a BDD by replacing all discriminants greater than or equal to lower and less than or equal to upper with 1, and all other discriminants with 0. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddThreshold Cudd_addBddStrictThreshold Cudd_addBddPattern Cudd_BddToAdd]

Definition at line 244 of file cuddBridge.c.

249 {
250  DdNode *res;
251  DdNode *l;
252  DdNode *u;
253 
254  /* Create constant nodes for the interval bounds, so that we can use
255  ** the global cache.
256  */
257  l = cuddUniqueConst(dd,lower);
258  if (l == NULL) return(NULL);
259  cuddRef(l);
260  u = cuddUniqueConst(dd,upper);
261  if (u == NULL) {
262  Cudd_RecursiveDeref(dd,l);
263  return(NULL);
264  }
265  cuddRef(u);
266 
267  do {
268  dd->reordered = 0;
269  res = addBddDoInterval(dd, f, l, u);
270  } while (dd->reordered == 1);
271 
272  if (res == NULL) {
273  Cudd_RecursiveDeref(dd, l);
274  Cudd_RecursiveDeref(dd, u);
275  return(NULL);
276  }
277  cuddRef(res);
278  Cudd_RecursiveDeref(dd, l);
279  Cudd_RecursiveDeref(dd, u);
280  cuddDeref(res);
281  return(res);
282 
283 } /* end of Cudd_addBddInterval */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
int reordered
Definition: cuddInt.h:409
static DdNode * addBddDoInterval(DdManager *dd, DdNode *f, DdNode *l, DdNode *u)
Definition: cuddBridge.c:716
DdNode* Cudd_addBddIthBit ( DdManager dd,
DdNode f,
int  bit 
)

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

Synopsis [Converts an ADD to a BDD by extracting the i-th bit from the leaves.]

Description [Converts an ADD to a BDD by replacing all discriminants whose i-th bit is equal to 1 with 1, and all other discriminants with 0. The i-th bit refers to the integer representation of the leaf value. If the value is has a fractional part, it is ignored. Repeated calls to this procedure allow one to transform an integer-valued ADD into an array of BDDs, one for each bit of the leaf values. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddInterval Cudd_addBddPattern Cudd_BddToAdd]

Definition at line 306 of file cuddBridge.c.

310 {
311  DdNode *res;
312  DdNode *index;
313 
314  index = cuddUniqueConst(dd,(CUDD_VALUE_TYPE) bit);
315  if (index == NULL) return(NULL);
316  cuddRef(index);
317 
318  do {
319  dd->reordered = 0;
320  res = addBddDoIthBit(dd, f, index);
321  } while (dd->reordered == 1);
322 
323  if (res == NULL) {
324  Cudd_RecursiveDeref(dd, index);
325  return(NULL);
326  }
327  cuddRef(res);
328  Cudd_RecursiveDeref(dd, index);
329  cuddDeref(res);
330  return(res);
331 
332 } /* end of Cudd_addBddIthBit */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
int reordered
Definition: cuddInt.h:409
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
static DdNode * addBddDoIthBit(DdManager *dd, DdNode *f, DdNode *index)
Definition: cuddBridge.c:790
DdNode* Cudd_addBddPattern ( DdManager dd,
DdNode f 
)

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

Synopsis [Converts an ADD to a BDD.]

Description [Converts an ADD to a BDD by replacing all discriminants different from 0 with 1. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_BddToAdd Cudd_addBddThreshold Cudd_addBddInterval Cudd_addBddStrictThreshold]

Definition at line 379 of file cuddBridge.c.

382 {
383  DdNode *res;
384 
385  do {
386  dd->reordered = 0;
387  res = cuddAddBddDoPattern(dd, f);
388  } while (dd->reordered == 1);
389  return(res);
390 
391 } /* end of Cudd_addBddPattern */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddAddBddDoPattern(DdManager *dd, DdNode *f)
Definition: cuddBridge.c:493
DdNode* Cudd_addBddStrictThreshold ( DdManager dd,
DdNode f,
CUDD_VALUE_TYPE  value 
)

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

Synopsis [Converts an ADD to a BDD.]

Description [Converts an ADD to a BDD by replacing all discriminants STRICTLY greater than value with 1, and all other discriminants with 0. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddInterval Cudd_addBddPattern Cudd_BddToAdd Cudd_addBddThreshold]

Definition at line 199 of file cuddBridge.c.

203 {
204  DdNode *res;
205  DdNode *val;
206 
207  val = cuddUniqueConst(dd,value);
208  if (val == NULL) return(NULL);
209  cuddRef(val);
210 
211  do {
212  dd->reordered = 0;
213  res = addBddDoStrictThreshold(dd, f, val);
214  } while (dd->reordered == 1);
215 
216  if (res == NULL) {
217  Cudd_RecursiveDeref(dd, val);
218  return(NULL);
219  }
220  cuddRef(res);
221  Cudd_RecursiveDeref(dd, val);
222  cuddDeref(res);
223  return(res);
224 
225 } /* end of Cudd_addBddStrictThreshold */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
int reordered
Definition: cuddInt.h:409
static DdNode * addBddDoStrictThreshold(DdManager *dd, DdNode *f, DdNode *val)
Definition: cuddBridge.c:643
int value
DdNode* Cudd_addBddThreshold ( DdManager dd,
DdNode f,
CUDD_VALUE_TYPE  value 
)

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

Synopsis [Converts an ADD to a BDD.]

Description [Converts an ADD to a BDD by replacing all discriminants greater than or equal to value with 1, and all other discriminants with 0. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddInterval Cudd_addBddPattern Cudd_BddToAdd Cudd_addBddStrictThreshold]

Definition at line 154 of file cuddBridge.c.

158 {
159  DdNode *res;
160  DdNode *val;
161 
162  val = cuddUniqueConst(dd,value);
163  if (val == NULL) return(NULL);
164  cuddRef(val);
165 
166  do {
167  dd->reordered = 0;
168  res = addBddDoThreshold(dd, f, val);
169  } while (dd->reordered == 1);
170 
171  if (res == NULL) {
172  Cudd_RecursiveDeref(dd, val);
173  return(NULL);
174  }
175  cuddRef(res);
176  Cudd_RecursiveDeref(dd, val);
177  cuddDeref(res);
178  return(res);
179 
180 } /* end of Cudd_addBddThreshold */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
static DdNode * addBddDoThreshold(DdManager *dd, DdNode *f, DdNode *val)
Definition: cuddBridge.c:570
int reordered
Definition: cuddInt.h:409
int value
DdNode* Cudd_BddToAdd ( DdManager dd,
DdNode B 
)

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

Synopsis [Converts a BDD to a 0-1 ADD.]

Description [Converts a BDD to a 0-1 ADD. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddPattern Cudd_addBddThreshold Cudd_addBddInterval Cudd_addBddStrictThreshold]

Definition at line 349 of file cuddBridge.c.

352 {
353  DdNode *res;
354 
355  do {
356  dd->reordered = 0;
357  res = ddBddToAddRecur(dd, B);
358  } while (dd->reordered ==1);
359  return(res);
360 
361 } /* end of Cudd_BddToAdd */
Definition: cudd.h:278
static DdNode * ddBddToAddRecur(DdManager *dd, DdNode *B)
Definition: cuddBridge.c:866
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_bddTransfer ( DdManager ddSource,
DdManager ddDestination,
DdNode f 
)

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

Synopsis [Convert a BDD from a manager to another one.]

Description [Convert a BDD from a manager to another one. The orders of the variables in the two managers may be different. Returns a pointer to the BDD in the destination manager if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 409 of file cuddBridge.c.

413 {
414  DdNode *res;
415  do {
416  ddDestination->reordered = 0;
417  res = cuddBddTransfer(ddSource, ddDestination, f);
418  } while (ddDestination->reordered == 1);
419  return(res);
420 
421 } /* end of Cudd_bddTransfer */
Definition: cudd.h:278
DdNode * cuddBddTransfer(DdManager *ddS, DdManager *ddD, DdNode *f)
Definition: cuddBridge.c:443
int reordered
Definition: cuddInt.h:409
DdNode* cuddAddBddDoPattern ( DdManager dd,
DdNode f 
)

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

Synopsis [Performs the recursive step for Cudd_addBddPattern.]

Description [Performs the recursive step for Cudd_addBddPattern. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 493 of file cuddBridge.c.

496 {
497  DdNode *res, *T, *E;
498  DdNode *fv, *fvn;
499  int v;
500 
501  statLine(dd);
502  /* Check terminal case. */
503  if (cuddIsConstant(f)) {
504  return(Cudd_NotCond(DD_ONE(dd),f == DD_ZERO(dd)));
505  }
506 
507  /* Check cache. */
509  if (res != NULL) return(res);
510 
511  /* Recursive step. */
512  v = f->index;
513  fv = cuddT(f); fvn = cuddE(f);
514 
515  T = cuddAddBddDoPattern(dd,fv);
516  if (T == NULL) return(NULL);
517  cuddRef(T);
518 
519  E = cuddAddBddDoPattern(dd,fvn);
520  if (E == NULL) {
521  Cudd_RecursiveDeref(dd, T);
522  return(NULL);
523  }
524  cuddRef(E);
525  if (Cudd_IsComplement(T)) {
526  res = (T == E) ? Cudd_Not(T) : cuddUniqueInter(dd,v,Cudd_Not(T),Cudd_Not(E));
527  if (res == NULL) {
528  Cudd_RecursiveDeref(dd, T);
529  Cudd_RecursiveDeref(dd, E);
530  return(NULL);
531  }
532  res = Cudd_Not(res);
533  } else {
534  res = (T == E) ? T : cuddUniqueInter(dd,v,T,E);
535  if (res == NULL) {
536  Cudd_RecursiveDeref(dd, T);
537  Cudd_RecursiveDeref(dd, E);
538  return(NULL);
539  }
540  }
541  cuddDeref(T);
542  cuddDeref(E);
543 
544  /* Store result. */
546 
547  return(res);
548 
549 } /* end of cuddAddBddDoPattern */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define statLine(dd)
Definition: cuddInt.h:1037
#define Cudd_IsComplement(node)
Definition: cudd.h:425
DdNode * cuddCacheLookup1(DdManager *table, DD_CTFP1 op, DdNode *f)
Definition: cuddCache.c:556
DdNode * cuddAddBddDoPattern(DdManager *dd, DdNode *f)
Definition: cuddBridge.c:493
#define cuddIsConstant(node)
Definition: cuddInt.h:620
DdNode * Cudd_addBddPattern(DdManager *dd, DdNode *f)
Definition: cuddBridge.c:379
#define cuddT(node)
Definition: cuddInt.h:636
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
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
void cuddCacheInsert1(DdManager *table, DD_CTFP1 op, DdNode *f, DdNode *data)
Definition: cuddCache.c:323
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddBddTransfer ( DdManager ddS,
DdManager ddD,
DdNode f 
)

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

Synopsis [Convert a BDD from a manager to another one.]

Description [Convert a BDD from a manager to another one. Returns a pointer to the BDD in the destination manager if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddTransfer]

Definition at line 443 of file cuddBridge.c.

447 {
448  DdNode *res;
449  st__table *table = NULL;
450  st__generator *gen = NULL;
451  DdNode *key, *value;
452 
454  if (table == NULL) goto failure;
455  res = cuddBddTransferRecur(ddS, ddD, f, table);
456  if (res != NULL) cuddRef(res);
457 
458  /* Dereference all elements in the table and dispose of the table.
459  ** This must be done also if res is NULL to avoid leaks in case of
460  ** reordering. */
461  gen = st__init_gen(table);
462  if (gen == NULL) goto failure;
463  while ( st__gen(gen, (const char **)&key, (char **)&value)) {
464  Cudd_RecursiveDeref(ddD, value);
465  }
466  st__free_gen(gen); gen = NULL;
467  st__free_table(table); table = NULL;
468 
469  if (res != NULL) cuddDeref(res);
470  return(res);
471 
472 failure:
473  /* No need to free gen because it is always NULL here. */
474  if (table != NULL) st__free_table(table);
475  return(NULL);
476 
477 } /* end of cuddBddTransfer */
void st__free_table(st__table *table)
Definition: st.c:81
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
void st__free_gen(st__generator *gen)
Definition: st.c:556
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
Definition: st.h:52
st__generator * st__init_gen(st__table *table)
Definition: st.c:486
enum keys key
int value
int st__ptrhash(const char *, int)
Definition: st.c:468
static DdNode * cuddBddTransferRecur(DdManager *ddS, DdManager *ddD, DdNode *f, st__table *table)
Definition: cuddBridge.c:953
int st__gen(st__generator *gen, const char **key_p, char **value_p)
Definition: st.c:502
static DdNode * cuddBddTransferRecur ( DdManager ddS,
DdManager ddD,
DdNode f,
st__table table 
)
static

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

Synopsis [Performs the recursive step of Cudd_bddTransfer.]

Description [Performs the recursive step of Cudd_bddTransfer. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [cuddBddTransfer]

Definition at line 953 of file cuddBridge.c.

958 {
959  DdNode *ft, *fe, *t, *e, *var, *res;
960  DdNode *one, *zero;
961  int index;
962  int comple = 0;
963 
964  statLine(ddD);
965  one = DD_ONE(ddD);
966  comple = Cudd_IsComplement(f);
967 
968  /* Trivial cases. */
969  if (Cudd_IsConstant(f)) return(Cudd_NotCond(one, comple));
970 
971  /* Make canonical to increase the utilization of the cache. */
972  f = Cudd_NotCond(f,comple);
973  /* Now f is a regular pointer to a non-constant node. */
974 
975  /* Check the cache. */
976  if ( st__lookup(table, (const char *)f, (char **)&res))
977  return(Cudd_NotCond(res,comple));
978 
979  if ( ddS->TimeStop && Abc_Clock() > ddS->TimeStop )
980  return NULL;
981  if ( ddD->TimeStop && Abc_Clock() > ddD->TimeStop )
982  return NULL;
983 
984  /* Recursive step. */
985  index = f->index;
986  ft = cuddT(f); fe = cuddE(f);
987 
988  t = cuddBddTransferRecur(ddS, ddD, ft, table);
989  if (t == NULL) {
990  return(NULL);
991  }
992  cuddRef(t);
993 
994  e = cuddBddTransferRecur(ddS, ddD, fe, table);
995  if (e == NULL) {
996  Cudd_RecursiveDeref(ddD, t);
997  return(NULL);
998  }
999  cuddRef(e);
1000 
1001  zero = Cudd_Not(one);
1002  var = cuddUniqueInter(ddD,index,one,zero);
1003  if (var == NULL) {
1004  Cudd_RecursiveDeref(ddD, t);
1005  Cudd_RecursiveDeref(ddD, e);
1006  return(NULL);
1007  }
1008  res = cuddBddIteRecur(ddD,var,t,e);
1009  if (res == NULL) {
1010  Cudd_RecursiveDeref(ddD, t);
1011  Cudd_RecursiveDeref(ddD, e);
1012  return(NULL);
1013  }
1014  cuddRef(res);
1015  Cudd_RecursiveDeref(ddD, t);
1016  Cudd_RecursiveDeref(ddD, e);
1017 
1018  if ( st__add_direct(table, (char *) f, (char *) res) == st__OUT_OF_MEM) {
1019  Cudd_RecursiveDeref(ddD, res);
1020  return(NULL);
1021  }
1022  return(Cudd_NotCond(res,comple));
1023 
1024 } /* end of cuddBddTransferRecur */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
abctime TimeStop
Definition: cuddInt.h:489
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int var(Lit p)
Definition: SolverTypes.h:62
#define Cudd_IsConstant(node)
Definition: cudd.h:352
static abctime Abc_Clock()
Definition: abc_global.h:279
#define statLine(dd)
Definition: cuddInt.h:1037
#define Cudd_IsComplement(node)
Definition: cudd.h:425
static DdNode * one
Definition: cuddDecomp.c:112
#define cuddT(node)
Definition: cuddInt.h:636
#define st__OUT_OF_MEM
Definition: st.h:113
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
int st__add_direct(st__table *table, char *key, char *value)
Definition: st.c:205
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
static DdNode * zero
Definition: cuddApa.c:100
static DdNode * cuddBddTransferRecur(DdManager *ddS, DdManager *ddD, DdNode *f, st__table *table)
Definition: cuddBridge.c:953
DdNode * cuddBddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:633
static DdNode * ddBddToAddRecur ( DdManager dd,
DdNode B 
)
static

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

Synopsis [Performs the recursive step for Cudd_BddToAdd.]

Description [Performs the recursive step for Cudd_BddToAdd. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 866 of file cuddBridge.c.

869 {
870  DdNode *one;
871  DdNode *res, *res1, *T, *E, *Bt, *Be;
872  int complement = 0;
873 
874  statLine(dd);
875  one = DD_ONE(dd);
876 
877  if (Cudd_IsConstant(B)) {
878  if (B == one) {
879  res = one;
880  } else {
881  res = DD_ZERO(dd);
882  }
883  return(res);
884  }
885  /* Check visited table */
886  res = cuddCacheLookup1(dd,ddBddToAddRecur,B);
887  if (res != NULL) return(res);
888 
889  if (Cudd_IsComplement(B)) {
890  complement = 1;
891  Bt = cuddT(Cudd_Regular(B));
892  Be = cuddE(Cudd_Regular(B));
893  } else {
894  Bt = cuddT(B);
895  Be = cuddE(B);
896  }
897 
898  T = ddBddToAddRecur(dd, Bt);
899  if (T == NULL) return(NULL);
900  cuddRef(T);
901 
902  E = ddBddToAddRecur(dd, Be);
903  if (E == NULL) {
904  Cudd_RecursiveDeref(dd, T);
905  return(NULL);
906  }
907  cuddRef(E);
908 
909  /* No need to check for T == E, because it is guaranteed not to happen. */
910  res = cuddUniqueInter(dd, (int) Cudd_Regular(B)->index, T, E);
911  if (res == NULL) {
912  Cudd_RecursiveDeref(dd ,T);
913  Cudd_RecursiveDeref(dd ,E);
914  return(NULL);
915  }
916  cuddDeref(T);
917  cuddDeref(E);
918 
919  if (complement) {
920  cuddRef(res);
921  res1 = cuddAddCmplRecur(dd, res);
922  if (res1 == NULL) {
923  Cudd_RecursiveDeref(dd, res);
924  return(NULL);
925  }
926  cuddRef(res1);
927  Cudd_RecursiveDeref(dd, res);
928  res = res1;
929  cuddDeref(res);
930  }
931 
932  /* Store result. */
934 
935  return(res);
936 
937 } /* end of ddBddToAddRecur */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define Cudd_Regular(node)
Definition: cudd.h:397
pcover complement(pcube *T)
Definition: compl.c:49
static DdNode * ddBddToAddRecur(DdManager *dd, DdNode *B)
Definition: cuddBridge.c:866
#define statLine(dd)
Definition: cuddInt.h:1037
#define Cudd_IsComplement(node)
Definition: cudd.h:425
DdNode * cuddCacheLookup1(DdManager *table, DD_CTFP1 op, DdNode *f)
Definition: cuddCache.c:556
static DdNode * one
Definition: cuddDecomp.c:112
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
void cuddCacheInsert1(DdManager *table, DD_CTFP1 op, DdNode *f, DdNode *data)
Definition: cuddCache.c:323
DdNode * cuddAddCmplRecur(DdManager *dd, DdNode *f)
Definition: cuddAddIte.c:562
#define DD_ZERO(dd)
Definition: cuddInt.h:927

Variable Documentation

ABC_NAMESPACE_IMPL_START char rcsid [] DD_UNUSED = "$Id: cuddBridge.c,v 1.19 2008/04/25 06:42:55 fabio Exp $"
static

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

FileName [cuddBridge.c]

PackageName [cudd]

Synopsis [Translation from BDD to ADD and vice versa and transfer between different managers.]

Description [External procedures included in this file:

Internal procedures included in this file:

Static procedures included in this file:

]

SeeAlso []

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 101 of file cuddBridge.c.