00001
00062 #include <math.h>
00063 #include "util.h"
00064 #include "cuddInt.h"
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 #ifndef lint
00086 static char rcsid[] DD_UNUSED = "$Id: cuddZddMisc.c,v 1.17 2009/03/08 02:49:02 fabio Exp $";
00087 #endif
00088
00089
00090
00091
00092
00093
00096
00097
00098
00099
00100 static int cuddZddDagInt (DdNode *n, st_table *tab);
00101
00105
00106
00107
00108
00109
00122 int
00123 Cudd_zddDagSize(
00124 DdNode * p_node)
00125 {
00126
00127 int i;
00128 st_table *table;
00129
00130 table = st_init_table(st_ptrcmp, st_ptrhash);
00131 i = cuddZddDagInt(p_node, table);
00132 st_free_table(table);
00133 return(i);
00134
00135 }
00136
00137
00153 double
00154 Cudd_zddCountMinterm(
00155 DdManager * zdd,
00156 DdNode * node,
00157 int path)
00158 {
00159 double dc_var, minterms;
00160
00161 dc_var = (double)((double)(zdd->sizeZ) - (double)path);
00162 minterms = Cudd_zddCountDouble(zdd, node) / pow(2.0, dc_var);
00163 return(minterms);
00164
00165 }
00166
00167
00179 void
00180 Cudd_zddPrintSubtable(
00181 DdManager * table)
00182 {
00183 int i, j;
00184 DdNode *z1, *z1_next, *base;
00185 DdSubtable *ZSubTable;
00186
00187 base = table->one;
00188 for (i = table->sizeZ - 1; i >= 0; i--) {
00189 ZSubTable = &(table->subtableZ[i]);
00190 printf("subtable[%d]:\n", i);
00191 for (j = ZSubTable->slots - 1; j >= 0; j--) {
00192 z1 = ZSubTable->nodelist[j];
00193 while (z1 != NIL(DdNode)) {
00194 (void) fprintf(table->out,
00195 #if SIZEOF_VOID_P == 8
00196 "ID = 0x%lx\tindex = %u\tr = %u\t",
00197 (ptruint) z1 / (ptruint) sizeof(DdNode),
00198 z1->index, z1->ref);
00199 #else
00200 "ID = 0x%x\tindex = %hu\tr = %hu\t",
00201 (ptruint) z1 / (ptruint) sizeof(DdNode),
00202 z1->index, z1->ref);
00203 #endif
00204 z1_next = cuddT(z1);
00205 if (Cudd_IsConstant(z1_next)) {
00206 (void) fprintf(table->out, "T = %d\t\t",
00207 (z1_next == base));
00208 }
00209 else {
00210 #if SIZEOF_VOID_P == 8
00211 (void) fprintf(table->out, "T = 0x%lx\t",
00212 (ptruint) z1_next / (ptruint) sizeof(DdNode));
00213 #else
00214 (void) fprintf(table->out, "T = 0x%x\t",
00215 (ptruint) z1_next / (ptruint) sizeof(DdNode));
00216 #endif
00217 }
00218 z1_next = cuddE(z1);
00219 if (Cudd_IsConstant(z1_next)) {
00220 (void) fprintf(table->out, "E = %d\n",
00221 (z1_next == base));
00222 }
00223 else {
00224 #if SIZEOF_VOID_P == 8
00225 (void) fprintf(table->out, "E = 0x%lx\n",
00226 (ptruint) z1_next / (ptruint) sizeof(DdNode));
00227 #else
00228 (void) fprintf(table->out, "E = 0x%x\n",
00229 (ptruint) z1_next / (ptruint) sizeof(DdNode));
00230 #endif
00231 }
00232
00233 z1_next = z1->next;
00234 z1 = z1_next;
00235 }
00236 }
00237 }
00238 putchar('\n');
00239
00240 }
00241
00242
00243
00244
00245
00246
00247
00260 static int
00261 cuddZddDagInt(
00262 DdNode * n,
00263 st_table * tab)
00264 {
00265 if (n == NIL(DdNode))
00266 return(0);
00267
00268 if (st_is_member(tab, (char *)n) == 1)
00269 return(0);
00270
00271 if (Cudd_IsConstant(n))
00272 return(0);
00273
00274 (void)st_insert(tab, (char *)n, NIL(char));
00275 return(1 + cuddZddDagInt(cuddT(n), tab) +
00276 cuddZddDagInt(cuddE(n), tab));
00277
00278 }