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

Go to the source code of this file.

Macros

#define MODULUS1   2147483563
 
#define LEQA1   40014
 
#define LEQQ1   53668
 
#define LEQR1   12211
 
#define MODULUS2   2147483399
 
#define LEQA2   40692
 
#define LEQQ2   52774
 
#define LEQR2   3791
 
#define STAB_SIZE   64
 
#define STAB_DIV   (1 + (MODULUS1 - 1) / STAB_SIZE)
 
#define bang(f)   ((Cudd_IsComplement(f)) ? '!' : ' ')
 

Functions

static int dp2 (DdManager *dd, DdNode *f, st__table *t)
 
static void ddPrintMintermAux (DdManager *dd, DdNode *node, int *list)
 
static int ddDagInt (DdNode *n)
 
static int cuddNodeArrayRecur (DdNode *f, DdNodePtr *table, int index)
 
static int cuddEstimateCofactor (DdManager *dd, st__table *table, DdNode *node, int i, int phase, DdNode **ptr)
 
static DdNodecuddUniqueLookup (DdManager *unique, int index, DdNode *T, DdNode *E)
 
static int cuddEstimateCofactorSimple (DdNode *node, int i)
 
static double ddCountMintermAux (DdNode *node, double max, DdHashTable *table)
 
static int ddEpdCountMintermAux (DdNode *node, EpDouble *max, EpDouble *epd, st__table *table)
 
static double ddCountPathAux (DdNode *node, st__table *table)
 
static double ddCountPathsToNonZero (DdNode *N, st__table *table)
 
static void ddSupportStep (DdNode *f, int *support)
 
static void ddClearFlag (DdNode *f)
 
static int ddLeavesInt (DdNode *n)
 
static int ddPickArbitraryMinterms (DdManager *dd, DdNode *node, int nvars, int nminterms, char **string)
 
static int ddPickRepresentativeCube (DdManager *dd, DdNode *node, double *weight, char *string)
 
static enum st__retval ddEpdFree (char *key, char *value, char *arg)
 
int Cudd_PrintMinterm (DdManager *manager, DdNode *node)
 
int Cudd_bddPrintCover (DdManager *dd, DdNode *l, DdNode *u)
 
int Cudd_PrintDebug (DdManager *dd, DdNode *f, int n, int pr)
 
int Cudd_DagSize (DdNode *node)
 
int Cudd_EstimateCofactor (DdManager *dd, DdNode *f, int i, int phase)
 
int Cudd_EstimateCofactorSimple (DdNode *node, int i)
 
int Cudd_SharingSize (DdNode **nodeArray, int n)
 
double Cudd_CountMinterm (DdManager *manager, DdNode *node, int nvars)
 
double Cudd_CountPath (DdNode *node)
 
int Cudd_EpdCountMinterm (DdManager *manager, DdNode *node, int nvars, EpDouble *epd)
 
double Cudd_CountPathsToNonZero (DdNode *node)
 
DdNodeCudd_Support (DdManager *dd, DdNode *f)
 
int * Cudd_SupportIndex (DdManager *dd, DdNode *f)
 
int Cudd_SupportSize (DdManager *dd, DdNode *f)
 
DdNodeCudd_VectorSupport (DdManager *dd, DdNode **F, int n)
 
int * Cudd_VectorSupportIndex (DdManager *dd, DdNode **F, int n)
 
int Cudd_VectorSupportSize (DdManager *dd, DdNode **F, int n)
 
int Cudd_ClassifySupport (DdManager *dd, DdNode *f, DdNode *g, DdNode **common, DdNode **onlyF, DdNode **onlyG)
 
int Cudd_CountLeaves (DdNode *node)
 
int Cudd_bddPickOneCube (DdManager *ddm, DdNode *node, char *string)
 
DdNodeCudd_bddPickOneMinterm (DdManager *dd, DdNode *f, DdNode **vars, int n)
 
DdNode ** Cudd_bddPickArbitraryMinterms (DdManager *dd, DdNode *f, DdNode **vars, int n, int k)
 
DdNodeCudd_SubsetWithMaskVars (DdManager *dd, DdNode *f, DdNode **vars, int nvars, DdNode **maskVars, int mvars)
 
DdGenCudd_FirstCube (DdManager *dd, DdNode *f, int **cube, CUDD_VALUE_TYPE *value)
 
int Cudd_NextCube (DdGen *gen, int **cube, CUDD_VALUE_TYPE *value)
 
DdGenCudd_FirstPrime (DdManager *dd, DdNode *l, DdNode *u, int **cube)
 
int Cudd_NextPrime (DdGen *gen, int **cube)
 
DdNodeCudd_bddComputeCube (DdManager *dd, DdNode **vars, int *phase, int n)
 
DdNodeCudd_addComputeCube (DdManager *dd, DdNode **vars, int *phase, int n)
 
DdNodeCudd_CubeArrayToBdd (DdManager *dd, int *array)
 
int Cudd_BddToCubeArray (DdManager *dd, DdNode *cube, int *array)
 
DdGenCudd_FirstNode (DdManager *dd, DdNode *f, DdNode **node)
 
int Cudd_NextNode (DdGen *gen, DdNode **node)
 
int Cudd_GenFree (DdGen *gen)
 
int Cudd_IsGenEmpty (DdGen *gen)
 
DdNodeCudd_IndicesToCube (DdManager *dd, int *array, int n)
 
void Cudd_PrintVersion (FILE *fp)
 
double Cudd_AverageDistance (DdManager *dd)
 
long Cudd_Random (void)
 
void Cudd_Srandom (long seed)
 
double Cudd_Density (DdManager *dd, DdNode *f, int nvars)
 
void Cudd_OutOfMem (long size)
 
int cuddP (DdManager *dd, DdNode *f)
 
enum st__retval cuddStCountfree (char *key, char *value, char *arg)
 
int cuddCollectNodes (DdNode *f, st__table *visited)
 
DdNodePtrcuddNodeArray (DdNode *f, int *n)
 

Variables

static char rcsid[] DD_UNUSED = "$Id: cuddUtil.c,v 1.81 2009/03/08 02:49:02 fabio Exp $"
 
static DdNodebackground
 
static DdNodezero
 
static long cuddRand = 0
 
static long cuddRand2
 
static long shuffleSelect
 
static long shuffleTable [STAB_SIZE]
 

Macro Definition Documentation

#define bang (   f)    ((Cudd_IsComplement(f)) ? '!' : ' ')

Definition at line 159 of file cuddUtil.c.

#define LEQA1   40014

Definition at line 121 of file cuddUtil.c.

#define LEQA2   40692

Definition at line 125 of file cuddUtil.c.

#define LEQQ1   53668

Definition at line 122 of file cuddUtil.c.

#define LEQQ2   52774

Definition at line 126 of file cuddUtil.c.

#define LEQR1   12211

Definition at line 123 of file cuddUtil.c.

#define LEQR2   3791

Definition at line 127 of file cuddUtil.c.

#define MODULUS1   2147483563

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

FileName [cuddUtil.c]

PackageName [cudd]

Synopsis [Utility functions.]

Description [External procedures included in this module:

Internal procedures included in this module:

Static procedures included in this module:

]

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 120 of file cuddUtil.c.

#define MODULUS2   2147483399

Definition at line 124 of file cuddUtil.c.

#define STAB_DIV   (1 + (MODULUS1 - 1) / STAB_SIZE)

Definition at line 129 of file cuddUtil.c.

#define STAB_SIZE   64

Definition at line 128 of file cuddUtil.c.

Function Documentation

DdNode* Cudd_addComputeCube ( DdManager dd,
DdNode **  vars,
int *  phase,
int  n 
)

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

Synopsis [Computes the cube of an array of ADD variables.]

