0% found this document useful (0 votes)
89 views12 pages

Binary Decision Diagrams (BDDS) : Ece 474A/57A Computer-Aided Logic Design

The document discusses Binary Decision Diagrams (BDDs), which provide an efficient way to represent large Boolean functions. BDDs use a graph structure similar to a binary tree to represent a function, with internal nodes corresponding to variables and terminal nodes representing the function values of 1 and 0. For a function to be represented canonically with a BDD, the variable ordering must be followed in all paths and there can be no isomorphic subgraphs. A function's BDD is built recursively using Shannon expansion with respect to the variable ordering.

Uploaded by

shankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views12 pages

Binary Decision Diagrams (BDDS) : Ece 474A/57A Computer-Aided Logic Design

The document discusses Binary Decision Diagrams (BDDs), which provide an efficient way to represent large Boolean functions. BDDs use a graph structure similar to a binary tree to represent a function, with internal nodes corresponding to variables and terminal nodes representing the function values of 1 and 0. For a function to be represented canonically with a BDD, the variable ordering must be followed in all paths and there can be no isomorphic subgraphs. A function's BDD is built recursively using Shannon expansion with respect to the variable ordering.

Uploaded by

shankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

ECE 474A/57A

Computer-Aided Logic Design

Lecture 11
Binary Decision Diagrams (BDDs)

ECE 474a/575a
Susan Lysecky

1 of 31

Boolean Logic Functions Representations

Function can be represented in different ways


Truth table, equation, K-map, circuit, etc
Some representations not unique (not canonical)
F

Equation 1: F(a,b) = ab + ab
a

Equation 2: F(a,b) = a

b
F

Circuit 1
a

Truth table

The function F

F
Circuit 2

ECE 474a/575a
Susan Lysecky

2 of 31

Why BDDs
An Efficient Representation

Synthesis, optimization, verification, and testing algorithms/tools manipulate


large Boolean functions
Important to have efficient way to represent these functions
Binary Decision Diagrams (BDDs) have emerged as a popular choice for representing
these functions

BDDs
Graph representation similar to a binary tree (i.e. decision trees from previous
lectures)
Able to efficiently represent large functions
Some representations are canonical (unique)

ECE 474a/575a
Susan Lysecky

3 of 31

Mux Representation of Boolean Functions


MUX circuit to implement logic
function S

0
x1

x2

x3

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

1
0
1
1
1
1
0
0

X3 (1)

0 1

x3

MUX

0 1

x2

0 1

MUX

MUX

0 1

x1

MUX

S(x1, x2, x3)

0 1

X3 (0)

x2 (0)

MUX

X3 (0)

MUX

x2 (1)

MUX

X1 (0)

0 1

X3 (1)

MUX

MUX

0
1

MUX

x2 (1)

MUX

X1 (1)

MUX

MUX

0 1

MUX

MUX

X1 (0)

MUX

S(1, 1, 1) = 0

MUX

x2 (0)

MUX

0 1

X1 (0)

MUX

S(0, 0, 0) = 1

1
0

MUX

S(0, 1, 0) = 1

S(0, 0, 1) = 0

ECE 474a/575a
Susan Lysecky

4 of 31

Mux Representation of Boolean Functions


Relation to BDDs

Corresponding BDD to implement function S

One-to-one correspondence to the MUX gates in


the flipped circuit

x1

x2

x3

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

1
0
1
1
1
1
0
0

S(x1, x2, x3)


1

S(x1, x2, x3)

0 1

x3

1
x2

x1

MUX

x1

MUX

0 1

0 1

0 1

MUX

MUX

MUX

x2

x2

x2

MUX

0 1

0 1

x3
0 1

x1

MUX

x3

MUX

0 1
1

S(x1, x2, x3)

Same circuit, just


flipped

ECE 474a/575a
Susan Lysecky

Corresponding BDD

5 of 31

Binary Decision Diagram (BDD)


Example 1

How does it work?

S(x1, x2, x3)

Line with bubble represent value = 0


Lines without bubble represent value = 1

x1

x2

x2

x3

x2

S(0, 0, 0)

S(1, 1, 1)

S(0, 1, 0)

x1

x1

x1

x2

x3

x2

x2

x3

x2

0
ECE 474a/575a
Susan Lysecky

x2

x3

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

1
0
1
1
1
1
0
0

S(0, 0, 1)
x1

x2

x3

x1

x2

x2

x3

0
6 of 31

Binary Decision Diagram (BDD)


Edge Notations

Several ways to represent value = 1 and value = 0


Bubble vs. Non-bubble line
Dashed vs. Solid line
T (then) vs. E (else) labels

