82 #define SINGLE_VERTICAL (char)'|'
83 #define SINGLE_HORIZONTAL (char)'-'
84 #define SINGLE_TOP_LEFT (char)'+'
85 #define SINGLE_TOP_RIGHT (char)'+'
86 #define SINGLE_BOT_LEFT (char)'+'
87 #define SINGLE_BOT_RIGHT (char)'+'
90 #define DOUBLE_VERTICAL (char)'|'
91 #define DOUBLE_HORIZONTAL (char)'-'
92 #define DOUBLE_TOP_LEFT (char)'+'
93 #define DOUBLE_TOP_RIGHT (char)'+'
94 #define DOUBLE_BOT_LEFT (char)'+'
95 #define DOUBLE_BOT_RIGHT (char)'+'
98 #define SINGLES_CROSS (char)'+'
99 #define DOUBLES_CROSS (char)'+'
100 #define S_HOR_CROSS_D_VER (char)'+'
101 #define S_VER_CROSS_D_HOR (char)'+'
104 #define S_JOINS_S_VER_LEFT (char)'+'
105 #define S_JOINS_S_VER_RIGHT (char)'+'
106 #define S_JOINS_S_HOR_TOP (char)'+'
107 #define S_JOINS_S_HOR_BOT (char)'+'
110 #define D_JOINS_D_VER_LEFT (char)'+'
111 #define D_JOINS_D_VER_RIGHT (char)'+'
112 #define D_JOINS_D_HOR_TOP (char)'+'
113 #define D_JOINS_D_HOR_BOT (char)'+'
116 #define S_JOINS_D_VER_LEFT (char)'+'
117 #define S_JOINS_D_VER_RIGHT (char)'+'
118 #define S_JOINS_D_HOR_TOP (char)'+'
119 #define S_JOINS_D_HOR_BOT (char)'+'
123 #define UNDERSCORE (char)95
127 #define SYMBOL_ZERO (char)'0'
129 #define SYMBOL_ZERO (char)' '
131 #define SYMBOL_ONE (char)'1'
132 #define SYMBOL_DC (char)'-'
133 #define SYMBOL_OVERLAP (char)'?'
136 #define CELL_FREE (char)32
137 #define CELL_FULL (char)219
138 #define HALF_UPPER (char)223
139 #define HALF_LOWER (char)220
140 #define HALF_LEFT (char)221
141 #define HALF_RIGHT (char)222
212 int d,
p, n, s, v, h, w;
222 fprintf( Output,
"PrintKMap(): The on-set and the off-set overlap\n" );
232 printf(
"Truth table: " );
234 printf(
"Constant" );
235 else if ( nVars == 1 )
236 printf(
"1-var function" );
240 for ( d = (1<<(nVars-2)) - 1; d >= 0; d-- )
243 for ( s = 0; s < 4; s++ )
247 Value |= ((int)(bPart ==
b1) << s);
252 fprintf( stdout,
"%d", Value );
254 fprintf( stdout,
"%c",
'a' + Value-10 );
273 if ( nVars < 0 || nVars >
MAXVARS )
275 fprintf( Output,
"PrintKMap(): The number of variables is less than zero or more than %d\n", MAXVARS );
282 if ( fSuppType == 0 )
285 for ( v = 0; v < nVars; v++ )
288 else if ( fSuppType == 1 )
291 for ( v = 0; v < nVars; v++ )
296 DdNode * SuppOn, * SuppOff, * Supp;
308 if ( nVars > MAXVARS )
310 fprintf( Output,
"PrintKMap(): The number of variables is more than %d\n", MAXVARS );
316 for ( TempSupp = Supp; TempSupp != dd->
one; TempSupp =
Cudd_T(TempSupp), cVars++ )
326 for ( v = 0; v < nVars; v++ )
327 s_XVars[v] = XVars[v];
333 nVarsHor = nVars - nVarsVer;
335 nCellsVer = (1<<nVarsVer);
336 nCellsHor = (1<<nVarsHor);
337 nSkipSpaces = nVarsVer + 1;
341 fprintf( Output,
"\n" );
342 for ( w = 0; w < nVarsVer; w++ )
343 if ( pVarNames == NULL )
344 fprintf( Output,
"%c",
'a'+nVarsHor+w );
346 fprintf( Output,
" %s", pVarNames[nVarsHor+w] );
350 fprintf( Output,
" \\ " );
351 for ( w = 0; w < nVarsHor; w++ )
352 if ( pVarNames == NULL )
353 fprintf( Output,
"%c",
'a'+w );
355 fprintf( Output,
"%s ", pVarNames[w] );
357 fprintf( Output,
"\n" );
363 for ( d = 0; d < nVarsHor; d++ )
365 for ( p = 0; p < nSkipSpaces + 2; p++, fprintf( Output,
" " ) );
366 for ( n = 0; n < nCellsHor; n++ )
367 if (
GrayCode(n) & (1<<(nVarsHor-1-d)) )
368 fprintf( Output,
"1 " );
370 fprintf( Output,
"0 " );
371 fprintf( Output,
"\n" );
377 for ( p = 0; p < nSkipSpaces; p++, fprintf( Output,
" " ) );
379 for ( s = 0; s < nCellsHor; s++ )
384 if ( s != nCellsHor-1 )
393 fprintf( Output,
"\n" );
397 for ( v = 0; v < nCellsVer; v++ )
403 for ( n = 0; n < nVarsVer; n++ )
404 if (
GrayCode(v) & (1<<(nVarsVer-1-n)) )
405 fprintf( Output,
"1" );
407 fprintf( Output,
"0" );
408 fprintf( Output,
" " );
415 for ( h = 0; h < nCellsHor; h++ )
417 DdNode * CubeHorBDD, * Prod, * ValueOnSet, * ValueOffSet;
419 fprintf( Output,
" " );
433 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
434 char Symb = 0, Color = 0;
435 if ( ValueOnSet ==
b1 && ValueOffSet ==
b0 )
437 else if ( ValueOnSet ==
b0 && ValueOffSet ==
b1 )
439 else if ( ValueOnSet ==
b0 && ValueOffSet ==
b0 )
441 else if ( ValueOnSet ==
b1 && ValueOffSet ==
b1 )
445 SetConsoleTextAttribute( hConsole, Color );
446 fprintf( Output,
"%c", Symb );
447 SetConsoleTextAttribute( hConsole, 7 );
451 if ( ValueOnSet ==
b1 && ValueOffSet ==
b0 )
453 else if ( ValueOnSet ==
b0 && ValueOffSet ==
b1 )
455 else if ( ValueOnSet ==
b0 && ValueOffSet ==
b0 )
457 else if ( ValueOnSet ==
b1 && ValueOffSet ==
b1 )
467 fprintf( Output,
" " );
469 if ( h != nCellsHor-1 )
478 fprintf( Output,
"\n" );
482 if ( v != nCellsVer-1 )
485 for ( p = 0; p < nSkipSpaces; p++, fprintf( Output,
" " ) );
489 for ( s = 0; s < nCellsHor; s++ )
494 if ( s != nCellsHor-1 )
507 for ( s = 0; s < nCellsHor; s++ )
512 if ( s != nCellsHor-1 )
522 fprintf( Output,
"\n" );
528 for ( p = 0; p < nSkipSpaces; p++, fprintf( Output,
" " ) );
530 for ( s = 0; s < nCellsHor; s++ )
535 if ( s != nCellsHor-1 )
544 fprintf( Output,
"\n" );
550 for ( d = 0; d < nVarsHor; d++ )
552 for ( p = 0; p < nSkipSpaces + 2; p++, fprintf( Output,
" " ) );
553 for ( n = 0; n < nCellsHor; n++ )
554 if (
GrayCode(n) & (1<<(nVarsHor-1-d)) )
555 fprintf( Output,
"1 " );
557 fprintf( Output,
"0 " );
560 fprintf( Output,
"%c", (
char)(
'a'+d) );
562 fprintf( Output,
"\n" );
591 int d,
p, n, s, v, h, w;
602 fprintf( Output,
"PrintKMap(): The on-set and the off-set overlap\n" );
608 fprintf( Output,
"PrintKMap(): Constant 1\n" );
613 fprintf( Output,
"PrintKMap(): Constant 0\n" );
617 nVars = nXVars + nYVars;
618 if ( nVars < 0 || nVars >
MAXVARS )
620 fprintf( Output,
"PrintKMap(): The number of variables is less than zero or more than %d\n", MAXVARS );
629 nCellsVer = (1<<nVarsVer);
630 nCellsHor = (1<<nVarsHor);
631 nSkipSpaces = nVarsVer + 1;
635 fprintf( Output,
"\n" );
636 for ( w = 0; w < nVarsVer; w++ )
637 fprintf( Output,
"%c",
'a'+nVarsHor+w );
640 fprintf( Output,
" \\ " );
641 for ( w = 0; w < nVarsHor; w++ )
642 fprintf( Output,
"%c",
'a'+w );
644 fprintf( Output,
"\n" );
650 for ( d = 0; d < nVarsHor; d++ )
652 for ( p = 0; p < nSkipSpaces + 2; p++, fprintf( Output,
" " ) );
653 for ( n = 0; n < nCellsHor; n++ )
654 if (
GrayCode(n) & (1<<(nVarsHor-1-d)) )
655 fprintf( Output,
"1 " );
657 fprintf( Output,
"0 " );
658 fprintf( Output,
"\n" );
664 for ( p = 0; p < nSkipSpaces; p++, fprintf( Output,
" " ) );
666 for ( s = 0; s < nCellsHor; s++ )
671 if ( s != nCellsHor-1 )
680 fprintf( Output,
"\n" );
684 for ( v = 0; v < nCellsVer; v++ )
690 for ( n = 0; n < nVarsVer; n++ )
691 if (
GrayCode(v) & (1<<(nVarsVer-1-n)) )
692 fprintf( Output,
"1" );
694 fprintf( Output,
"0" );
695 fprintf( Output,
" " );
703 for ( h = 0; h < nCellsHor; h++ )
705 DdNode * CubeHorBDD, * Prod, * ValueOnSet, * ValueOffSet;
707 fprintf( Output,
" " );
720 if ( ValueOnSet ==
b1 && ValueOffSet ==
b0 )
722 else if ( ValueOnSet ==
b0 && ValueOffSet ==
b1 )
724 else if ( ValueOnSet ==
b0 && ValueOffSet ==
b0 )
726 else if ( ValueOnSet ==
b1 && ValueOffSet ==
b1 )
734 fprintf( Output,
" " );
736 if ( h != nCellsHor-1 )
745 fprintf( Output,
"\n" );
749 if ( v != nCellsVer-1 )
752 for ( p = 0; p < nSkipSpaces; p++, fprintf( Output,
" " ) );
756 for ( s = 0; s < nCellsHor; s++ )
761 if ( s != nCellsHor-1 )
774 for ( s = 0; s < nCellsHor; s++ )
779 if ( s != nCellsHor-1 )
789 fprintf( Output,
"\n" );
795 for ( p = 0; p < nSkipSpaces; p++, fprintf( Output,
" " ) );
797 for ( s = 0; s < nCellsHor; s++ )
802 if ( s != nCellsHor-1 )
811 fprintf( Output,
"\n" );
817 for ( d = 0; d < nVarsHor; d++ )
819 for ( p = 0; p < nSkipSpaces + 2; p++, fprintf( Output,
" " ) );
820 for ( n = 0; n < nCellsHor; n++ )
821 if (
GrayCode(n) & (1<<(nVarsHor-1-d)) )
822 fprintf( Output,
"1 " );
824 fprintf( Output,
"0 " );
827 fprintf( Output,
"%c", (
char)(
'a'+d) );
829 fprintf( Output,
"\n" );
853 return BinCode ^ ( BinCode >> 1 );
870 while( GrayCode >>= 1 ) bc ^=
GrayCode;
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
DdNode * Cudd_Support(DdManager *dd, DdNode *f)
#define Cudd_IsComplement(node)
DdNode * Cudd_Cofactor(DdManager *dd, DdNode *f, DdNode *g)
#define ABC_NAMESPACE_IMPL_END
#define ABC_NAMESPACE_IMPL_START
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
int Cudd_SupportSize(DdManager *dd, DdNode *f)