Description [Computes the cube of an array of ADD variables. If non-null, the phase argument indicates which literal of each variable should appear in the cube. If phase[i] is nonzero, then the positive literal is used. If phase is NULL, the cube is positive unate. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [none]

SeeAlso [Cudd_bddComputeCube]

Definition at line 2246 of file cuddUtil.c.

2251 {
2252  DdNode *cube, *zero;
2253  DdNode *fn;
2254  int i;
2255 
2256  cube = DD_ONE(dd);
2257  cuddRef(cube);
2258  zero = DD_ZERO(dd);
2259 
2260  for (i = n - 1; i >= 0; i--) {
2261  if (phase == NULL || phase[i] != 0) {
2262  fn = Cudd_addIte(dd,vars[i],cube,zero);
2263  } else {
2264  fn = Cudd_addIte(dd,vars[i],zero,cube);
2265  }
2266  if (fn == NULL) {
2267  Cudd_RecursiveDeref(dd,cube);
2268  return(NULL);
2269  }
2270  cuddRef(fn);
2271  Cudd_RecursiveDeref(dd,cube);
2272  cube = fn;
2273  }
2274  cuddDeref(cube);
2275 
2276  return(cube);
2277 
2278 } /* end of Cudd_addComputeCube */
#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
static DdNode * zero
Definition: cuddUtil.c:148
static pcube phase
Definition: cvrm.c:405
DdNode * Cudd_addIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddAddIte.c:129
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
double Cudd_AverageDistance ( DdManager dd)

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

Synopsis [Computes the average distance between adjacent nodes.]

Description [Computes the average distance between adjacent nodes in the manager. Adjacent nodes are node pairs such that the second node is the then child, else child, or next node in the collision list.]

SideEffects [None]

SeeAlso []

Definition at line 2614 of file cuddUtil.c.

2616 {
2617  double tetotal, nexttotal;
2618  double tesubtotal, nextsubtotal;
2619  double temeasured, nextmeasured;
2620  int i, j;
2621  int slots, nvars;
2622  long diff;
2623  DdNode *scan;
2624  DdNodePtr *nodelist;
2625  DdNode *sentinel = &(dd->sentinel);
2626 
2627  nvars = dd->size;
2628  if (nvars == 0) return(0.0);
2629 
2630  /* Initialize totals. */
2631  tetotal = 0.0;
2632  nexttotal = 0.0;
2633  temeasured = 0.0;
2634  nextmeasured = 0.0;
2635 
2636  /* Scan the variable subtables. */
2637  for (i = 0; i < nvars; i++) {
2638  nodelist = dd->subtables[i].nodelist;
2639  tesubtotal = 0.0;
2640  nextsubtotal = 0.0;
2641  slots = dd->subtables[i].slots;
2642  for (j = 0; j < slots; j++) {
2643  scan = nodelist[j];
2644  while (scan != sentinel) {
2645  diff = (long) scan - (long) cuddT(scan);
2646  tesubtotal += (double) ddAbs(diff);
2647  diff = (long) scan - (long) Cudd_Regular(cuddE(scan));
2648  tesubtotal += (double) ddAbs(diff);
2649  temeasured += 2.0;
2650  if (scan->next != sentinel) {
2651  diff = (long) scan - (long) scan->next;
2652  nextsubtotal += (double) ddAbs(diff);
2653  nextmeasured += 1.0;
2654  }
2655  scan = scan->next;
2656  }
2657  }
2658  tetotal += tesubtotal;
2659  nexttotal += nextsubtotal;
2660  }
2661 
2662  /* Scan the constant table. */
2663  nodelist = dd->constants.nodelist;
2664  nextsubtotal = 0.0;
2665  slots = dd->constants.slots;
2666  for (j = 0; j < slots; j++) {
2667  scan = nodelist[j];
2668  while (scan != NULL) {
2669  if (scan->next != NULL) {
2670  diff = (long) scan - (long) scan->next;
2671  nextsubtotal += (double) ddAbs(diff);
2672  nextmeasured += 1.0;
2673  }
2674  scan = scan->next;
2675  }
2676  }
2677  nexttotal += nextsubtotal;
2678 
2679  return((tetotal + nexttotal) / (temeasured + nextmeasured));
2680 
2681 } /* end of Cudd_AverageDistance */
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
DdSubtable * subtables
Definition: cuddInt.h:365
DdNode sentinel
Definition: cuddInt.h:344
DdNode * next
Definition: cudd.h:281
#define ddAbs(x)
Definition: cuddInt.h:846
DdNode ** nodelist
Definition: cuddInt.h:327
#define cuddT(node)
Definition: cuddInt.h:636
unsigned int slots
Definition: cuddInt.h:329
#define cuddE(node)
Definition: cuddInt.h:652
DdSubtable constants
Definition: cuddInt.h:367
DdNode* Cudd_bddComputeCube ( DdManager dd,
DdNode **  vars,
int *  phase,
int  n 
)

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

Synopsis [Computes the cube of an array of BDD variables.]

Description [Computes the cube of an array of BDD variables. If non-null, the phase argument indicates which literal of each variable should appear in the cube. If phase[i] is nonzero, then the positive literal is used. If phase is NULL, the cube is positive unate. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addComputeCube Cudd_IndicesToCube Cudd_CubeArrayToBdd]

Definition at line 2196 of file cuddUtil.c.

2201 {
2202  DdNode *cube;
2203  DdNode *fn;
2204  int i;
2205 
2206  cube = DD_ONE(dd);
2207  cuddRef(cube);
2208 
2209  for (i = n - 1; i >= 0; i--) {
2210  if (phase == NULL || phase[i] != 0) {
2211  fn = Cudd_bddAnd(dd,vars[i],cube);
2212  } else {
2213  fn = Cudd_bddAnd(dd,Cudd_Not(vars[i]),cube);
2214  }
2215  if (fn == NULL) {
2216  Cudd_RecursiveDeref(dd,cube);
2217  return(NULL);
2218  }
2219  cuddRef(fn);
2220  Cudd_RecursiveDeref(dd,cube);
2221  cube = fn;
2222  }
2223  cuddDeref(cube);
2224 
2225  return(cube);
2226 
2227 } /* end of Cudd_bddComputeCube */
#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
static pcube phase
Definition: cvrm.c:405
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode** Cudd_bddPickArbitraryMinterms ( DdManager dd,
DdNode f,
DdNode **  vars,
int  n,
int  k 
)

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

Synopsis [Picks k on-set minterms evenly distributed from given DD.]

Description [Picks k on-set minterms evenly distributed from given DD. The minterms are in terms of vars. The array vars should contain at least all variables in the support of f; if this condition is not met the minterms built by this procedure may not be contained in f. Builds an array of BDDs for the minterms and returns a pointer to it if successful; NULL otherwise. There are three reasons why the procedure may fail:

  • It may run out of memory;
  • the function f may be the constant 0;
  • the minterms may not be contained in f.

]

SideEffects [None]

SeeAlso [Cudd_bddPickOneMinterm Cudd_bddPickOneCube]

Definition at line 1393 of file cuddUtil.c.

1399 {
1400  char **string;
1401  int i, j, l, size;
1402  int *indices;
1403  int result;
1404  DdNode **old, *neW;
1405  double minterms;
1406  char *saveString;
1407  int saveFlag, savePoint = -1, isSame;
1408 
1409  minterms = Cudd_CountMinterm(dd,f,n);
1410  if ((double)k > minterms) {
1411  return(NULL);
1412  }
1413 
1414  size = dd->size;
1415  string = ABC_ALLOC(char *, k);
1416  if (string == NULL) {
1417  dd->errorCode = CUDD_MEMORY_OUT;
1418  return(NULL);
1419  }
1420  for (i = 0; i < k; i++) {
1421  string[i] = ABC_ALLOC(char, size + 1);
1422  if (string[i] == NULL) {
1423  for (j = 0; j < i; j++)
1424  ABC_FREE(string[i]);
1425  ABC_FREE(string);
1426  dd->errorCode = CUDD_MEMORY_OUT;
1427  return(NULL);
1428  }
1429  for (j = 0; j < size; j++) string[i][j] = '2';
1430  string[i][size] = '\0';
1431  }
1432  indices = ABC_ALLOC(int,n);
1433  if (indices == NULL) {
1434  dd->errorCode = CUDD_MEMORY_OUT;
1435  for (i = 0; i < k; i++)
1436  ABC_FREE(string[i]);
1437  ABC_FREE(string);
1438  return(NULL);
1439  }
1440 
1441  for (i = 0; i < n; i++) {
1442  indices[i] = vars[i]->index;
1443  }
1444 
1445  result = ddPickArbitraryMinterms(dd,f,n,k,string);
1446  if (result == 0) {
1447  for (i = 0; i < k; i++)
1448  ABC_FREE(string[i]);
1449  ABC_FREE(string);
1450  ABC_FREE(indices);
1451  return(NULL);
1452  }
1453 
1454  old = ABC_ALLOC(DdNode *, k);
1455  if (old == NULL) {
1456  dd->errorCode = CUDD_MEMORY_OUT;
1457  for (i = 0; i < k; i++)
1458  ABC_FREE(string[i]);
1459  ABC_FREE(string);
1460  ABC_FREE(indices);
1461  return(NULL);
1462  }
1463  saveString = ABC_ALLOC(char, size + 1);
1464  if (saveString == NULL) {
1465  dd->errorCode = CUDD_MEMORY_OUT;
1466  for (i = 0; i < k; i++)
1467  ABC_FREE(string[i]);
1468  ABC_FREE(string);
1469  ABC_FREE(indices);
1470  ABC_FREE(old);
1471  return(NULL);
1472  }
1473  saveFlag = 0;
1474 
1475  /* Build result BDD array. */
1476  for (i = 0; i < k; i++) {
1477  isSame = 0;
1478  if (!saveFlag) {
1479  for (j = i + 1; j < k; j++) {
1480  if (strcmp(string[i], string[j]) == 0) {
1481  savePoint = i;
1482  strcpy(saveString, string[i]);
1483  saveFlag = 1;
1484  break;
1485  }
1486  }
1487  } else {
1488  if (strcmp(string[i], saveString) == 0) {
1489  isSame = 1;
1490  } else {
1491  saveFlag = 0;
1492  for (j = i + 1; j < k; j++) {
1493  if (strcmp(string[i], string[j]) == 0) {
1494  savePoint = i;
1495  strcpy(saveString, string[i]);
1496  saveFlag = 1;
1497  break;
1498  }
1499  }
1500  }
1501  }
1502  /* Randomize choice for don't cares. */
1503  for (j = 0; j < n; j++) {
1504  if (string[i][indices[j]] == '2')
1505  string[i][indices[j]] =
1506  (char) ((Cudd_Random() & 0x20) ? '1' : '0');
1507  }
1508 
1509  while (isSame) {
1510  isSame = 0;
1511  for (j = savePoint; j < i; j++) {
1512  if (strcmp(string[i], string[j]) == 0) {
1513  isSame = 1;
1514  break;
1515  }
1516  }
1517  if (isSame) {
1518  strcpy(string[i], saveString);
1519  /* Randomize choice for don't cares. */
1520  for (j = 0; j < n; j++) {
1521  if (string[i][indices[j]] == '2')
1522  string[i][indices[j]] =
1523  (char) ((Cudd_Random() & 0x20) ? '1' : '0');
1524  }
1525  }
1526  }
1527 
1528  old[i] = Cudd_ReadOne(dd);
1529  cuddRef(old[i]);
1530 
1531  for (j = 0; j < n; j++) {
1532  if (string[i][indices[j]] == '0') {
1533  neW = Cudd_bddAnd(dd,old[i],Cudd_Not(vars[j]));
1534  } else {
1535  neW = Cudd_bddAnd(dd,old[i],vars[j]);
1536  }
1537  if (neW == NULL) {
1538  ABC_FREE(saveString);
1539  for (l = 0; l < k; l++)
1540  ABC_FREE(string[l]);
1541  ABC_FREE(string);
1542  ABC_FREE(indices);
1543  for (l = 0; l <= i; l++)
1544  Cudd_RecursiveDeref(dd,old[l]);
1545  ABC_FREE(old);
1546  return(NULL);
1547  }
1548  cuddRef(neW);
1549  Cudd_RecursiveDeref(dd,old[i]);
1550  old[i] = neW;
1551  }
1552 
1553  /* Test. */
1554  if (!Cudd_bddLeq(dd,old[i],f)) {
1555  ABC_FREE(saveString);
1556  for (l = 0; l < k; l++)
1557  ABC_FREE(string[l]);
1558  ABC_FREE(string);
1559  ABC_FREE(indices);
1560  for (l = 0; l <= i; l++)
1561  Cudd_RecursiveDeref(dd,old[l]);
1562  ABC_FREE(old);
1563  return(NULL);
1564  }
1565  }
1566 
1567  ABC_FREE(saveString);
1568  for (i = 0; i < k; i++) {
1569  cuddDeref(old[i]);
1570  ABC_FREE(string[i]);
1571  }
1572  ABC_FREE(string);
1573  ABC_FREE(indices);
1574  return(old);
1575 
1576 } /* end of Cudd_bddPickArbitraryMinterms */
#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
static int ddPickArbitraryMinterms(DdManager *dd, DdNode *node, int nvars, int nminterms, char **string)
Definition: cuddUtil.c:3798
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int strcmp()
double Cudd_CountMinterm(DdManager *manager, DdNode *node, int nvars)
Definition: cuddUtil.c:578
long Cudd_Random(void)
Definition: cuddUtil.c:2702
static int size
Definition: cuddSign.c:86
char * strcpy()
DdNode * Cudd_ReadOne(DdManager *dd)
Definition: cuddAPI.c:987
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
pset minterms()
int Cudd_bddPickOneCube ( DdManager ddm,
DdNode node,
char *  string 
)

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

Synopsis [Picks one on-set cube randomly from the given DD.]

Description [Picks one on-set cube randomly from the given DD. The cube is written into an array of characters. The array must have at least as many entries as there are variables. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddPickOneMinterm]

Definition at line 1221 of file cuddUtil.c.

1225 {
1226  DdNode *N, *T, *E;
1227  DdNode *one, *bzero;
1228  char dir;
1229  int i;
1230 
1231  if (string == NULL || node == NULL) return(0);
1232 
1233  /* The constant 0 function has no on-set cubes. */
1234  one = DD_ONE(ddm);
1235  bzero = Cudd_Not(one);
1236  if (node == bzero) return(0);
1237 
1238  for (i = 0; i < ddm->size; i++) string[i] = 2;
1239 
1240  for (;;) {
1241 
1242  if (node == one) break;
1243 
1244  N = Cudd_Regular(node);
1245 
1246  T = cuddT(N); E = cuddE(N);
1247  if (Cudd_IsComplement(node)) {
1248  T = Cudd_Not(T); E = Cudd_Not(E);
1249  }
1250  if (T == bzero) {
1251  string[N->index] = 0;
1252  node = E;
1253  } else if (E == bzero) {
1254  string[N->index] = 1;
1255  node = T;
1256  } else {
1257  dir = (char) ((Cudd_Random() & 0x2000) >> 13);
1258  string[N->index] = dir;
1259  node = dir ? T : E;
1260  }
1261  }
1262  return(1);
1263 
1264 } /* end of Cudd_bddPickOneCube */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
long Cudd_Random(void)
Definition: cuddUtil.c:2702
#define Cudd_IsComplement(node)
Definition: cudd.h:425
static DdNode * one
Definition: cuddDecomp.c:112
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode* Cudd_bddPickOneMinterm ( DdManager dd,
DdNode f,
DdNode **  vars,
int  n 
)

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

Synopsis [Picks one on-set minterm randomly from the given DD.]

Description [Picks one on-set minterm randomly from the given DD. The minterm is in terms of vars. The array vars should contain at least all variables in the support of f; if this condition is not met the minterm built by this procedure may not be contained in f. Builds a BDD for the minterm and returns a pointer to it if successful; NULL otherwise. There are three reasons why the procedure may fail:

  • It may run out of memory;
  • the function f may be the constant 0;
  • the minterm may not be contained in f.

]

SideEffects [None]

SeeAlso [Cudd_bddPickOneCube]

Definition at line 1291 of file cuddUtil.c.

1296 {
1297  char *string;
1298  int i, size;
1299  int *indices;
1300  int result;
1301  DdNode *old, *neW;
1302 
1303  size = dd->size;
1304  string = ABC_ALLOC(char, size);
1305  if (string == NULL) {
1306  dd->errorCode = CUDD_MEMORY_OUT;
1307  return(NULL);
1308  }
1309  indices = ABC_ALLOC(int,n);
1310  if (indices == NULL) {
1311  dd->errorCode = CUDD_MEMORY_OUT;
1312  ABC_FREE(string);
1313  return(NULL);
1314  }
1315 
1316  for (i = 0; i < n; i++) {
1317  indices[i] = vars[i]->index;
1318  }
1319 
1320  result = Cudd_bddPickOneCube(dd,f,string);
1321  if (result == 0) {
1322  ABC_FREE(string);
1323  ABC_FREE(indices);
1324  return(NULL);
1325  }
1326 
1327  /* Randomize choice for don't cares. */
1328  for (i = 0; i < n; i++) {
1329  if (string[indices[i]] == 2)
1330  string[indices[i]] = (char) ((Cudd_Random() & 0x20) >> 5);
1331  }
1332 
1333  /* Build result BDD. */
1334  old = Cudd_ReadOne(dd);
1335  cuddRef(old);
1336 
1337  for (i = n-1; i >= 0; i--) {
1338  neW = Cudd_bddAnd(dd,old,Cudd_NotCond(vars[i],string[indices[i]]==0));
1339  if (neW == NULL) {
1340  ABC_FREE(string);
1341  ABC_FREE(indices);
1342  Cudd_RecursiveDeref(dd,old);
1343  return(NULL);
1344  }
1345  cuddRef(neW);
1346  Cudd_RecursiveDeref(dd,old);
1347  old = neW;
1348  }
1349 
1350 #ifdef DD_DEBUG
1351  /* Test. */
1352  if (Cudd_bddLeq(dd,old,f)) {
1353  cuddDeref(old);
1354  } else {
1355  Cudd_RecursiveDeref(dd,old);
1356  old = NULL;
1357  }
1358 #else
1359  cuddDeref(old);
1360 #endif
1361 
1362  ABC_FREE(string);
1363  ABC_FREE(indices);
1364  return(old);
1365 
1366 } /* end of Cudd_bddPickOneMinterm */
#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
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
long Cudd_Random(void)
Definition: cuddUtil.c:2702
static int size
Definition: cuddSign.c:86
DdNode * Cudd_ReadOne(DdManager *dd)
Definition: cuddAPI.c:987
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
int Cudd_bddPickOneCube(DdManager *ddm, DdNode *node, char *string)
Definition: cuddUtil.c:1221
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_bddPrintCover ( DdManager dd,
DdNode l,
DdNode u 
)

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

Synopsis [Prints a sum of prime implicants of a BDD.]

Description [Prints a sum of product cover for an incompletely specified function given by a lower bound and an upper bound. Each product is a prime implicant obtained by expanding the product corresponding to a path from node to the constant one. Uses the package default output file. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_PrintMinterm]

Definition at line 253 of file cuddUtil.c.

257 {
258  int *array;
259  int q, result;
260  DdNode *lb;
261 #ifdef DD_DEBUG
262  DdNode *cover;
263 #endif
264 
265  array = ABC_ALLOC(int, Cudd_ReadSize(dd));
266  if (array == NULL) return(0);
267  lb = l;
268  cuddRef(lb);
269 #ifdef DD_DEBUG
270  cover = Cudd_ReadLogicZero(dd);
271  cuddRef(cover);
272 #endif
273  while (lb != Cudd_ReadLogicZero(dd)) {
274  DdNode *implicant, *prime, *tmp;
275  int length;
276  implicant = Cudd_LargestCube(dd,lb,&length);
277  if (implicant == NULL) {
278  Cudd_RecursiveDeref(dd,lb);
279  ABC_FREE(array);
280  return(0);
281  }
282  cuddRef(implicant);
283  prime = Cudd_bddMakePrime(dd,implicant,u);
284  if (prime == NULL) {
285  Cudd_RecursiveDeref(dd,lb);
286  Cudd_RecursiveDeref(dd,implicant);
287  ABC_FREE(array);
288  return(0);
289  }
290  cuddRef(prime);
291  Cudd_RecursiveDeref(dd,implicant);
292  tmp = Cudd_bddAnd(dd,lb,Cudd_Not(prime));
293  if (tmp == NULL) {
294  Cudd_RecursiveDeref(dd,lb);
295  Cudd_RecursiveDeref(dd,prime);
296  ABC_FREE(array);
297  return(0);
298  }
299  cuddRef(tmp);
300  Cudd_RecursiveDeref(dd,lb);
301  lb = tmp;
302  result = Cudd_BddToCubeArray(dd,prime,array);
303  if (result == 0) {
304  Cudd_RecursiveDeref(dd,lb);
305  Cudd_RecursiveDeref(dd,prime);
306  ABC_FREE(array);
307  return(0);
308  }
309  for (q = 0; q < dd->size; q++) {
310  switch (array[q]) {
311  case 0:
312  (void) fprintf(dd->out, "0");
313  break;
314  case 1:
315  (void) fprintf(dd->out, "1");
316  break;
317  case 2:
318  (void) fprintf(dd->out, "-");
319  break;
320  default:
321  (void) fprintf(dd->out, "?");
322  }
323  }
324  (void) fprintf(dd->out, " 1\n");
325 #ifdef DD_DEBUG
326  tmp = Cudd_bddOr(dd,prime,cover);
327  if (tmp == NULL) {
328  Cudd_RecursiveDeref(dd,cover);
329  Cudd_RecursiveDeref(dd,lb);
330  Cudd_RecursiveDeref(dd,prime);
331  ABC_FREE(array);
332  return(0);
333  }
334  cuddRef(tmp);
335  Cudd_RecursiveDeref(dd,cover);
336  cover = tmp;
337 #endif
338  Cudd_RecursiveDeref(dd,prime);
339  }
340  (void) fprintf(dd->out, "\n");
341  Cudd_RecursiveDeref(dd,lb);
342  ABC_FREE(array);
343 #ifdef DD_DEBUG
344  if (!Cudd_bddLeq(dd,cover,u) || !Cudd_bddLeq(dd,l,cover)) {
345  Cudd_RecursiveDeref(dd,cover);
346  return(0);
347  }
348  Cudd_RecursiveDeref(dd,cover);
349 #endif
350  return(1);
351 
352 } /* end of Cudd_bddPrintCover */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
DdNode * Cudd_ReadLogicZero(DdManager *dd)
Definition: cuddAPI.c:1058
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int Cudd_ReadSize(DdManager *dd)
Definition: cuddAPI.c:1441
DdNode * Cudd_LargestCube(DdManager *manager, DdNode *f, int *length)
Definition: cuddSat.c:285
DdNode * Cudd_bddMakePrime(DdManager *dd, DdNode *cube, DdNode *f)
Definition: cuddSat.c:864
int Cudd_BddToCubeArray(DdManager *dd, DdNode *cube, int *array)
Definition: cuddUtil.c:2346
FILE * out
Definition: cuddInt.h:441
DdNode * Cudd_bddOr(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:381
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
int Cudd_BddToCubeArray ( DdManager dd,
DdNode cube,
int *  array 
)

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

Synopsis [Builds a positional array from the BDD of a cube.]

Description [Builds a positional array from the BDD of a cube. Array must have one entry for each BDD variable. The positional array has 1 in i-th position if the variable of index i appears in true form in the cube; it has 0 in i-th position if the variable of index i appears in complemented form in the cube; finally, it has 2 in i-th position if the variable of index i does not appear in the cube. Returns 1 if successful (the BDD is indeed a cube); 0 otherwise.]

SideEffects [The result is in the array passed by reference.]

SeeAlso [Cudd_CubeArrayToBdd]

Definition at line 2346 of file cuddUtil.c.

2350 {
2351  DdNode *scan, *t, *e;
2352  int i;
2353  int size = Cudd_ReadSize(dd);
2354  DdNode *zero = Cudd_Not(DD_ONE(dd));
2355 
2356  for (i = size-1; i >= 0; i--) {
2357  array[i] = 2;
2358  }
2359  scan = cube;
2360  while (!Cudd_IsConstant(scan)) {
2361  int index = Cudd_Regular(scan)->index;
2362  cuddGetBranches(scan,&t,&e);
2363  if (t == zero) {
2364  array[index] = 0;
2365  scan = e;
2366  } else if (e == zero) {
2367  array[index] = 1;
2368  scan = t;
2369  } else {
2370  return(0); /* cube is not a cube */
2371  }
2372  }
2373  if (scan == zero) {
2374  return(0);
2375  } else {
2376  return(1);
2377  }
2378 
2379 } /* end of Cudd_BddToCubeArray */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define Cudd_Regular(node)
Definition: cudd.h:397
void cuddGetBranches(DdNode *g, DdNode **g1, DdNode **g0)
Definition: cuddCof.c:162
int Cudd_ReadSize(DdManager *dd)
Definition: cuddAPI.c:1441
static DdNode * zero
Definition: cuddUtil.c:148
static int size
Definition: cuddSign.c:86
#define DD_ONE(dd)
Definition: cuddInt.h:911
int Cudd_ClassifySupport ( DdManager dd,
DdNode f,
DdNode g,
DdNode **  common,
DdNode **  onlyF,
DdNode **  onlyG 
)

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

Synopsis [Classifies the variables in the support of two DDs.]

Description [Classifies the variables in the support of two DDs f and g, depending on whther they appear in both DDs, only in f, or only in g. Returns 1 if successful; 0 otherwise.]

SideEffects [The cubes of the three classes of variables are returned as side effects.]

SeeAlso [Cudd_Support Cudd_VectorSupport]

Definition at line 1085 of file cuddUtil.c.

1092 {
1093  int *supportF, *supportG;
1094  DdNode *tmp, *var;
1095  int i,j;
1096  int size;
1097 
1098  /* Allocate and initialize support arrays for ddSupportStep. */
1099  size = ddMax(dd->size, dd->sizeZ);
1100  supportF = ABC_ALLOC(int,size);
1101  if (supportF == NULL) {
1102  dd->errorCode = CUDD_MEMORY_OUT;
1103  return(0);
1104  }
1105  supportG = ABC_ALLOC(int,size);
1106  if (supportG == NULL) {
1107  dd->errorCode = CUDD_MEMORY_OUT;
1108  ABC_FREE(supportF);
1109  return(0);
1110  }
1111  for (i = 0; i < size; i++) {
1112  supportF[i] = 0;
1113  supportG[i] = 0;
1114  }
1115 
1116  /* Compute supports and clean up markers. */
1117  ddSupportStep(Cudd_Regular(f),supportF);
1119  ddSupportStep(Cudd_Regular(g),supportG);
1121 
1122  /* Classify variables and create cubes. */
1123  *common = *onlyF = *onlyG = DD_ONE(dd);
1124  cuddRef(*common); cuddRef(*onlyF); cuddRef(*onlyG);
1125  for (j = size - 1; j >= 0; j--) { /* for each level bottom-up */
1126  i = (j >= dd->size) ? j : dd->invperm[j];
1127  if (supportF[i] == 0 && supportG[i] == 0) continue;
1128  var = cuddUniqueInter(dd,i,dd->one,Cudd_Not(dd->one));
1129  cuddRef(var);
1130  if (supportG[i] == 0) {
1131  tmp = Cudd_bddAnd(dd,*onlyF,var);
1132  if (tmp == NULL) {
1133  Cudd_RecursiveDeref(dd,*common);
1134  Cudd_RecursiveDeref(dd,*onlyF);
1135  Cudd_RecursiveDeref(dd,*onlyG);
1136  Cudd_RecursiveDeref(dd,var);
1137  ABC_FREE(supportF); ABC_FREE(supportG);
1138  return(0);
1139  }
1140  cuddRef(tmp);
1141  Cudd_RecursiveDeref(dd,*onlyF);
1142  *onlyF = tmp;
1143  } else if (supportF[i] == 0) {
1144  tmp = Cudd_bddAnd(dd,*onlyG,var);
1145  if (tmp == NULL) {
1146  Cudd_RecursiveDeref(dd,*common);
1147  Cudd_RecursiveDeref(dd,*onlyF);
1148  Cudd_RecursiveDeref(dd,*onlyG);
1149  Cudd_RecursiveDeref(dd,var);
1150  ABC_FREE(supportF); ABC_FREE(supportG);
1151  return(0);
1152  }
1153  cuddRef(tmp);
1154  Cudd_RecursiveDeref(dd,*onlyG);
1155  *onlyG = tmp;
1156  } else {
1157  tmp = Cudd_bddAnd(dd,*common,var);
1158  if (tmp == NULL) {
1159  Cudd_RecursiveDeref(dd,*common);
1160  Cudd_RecursiveDeref(dd,*onlyF);
1161  Cudd_RecursiveDeref(dd,*onlyG);
1162  Cudd_RecursiveDeref(dd,var);
1163  ABC_FREE(supportF); ABC_FREE(supportG);
1164  return(0);
1165  }
1166  cuddRef(tmp);
1167  Cudd_RecursiveDeref(dd,*common);
1168  *common = tmp;
1169  }
1170  Cudd_RecursiveDeref(dd,var);
1171  }
1172 
1173  ABC_FREE(supportF); ABC_FREE(supportG);
1174  cuddDeref(*common); cuddDeref(*onlyF); cuddDeref(*onlyG);
1175  return(1);
1176 
1177 } /* end of Cudd_ClassifySupport */
#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
int size
Definition: cuddInt.h:361
int var(Lit p)
Definition: SolverTypes.h:62
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
if(last==0)
Definition: sparse_int.h:34
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * one
Definition: cuddInt.h:345
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
int * invperm
Definition: cuddInt.h:388
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
int Cudd_CountLeaves ( DdNode node)

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

Synopsis [Counts the number of leaves in a DD.]

Description [Counts the number of leaves in a DD. Returns the number of leaves in the DD rooted at node if successful; CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_PrintDebug]

Definition at line 1194 of file cuddUtil.c.

1196 {
1197  int i;
1198 
1199  i = ddLeavesInt(Cudd_Regular(node));
1200  ddClearFlag(Cudd_Regular(node));
1201  return(i);
1202 
1203 } /* end of Cudd_CountLeaves */
#define Cudd_Regular(node)
Definition: cudd.h:397
static int ddLeavesInt(DdNode *n)
Definition: cuddUtil.c:3766
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
double Cudd_CountMinterm ( DdManager manager,
DdNode node,
int  nvars 
)

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

Synopsis [Counts the number of minterms of a DD.]

Description [Counts the number of minterms of a DD. The function is assumed to depend on nvars variables. The minterm count is represented as a double, to allow for a larger number of variables. Returns the number of minterms of the function rooted at node if successful; (double) CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_PrintDebug Cudd_CountPath]

Definition at line 578 of file cuddUtil.c.

582 {
583  double max;
584  DdHashTable *table;
585  double res;
586  CUDD_VALUE_TYPE epsilon;
587 
588  background = manager->background;
589  zero = Cudd_Not(manager->one);
590 
591  max = pow(2.0,(double)nvars);
592  table = cuddHashTableInit(manager,1,2);
593  if (table == NULL) {
594  return((double)CUDD_OUT_OF_MEM);
595  }
596  epsilon = Cudd_ReadEpsilon(manager);
597  Cudd_SetEpsilon(manager,(CUDD_VALUE_TYPE)0.0);
598  res = ddCountMintermAux(node,max,table);
599  cuddHashTableQuit(table);
600  Cudd_SetEpsilon(manager,epsilon);
601 
602  return(res);
603 
604 } /* end of Cudd_CountMinterm */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
#define Cudd_Not(node)
Definition: cudd.h:367
static DdNode * background
Definition: cuddUtil.c:148
void Cudd_SetEpsilon(DdManager *dd, CUDD_VALUE_TYPE ep)
Definition: cuddAPI.c:2451
static DdNode * zero
Definition: cuddUtil.c:148
static double max
Definition: cuddSubsetHB.c:134
void cuddHashTableQuit(DdHashTable *hash)
Definition: cuddLCache.c:595
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
DdNode * one
Definition: cuddInt.h:345
static double ddCountMintermAux(DdNode *node, double max, DdHashTable *table)
Definition: cuddUtil.c:3439
DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize)
Definition: cuddLCache.c:538
CUDD_VALUE_TYPE Cudd_ReadEpsilon(DdManager *dd)
Definition: cuddAPI.c:2430
DdNode * background
Definition: cuddInt.h:349
double Cudd_CountPath ( DdNode node)

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

Synopsis [Counts the number of paths of a DD.]

Description [Counts the number of paths of a DD. Paths to all terminal nodes are counted. The path count is represented as a double, to allow for a larger number of variables. Returns the number of paths of the function rooted at node if successful; (double) CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_CountMinterm]

Definition at line 623 of file cuddUtil.c.

625 {
626 
627  st__table *table;
628  double i;
629 
631  if (table == NULL) {
632  return((double)CUDD_OUT_OF_MEM);
633  }
634  i = ddCountPathAux(Cudd_Regular(node),table);
635  st__foreach(table, cuddStCountfree, NULL);
636  st__free_table(table);
637  return(i);
638 
639 } /* end of Cudd_CountPath */
void st__free_table(st__table *table)
Definition: st.c:81
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
#define Cudd_Regular(node)
Definition: cudd.h:397
enum st__retval cuddStCountfree(char *key, char *value, char *arg)
Definition: cuddUtil.c:2895
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
static double ddCountPathAux(DdNode *node, st__table *table)
Definition: cuddUtil.c:3512
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
int st__ptrhash(const char *, int)
Definition: st.c:468
double Cudd_CountPathsToNonZero ( DdNode node)

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

Synopsis [Counts the number of paths to a non-zero terminal of a DD.]

Description [Counts the number of paths to a non-zero terminal of a DD. The path count is represented as a double, to allow for a larger number of variables. Returns the number of paths of the function rooted at node.]

SideEffects [None]

SeeAlso [Cudd_CountMinterm Cudd_CountPath]

Definition at line 707 of file cuddUtil.c.

709 {
710 
711  st__table *table;
712  double i;
713 
715  if (table == NULL) {
716  return((double)CUDD_OUT_OF_MEM);
717  }
718  i = ddCountPathsToNonZero(node,table);
719  st__foreach(table, cuddStCountfree, NULL);
720  st__free_table(table);
721  return(i);
722 
723 } /* end of Cudd_CountPathsToNonZero */
void st__free_table(st__table *table)
Definition: st.c:81
static double ddCountPathsToNonZero(DdNode *N, st__table *table)
Definition: cuddUtil.c:3645
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
enum st__retval cuddStCountfree(char *key, char *value, char *arg)
Definition: cuddUtil.c:2895
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
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
int st__ptrhash(const char *, int)
Definition: st.c:468
DdNode* Cudd_CubeArrayToBdd ( DdManager dd,
int *  array 
)

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

Synopsis [Builds the BDD of a cube from a positional array.]

Description [Builds a cube from a positional array. The array must have one integer entry for each BDD variable. If the i-th entry is 1, the variable of index i appears in true form in the cube; If the i-th entry is 0, the variable of index i appears complemented in the cube; otherwise the variable does not appear in the cube. Returns a pointer to the BDD for the cube if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddComputeCube Cudd_IndicesToCube Cudd_BddToCubeArray]

Definition at line 2298 of file cuddUtil.c.

2301 {
2302  DdNode *cube, *var, *tmp;
2303  int i;
2304  int size = Cudd_ReadSize(dd);
2305 
2306  cube = DD_ONE(dd);
2307  cuddRef(cube);
2308  for (i = size - 1; i >= 0; i--) {
2309  if ((array[i] & ~1) == 0) {
2310  var = Cudd_bddIthVar(dd,i);
2311  tmp = Cudd_bddAnd(dd,cube,Cudd_NotCond(var,array[i]==0));
2312  if (tmp == NULL) {
2313  Cudd_RecursiveDeref(dd,cube);
2314  return(NULL);
2315  }
2316  cuddRef(tmp);
2317  Cudd_RecursiveDeref(dd,cube);
2318  cube = tmp;
2319  }
2320  }
2321  cuddDeref(cube);
2322  return(cube);
2323 
2324 } /* end of Cudd_CubeArrayToBdd */
#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
int var(Lit p)
Definition: SolverTypes.h:62
int Cudd_ReadSize(DdManager *dd)
Definition: cuddAPI.c:1441
static int size
Definition: cuddSign.c:86
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define DD_ONE(dd)
Definition: cuddInt.h:911
int Cudd_DagSize ( DdNode node)

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

Synopsis [Counts the number of nodes in a DD.]

Description [Counts the number of nodes in a DD. Returns the number of nodes in the graph rooted at node.]

SideEffects [None]

SeeAlso [Cudd_SharingSize Cudd_PrintDebug]

Definition at line 442 of file cuddUtil.c.

444 {
445  int i;
446 
447  i = ddDagInt(Cudd_Regular(node));
448  ddClearFlag(Cudd_Regular(node));
449 
450  return(i);
451 
452 } /* end of Cudd_DagSize */
#define Cudd_Regular(node)
Definition: cudd.h:397
static int ddDagInt(DdNode *n)
Definition: cuddUtil.c:3165
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
double Cudd_Density ( DdManager dd,
DdNode f,
int  nvars 
)

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

Synopsis [Computes the density of a BDD or ADD.]

Description [Computes the density of a BDD or ADD. The density is the ratio of the number of minterms to the number of nodes. If 0 is passed as number of variables, the number of variables existing in the manager is used. Returns the density if successful; (double) CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_CountMinterm Cudd_DagSize]

Definition at line 2802 of file cuddUtil.c.

2806 {
2807  double minterms;
2808  int nodes;
2809  double density;
2810 
2811  if (nvars == 0) nvars = dd->size;
2812  minterms = Cudd_CountMinterm(dd,f,nvars);
2813  if (minterms == (double) CUDD_OUT_OF_MEM) return(minterms);
2814  nodes = Cudd_DagSize(f);
2815  density = minterms / (double) nodes;
2816  return(density);
2817 
2818 } /* end of Cudd_Density */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
int size
Definition: cuddInt.h:361
int Cudd_DagSize(DdNode *node)
Definition: cuddUtil.c:442
double Cudd_CountMinterm(DdManager *manager, DdNode *node, int nvars)
Definition: cuddUtil.c:578
pset minterms()
int Cudd_EpdCountMinterm ( DdManager manager,
DdNode node,
int  nvars,
EpDouble epd 
)

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

Synopsis [Counts the number of minterms of a DD with extended precision.]

Description [Counts the number of minterms of a DD with extended precision. The function is assumed to depend on nvars variables. The minterm count is represented as an EpDouble, to allow any number of variables. Returns 0 if successful; CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_PrintDebug Cudd_CountPath]

Definition at line 657 of file cuddUtil.c.

662 {
663  EpDouble max, tmp;
664  st__table *table;
665  int status;
666 
667  background = manager->background;
668  zero = Cudd_Not(manager->one);
669 
670  EpdPow2(nvars, &max);
672  if (table == NULL) {
673  EpdMakeZero(epd, 0);
674  return(CUDD_OUT_OF_MEM);
675  }
676  status = ddEpdCountMintermAux(Cudd_Regular(node),&max,epd,table);
677  st__foreach(table, ddEpdFree, NULL);
678  st__free_table(table);
679  if (status == CUDD_OUT_OF_MEM) {
680  EpdMakeZero(epd, 0);
681  return(CUDD_OUT_OF_MEM);
682  }
683  if (Cudd_IsComplement(node)) {
684  EpdSubtract3(&max, epd, &tmp);
685  EpdCopy(&tmp, epd);
686  }
687  return(0);
688 
689 } /* end of Cudd_EpdCountMinterm */
void st__free_table(st__table *table)
Definition: st.c:81
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
int EpdCmp(const char *key1, const char *key2)
Definition: epd.c:93
#define Cudd_Not(node)
Definition: cudd.h:367
void EpdCopy(EpDouble *from, EpDouble *to)
Definition: epd.c:1182
#define Cudd_Regular(node)
Definition: cudd.h:397
static enum st__retval ddEpdFree(char *key, char *value, char *arg)
Definition: cuddUtil.c:3922
static DdNode * background
Definition: cuddUtil.c:148
void EpdPow2(int n, EpDouble *epd)
Definition: epd.c:917
void EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
Definition: epd.c:850
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
#define Cudd_IsComplement(node)
Definition: cudd.h:425
Definition: st.h:52
static DdNode * zero
Definition: cuddUtil.c:148
static double max
Definition: cuddSubsetHB.c:134
void EpdMakeZero(EpDouble *epd, int sign)
Definition: epd.c:1137
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
DdNode * one
Definition: cuddInt.h:345
static int ddEpdCountMintermAux(DdNode *node, EpDouble *max, EpDouble *epd, st__table *table)
Definition: cuddUtil.c:3573
int st__ptrhash(const char *, int)
Definition: st.c:468
DdNode * background
Definition: cuddInt.h:349
int Cudd_EstimateCofactor ( DdManager dd,
DdNode f,
int  i,
int  phase 
)

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

Synopsis [Estimates the number of nodes in a cofactor of a DD.]

Description [Estimates the number of nodes in a cofactor of a DD. Returns an estimate of the number of nodes in a cofactor of the graph rooted at node with respect to the variable whose index is i. In case of failure, returns CUDD_OUT_OF_MEM. This function uses a refinement of the algorithm of Cabodi et al. (ICCAD96). The refinement allows the procedure to account for part of the recombination that may occur in the part of the cofactor above the cofactoring variable. This procedure does no create any new node. It does keep a small table of results; therefore it may run out of memory. If this is a concern, one should use Cudd_EstimateCofactorSimple, which is faster, does not allocate any memory, but is less accurate.]

SideEffects [None]

SeeAlso [Cudd_DagSize Cudd_EstimateCofactorSimple]

Definition at line 477 of file cuddUtil.c.

483 {
484  int val;
485  DdNode *ptr;
486  st__table *table;
487 
489  if (table == NULL) return(CUDD_OUT_OF_MEM);
490  val = cuddEstimateCofactor(dd,table,Cudd_Regular(f),i,phase,&ptr);
492  st__free_table(table);
493 
494  return(val);
495 
496 } /* end of Cudd_EstimateCofactor */
void st__free_table(st__table *table)
Definition: st.c:81
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
static int cuddEstimateCofactor(DdManager *dd, st__table *table, DdNode *node, int i, int phase, DdNode **ptr)
Definition: cuddUtil.c:3240
Definition: cudd.h:278
#define Cudd_Regular(node)
Definition: cudd.h:397
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
static pcube phase
Definition: cvrm.c:405
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
int st__ptrhash(const char *, int)
Definition: st.c:468
int Cudd_EstimateCofactorSimple ( DdNode node,
int  i 
)

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

Synopsis [Estimates the number of nodes in a cofactor of a DD.]

Description [Estimates the number of nodes in a cofactor of a DD. Returns an estimate of the number of nodes in the positive cofactor of the graph rooted at node with respect to the variable whose index is i. This procedure implements with minor changes the algorithm of Cabodi et al. (ICCAD96). It does not allocate any memory, it does not change the state of the manager, and it is fast. However, it has been observed to overestimate the size of the cofactor by as much as a factor of 2.]

SideEffects [None]

SeeAlso [Cudd_DagSize]

Definition at line 517 of file cuddUtil.c.

520 {
521  int val;
522 
524  ddClearFlag(Cudd_Regular(node));
525 
526  return(val);
527 
528 } /* end of Cudd_EstimateCofactorSimple */
static int cuddEstimateCofactorSimple(DdNode *node, int i)
Definition: cuddUtil.c:3399
#define Cudd_Regular(node)
Definition: cudd.h:397
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
DdGen* Cudd_FirstCube ( DdManager dd,
DdNode f,
int **  cube,
CUDD_VALUE_TYPE value 
)

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

Synopsis [Finds the first cube of a decision diagram.]

Description [Defines an iterator on the onset of a decision diagram and finds its first cube. Returns a generator that contains the information necessary to continue the enumeration if successful; NULL otherwise.

A cube is represented as an array of literals, which are integers in {0, 1, 2}; 0 represents a complemented literal, 1 represents an uncomplemented literal, and 2 stands for don't care. The enumeration produces a disjoint cover of the function associated with the diagram. The size of the array equals the number of variables in the manager at the time Cudd_FirstCube is called.

For each cube, a value is also returned. This value is always 1 for a BDD, while it may be different from 1 for an ADD. For BDDs, the offset is the set of cubes whose value is the logical zero. For ADDs, the offset is the set of cubes whose value is the background value. The cubes of the offset are not enumerated.]

SideEffects [The first cube and its value are returned as side effects.]

SeeAlso [Cudd_ForeachCube Cudd_NextCube Cudd_GenFree Cudd_IsGenEmpty Cudd_FirstNode]

Definition at line 1798 of file cuddUtil.c.

1803 {
1804  DdGen *gen;
1805  DdNode *top, *treg, *next, *nreg, *prev, *preg;
1806  int i;
1807  int nvars;
1808 
1809  /* Sanity Check. */
1810  if (dd == NULL || f == NULL) return(NULL);
1811 
1812  /* Allocate generator an initialize it. */
1813  gen = ABC_ALLOC(DdGen,1);
1814  if (gen == NULL) {
1815  dd->errorCode = CUDD_MEMORY_OUT;
1816  return(NULL);
1817  }
1818 
1819  gen->manager = dd;
1820  gen->type = CUDD_GEN_CUBES;
1821  gen->status = CUDD_GEN_EMPTY;
1822  gen->gen.cubes.cube = NULL;
1823  gen->gen.cubes.value = DD_ZERO_VAL;
1824  gen->stack.sp = 0;
1825  gen->stack.stack = NULL;
1826  gen->node = NULL;
1827 
1828  nvars = dd->size;
1829  gen->gen.cubes.cube = ABC_ALLOC(int,nvars);
1830  if (gen->gen.cubes.cube == NULL) {
1831  dd->errorCode = CUDD_MEMORY_OUT;
1832  ABC_FREE(gen);
1833  return(NULL);
1834  }
1835  for (i = 0; i < nvars; i++) gen->gen.cubes.cube[i] = 2;
1836 
1837  /* The maximum stack depth is one plus the number of variables.
1838  ** because a path may have nodes at all levels, including the
1839  ** constant level.
1840  */
1841  gen->stack.stack = ABC_ALLOC(DdNodePtr, nvars+1);
1842  if (gen->stack.stack == NULL) {
1843  dd->errorCode = CUDD_MEMORY_OUT;
1844  ABC_FREE(gen->gen.cubes.cube);
1845  ABC_FREE(gen);
1846  return(NULL);
1847  }
1848  for (i = 0; i <= nvars; i++) gen->stack.stack[i] = NULL;
1849 
1850  /* Find the first cube of the onset. */
1851  gen->stack.stack[gen->stack.sp] = f; gen->stack.sp++;
1852 
1853  while (1) {
1854  top = gen->stack.stack[gen->stack.sp-1];
1855  treg = Cudd_Regular(top);
1856  if (!cuddIsConstant(treg)) {
1857  /* Take the else branch first. */
1858  gen->gen.cubes.cube[treg->index] = 0;
1859  next = cuddE(treg);
1860  if (top != treg) next = Cudd_Not(next);
1861  gen->stack.stack[gen->stack.sp] = next; gen->stack.sp++;
1862  } else if (top == Cudd_Not(DD_ONE(dd)) || top == dd->background) {
1863  /* Backtrack */
1864  while (1) {
1865  if (gen->stack.sp == 1) {
1866  /* The current node has no predecessor. */
1867  gen->status = CUDD_GEN_EMPTY;
1868  gen->stack.sp--;
1869  goto done;
1870  }
1871  prev = gen->stack.stack[gen->stack.sp-2];
1872  preg = Cudd_Regular(prev);
1873  nreg = cuddT(preg);
1874  if (prev != preg) {next = Cudd_Not(nreg);} else {next = nreg;}
1875  if (next != top) { /* follow the then branch next */
1876  gen->gen.cubes.cube[preg->index] = 1;
1877  gen->stack.stack[gen->stack.sp-1] = next;
1878  break;
1879  }
1880  /* Pop the stack and try again. */
1881  gen->gen.cubes.cube[preg->index] = 2;
1882  gen->stack.sp--;
1883  top = gen->stack.stack[gen->stack.sp-1];
1884  treg = Cudd_Regular(top);
1885  }
1886  } else {
1887  gen->status = CUDD_GEN_NONEMPTY;
1888  gen->gen.cubes.value = cuddV(top);
1889  goto done;
1890  }
1891  }
1892 
1893 done:
1894  *cube = gen->gen.cubes.cube;
1895  *value = gen->gen.cubes.value;
1896  return(gen);
1897 
1898 } /* end of Cudd_FirstCube */
DdNode * node
Definition: cuddInt.h:232
int type
Definition: cuddInt.h:206
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
struct DdGen::@30::@32 cubes
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: cuddInt.h:204
#define DD_ZERO_VAL
Definition: cuddInt.h:108
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
#define cuddV(node)
Definition: cuddInt.h:668
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define CUDD_GEN_CUBES
Definition: cuddInt.h:192
#define cuddE(node)
Definition: cuddInt.h:652
int value
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * background
Definition: cuddInt.h:349
int status
Definition: cuddInt.h:207
DdGen* Cudd_FirstNode ( DdManager dd,
DdNode f,
DdNode **  node 
)

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

Synopsis [Finds the first node of a decision diagram.]

Description [Defines an iterator on the nodes of a decision diagram and finds its first node. Returns a generator that contains the information necessary to continue the enumeration if successful; NULL otherwise. The nodes are enumerated in a reverse topological order, so that a node is always preceded in the enumeration by its descendants.]

SideEffects [The first node is returned as a side effect.]

SeeAlso [Cudd_ForeachNode Cudd_NextNode Cudd_GenFree Cudd_IsGenEmpty Cudd_FirstCube]

Definition at line 2400 of file cuddUtil.c.

2404 {
2405  DdGen *gen;
2406  int size;
2407 
2408  /* Sanity Check. */
2409  if (dd == NULL || f == NULL) return(NULL);
2410 
2411  /* Allocate generator an initialize it. */
2412  gen = ABC_ALLOC(DdGen,1);
2413  if (gen == NULL) {
2414  dd->errorCode = CUDD_MEMORY_OUT;
2415  return(NULL);
2416  }
2417 
2418  gen->manager = dd;
2419  gen->type = CUDD_GEN_NODES;
2420  gen->status = CUDD_GEN_EMPTY;
2421  gen->stack.sp = 0;
2422  gen->node = NULL;
2423 
2424  /* Collect all the nodes on the generator stack for later perusal. */
2425  gen->stack.stack = cuddNodeArray(Cudd_Regular(f), &size);
2426  if (gen->stack.stack == NULL) {
2427  ABC_FREE(gen);
2428  dd->errorCode = CUDD_MEMORY_OUT;
2429  return(NULL);
2430  }
2431  gen->gen.nodes.size = size;
2432 
2433  /* Find the first node. */
2434  if (gen->stack.sp < gen->gen.nodes.size) {
2435  gen->status = CUDD_GEN_NONEMPTY;
2436  gen->node = gen->stack.stack[gen->stack.sp];
2437  *node = gen->node;
2438  }
2439 
2440  return(gen);
2441 
2442 } /* end of Cudd_FirstNode */
DdNode * node
Definition: cuddInt.h:232
int type
Definition: cuddInt.h:206
#define CUDD_GEN_NODES
Definition: cuddInt.h:194
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: cuddInt.h:204
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
static int size
Definition: cuddSign.c:86
DdNodePtr * cuddNodeArray(DdNode *f, int *n)
Definition: cuddUtil.c:2979
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
#define ABC_FREE(obj)
Definition: abc_global.h:232
struct DdGen::@30::@34 nodes
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int status
Definition: cuddInt.h:207
DdGen* Cudd_FirstPrime ( DdManager dd,
DdNode l,
DdNode u,
int **  cube 
)

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

Synopsis [Finds the first prime of a Boolean function.]

Description [Defines an iterator on a pair of BDDs describing a (possibly incompletely specified) Boolean functions and finds the first cube of a cover of the function. Returns a generator that contains the information necessary to continue the enumeration if successful; NULL otherwise.

The two argument BDDs are the lower and upper bounds of an interval. It is a mistake to call this function with a lower bound that is not less than or equal to the upper bound.

A cube is represented as an array of literals, which are integers in {0, 1, 2}; 0 represents a complemented literal, 1 represents an uncomplemented literal, and 2 stands for don't care. The enumeration produces a prime and irredundant cover of the function associated with the two BDDs. The size of the array equals the number of variables in the manager at the time Cudd_FirstCube is called.

This iterator can only be used on BDDs.]

SideEffects [The first cube is returned as side effect.]

SeeAlso [Cudd_ForeachPrime Cudd_NextPrime Cudd_GenFree Cudd_IsGenEmpty Cudd_FirstCube Cudd_FirstNode]

Definition at line 2028 of file cuddUtil.c.

2033 {
2034  DdGen *gen;
2035  DdNode *implicant, *prime, *tmp;
2036  int length, result;
2037 
2038  /* Sanity Check. */
2039  if (dd == NULL || l == NULL || u == NULL) return(NULL);
2040 
2041  /* Allocate generator an initialize it. */
2042  gen = ABC_ALLOC(DdGen,1);
2043  if (gen == NULL) {
2044  dd->errorCode = CUDD_MEMORY_OUT;
2045  return(NULL);
2046  }
2047 
2048  gen->manager = dd;
2049  gen->type = CUDD_GEN_PRIMES;
2050  gen->status = CUDD_GEN_EMPTY;
2051  gen->gen.primes.cube = NULL;
2052  gen->gen.primes.ub = u;
2053  gen->stack.sp = 0;
2054  gen->stack.stack = NULL;
2055  gen->node = l;
2056  cuddRef(l);
2057 
2058  gen->gen.primes.cube = ABC_ALLOC(int,dd->size);
2059  if (gen->gen.primes.cube == NULL) {
2060  dd->errorCode = CUDD_MEMORY_OUT;
2061  ABC_FREE(gen);
2062  return(NULL);
2063  }
2064 
2065  if (gen->node == Cudd_ReadLogicZero(dd)) {
2066  gen->status = CUDD_GEN_EMPTY;
2067  } else {
2068  implicant = Cudd_LargestCube(dd,gen->node,&length);
2069  if (implicant == NULL) {
2070  Cudd_RecursiveDeref(dd,gen->node);
2071  ABC_FREE(gen->gen.primes.cube);
2072  ABC_FREE(gen);
2073  return(NULL);
2074  }
2075  cuddRef(implicant);
2076  prime = Cudd_bddMakePrime(dd,implicant,gen->gen.primes.ub);
2077  if (prime == NULL) {
2078  Cudd_RecursiveDeref(dd,gen->node);
2079  Cudd_RecursiveDeref(dd,implicant);
2080  ABC_FREE(gen->gen.primes.cube);
2081  ABC_FREE(gen);
2082  return(NULL);
2083  }
2084  cuddRef(prime);
2085  Cudd_RecursiveDeref(dd,implicant);
2086  tmp = Cudd_bddAnd(dd,gen->node,Cudd_Not(prime));
2087  if (tmp == NULL) {
2088  Cudd_RecursiveDeref(dd,gen->node);
2089  Cudd_RecursiveDeref(dd,prime);
2090  ABC_FREE(gen->gen.primes.cube);
2091  ABC_FREE(gen);
2092  return(NULL);
2093  }
2094  cuddRef(tmp);
2095  Cudd_RecursiveDeref(dd,gen->node);
2096  gen->node = tmp;
2097  result = Cudd_BddToCubeArray(dd,prime,gen->gen.primes.cube);
2098  if (result == 0) {
2099  Cudd_RecursiveDeref(dd,gen->node);
2100  Cudd_RecursiveDeref(dd,prime);
2101  ABC_FREE(gen->gen.primes.cube);
2102  ABC_FREE(gen);
2103  return(NULL);
2104  }
2105  Cudd_RecursiveDeref(dd,prime);
2106  gen->status = CUDD_GEN_NONEMPTY;
2107  }
2108  *cube = gen->gen.primes.cube;
2109  return(gen);
2110 
2111 } /* end of Cudd_FirstPrime */
#define cuddRef(n)
Definition: cuddInt.h:584
DdNode * node
Definition: cuddInt.h:232
int type
Definition: cuddInt.h:206
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
DdNode * Cudd_ReadLogicZero(DdManager *dd)
Definition: cuddAPI.c:1058
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: cuddInt.h:204
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
DdNode * Cudd_LargestCube(DdManager *manager, DdNode *f, int *length)
Definition: cuddSat.c:285
DdNode * Cudd_bddMakePrime(DdManager *dd, DdNode *cube, DdNode *f)
Definition: cuddSat.c:864
int Cudd_BddToCubeArray(DdManager *dd, DdNode *cube, int *array)
Definition: cuddUtil.c:2346
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
struct DdGen::@30::@33 primes
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
#define CUDD_GEN_PRIMES
Definition: cuddInt.h:193
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int status
Definition: cuddInt.h:207
int Cudd_GenFree ( DdGen gen)

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

Synopsis [Frees a CUDD generator.]

Description [Frees a CUDD generator. Always returns 0, so that it can be used in mis-like foreach constructs.]

SideEffects [None]

SeeAlso [Cudd_ForeachCube Cudd_ForeachNode Cudd_FirstCube Cudd_NextCube Cudd_FirstNode Cudd_NextNode Cudd_IsGenEmpty]

Definition at line 2491 of file cuddUtil.c.

2493 {
2494  if (gen == NULL) return(0);
2495  switch (gen->type) {
2496  case CUDD_GEN_CUBES:
2497  case CUDD_GEN_ZDD_PATHS:
2498  ABC_FREE(gen->gen.cubes.cube);
2499  ABC_FREE(gen->stack.stack);
2500  break;
2501  case CUDD_GEN_PRIMES:
2502  ABC_FREE(gen->gen.primes.cube);
2503  Cudd_RecursiveDeref(gen->manager,gen->node);
2504  break;
2505  case CUDD_GEN_NODES:
2506  ABC_FREE(gen->stack.stack);
2507  break;
2508  default:
2509  return(0);
2510  }
2511  ABC_FREE(gen);
2512  return(0);
2513 
2514 } /* end of Cudd_GenFree */
DdNode * node
Definition: cuddInt.h:232
int type
Definition: cuddInt.h:206
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
#define CUDD_GEN_ZDD_PATHS
Definition: cuddInt.h:195
struct DdGen::@30::@32 cubes
#define CUDD_GEN_NODES
Definition: cuddInt.h:194
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
union DdGen::@30 gen
struct DdGen::@30::@33 primes
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define CUDD_GEN_CUBES
Definition: cuddInt.h:192
#define CUDD_GEN_PRIMES
Definition: cuddInt.h:193
DdNode* Cudd_IndicesToCube ( DdManager dd,
int *  array,
int  n 
)

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

Synopsis [Builds a cube of BDD variables from an array of indices.]

Description [Builds a cube of BDD variables from an array of indices. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddComputeCube Cudd_CubeArrayToBdd]

Definition at line 2553 of file cuddUtil.c.

2557 {
2558  DdNode *cube, *tmp;
2559  int i;
2560 
2561  cube = DD_ONE(dd);
2562  cuddRef(cube);
2563  for (i = n - 1; i >= 0; i--) {
2564  tmp = Cudd_bddAnd(dd,Cudd_bddIthVar(dd,array[i]),cube);
2565  if (tmp == NULL) {
2566  Cudd_RecursiveDeref(dd,cube);
2567  return(NULL);
2568  }
2569  cuddRef(tmp);
2570  Cudd_RecursiveDeref(dd,cube);
2571  cube = tmp;
2572  }
2573 
2574  cuddDeref(cube);
2575  return(cube);
2576 
2577 } /* end of Cudd_IndicesToCube */
#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 * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define DD_ONE(dd)
Definition: cuddInt.h:911
int Cudd_IsGenEmpty ( DdGen gen)

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

Synopsis [Queries the status of a generator.]

Description [Queries the status of a generator. Returns 1 if the generator is empty or NULL; 0 otherswise.]

SideEffects [None]

SeeAlso [Cudd_ForeachCube Cudd_ForeachNode Cudd_FirstCube Cudd_NextCube Cudd_FirstNode Cudd_NextNode Cudd_GenFree]

Definition at line 2531 of file cuddUtil.c.

2533 {
2534  if (gen == NULL) return(1);
2535  return(gen->status == CUDD_GEN_EMPTY);
2536 
2537 } /* end of Cudd_IsGenEmpty */
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
int status
Definition: cuddInt.h:207
int Cudd_NextCube ( DdGen gen,
int **  cube,
CUDD_VALUE_TYPE value 
)

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

Synopsis [Generates the next cube of a decision diagram onset.]

Description [Generates the next cube of a decision diagram onset, using generator gen. Returns 0 if the enumeration is completed; 1 otherwise.]

SideEffects [The cube and its value are returned as side effects. The generator is modified.]

SeeAlso [Cudd_ForeachCube Cudd_FirstCube Cudd_GenFree Cudd_IsGenEmpty Cudd_NextNode]

Definition at line 1917 of file cuddUtil.c.

1921 {
1922  DdNode *top, *treg, *next, *nreg, *prev, *preg;
1923  DdManager *dd = gen->manager;
1924 
1925  /* Backtrack from previously reached terminal node. */
1926  while (1) {
1927  if (gen->stack.sp == 1) {
1928  /* The current node has no predecessor. */
1929  gen->status = CUDD_GEN_EMPTY;
1930  gen->stack.sp--;
1931  goto done;
1932  }
1933  top = gen->stack.stack[gen->stack.sp-1];
1934  treg = Cudd_Regular(top);
1935  prev = gen->stack.stack[gen->stack.sp-2];
1936  preg = Cudd_Regular(prev);
1937  nreg = cuddT(preg);
1938  if (prev != preg) {next = Cudd_Not(nreg);} else {next = nreg;}
1939  if (next != top) { /* follow the then branch next */
1940  gen->gen.cubes.cube[preg->index] = 1;
1941  gen->stack.stack[gen->stack.sp-1] = next;
1942  break;
1943  }
1944  /* Pop the stack and try again. */
1945  gen->gen.cubes.cube[preg->index] = 2;
1946  gen->stack.sp--;
1947  }
1948 
1949  while (1) {
1950  top = gen->stack.stack[gen->stack.sp-1];
1951  treg = Cudd_Regular(top);
1952  if (!cuddIsConstant(treg)) {
1953  /* Take the else branch first. */
1954  gen->gen.cubes.cube[treg->index] = 0;
1955  next = cuddE(treg);
1956  if (top != treg) next = Cudd_Not(next);
1957  gen->stack.stack[gen->stack.sp] = next; gen->stack.sp++;
1958  } else if (top == Cudd_Not(DD_ONE(dd)) || top == dd->background) {
1959  /* Backtrack */
1960  while (1) {
1961  if (gen->stack.sp == 1) {
1962  /* The current node has no predecessor. */
1963  gen->status = CUDD_GEN_EMPTY;
1964  gen->stack.sp--;
1965  goto done;
1966  }
1967  prev = gen->stack.stack[gen->stack.sp-2];
1968  preg = Cudd_Regular(prev);
1969  nreg = cuddT(preg);
1970  if (prev != preg) {next = Cudd_Not(nreg);} else {next = nreg;}
1971  if (next != top) { /* follow the then branch next */
1972  gen->gen.cubes.cube[preg->index] = 1;
1973  gen->stack.stack[gen->stack.sp-1] = next;
1974  break;
1975  }
1976  /* Pop the stack and try again. */
1977  gen->gen.cubes.cube[preg->index] = 2;
1978  gen->stack.sp--;
1979  top = gen->stack.stack[gen->stack.sp-1];
1980  treg = Cudd_Regular(top);
1981  }
1982  } else {
1983  gen->status = CUDD_GEN_NONEMPTY;
1984  gen->gen.cubes.value = cuddV(top);
1985  goto done;
1986  }
1987  }
1988 
1989 done:
1990  if (gen->status == CUDD_GEN_EMPTY) return(0);
1991  *cube = gen->gen.cubes.cube;
1992  *value = gen->gen.cubes.value;
1993  return(1);
1994 
1995 } /* end of Cudd_NextCube */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
struct DdGen::@30::@32 cubes
#define Cudd_Regular(node)
Definition: cudd.h:397
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
#define cuddV(node)
Definition: cuddInt.h:668
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
int value
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * background
Definition: cuddInt.h:349
int status
Definition: cuddInt.h:207
int Cudd_NextNode ( DdGen gen,
DdNode **  node 
)

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

Synopsis [Finds the next node of a decision diagram.]

Description [Finds the node of a decision diagram, using generator gen. Returns 0 if the enumeration is completed; 1 otherwise.]

SideEffects [The next node is returned as a side effect.]

SeeAlso [Cudd_ForeachNode Cudd_FirstNode Cudd_GenFree Cudd_IsGenEmpty Cudd_NextCube]

Definition at line 2459 of file cuddUtil.c.

2462 {
2463  /* Find the next node. */
2464  gen->stack.sp++;
2465  if (gen->stack.sp < gen->gen.nodes.size) {
2466  gen->node = gen->stack.stack[gen->stack.sp];
2467  *node = gen->node;
2468  return(1);
2469  } else {
2470  gen->status = CUDD_GEN_EMPTY;
2471  return(0);
2472  }
2473 
2474 } /* end of Cudd_NextNode */
DdNode * node
Definition: cuddInt.h:232
DdNode ** stack
Definition: cuddInt.h:227
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
struct DdGen::@30::@34 nodes
int status
Definition: cuddInt.h:207
int Cudd_NextPrime ( DdGen gen,
int **  cube 
)

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

Synopsis [Generates the next prime of a Boolean function.]

Description [Generates the next cube of a Boolean function, using generator gen. Returns 0 if the enumeration is completed; 1 otherwise.]

SideEffects [The cube and is returned as side effects. The generator is modified.]

SeeAlso [Cudd_ForeachPrime Cudd_FirstPrime Cudd_GenFree Cudd_IsGenEmpty Cudd_NextCube Cudd_NextNode]

Definition at line 2130 of file cuddUtil.c.

2133 {
2134  DdNode *implicant, *prime, *tmp;
2135  DdManager *dd = gen->manager;
2136  int length, result;
2137 
2138  if (gen->node == Cudd_ReadLogicZero(dd)) {
2139  gen->status = CUDD_GEN_EMPTY;
2140  } else {
2141  implicant = Cudd_LargestCube(dd,gen->node,&length);
2142  if (implicant == NULL) {
2143  gen->status = CUDD_GEN_EMPTY;
2144  return(0);
2145  }
2146  cuddRef(implicant);
2147  prime = Cudd_bddMakePrime(dd,implicant,gen->gen.primes.ub);
2148  if (prime == NULL) {
2149  Cudd_RecursiveDeref(dd,implicant);
2150  gen->status = CUDD_GEN_EMPTY;
2151  return(0);
2152  }
2153  cuddRef(prime);
2154  Cudd_RecursiveDeref(dd,implicant);
2155  tmp = Cudd_bddAnd(dd,gen->node,Cudd_Not(prime));
2156  if (tmp == NULL) {
2157  Cudd_RecursiveDeref(dd,prime);
2158  gen->status = CUDD_GEN_EMPTY;
2159  return(0);
2160  }
2161  cuddRef(tmp);
2162  Cudd_RecursiveDeref(dd,gen->node);
2163  gen->node = tmp;
2164  result = Cudd_BddToCubeArray(dd,prime,gen->gen.primes.cube);
2165  if (result == 0) {
2166  Cudd_RecursiveDeref(dd,prime);
2167  gen->status = CUDD_GEN_EMPTY;
2168  return(0);
2169  }
2170  Cudd_RecursiveDeref(dd,prime);
2171  gen->status = CUDD_GEN_NONEMPTY;
2172  }
2173  if (gen->status == CUDD_GEN_EMPTY) return(0);
2174  *cube = gen->gen.primes.cube;
2175  return(1);
2176 
2177 } /* end of Cudd_NextPrime */
#define cuddRef(n)
Definition: cuddInt.h:584
DdNode * node
Definition: cuddInt.h:232
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * Cudd_ReadLogicZero(DdManager *dd)
Definition: cuddAPI.c:1058
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
DdNode * Cudd_LargestCube(DdManager *manager, DdNode *f, int *length)
Definition: cuddSat.c:285
DdNode * Cudd_bddMakePrime(DdManager *dd, DdNode *cube, DdNode *f)
Definition: cuddSat.c:864
int Cudd_BddToCubeArray(DdManager *dd, DdNode *cube, int *array)
Definition: cuddUtil.c:2346
DdManager * manager
Definition: cuddInt.h:205
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
struct DdGen::@30::@33 primes
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
int status
Definition: cuddInt.h:207
void Cudd_OutOfMem ( long  size)

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

Synopsis [Warns that a memory allocation failed.]

Description [Warns that a memory allocation failed. This function can be used as replacement of MMout_of_memory to prevent the safe_mem functions of the util package from exiting when malloc returns NULL. One possible use is in case of discretionary allocations; for instance, the allocation of memory to enlarge the computed table.]

SideEffects [None]

SeeAlso []

Definition at line 2837 of file cuddUtil.c.

2839 {
2840  (void) fflush(stdout);
2841  (void) fprintf(stderr, "\nunable to allocate %ld bytes\n", size);
2842  return;
2843 
2844 } /* end of Cudd_OutOfMem */
static int size
Definition: cuddSign.c:86
int Cudd_PrintDebug ( DdManager dd,
DdNode f,
int  n,
int  pr 
)

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

Synopsis [Prints to the standard output a DD and its statistics.]

Description [Prints to the standard output a DD and its statistics. The statistics include the number of nodes, the number of leaves, and the number of minterms. (The number of minterms is the number of assignments to the variables that cause the function to be different from the logical zero (for BDDs) and from the background value (for ADDs.) The statistics are printed if pr > 0. Specifically:

  • pr = 0 : prints nothing
  • pr = 1 : prints counts of nodes and minterms
  • pr = 2 : prints counts + disjoint sum of product
  • pr = 3 : prints counts + list of nodes
  • pr > 3 : prints counts + disjoint sum of product + list of nodes

For the purpose of counting the number of minterms, the function is supposed to depend on n variables. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_DagSize Cudd_CountLeaves Cudd_CountMinterm Cudd_PrintMinterm]

Definition at line 382 of file cuddUtil.c.

387 {
388  DdNode *azero, *bzero;
389  int nodes;
390  int leaves;
391  double minterms;
392  int retval = 1;
393 
394  if (f == NULL) {
395  (void) fprintf(dd->out,": is the NULL DD\n");
396  (void) fflush(dd->out);
397  return(0);
398  }
399  azero = DD_ZERO(dd);
400  bzero = Cudd_Not(DD_ONE(dd));
401  if ((f == azero || f == bzero) && pr > 0){
402  (void) fprintf(dd->out,": is the zero DD\n");
403  (void) fflush(dd->out);
404  return(1);
405  }
406  if (pr > 0) {
407  nodes = Cudd_DagSize(f);
408  if (nodes == CUDD_OUT_OF_MEM) retval = 0;
409  leaves = Cudd_CountLeaves(f);
410  if (leaves == CUDD_OUT_OF_MEM) retval = 0;
411  minterms = Cudd_CountMinterm(dd, f, n);
412  if (minterms == (double)CUDD_OUT_OF_MEM) retval = 0;
413  (void) fprintf(dd->out,": %d nodes %d leaves %g minterms\n",
414  nodes, leaves, minterms);
415  if (pr > 2) {
416  if (!cuddP(dd, f)) retval = 0;
417  }
418  if (pr == 2 || pr > 3) {
419  if (!Cudd_PrintMinterm(dd,f)) retval = 0;
420  (void) fprintf(dd->out,"\n");
421  }
422  (void) fflush(dd->out);
423  }
424  return(retval);
425 
426 } /* end of Cudd_PrintDebug */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int Cudd_DagSize(DdNode *node)
Definition: cuddUtil.c:442
double Cudd_CountMinterm(DdManager *manager, DdNode *node, int nvars)
Definition: cuddUtil.c:578
FILE * out
Definition: cuddInt.h:441
int Cudd_PrintMinterm(DdManager *manager, DdNode *node)
Definition: cuddUtil.c:216
int Cudd_CountLeaves(DdNode *node)
Definition: cuddUtil.c:1194
int cuddP(DdManager *dd, DdNode *f)
Definition: cuddUtil.c:2866
#define DD_ONE(dd)
Definition: cuddInt.h:911
pset minterms()
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int Cudd_PrintMinterm ( DdManager manager,
DdNode node 
)

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

Synopsis [Prints a disjoint sum of products.]

Description [Prints a disjoint sum of product cover for the function rooted at node. Each product corresponds to a path from node to a leaf node different from the logical zero, and different from the background value. Uses the package default output file. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_PrintDebug Cudd_bddPrintCover]

Definition at line 216 of file cuddUtil.c.

219 {
220  int i, *list;
221 
222  background = manager->background;
223  zero = Cudd_Not(manager->one);
224  list = ABC_ALLOC(int,manager->size);
225  if (list == NULL) {
226  manager->errorCode = CUDD_MEMORY_OUT;
227  return(0);
228  }
229  for (i = 0; i < manager->size; i++) list[i] = 2;
230  ddPrintMintermAux(manager,node,list);
231  ABC_FREE(list);
232  return(1);
233 
234 } /* end of Cudd_PrintMinterm */
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static DdNode * background
Definition: cuddUtil.c:148
static void ddPrintMintermAux(DdManager *dd, DdNode *node, int *list)
Definition: cuddUtil.c:3111
static DdNode * zero
Definition: cuddUtil.c:148
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * one
Definition: cuddInt.h:345
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * background
Definition: cuddInt.h:349
void Cudd_PrintVersion ( FILE *  fp)

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

Synopsis [Prints the package version number.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 2592 of file cuddUtil.c.

2594 {
2595  (void) fprintf(fp, "%s\n", CUDD_VERSION);
2596 
2597 } /* end of Cudd_PrintVersion */
#define CUDD_VERSION
Definition: cudd.h:75
long Cudd_Random ( void  )

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

Synopsis [Portable random number generator.]

Description [Portable number generator based on ran2 from "Numerical Recipes in C." It is a long period (> 2 * 10^18) random number generator of L'Ecuyer with Bays-Durham shuffle. Returns a long integer uniformly distributed between 0 and 2147483561 (inclusive of the endpoint values). The random generator can be explicitly initialized by calling Cudd_Srandom. If no explicit initialization is performed, then the seed 1 is assumed.]

SideEffects [None]

SeeAlso [Cudd_Srandom]

Definition at line 2702 of file cuddUtil.c.

2703 {
2704  int i; /* index in the shuffle table */
2705  long int w; /* work variable */
2706 
2707  /* cuddRand == 0 if the geneartor has not been initialized yet. */
2708  if (cuddRand == 0) Cudd_Srandom(1);
2709 
2710  /* Compute cuddRand = (cuddRand * LEQA1) % MODULUS1 avoiding
2711  ** overflows by Schrage's method.
2712  */
2713  w = cuddRand / LEQQ1;
2714  cuddRand = LEQA1 * (cuddRand - w * LEQQ1) - w * LEQR1;
2715  cuddRand += (cuddRand < 0) * MODULUS1;
2716 
2717  /* Compute cuddRand2 = (cuddRand2 * LEQA2) % MODULUS2 avoiding
2718  ** overflows by Schrage's method.
2719  */
2720  w = cuddRand2 / LEQQ2;
2721  cuddRand2 = LEQA2 * (cuddRand2 - w * LEQQ2) - w * LEQR2;
2722  cuddRand2 += (cuddRand2 < 0) * MODULUS2;
2723 
2724  /* cuddRand is shuffled with the Bays-Durham algorithm.
2725  ** shuffleSelect and cuddRand2 are combined to generate the output.
2726  */
2727 
2728  /* Pick one element from the shuffle table; "i" will be in the range
2729  ** from 0 to STAB_SIZE-1.
2730  */
2731  i = (int) (shuffleSelect / STAB_DIV);
2732  /* Mix the element of the shuffle table with the current iterate of
2733  ** the second sub-generator, and replace the chosen element of the
2734  ** shuffle table with the current iterate of the first sub-generator.
2735  */
2737  shuffleTable[i] = cuddRand;
2738  shuffleSelect += (shuffleSelect < 1) * (MODULUS1 - 1);
2739  /* Since shuffleSelect != 0, and we want to be able to return 0,
2740  ** here we subtract 1 before returning.
2741  */
2742  return(shuffleSelect - 1);
2743 
2744 } /* end of Cudd_Random */
void Cudd_Srandom(long seed)
Definition: cuddUtil.c:2764
#define LEQQ1
Definition: cuddUtil.c:122
#define LEQQ2
Definition: cuddUtil.c:126
#define MODULUS1
Definition: cuddUtil.c:120
#define LEQR2
Definition: cuddUtil.c:127
static long shuffleSelect
Definition: cuddUtil.c:152
static long shuffleTable[STAB_SIZE]
Definition: cuddUtil.c:153
static long cuddRand
Definition: cuddUtil.c:150
#define LEQA2
Definition: cuddUtil.c:125
#define LEQR1
Definition: cuddUtil.c:123
#define STAB_DIV
Definition: cuddUtil.c:129
static long cuddRand2
Definition: cuddUtil.c:151
#define MODULUS2
Definition: cuddUtil.c:124
#define LEQA1
Definition: cuddUtil.c:121
int Cudd_SharingSize ( DdNode **  nodeArray,
int  n 
)

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

Synopsis [Counts the number of nodes in an array of DDs.]

Description [Counts the number of nodes in an array of DDs. Shared nodes are counted only once. Returns the total number of nodes.]

SideEffects [None]

SeeAlso [Cudd_DagSize]

Definition at line 544 of file cuddUtil.c.

547 {
548  int i,j;
549 
550  i = 0;
551  for (j = 0; j < n; j++) {
552  i += ddDagInt(Cudd_Regular(nodeArray[j]));
553  }
554  for (j = 0; j < n; j++) {
555  ddClearFlag(Cudd_Regular(nodeArray[j]));
556  }
557  return(i);
558 
559 } /* end of Cudd_SharingSize */
#define Cudd_Regular(node)
Definition: cudd.h:397
static int ddDagInt(DdNode *n)
Definition: cuddUtil.c:3165
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
void Cudd_Srandom ( long  seed)

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

Synopsis [Initializer for the portable random number generator.]

Description [Initializer for the portable number generator based on ran2 in "Numerical Recipes in C." The input is the seed for the generator. If it is negative, its absolute value is taken as seed. If it is 0, then 1 is taken as seed. The initialized sets up the two recurrences used to generate a long-period stream, and sets up the shuffle table.]

SideEffects [None]

SeeAlso [Cudd_Random]

Definition at line 2764 of file cuddUtil.c.

2766 {
2767  int i;
2768 
2769  if (seed < 0) cuddRand = -seed;
2770  else if (seed == 0) cuddRand = 1;
2771  else cuddRand = seed;
2772  cuddRand2 = cuddRand;
2773  /* Load the shuffle table (after 11 warm-ups). */
2774  for (i = 0; i < STAB_SIZE + 11; i++) {
2775  long int w;
2776  w = cuddRand / LEQQ1;
2777  cuddRand = LEQA1 * (cuddRand - w * LEQQ1) - w * LEQR1;
2778  cuddRand += (cuddRand < 0) * MODULUS1;
2780  }
2782 
2783 } /* end of Cudd_Srandom */
#define LEQQ1
Definition: cuddUtil.c:122
#define MODULUS1
Definition: cuddUtil.c:120
static long shuffleSelect
Definition: cuddUtil.c:152
static long shuffleTable[STAB_SIZE]
Definition: cuddUtil.c:153
static long cuddRand
Definition: cuddUtil.c:150
#define STAB_SIZE
Definition: cuddUtil.c:128
#define LEQR1
Definition: cuddUtil.c:123
static long cuddRand2
Definition: cuddUtil.c:151
#define LEQA1
Definition: cuddUtil.c:121
DdNode* Cudd_SubsetWithMaskVars ( DdManager dd,
DdNode f,
DdNode **  vars,
int  nvars,
DdNode **  maskVars,
int  mvars 
)

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

Synopsis [Extracts a subset from a BDD.]

Description [Extracts a subset from a BDD in the following procedure.

  1. Compute the weight for each mask variable by counting the number of minterms for both positive and negative cofactors of the BDD with respect to each mask variable. (weight = #positive - #negative)
  2. Find a representative cube of the BDD by using the weight. From the top variable of the BDD, for each variable, if the weight is greater than 0.0, choose THEN branch, othereise ELSE branch, until meeting the constant 1.
  3. Quantify out the variables not in maskVars from the representative cube and if a variable in maskVars is don't care, replace the variable with a constant(1 or 0) depending on the weight.
  4. Make a subset of the BDD by multiplying with the modified cube.]

SideEffects [None]

SeeAlso []

Definition at line 1602 of file cuddUtil.c.

1609 {
1610  double *weight;
1611  char *string;
1612  int i, size;
1613  int *indices, *mask;
1614  int result;
1615  DdNode *zero, *cube, *newCube, *subset;
1616  DdNode *cof;
1617 
1618  DdNode *support;
1619  support = Cudd_Support(dd,f);
1620  cuddRef(support);
1621  Cudd_RecursiveDeref(dd,support);
1622 
1623  zero = Cudd_Not(dd->one);
1624  size = dd->size;
1625 
1626  weight = ABC_ALLOC(double,size);
1627  if (weight == NULL) {
1628  dd->errorCode = CUDD_MEMORY_OUT;
1629  return(NULL);
1630  }
1631  for (i = 0; i < size; i++) {
1632  weight[i] = 0.0;
1633  }
1634  for (i = 0; i < mvars; i++) {
1635  cof = Cudd_Cofactor(dd, f, maskVars[i]);
1636  cuddRef(cof);
1637  weight[i] = Cudd_CountMinterm(dd, cof, nvars);
1638  Cudd_RecursiveDeref(dd,cof);
1639 
1640  cof = Cudd_Cofactor(dd, f, Cudd_Not(maskVars[i]));
1641  cuddRef(cof);
1642  weight[i] -= Cudd_CountMinterm(dd, cof, nvars);
1643  Cudd_RecursiveDeref(dd,cof);
1644  }
1645 
1646  string = ABC_ALLOC(char, size + 1);
1647  if (string == NULL) {
1648  dd->errorCode = CUDD_MEMORY_OUT;
1649  ABC_FREE(weight);
1650  return(NULL);
1651  }
1652  mask = ABC_ALLOC(int, size);
1653  if (mask == NULL) {
1654  dd->errorCode = CUDD_MEMORY_OUT;
1655  ABC_FREE(weight);
1656  ABC_FREE(string);
1657  return(NULL);
1658  }
1659  for (i = 0; i < size; i++) {
1660  string[i] = '2';
1661  mask[i] = 0;
1662  }
1663  string[size] = '\0';
1664  indices = ABC_ALLOC(int,nvars);
1665  if (indices == NULL) {
1666  dd->errorCode = CUDD_MEMORY_OUT;
1667  ABC_FREE(weight);
1668  ABC_FREE(string);
1669  ABC_FREE(mask);
1670  return(NULL);
1671  }
1672  for (i = 0; i < nvars; i++) {
1673  indices[i] = vars[i]->index;
1674  }
1675 
1676  result = ddPickRepresentativeCube(dd,f,weight,string);
1677  if (result == 0) {
1678  ABC_FREE(weight);
1679  ABC_FREE(string);
1680  ABC_FREE(mask);
1681  ABC_FREE(indices);
1682  return(NULL);
1683  }
1684 
1685  cube = Cudd_ReadOne(dd);
1686  cuddRef(cube);
1687  zero = Cudd_Not(Cudd_ReadOne(dd));
1688  for (i = 0; i < nvars; i++) {
1689  if (string[indices[i]] == '0') {
1690  newCube = Cudd_bddIte(dd,cube,Cudd_Not(vars[i]),zero);
1691  } else if (string[indices[i]] == '1') {
1692  newCube = Cudd_bddIte(dd,cube,vars[i],zero);
1693  } else
1694  continue;
1695  if (newCube == NULL) {
1696  ABC_FREE(weight);
1697  ABC_FREE(string);
1698  ABC_FREE(mask);
1699  ABC_FREE(indices);
1700  Cudd_RecursiveDeref(dd,cube);
1701  return(NULL);
1702  }
1703  cuddRef(newCube);
1704  Cudd_RecursiveDeref(dd,cube);
1705  cube = newCube;
1706  }
1707  Cudd_RecursiveDeref(dd,cube);
1708 
1709  for (i = 0; i < mvars; i++) {
1710  mask[maskVars[i]->index] = 1;
1711  }
1712  for (i = 0; i < nvars; i++) {
1713  if (mask[indices[i]]) {
1714  if (string[indices[i]] == '2') {
1715  if (weight[indices[i]] >= 0.0)
1716  string[indices[i]] = '1';
1717  else
1718  string[indices[i]] = '0';
1719  }
1720  } else {
1721  string[indices[i]] = '2';
1722  }
1723  }
1724 
1725  cube = Cudd_ReadOne(dd);
1726  cuddRef(cube);
1727  zero = Cudd_Not(Cudd_ReadOne(dd));
1728 
1729  /* Build result BDD. */
1730  for (i = 0; i < nvars; i++) {
1731  if (string[indices[i]] == '0') {
1732  newCube = Cudd_bddIte(dd,cube,Cudd_Not(vars[i]),zero);
1733  } else if (string[indices[i]] == '1') {
1734  newCube = Cudd_bddIte(dd,cube,vars[i],zero);
1735  } else
1736  continue;
1737  if (newCube == NULL) {
1738  ABC_FREE(weight);
1739  ABC_FREE(string);
1740  ABC_FREE(mask);
1741  ABC_FREE(indices);
1742  Cudd_RecursiveDeref(dd,cube);
1743  return(NULL);
1744  }
1745  cuddRef(newCube);
1746  Cudd_RecursiveDeref(dd,cube);
1747  cube = newCube;
1748  }
1749 
1750  subset = Cudd_bddAnd(dd,f,cube);
1751  cuddRef(subset);
1752  Cudd_RecursiveDeref(dd,cube);
1753 
1754  /* Test. */
1755  if (Cudd_bddLeq(dd,subset,f)) {
1756  cuddDeref(subset);
1757  } else {
1758  Cudd_RecursiveDeref(dd,subset);
1759  subset = NULL;
1760  }
1761 
1762  ABC_FREE(weight);
1763  ABC_FREE(string);
1764  ABC_FREE(mask);
1765  ABC_FREE(indices);
1766  return(subset);
1767 
1768 } /* end of Cudd_SubsetWithMaskVars */
#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
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
static int ddPickRepresentativeCube(DdManager *dd, DdNode *node, double *weight, char *string)
Definition: cuddUtil.c:3859
double Cudd_CountMinterm(DdManager *manager, DdNode *node, int nvars)
Definition: cuddUtil.c:578
DdNode * Cudd_Cofactor(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddCof.c:123
static DdNode * zero
Definition: cuddUtil.c:148
static int size
Definition: cuddSign.c:86
DdNode * Cudd_ReadOne(DdManager *dd)
Definition: cuddAPI.c:987
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * one
Definition: cuddInt.h:345
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
DdNode * Cudd_Support(DdManager *dd, DdNode *f)
Definition: cuddUtil.c:740
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_Support ( DdManager dd,
DdNode f 
)

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

Synopsis [Finds the variables on which a DD depends.]

Description [Finds the variables on which a DD depends. Returns a BDD consisting of the product of the variables if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_VectorSupport Cudd_ClassifySupport]

Definition at line 740 of file cuddUtil.c.

743 {
744  int *support;
745  DdNode *res, *tmp, *var;
746  int i,j;
747  int size;
748 
749  /* Allocate and initialize support array for ddSupportStep. */
750  size = ddMax(dd->size, dd->sizeZ);
751  support = ABC_ALLOC(int,size);
752  if (support == NULL) {
754  return(NULL);
755  }
756  for (i = 0; i < size; i++) {
757  support[i] = 0;
758  }
759 
760  /* Compute support and clean up markers. */
761  ddSupportStep(Cudd_Regular(f),support);
763 
764  /* Transform support from array to cube. */
765  do {
766  dd->reordered = 0;
767  res = DD_ONE(dd);
768  cuddRef(res);
769  for (j = size - 1; j >= 0; j--) { /* for each level bottom-up */
770  i = (j >= dd->size) ? j : dd->invperm[j];
771  if (support[i] == 1) {
772  /* The following call to cuddUniqueInter is guaranteed
773  ** not to trigger reordering because the node we look up
774  ** already exists. */
775  var = cuddUniqueInter(dd,i,dd->one,Cudd_Not(dd->one));
776  cuddRef(var);
777  tmp = cuddBddAndRecur(dd,res,var);
778  if (tmp == NULL) {
779  Cudd_RecursiveDeref(dd,res);
780  Cudd_RecursiveDeref(dd,var);
781  res = NULL;
782  break;
783  }
784  cuddRef(tmp);
785  Cudd_RecursiveDeref(dd,res);
786  Cudd_RecursiveDeref(dd,var);
787  res = tmp;
788  }
789  }
790  } while (dd->reordered == 1);
791 
792  ABC_FREE(support);
793  if (res != NULL) cuddDeref(res);
794  return(res);
795 
796 } /* end of Cudd_Support */
#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
int size
Definition: cuddInt.h:361
int var(Lit p)
Definition: SolverTypes.h:62
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int reordered
Definition: cuddInt.h:409
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
if(last==0)
Definition: sparse_int.h:34
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * one
Definition: cuddInt.h:345
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
int * invperm
Definition: cuddInt.h:388
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
int* Cudd_SupportIndex ( DdManager dd,
DdNode f 
)

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

Synopsis [Finds the variables on which a DD depends.]

Description [Finds the variables on which a DD depends. Returns an index array of the variables if successful; NULL otherwise. The size of the array equals the number of variables in the manager. Each entry of the array is 1 if the corresponding variable is in the support of the DD and 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_Support Cudd_VectorSupport Cudd_ClassifySupport]

Definition at line 815 of file cuddUtil.c.

818 {
819  int *support;
820  int i;
821  int size;
822 
823  /* Allocate and initialize support array for ddSupportStep. */
824  size = ddMax(dd->size, dd->sizeZ);
825  support = ABC_ALLOC(int,size);
826  if (support == NULL) {
828  return(NULL);
829  }
830  for (i = 0; i < size; i++) {
831  support[i] = 0;
832  }
833 
834  /* Compute support and clean up markers. */
835  ddSupportStep(Cudd_Regular(f),support);
837 
838  return(support);
839 
840 } /* end of Cudd_SupportIndex */
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_SupportSize ( DdManager dd,
DdNode f 
)

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

Synopsis [Counts the variables on which a DD depends.]

Description [Counts the variables on which a DD depends. Returns the number of the variables if successful; CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_Support]

Definition at line 857 of file cuddUtil.c.

860 {
861  int *support;
862  int i;
863  int size;
864  int count;
865 
866  /* Allocate and initialize support array for ddSupportStep. */
867  size = ddMax(dd->size, dd->sizeZ);
868  support = ABC_ALLOC(int,size);
869  if (support == NULL) {
871  return(CUDD_OUT_OF_MEM);
872  }
873  for (i = 0; i < size; i++) {
874  support[i] = 0;
875  }
876 
877  /* Compute support and clean up markers. */
878  ddSupportStep(Cudd_Regular(f),support);
880 
881  /* Count support variables. */
882  count = 0;
883  for (i = 0; i < size; i++) {
884  if (support[i] == 1) count++;
885  }
886 
887  ABC_FREE(support);
888  return(count);
889 
890 } /* end of Cudd_SupportSize */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_VectorSupport ( DdManager dd,
DdNode **  F,
int  n 
)

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

Synopsis [Finds the variables on which a set of DDs depends.]

Description [Finds the variables on which a set of DDs depends. The set must contain either BDDs and ADDs, or ZDDs. Returns a BDD consisting of the product of the variables if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_Support Cudd_ClassifySupport]

Definition at line 908 of file cuddUtil.c.

912 {
913  int *support;
914  DdNode *res, *tmp, *var;
915  int i,j;
916  int size;
917 
918  /* Allocate and initialize support array for ddSupportStep. */
919  size = ddMax(dd->size, dd->sizeZ);
920  support = ABC_ALLOC(int,size);
921  if (support == NULL) {
923  return(NULL);
924  }
925  for (i = 0; i < size; i++) {
926  support[i] = 0;
927  }
928 
929  /* Compute support and clean up markers. */
930  for (i = 0; i < n; i++) {
931  ddSupportStep(Cudd_Regular(F[i]),support);
932  }
933  for (i = 0; i < n; i++) {
934  ddClearFlag(Cudd_Regular(F[i]));
935  }
936 
937  /* Transform support from array to cube. */
938  res = DD_ONE(dd);
939  cuddRef(res);
940  for (j = size - 1; j >= 0; j--) { /* for each level bottom-up */
941  i = (j >= dd->size) ? j : dd->invperm[j];
942  if (support[i] == 1) {
943  var = cuddUniqueInter(dd,i,dd->one,Cudd_Not(dd->one));
944  cuddRef(var);
945  tmp = Cudd_bddAnd(dd,res,var);
946  if (tmp == NULL) {
947  Cudd_RecursiveDeref(dd,res);
948  Cudd_RecursiveDeref(dd,var);
949  ABC_FREE(support);
950  return(NULL);
951  }
952  cuddRef(tmp);
953  Cudd_RecursiveDeref(dd,res);
954  Cudd_RecursiveDeref(dd,var);
955  res = tmp;
956  }
957  }
958 
959  ABC_FREE(support);
960  cuddDeref(res);
961  return(res);
962 
963 } /* end of Cudd_VectorSupport */
#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
int size
Definition: cuddInt.h:361
int var(Lit p)
Definition: SolverTypes.h:62
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
if(last==0)
Definition: sparse_int.h:34
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * one
Definition: cuddInt.h:345
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
int * invperm
Definition: cuddInt.h:388
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
int* Cudd_VectorSupportIndex ( DdManager dd,
DdNode **  F,
int  n 
)

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

Synopsis [Finds the variables on which a set of DDs depends.]

Description [Finds the variables on which a set of DDs depends. The set must contain either BDDs and ADDs, or ZDDs. Returns an index array of the variables if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_SupportIndex Cudd_VectorSupport Cudd_ClassifySupport]

Definition at line 980 of file cuddUtil.c.

984 {
985  int *support;
986  int i;
987  int size;
988 
989  /* Allocate and initialize support array for ddSupportStep. */
990  size = ddMax(dd->size, dd->sizeZ);
991  support = ABC_ALLOC(int,size);
992  if (support == NULL) {
994  return(NULL);
995  }
996  for (i = 0; i < size; i++) {
997  support[i] = 0;
998  }
999 
1000  /* Compute support and clean up markers. */
1001  for (i = 0; i < n; i++) {
1002  ddSupportStep(Cudd_Regular(F[i]),support);
1003  }
1004  for (i = 0; i < n; i++) {
1005  ddClearFlag(Cudd_Regular(F[i]));
1006  }
1007 
1008  return(support);
1009 
1010 } /* end of Cudd_VectorSupportIndex */
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_VectorSupportSize ( DdManager dd,
DdNode **  F,
int  n 
)

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

Synopsis [Counts the variables on which a set of DDs depends.]

Description [Counts the variables on which a set of DDs depends. The set must contain either BDDs and ADDs, or ZDDs. Returns the number of the variables if successful; CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_VectorSupport Cudd_SupportSize]

Definition at line 1028 of file cuddUtil.c.

1032 {
1033  int *support;
1034  int i;
1035  int size;
1036  int count;
1037 
1038  /* Allocate and initialize support array for ddSupportStep. */
1039  size = ddMax(dd->size, dd->sizeZ);
1040  support = ABC_ALLOC(int,size);
1041  if (support == NULL) {
1042  dd->errorCode = CUDD_MEMORY_OUT;
1043  return(CUDD_OUT_OF_MEM);
1044  }
1045  for (i = 0; i < size; i++) {
1046  support[i] = 0;
1047  }
1048 
1049  /* Compute support and clean up markers. */
1050  for (i = 0; i < n; i++) {
1051  ddSupportStep(Cudd_Regular(F[i]),support);
1052  }
1053  for (i = 0; i < n; i++) {
1054  ddClearFlag(Cudd_Regular(F[i]));
1055  }
1056 
1057  /* Count vriables in support. */
1058  count = 0;
1059  for (i = 0; i < size; i++) {
1060  if (support[i] == 1) count++;
1061  }
1062 
1063  ABC_FREE(support);
1064  return(count);
1065 
1066 } /* end of Cudd_VectorSupportSize */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int cuddCollectNodes ( DdNode f,
st__table visited 
)

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

Synopsis [Recursively collects all the nodes of a DD in a symbol table.]

Description [Traverses the DD f and collects all its nodes in a symbol table. f is assumed to be a regular pointer and cuddCollectNodes guarantees this assumption in the recursive calls. Returns 1 in case of success; 0 otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 2925 of file cuddUtil.c.

2928 {
2929  DdNode *T, *E;
2930  int retval;
2931 
2932 #ifdef DD_DEBUG
2934 #endif
2935 
2936  /* If already visited, nothing to do. */
2937  if ( st__is_member(visited, (char *) f) == 1)
2938  return(1);
2939 
2940  /* Check for abnormal condition that should never happen. */
2941  if (f == NULL)
2942  return(0);
2943 
2944  /* Mark node as visited. */
2945  if ( st__add_direct(visited, (char *) f, NULL) == st__OUT_OF_MEM)
2946  return(0);
2947 
2948  /* Check terminal case. */
2949  if (cuddIsConstant(f))
2950  return(1);
2951 
2952  /* Recursive calls. */
2953  T = cuddT(f);
2954  retval = cuddCollectNodes(T,visited);
2955  if (retval != 1) return(retval);
2956  E = Cudd_Regular(cuddE(f));
2957  retval = cuddCollectNodes(E,visited);
2958  return(retval);
2959 
2960 } /* end of cuddCollectNodes */
Definition: cudd.h:278
#define Cudd_Regular(node)
Definition: cudd.h:397
#define st__is_member(table, key)
Definition: st.h:70
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
#define st__OUT_OF_MEM
Definition: st.h:113
#define cuddE(node)
Definition: cuddInt.h:652
int st__add_direct(st__table *table, char *key, char *value)
Definition: st.c:205
int cuddCollectNodes(DdNode *f, st__table *visited)
Definition: cuddUtil.c:2925
#define assert(ex)
Definition: util_old.h:213
static int cuddEstimateCofactor ( DdManager dd,
st__table table,
DdNode node,
int  i,
int  phase,
DdNode **  ptr 
)
static

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

Synopsis [Performs the recursive step of Cudd_CofactorEstimate.]

Description [Performs the recursive step of Cudd_CofactorEstimate. Returns an estimate of the number of nodes in the DD of a cofactor of node. Uses the least significant bit of the next field as visited flag. node is supposed to be regular; the invariant is maintained by this procedure.]

SideEffects [None]

SeeAlso []

Definition at line 3240 of file cuddUtil.c.

3247 {
3248  int tval, eval, val;
3249  DdNode *ptrT, *ptrE;
3250 
3251  if (Cudd_IsComplement(node->next)) {
3252  if (! st__lookup(table,(char *)node,(char **)ptr)) {
3253  if ( st__add_direct(table,(char *)node,(char *)node) ==
3255  return(CUDD_OUT_OF_MEM);
3256  *ptr = node;
3257  }
3258  return(0);
3259  }
3260  node->next = Cudd_Not(node->next);
3261  if (cuddIsConstant(node)) {
3262  *ptr = node;
3263  if ( st__add_direct(table,(char *)node,(char *)node) == st__OUT_OF_MEM)
3264  return(CUDD_OUT_OF_MEM);
3265  return(1);
3266  }
3267  if ((int) node->index == i) {
3268  if (phase == 1) {
3269  *ptr = cuddT(node);
3270  val = ddDagInt(cuddT(node));
3271  } else {
3272  *ptr = cuddE(node);
3273  val = ddDagInt(Cudd_Regular(cuddE(node)));
3274  }
3275  if (node->ref > 1) {
3276  if ( st__add_direct(table,(char *)node,(char *)*ptr) ==
3278  return(CUDD_OUT_OF_MEM);
3279  }
3280  return(val);
3281  }
3282  if (dd->perm[node->index] > dd->perm[i]) {
3283  *ptr = node;
3284  tval = ddDagInt(cuddT(node));
3285  eval = ddDagInt(Cudd_Regular(cuddE(node)));
3286  if (node->ref > 1) {
3287  if ( st__add_direct(table,(char *)node,(char *)node) ==
3289  return(CUDD_OUT_OF_MEM);
3290  }
3291  val = 1 + tval + eval;
3292  return(val);
3293  }
3294  tval = cuddEstimateCofactor(dd,table,cuddT(node),i,phase,&ptrT);
3295  eval = cuddEstimateCofactor(dd,table,Cudd_Regular(cuddE(node)),i,
3296  phase,&ptrE);
3297  ptrE = Cudd_NotCond(ptrE,Cudd_IsComplement(cuddE(node)));
3298  if (ptrT == ptrE) { /* recombination */
3299  *ptr = ptrT;
3300  val = tval;
3301  if (node->ref > 1) {
3302  if ( st__add_direct(table,(char *)node,(char *)*ptr) ==
3304  return(CUDD_OUT_OF_MEM);
3305  }
3306  } else if ((ptrT != cuddT(node) || ptrE != cuddE(node)) &&
3307  (*ptr = cuddUniqueLookup(dd,node->index,ptrT,ptrE)) != NULL) {
3308  if (Cudd_IsComplement((*ptr)->next)) {
3309  val = 0;
3310  } else {
3311  val = 1 + tval + eval;
3312  }
3313  if (node->ref > 1) {
3314  if ( st__add_direct(table,(char *)node,(char *)*ptr) ==
3316  return(CUDD_OUT_OF_MEM);
3317  }
3318  } else {
3319  *ptr = node;
3320  val = 1 + tval + eval;
3321  }
3322  return(val);
3323 
3324 } /* end of cuddEstimateCofactor */
DdHalfWord ref
Definition: cudd.h:280
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
static int cuddEstimateCofactor(DdManager *dd, st__table *table, DdNode *node, int i, int phase, DdNode **ptr)
Definition: cuddUtil.c:3240
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_Regular(node)
Definition: cudd.h:397
static DdNode * cuddUniqueLookup(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddUtil.c:3340
#define Cudd_IsComplement(node)
Definition: cudd.h:425
DdNode * next
Definition: cudd.h:281
#define cuddIsConstant(node)
Definition: cuddInt.h:620
static int ddDagInt(DdNode *n)
Definition: cuddUtil.c:3165
#define cuddT(node)
Definition: cuddInt.h:636
#define st__OUT_OF_MEM
Definition: st.h:113
static pcube phase
Definition: cvrm.c:405
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
int * perm
Definition: cuddInt.h:386
static int cuddEstimateCofactorSimple ( DdNode node,
int  i 
)
static

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

Synopsis [Performs the recursive step of Cudd_CofactorEstimateSimple.]

Description [Performs the recursive step of Cudd_CofactorEstimateSimple. Returns an estimate of the number of nodes in the DD of the positive cofactor of node. Uses the least significant bit of the next field as visited flag. node is supposed to be regular; the invariant is maintained by this procedure.]

SideEffects [None]

SeeAlso []

Definition at line 3399 of file cuddUtil.c.

3402 {
3403  int tval, eval;
3404 
3405  if (Cudd_IsComplement(node->next)) {
3406  return(0);
3407  }
3408  node->next = Cudd_Not(node->next);
3409  if (cuddIsConstant(node)) {
3410  return(1);
3411  }
3412  tval = cuddEstimateCofactorSimple(cuddT(node),i);
3413  if ((int) node->index == i) return(tval);
3415  return(1 + tval + eval);
3416 
3417 } /* end of cuddEstimateCofactorSimple */
#define Cudd_Not(node)
Definition: cudd.h:367
static int cuddEstimateCofactorSimple(DdNode *node, int i)
Definition: cuddUtil.c:3399
#define Cudd_Regular(node)
Definition: cudd.h:397
#define Cudd_IsComplement(node)
Definition: cudd.h:425
DdNode * next
Definition: cudd.h:281
#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
DdNodePtr* cuddNodeArray ( DdNode f,
int *  n 
)

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

Synopsis [Recursively collects all the nodes of a DD in an array.]

Description [Traverses the DD f and collects all its nodes in an array. The caller should free the array returned by cuddNodeArray. Returns a pointer to the array of nodes in case of success; NULL otherwise. The nodes are collected in reverse topological order, so that a node is always preceded in the array by all its descendants.]

SideEffects [The number of nodes is returned as a side effect.]

SeeAlso [Cudd_FirstNode]

Definition at line 2979 of file cuddUtil.c.

2982 {
2983  DdNodePtr *table;
2984  int size, retval;
2985 
2986  size = ddDagInt(Cudd_Regular(f));
2987  table = ABC_ALLOC(DdNodePtr, size);
2988  if (table == NULL) {
2990  return(NULL);
2991  }
2992 
2993  retval = cuddNodeArrayRecur(f, table, 0);
2994  assert(retval == size);
2995 
2996  *n = size;
2997  return(table);
2998 
2999 } /* cuddNodeArray */
Definition: cudd.h:278
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int size
Definition: cuddSign.c:86
static int ddDagInt(DdNode *n)
Definition: cuddUtil.c:3165
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
#define assert(ex)
Definition: util_old.h:213
static int cuddNodeArrayRecur(DdNode *f, DdNodePtr *table, int index)
Definition: cuddUtil.c:3200
static int cuddNodeArrayRecur ( DdNode f,
DdNodePtr table,
int  index 
)
static

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

Synopsis [Performs the recursive step of cuddNodeArray.]

Description [Performs the recursive step of cuddNodeArray. Returns an the number of nodes in the DD. Clear the least significant bit of the next field that was used as visited flag by cuddNodeArrayRecur when counting the nodes. node is supposed to be regular; the invariant is maintained by this procedure.]

SideEffects [None]

SeeAlso []

Definition at line 3200 of file cuddUtil.c.

3204 {
3205  int tindex, eindex;
3206 
3207  if (!Cudd_IsComplement(f->next)) {
3208  return(index);
3209  }
3210  /* Clear visited flag. */
3211  f->next = Cudd_Regular(f->next);
3212  if (cuddIsConstant(f)) {
3213  table[index] = f;
3214  return(index + 1);
3215  }
3216  tindex = cuddNodeArrayRecur(cuddT(f), table, index);
3217  eindex = cuddNodeArrayRecur(Cudd_Regular(cuddE(f)), table, tindex);
3218  table[eindex] = f;
3219  return(eindex + 1);
3220 
3221 } /* end of cuddNodeArrayRecur */
#define Cudd_Regular(node)
Definition: cudd.h:397
#define Cudd_IsComplement(node)
Definition: cudd.h:425
DdNode * next
Definition: cudd.h:281
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddE(node)
Definition: cuddInt.h:652
static int cuddNodeArrayRecur(DdNode *f, DdNodePtr *table, int index)
Definition: cuddUtil.c:3200
int cuddP ( DdManager dd,
DdNode f 
)

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

Synopsis [Prints a DD to the standard output. One line per node is printed.]

Description [Prints a DD to the standard output. One line per node is printed. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_PrintDebug]

Definition at line 2866 of file cuddUtil.c.

2869 {
2870  int retval;
2872 
2873  if (table == NULL) return(0);
2874 
2875  retval = dp2(dd,f,table);
2876  st__free_table(table);
2877  (void) fputc('\n',dd->out);
2878  return(retval);
2879 
2880 } /* end of cuddP */
void st__free_table(st__table *table)
Definition: st.c:81
static int dp2(DdManager *dd, DdNode *f, st__table *t)
Definition: cuddUtil.c:3018
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
FILE * out
Definition: cuddInt.h:441
Definition: st.h:52
int st__ptrhash(const char *, int)
Definition: st.c:468
enum st__retval cuddStCountfree ( char *  key,
char *  value,
char *  arg 
)

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

Synopsis [Frees the memory used to store the minterm counts recorded in the visited table.]

Description [Frees the memory used to store the minterm counts recorded in the visited table. Returns st__CONTINUE.]

SideEffects [None]

Definition at line 2895 of file cuddUtil.c.

2899 {
2900  double *d;
2901 
2902  d = (double *)value;
2903  ABC_FREE(d);
2904  return( st__CONTINUE);
2905 
2906 } /* end of cuddStCountfree */
#define ABC_FREE(obj)
Definition: abc_global.h:232
int value
static DdNode * cuddUniqueLookup ( DdManager unique,
int  index,
DdNode T,
DdNode E 
)
static

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

Synopsis [Checks the unique table for the existence of an internal node.]

Description [Checks the unique table for the existence of an internal node. Returns a pointer to the node if it is in the table; NULL otherwise.]

SideEffects [None]

SeeAlso [cuddUniqueInter]

Definition at line 3340 of file cuddUtil.c.

3345 {
3346  int posn;
3347  unsigned int level;
3348  DdNodePtr *nodelist;
3349  DdNode *looking;
3350  DdSubtable *subtable;
3351 
3352  if (index >= unique->size) {
3353  return(NULL);
3354  }
3355 
3356  level = unique->perm[index];
3357  subtable = &(unique->subtables[level]);
3358 
3359 #ifdef DD_DEBUG
3360  assert(level < (unsigned) cuddI(unique,T->index));
3361  assert(level < (unsigned) cuddI(unique,Cudd_Regular(E)->index));
3362 #endif
3363 
3364  posn = ddHash(cuddF2L(T), cuddF2L(E), subtable->shift);
3365  nodelist = subtable->nodelist;
3366  looking = nodelist[posn];
3367 
3368  while (T < cuddT(looking)) {
3369  looking = Cudd_Regular(looking->next);
3370  }
3371  while (T == cuddT(looking) && E < cuddE(looking)) {
3372  looking = Cudd_Regular(looking->next);
3373  }
3374  if (cuddT(looking) == T && cuddE(looking) == E) {
3375  return(looking);
3376  }
3377 
3378  return(NULL);
3379 
3380 } /* end of cuddUniqueLookup */
#define ddHash(f, g, s)
Definition: cuddInt.h:737
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
DdSubtable * subtables
Definition: cuddInt.h:365
DdNode * next
Definition: cudd.h:281
DdNode ** nodelist
Definition: cuddInt.h:327
#define cuddF2L(f)
Definition: cuddInt.h:718
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddI(dd, index)
Definition: cuddInt.h:686
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define assert(ex)
Definition: util_old.h:213
int shift
Definition: cuddInt.h:328
int * perm
Definition: cuddInt.h:386
static void ddClearFlag ( DdNode f)
static

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

Synopsis [Performs a DFS from f, clearing the LSB of the next pointers.]

Description []

SideEffects [None]

SeeAlso [ddSupportStep ddDagInt]

Definition at line 3735 of file cuddUtil.c.

3737 {
3738  if (!Cudd_IsComplement(f->next)) {
3739  return;
3740  }
3741  /* Clear visited flag. */
3742  f->next = Cudd_Regular(f->next);
3743  if (cuddIsConstant(f)) {
3744  return;
3745  }
3746  ddClearFlag(cuddT(f));
3748  return;
3749 
3750 } /* end of ddClearFlag */
#define Cudd_Regular(node)
Definition: cudd.h:397
#define Cudd_IsComplement(node)
Definition: cudd.h:425
DdNode * next
Definition: cudd.h:281
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddE(node)
Definition: cuddInt.h:652
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
static double ddCountMintermAux ( DdNode node,
double  max,
DdHashTable table 
)
static

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

Synopsis [Performs the recursive step of Cudd_CountMinterm.]

Description [Performs the recursive step of Cudd_CountMinterm. It is based on the following identity. Let |f| be the number of minterms of f. Then: <xmp> |f| = (|f0|+|f1|)/2 </xmp> where f0 and f1 are the two cofactors of f. Does not use the identity |f'| = max - |f|, to minimize loss of accuracy due to roundoff. Returns the number of minterms of the function rooted at node.]

SideEffects [None]

Definition at line 3439 of file cuddUtil.c.

3443 {
3444  DdNode *N, *Nt, *Ne;
3445  double min, minT, minE;
3446  DdNode *res;
3447 
3448  N = Cudd_Regular(node);
3449 
3450  if (cuddIsConstant(N)) {
3451  if (node == background || node == zero) {
3452  return(0.0);
3453  } else {
3454  return(max);
3455  }
3456  }
3457  if (N->ref != 1 && (res = cuddHashTableLookup1(table,node)) != NULL) {
3458  min = cuddV(res);
3459  if (res->ref == 0) {
3460  table->manager->dead++;
3461  table->manager->constants.dead++;
3462  }
3463  return(min);
3464  }
3465 
3466  Nt = cuddT(N); Ne = cuddE(N);
3467  if (Cudd_IsComplement(node)) {
3468  Nt = Cudd_Not(Nt); Ne = Cudd_Not(Ne);
3469  }
3470 
3471  minT = ddCountMintermAux(Nt,max,table);
3472  if (minT == (double)CUDD_OUT_OF_MEM) return((double)CUDD_OUT_OF_MEM);
3473  minT *= 0.5;
3474  minE = ddCountMintermAux(Ne,max,table);
3475  if (minE == (double)CUDD_OUT_OF_MEM) return((double)CUDD_OUT_OF_MEM);
3476  minE *= 0.5;
3477  min = minT + minE;
3478 
3479  if (N->ref != 1) {
3480  ptrint fanout = (ptrint) N->ref;
3481  cuddSatDec(fanout);
3482  res = cuddUniqueConst(table->manager,min);
3483  if (!cuddHashTableInsert1(table,node,res,fanout)) {
3484  cuddRef(res); Cudd_RecursiveDeref(table->manager, res);
3485  return((double)CUDD_OUT_OF_MEM);
3486  }
3487  }
3488 
3489  return(min);
3490 
3491 } /* end of ddCountMintermAux */
DdHalfWord ref
Definition: cudd.h:280
#define cuddRef(n)
Definition: cuddInt.h:584
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
DdManager * manager
Definition: cuddInt.h:313
#define Cudd_Regular(node)
Definition: cudd.h:397
static DdNode * background
Definition: cuddUtil.c:148
DdNode * cuddHashTableLookup1(DdHashTable *hash, DdNode *f)
Definition: cuddLCache.c:819
#define cuddV(node)
Definition: cuddInt.h:668
unsigned int dead
Definition: cuddInt.h:371
#define Cudd_IsComplement(node)
Definition: cudd.h:425
unsigned int dead
Definition: cuddInt.h:332
ABC_PTRINT_T ptrint
Definition: cuddInt.h:260
#define cuddIsConstant(node)
Definition: cuddInt.h:620
static DdNode * zero
Definition: cuddUtil.c:148
static double max
Definition: cuddSubsetHB.c:134
#define cuddT(node)
Definition: cuddInt.h:636
int cuddHashTableInsert1(DdHashTable *hash, DdNode *f, DdNode *value, ptrint count)
Definition: cuddLCache.c:767
#define cuddE(node)
Definition: cuddInt.h:652
static double ddCountMintermAux(DdNode *node, double max, DdHashTable *table)
Definition: cuddUtil.c:3439
#define cuddSatDec(x)
Definition: cuddInt.h:896
DdSubtable constants
Definition: cuddInt.h:367
static double ddCountPathAux ( DdNode node,
st__table table 
)
static

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

Synopsis [Performs the recursive step of Cudd_CountPath.]

Description [Performs the recursive step of Cudd_CountPath. It is based on the following identity. Let |f| be the number of paths of f. Then: <xmp> |f| = |f0|+|f1| </xmp> where f0 and f1 are the two cofactors of f. Uses the identity |f'| = |f|, to improve the utilization of the (local) cache. Returns the number of paths of the function rooted at node.]

SideEffects [None]

Definition at line 3512 of file cuddUtil.c.

3515 {
3516 
3517  DdNode *Nv, *Nnv;
3518  double paths, *ppaths, paths1, paths2;
3519  double *dummy;
3520 
3521 
3522  if (cuddIsConstant(node)) {
3523  return(1.0);
3524  }
3525  if ( st__lookup(table, (const char *)node, (char **)&dummy)) {
3526  paths = *dummy;
3527  return(paths);
3528  }
3529 
3530  Nv = cuddT(node); Nnv = cuddE(node);
3531 
3532  paths1 = ddCountPathAux(Nv,table);
3533  if (paths1 == (double)CUDD_OUT_OF_MEM) return((double)CUDD_OUT_OF_MEM);
3534  paths2 = ddCountPathAux(Cudd_Regular(Nnv),table);
3535  if (paths2 == (double)CUDD_OUT_OF_MEM) return((double)CUDD_OUT_OF_MEM);
3536  paths = paths1 + paths2;
3537 
3538  ppaths = ABC_ALLOC(double,1);
3539  if (ppaths == NULL) {
3540  return((double)CUDD_OUT_OF_MEM);
3541  }
3542 
3543  *ppaths = paths;
3544 
3545  if ( st__add_direct(table,(char *)node, (char *)ppaths) == st__OUT_OF_MEM) {
3546  ABC_FREE(ppaths);
3547  return((double)CUDD_OUT_OF_MEM);
3548  }
3549  return(paths);
3550 
3551 } /* end of ddCountPathAux */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
Definition: cudd.h:278
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define cuddIsConstant(node)
Definition: cuddInt.h:620
static double ddCountPathAux(DdNode *node, st__table *table)
Definition: cuddUtil.c:3512
#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
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define cuddE(node)
Definition: cuddInt.h:652
int st__add_direct(st__table *table, char *key, char *value)
Definition: st.c:205
static double ddCountPathsToNonZero ( DdNode N,
st__table table 
)
static

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

Synopsis [Performs the recursive step of Cudd_CountPathsToNonZero.]

Description [Performs the recursive step of Cudd_CountPathsToNonZero. It is based on the following identity. Let |f| be the number of paths of f. Then: <xmp> |f| = |f0|+|f1| </xmp> where f0 and f1 are the two cofactors of f. Returns the number of paths of the function rooted at node.]

SideEffects [None]

Definition at line 3645 of file cuddUtil.c.

3648 {
3649 
3650  DdNode *node, *Nt, *Ne;
3651  double paths, *ppaths, paths1, paths2;
3652  double *dummy;
3653 
3654  node = Cudd_Regular(N);
3655  if (cuddIsConstant(node)) {
3656  return((double) !(Cudd_IsComplement(N) || cuddV(node)==DD_ZERO_VAL));
3657  }
3658  if ( st__lookup(table, (const char *)N, (char **)&dummy)) {
3659  paths = *dummy;
3660  return(paths);
3661  }
3662 
3663  Nt = cuddT(node); Ne = cuddE(node);
3664  if (node != N) {
3665  Nt = Cudd_Not(Nt); Ne = Cudd_Not(Ne);
3666  }
3667 
3668  paths1 = ddCountPathsToNonZero(Nt,table);
3669  if (paths1 == (double)CUDD_OUT_OF_MEM) return((double)CUDD_OUT_OF_MEM);
3670  paths2 = ddCountPathsToNonZero(Ne,table);
3671  if (paths2 == (double)CUDD_OUT_OF_MEM) return((double)CUDD_OUT_OF_MEM);
3672  paths = paths1 + paths2;
3673 
3674  ppaths = ABC_ALLOC(double,1);
3675  if (ppaths == NULL) {
3676  return((double)CUDD_OUT_OF_MEM);
3677  }
3678 
3679  *ppaths = paths;
3680 
3681  if ( st__add_direct(table,(char *)N, (char *)ppaths) == st__OUT_OF_MEM) {
3682  ABC_FREE(ppaths);
3683  return((double)CUDD_OUT_OF_MEM);
3684  }
3685  return(paths);
3686 
3687 } /* end of ddCountPathsToNonZero */
static double ddCountPathsToNonZero(DdNode *N, st__table *table)
Definition: cuddUtil.c:3645
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define DD_ZERO_VAL
Definition: cuddInt.h:108
#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 st__OUT_OF_MEM
Definition: st.h:113
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define cuddE(node)
Definition: cuddInt.h:652
int st__add_direct(st__table *table, char *key, char *value)
Definition: st.c:205
static int ddDagInt ( DdNode n)
static

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

Synopsis [Performs the recursive step of Cudd_DagSize.]

Description [Performs the recursive step of Cudd_DagSize. Returns the number of nodes in the graph rooted at n.]

SideEffects [None]

Definition at line 3165 of file cuddUtil.c.

3167 {
3168  int tval, eval;
3169 
3170  if (Cudd_IsComplement(n->next)) {
3171  return(0);
3172  }
3173  n->next = Cudd_Not(n->next);
3174  if (cuddIsConstant(n)) {
3175  return(1);
3176  }
3177  tval = ddDagInt(cuddT(n));
3178  eval = ddDagInt(Cudd_Regular(cuddE(n)));
3179  return(1 + tval + eval);
3180 
3181 } /* end of ddDagInt */
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_Regular(node)
Definition: cudd.h:397
#define Cudd_IsComplement(node)
Definition: cudd.h:425
DdNode * next
Definition: cudd.h:281
#define cuddIsConstant(node)
Definition: cuddInt.h:620
static int ddDagInt(DdNode *n)
Definition: cuddUtil.c:3165
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddE(node)
Definition: cuddInt.h:652
static int ddEpdCountMintermAux ( DdNode node,
EpDouble max,
EpDouble epd,
st__table table 
)
static

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

Synopsis [Performs the recursive step of Cudd_EpdCountMinterm.]

Description [Performs the recursive step of Cudd_EpdCountMinterm. It is based on the following identity. Let |f| be the number of minterms of f. Then: <xmp> |f| = (|f0|+|f1|)/2 </xmp> where f0 and f1 are the two cofactors of f. Does not use the identity |f'| = max - |f|, to minimize loss of accuracy due to roundoff. Returns the number of minterms of the function rooted at node.]

SideEffects [None]

Definition at line 3573 of file cuddUtil.c.

3578 {
3579  DdNode *Nt, *Ne;
3580  EpDouble *min, minT, minE;
3581  EpDouble *res;
3582  int status;
3583 
3584  /* node is assumed to be regular */
3585  if (cuddIsConstant(node)) {
3586  if (node == background || node == zero) {
3587  EpdMakeZero(epd, 0);
3588  } else {
3589  EpdCopy(max, epd);
3590  }
3591  return(0);
3592  }
3593  if (node->ref != 1 && st__lookup(table, (const char *)node, (char **)&res)) {
3594  EpdCopy(res, epd);
3595  return(0);
3596  }
3597 
3598  Nt = cuddT(node); Ne = cuddE(node);
3599 
3600  status = ddEpdCountMintermAux(Nt,max,&minT,table);
3601  if (status == CUDD_OUT_OF_MEM) return(CUDD_OUT_OF_MEM);
3602  EpdMultiply(&minT, (double)0.5);
3603  status = ddEpdCountMintermAux(Cudd_Regular(Ne),max,&minE,table);
3604  if (status == CUDD_OUT_OF_MEM) return(CUDD_OUT_OF_MEM);
3605  if (Cudd_IsComplement(Ne)) {
3606  EpdSubtract3(max, &minE, epd);
3607  EpdCopy(epd, &minE);
3608  }
3609  EpdMultiply(&minE, (double)0.5);
3610  EpdAdd3(&minT, &minE, epd);
3611 
3612  if (node->ref > 1) {
3613  min = EpdAlloc();
3614  if (!min)
3615  return(CUDD_OUT_OF_MEM);
3616  EpdCopy(epd, min);
3617  if ( st__insert(table, (char *)node, (char *)min) == st__OUT_OF_MEM) {
3618  EpdFree(min);
3619  return(CUDD_OUT_OF_MEM);
3620  }
3621  }
3622 
3623  return(0);
3624 
3625 } /* end of ddEpdCountMintermAux */
DdHalfWord ref
Definition: cudd.h:280
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
Definition: cudd.h:278
void EpdCopy(EpDouble *from, EpDouble *to)
Definition: epd.c:1182
int st__insert(st__table *table, const char *key, char *value)
Definition: st.c:171
#define Cudd_Regular(node)
Definition: cudd.h:397
static DdNode * background
Definition: cuddUtil.c:148
void EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
Definition: epd.c:850
#define Cudd_IsComplement(node)
Definition: cudd.h:425
void EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
Definition: epd.c:660
#define cuddIsConstant(node)
Definition: cuddInt.h:620
static DdNode * zero
Definition: cuddUtil.c:148
void EpdMakeZero(EpDouble *epd, int sign)
Definition: epd.c:1137
ABC_NAMESPACE_IMPL_START EpDouble * EpdAlloc(void)
Definition: epd.c:72
#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
#define cuddE(node)
Definition: cuddInt.h:652
void EpdMultiply(EpDouble *epd1, double value)
Definition: epd.c:205
void EpdFree(EpDouble *epd)
Definition: epd.c:117
static int ddEpdCountMintermAux(DdNode *node, EpDouble *max, EpDouble *epd, st__table *table)
Definition: cuddUtil.c:3573
static enum st__retval ddEpdFree ( char *  key,
char *  value,
char *  arg 
)
static

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

Synopsis [Frees the memory used to store the minterm counts recorded in the visited table.]

Description [Frees the memory used to store the minterm counts recorded in the visited table. Returns st__CONTINUE.]

SideEffects [None]

Definition at line 3922 of file cuddUtil.c.

3926 {
3927  EpDouble *epd;
3928 
3929  epd = (EpDouble *) value;
3930  EpdFree(epd);
3931  return( st__CONTINUE);
3932 
3933 } /* end of ddEpdFree */
int value
void EpdFree(EpDouble *epd)
Definition: epd.c:117
static int ddLeavesInt ( DdNode n)
static

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

Synopsis [Performs the recursive step of Cudd_CountLeaves.]

Description [Performs the recursive step of Cudd_CountLeaves. Returns the number of leaves in the DD rooted at n.]

SideEffects [None]

SeeAlso [Cudd_CountLeaves]

Definition at line 3766 of file cuddUtil.c.

3768 {
3769  int tval, eval;
3770 
3771  if (Cudd_IsComplement(n->next)) {
3772  return(0);
3773  }
3774  n->next = Cudd_Not(n->next);
3775  if (cuddIsConstant(n)) {
3776  return(1);
3777  }
3778  tval = ddLeavesInt(cuddT(n));
3779  eval = ddLeavesInt(Cudd_Regular(cuddE(n)));
3780  return(tval + eval);
3781 
3782 } /* end of ddLeavesInt */
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_Regular(node)
Definition: cudd.h:397
#define Cudd_IsComplement(node)
Definition: cudd.h:425
DdNode * next
Definition: cudd.h:281
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
static int ddLeavesInt(DdNode *n)
Definition: cuddUtil.c:3766
#define cuddE(node)
Definition: cuddInt.h:652
static int ddPickArbitraryMinterms ( DdManager dd,
DdNode node,
int  nvars,
int  nminterms,
char **  string 
)
static

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

Synopsis [Performs the recursive step of Cudd_bddPickArbitraryMinterms.]

Description [Performs the recursive step of Cudd_bddPickArbitraryMinterms. Returns 1 if successful; 0 otherwise.]

SideEffects [none]

SeeAlso [Cudd_bddPickArbitraryMinterms]

Definition at line 3798 of file cuddUtil.c.

3804 {
3805  DdNode *N, *T, *E;
3806  DdNode *one, *bzero;
3807  int i, t, result;
3808  double min1, min2;
3809 
3810  if (string == NULL || node == NULL) return(0);
3811 
3812  /* The constant 0 function has no on-set cubes. */
3813  one = DD_ONE(dd);
3814  bzero = Cudd_Not(one);
3815  if (nminterms == 0 || node == bzero) return(1);
3816  if (node == one) {
3817  return(1);
3818  }
3819 
3820  N = Cudd_Regular(node);
3821  T = cuddT(N); E = cuddE(N);
3822  if (Cudd_IsComplement(node)) {
3823  T = Cudd_Not(T); E = Cudd_Not(E);
3824  }
3825 
3826  min1 = Cudd_CountMinterm(dd, T, nvars) / 2.0;
3827  if (min1 == (double)CUDD_OUT_OF_MEM) return(0);
3828  min2 = Cudd_CountMinterm(dd, E, nvars) / 2.0;
3829  if (min2 == (double)CUDD_OUT_OF_MEM) return(0);
3830 
3831  t = (int)((double)nminterms * min1 / (min1 + min2) + 0.5);
3832  for (i = 0; i < t; i++)
3833  string[i][N->index] = '1';
3834  for (i = t; i < nminterms; i++)
3835  string[i][N->index] = '0';
3836 
3837  result = ddPickArbitraryMinterms(dd,T,nvars,t,&string[0]);
3838  if (result == 0)
3839  return(0);
3840  result = ddPickArbitraryMinterms(dd,E,nvars,nminterms-t,&string[t]);
3841  return(result);
3842 
3843 } /* end of ddPickArbitraryMinterms */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
static int ddPickArbitraryMinterms(DdManager *dd, DdNode *node, int nvars, int nminterms, char **string)
Definition: cuddUtil.c:3798
#define Cudd_Regular(node)
Definition: cudd.h:397
for(p=first;p->value< newval;p=p->next)
double Cudd_CountMinterm(DdManager *manager, DdNode *node, int nvars)
Definition: cuddUtil.c:578
#define Cudd_IsComplement(node)
Definition: cudd.h:425
static DdNode * one
Definition: cuddDecomp.c:112
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
static int result
Definition: cuddGenetic.c:125
#define DD_ONE(dd)
Definition: cuddInt.h:911
static int ddPickRepresentativeCube ( DdManager dd,
DdNode node,
double *  weight,
char *  string 
)
static

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

Synopsis [Finds a representative cube of a BDD.]

Description [Finds a representative cube of a BDD with the weight of each variable. From the top variable, if the weight is greater than or equal to 0.0, choose THEN branch unless the child is the constant 0. Otherwise, choose ELSE branch unless the child is the constant 0.]

SideEffects [Cudd_SubsetWithMaskVars Cudd_bddPickOneCube]

Definition at line 3859 of file cuddUtil.c.

3864 {
3865  DdNode *N, *T, *E;
3866  DdNode *one, *bzero;
3867 
3868  if (string == NULL || node == NULL) return(0);
3869 
3870  /* The constant 0 function has no on-set cubes. */
3871  one = DD_ONE(dd);
3872  bzero = Cudd_Not(one);
3873  if (node == bzero) return(0);
3874 
3875  if (node == DD_ONE(dd)) return(1);
3876 
3877  for (;;) {
3878  N = Cudd_Regular(node);
3879  if (N == one)
3880  break;
3881  T = cuddT(N);
3882  E = cuddE(N);
3883  if (Cudd_IsComplement(node)) {
3884  T = Cudd_Not(T);
3885  E = Cudd_Not(E);
3886  }
3887  if (weight[N->index] >= 0.0) {
3888  if (T == bzero) {
3889  node = E;
3890  string[N->index] = '0';
3891  } else {
3892  node = T;
3893  string[N->index] = '1';
3894  }
3895  } else {
3896  if (E == bzero) {
3897  node = T;
3898  string[N->index] = '1';
3899  } else {
3900  node = E;
3901  string[N->index] = '0';
3902  }
3903  }
3904  }
3905  return(1);
3906 
3907 } /* end of ddPickRepresentativeCube */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_Regular(node)
Definition: cudd.h:397
#define Cudd_IsComplement(node)
Definition: cudd.h:425
static DdNode * one
Definition: cuddDecomp.c:112
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
static void ddPrintMintermAux ( DdManager dd,
DdNode node,
int *  list 
)
static

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

Synopsis [Performs the recursive step of Cudd_PrintMinterm.]

Description []

SideEffects [None]

Definition at line 3111 of file cuddUtil.c.

3115 {
3116  DdNode *N,*Nv,*Nnv;
3117  int i,v,index;
3118 
3119  N = Cudd_Regular(node);
3120 
3121  if (cuddIsConstant(N)) {
3122  /* Terminal case: Print one cube based on the current recursion
3123  ** path, unless we have reached the background value (ADDs) or
3124  ** the logical zero (BDDs).
3125  */
3126  if (node != background && node != zero) {
3127  for (i = 0; i < dd->size; i++) {
3128  v = list[i];
3129  if (v == 0) (void) fprintf(dd->out,"0");
3130  else if (v == 1) (void) fprintf(dd->out,"1");
3131  else (void) fprintf(dd->out,"-");
3132  }
3133  (void) fprintf(dd->out," % g\n", cuddV(node));
3134  }
3135  } else {
3136  Nv = cuddT(N);
3137  Nnv = cuddE(N);
3138  if (Cudd_IsComplement(node)) {
3139  Nv = Cudd_Not(Nv);
3140  Nnv = Cudd_Not(Nnv);
3141  }
3142  index = N->index;
3143  list[index] = 0;
3144  ddPrintMintermAux(dd,Nnv,list);
3145  list[index] = 1;
3146  ddPrintMintermAux(dd,Nv,list);
3147  list[index] = 2;
3148  }
3149  return;
3150 
3151 } /* end of ddPrintMintermAux */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
static DdNode * background
Definition: cuddUtil.c:148
#define cuddV(node)
Definition: cuddInt.h:668
#define Cudd_IsComplement(node)
Definition: cudd.h:425
FILE * out
Definition: cuddInt.h:441
static void ddPrintMintermAux(DdManager *dd, DdNode *node, int *list)
Definition: cuddUtil.c:3111
#define cuddIsConstant(node)
Definition: cuddInt.h:620
static DdNode * zero
Definition: cuddUtil.c:148
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
static void ddSupportStep ( DdNode f,
int *  support 
)
static

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

Synopsis [Performs the recursive step of Cudd_Support.]

Description [Performs the recursive step of Cudd_Support. Performs a DFS from f. The support is accumulated in supp as a side effect. Uses the LSB of the then pointer as visited flag.]

SideEffects [None]

SeeAlso [ddClearFlag]

Definition at line 3704 of file cuddUtil.c.

3707 {
3708  if (cuddIsConstant(f) || Cudd_IsComplement(f->next)) {
3709  return;
3710  }
3711 
3712  support[f->index] = 1;
3713  ddSupportStep(cuddT(f),support);
3714  ddSupportStep(Cudd_Regular(cuddE(f)),support);
3715  /* Mark as visited. */
3716  f->next = Cudd_Not(f->next);
3717  return;
3718 
3719 } /* end of ddSupportStep */
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_Regular(node)
Definition: cudd.h:397
#define Cudd_IsComplement(node)
Definition: cudd.h:425
DdNode * next
Definition: cudd.h:281
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
static int dp2 ( DdManager dd,
DdNode f,
st__table t 
)
static

AutomaticStart

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

Synopsis [Performs the recursive step of cuddP.]

Description [Performs the recursive step of cuddP. Returns 1 in case of success; 0 otherwise.]

SideEffects [None]

Definition at line 3018 of file cuddUtil.c.

3022 {
3023  DdNode *g, *n, *N;
3024  int T,E;
3025 
3026  if (f == NULL) {
3027  return(0);
3028  }
3029  g = Cudd_Regular(f);
3030  if (cuddIsConstant(g)) {
3031 #if SIZEOF_VOID_P == 8
3032  (void) fprintf(dd->out,"ID = %c0x%lx\tvalue = %-9g\n", bang(f),
3033  (ptruint) g / (ptruint) sizeof(DdNode),cuddV(g));
3034 #else
3035  (void) fprintf(dd->out,"ID = %c0x%x\tvalue = %-9g\n", bang(f),
3036  (ptruint) g / (ptruint) sizeof(DdNode),cuddV(g));
3037 #endif
3038  return(1);
3039  }
3040  if ( st__is_member(t,(char *) g) == 1) {
3041  return(1);
3042  }
3043  if ( st__add_direct(t,(char *) g,NULL) == st__OUT_OF_MEM)
3044  return(0);
3045 #ifdef DD_STATS
3046 #if SIZEOF_VOID_P == 8
3047  (void) fprintf(dd->out,"ID = %c0x%lx\tindex = %d\tr = %d\t", bang(f),
3048  (ptruint) g / (ptruint) sizeof(DdNode), g->index, g->ref);
3049 #else
3050  (void) fprintf(dd->out,"ID = %c0x%x\tindex = %d\tr = %d\t", bang(f),
3051  (ptruint) g / (ptruint) sizeof(DdNode),g->index,g->ref);
3052 #endif
3053 #else
3054 #if SIZEOF_VOID_P == 8
3055  (void) fprintf(dd->out,"ID = %c0x%lx\tindex = %u\t", bang(f),
3056  (ptruint) g / (ptruint) sizeof(DdNode),g->index);
3057 #else
3058  (void) fprintf(dd->out,"ID = %c0x%x\tindex = %hu\t", bang(f),
3059  (ptruint) g / (ptruint) sizeof(DdNode),g->index);
3060 #endif
3061 #endif
3062  n = cuddT(g);
3063  if (cuddIsConstant(n)) {
3064  (void) fprintf(dd->out,"T = %-9g\t",cuddV(n));
3065  T = 1;
3066  } else {
3067 #if SIZEOF_VOID_P == 8
3068  (void) fprintf(dd->out,"T = 0x%lx\t",(ptruint) n / (ptruint) sizeof(DdNode));
3069 #else
3070  (void) fprintf(dd->out,"T = 0x%x\t",(ptruint) n / (ptruint) sizeof(DdNode));
3071 #endif
3072  T = 0;
3073  }
3074 
3075  n = cuddE(g);
3076  N = Cudd_Regular(n);
3077  if (cuddIsConstant(N)) {
3078  (void) fprintf(dd->out,"E = %c%-9g\n",bang(n),cuddV(N));
3079  E = 1;
3080  } else {
3081 #if SIZEOF_VOID_P == 8
3082  (void) fprintf(dd->out,"E = %c0x%lx\n", bang(n), (ptruint) N/(ptruint) sizeof(DdNode));
3083 #else
3084  (void) fprintf(dd->out,"E = %c0x%x\n", bang(n), (ptruint) N/(ptruint) sizeof(DdNode));
3085 #endif
3086  E = 0;
3087  }
3088  if (E == 0) {
3089  if (dp2(dd,N,t) == 0)
3090  return(0);
3091  }
3092  if (T == 0) {
3093  if (dp2(dd,cuddT(g),t) == 0)
3094  return(0);
3095  }
3096  return(1);
3097 
3098 } /* end of dp2 */
DdHalfWord ref
Definition: cudd.h:280
Definition: cudd.h:278
static int dp2(DdManager *dd, DdNode *f, st__table *t)
Definition: cuddUtil.c:3018
#define Cudd_Regular(node)
Definition: cudd.h:397
#define st__is_member(table, key)
Definition: st.h:70
#define bang(f)
Definition: cuddUtil.c:159
struct DdNode DdNode
Definition: cudd.h:270
#define cuddV(node)
Definition: cuddInt.h:668
ABC_PTRUINT_T ptruint
Definition: cuddInt.h:261
FILE * out
Definition: cuddInt.h:441
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
#define st__OUT_OF_MEM
Definition: st.h:113
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

Variable Documentation

DdNode* background
static

Definition at line 148 of file cuddUtil.c.

long cuddRand = 0
static

Definition at line 150 of file cuddUtil.c.

long cuddRand2
static

Definition at line 151 of file cuddUtil.c.

char rcsid [] DD_UNUSED = "$Id: cuddUtil.c,v 1.81 2009/03/08 02:49:02 fabio Exp $"
static

Definition at line 145 of file cuddUtil.c.

long shuffleSelect
static

Definition at line 152 of file cuddUtil.c.

long shuffleTable[STAB_SIZE]
static

Definition at line 153 of file cuddUtil.c.

DdNode * zero
static

Definition at line 148 of file cuddUtil.c.