Professional Documents
Culture Documents
12 1 BooleanFunctions 2
12 1 BooleanFunctions 2
Todays Lecture
Boolean algebra basics
Binary Decision Diagrams
Representation, size
Building BDDs
S. Seshia
Recap
What is a
Literal?
Cube?
Minterm?
S. Seshia
Boolean function
A Boolean function F of n variables x1, x2, , xn
F : {0,1}n {0,1}
Mapped to 0
S. Seshia
Mapped to 1
Cofactors
A Boolean function F of n variables x1, x2, , xn
F : {0,1}n {0,1}
Suppose we define new Boolean functions of n-1
variables as follows:
Fx (x2, , xn) = F(1, x2, x3, , xn)
1
Fx1 (x2, , xn) = F(0, x2, x3, , xn)
Fx1 and Fx1 are cofactors of F.
What does their input state space look like?
S. Seshia
Examples of Cofactors
F(x, y, z) = xy + xz + y(xz + z)
Whats Fx ?
Fx ?
y + z + yz
yz + yz
S. Seshia
S. Seshia
Shannon Expansion
F(x1, , xn) = xi . Fxi + xi . Fxi
Proof?
S. Seshia
S. Seshia
Properties of Cofactors
Suppose you construct a new function H from
two existing functions F and G: e.g.,
H = F
H = F.G
H=F+G
Etc.
S. Seshia
10
11
S. Seshia
S. Seshia
12
13
S. Seshia
14
Ordering
15
S. Seshia
Reduction
Identify Redundancies
3 Rules:
1. Merge equivalent leaves
2. Merge isomorphic nodes
3. Eliminate redundant tests
S. Seshia
16
S. Seshia
17
S. Seshia
18
S. Seshia
19
Example
S. Seshia
20
10
Example
S. Seshia
21
S. Seshia
22
11
Example of Rule 3
23
S. Seshia
a
b
ordering
abcd
0
0
S. Seshia
c
d
1
1
1
24
12
25
S. Seshia
S. Seshia
26
13
Sensitivity to Ordering
Given a function with n inputs, one input
ordering may require exponential # vertices
in ROBDD, while other may be linear in size.
f = x1 x2 + x3 x4 + x5 x6
x1 < x2 < x3 < x4 < x5 < x6
1
2
5
4
2
3
6
1
5
2
3
6
1
27
S. Seshia
S. Seshia
MUX
28
14
ROBDD Construction
Given ordering and multilevel network.
ROBDD of a b
a
b
ab+c
c
d
a
1
S. Seshia
Advantage of 2:
Less programming work
Easier to add new operators later by writing wrappers
S. Seshia
30
15
Core Operators
Just two of them!
1. Restrict(Function F, variable v, constant k)
if-then-else operator
31
S. Seshia
ITE
Just like:
if then else in a programming language
A mux in hardware
T(x)
E(x)
I(x)
S. Seshia
32
16
33
S. Seshia
S. Seshia
34
17
35
S. Seshia
ITE Algorithm
ITE (bdd I, bdd T, bdd E) {
if (terminal case) { return computed result; }
else { // general case
Let x be the topmost variable of I, T, E;
PosFactor = ITE(Ix , Tx , Ex) ;
NegFactor = ITE(Ix , Tx , Ex);
R = new node labeled by x;
R.low = NegFactor;
R.high = PosFactor;
Reduce(R);
return R;
}
S. Seshia
36
18
Terminal Cases
ITE(1, T, E) =
ITE(0, T, E) =
ITE(I, T, T) =
ITE(I, 1, 0) =
37
S. Seshia
General Case
Still need to do cofactor (Restrict)
How hard is that?
Which variable are we cofactoring out? (2 cases)
S. Seshia
38
19
R.high = PosFactor;
Reduce(R);
return R;
}
39
S. Seshia
Practical Issues
Previous calls to ITE are cached
memoization
S. Seshia
40
20
41
S. Seshia
S. Seshia
42
21
RTL
Synthesis
netlist
Step 1:
(formally)
translate
HDL
source
into
netlist
Step 2:
Perform
gates-to-gates
verification
gate-level
implementation
Combinational
logic
Combinational
logic
clk
clk
clk
clk
43
S. Seshia
RTL
Synthesis
netlist
HDL
implementation
Step 1:
(formally)
translate
both HDL
sources
into
netlists
Step 2:
perform
gate-togate
verification
on netlists
S. Seshia
netlist
Combinational
logic
Combinational
logic
clk
RTL
Synthesis
clk
clk
clk
44
22
S. Seshia
45
23