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

Go to the source code of this file.

Functions

DdNodeCudd_zddProduct (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddUnateProduct (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddWeakDiv (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddDivide (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddWeakDivF (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddDivideF (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddComplement (DdManager *dd, DdNode *node)
 
DdNodecuddZddProduct (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodecuddZddUnateProduct (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodecuddZddWeakDiv (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodecuddZddWeakDivF (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodecuddZddDivide (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodecuddZddDivideF (DdManager *dd, DdNode *f, DdNode *g)
 
int cuddZddGetCofactors3 (DdManager *dd, DdNode *f, int v, DdNode **f1, DdNode **f0, DdNode **fd)
 
int cuddZddGetCofactors2 (DdManager *dd, DdNode *f, int v, DdNode **f1, DdNode **f0)
 
DdNodecuddZddComplement (DdManager *dd, DdNode *node)
 
int cuddZddGetPosVarIndex (DdManager *dd, int index)
 
int cuddZddGetNegVarIndex (DdManager *dd, int index)
 
int cuddZddGetPosVarLevel (DdManager *dd, int index)
 
int cuddZddGetNegVarLevel (DdManager *dd, int index)
 

Variables

static
ABC_NAMESPACE_IMPL_START char
rcsid[] 
DD_UNUSED = "$Id: cuddZddFuncs.c,v 1.16 2008/04/25 07:39:33 fabio Exp $"
 

Function Documentation

DdNode* Cudd_zddComplement ( DdManager dd,
DdNode node 
)

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

Synopsis [Computes a complement cover for a ZDD node.]

Description [Computes a complement cover for a ZDD node. For lack of a better method, we first extract the function BDD from the ZDD cover, then make the complement of the ZDD cover from the complement of the BDD node by using ISOP. Returns a pointer to the resulting cover if successful; NULL otherwise. The result depends on current variable order.]

SideEffects [The result depends on current variable order.]

SeeAlso []

Definition at line 332 of file cuddZddFuncs.c.

335 {
336  DdNode *b, *isop, *zdd_I;
337 
338  /* Check cache */
339  zdd_I = cuddCacheLookup1Zdd(dd, cuddZddComplement, node);
340  if (zdd_I)
341  return(zdd_I);
342 
343  b = Cudd_MakeBddFromZddCover(dd, node);
344  if (!b)
345  return(NULL);
346  Cudd_Ref(b);
347  isop = Cudd_zddIsop(dd, Cudd_Not(b), Cudd_Not(b), &zdd_I);
348  if (!isop) {
349  Cudd_RecursiveDeref(dd, b);
350  return(NULL);
351  }
352  Cudd_Ref(isop);
353  Cudd_Ref(zdd_I);
354  Cudd_RecursiveDeref(dd, b);
355  Cudd_RecursiveDeref(dd, isop);
356 
357  cuddCacheInsert1(dd, cuddZddComplement, node, zdd_I);
358  Cudd_Deref(zdd_I);
359  return(zdd_I);
360 } /* end of Cudd_zddComplement */
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
DdNode * Cudd_MakeBddFromZddCover(DdManager *dd, DdNode *node)
Definition: cuddZddIsop.c:203
DdNode * Cudd_zddIsop(DdManager *dd, DdNode *L, DdNode *U, DdNode **zdd_I)
Definition: cuddZddIsop.c:136
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
DdNode * cuddZddComplement(DdManager *dd, DdNode *node)
DdNode * cuddCacheLookup1Zdd(DdManager *table, DD_CTFP1 op, DdNode *f)
Definition: cuddCache.c:664
void cuddCacheInsert1(DdManager *table, DD_CTFP1 op, DdNode *f, DdNode *data)
Definition: cuddCache.c:323
DdNode* Cudd_zddDivide ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Computes the quotient of two unate covers.]

Description [Computes the quotient of two unate covers represented by ZDDs. Unate covers use one ZDD variable for each BDD variable. Returns a pointer to the resulting ZDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddWeakDiv]

Definition at line 241 of file cuddZddFuncs.c.

245 {
246  DdNode *res;
247 
248  do {
249  dd->reordered = 0;
250  res = cuddZddDivide(dd, f, g);
251  } while (dd->reordered == 1);
252  return(res);
253 
254 } /* end of Cudd_zddDivide */
DdNode * cuddZddDivide(DdManager *dd, DdNode *f, DdNode *g)
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_zddDivideF ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Modified version of Cudd_zddDivide.]

Description [Modified version of Cudd_zddDivide. This function may disappear in future releases.]

SideEffects [None]

SeeAlso []

Definition at line 299 of file cuddZddFuncs.c.

303 {
304  DdNode *res;
305 
306  do {
307  dd->reordered = 0;
308  res = cuddZddDivideF(dd, f, g);
309  } while (dd->reordered == 1);
310  return(res);
311 
312 } /* end of Cudd_zddDivideF */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddDivideF(DdManager *dd, DdNode *f, DdNode *g)
DdNode* Cudd_zddProduct ( DdManager dd,
DdNode f,
DdNode g 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Computes the product of two covers represented by ZDDs.]

Description [Computes the product of two covers represented by ZDDs. The result is also a ZDD. Returns a pointer to the result if successful; NULL otherwise. The covers on which Cudd_zddProduct operates use two ZDD variables for each function variable (one ZDD variable for each literal of the variable). Those two ZDD variables should be adjacent in the order.]

SideEffects [None]

SeeAlso [Cudd_zddUnateProduct]

Definition at line 145 of file cuddZddFuncs.c.

149 {
150  DdNode *res;
151 
152  do {
153  dd->reordered = 0;
154  res = cuddZddProduct(dd, f, g);
155  } while (dd->reordered == 1);
156  return(res);
157 
158 } /* end of Cudd_zddProduct */
Definition: cudd.h:278
DdNode * cuddZddProduct(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:380
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_zddUnateProduct ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Computes the product of two unate covers.]

Description [Computes the product of two unate covers represented as ZDDs. Unate covers use one ZDD variable for each BDD variable. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddProduct]

Definition at line 176 of file cuddZddFuncs.c.

180 {
181  DdNode *res;
182 
183  do {
184  dd->reordered = 0;
185  res = cuddZddUnateProduct(dd, f, g);
186  } while (dd->reordered == 1);
187  return(res);
188 
189 } /* end of Cudd_zddUnateProduct */
Definition: cudd.h:278
DdNode * cuddZddUnateProduct(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:617
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_zddWeakDiv ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Applies weak division to two covers.]

Description [Applies weak division to two ZDDs representing two covers. Returns a pointer to the ZDD representing the result if successful; NULL otherwise. The result of weak division depends on the variable order. The covers on which Cudd_zddWeakDiv operates use two ZDD variables for each function variable (one ZDD variable for each literal of the variable). Those two ZDD variables should be adjacent in the order.]

SideEffects [None]

SeeAlso [Cudd_zddDivide]

Definition at line 210 of file cuddZddFuncs.c.

214 {
215  DdNode *res;
216 
217  do {
218  dd->reordered = 0;
219  res = cuddZddWeakDiv(dd, f, g);
220  } while (dd->reordered == 1);
221  return(res);
222 
223 } /* end of Cudd_zddWeakDiv */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddWeakDiv(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:761
DdNode* Cudd_zddWeakDivF ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Modified version of Cudd_zddWeakDiv.]

Description [Modified version of Cudd_zddWeakDiv. This function may disappear in future releases.]

SideEffects [None]

SeeAlso [Cudd_zddWeakDiv]

Definition at line 270 of file cuddZddFuncs.c.

274 {
275  DdNode *res;
276 
277  do {
278  dd->reordered = 0;
279  res = cuddZddWeakDivF(dd, f, g);
280  } while (dd->reordered == 1);
281  return(res);
282 
283 } /* end of Cudd_zddWeakDivF */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddWeakDivF(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:922
DdNode* cuddZddComplement ( DdManager dd,
DdNode node 
)

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

Synopsis [Computes a complement of a ZDD node.]

Description [Computes the complement of a ZDD node. So far, since we couldn't find a direct way to get the complement of a ZDD cover, we first convert a ZDD cover to a BDD, then make the complement of the ZDD cover from the complement of the BDD node by using ISOP.]

SideEffects [The result depends on current variable order.]

SeeAlso []

Definition at line 1522 of file cuddZddFuncs.c.

1525 {
1526  DdNode *b, *isop, *zdd_I;
1527 
1528  /* Check cache */
1529  zdd_I = cuddCacheLookup1Zdd(dd, cuddZddComplement, node);
1530  if (zdd_I)
1531  return(zdd_I);
1532 
1533  b = cuddMakeBddFromZddCover(dd, node);
1534  if (!b)
1535  return(NULL);
1536  cuddRef(b);
1537  isop = cuddZddIsop(dd, Cudd_Not(b), Cudd_Not(b), &zdd_I);
1538  if (!isop) {
1539  Cudd_RecursiveDeref(dd, b);
1540  return(NULL);
1541  }
1542  cuddRef(isop);
1543  cuddRef(zdd_I);
1544  Cudd_RecursiveDeref(dd, b);
1545  Cudd_RecursiveDeref(dd, isop);
1546 
1547  cuddCacheInsert1(dd, cuddZddComplement, node, zdd_I);
1548  cuddDeref(zdd_I);
1549  return(zdd_I);
1550 } /* end of cuddZddComplement */
#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
DdNode * cuddZddIsop(DdManager *dd, DdNode *L, DdNode *U, DdNode **zdd_I)
Definition: cuddZddIsop.c:234
DdNode * cuddMakeBddFromZddCover(DdManager *dd, DdNode *node)
Definition: cuddZddIsop.c:800
DdNode * cuddZddComplement(DdManager *dd, DdNode *node)
DdNode * cuddCacheLookup1Zdd(DdManager *table, DD_CTFP1 op, DdNode *f)
Definition: cuddCache.c:664
void cuddCacheInsert1(DdManager *table, DD_CTFP1 op, DdNode *f, DdNode *data)
Definition: cuddCache.c:323
DdNode* cuddZddDivide ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Performs the recursive step of Cudd_zddDivide.]

Description []

SideEffects [None]

SeeAlso [Cudd_zddDivide]

Definition at line 1159 of file cuddZddFuncs.c.

1163 {
1164  int v;
1165  DdNode *one = DD_ONE(dd);
1166  DdNode *zero = DD_ZERO(dd);
1167  DdNode *f0, *f1, *g0, *g1;
1168  DdNode *q, *r, *tmp;
1169  int flag;
1170 
1171  statLine(dd);
1172  if (g == one)
1173  return(f);
1174  if (f == zero || f == one)
1175  return(zero);
1176  if (f == g)
1177  return(one);
1178 
1179  /* Check cache. */
1180  r = cuddCacheLookup2Zdd(dd, cuddZddDivide, f, g);
1181  if (r)
1182  return(r);
1183 
1184  v = g->index;
1185 
1186  flag = cuddZddGetCofactors2(dd, f, v, &f1, &f0);
1187  if (flag == 1)
1188  return(NULL);
1189  Cudd_Ref(f1);
1190  Cudd_Ref(f0);
1191  flag = cuddZddGetCofactors2(dd, g, v, &g1, &g0); /* g1 != zero */
1192  if (flag == 1) {
1193  Cudd_RecursiveDerefZdd(dd, f1);
1194  Cudd_RecursiveDerefZdd(dd, f0);
1195  return(NULL);
1196  }
1197  Cudd_Ref(g1);
1198  Cudd_Ref(g0);
1199 
1200  r = cuddZddDivide(dd, f1, g1);
1201  if (r == NULL) {
1202  Cudd_RecursiveDerefZdd(dd, f1);
1203  Cudd_RecursiveDerefZdd(dd, f0);
1204  Cudd_RecursiveDerefZdd(dd, g1);
1205  Cudd_RecursiveDerefZdd(dd, g0);
1206  return(NULL);
1207  }
1208  Cudd_Ref(r);
1209 
1210  if (r != zero && g0 != zero) {
1211  tmp = r;
1212  q = cuddZddDivide(dd, f0, g0);
1213  if (q == NULL) {
1214  Cudd_RecursiveDerefZdd(dd, f1);
1215  Cudd_RecursiveDerefZdd(dd, f0);
1216  Cudd_RecursiveDerefZdd(dd, g1);
1217  Cudd_RecursiveDerefZdd(dd, g0);
1218  return(NULL);
1219  }
1220  Cudd_Ref(q);
1221  r = cuddZddIntersect(dd, r, q);
1222  if (r == NULL) {
1223  Cudd_RecursiveDerefZdd(dd, f1);
1224  Cudd_RecursiveDerefZdd(dd, f0);
1225  Cudd_RecursiveDerefZdd(dd, g1);
1226  Cudd_RecursiveDerefZdd(dd, g0);
1227  Cudd_RecursiveDerefZdd(dd, q);
1228  return(NULL);
1229  }
1230  Cudd_Ref(r);
1231  Cudd_RecursiveDerefZdd(dd, q);
1232  Cudd_RecursiveDerefZdd(dd, tmp);
1233  }
1234 
1235  Cudd_RecursiveDerefZdd(dd, f1);
1236  Cudd_RecursiveDerefZdd(dd, f0);
1237  Cudd_RecursiveDerefZdd(dd, g1);
1238  Cudd_RecursiveDerefZdd(dd, g0);
1239 
1240  cuddCacheInsert2(dd, cuddZddDivide, f, g, r);
1241  Cudd_Deref(r);
1242  return(r);
1243 
1244 } /* end of cuddZddDivide */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
DdNode * cuddZddDivide(DdManager *dd, DdNode *f, DdNode *g)
Definition: cudd.h:278
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
int cuddZddGetCofactors2(DdManager *dd, DdNode *f, int v, DdNode **f1, DdNode **f0)
#define statLine(dd)
Definition: cuddInt.h:1037
static DdNode * one
Definition: cuddDecomp.c:112
DdNode * cuddZddIntersect(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:642
DdHalfWord index
Definition: cudd.h:279
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddZddDivideF ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Performs the recursive step of Cudd_zddDivideF.]

Description []

SideEffects [None]

SeeAlso [Cudd_zddDivideF]

Definition at line 1259 of file cuddZddFuncs.c.

1263 {
1264  int v;
1265  DdNode *one = DD_ONE(dd);
1266  DdNode *zero = DD_ZERO(dd);
1267  DdNode *f0, *f1, *g0, *g1;
1268  DdNode *q, *r, *tmp;
1269  int flag;
1270 
1271  statLine(dd);
1272  if (g == one)
1273  return(f);
1274  if (f == zero || f == one)
1275  return(zero);
1276  if (f == g)
1277  return(one);
1278 
1279  /* Check cache. */
1280  r = cuddCacheLookup2Zdd(dd, cuddZddDivideF, f, g);
1281  if (r)
1282  return(r);
1283 
1284  v = g->index;
1285 
1286  flag = cuddZddGetCofactors2(dd, f, v, &f1, &f0);
1287  if (flag == 1)
1288  return(NULL);
1289  Cudd_Ref(f1);
1290  Cudd_Ref(f0);
1291  flag = cuddZddGetCofactors2(dd, g, v, &g1, &g0); /* g1 != zero */
1292  if (flag == 1) {
1293  Cudd_RecursiveDerefZdd(dd, f1);
1294  Cudd_RecursiveDerefZdd(dd, f0);
1295  return(NULL);
1296  }
1297  Cudd_Ref(g1);
1298  Cudd_Ref(g0);
1299 
1300  r = cuddZddDivideF(dd, f1, g1);
1301  if (r == NULL) {
1302  Cudd_RecursiveDerefZdd(dd, f1);
1303  Cudd_RecursiveDerefZdd(dd, f0);
1304  Cudd_RecursiveDerefZdd(dd, g1);
1305  Cudd_RecursiveDerefZdd(dd, g0);
1306  return(NULL);
1307  }
1308  Cudd_Ref(r);
1309 
1310  if (r != zero && g0 != zero) {
1311  tmp = r;
1312  q = cuddZddDivideF(dd, f0, g0);
1313  if (q == NULL) {
1314  Cudd_RecursiveDerefZdd(dd, f1);
1315  Cudd_RecursiveDerefZdd(dd, f0);
1316  Cudd_RecursiveDerefZdd(dd, g1);
1317  Cudd_RecursiveDerefZdd(dd, g0);
1318  return(NULL);
1319  }
1320  Cudd_Ref(q);
1321  r = cuddZddIntersect(dd, r, q);
1322  if (r == NULL) {
1323  Cudd_RecursiveDerefZdd(dd, f1);
1324  Cudd_RecursiveDerefZdd(dd, f0);
1325  Cudd_RecursiveDerefZdd(dd, g1);
1326  Cudd_RecursiveDerefZdd(dd, g0);
1327  Cudd_RecursiveDerefZdd(dd, q);
1328  return(NULL);
1329  }
1330  Cudd_Ref(r);
1331  Cudd_RecursiveDerefZdd(dd, q);
1332  Cudd_RecursiveDerefZdd(dd, tmp);
1333  }
1334 
1335  Cudd_RecursiveDerefZdd(dd, f1);
1336  Cudd_RecursiveDerefZdd(dd, f0);
1337  Cudd_RecursiveDerefZdd(dd, g1);
1338  Cudd_RecursiveDerefZdd(dd, g0);
1339 
1340  cuddCacheInsert2(dd, cuddZddDivideF, f, g, r);
1341  Cudd_Deref(r);
1342  return(r);
1343 
1344 } /* end of cuddZddDivideF */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
Definition: cudd.h:278
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
int cuddZddGetCofactors2(DdManager *dd, DdNode *f, int v, DdNode **f1, DdNode **f0)
#define statLine(dd)
Definition: cuddInt.h:1037
static DdNode * one
Definition: cuddDecomp.c:112
DdNode * cuddZddIntersect(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:642
DdHalfWord index
Definition: cudd.h:279
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddZddDivideF(DdManager *dd, DdNode *f, DdNode *g)
static DdNode * zero
Definition: cuddApa.c:100
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int cuddZddGetCofactors2 ( DdManager dd,
DdNode f,
int  v,
DdNode **  f1,
DdNode **  f0 
)

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

Synopsis [Computes the two-way decomposition of f w.r.t. v.]

Description []

SideEffects [The results are returned in f1 and f0.]

SeeAlso [cuddZddGetCofactors3]

Definition at line 1487 of file cuddZddFuncs.c.

1493 {
1494  *f1 = cuddZddSubset1(dd, f, v);
1495  if (*f1 == NULL)
1496  return(1);
1497  *f0 = cuddZddSubset0(dd, f, v);
1498  if (*f0 == NULL) {
1499  Cudd_RecursiveDerefZdd(dd, *f1);
1500  return(1);
1501  }
1502  return(0);
1503 
1504 } /* end of cuddZddGetCofactors2 */
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
DdNode * cuddZddSubset1(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:874
DdNode * cuddZddSubset0(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:923
int cuddZddGetCofactors3 ( DdManager dd,
DdNode f,
int  v,
DdNode **  f1,
DdNode **  f0,
DdNode **  fd 
)

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

Synopsis [Computes the three-way decomposition of f w.r.t. v.]

Description [Computes the three-way decomposition of function f (represented by a ZDD) wit respect to variable v. Returns 0 if successful; 1 otherwise.]

SideEffects [The results are returned in f1, f0, and fd.]

SeeAlso [cuddZddGetCofactors2]

Definition at line 1360 of file cuddZddFuncs.c.

1367 {
1368  DdNode *pc, *nc;
1369  DdNode *zero = DD_ZERO(dd);
1370  int top, hv, ht, pv, nv;
1371  int level;
1372 
1373  top = dd->permZ[f->index];
1374  level = dd->permZ[v];
1375  hv = level >> 1;
1376  ht = top >> 1;
1377 
1378  if (hv < ht) {
1379  *f1 = zero;
1380  *f0 = zero;
1381  *fd = f;
1382  }
1383  else {
1384  pv = cuddZddGetPosVarIndex(dd, v);
1385  nv = cuddZddGetNegVarIndex(dd, v);
1386 
1387  /* not to create intermediate ZDD node */
1388  if (cuddZddGetPosVarLevel(dd, v) < cuddZddGetNegVarLevel(dd, v)) {
1389  pc = cuddZddSubset1(dd, f, pv);
1390  if (pc == NULL)
1391  return(1);
1392  Cudd_Ref(pc);
1393  nc = cuddZddSubset0(dd, f, pv);
1394  if (nc == NULL) {
1395  Cudd_RecursiveDerefZdd(dd, pc);
1396  return(1);
1397  }
1398  Cudd_Ref(nc);
1399 
1400  *f1 = cuddZddSubset0(dd, pc, nv);
1401  if (*f1 == NULL) {
1402  Cudd_RecursiveDerefZdd(dd, pc);
1403  Cudd_RecursiveDerefZdd(dd, nc);
1404  return(1);
1405  }
1406  Cudd_Ref(*f1);
1407  *f0 = cuddZddSubset1(dd, nc, nv);
1408  if (*f0 == NULL) {
1409  Cudd_RecursiveDerefZdd(dd, pc);
1410  Cudd_RecursiveDerefZdd(dd, nc);
1411  Cudd_RecursiveDerefZdd(dd, *f1);
1412  return(1);
1413  }
1414  Cudd_Ref(*f0);
1415 
1416  *fd = cuddZddSubset0(dd, nc, nv);
1417  if (*fd == NULL) {
1418  Cudd_RecursiveDerefZdd(dd, pc);
1419  Cudd_RecursiveDerefZdd(dd, nc);
1420  Cudd_RecursiveDerefZdd(dd, *f1);
1421  Cudd_RecursiveDerefZdd(dd, *f0);
1422  return(1);
1423  }
1424  Cudd_Ref(*fd);
1425  } else {
1426  pc = cuddZddSubset1(dd, f, nv);
1427  if (pc == NULL)
1428  return(1);
1429  Cudd_Ref(pc);
1430  nc = cuddZddSubset0(dd, f, nv);
1431  if (nc == NULL) {
1432  Cudd_RecursiveDerefZdd(dd, pc);
1433  return(1);
1434  }
1435  Cudd_Ref(nc);
1436 
1437  *f0 = cuddZddSubset0(dd, pc, pv);
1438  if (*f0 == NULL) {
1439  Cudd_RecursiveDerefZdd(dd, pc);
1440  Cudd_RecursiveDerefZdd(dd, nc);
1441  return(1);
1442  }
1443  Cudd_Ref(*f0);
1444  *f1 = cuddZddSubset1(dd, nc, pv);
1445  if (*f1 == NULL) {
1446  Cudd_RecursiveDerefZdd(dd, pc);
1447  Cudd_RecursiveDerefZdd(dd, nc);
1448  Cudd_RecursiveDerefZdd(dd, *f0);
1449  return(1);
1450  }
1451  Cudd_Ref(*f1);
1452 
1453  *fd = cuddZddSubset0(dd, nc, pv);
1454  if (*fd == NULL) {
1455  Cudd_RecursiveDerefZdd(dd, pc);
1456  Cudd_RecursiveDerefZdd(dd, nc);
1457  Cudd_RecursiveDerefZdd(dd, *f1);
1458  Cudd_RecursiveDerefZdd(dd, *f0);
1459  return(1);
1460  }
1461  Cudd_Ref(*fd);
1462  }
1463 
1464  Cudd_RecursiveDerefZdd(dd, pc);
1465  Cudd_RecursiveDerefZdd(dd, nc);
1466  Cudd_Deref(*f1);
1467  Cudd_Deref(*f0);
1468  Cudd_Deref(*fd);
1469  }
1470  return(0);
1471 
1472 } /* end of cuddZddGetCofactors3 */
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
Definition: cudd.h:278
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
int * permZ
Definition: cuddInt.h:387
int cuddZddGetPosVarLevel(DdManager *dd, int index)
int cuddZddGetNegVarIndex(DdManager *dd, int index)
int cuddZddGetPosVarIndex(DdManager *dd, int index)
DdNode * cuddZddSubset1(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:874
int cuddZddGetNegVarLevel(DdManager *dd, int index)
DdHalfWord index
Definition: cudd.h:279
DdNode * cuddZddSubset0(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:923
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
static DdNode * zero
Definition: cuddApa.c:100
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int cuddZddGetNegVarIndex ( DdManager dd,
int  index 
)

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

Synopsis [Returns the index of negative ZDD variable.]

Description [Returns the index of negative ZDD variable.]

SideEffects []

SeeAlso []

Definition at line 1586 of file cuddZddFuncs.c.

1589 {
1590  int nv = index | 0x1;
1591  return(nv);
1592 } /* end of cuddZddGetPosVarIndex */
int cuddZddGetNegVarLevel ( DdManager dd,
int  index 
)

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

Synopsis [Returns the level of negative ZDD variable.]

Description [Returns the level of negative ZDD variable.]

SideEffects []

SeeAlso []

Definition at line 1628 of file cuddZddFuncs.c.

1631 {
1632  int nv = cuddZddGetNegVarIndex(dd, index);
1633  return(dd->permZ[nv]);
1634 } /* end of cuddZddGetNegVarLevel */
int * permZ
Definition: cuddInt.h:387
int cuddZddGetNegVarIndex(DdManager *dd, int index)
int cuddZddGetPosVarIndex ( DdManager dd,
int  index 
)

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

Synopsis [Returns the index of positive ZDD variable.]

Description [Returns the index of positive ZDD variable.]

SideEffects []

SeeAlso []

Definition at line 1565 of file cuddZddFuncs.c.

1568 {
1569  int pv = (index >> 1) << 1;
1570  return(pv);
1571 } /* end of cuddZddGetPosVarIndex */
int cuddZddGetPosVarLevel ( DdManager dd,
int  index 
)

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

Synopsis [Returns the level of positive ZDD variable.]

Description [Returns the level of positive ZDD variable.]

SideEffects []

SeeAlso []

Definition at line 1607 of file cuddZddFuncs.c.

1610 {
1611  int pv = cuddZddGetPosVarIndex(dd, index);
1612  return(dd->permZ[pv]);
1613 } /* end of cuddZddGetPosVarLevel */
int * permZ
Definition: cuddInt.h:387
int cuddZddGetPosVarIndex(DdManager *dd, int index)
DdNode* cuddZddProduct ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Performs the recursive step of Cudd_zddProduct.]

Description []

SideEffects [None]

SeeAlso [Cudd_zddProduct]

Definition at line 380 of file cuddZddFuncs.c.

384 {
385  int v, top_f, top_g;
386  DdNode *tmp, *term1, *term2, *term3;
387  DdNode *f0, *f1, *fd, *g0, *g1, *gd;
388  DdNode *R0, *R1, *Rd, *N0, *N1;
389  DdNode *r;
390  DdNode *one = DD_ONE(dd);
391  DdNode *zero = DD_ZERO(dd);
392  int flag;
393  int pv, nv;
394 
395  statLine(dd);
396  if (f == zero || g == zero)
397  return(zero);
398  if (f == one)
399  return(g);
400  if (g == one)
401  return(f);
402 
403  top_f = dd->permZ[f->index];
404  top_g = dd->permZ[g->index];
405 
406  if (top_f > top_g)
407  return(cuddZddProduct(dd, g, f));
408 
409  /* Check cache */
410  r = cuddCacheLookup2Zdd(dd, cuddZddProduct, f, g);
411  if (r)
412  return(r);
413 
414  v = f->index; /* either yi or zi */
415  flag = cuddZddGetCofactors3(dd, f, v, &f1, &f0, &fd);
416  if (flag == 1)
417  return(NULL);
418  Cudd_Ref(f1);
419  Cudd_Ref(f0);
420  Cudd_Ref(fd);
421  flag = cuddZddGetCofactors3(dd, g, v, &g1, &g0, &gd);
422  if (flag == 1) {
423  Cudd_RecursiveDerefZdd(dd, f1);
424  Cudd_RecursiveDerefZdd(dd, f0);
425  Cudd_RecursiveDerefZdd(dd, fd);
426  return(NULL);
427  }
428  Cudd_Ref(g1);
429  Cudd_Ref(g0);
430  Cudd_Ref(gd);
431  pv = cuddZddGetPosVarIndex(dd, v);
432  nv = cuddZddGetNegVarIndex(dd, v);
433 
434  Rd = cuddZddProduct(dd, fd, gd);
435  if (Rd == NULL) {
436  Cudd_RecursiveDerefZdd(dd, f1);
437  Cudd_RecursiveDerefZdd(dd, f0);
438  Cudd_RecursiveDerefZdd(dd, fd);
439  Cudd_RecursiveDerefZdd(dd, g1);
440  Cudd_RecursiveDerefZdd(dd, g0);
441  Cudd_RecursiveDerefZdd(dd, gd);
442  return(NULL);
443  }
444  Cudd_Ref(Rd);
445 
446  term1 = cuddZddProduct(dd, f0, g0);
447  if (term1 == NULL) {
448  Cudd_RecursiveDerefZdd(dd, f1);
449  Cudd_RecursiveDerefZdd(dd, f0);
450  Cudd_RecursiveDerefZdd(dd, fd);
451  Cudd_RecursiveDerefZdd(dd, g1);
452  Cudd_RecursiveDerefZdd(dd, g0);
453  Cudd_RecursiveDerefZdd(dd, gd);
454  Cudd_RecursiveDerefZdd(dd, Rd);
455  return(NULL);
456  }
457  Cudd_Ref(term1);
458  term2 = cuddZddProduct(dd, f0, gd);
459  if (term2 == NULL) {
460  Cudd_RecursiveDerefZdd(dd, f1);
461  Cudd_RecursiveDerefZdd(dd, f0);
462  Cudd_RecursiveDerefZdd(dd, fd);
463  Cudd_RecursiveDerefZdd(dd, g1);
464  Cudd_RecursiveDerefZdd(dd, g0);
465  Cudd_RecursiveDerefZdd(dd, gd);
466  Cudd_RecursiveDerefZdd(dd, Rd);
467  Cudd_RecursiveDerefZdd(dd, term1);
468  return(NULL);
469  }
470  Cudd_Ref(term2);
471  term3 = cuddZddProduct(dd, fd, g0);
472  if (term3 == NULL) {
473  Cudd_RecursiveDerefZdd(dd, f1);
474  Cudd_RecursiveDerefZdd(dd, f0);
475  Cudd_RecursiveDerefZdd(dd, fd);
476  Cudd_RecursiveDerefZdd(dd, g1);
477  Cudd_RecursiveDerefZdd(dd, g0);
478  Cudd_RecursiveDerefZdd(dd, gd);
479  Cudd_RecursiveDerefZdd(dd, Rd);
480  Cudd_RecursiveDerefZdd(dd, term1);
481  Cudd_RecursiveDerefZdd(dd, term2);
482  return(NULL);
483  }
484  Cudd_Ref(term3);
485  Cudd_RecursiveDerefZdd(dd, f0);
486  Cudd_RecursiveDerefZdd(dd, g0);
487  tmp = cuddZddUnion(dd, term1, term2);
488  if (tmp == NULL) {
489  Cudd_RecursiveDerefZdd(dd, f1);
490  Cudd_RecursiveDerefZdd(dd, fd);
491  Cudd_RecursiveDerefZdd(dd, g1);
492  Cudd_RecursiveDerefZdd(dd, gd);
493  Cudd_RecursiveDerefZdd(dd, Rd);
494  Cudd_RecursiveDerefZdd(dd, term1);
495  Cudd_RecursiveDerefZdd(dd, term2);
496  Cudd_RecursiveDerefZdd(dd, term3);
497  return(NULL);
498  }
499  Cudd_Ref(tmp);
500  Cudd_RecursiveDerefZdd(dd, term1);
501  Cudd_RecursiveDerefZdd(dd, term2);
502  R0 = cuddZddUnion(dd, tmp, term3);
503  if (R0 == NULL) {
504  Cudd_RecursiveDerefZdd(dd, f1);
505  Cudd_RecursiveDerefZdd(dd, fd);
506  Cudd_RecursiveDerefZdd(dd, g1);
507  Cudd_RecursiveDerefZdd(dd, gd);
508  Cudd_RecursiveDerefZdd(dd, Rd);
509  Cudd_RecursiveDerefZdd(dd, term3);
510  Cudd_RecursiveDerefZdd(dd, tmp);
511  return(NULL);
512  }
513  Cudd_Ref(R0);
514  Cudd_RecursiveDerefZdd(dd, tmp);
515  Cudd_RecursiveDerefZdd(dd, term3);
516  N0 = cuddZddGetNode(dd, nv, R0, Rd); /* nv = zi */
517  if (N0 == NULL) {
518  Cudd_RecursiveDerefZdd(dd, f1);
519  Cudd_RecursiveDerefZdd(dd, fd);
520  Cudd_RecursiveDerefZdd(dd, g1);
521  Cudd_RecursiveDerefZdd(dd, gd);
522  Cudd_RecursiveDerefZdd(dd, Rd);
523  Cudd_RecursiveDerefZdd(dd, R0);
524  return(NULL);
525  }
526  Cudd_Ref(N0);
527  Cudd_RecursiveDerefZdd(dd, R0);
528  Cudd_RecursiveDerefZdd(dd, Rd);
529 
530  term1 = cuddZddProduct(dd, f1, g1);
531  if (term1 == NULL) {
532  Cudd_RecursiveDerefZdd(dd, f1);
533  Cudd_RecursiveDerefZdd(dd, fd);
534  Cudd_RecursiveDerefZdd(dd, g1);
535  Cudd_RecursiveDerefZdd(dd, gd);
536  Cudd_RecursiveDerefZdd(dd, N0);
537  return(NULL);
538  }
539  Cudd_Ref(term1);
540  term2 = cuddZddProduct(dd, f1, gd);
541  if (term2 == NULL) {
542  Cudd_RecursiveDerefZdd(dd, f1);
543  Cudd_RecursiveDerefZdd(dd, fd);
544  Cudd_RecursiveDerefZdd(dd, g1);
545  Cudd_RecursiveDerefZdd(dd, gd);
546  Cudd_RecursiveDerefZdd(dd, N0);
547  Cudd_RecursiveDerefZdd(dd, term1);
548  return(NULL);
549  }
550  Cudd_Ref(term2);
551  term3 = cuddZddProduct(dd, fd, g1);
552  if (term3 == NULL) {
553  Cudd_RecursiveDerefZdd(dd, f1);
554  Cudd_RecursiveDerefZdd(dd, fd);
555  Cudd_RecursiveDerefZdd(dd, g1);
556  Cudd_RecursiveDerefZdd(dd, gd);
557  Cudd_RecursiveDerefZdd(dd, N0);
558  Cudd_RecursiveDerefZdd(dd, term1);
559  Cudd_RecursiveDerefZdd(dd, term2);
560  return(NULL);
561  }
562  Cudd_Ref(term3);
563  Cudd_RecursiveDerefZdd(dd, f1);
564  Cudd_RecursiveDerefZdd(dd, g1);
565  Cudd_RecursiveDerefZdd(dd, fd);
566  Cudd_RecursiveDerefZdd(dd, gd);
567  tmp = cuddZddUnion(dd, term1, term2);
568  if (tmp == NULL) {
569  Cudd_RecursiveDerefZdd(dd, N0);
570  Cudd_RecursiveDerefZdd(dd, term1);
571  Cudd_RecursiveDerefZdd(dd, term2);
572  Cudd_RecursiveDerefZdd(dd, term3);
573  return(NULL);
574  }
575  Cudd_Ref(tmp);
576  Cudd_RecursiveDerefZdd(dd, term1);
577  Cudd_RecursiveDerefZdd(dd, term2);
578  R1 = cuddZddUnion(dd, tmp, term3);
579  if (R1 == NULL) {
580  Cudd_RecursiveDerefZdd(dd, N0);
581  Cudd_RecursiveDerefZdd(dd, term3);
582  Cudd_RecursiveDerefZdd(dd, tmp);
583  return(NULL);
584  }
585  Cudd_Ref(R1);
586  Cudd_RecursiveDerefZdd(dd, tmp);
587  Cudd_RecursiveDerefZdd(dd, term3);
588  N1 = cuddZddGetNode(dd, pv, R1, N0); /* pv = yi */
589  if (N1 == NULL) {
590  Cudd_RecursiveDerefZdd(dd, N0);
591  Cudd_RecursiveDerefZdd(dd, R1);
592  return(NULL);
593  }
594  Cudd_Ref(N1);
595  Cudd_RecursiveDerefZdd(dd, R1);
596  Cudd_RecursiveDerefZdd(dd, N0);
597 
598  cuddCacheInsert2(dd, cuddZddProduct, f, g, N1);
599  Cudd_Deref(N1);
600  return(N1);
601 
602 } /* end of cuddZddProduct */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
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
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
int * permZ
Definition: cuddInt.h:387
int cuddZddGetCofactors3(DdManager *dd, DdNode *f, int v, DdNode **f1, DdNode **f0, DdNode **fd)
#define statLine(dd)
Definition: cuddInt.h:1037
DdNode * cuddZddProduct(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:380
int cuddZddGetNegVarIndex(DdManager *dd, int index)
static DdNode * one
Definition: cuddDecomp.c:112
int cuddZddGetPosVarIndex(DdManager *dd, int index)
DdNode * cuddZddUnion(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:553
DdHalfWord index
Definition: cudd.h:279
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddZddUnateProduct ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Performs the recursive step of Cudd_zddUnateProduct.]

Description []

SideEffects [None]

SeeAlso [Cudd_zddUnateProduct]

Definition at line 617 of file cuddZddFuncs.c.

621 {
622  int v, top_f, top_g;
623  DdNode *term1, *term2, *term3, *term4;
624  DdNode *sum1, *sum2;
625  DdNode *f0, *f1, *g0, *g1;
626  DdNode *r;
627  DdNode *one = DD_ONE(dd);
628  DdNode *zero = DD_ZERO(dd);
629  int flag;
630 
631  statLine(dd);
632  if (f == zero || g == zero)
633  return(zero);
634  if (f == one)
635  return(g);
636  if (g == one)
637  return(f);
638 
639  top_f = dd->permZ[f->index];
640  top_g = dd->permZ[g->index];
641 
642  if (top_f > top_g)
643  return(cuddZddUnateProduct(dd, g, f));
644 
645  /* Check cache */
647  if (r)
648  return(r);
649 
650  v = f->index; /* either yi or zi */
651  flag = cuddZddGetCofactors2(dd, f, v, &f1, &f0);
652  if (flag == 1)
653  return(NULL);
654  Cudd_Ref(f1);
655  Cudd_Ref(f0);
656  flag = cuddZddGetCofactors2(dd, g, v, &g1, &g0);
657  if (flag == 1) {
658  Cudd_RecursiveDerefZdd(dd, f1);
659  Cudd_RecursiveDerefZdd(dd, f0);
660  return(NULL);
661  }
662  Cudd_Ref(g1);
663  Cudd_Ref(g0);
664 
665  term1 = cuddZddUnateProduct(dd, f1, g1);
666  if (term1 == NULL) {
667  Cudd_RecursiveDerefZdd(dd, f1);
668  Cudd_RecursiveDerefZdd(dd, f0);
669  Cudd_RecursiveDerefZdd(dd, g1);
670  Cudd_RecursiveDerefZdd(dd, g0);
671  return(NULL);
672  }
673  Cudd_Ref(term1);
674  term2 = cuddZddUnateProduct(dd, f1, g0);
675  if (term2 == NULL) {
676  Cudd_RecursiveDerefZdd(dd, f1);
677  Cudd_RecursiveDerefZdd(dd, f0);
678  Cudd_RecursiveDerefZdd(dd, g1);
679  Cudd_RecursiveDerefZdd(dd, g0);
680  Cudd_RecursiveDerefZdd(dd, term1);
681  return(NULL);
682  }
683  Cudd_Ref(term2);
684  term3 = cuddZddUnateProduct(dd, f0, g1);
685  if (term3 == NULL) {
686  Cudd_RecursiveDerefZdd(dd, f1);
687  Cudd_RecursiveDerefZdd(dd, f0);
688  Cudd_RecursiveDerefZdd(dd, g1);
689  Cudd_RecursiveDerefZdd(dd, g0);
690  Cudd_RecursiveDerefZdd(dd, term1);
691  Cudd_RecursiveDerefZdd(dd, term2);
692  return(NULL);
693  }
694  Cudd_Ref(term3);
695  term4 = cuddZddUnateProduct(dd, f0, g0);
696  if (term4 == NULL) {
697  Cudd_RecursiveDerefZdd(dd, f1);
698  Cudd_RecursiveDerefZdd(dd, f0);
699  Cudd_RecursiveDerefZdd(dd, g1);
700  Cudd_RecursiveDerefZdd(dd, g0);
701  Cudd_RecursiveDerefZdd(dd, term1);
702  Cudd_RecursiveDerefZdd(dd, term2);
703  Cudd_RecursiveDerefZdd(dd, term3);
704  return(NULL);
705  }
706  Cudd_Ref(term4);
707  Cudd_RecursiveDerefZdd(dd, f1);
708  Cudd_RecursiveDerefZdd(dd, f0);
709  Cudd_RecursiveDerefZdd(dd, g1);
710  Cudd_RecursiveDerefZdd(dd, g0);
711  sum1 = cuddZddUnion(dd, term1, term2);
712  if (sum1 == NULL) {
713  Cudd_RecursiveDerefZdd(dd, term1);
714  Cudd_RecursiveDerefZdd(dd, term2);
715  Cudd_RecursiveDerefZdd(dd, term3);
716  Cudd_RecursiveDerefZdd(dd, term4);
717  return(NULL);
718  }
719  Cudd_Ref(sum1);
720  Cudd_RecursiveDerefZdd(dd, term1);
721  Cudd_RecursiveDerefZdd(dd, term2);
722  sum2 = cuddZddUnion(dd, sum1, term3);
723  if (sum2 == NULL) {
724  Cudd_RecursiveDerefZdd(dd, term3);
725  Cudd_RecursiveDerefZdd(dd, term4);
726  Cudd_RecursiveDerefZdd(dd, sum1);
727  return(NULL);
728  }
729  Cudd_Ref(sum2);
730  Cudd_RecursiveDerefZdd(dd, sum1);
731  Cudd_RecursiveDerefZdd(dd, term3);
732  r = cuddZddGetNode(dd, v, sum2, term4);
733  if (r == NULL) {
734  Cudd_RecursiveDerefZdd(dd, term4);
735  Cudd_RecursiveDerefZdd(dd, sum2);
736  return(NULL);
737  }
738  Cudd_Ref(r);
739  Cudd_RecursiveDerefZdd(dd, sum2);
740  Cudd_RecursiveDerefZdd(dd, term4);
741 
743  Cudd_Deref(r);
744  return(r);
745 
746 } /* end of cuddZddUnateProduct */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
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
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
int cuddZddGetCofactors2(DdManager *dd, DdNode *f, int v, DdNode **f1, DdNode **f0)
int * permZ
Definition: cuddInt.h:387
#define statLine(dd)
Definition: cuddInt.h:1037
DdNode * cuddZddUnateProduct(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:617
static DdNode * one
Definition: cuddDecomp.c:112
DdNode * cuddZddUnion(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:553
DdHalfWord index
Definition: cudd.h:279
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddZddWeakDiv ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Performs the recursive step of Cudd_zddWeakDiv.]

Description []

SideEffects [None]

SeeAlso [Cudd_zddWeakDiv]

Definition at line 761 of file cuddZddFuncs.c.

765 {
766  int v;
767  DdNode *one = DD_ONE(dd);
768  DdNode *zero = DD_ZERO(dd);
769  DdNode *f0, *f1, *fd, *g0, *g1, *gd;
770  DdNode *q, *tmp;
771  DdNode *r;
772  int flag;
773 
774  statLine(dd);
775  if (g == one)
776  return(f);
777  if (f == zero || f == one)
778  return(zero);
779  if (f == g)
780  return(one);
781 
782  /* Check cache. */
783  r = cuddCacheLookup2Zdd(dd, cuddZddWeakDiv, f, g);
784  if (r)
785  return(r);
786 
787  v = g->index;
788 
789  flag = cuddZddGetCofactors3(dd, f, v, &f1, &f0, &fd);
790  if (flag == 1)
791  return(NULL);
792  Cudd_Ref(f1);
793  Cudd_Ref(f0);
794  Cudd_Ref(fd);
795  flag = cuddZddGetCofactors3(dd, g, v, &g1, &g0, &gd);
796  if (flag == 1) {
797  Cudd_RecursiveDerefZdd(dd, f1);
798  Cudd_RecursiveDerefZdd(dd, f0);
799  Cudd_RecursiveDerefZdd(dd, fd);
800  return(NULL);
801  }
802  Cudd_Ref(g1);
803  Cudd_Ref(g0);
804  Cudd_Ref(gd);
805 
806  q = g;
807 
808  if (g0 != zero) {
809  q = cuddZddWeakDiv(dd, f0, g0);
810  if (q == NULL) {
811  Cudd_RecursiveDerefZdd(dd, f1);
812  Cudd_RecursiveDerefZdd(dd, f0);
813  Cudd_RecursiveDerefZdd(dd, fd);
814  Cudd_RecursiveDerefZdd(dd, g1);
815  Cudd_RecursiveDerefZdd(dd, g0);
816  Cudd_RecursiveDerefZdd(dd, gd);
817  return(NULL);
818  }
819  Cudd_Ref(q);
820  }
821  else
822  Cudd_Ref(q);
823  Cudd_RecursiveDerefZdd(dd, f0);
824  Cudd_RecursiveDerefZdd(dd, g0);
825 
826  if (q == zero) {
827  Cudd_RecursiveDerefZdd(dd, f1);
828  Cudd_RecursiveDerefZdd(dd, g1);
829  Cudd_RecursiveDerefZdd(dd, fd);
830  Cudd_RecursiveDerefZdd(dd, gd);
831  cuddCacheInsert2(dd, cuddZddWeakDiv, f, g, zero);
832  Cudd_Deref(q);
833  return(zero);
834  }
835 
836  if (g1 != zero) {
837  Cudd_RecursiveDerefZdd(dd, q);
838  tmp = cuddZddWeakDiv(dd, f1, g1);
839  if (tmp == NULL) {
840  Cudd_RecursiveDerefZdd(dd, f1);
841  Cudd_RecursiveDerefZdd(dd, g1);
842  Cudd_RecursiveDerefZdd(dd, fd);
843  Cudd_RecursiveDerefZdd(dd, gd);
844  return(NULL);
845  }
846  Cudd_Ref(tmp);
847  Cudd_RecursiveDerefZdd(dd, f1);
848  Cudd_RecursiveDerefZdd(dd, g1);
849  if (q == g)
850  q = tmp;
851  else {
852  q = cuddZddIntersect(dd, q, tmp);
853  if (q == NULL) {
854  Cudd_RecursiveDerefZdd(dd, fd);
855  Cudd_RecursiveDerefZdd(dd, gd);
856  return(NULL);
857  }
858  Cudd_Ref(q);
859  Cudd_RecursiveDerefZdd(dd, tmp);
860  }
861  }
862  else {
863  Cudd_RecursiveDerefZdd(dd, f1);
864  Cudd_RecursiveDerefZdd(dd, g1);
865  }
866 
867  if (q == zero) {
868  Cudd_RecursiveDerefZdd(dd, fd);
869  Cudd_RecursiveDerefZdd(dd, gd);
870  cuddCacheInsert2(dd, cuddZddWeakDiv, f, g, zero);
871  Cudd_Deref(q);
872  return(zero);
873  }
874 
875  if (gd != zero) {
876  Cudd_RecursiveDerefZdd(dd, q);
877  tmp = cuddZddWeakDiv(dd, fd, gd);
878  if (tmp == NULL) {
879  Cudd_RecursiveDerefZdd(dd, fd);
880  Cudd_RecursiveDerefZdd(dd, gd);
881  return(NULL);
882  }
883  Cudd_Ref(tmp);
884  Cudd_RecursiveDerefZdd(dd, fd);
885  Cudd_RecursiveDerefZdd(dd, gd);
886  if (q == g)
887  q = tmp;
888  else {
889  q = cuddZddIntersect(dd, q, tmp);
890  if (q == NULL) {
891  Cudd_RecursiveDerefZdd(dd, tmp);
892  return(NULL);
893  }
894  Cudd_Ref(q);
895  Cudd_RecursiveDerefZdd(dd, tmp);
896  }
897  }
898  else {
899  Cudd_RecursiveDerefZdd(dd, fd);
900  Cudd_RecursiveDerefZdd(dd, gd);
901  }
902 
903  cuddCacheInsert2(dd, cuddZddWeakDiv, f, g, q);
904  Cudd_Deref(q);
905  return(q);
906 
907 } /* end of cuddZddWeakDiv */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
Definition: cudd.h:278
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
int cuddZddGetCofactors3(DdManager *dd, DdNode *f, int v, DdNode **f1, DdNode **f0, DdNode **fd)
#define statLine(dd)
Definition: cuddInt.h:1037
static DdNode * one
Definition: cuddDecomp.c:112
DdNode * cuddZddIntersect(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:642
DdNode * cuddZddWeakDiv(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:761
DdHalfWord index
Definition: cudd.h:279
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* cuddZddWeakDivF ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Performs the recursive step of Cudd_zddWeakDivF.]

Description []

SideEffects [None]

SeeAlso [Cudd_zddWeakDivF]

Definition at line 922 of file cuddZddFuncs.c.

926 {
927  int v, top_f, top_g, vf, vg;
928  DdNode *one = DD_ONE(dd);
929  DdNode *zero = DD_ZERO(dd);
930  DdNode *f0, *f1, *fd, *g0, *g1, *gd;
931  DdNode *q, *tmp;
932  DdNode *r;
933  DdNode *term1, *term0, *termd;
934  int flag;
935  int pv, nv;
936 
937  statLine(dd);
938  if (g == one)
939  return(f);
940  if (f == zero || f == one)
941  return(zero);
942  if (f == g)
943  return(one);
944 
945  /* Check cache. */
946  r = cuddCacheLookup2Zdd(dd, cuddZddWeakDivF, f, g);
947  if (r)
948  return(r);
949 
950  top_f = dd->permZ[f->index];
951  top_g = dd->permZ[g->index];
952  vf = top_f >> 1;
953  vg = top_g >> 1;
954  v = ddMin(top_f, top_g);
955 
956  if (v == top_f && vf < vg) {
957  v = f->index;
958  flag = cuddZddGetCofactors3(dd, f, v, &f1, &f0, &fd);
959  if (flag == 1)
960  return(NULL);
961  Cudd_Ref(f1);
962  Cudd_Ref(f0);
963  Cudd_Ref(fd);
964 
965  pv = cuddZddGetPosVarIndex(dd, v);
966  nv = cuddZddGetNegVarIndex(dd, v);
967 
968  term1 = cuddZddWeakDivF(dd, f1, g);
969  if (term1 == NULL) {
970  Cudd_RecursiveDerefZdd(dd, f1);
971  Cudd_RecursiveDerefZdd(dd, f0);
972  Cudd_RecursiveDerefZdd(dd, fd);
973  return(NULL);
974  }
975  Cudd_Ref(term1);
976  Cudd_RecursiveDerefZdd(dd, f1);
977  term0 = cuddZddWeakDivF(dd, f0, g);
978  if (term0 == NULL) {
979  Cudd_RecursiveDerefZdd(dd, f0);
980  Cudd_RecursiveDerefZdd(dd, fd);
981  Cudd_RecursiveDerefZdd(dd, term1);
982  return(NULL);
983  }
984  Cudd_Ref(term0);
985  Cudd_RecursiveDerefZdd(dd, f0);
986  termd = cuddZddWeakDivF(dd, fd, g);
987  if (termd == NULL) {
988  Cudd_RecursiveDerefZdd(dd, fd);
989  Cudd_RecursiveDerefZdd(dd, term1);
990  Cudd_RecursiveDerefZdd(dd, term0);
991  return(NULL);
992  }
993  Cudd_Ref(termd);
994  Cudd_RecursiveDerefZdd(dd, fd);
995 
996  tmp = cuddZddGetNode(dd, nv, term0, termd); /* nv = zi */
997  if (tmp == NULL) {
998  Cudd_RecursiveDerefZdd(dd, term1);
999  Cudd_RecursiveDerefZdd(dd, term0);
1000  Cudd_RecursiveDerefZdd(dd, termd);
1001  return(NULL);
1002  }
1003  Cudd_Ref(tmp);
1004  Cudd_RecursiveDerefZdd(dd, term0);
1005  Cudd_RecursiveDerefZdd(dd, termd);
1006  q = cuddZddGetNode(dd, pv, term1, tmp); /* pv = yi */
1007  if (q == NULL) {
1008  Cudd_RecursiveDerefZdd(dd, term1);
1009  Cudd_RecursiveDerefZdd(dd, tmp);
1010  return(NULL);
1011  }
1012  Cudd_Ref(q);
1013  Cudd_RecursiveDerefZdd(dd, term1);
1014  Cudd_RecursiveDerefZdd(dd, tmp);
1015 
1016  cuddCacheInsert2(dd, cuddZddWeakDivF, f, g, q);
1017  Cudd_Deref(q);
1018  return(q);
1019  }
1020 
1021  if (v == top_f)
1022  v = f->index;
1023  else
1024  v = g->index;
1025 
1026  flag = cuddZddGetCofactors3(dd, f, v, &f1, &f0, &fd);
1027  if (flag == 1)
1028  return(NULL);
1029  Cudd_Ref(f1);
1030  Cudd_Ref(f0);
1031  Cudd_Ref(fd);
1032  flag = cuddZddGetCofactors3(dd, g, v, &g1, &g0, &gd);
1033  if (flag == 1) {
1034  Cudd_RecursiveDerefZdd(dd, f1);
1035  Cudd_RecursiveDerefZdd(dd, f0);
1036  Cudd_RecursiveDerefZdd(dd, fd);
1037  return(NULL);
1038  }
1039  Cudd_Ref(g1);
1040  Cudd_Ref(g0);
1041  Cudd_Ref(gd);
1042 
1043  q = g;
1044 
1045  if (g0 != zero) {
1046  q = cuddZddWeakDivF(dd, f0, g0);
1047  if (q == NULL) {
1048  Cudd_RecursiveDerefZdd(dd, f1);
1049  Cudd_RecursiveDerefZdd(dd, f0);
1050  Cudd_RecursiveDerefZdd(dd, fd);
1051  Cudd_RecursiveDerefZdd(dd, g1);
1052  Cudd_RecursiveDerefZdd(dd, g0);
1053  Cudd_RecursiveDerefZdd(dd, gd);
1054  return(NULL);
1055  }
1056  Cudd_Ref(q);
1057  }
1058  else
1059  Cudd_Ref(q);
1060  Cudd_RecursiveDerefZdd(dd, f0);
1061  Cudd_RecursiveDerefZdd(dd, g0);
1062 
1063  if (q == zero) {
1064  Cudd_RecursiveDerefZdd(dd, f1);
1065  Cudd_RecursiveDerefZdd(dd, g1);
1066  Cudd_RecursiveDerefZdd(dd, fd);
1067  Cudd_RecursiveDerefZdd(dd, gd);
1068  cuddCacheInsert2(dd, cuddZddWeakDivF, f, g, zero);
1069  Cudd_Deref(q);
1070  return(zero);
1071  }
1072 
1073  if (g1 != zero) {
1074  Cudd_RecursiveDerefZdd(dd, q);
1075  tmp = cuddZddWeakDivF(dd, f1, g1);
1076  if (tmp == NULL) {
1077  Cudd_RecursiveDerefZdd(dd, f1);
1078  Cudd_RecursiveDerefZdd(dd, g1);
1079  Cudd_RecursiveDerefZdd(dd, fd);
1080  Cudd_RecursiveDerefZdd(dd, gd);
1081  return(NULL);
1082  }
1083  Cudd_Ref(tmp);
1084  Cudd_RecursiveDerefZdd(dd, f1);
1085  Cudd_RecursiveDerefZdd(dd, g1);
1086  if (q == g)
1087  q = tmp;
1088  else {
1089  q = cuddZddIntersect(dd, q, tmp);
1090  if (q == NULL) {
1091  Cudd_RecursiveDerefZdd(dd, fd);
1092  Cudd_RecursiveDerefZdd(dd, gd);
1093  return(NULL);
1094  }
1095  Cudd_Ref(q);
1096  Cudd_RecursiveDerefZdd(dd, tmp);
1097  }
1098  }
1099  else {
1100  Cudd_RecursiveDerefZdd(dd, f1);
1101  Cudd_RecursiveDerefZdd(dd, g1);
1102  }
1103 
1104  if (q == zero) {
1105  Cudd_RecursiveDerefZdd(dd, fd);
1106  Cudd_RecursiveDerefZdd(dd, gd);
1107  cuddCacheInsert2(dd, cuddZddWeakDivF, f, g, zero);
1108  Cudd_Deref(q);
1109  return(zero);
1110  }
1111 
1112  if (gd != zero) {
1113  Cudd_RecursiveDerefZdd(dd, q);
1114  tmp = cuddZddWeakDivF(dd, fd, gd);
1115  if (tmp == NULL) {
1116  Cudd_RecursiveDerefZdd(dd, fd);
1117  Cudd_RecursiveDerefZdd(dd, gd);
1118  return(NULL);
1119  }
1120  Cudd_Ref(tmp);
1121  Cudd_RecursiveDerefZdd(dd, fd);
1122  Cudd_RecursiveDerefZdd(dd, gd);
1123  if (q == g)
1124  q = tmp;
1125  else {
1126  q = cuddZddIntersect(dd, q, tmp);
1127  if (q == NULL) {
1128  Cudd_RecursiveDerefZdd(dd, tmp);
1129  return(NULL);
1130  }
1131  Cudd_Ref(q);
1132  Cudd_RecursiveDerefZdd(dd, tmp);
1133  }
1134  }
1135  else {
1136  Cudd_RecursiveDerefZdd(dd, fd);
1137  Cudd_RecursiveDerefZdd(dd, gd);
1138  }
1139 
1140  cuddCacheInsert2(dd, cuddZddWeakDivF, f, g, q);
1141  Cudd_Deref(q);
1142  return(q);
1143 
1144 } /* end of cuddZddWeakDivF */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
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
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
int * permZ
Definition: cuddInt.h:387
int cuddZddGetCofactors3(DdManager *dd, DdNode *f, int v, DdNode **f1, DdNode **f0, DdNode **fd)
#define statLine(dd)
Definition: cuddInt.h:1037
int cuddZddGetNegVarIndex(DdManager *dd, int index)
static DdNode * one
Definition: cuddDecomp.c:112
DdNode * cuddZddIntersect(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:642
#define ddMin(x, y)
Definition: cuddInt.h:818
int cuddZddGetPosVarIndex(DdManager *dd, int index)
DdNode * cuddZddWeakDivF(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:922
DdHalfWord index
Definition: cudd.h:279
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
#define DD_ZERO(dd)
Definition: cuddInt.h:927

Variable Documentation

ABC_NAMESPACE_IMPL_START char rcsid [] DD_UNUSED = "$Id: cuddZddFuncs.c,v 1.16 2008/04/25 07:39:33 fabio Exp $"
static

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

FileName [cuddZddFuncs.c]

PackageName [cudd]

Synopsis [Functions to manipulate covers represented as ZDDs.]

Description [External procedures included in this module:

Internal procedures included in this module:

Static procedures included in this module:

]

SeeAlso []

Author [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 105 of file cuddZddFuncs.c.