-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
85 lines (69 loc) · 1.56 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <stdlib.h>
//#include "argtable2.h"
#include "bddObj.h"
/* NOTE: the last 2 parameters are optional
*/
extern void
bddToDot(bddMgr& mgr,
BDD f,
int num_vars,
FILE* fp_dot,
int debug = 0,
int verbose = 0);
/* The gVerbose and gDebug globals are used to toggle verbose and debug
* output. This standard is followed in all projects for cs486.
*/
int gVerbose = 0, gDebug = 0;
/* This is a simple test function. Please feel free to change it to
* meet your needs.
*/
void test_BDD(FILE *fp_dot)
{
bddMgr mgr (0, 0);
BDD a = mgr.bddVar();
BDD b = mgr.bddVar();
BDD ap = mgr.bddVar();
BDD bp = mgr.bddVar();
BDD c = mgr.bddVar();
BDD cp = mgr.bddVar();
BDD d = mgr.bddVar();
BDD dp = mgr.bddVar();
BDD r = (~a & ~b & ap & bp) | (a & b & ~ap & ~bp) | (a & b & ap & ~bp) |
(a & ~b & ap & ~bp);
BDD l = (~ap & ~bp) | (ap & ~bp);
BDD s = (~a & ~b & ap & bp) | (a & b & ~ap & ~bp) | (c & d & dp & ap) | (d & ~c & ap & ~bp);
BDD t = a & b & c & d;
if (fp_dot)
{
bddToDot(mgr, t, 8, fp_dot, gDebug, gVerbose);
}
}
/* See:
*
* http://students.cs.byu.edu/~cs486ta/handouts/f04/bdd-package.html
*
* For detailed instructions.
*/
int
main(int argc, char* argv[])
{
FILE *fp_dot = NULL;
gVerbose = 1;
gDebug = 1;
if (argc > 1)
{
if (gVerbose)
{
printf("Enabling dump dot\n");
}
fp_dot = fopen(argv[1], "w");
if (!fp_dot)
{
printf("ERROR: failed to open %s for writing\n", argv[1]);
}
}
test_BDD(fp_dot);
if (fp_dot)
fclose(fp_dot);
return 0;
}