We will adopt T vs. E labels consistent with most of the book (Hatchel) examples

S(x1, x2, x3)

S(x1, x2, x3)

x1

x1

S(x1, x2, x3)


x1
E

x2

x2

x2

x3

x2

x2

x3

x2
T

x3 E
T

ECE 474a/575a
Susan Lysecky

7 of 31

Binary Decision Diagram (BDD)


Example 2

Lets consider another function


f(a,b,c,d) = abc + bd + cd
f

b
E

b
E

d
T

a
T

b
E

c
T

What is the value of f(1,1,0,1)?

What is the value of f(1,0,1,0)?


Notice that if a=1 and b=0, the
function does not depend on a
value for c.
ECE 474a/575a
Susan Lysecky

8 of 31

Ordered Binary Decision Diagram (OBDD)


What is a OBDD?

Ordered binary decision diagrams ensure the variables appear in


the same order along all paths from the root to the leaves

c
T

c
T

Ordering : a c b

b
T

Not ordered

ECE 474a/575a
Susan Lysecky

9 of 31

Ordered Binary Decision Diagram (OBDD)


Different Ordering Lead to Different Complexity Example1

Variable ordering important, may result in a more complex (or simple) BDD
All three BDDs below represent the same function
Third ordering (b c a d) optimal because there is exactly one node for
each variable
f

b
E

d
E

E
E

d
T

b
E

1
1

Order : a b c d

Order : a d b c

Order : b c a d

ECE 474a/575a
Susan Lysecky

10 of 31

Ordered Binary Decision Diagram (OBDD)


Different Ordering Lead to Different Complexity Example 2

Consider F = ab + cd + ef, again both BDDs represent same function


Variable order has a large impact on resulting BDD, first variable ordering (a
b c d e f) yields a much simpler BDD
f
a

f
a
T

f
E

E
E

Order : a b c d e f

Order : a c e b d f
ECE 474a/575a
Susan Lysecky

11 of 31

BDDs for Basic Logic Functions


AND
NOT
a

0
1

1
0

NAND

0
1
0
1

0
0
0
1

0
0
1
1

0
1
0
1

0
1
1
1

0
0
1
1

0
1
0
1

0
1
1
0

0
0
1
1

0
1
0
1

1
1
1
0

XOR

a
E

OR

a
0
0
1
1

a
T

b E
1

a
E

b T
E

ECE 474a/575a
Susan Lysecky

a
E

b
T

12 of 31

Formal Definition of BDDs

A BDD is a direct acyclic graph (DAG) representing a


multiple-output switching function F

b
T

Function node

Represents the function symbol (f)


Indegree = 0
Outdegree = 1

Function node

Nodes are partitioned into three subsets

Internal
nodes

E
E

d
T

Internal node

Represents variable in function (a, b, c, d)


Indegree 1
Outdegree = 2

Terminal nodes

Terminal node

Represents a value (1 or 0)
Indegree 1
Outdegree = 0

ECE 474a/575a
Susan Lysecky

13 of 31

Formal Definition of BDDs

A BDD definition (cont)

Three types of edges

Incoming edge

Incoming edge

From the function node and defines function

E edge

From an internal node and represents when


the corresponding variable is 0

T edge

T edge

From an internal node and represents when


the corresponding variable is 1

E edge
a

d
T

ECE 474a/575a
Susan Lysecky

14 of 31

Formal Definition of BDDs

A BDD definition (cont)

The function f represented by a BDD is


defined as follows

The function of the terminal node is a


constant value (1 or 0)
The function of a T edge is the function of
the head node
The function of a E edge is the complement
of the function of the node
The function of a node v is given by vfT +
vfE, when fT is the function of the T edge and
fE is the function of the E edge
The function of the function node is the
function of its outgoing edge

Function of the function


node is the function of
its outgoing edge

b
T

Function of this
E edge is a

E
E

d
T

Function of this
T edge is a
1

Function of this terminal


node is 0
Function of this terminal node is 1

ECE 474a/575a
Susan Lysecky

15 of 31

BDD Canonical Form

BDDs are canonical (unique) for a representation of


F given a variable ordering if

b
T

All internal nodes are descendants of some node


There are no isomorphic subgraphs
For every node fT fE

c
T

Isomorphic subgraphs

Isomorphic
Two graphs are isomorphic if there is a one-to-one correspondence between their vertices and there is an edge between
two vertices of one graph if and only if there is an edge between the two corresponding vertices in the other graph
English same subgraph - all vertices the same, all edges between vertices the same
ECE 474a/575a
Susan Lysecky

16 of 31

Building BDDs For a Function F

How do I build a BDD given a function F ?


