Biddy  1.8.1
An academic Binary Decision Diagrams package
manual1.c
1 #define UNIX
2 #include "biddy.h"
3 
4 #define Str2Var(x) (Biddy_GetVariable((Biddy_String)x))
5 
6 int main() {
7  Biddy_Edge f,g,h,r;
8 
9  Biddy_Init(); /* use default, i.e. ROBDD WITH COMPLEMENTED EDGES */
10  printf("Biddy is using %s.\n",Biddy_GetManagerName());
11 
12  f = Biddy_Eval1((Biddy_String)"(OR H E L L O)"); /* PREFIX INPUT */
13  g = Biddy_Eval1((Biddy_String)"(AND W O R L D)"); /* PREFIX INPUT */
14  h = Biddy_Eval2((Biddy_String)"~(H * E * L * L)"); /* INFIX INPUT */
15 
16  /* BASIC OPERATION */
17  r = Biddy_Xor(f,g);
18 
19  /* REPLACE SOME VARIABLES */
21  Biddy_SetVariableValue(Str2Var("H"),Biddy_GetVariableEdge(Str2Var("L")));
22  Biddy_SetVariableValue(Str2Var("K"),Biddy_GetVariableEdge(Str2Var("L")));
23  Biddy_SetVariableValue(Str2Var("W"),Biddy_GetVariableEdge(Str2Var("L")));
24  r = Biddy_Replace(r);
25 
26  /* SIMPLE RESTRICTION */
27  r = Biddy_Restrict(r,Str2Var("E"),FALSE);
28 
29  /* COUDERT AND MADRE'S RESTRICT FUNCTION */
30  r = Biddy_Simplify(r,h);
31 
32  /* SOME STATS */
33  printf("Function r depends on %u variables.\n",Biddy_DependentVariableNumber(r,FALSE));
34  printf("Function r has %.0f minterms.\n",Biddy_CountMinterms(r,0));
35  printf("BDD for function r has %u nodes.\n",Biddy_CountNodes(r));
36 
37  /* TRUTH TABLE */
38  printf("Here is a truth table for function r\n");
40 
41  /* GRAPHVIZ/DOT OUTPUT */
42  Biddy_WriteDot("biddy.dot",r,"r",-1,FALSE);
43  printf("USE 'dot -y -Tpng -O biddy.dot' to visualize BDD for function r.\n");
44 
45  Biddy_Exit();
46 }
#define Biddy_ResetVariablesValue()
Definition: biddy.h:462
#define Biddy_Simplify(f, c)
Definition: biddy.h:827
#define Biddy_SetVariableValue(v, f)
Definition: biddy.h:467
#define Biddy_DependentVariableNumber(f, select)
Definition: biddy.h:1077
#define Biddy_PrintfTable(f)
Definition: biddy.h:1178
Biddy_Edge is a marked edge (i.e. a marked pointer to BiddyNode).
#define Biddy_Restrict(f, v, value)
Definition: biddy.h:781
Biddy_String is used for strings.
#define Biddy_Xor(f, g)
Definition: biddy.h:753
#define Biddy_CountMinterms(f, nvars)
Definition: biddy.h:1092
#define Biddy_Exit()
Definition: biddy.h:315
#define Biddy_Eval2(boolFunc)
Definition: biddy.h:1153
File biddy.h contains declaration of all external data structures.
#define Biddy_Init()
Definition: biddy.h:309
#define Biddy_GetVariableEdge(v)
Definition: biddy.h:432
#define Biddy_CountNodes(f)
Definition: biddy.h:897
#define Biddy_WriteDot(filename, f, label, id, cudd)
Definition: biddy.h:1198
#define Biddy_GetManagerName()
Definition: biddy.h:328