00001
00035 #include <math.h>
00036 #include "util_hack.h"
00037 #include "cuddInt.h"
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #ifndef lint
00059 static char rcsid[] DD_UNUSED = "$Id: cuddZddMisc.c,v 1.1.1.1 2003/02/24 22:23:54 wjiang Exp $";
00060 #endif
00061
00062
00063
00064
00065
00066
00069
00070
00071
00072
00073 static int cuddZddDagInt ARGS((DdNode *n, st_table *tab));
00074
00078
00079
00080
00081
00082
00095 int
00096 Cudd_zddDagSize(
00097 DdNode * p_node)
00098 {
00099
00100 int i;
00101 st_table *table;
00102
00103 table = st_init_table(st_ptrcmp, st_ptrhash);
00104 i = cuddZddDagInt(p_node, table);
00105 st_free_table(table);
00106 return(i);
00107
00108 }
00109
00110
00126 double
00127 Cudd_zddCountMinterm(
00128 DdManager * zdd,
00129 DdNode * node,
00130 int path)
00131 {
00132 double dc_var, minterms;
00133
00134 dc_var = (double)((double)(zdd->sizeZ) - (double)path);
00135 minterms = Cudd_zddCountDouble(zdd, node) / pow(2.0, dc_var);
00136 return(minterms);
00137
00138 }
00139
00140
00152 void
00153 Cudd_zddPrintSubtable(
00154 DdManager * table)
00155 {
00156 int i, j;
00157 DdNode *z1, *z1_next, *base;
00158 DdSubtable *ZSubTable;
00159
00160 base = table->one;
00161 for (i = table->sizeZ - 1; i >= 0; i--) {
00162 ZSubTable = &(table->subtableZ[i]);
00163 printf("subtable[%d]:\n", i);
00164 for (j = ZSubTable->slots - 1; j >= 0; j--) {
00165 z1 = ZSubTable->nodelist[j];
00166 while (z1 != NIL(DdNode)) {
00167 (void) fprintf(table->out,
00168 #if SIZEOF_VOID_P == 8
00169 "ID = 0x%lx\tindex = %d\tr = %d\t",
00170 (unsigned long) z1 / (unsigned long) sizeof(DdNode),
00171 z1->index, z1->ref);
00172 #else
00173 "ID = 0x%x\tindex = %d\tr = %d\t",
00174 (unsigned) z1 / (unsigned) sizeof(DdNode),
00175 z1->index, z1->ref);
00176 #endif
00177 z1_next = cuddT(z1);
00178 if (Cudd_IsConstant(z1_next)) {
00179 (void) fprintf(table->out, "T = %d\t\t",
00180 (z1_next == base));
00181 }
00182 else {
00183 #if SIZEOF_VOID_P == 8
00184 (void) fprintf(table->out, "T = 0x%lx\t",
00185 (unsigned long) z1_next / (unsigned long) sizeof(DdNode));
00186 #else
00187 (void) fprintf(table->out, "T = 0x%x\t",
00188 (unsigned) z1_next / (unsigned) sizeof(DdNode));
00189 #endif
00190 }
00191 z1_next = cuddE(z1);
00192 if (Cudd_IsConstant(z1_next)) {
00193 (void) fprintf(table->out, "E = %d\n",
00194 (z1_next == base));
00195 }
00196 else {
00197 #if SIZEOF_VOID_P == 8
00198 (void) fprintf(table->out, "E = 0x%lx\n",
00199 (unsigned long) z1_next / (unsigned long) sizeof(DdNode));
00200 #else
00201 (void) fprintf(table->out, "E = 0x%x\n",
00202 (unsigned) z1_next / (unsigned) sizeof(DdNode));
00203 #endif
00204 }
00205
00206 z1_next = z1->next;
00207 z1 = z1_next;
00208 }
00209 }
00210 }
00211 putchar('\n');
00212
00213 }
00214
00215
00216
00217
00218
00219
00220
00233 static int
00234 cuddZddDagInt(
00235 DdNode * n,
00236 st_table * tab)
00237 {
00238 if (n == NIL(DdNode))
00239 return(0);
00240
00241 if (st_is_member(tab, (char *)n) == 1)
00242 return(0);
00243
00244 if (Cudd_IsConstant(n))
00245 return(0);
00246
00247 (void)st_insert(tab, (char *)n, NIL(char));
00248 return(1 + cuddZddDagInt(cuddT(n), tab) +
00249 cuddZddDagInt(cuddE(n), tab));
00250
00251 }
00252