Recursive use of Shannons Expansion Theorem

F = aFa + aFa
We can keep applying expansion theorem,
eventually we reach the unique canonical form ,
which uses only minterms

F = ab + abc + abc
F = a(bc) + a(b+bc)

Fa = (b+bc)
Fa = (bc)
Fa also called the cofactor of F w.r.t.
(with respect to) a

F = ab + abc + abc

F = ab + abc + abc

F = bFb + bFb

F = cFc + cFc

F = b(a+ ac) + b(ac)

F = c(ab + ab) + c(ab + ab)

F expanded w.r.t to b

F expanded w.r.t to c

ECE 474a/575a
Susan Lysecky

17 of 31

Building BDDs - Exercise 1

Build a BDD for f = abc + abc + abc + abc


Use the variable ordering a b c

partial expansion
with respect to a

Compute cofactors of f with respect


to a (first variable in ordering)
f

f = abc + abc + abc + abc

fa = bc + bc

fa

fa = bc + bc

ECE 474a/575a
Susan Lysecky

fa

18 of 31

Building BDDs - Exercise 1

Build a BDD for f = abc + abc + abc + abc


Use the variable ordering a b c

f
a
T

fa

fa

partial expansion
with respect to b

Compute cofactors of fa and fa with respect to b


(second variable in ordering)
f

fa = bc + bc

(fa)b = fab = c

(fa)b = fab = c

fab

fa = bc + bc

fab

fab

fab

(fa)b = fab = c
(fa)b = fab = c

ECE 474a/575a
Susan Lysecky

19 of 31

Building BDDs - Exercise 1

Build a BDD for f = abc + abc + abc + abc


Use the variable ordering a b c

f
a
T

b
T

Compute cofactors of fab, fab, fab, fab with respect


to c (third variable in ordering)

b
T

fab

fab

fab

fab = c

fab

fabc = 1

fabc = 0

fab = c

fabc = 1
fabc = 0

fab = c
fabc = 0

expansion with
respect to c, final
BDD

c
T

fabc = 1
fab = c
fabc = 0
fabc = 1

ECE 474a/575a
Susan Lysecky

20 of 31

Building BDDs - Exercise 1

f = abc + abc + abc + abc

a
0
0
0
0
1
1
1
1

b
0
0
1
1
0
0
1
1

c
0
1
0
1
0
1
0
1

f
1
0
1
0
0
1
0
1

f
a
T

b
T

b
T

c
T

c
E

Does it work?

ECE 474a/575a
Susan Lysecky

21 of 31

Building BDDs - Exercise 2

Build a BDD for f = abc + bd + cd


Use the variable ordering b c d a

partial expansion
with respect to b

Compute cofactors of f with respect


to b (first variable in ordering)
f

f = abc + bd + cd

b
T

fb = ac + cd

fb

fb = d + cd

fb

ECE 474a/575a
Susan Lysecky

22 of 31

Building BDDs - Exercise 2

Build a BDD for f = abc + bd + cd


Use the variable ordering b c d a

f
b
T

fb
f
b

fb = ac + cd

c
T

fbc = a

c
E

fbc

fbc = d

partial expansion
with respect to c

fb

Compute cofactors of fb and fb with respect to c


(second variable in ordering)

fbc

fbc

fbc

equivalent
cofactors, we can
create a single
node (reduced)

fb = d + cd
T

fbc = d
c
T

fbc = d
ECE 474a/575a
Susan Lysecky

fbc

fbc = fbc = fbc

23 of 31

Building BDDs - Exercise 2

Build a BDD for f = abc + bd + cd


Use the variable ordering b c d a

c
T

Compute cofactors of fbc, fbc, and fbc with


respect to d (third variable in ordering)

partial expansion
with respect to d

fbc

fbc = fbc = fbc


f

fbc = fbc = fbc = d


fbcd = fbcd = fbcd = 1

fbcd = fbcd = fbcd = 0

fbc
1

ECE 474a/575a
Susan Lysecky

24 of 31

Building BDDs - Exercise 2

Build a BDD for f = abc + bd + cd


Use the variable ordering b c d a

c
T

Compute cofactors of fbc with respect to a (fourth


variable in ordering)

fbc

fbc = a

expansion with
respect to a, final
BDD

fbca = 1
fbca = 0

c
T

a
T

ECE 474a/575a
Susan Lysecky

25 of 31

Building BDDs - Exercise 2

Build a BDD for f = abc + bd + cd


a
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1

b
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1

c
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1

d
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1

f
0
1
0
1
0
1
0
0
0
1
0
1
0
1
1
1

c
T

a
T

Does it work?
ECE 474a/575a
Susan Lysecky

