89 static char rcsid[]
DD_UNUSED =
"$Id: cuddExport.c,v 1.22 2009/03/08 02:49:02 fabio Exp $";
149 int nvars = dd->
size;
155 if (sorted == NULL) {
159 for (i = 0; i < nvars; i++) sorted[i] = 0;
163 if (support == NULL)
goto failure;
167 sorted[scan->
index] = 1;
175 retval = fprintf(fp,
".model DD\n.inputs");
177 retval = fprintf(fp,
".model %s\n.inputs",mname);
185 for (i = 0; i < nvars; i++) {
187 if (inames == NULL) {
188 retval = fprintf(fp,
" %d", i);
190 retval = fprintf(fp,
" %s", inames[i]);
192 if (retval == EOF)
goto failure;
199 retval = fprintf(fp,
"\n.outputs");
200 if (retval == EOF)
goto failure;
201 for (i = 0; i < n; i++) {
202 if (onames == NULL) {
203 retval = fprintf(fp,
" f%d", i);
205 retval = fprintf(fp,
" %s", onames[i]);
207 if (retval == EOF)
goto failure;
209 retval = fprintf(fp,
"\n");
210 if (retval == EOF)
goto failure;
213 if (retval == 0)
goto failure;
216 retval = fprintf(fp,
".end\n");
217 if (retval == EOF)
goto failure;
222 if (sorted != NULL)
ABC_FREE(sorted);
267 if (visited == NULL)
goto failure;
270 for (i = 0; i < n; i++) {
272 if (retval == 0)
goto failure;
279 for (i = 0; i < n; i++) {
280 if (onames == NULL) {
295 if (retval == EOF)
goto failure;
297 retval = fprintf(fp,
"%s0 1\n", mv ?
".def 0\n" :
"");
299 retval = fprintf(fp,
"%s1 1\n", mv ?
".def 0\n" :
"");
301 if (retval == EOF)
goto failure;
355 int nvars = dd->
size;
362 long refAddr, diff, mask;
366 if (sorted == NULL) {
370 for (i = 0; i < nvars; i++) sorted[i] = 0;
374 if (support == NULL)
goto failure;
378 sorted[scan->
index] = 1;
386 if (visited == NULL)
goto failure;
389 for (i = 0; i < n; i++) {
391 if (retval == 0)
goto failure;
409 if (gen == NULL)
goto failure;
410 while (
st__gen(gen, (
const char **)&scan, NULL)) {
411 diff |= refAddr ^ (long) scan;
416 for (i = 0; (unsigned) i < 8 *
sizeof(
long); i += 4) {
418 if (diff <= mask)
break;
422 retval = fprintf(fp,
"digraph \"DD\" {\n");
423 if (retval == EOF)
return(0);
425 "size = \"7.5,10\"\ncenter = true;\nedge [dir = none];\n");
426 if (retval == EOF)
return(0);
429 retval = fprintf(fp,
"{ node [shape = plaintext];\n");
430 if (retval == EOF)
goto failure;
431 retval = fprintf(fp,
" edge [style = invis];\n");
432 if (retval == EOF)
goto failure;
436 retval = fprintf(fp,
" \"CONST NODES\" [style = invis];\n");
437 if (retval == EOF)
goto failure;
438 for (i = 0; i < nvars; i++) {
440 if (inames == NULL || inames[dd->
invperm[i]] == NULL) {
441 retval = fprintf(fp,
"\" %d \" -> ", dd->
invperm[i]);
443 retval = fprintf(fp,
"\" %s \" -> ", inames[dd->
invperm[i]]);
445 if (retval == EOF)
goto failure;
448 retval = fprintf(fp,
"\"CONST NODES\"; \n}\n");
449 if (retval == EOF)
goto failure;
452 retval = fprintf(fp,
"{ rank = same; node [shape = box]; edge [style = invis];\n");
453 if (retval == EOF)
goto failure;
454 for (i = 0; i < n; i++) {
455 if (onames == NULL) {
456 retval = fprintf(fp,
"\"F%d\"", i);
458 retval = fprintf(fp,
"\" %s \"", onames[i]);
460 if (retval == EOF)
goto failure;
462 retval = fprintf(fp,
"; }\n");
464 retval = fprintf(fp,
" -> ");
466 if (retval == EOF)
goto failure;
470 for (i = 0; i < nvars; i++) {
472 retval = fprintf(fp,
"{ rank = same; ");
473 if (retval == EOF)
goto failure;
474 if (inames == NULL || inames[dd->
invperm[i]] == NULL) {
475 retval = fprintf(fp,
"\" %d \";\n", dd->
invperm[i]);
477 retval = fprintf(fp,
"\" %s \";\n", inames[dd->
invperm[i]]);
479 if (retval == EOF)
goto failure;
482 for (j = 0; j < slots; j++) {
484 while (scan != NULL) {
486 retval = fprintf(fp,
"\"%lx\";\n", ((mask & (
ptrint) scan) /
sizeof(
DdNode)));
487 if (retval == EOF)
goto failure;
492 retval = fprintf(fp,
"}\n");
493 if (retval == EOF)
goto failure;
499 "{ rank = same; \"CONST NODES\";\n{ node [shape = box]; ");
500 if (retval == EOF)
goto failure;
503 for (j = 0; j < slots; j++) {
505 while (scan != NULL) {
507 retval = fprintf(fp,
"\"%lx\";\n", ((mask & (
ptrint) scan) /
sizeof(
DdNode)));
508 if (retval == EOF)
goto failure;
513 retval = fprintf(fp,
"}\n}\n");
514 if (retval == EOF)
goto failure;
518 for (i = 0; i < n; i++) {
519 if (onames == NULL) {
520 retval = fprintf(fp,
"\"F%d\"", i);
522 retval = fprintf(fp,
"\" %s \"", onames[i]);
524 if (retval == EOF)
goto failure;
527 retval = fprintf(fp,
" -> \"%lx\" [style = dotted];\n", ((mask & (
ptrint) f[i]) /
sizeof(
DdNode)));
529 retval = fprintf(fp,
" -> \"%lx\" [style = solid];\n", ((mask & (
ptrint) f[i]) /
sizeof(
DdNode)));
531 if (retval == EOF)
goto failure;
535 for (i = 0; i < nvars; i++) {
539 for (j = 0; j < slots; j++) {
541 while (scan != NULL) {
543 retval = fprintf(fp,
"\"%lx\" -> \"%lx\";\n",
546 if (retval == EOF)
goto failure;
548 retval = fprintf(fp,
"\"%lx\" -> \"%lx\" [style = dotted];\n",
552 retval = fprintf(fp,
"\"%lx\" -> \"%lx\" [style = dashed];\n",
556 if (retval == EOF)
goto failure;
567 for (j = 0; j < slots; j++) {
569 while (scan != NULL) {
571 retval = fprintf(fp,
"\"%lx\" [label = \"%g\"];\n",
573 if (retval == EOF)
goto failure;
580 retval = fprintf(fp,
"}\n");
581 if (retval == EOF)
goto failure;
588 if (sorted != NULL)
ABC_FREE(sorted);
633 if (visited == NULL)
goto failure;
636 for (i = 0; i < n; i++) {
638 if (retval == 0)
goto failure;
656 while (
st__gen(gen, (
const char **)&scan, NULL)) {
657 diff |= refAddr ^ (
ptruint) scan;
662 for (i = 0; (unsigned) i < 8 *
sizeof(
ptruint); i += 4) {
664 if (diff <= mask)
break;
670 if (visited == NULL)
goto failure;
672 retval = fprintf(fp,
"[");
673 if (retval == EOF)
goto failure;
675 for (i = 0; i < n; i++) {
676 if (onames == NULL) {
678 "l(\"f%d\",n(\"root\",[a(\"OBJECT\",\"f%d\")],",
682 "l(\"%s\",n(\"root\",[a(\"OBJECT\",\"%s\")],",
683 onames[i], onames[i]);
685 if (retval == EOF)
goto failure;
686 retval = fprintf(fp,
"[e(\"edge\",[a(\"EDGECOLOR\",\"%s\"),a(\"_DIR\",\"none\")],",
688 if (retval == EOF)
goto failure;
690 if (retval == 0)
goto failure;
691 retval = fprintf(fp,
")]))%s", i == n-1 ?
"" :
",");
692 if (retval == EOF)
goto failure;
696 retval = fprintf(fp,
"]\n");
697 if (retval == EOF)
goto failure;
740 int nvars = dd->
size;
749 if (visited == NULL)
goto failure;
752 for (i = 0; i < n; i++) {
754 if (retval == 0)
goto failure;
772 while (
st__gen(gen, (
const char **)&scan, NULL)) {
773 diff |= refAddr ^ (
ptruint) scan;
778 for (i = 0; (unsigned) i < 8 *
sizeof(
ptruint); i += 4) {
780 if (diff <= mask)
break;
787 if (sorted == NULL) {
791 for (i = 0; i < nvars; i++) sorted[i] = 0;
795 if (support == NULL)
goto failure;
799 sorted[scan->
index] = 1;
804 for (i = 0; i < nvars; i++) {
806 if (inames == NULL || inames[dd->
invperm[i]] == NULL) {
807 retval = fprintf(fp,
"v%d", dd->
invperm[i]);
809 retval = fprintf(fp,
"%s", inames[dd->
invperm[i]]);
811 if (retval == EOF)
goto failure;
813 retval = fprintf(fp,
"%s", i == nvars - 1 ?
"\n" :
" * ");
814 if (retval == EOF)
goto failure;
821 if (visited == NULL)
goto failure;
824 for (i = 0; i < n; i++) {
826 if (retval == 0)
goto failure;
827 if (onames == NULL) {
828 retval = fprintf(fp,
"f%d = ", i);
830 retval = fprintf(fp,
"%s = ", onames[i]);
832 if (retval == EOF)
goto failure;
833 retval = fprintf(fp,
"n%p%s\n",
834 (
void *) (((
ptruint) f[i] & mask) /
837 if (retval == EOF)
goto failure;
841 retval = fprintf(fp,
"[");
842 if (retval == EOF)
goto failure;
843 for (i = 0; i < n; i++) {
844 if (onames == NULL) {
845 retval = fprintf(fp,
"f%d", i);
847 retval = fprintf(fp,
"%s", onames[i]);
849 retval = fprintf(fp,
"%s", i == n-1 ?
"" :
" ");
850 if (retval == EOF)
goto failure;
852 retval = fprintf(fp,
"]\n");
853 if (retval == EOF)
goto failure;
860 if (sorted != NULL)
ABC_FREE(sorted);
901 for (i = 0; i < n; i++) {
902 if (onames == NULL) {
903 retval = fprintf(fp,
"f%d = ", i);
905 retval = fprintf(fp,
"%s = ", onames[i]);
907 if (retval == EOF)
return(0);
909 retval = fprintf(fp,
"CONST1");
910 if (retval == EOF)
return(0);
912 retval = fprintf(fp,
"CONST0");
913 if (retval == EOF)
return(0);
916 if (retval == EOF)
return(0);
918 if (retval == 0)
return(0);
920 if (retval == EOF)
return(0);
922 retval = fprintf(fp,
"%s", i == n-1 ?
"" :
"\n");
923 if (retval == EOF)
return(0);
985 #if SIZEOF_VOID_P == 8
1001 #if SIZEOF_VOID_P == 8
1002 retval = fprintf(fp,
".names %lx\n%s",
1006 retval = fprintf(fp,
".names %x\n%s",
1010 if (retval == EOF) {
1022 if (retval != 1)
return(retval);
1025 if (retval != 1)
return(retval);
1028 if (names != NULL) {
1029 retval = fprintf(fp,
".names %s", names[f->
index]);
1031 #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
1032 retval = fprintf(fp,
".names %u", f->
index);
1034 retval = fprintf(fp,
".names %hu", f->
index);
1040 #if SIZEOF_VOID_P == 8
1043 retval = fprintf(fp,
" %lx %lx %lx\n.def 0\n1 1 - 1\n0 - 0 1\n",
1048 retval = fprintf(fp,
" %lx %lx %lx\n.def 0\n1 1 - 1\n0 - 1 1\n",
1055 retval = fprintf(fp,
" %lx %lx %lx\n11- 1\n0-0 1\n",
1060 retval = fprintf(fp,
" %lx %lx %lx\n11- 1\n0-1 1\n",
1069 retval = fprintf(fp,
" %x %x %x\n.def 0\n1 1 - 1\n0 - 0 1\n",
1074 retval = fprintf(fp,
" %x %x %x\n.def 0\n1 1 - 1\n0 - 1 1\n",
1081 retval = fprintf(fp,
" %x %x %x\n11- 1\n0-0 1\n",
1086 retval = fprintf(fp,
" %x %x %x\n11- 1\n0-1 1\n",
1093 if (retval == EOF) {
1137 retval = fprintf(fp,
"r(\"%p\")", (
void *)
id);
1138 if (retval == EOF) {
1155 retval = fprintf(fp,
1156 "l(\"%p\",n(\"constant\",[a(\"OBJECT\",\"%g\")],[]))",
1157 (
void *)
id,
cuddV(f));
1158 if (retval == EOF) {
1166 if (names != NULL) {
1167 retval = fprintf(fp,
1168 "l(\"%p\",n(\"internal\",[a(\"OBJECT\",\"%s\"),",
1169 (
void *)
id, names[f->
index]);
1171 retval = fprintf(fp,
1173 "l(\"%p\",n(\"internal\",[a(\"OBJECT\",\"%u\"),",
1175 "l(\"%p\",n(\"internal\",[a(\"OBJECT\",\"%hu\"),",
1177 (
void *)
id, f->
index);
1179 retval = fprintf(fp,
"a(\"_GO\",\"ellipse\")],[e(\"then\",[a(\"EDGECOLOR\",\"blue\"),a(\"_DIR\",\"none\")],");
1180 if (retval == EOF)
return(0);
1183 if (retval != 1)
return(retval);
1184 retval = fprintf(fp,
"),e(\"else\",[a(\"EDGECOLOR\",\"%s\"),a(\"_DIR\",\"none\")],",
1186 if (retval == EOF)
return(0);
1189 if (retval != 1)
return(retval);
1191 retval = fprintf(fp,
")]))");
1192 if (retval == EOF) {
1251 retval = fprintf(fp,
"n%p = %g\n", (
void *)
id,
cuddV(f));
1252 if (retval == EOF) {
1262 if (retval != 1)
return(retval);
1265 if (retval != 1)
return(retval);
1268 if (names != NULL) {
1269 retval = fprintf(fp,
"n%p = %s * n%p + %s' * n%p%s\n",
1270 (
void *)
id, names[f->
index],
1271 (
void *) idT, names[f->
index],
1274 #if SIZEOF_VOID_P == 8
1275 retval = fprintf(fp,
"n%p = v%u * n%p + v%u' * n%p%s\n",
1277 retval = fprintf(fp,
"n%p = v%hu * n%p + v%hu' * n%p%s\n",
1279 (
void *)
id, f->
index,
1280 (
void *) idT, f->
index,
1283 if (retval == EOF) {
1333 if (names != NULL) {
1334 retval = fprintf(fp,
"%s", names[f->
index]);
1336 #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
1337 retval = fprintf(fp,
"x%u", f->
index);
1339 retval = fprintf(fp,
"x%hu", f->
index);
1342 if (retval == EOF)
return(0);
1345 retval = fprintf(fp,
"%s(", E !=
DD_ONE(dd) ?
" * " :
"");
1346 if (retval == EOF)
return(0);
1348 if (retval != 1)
return(retval);
1349 retval = fprintf(fp,
")");
1350 if (retval == EOF)
return(0);
1353 retval = fprintf(fp,
" + ");
1354 if (retval == EOF)
return(0);
1358 if (names != NULL) {
1359 retval = fprintf(fp,
"!%s", names[f->
index]);
1361 #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
1362 retval = fprintf(fp,
"!x%u", f->
index);
1364 retval = fprintf(fp,
"!x%hu", f->
index);
1367 if (retval == EOF)
return(0);
1370 retval = fprintf(fp,
"%s%s(", T !=
DD_ONE(dd) ?
" * " :
"",
1371 E !=
cuddE(f) ?
"!" :
"");
1372 if (retval == EOF)
return(0);
1374 if (retval != 1)
return(retval);
1375 retval = fprintf(fp,
")");
1376 if (retval == EOF)
return(0);
static int ddDoDumpDaVinci(DdManager *dd, DdNode *f, FILE *fp, st__table *visited, char **names, ptruint mask)
static int ddDoDumpFactoredForm(DdManager *dd, DdNode *f, FILE *fp, char **names)
void st__free_table(st__table *table)
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
void st__free_gen(st__generator *gen)
int st__insert(st__table *table, const char *key, char *value)
int Cudd_DumpDot(DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp)
#define Cudd_IsConstant(node)
#define Cudd_Regular(node)
int Cudd_DumpBlifBody(DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp, int mv)
int st__ptrcmp(const char *, const char *)
int Cudd_DumpBlif(DdManager *dd, int n, DdNode **f, char **inames, char **onames, char *mname, FILE *fp, int mv)
#define ABC_ALLOC(type, num)
#define st__is_member(table, key)
static int ddDoDumpBlif(DdManager *dd, DdNode *f, FILE *fp, st__table *visited, char **names, int mv)
static const char * onames[]
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
#define Cudd_IsComplement(node)
#define ABC_NAMESPACE_IMPL_END
#define cuddIsConstant(node)
int Cudd_DumpDaVinci(DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp)
st__generator * st__init_gen(st__table *table)
#define ABC_NAMESPACE_IMPL_START
int Cudd_DumpDDcal(DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp)
static int ddDoDumpDDcal(DdManager *dd, DdNode *f, FILE *fp, st__table *visited, char **names, ptruint mask)
int cuddCollectNodes(DdNode *f, st__table *visited)
int Cudd_DumpFactoredForm(DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp)
int st__ptrhash(const char *, int)
int st__gen(st__generator *gen, const char **key_p, char **value_p)
DdNode * Cudd_VectorSupport(DdManager *dd, DdNode **F, int n)
static ABC_NAMESPACE_IMPL_START char rcsid[] DD_UNUSED