3-vlsicad-bdd

download 3-vlsicad-bdd

of 35

Transcript of 3-vlsicad-bdd

  • 7/29/2019 3-vlsicad-bdd

    1/35

    VLSI CAD:Logic to Layout

    Rob A. RutenbarUniversity of Illinois

    Lecture 3.1

    Computational BooleanAlgebra Representations:

    BDD Basics, Part 1

  • 7/29/2019 3-vlsicad-bdd

    2/35

    2013, R.A. Rutenbar

    Representations, Revisited URP tautology is a great

    warm up example

    Shows big idea: Boolean functions asthings we manipulate with software

    Data structure + operators But URP not the real way(s) we do it

    Lets look at a real, important,elegantway to do this

    Binary Decision Diagrams: BDDs

    Slide 2

    b 11 01 11

    c 11 11 01

    bc 11 10 10

    fab fab

    c 11 11 01

    c 11 11 10

    1 11 11 11c 11 11 01

  • 7/29/2019 3-vlsicad-bdd

    3/35

    2013, R.A. Rutenbar

    Background: BDDs Originally studied by many

    Lee first, then Boute and Akers

    Got seriously useful in 1986 Randy Bryant of CMU made

    breakthrough ofROBDDs

    Randy also providedmany of the nice BDD

    pictures in this lecture

    thanks!

    Slide 3

    http://www.cs.cmu.edu/~bryant/

  • 7/29/2019 3-vlsicad-bdd

    4/35

    2013, R.A. Rutenbar

    Binary Decision Diagrams for Truth Tables Big Idea #1: BDD

    Turn a truth table for the Booleanfunction into a Decision Diagram

    In simplest case, graph is just a tree By convention dont draw arrows on

    the edges, we know where they go

    Vertex represents a variable; edge out is a decision (0 or 1)

    Follow green (dashed) line for value 0

    Follow red (solid) line for value 1

    Function value determined by leaf value.

    Truth Table

    Decision Tree

    x3 x3x2

    x3 x3x2

    x1

    Slide 4

  • 7/29/2019 3-vlsicad-bdd

    5/35

    2013, R.A. Rutenbar

    Binary Decision Diagrams Some terminology

    A variable vertex

    The lo pointer

    to lo child of

    vertex

    The hi pointer

    to hi child ofof vertex

    A constant vertex

    at the bottom

    leaves of the tree

    The variable ordering, which is the

    order in which decisions about variables

    are made. Here, its X1 X2 X3

    0 0

    x3

    0 1

    x3

    x2

    0 1

    x3

    0 1

    x3

    x2

    x1

    Slide 5

  • 7/29/2019 3-vlsicad-bdd

    6/35

    2013, R.A. Rutenbar

    Ordering Note: Different variable orders are possible

    Order for this subtree is

    X2then X3

    Here, itsX3then X20 0

    x3

    0 1

    x3

    x2

    0 1

    x3

    0 1

    x3

    x2

    x1

    0 0

    x3

    0 1

    x3

    x2

    x2 x2

    x3

    x1

    Slide 6

  • 7/29/2019 3-vlsicad-bdd

    7/35

    2013, R.A. Rutenbar

    Binary Decision Diagrams Observations

    Each path from root to leaf traverses variables in a some order Each such path constitutes a row of the truth table, ie, a decision about what output

    is when variables take particular values But we have not yet specified anything about the orderof decisions This decision diagram is not unique for this function

    Terminology: Canonical form

    Representation that does not depend on gate implementation of a Boolean function Same function of same variables always produces this exact samerepresentation Example: a truth table is canonical. We want a canonical form data structure.

    Slide 7

  • 7/29/2019 3-vlsicad-bdd

    8/35

    2013, R.A. Rutenbar

    Binary Decision Diagrams Whats wrong with this diagram representation?

    Its notcanonical, and it is way too big to be useful (its as big as truth table!)

    Big idea #2: Ordering Restrictglobal ordering of variables Means:

    Note Its OK to omita variable if you dont need to check it to decide which leaf node

    to reach for final value of functionSlide 8

  • 7/29/2019 3-vlsicad-bdd

    9/35

    2013, R.A. Rutenbar

    Ordering BDD Variables Assign arbitrary orderingto vars: x1 < x2 < x3

    Variables must appear in this specific order along all paths; ok to skip vars

    Properties No conflicting assignments along path (see each var at most once on path).

    OK No!x

    1

    x2x3

    x1

    x3

    x3

    x2x1

    x1

    x1

    Slide 9

  • 7/29/2019 3-vlsicad-bdd

    10/35

    2013, R.A. Rutenbar

    Binary Decision Diagrams OK, now whats wrong with it?

    Variable ordering simplifies things... But still too big, and not canonical

    0 0

    x3

    0 1

    x3

    x2

    0 1

    x3

    x1

    Original decision diagram

    Equivalent, butdifferentdiagram

    0 0

    x3

    0 1

    x3

    x2

    0 1

    x3

    0 1

    x3

    x2

    x1

    Slide 10

  • 7/29/2019 3-vlsicad-bdd

    11/35

    VLSI CAD:

    Logic to Layout

    Rob A. RutenbarUniversity of Illinois

    Lecture 3.2

    Computational BooleanAlgebra Representations:

    BDD Basics, Part 2

  • 7/29/2019 3-vlsicad-bdd

    12/35

    2013, R.A. Rutenbar

    Binary Decision Diagrams Big Idea #3: Reduction

    Identify redundancies in the graph that can remove unnecessary nodes and edges Removal ofX2 node and its children, replace with X3 node is an example of this

    Why are we doing this? GRAPH SIZE: Want result as smallas possible CANONICAL FORM: Forsamefunction, given same variable order,

    want there to be exactly one graph that represents this function

    Slide 12

    0 0

    x30 1

    x3x2

    0 1

    x3x1

  • 7/29/2019 3-vlsicad-bdd

    13/35

    2013, R.A. Rutenbar

    Reduction Rules Reduction Rule 1: Merge equivalent leaves

    Just keep one copy of each constant leaf anything else is totally wasteful Redirect all edges that went into the redundant leaves into this one kept node

    Apply Rule 1 to our example...

    0 0

    x3

    0 1

    x3

    x2

    0 1

    x3

    0 1

    x3

    x2

    x1

    x3 x3

    x2

    x3

    0 1

    x3

    x2

    x1

    x3 x3

    x2

    x3

    0 1

    x3

    x2

    x1

    Slide 13

  • 7/29/2019 3-vlsicad-bdd

    14/35

    2013, R.A. Rutenbar

    Reduction Rule 2: Merge isomorphic nodes

    Isomorphic = 2 nodes with same variable and identicalchildren Cannot tell these nodes apart from how they contribute to decisions in graph Note: meansexact same physicalchild nodes, not just children with same label

    Reduction Rules

    y

    x

    z

    x

    y

    x

    z

    Remove redundant node(extra x node).Redirect all edges that went

    into the redundant node intothe one copy that you kept

    (edges into right x node nowinto left as well)

    Slide 14

  • 7/29/2019 3-vlsicad-bdd

    15/35

    2013, R.A. Rutenbar

    Reduction Rules Apply Rule 2 to our example

    x3 x3

    x2

    x3

    0 1

    x3

    x2

    x1

    x3 x3

    x2

    x3

    0 1

    x3

    x2

    x1

    Slide 15

  • 7/29/2019 3-vlsicad-bdd

    16/35

    2013, R.A. Rutenbar

    Reduction Rules Reduction Rule #3: Eliminate Redundant Tests

    Test: means a variable node: redundant since children go to same node... ...so we dont care what value x node takes in this diagram

    y

    x

    Remove redundant nodeRedirect all edges intoredundant node (x) into child

    (y) of the removed node

    Slide 16

  • 7/29/2019 3-vlsicad-bdd

    17/35

    2013, R.A. Rutenbar

    Reduction Rules Apply Rule #3 to our example and were finished!

    Aside: How to apply the rules? For now, iteratively: when you cant find another match, graph is reduced Is this how programs really do it? No we will talk about that later

    x3

    x2

    0 1

    x3

    x2

    x1

    x3

    x2

    0 1

    x3

    x2

    x1

    x2

    0 1

    x3

    x1

    Slide 17

  • 7/29/2019 3-vlsicad-bdd

    18/35

    2013, R.A. Rutenbar

    BDDs: Big Results Recap: What did we do?

    Start with a BDD, order the vars, reduce the diagram Name: Reduced Ordered BDD (ROBDD)

    Big result

    Same function always generates exactly same graph... forsame var ordering Two functions identical if and only if ROBDD graphs are isomorphic (ie, same)

    Nice property to have: Simplest form of graph is canonicalSlide 18

  • 7/29/2019 3-vlsicad-bdd

    19/35

    VLSI CAD:

    Logic to Layout

    Rob A. RutenbarUniversity of Illinois

    Lecture 3.3

    Computational BooleanAlgebra Representations:

    BDD Sharing

  • 7/29/2019 3-vlsicad-bdd

    20/35

    2013, R.A. Rutenbar

    BDDs: Representing Simple Things Note: can represent any function as a ROBDD

    ROBDD forf(x1,x2,...xn) = 0 ROBDD forf(x1,, x,xn) = x

    ROBDD forf(x1,x2,...xn) = 1NOTE: In a ROBDD, a Boolean function

    is really just a pointer to the root node ofa canonical graph data structure

    Slide 20

  • 7/29/2019 3-vlsicad-bdd

    21/35

    2013, R.A. Rutenbar

    BDD: Examples Assume variable order is X1, X2, X3, X4

    Odd Parity

    Linearrepresentation

    Typical Function

    (X1 + X2 )X4No vertex labeled X3

    independent ofX3Many subgraphs shared

    x2

    0 1

    x4

    x1

    x2

    x3

    x4

    10

    x4

    x3

    x2

    x1

    Slide 21

  • 7/29/2019 3-vlsicad-bdd

    22/35

    2013, R.A. Rutenbar

    Sharing in BDDs Very important technical point

    Every BDD node (notjustroot) represents someBoolean function in a canonicalway BDDs good at extracting & representing sharing of subfunctions in subgraphs

    (X1 + X2 )X4

    x2

    0 1

    x4

    x1

    x2

    x3

    x4

    10

    x4

    x3

    x2

    x1

    ( x3!!x4 )

    X1X2

    X3

    X4

    x3!!x4

    x4

    Slide 22

  • 7/29/2019 3-vlsicad-bdd

    23/35

    2013, R.A. Rutenbar

    BDDs Sharing: Consider a 4bit Adder Look at sum S3 msb & carry out Cout

    4 bit binary adder

    a3 b3 a0 b0a1 b1a2 b2

    S3

    b3

    b2

    b1

    0

    b0

    a0

    b1

    a1

    b2

    a2

    1

    b3

    a3

    Cout

    b3

    b2

    b1

    b0

    a0

    b1

    a1

    b2

    a2

    b2

    b1

    0

    b0

    a0

    b1

    a1

    1

    b2

    a2

    b3

    a3

    S3

    Xor

    Negative

    LogicCarryChain

    PositiveLogicCarryChain

    Basically sameshared

    subfunction

    Cout

    Slide 23

  • 7/29/2019 3-vlsicad-bdd

    24/35

    2013, R.A. Rutenbar

    BDD Sharing: Multi-rooted Graph Dont represent it twice!

    BDD can have multipleentry points, or roots

    Called a multi-rooted BDD

    Recall (again!) Everynode in a BDD represents

    some Boolean function

    This multi-rooting idea just explicitlyexploits this to better share stuff

    b3 b3

    a3

    Cout

    b3

    b2

    b1

    b0

    a0

    b1

    a1

    b2

    a2

    b2

    b1

    0

    b0

    a0

    b1

    a1

    1

    b2

    a2

    b3

    a3

    S3

    PositiveLogicCarryChain

    2 roots

    Slide 24

  • 7/29/2019 3-vlsicad-bdd

    25/35

    2013, R.A. Rutenbar

    Sharing: Multi-rooted BDD Graphs Why stop at 2 roots?

    Big savings forsets of functions Minimize size overseveralseparate

    BDDs by maximum sharing

    Example: Adders Separately

    51nodes for4-bit adder 12,481 for64-bit adder

    Shared 31 nodes for4-bit adder 571 nodes for64-bit adder

    b3 b3

    a3

    Cout

    b3

    b2 b2

    a2

    b2 b2

    a2

    b3

    a3

    S3

    b2

    b1 b1

    a1

    b1 b1

    a1

    b2

    a2

    S2

    b1

    a0 a0

    b1

    a1

    S1

    b0

    10

    b0

    a0

    S0

    Slide 25

  • 7/29/2019 3-vlsicad-bdd

    26/35

    VLSI CAD:

    Logic to Layout

    Rob A. RutenbarUniversity of Illinois

    Lecture 3.4

    Computational BooleanAlgebra Representations:

    BDD Ordering

  • 7/29/2019 3-vlsicad-bdd

    27/35

    2013, R.A. Rutenbar

    How Are BDDs Really Implemented Recursive methods, like URP

    Shannon cofactor divide & conquer is key

    As a set ofoperators (ops) onthe BDDs

    AND, OR, NOT, EXOR, CoFactor Quant,Quant, Satisfy, etc

    Operate on a universe ofBoolean data as input/output Constants 0,1; vars; Bool functions

    represented as shared BDD graphs

    Big trick: Implement each op so ifinputs shared, reduced, ordered,

    outputs are too

    Slide 27

    H = (bdd)OP(bdd F, bdd G)

    bdd nodes

  • 7/29/2019 3-vlsicad-bdd

    28/35

    2013, R.A. Rutenbar

    BDDs: Build Up Incrementally

    For example: by walking a gate-level network

    Each inputis a BDD, each gatebecomesan operatorthat produces a new outputBDD

    Build BDD for Out as a scriptof callsto basic BDD operators

    A

    B

    C

    T1

    T2

    Out

    A B C

    T1 T2

    Out

    0 1

    a

    0 1

    c

    0 1

    b

    0 1

    b

    a

    0 1

    c

    b

    c

    b

    0 1

    b

    a

    BDD operator script

    1. A = CreateVar(A)2. B = CreateVar(B)3. C = CreateVar(C)4. T1 = And(A,B)5. T2 = And(B,C)6. Out = Or(T1,T2)

    Slide 28

  • 7/29/2019 3-vlsicad-bdd

    29/35

    2013, R.A. Rutenbar

    Apps: Comparing Logic Implementations Are these two Boolean

    functions F, G the same?

    Build BDD forF. Build BDD forG

    Compare pointers to roots ofF, G If pointers are same(!!), F==G

    What inputs make functionsF, G give different answers?

    Build BDD forF. Build BDD forG.

    Build the BDD forH = FG

    Ask satisfiable forH (!!)

    Slide 29

    bdd nodes bdd nodes

  • 7/29/2019 3-vlsicad-bdd

    30/35

    2013, R.A. Rutenbar

    More Very Useful BDD Applications Tautology checking

    Was complex with cubelist URP,subtle algorithm, lots of work

    With BDDs, its trivial. Just build theBDD, check if BDD graph ==

    Satisfiability Find values (0,1) for vars so F == 1? No idea how to do it with cubelists Any pathfrom root to 1 leaf is soln!

    x2

    0 1

    x4

    x1 Satisfiability: X1 X2 X3 X4 =

    Slide 30

  • 7/29/2019 3-vlsicad-bdd

    31/35

    2013, R.A. Rutenbar

    BDDs: Seem Too Good To Be True?! Problem : Variable ordering matters. Ex: a1b1 + a2b2 + a3b3

    Good Ordering Bad Ordering

    Linear Growth Exponential Growth

    0

    b3

    a3

    b2

    a2

    1

    b1

    a1

    a3 a3

    a2

    b1 b1

    a3

    b2

    b1

    0

    b3

    b2

    1

    b1

    a3

    a2

    a1

    Slide 31

  • 7/29/2019 3-vlsicad-bdd

    32/35

    2013, R.A. Rutenbar

    Variable Ordering: Consequences Interesting problem

    Some problems known to be exponentially hard are very easydone with BDDs(!) Trouble is, they are easy only if size of the BDD for the problem is reasonable Some problems make nice (small) BDDs, others make pathological (large) BDDs No universal solution (or could always to solve exponentially hard problems easily)

    How to handle? Variable ordering heuristics:make nice BDDs for reasonable probs Characterization: know which problems nevermake nice BDDs (eg, multipliers) Dynamic ordering: let the BDD software package pick the order on the fly

    Slide 32

  • 7/29/2019 3-vlsicad-bdd

    33/35

    2013, R.A. Rutenbar

    Variable Ordering: Intuition Rules of thumb for BDD ordering

    Related inputsshould be neareach other in order; groupsof inputs that candetermine function by themselves should be (i) close together, and (ii) neartop of BDD

    0

    b3

    a3

    b2

    a2

    1

    b1

    a1

    a3 a3

    a2

    b1 b1

    a3

    b2

    b1

    0

    b3

    b2

    1

    b1

    a3

    a2

    a1

    Slide 33

    Ex:(a1b1 + a2b2 + a3b3)

  • 7/29/2019 3-vlsicad-bdd

    34/35

    2013, R.A. Rutenbar

    Aside: Variable Ordering Arithmetic circuits are important logic; how are their BDDs?

    Many carry chain circuits have easy linear sized ROBDD orderings:Adders, Subtractors, Comparators, Priority encoders

    Rule is alternatevariables in the BDD order: a0 b0 a1 b1 a2 b2 an bn So are all arithmetic circuits easy then? No, sorry

    General experience with BDDs Many tasks have reasonable OBDD sizes; algorithms practical to ~100M nodes People spend a lot of effort to find orderings that work

    Function Class Best Order Worst Order

    Addition linear exponential

    Multiplication exponential exponential

    Slide 34

  • 7/29/2019 3-vlsicad-bdd

    35/35

    2013, R.A. Rutenbar

    BDD Summary Reduced, Ordered, Binary Decision Diagrams, ROBDDs

    Canonical form a data structure for Boolean functions Two boolean functions the same if and only if they have identical BDD A Boolean function is just a pointer to the root node of the BDD graph Every node in a (shared) BDD represents some function With shared BDD, test (F==G) check pointers for equality, point to same root Basis for much of todays general manipulation or Boolean stuff

    Problems Variable ordering matters; sometimes BDD is just too big Often, we just want to know SAT dont need to build the whole function

    Slide 35