105 static char rcsid[]
DD_UNUSED =
"$Id: cuddPriority.c,v 1.33 2009/02/20 02:14:58 fabio Exp $";
194 if (Pi != NULL)
return(NULL);
201 for (i = 0; i < n; i++) {
204 if (z[i] == NULL)
goto endgame;
210 Pi = Pifunc(dd,n,x,y,z);
211 if (Pi == NULL)
goto endgame;
219 for (i = n - 1; i >= 0; i--) {
222 if (tmpp == NULL)
goto endgame;
230 if (Rxz == NULL)
goto endgame;
292 if (u == NULL)
return(NULL);
296 for (i = N-2; i >= 0; i--) {
356 if (u == NULL)
return(NULL);
360 for (i = N-2; i >= 0; i--) {
423 if (v == NULL)
return(NULL);
442 for (i = N-2; i >= 0; i--) {
502 DdNode *
z1, *z2, *z3, *z4, *y1_, *y2, *x1;
510 if (y1_ == NULL)
return(NULL);
529 for (i = N-2; i >= 0; i--) {
629 DdNode *
z1, *z2, *z3, *z4, *y1_, *y2, *x1;
637 if (y1_ == NULL)
return(NULL);
656 for (i = N-2; i >= 0; i--) {
771 int invalidIndex = 1 << (N-1);
772 int index[2] = {invalidIndex, invalidIndex};
775 if (N < 0)
return(NULL);
779 if (c >= 0)
return(one);
784 if ((1 << N) - 1 < c)
return(zero);
785 else if ((-(1 << N) + 1) >= c)
return(one);
788 for (i = 1; i <= N; i++) {
789 int kTrueLower, kFalseLower;
790 int leftChild, middleChild, rightChild;
791 DdNode *g0, *g1, *fplus, *fequal, *fminus;
793 DdNode *newMap[2] = {NULL};
797 kFalseLower = kFalse;
799 kTrue = ((c-1) >> i) + ((c & mask) != 1) + 1;
800 mask = (mask << 1) | 1;
802 kFalse = (c >> i) - 1;
803 newIndex[0] = invalidIndex;
804 newIndex[1] = invalidIndex;
806 for (j = kFalse + 1; j < kTrue; j++) {
808 if ((j >= (1 << (N - i))) || (j <= -(1 << (N -i))))
continue;
811 leftChild = (j << 1) - 1;
812 if (leftChild >= kTrueLower) {
814 }
else if (leftChild <= kFalseLower) {
817 assert(leftChild == index[0] || leftChild == index[1]);
818 if (leftChild == index[0]) {
826 middleChild = j << 1;
827 if (middleChild >= kTrueLower) {
829 }
else if (middleChild <= kFalseLower) {
832 assert(middleChild == index[0] || middleChild == index[1]);
833 if (middleChild == index[0]) {
841 rightChild = (j << 1) + 1;
842 if (rightChild >= kTrueLower) {
844 }
else if (rightChild <= kFalseLower) {
847 assert(rightChild == index[0] || rightChild == index[1]);
848 if (rightChild == index[0]) {
890 assert(newIndex[0] == invalidIndex || newIndex[1] == invalidIndex);
891 if (newIndex[0] == invalidIndex) {
905 index[0] = newIndex[0];
906 index[1] = newIndex[1];
960 int invalidIndex = 1 << (N-1);
961 int index[2] = {invalidIndex, invalidIndex};
964 if (N < 0)
return(NULL);
968 if (c != 0)
return(one);
973 if ((1 << N) - 1 < c || (-(1 << N) + 1) > c)
return(one);
976 for (i = 1; i <= N; i++) {
977 int kTrueLbLower, kTrueUbLower;
978 int leftChild, middleChild, rightChild;
979 DdNode *g0, *g1, *fplus, *fequal, *fminus;
981 DdNode *newMap[2] = {NULL};
984 kTrueLbLower = kTrueLb;
985 kTrueUbLower = kTrueUb;
987 kTrueLb = ((c-1) >> i) + 2;
989 kTrueUb = ((c+1) >> i) + (((c+2) & mask) != 1) - 2;
990 mask = (mask << 1) | 1;
991 newIndex[0] = invalidIndex;
992 newIndex[1] = invalidIndex;
994 for (j = kTrueUb + 1; j < kTrueLb; j++) {
996 if ((j >= (1 << (N - i))) || (j <= -(1 << (N -i))))
continue;
999 leftChild = (j << 1) - 1;
1000 if (leftChild >= kTrueLbLower || leftChild <= kTrueUbLower) {
1002 }
else if (i == 1 && leftChild == kFalse) {
1005 assert(leftChild == index[0] || leftChild == index[1]);
1006 if (leftChild == index[0]) {
1014 middleChild = j << 1;
1015 if (middleChild >= kTrueLbLower || middleChild <= kTrueUbLower) {
1017 }
else if (i == 1 && middleChild == kFalse) {
1020 assert(middleChild == index[0] || middleChild == index[1]);
1021 if (middleChild == index[0]) {
1029 rightChild = (j << 1) + 1;
1030 if (rightChild >= kTrueLbLower || rightChild <= kTrueUbLower) {
1032 }
else if (i == 1 && rightChild == kFalse) {
1035 assert(rightChild == index[0] || rightChild == index[1]);
1036 if (rightChild == index[0]) {
1078 assert(newIndex[0] == invalidIndex || newIndex[1] == invalidIndex);
1079 if (newIndex[0] == invalidIndex) {
1093 index[0] = newIndex[0];
1094 index[1] = newIndex[1];
1125 unsigned int lowerB ,
1126 unsigned int upperB )
1141 for (i = N-1; i >= 0; i--) {
1144 lowerB&1 ? rl : one,
1145 lowerB&1 ? zero : rl);
1156 upperB&1 ? ru : zero,
1157 upperB&1 ? one : ru);
1209 (void) fprintf(dd->
err,
1210 "Error: The third argument of Cudd_CProjection should be a cube\n");
1219 if (support == NULL)
return(NULL);
1268 for (i = 0; i < nVars; i++) {
1270 if (tempBdd == NULL) {
1276 if (tempAdd == NULL) {
1329 if (table == NULL) {
1373 if (res == NULL)
return(NULL);
1381 if (acube == NULL) {
1400 *distance = (int) rdist;
1431 DdNode *res, *res1, *res2, *resA;
1432 DdNode *r, *y, *RT, *RE, *YT, *YE, *Yrest, *Ra, *Ran, *Gamma, *Alpha;
1433 unsigned int topR, topY, top, index = 0;
1437 if (Y == one)
return(R);
1446 if (res != NULL)
return(res);
1453 top =
ddMin(topR, topY);
1473 if (res1 == NULL)
return(NULL);
1506 Alpha = dd->
vars[index];
1512 if (Gamma == NULL)
return(NULL);
1515 if (res1 == NULL)
return(NULL);
1523 }
else if (Gamma ==
Cudd_Not(one)) {
1525 if (res1 == NULL)
return(NULL);
1652 DdNode *res, *F, *G, *ft, *fe, *gt, *ge, *tt, *ee;
1653 DdNode *ctt, *cee, *cte, *cet;
1658 unsigned int topf, topg, index;
1661 if (bound < (
int)(f ==
Cudd_Not(g)))
return(azero);
1663 if (g == lzero || f == lzero)
return(azero);
1664 if (f == one && g == one)
return(one);
1669 if (F->
ref != 1 || G->
ref != 1) {
1671 if (res != NULL)
return(res);
1703 if (tt == NULL)
return(NULL);
1713 bound =
ddMin(bound,minD);
1729 minD =
ddMin(dtt, dee);
1732 if (minD > 0 && topf == topg) {
1750 minD =
ddMin(minD, dte);
1758 if (minD > 0 && topf == topg) {
1778 minD =
ddMin(minD, det);
1786 if (dtt == dee && ctt == cee) {
1791 }
else if (minD == dee) {
1793 }
else if (minD == dte) {
1819 if ((F->
ref != 1 || G->
ref != 1) && res != azero)
1870 if (upperBound == 0)
return(0);
1884 if (res->
ref == 0) {
1895 if (minterm[F->
index] == 0) {
1908 h =
ddMin(hT, hE + 1);
1947 *distance = (f ==
DD_ONE(dd)) ? 0.0 :
1959 *distance = -
cuddV(t);
2002 if (constant == NULL)
return(NULL);
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
DdNode * Cudd_Disequality(DdManager *dd, int N, int c, DdNode **x, DdNode **y)
DdNode * cuddBddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube)
DdNode * Cudd_bddClosestCube(DdManager *dd, DdNode *f, DdNode *g, int *distance)
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
DdNode * Cudd_addHamming(DdManager *dd, DdNode **xVars, DdNode **yVars, int nVars)
int Cudd_MinHammingDist(DdManager *dd, DdNode *f, int *minterm, int upperBound)
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
DdNode * Cudd_Inequality(DdManager *dd, int N, int c, DdNode **x, DdNode **y)
DdNode * Cudd_PrioritySelect(DdManager *dd, DdNode *R, DdNode **x, DdNode **y, DdNode **z, DdNode *Pi, int n, DD_PRFP Pifunc)
DdNode * Cudd_Support(DdManager *dd, DdNode *f)
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
DdNode * Cudd_Xeqy(DdManager *dd, int N, DdNode **x, DdNode **y)
#define Cudd_IsConstant(node)
#define Cudd_Regular(node)
int cuddCheckCube(DdManager *dd, DdNode *g)
DdNode *(* DD_CTFP)(DdManager *, DdNode *, DdNode *)
DdNode * Cudd_Xgty(DdManager *dd, int N, DdNode **z, DdNode **x, DdNode **y)
#define ABC_ALLOC(type, num)
DdNode * Cudd_addApply(DdManager *dd, DdNode *(*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g)
DdNode * Cudd_bddSwapVariables(DdManager *dd, DdNode *f, DdNode **x, DdNode **y, int n)
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
static int cuddMinHammingDistRecur(DdNode *f, int *minterm, DdHashTable *table, int upperBound)
DdNode * cuddHashTableLookup1(DdHashTable *hash, DdNode *f)
DdNode * cuddCProjectionRecur(DdManager *dd, DdNode *R, DdNode *Y, DdNode *Ysupp)
static DdNode * separateCube(DdManager *dd, DdNode *f, CUDD_VALUE_TYPE *distance)
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
#define Cudd_IsComplement(node)
void Cudd_SetEpsilon(DdManager *dd, CUDD_VALUE_TYPE ep)
static char rcsid[] DD_UNUSED
DdNode * cuddAddBddDoPattern(DdManager *dd, DdNode *f)
DdNode * Cudd_addPlus(DdManager *dd, DdNode **f, DdNode **g)
#define ABC_NAMESPACE_IMPL_END
#define cuddIsConstant(node)
DdNode * Cudd_BddToAdd(DdManager *dd, DdNode *B)
DdNode * Cudd_bddAndAbstract(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube)
void cuddHashTableQuit(DdHashTable *hash)
DdNode * Cudd_Dxygtdxz(DdManager *dd, int N, DdNode **x, DdNode **y, DdNode **z)
#define ABC_NAMESPACE_IMPL_START
DdNode * Cudd_Dxygtdyz(DdManager *dd, int N, DdNode **x, DdNode **y, DdNode **z)
DdNode * Cudd_addIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
DdNode * Cudd_addXeqy(DdManager *dd, int N, DdNode **x, DdNode **y)
int cuddHashTableInsert1(DdHashTable *hash, DdNode *f, DdNode *value, ptrint count)
DdNode * Cudd_CProjection(DdManager *dd, DdNode *R, DdNode *Y)
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize)
DdNode * cuddBddClosestCube(DdManager *dd, DdNode *f, DdNode *g, CUDD_VALUE_TYPE bound)
static DdNode * createResult(DdManager *dd, unsigned int index, unsigned int phase, DdNode *cube, CUDD_VALUE_TYPE distance)
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
CUDD_VALUE_TYPE Cudd_ReadEpsilon(DdManager *dd)
DdNode * Cudd_bddInterval(DdManager *dd, int N, DdNode **x, unsigned int lowerB, unsigned int upperB)
DdNode * cuddBddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
DdNode *(* DD_PRFP)(DdManager *, int, DdNode **, DdNode **, DdNode **)