96 static char rcsid[]
DD_UNUSED =
"$Id: cuddZddUtil.c,v 1.27 2009/03/08 02:49:02 fabio Exp $";
142 size = (int)zdd->
sizeZ;
148 for (i = 0; i <
size; i++) list[i] = 3;
176 size = (int)zdd->
sizeZ;
177 if (size % 2 != 0)
return(0);
183 for (i = 0; i <
size; i++) list[i] = 3;
226 if (f == empty && pr > 0) {
227 (void) fprintf(zdd->
out,
": is the empty ZDD\n");
228 (void) fflush(zdd->
out);
237 (void) fprintf(zdd->
out,
": %d nodes %g minterms\n",
241 if (pr == 2 || pr > 3) {
243 (void) fprintf(zdd->
out,
"\n");
245 (void) fflush(zdd->
out);
281 DdNode *top, *next, *prev;
286 if (zdd == NULL || f == NULL)
return(NULL);
301 gen->
stack.stack = NULL;
311 for (i = 0; i < nvars; i++) gen->
gen.
cubes.cube[i] = 2;
318 if (gen->
stack.stack == NULL) {
324 for (i = 0; i <= nvars; i++) gen->
stack.stack[i] = NULL;
339 if (gen->
stack.sp == 1) {
391 DdNode *top, *next, *prev;
396 if (gen->
stack.sp == 1) {
425 if (gen->
stack.sp == 1) {
481 int nvars = zdd->
sizeZ;
485 if (nvars & 1)
return(NULL);
489 if (res == NULL)
return(NULL);
493 for (i = 0; i < nvars; i++) {
494 int v = (path[2*i] << 2) | path[2*i+1];
560 int nvars = dd->
sizeZ;
567 long refAddr, diff, mask;
571 if (sorted == NULL) {
575 for (i = 0; i < nvars; i++) sorted[i] = 0;
578 for (i = 0; i < n; i++) {
580 if (support == NULL)
goto failure;
584 sorted[scan->
index] = 1;
593 if (visited == NULL)
goto failure;
596 for (i = 0; i < n; i++) {
598 if (retval == 0)
goto failure;
613 refAddr = (long) f[0];
616 while (
st__gen(gen, (
const char **)&scan, NULL)) {
617 diff |= refAddr ^ (long) scan;
622 for (i = 0; (unsigned) i < 8 *
sizeof(
long); i += 4) {
624 if (diff <= mask)
break;
628 retval = fprintf(fp,
"digraph \"ZDD\" {\n");
629 if (retval == EOF)
return(0);
631 "size = \"7.5,10\"\ncenter = true;\nedge [dir = none];\n");
632 if (retval == EOF)
return(0);
635 retval = fprintf(fp,
"{ node [shape = plaintext];\n");
636 if (retval == EOF)
goto failure;
637 retval = fprintf(fp,
" edge [style = invis];\n");
638 if (retval == EOF)
goto failure;
642 retval = fprintf(fp,
" \"CONST NODES\" [style = invis];\n");
643 if (retval == EOF)
goto failure;
644 for (i = 0; i < nvars; i++) {
646 if (inames == NULL) {
647 retval = fprintf(fp,
"\" %d \" -> ", dd->
invpermZ[i]);
649 retval = fprintf(fp,
"\" %s \" -> ", inames[dd->
invpermZ[i]]);
651 if (retval == EOF)
goto failure;
654 retval = fprintf(fp,
"\"CONST NODES\"; \n}\n");
655 if (retval == EOF)
goto failure;
658 retval = fprintf(fp,
"{ rank = same; node [shape = box]; edge [style = invis];\n");
659 if (retval == EOF)
goto failure;
660 for (i = 0; i < n; i++) {
661 if (onames == NULL) {
662 retval = fprintf(fp,
"\"F%d\"", i);
664 retval = fprintf(fp,
"\" %s \"", onames[i]);
666 if (retval == EOF)
goto failure;
668 retval = fprintf(fp,
"; }\n");
670 retval = fprintf(fp,
" -> ");
672 if (retval == EOF)
goto failure;
676 for (i = 0; i < nvars; i++) {
678 retval = fprintf(fp,
"{ rank = same; ");
679 if (retval == EOF)
goto failure;
680 if (inames == NULL) {
681 retval = fprintf(fp,
"\" %d \";\n", dd->
invpermZ[i]);
683 retval = fprintf(fp,
"\" %s \";\n", inames[dd->
invpermZ[i]]);
685 if (retval == EOF)
goto failure;
688 for (j = 0; j < slots; j++) {
690 while (scan != NULL) {
692 retval = fprintf(fp,
"\"%p\";\n", (
void *)
695 if (retval == EOF)
goto failure;
700 retval = fprintf(fp,
"}\n");
701 if (retval == EOF)
goto failure;
707 "{ rank = same; \"CONST NODES\";\n{ node [shape = box]; ");
708 if (retval == EOF)
goto failure;
711 for (j = 0; j < slots; j++) {
713 while (scan != NULL) {
715 retval = fprintf(fp,
"\"%p\";\n", (
void *)
717 if (retval == EOF)
goto failure;
722 retval = fprintf(fp,
"}\n}\n");
723 if (retval == EOF)
goto failure;
727 for (i = 0; i < n; i++) {
728 if (onames == NULL) {
729 retval = fprintf(fp,
"\"F%d\"", i);
731 retval = fprintf(fp,
"\" %s \"", onames[i]);
733 if (retval == EOF)
goto failure;
734 retval = fprintf(fp,
" -> \"%p\" [style = solid];\n",
735 (
void *) ((mask & (
ptrint) f[i]) /
737 if (retval == EOF)
goto failure;
741 for (i = 0; i < nvars; i++) {
745 for (j = 0; j < slots; j++) {
747 while (scan != NULL) {
750 "\"%p\" -> \"%p\";\n",
754 if (retval == EOF)
goto failure;
756 "\"%p\" -> \"%p\" [style = dashed];\n",
757 (
void *) ((mask & (
ptrint) scan)
759 (
void *) ((mask & (
ptrint)
762 if (retval == EOF)
goto failure;
773 for (j = 0; j < slots; j++) {
775 while (scan != NULL) {
777 retval = fprintf(fp,
"\"%p\" [label = \"%g\"];\n",
778 (
void *) ((mask & (
ptrint) scan) /
781 if (retval == EOF)
goto failure;
788 retval = fprintf(fp,
"}\n");
789 if (retval == EOF)
goto failure;
796 if (sorted != NULL)
ABC_FREE(sorted);
829 if (table == NULL)
return(0);
831 retval =
zp2(zdd, f, table);
833 (void) fputc(
'\n', zdd->
out);
870 (void)fprintf(zdd->
out,
"ID = %d\n", (f == base));
879 #if SIZEOF_VOID_P == 8
880 (void) fprintf(zdd->
out,
"ID = 0x%lx\tindex = %u\tr = %u\t",
883 (void) fprintf(zdd->
out,
"ID = 0x%x\tindex = %hu\tr = %hu\t",
889 (void) fprintf(zdd->
out,
"T = %d\t\t", (n == base));
892 #if SIZEOF_VOID_P == 8
893 (void) fprintf(zdd->
out,
"T = 0x%lx\t", (
ptruint) n /
896 (void) fprintf(zdd->
out,
"T = 0x%x\t", (
ptruint) n /
904 (void) fprintf(zdd->
out,
"E = %d\n", (n == base));
907 #if SIZEOF_VOID_P == 8
908 (void) fprintf(zdd->
out,
"E = 0x%lx\n", (
ptruint) n /
911 (void) fprintf(zdd->
out,
"E = 0x%x\n", (
ptruint) n /
918 if (
zp2(zdd,
cuddE(f), t) == 0)
return(0);
920 if (
zp2(zdd,
cuddT(f), t) == 0)
return(0);
951 if (level != zdd->
sizeZ) {
959 for (i = 0; i < zdd->
sizeZ; i++) {
962 (void) fprintf(zdd->
out,
"0");
964 (void) fprintf(zdd->
out,
"1");
966 (void) fprintf(zdd->
out,
"@");
968 (
void) fprintf(zdd->
out,
"-");
970 (void) fprintf(zdd->
out,
" 1\n");
983 list[node->
index] = 2;
988 list[node->
index] = 1;
990 list[node->
index] = 0;
1023 if (level != zdd->
sizeZ) {
1031 for (i = 0; i < zdd->
sizeZ; i += 2) {
1032 v = list[i] * 4 + list[i+1];
1034 (void) putc(
'-',zdd->
out);
1036 (void) putc(
'1',zdd->
out);
1038 (void) putc(
'0',zdd->
out);
1040 (
void) putc(
'@',zdd->
out);
1042 (void) fprintf(zdd->
out,
" 1\n");
1055 list[node->
index] = 2;
1060 list[node->
index] = 1;
1062 list[node->
index] = 0;
void st__free_table(st__table *table)
#define cuddIZ(dd, index)
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
static void zdd_print_minterm_aux(DdManager *zdd, DdNode *node, int level, int *list)
DdGen * Cudd_zddFirstPath(DdManager *zdd, DdNode *f, int **path)
#define CUDD_GEN_ZDD_PATHS
struct DdGen::@30::@32 cubes
int Cudd_zddPrintMinterm(DdManager *zdd, DdNode *node)
void st__free_gen(st__generator *gen)
int st__insert(st__table *table, const char *key, char *value)
DdNode * Cudd_Support(DdManager *dd, DdNode *f)
double Cudd_zddCountMinterm(DdManager *zdd, DdNode *node, int path)
#define Cudd_IsConstant(node)
int Cudd_zddDagSize(DdNode *p_node)
char * Cudd_zddCoverPathToString(DdManager *zdd, int *path, char *str)
#define Cudd_Regular(node)
int Cudd_zddPrintCover(DdManager *zdd, DdNode *node)
int st__ptrcmp(const char *, const char *)
int Cudd_zddDumpDot(DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp)
#define ABC_ALLOC(type, num)
#define st__is_member(table, key)
#define CUDD_GEN_NONEMPTY
static const char * onames[]
static int zp2(DdManager *zdd, DdNode *f, st__table *t)
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
static void zddPrintCoverAux(DdManager *zdd, DdNode *node, int level, int *list)
#define ABC_NAMESPACE_IMPL_END
#define cuddIsConstant(node)
int Cudd_zddNextPath(DdGen *gen, int **path)
st__generator * st__init_gen(st__table *table)
#define ABC_NAMESPACE_IMPL_START
int cuddCollectNodes(DdNode *f, st__table *visited)
static ABC_NAMESPACE_IMPL_START char rcsid[] DD_UNUSED
int Cudd_zddPrintDebug(DdManager *zdd, DdNode *f, int n, int pr)
int st__ptrhash(const char *, int)
int st__gen(st__generator *gen, const char **key_p, char **value_p)
int cuddZddP(DdManager *zdd, DdNode *f)