26 of 31

BDD to Boolean Function Exercise 1

Can we go from a BDD to a Boolean function ?

Sum all paths from function node to terminal nodes

F = bca + bcd + bd
= cFc + cFc
= c(a) + c(d)
= ca + cd

a
T

= aFa + aFa
= a(1) + a(0)
=a+0
=a

= bFb + bFb
= b(ca + cd) + b(d)
= bca + bcd + bd

=d
1

ECE 474a/575a
Susan Lysecky

27 of 31

BDD to Boolean Function Exercise 2


Another Example

F = abc + ab + a
f

= bFb + bFb
= b(c) + b(1)
= bc + b

c
T

= aFa + aFa
= a(bc + b) + a(1)
= abc + ab + a

= c

ECE 474a/575a
Susan Lysecky

28 of 31

Reducing BDDs

When building BDDs, result not always reduced (Example 1 - slide 19)

Transform a non-reduced BDD into a reduced BDD by iteratively applying

We have isomorphic subgraphs, potential for reduction


Identify isomorphic subgraphs
Remove redundant nodes

A ordered reduced BDD (ROBDD) is unique so we have a canonical form

a
T

b
T

b
T

c
T

a
T

c
T

a
T

c
T

c
E

c
T

Fb = Fb
(redundant node)

isomorphic subgraphs
ECE 474a/575a
Susan Lysecky

29 of 31

Reducing BDDs
Example 2

Lets try to reduce and OBDD

Iterative apply
Identify isomorphic subgraphs
Remove redundant nodes

a
T

b
T

a
T

a
T

b
T

c
T

c
E

isomorphic subgraphs

c
E

c
E

c
E

Fb = Fb
(redundant node)
ECE 474a/575a
Susan Lysecky

30 of 31

10

Summary, and then some

Binary Decision Diagrams (BDDs)


Efficient mechanism to representation of Boolean functions in terms of memory and
CPU
Translating functionBDD and BDDfunction
Importance of variable ordering
Method to reduced OBDDs, getting a ROBDD

We said that BDDs can be efficiently stored and manipulated HOW?


Refer to handwritten notes
Supplemental materials attached

ECE 474a/575a
Susan Lysecky

31 of 31

ITE Operator
Two argument operators expressed in terms of ITE

Table

Name

Expression

Equivalent Form

0000

0001

AND(F, G)

FG

ITE(F, G, 0)

0010

F>G

FG

ITE(F, G, 0)

0011

0100

F<G

FG

ITE(F, 0, G)

0101

0110

XOR(F, G)

FG

ITE(F, G, G)

0111

OR(F, G)

F+G

ITE(F, 1, G)

1000

NOR(F, G)

(F + G)

ITE(F, 0, G)

1001

XNOR(F, G)

(F G)

ITE(F, G, G)

1010

NOT(G)

ITE(G, 0, 1)

1011

FG

F + G

ITE(F, 1, G)

1100

NOT(F)

ITE(F, 0, 1)

1101

FG

F + G

ITE(F, G, 1)

1110

NAND(F, G)

(FG)

ITE(F, G, 1)

1111

1
ECE 474a/575a
Susan Lysecky

32 of 31

ITE Algorithm

Most standard manipulation of BDDs can be done with ITE


Algorithm recursive, based on formulation where v is the top variable of F, G, H
ITE(F, G, H) = FG + FH
= v(FG + FH)v + v(FG + FH)v
= v(FvGv + FvHv) + v(FvGv + FvHv)
= ITE( v, ITE(Fv, Gv, Hv), ITE(Fv, Gv, Hv) )

Terminal cases are as follows


ITE(1, F, G) = ITE(0, G, F) = ITE(F, 1, 0) = ITE(G, F, F) = F

ECE 474a/575a
Susan Lysecky

33 of 31

11

Pseduo-code of the ITE Algorithm


ITE(F, G, H){
(result, terminal_case) = TERMINAL_CASE(F, G, H)

// did we find a terminal case?

if (terminal_case) return (result)


(result, in_computed_table) = COMPUTED_TABLE_HAS_ENTRY(F, G, H)

// have we already calculated this value?

if (in_computed_table) return (result)


v = TOP_VARIABLE(F, G, H)

// recursively calculate this value

T = ITE(Fv, Gv, Hv)


E = ITE(Fv, Gv, Hv)
R = FIND_OR_ADD_UNIQUE_TABLE(v, T, E)

// see if subtree already present

INSERT_COMPUTED_TABLE((F, G, H), R)

// record the calculated value

return (R)
}

ECE 474a/575a
Susan Lysecky

34 of 31

12

You might also like