06 bdd 2014

Upload: jubin-jain

Post on 01-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 06 BDD 2014

    1/39

    VLSI CAD

    Tutorial #6

    Binary Decision Diagram s

    BDD s

    1

    0

    0

    0

    X1

    X2

    X3

    1

    1

    1

    10

  • 8/9/2019 06 BDD 2014

    2/39

    Binary Decision Diagram

    Ordered BDD ( OBDD ) : The variables in all paths always appear in the same order x1 < x2 < x3

    Introduction: draw an ordered BDD for the following truth table:FX3X2X1

    0000

    0100

    0010

    1110

    0001

    1101

    0011

    1111

    2

  • 8/9/2019 06 BDD 2014

    3/39

    Binary Decision Diagram

    Ordered BDD ( OBDD ) : The variables in all paths always appear in the same order x1 < x2 < x3

    0

    000 0

    0

    X1

    X3

    X2

    X3 X3 X3

    X20

    1

    1 1 1 1

    11

    10 1 10 0 0 0

    Introduction: draw an ordered BDD for the following truth table:FX3X2X1

    0000

    0100

    0010

    1110

    0001

    1101

    0011

    1111

    3

  • 8/9/2019 06 BDD 2014

    4/39

    Reduced OBDD - ROBDD

    Example : Reduce the bdd given on the previous slide.

    0

    000 0

    0

    X1

    X3

    X2

    X3 X3 X3

    X20

    1

    1 1 1 1

    11

    10 1 10 0 0 0

    Step 1 : Duplicate terminal removal

    4

  • 8/9/2019 06 BDD 2014

    5/39

    Reduced OBDD - ROBDD

    Example : Reduce the bdd given on the previous slide.

    0

    000 0

    0

    X1

    X3

    X2

    X3 X3 X3

    X20

    1

    1 1 1 1

    11

    10 1 10 0 0 0

    Step 1 : Duplicate terminal removal

    0

    00

    00

    0

    X1

    X3

    X2

    X3 X3 X3

    X20

    1

    1 11

    1

    11

    105

  • 8/9/2019 06 BDD 2014

    6/39

    Reduced OBDD - ROBDD

    Example : Reduce the bdd given on the previous slide.Step 2 : Duplicate non-terminal removal

    0

    00

    00

    0

    X1

    X3

    X2

    X3 X3 X3

    X20

    1

    1 11

    1

    11

    106

  • 8/9/2019 06 BDD 2014

    7/39

    Reduced OBDD - ROBDD

    Example : Reduce the bdd given on the previous slide.Step 2 : Duplicate non-terminal removal

    0

    00

    00

    0

    X1

    X3

    X2

    X3 X3 X3

    X20

    1

    1 11

    1

    11

    10

    0

    00

    0

    X1

    X2

    X3 X3

    X20

    1

    1 1

    11

    107

  • 8/9/2019 06 BDD 2014

    8/39

    Reduced OBDD - ROBDD

    Example : Reduce the bdd given on the previous slide.Step 3 : Redundant test removal

    0

    00

    0

    X1

    X2

    X3 X3

    X20

    1

    1 1

    11

    108

  • 8/9/2019 06 BDD 2014

    9/39

    Reduced OBDD - ROBDD

    Example : Reduce the bdd given on the previous slide.Step 3 : Redundant test removal

    0

    0

    0

    X1

    X2

    X3

    1

    1

    1

    10

    0

    00

    0

    X1

    X2

    X3 X3

    X20

    1

    1 1

    11

    109

  • 8/9/2019 06 BDD 2014

    10/39

    Storing BDDs

    0

    00

    A

    B

    C

    1

    1

    1

    10

    F = ABC

    H=C

    G = BC

    Shared BDDs :BDD structures can be shared by different functions.

    Example :

    F = ABC, G=BC, H=C

    The bdd for F can be created as a multi-rooted bdd.

    Once the bdds of C and BC have been computed,

    pointers to these structures ( C and BC ) can be usedto create the bdd for F.

    10

  • 8/9/2019 06 BDD 2014

    11/39

    The Unique Table ( UT )

    Unique Table : • A data base storing pointers to all the subgraphs of the BDD.• The table is unique - there is a single pointer to each node.• The purpose of the unique table is to avoid redundancies

    in the multi-rooted BDDs.• The main Idea is to check for existing nodes before adding.• The key to the table:

    The key is a description of the node: (v,H,L ) where “v” is the decision variable,

    “H” and “L” are it’s two sons - subgraphs.

    0 v 1

    HL

    11

    0

    0

    0

    A

    B

    C

    1

    1

    1

    10

    ABC

    C

    BC

    01cC:

    0C bBC:0BCaABC:

  • 8/9/2019 06 BDD 2014

    12/39

    Building BDDs - wrong way

    Intuitive solution:

    1) Work bottom up,Build Primitives:

    Recall the Shannon expansion , how it applies to BDDS ?

    Exercise : Build a ROBDD for the following function: f = a’b + ac

    0 a

    1

    10

    0 a

    1

    01

    0 b

    1

    10

    0 c

    1

    10

    A A` B C

    2) Build (simple) minterms:Remark: what about large minterms ? 0

    a1

    0B

    A`B

    0 a

    1

    C0

    AC

    3) Join the minterms ??? Not reduced, nor unique !!!

    0 a

    1

    CB

    A`B+AC

    12

  • 8/9/2019 06 BDD 2014

    13/39

    The Shannon Expansion

    a

    Shannon’s expansion : f = af a + a’f a’

    The BDD represents recursiveapplication of Shannon’s expansion !

    f a f a’

    f

    10

    Decomposing the function (co-factoring)Creates subgraphs that are unique (unless it already exists),and are used in building the function.

    13

  • 8/9/2019 06 BDD 2014

    14/39

    Build BDD - Algorithm

    Build_BDD (F){

    If ( terminal = Terminal_Case ( F ) ){ return terminal; }else{

    v = Top_Variable( F ); // Assumes global variable orderFv = Co_Factor( F , v );Fv` = Co_Factor( F , v` );HSON = Build_BDD (F v ); // recursive call

    LSON = Build_BDD (F v` ); // recursive call return Unique_Table ( v , HSON , LSON );

    }}

    14

  • 8/9/2019 06 BDD 2014

    15/39

    Build BDD - functionsUnique_Table ( v , HSON , LSON ){

    If ( HSON == LSON ){ return HSON; }else if ( node = Unique_Table_Exists ( v , HSON , LSON ) ){ return node; }else{

    new_node = Unique_Table_Insert ( v , HSON , LSON );return new_node;

    }}

    Terminal_Case ( F ){

    if ( F == ‘ 0’) { return BDD(‘ 0’); }else if ( F == ‘ 1’) { return BDD(‘ 1’); }else { return NON_TERMINAL; }

    } 15

    ר ש פ ך ש מ ה ה י פת ז ה ה ר ד ג ה ת ה י ח :ר

  • 8/9/2019 06 BDD 2014

    16/39

    More Terminal Cases• If we find at some point during our recursive process that

    f ab’c =d (not a Terminal_Case ) we will continue to cofactorit further to f ab’cd =1 and f ab’cd’ =0 which are both terminalcases.

    • However, building a BDD-Key for f ab’c =d (or even g=d’ ) is very easy:

    • So we can from now on say that anyfunction which is equal to a literal(such as a or b, c, … ) or even a negated one ( a’ or b’,…)

    is also a Terminal_Case .• Actually even functions like

    p=a+b or q=cd can be alsoeasily built and said to be

    terminal cases too. 16

    0 d

    10

    f ab’c

    1 0 d

    01

    g

    1

    a

    10

    b

    p c

    0 1

    d

    q

  • 8/9/2019 06 BDD 2014

    17/39

    Exercise 1

    Exercise : Build a shared ROBDD for the following functions:

    A) f = (a + b) • c + dB) g = ac’ + d

    C) h = f + g

    - We will use the Build_BDD algorithm- The variable ordering is: a < b < c < d , (a is the top).- Compution is always “bottom up”.

    First compute f and g and then “ f op g ” Recall that : f op g = x(f x op g x ) + x’(f x’ op g x’ )

    17

  • 8/9/2019 06 BDD 2014

    18/39

    Exercise 1-A

    LsonHsonvIDLabel(s)Boolean exp’

    18

    • We begin with an empty Unique_Table:For our convenience we add two more columns

    (for humans only ).

    • We recall our algorithm:

    • We begin with our function: f = (a + b) • c + d

    (performing Build_BDD ( f ) )

    • Obviously f is not a Terminal_Case sowe break it into coffactors f a , f a’ : f a=c+d ; f a’ =bc+d

    and enter recursively to compute f a .

    Build_BDD (F) { // F= f = (a + b) • c + d If ( terminal = Terminal_Case ( F ) ) {

    return terminal;} else {

    v = Top_Variable( F ); // v=a Fv = Co_Factor( F , v ); // F v = f a=c+dFv` = Co_Factor( F , v` ); // F v’ = f a’ =bc+d HSON = Build_BDD (F v );

    LSON = Build_BDD (Fv` );return Unique_Table ( v , HSON , LSON );

    } }

    f

  • 8/9/2019 06 BDD 2014

    19/39

    Exercise 1-A (cont’)

    19

    LsonHsonvIDLabel(s)Boolean exp’

    01d0x001d; f abc' d

    (performing Build_BDD ( f a ) )

    • Obviously f a=c+d is also not a Terminal_Case so therecursion continues to f ab=c+d ; f ab ’ =c+d.

    (performing Build_BDD ( f ab ) )

    • f ab ; f ab ’ are also not Terminal_Case s by themselves, so wecontinue and finally reach : f abc =1; f abc ’ =d

    • While f abc =1 is Terminal_Case , f abc ’ =d is not but it is trivial to(perform Build_BDD ( f abc ’ ) ) (which returns 0x01)

    • For this expanded Terminal_Case theKey is simply: {d, 1, 0}

    f a = c + df a` = bc + d

    f ab =c + d

    f

    f ab' =c + d

    f a`b =c + d

    f a`b` = d

    f abc=1

    f abc`=d

    f ab`c=1

    f ab`c`=d

    f a`bc=1

    f a`bc`=d

    f

  • 8/9/2019 06 BDD 2014

    20/39

    Exercise 1-A (cont’)

    20

    LsonHsonvIDLabel(s)Boolean exp’

    01d0x01d; f abc' d

    0x011c0x02 f ab ; f ab ’ c+d

    (performing Build_BDD ( f ab ) )

    • Now that we have finished with all of the recursion tree under f ab=c+d , and we know that v= c, HSON=1, LSON=0x01 we can build another BDD part with Key={c, 1, 0x01 }(r etur ns 0x02)

    • Having finished with Build_BDD ( f ab ) the next step is(performing Build_BDD ( f ab ’ ) )

    • But because f ab ’ =c+d exactly equals f ab=c+d for which therelevant BDD part was already built it returns the same pointerLSON=HSON=0x02.

    • Humans can add another Label to 0x02:

    f a = c + df a` = bc + d

    f ab =c + d

    f

    f ab' =c + d

    f a`b =c + d

    f a`b` = d

    f abc=1

    f abc`=d

    f ab`c=1

    f ab`c`=d

    f a`bc=1

    f a`bc`=d

    f

  • 8/9/2019 06 BDD 2014

    21/39

    Exercise 1-A (cont’)

    21

    LsonHsonvIDLabel(s)Bool ’ exp’

    01d0x01d; f abc' d

    0x011c0x02 f a ; f ab ; f ab ’ c+d

    (performing Build_BDD ( f a ) )

    • Having finished with Build_BDD ( f ab ’ ) the next step is callingUnique_Table from within the recursion hierarchy level ofBuild_BDD ( f

    a).

    • Because we in the case of HSON==LSON nothing is need to bedone except returning HSON=0x02. That is again no new linein the Unique_Table is needed, one can only add additionallabel to the line 0x02.

    f a = c + df a` = bc + d

    f ab =c + d

    f

    f ab' =c + d

    f a`b =c + d

    f a`b` = d

    f abc=1

    f abc`=d

    f ab`c=1

    f ab`c`=d

    f a`bc=1

    f a`bc`=d

    f

  • 8/9/2019 06 BDD 2014

    22/39

    Exercise 1-A (cont’)

    22

    LsonHsonvIDLabel(s)Bool ’ exp’

    01d0x01d; f abc' ; f a’b’ d

    0x011c0x02 f a ; f ab ; f ab ’ ; f a’b c+d

    (performing Build_BDD ( f ) )

    • We return to the top recursion hierarchy of f itself. We havefinished with all of the recursion tree under f a=c+d , and weknow that v= a and HSON=0x02. ( & we know f a=c+d;f a’ =bc+d )

    • It is now time to compute LSON by further recursion: (performing Build_BDD ( f a’ ) )

    • After cofactoring of f a’ w.r.t. v= b we find that f a’b =c+d and f a’b’ =d both of which were calculated before, so their HSONand LSON are already known: HSON=0x02, LSON=0x01.

    • Humans can add more labels.

    f a = c + df a` = bc + d

    f ab =c + d

    f

    f ab' =c + d

    f a`b =c + d

    f a`b` = d

    f abc=1

    f abc`=d

    f ab`c=1

    f ab`c`=d

    f a`bc=1

    f a`bc`=d

    f

  • 8/9/2019 06 BDD 2014

    23/39

    Build_BDD (F) { // F= f a’ =bc+d If ( terminal = Terminal_Case ( F ) ) {

    return terminal;} else {

    v = Top_Variable( F ); // v=b Fv = Co_Factor( F , v ); // F v = f a’b =c+dFv` = Co_Factor( F , v` ); // F v’ = f a’b’ =d HSON = Build_BDD (F v ); // HSON=0x02

    LSON = Build_BDD (F v` ); // LSON=0x01 return Unique_Table ( v , HSON , LSON );

    Exercise 1-A (cont’)

    23

    LsonHsonvIDLabel(s)Bool ’ exp’

    01d0x01d; f abc' ; f a’b’ d

    0x011c0x02 f a ; f ab ; f ab ’ ; f a’b c+d

    0x010x02 b0x03 f a' bc+d

    (performing Build_BDD ( f a’ ) )

    • The next step is to call Unique_Table from within the recursionhierarchy level of Build_BDD ( f a’ ), where v= b and HSON=0x02,LSON=0x01.

    • This creates a new Key entry in the Unique_Table{b,0x02,0x01}:

    • Humans can add the label f a ’ to this newly created line 0x03.

    f a = c + df a` = bc + d

    f ab =c + d

    f

    f ab' =c + d

    f a`b =c + d

    f a`b` = d

    f abc=1

    f abc`=d

    f ab`c=1

    f ab`c`=d

    f a`bc=1

    f a`bc`=d

  • 8/9/2019 06 BDD 2014

    24/39

    Exercise 1-A (cont’)

    24

    Humans candraw the BDDrepresented in

    theUnique_Table:

    Simpleor

    Elaborated

    LsonHsonvIDLabel(s)Bool ’ exp’

    01d0x01d; f abc' ; f a’b’ d

    0x011c0x02 f a ; f ab ; f ab ’ ; f a’b c+d

    0x010x02 b0x03 f a' bc+d

    0x030x02a0x04 f (a+b)c+d

    a

    10

    b

    f

    d

    c

    a

    10

    b

    f

    d

    c

    0x04

    0x03

    0x02

    0x01

    f a'

    f a ; f ab ; f ab’ ; f a’b

    d; f abc' ; f a’b’

  • 8/9/2019 06 BDD 2014

    25/39

    Exercise 1-B

    25

    (performing Build_BDD ( g ) )

    • Now we need to build the BDD for the function g= ac’ + d .• Obviously g is not a Terminal_Case so we break it into

    coffactors g a , g a’ : g a=c’+d ; g a’ =d• and enter recursively to compute g a.

    (performing Build_BDD ( g a ) )• As g a doesn’t depend on b the recursion would yield the

    same for g a=g ab=g ab’ se we (perform Build_BDD ( g ab ) )

    LsonHsonvIDLabel(s)Bool ’ exp’

    01d0x01d; f abc' ; f a’b’ d

    0x011c0x02 f a ; f ab ; f ab ’ ; f a’b c+d

    0x010x02 b0x03 f a' bc+d

    0x030x02a0x04 f (a+b)c+d

  • 8/9/2019 06 BDD 2014

    26/39

    Exercise 1-B (cont’)

    26

    (performing Build_BDD ( g ab ) )

    • As g ab =c’+d and is not a Terminal_Case we break it intocofactors and find g abc =d ; g abc’ =1 which are already computedand a Terminal_Case respectively, i.e. we found that

    HSON=0x01 and LSON=1. With v= c, the new Key={ c,0x01,1}:• Humans make labels and make a shortcut to g a:

    LsonHsonvIDLabel(s)Bool ’ exp’

    01d0x01d; f abc' ; f a’b’ d

    0x011c0x02 f a ; f ab ; f ab ’ ; f a’b c+d

    0x010x02 b0x03 f a' bc+d

    0x030x02a0x04 f (a+b)c+d

    10x01c0x05 g a; g ab ; g ab’ c’+d

  • 8/9/2019 06 BDD 2014

    27/39

    Exercise 1-B (cont’)

    27

    (performing Build_BDD ( g ) )• We now finished with all the recursion sub-tree on the g a side.• We are back to the recursion level of Build_BDD ( g ) and now is

    the time to compute LSON but as we found earlier that g a’ =d it

    is clear that LSON=0x01 (another human label added).• Currently v= a so the call to Unique_Table creats a new entry

    with the Key :{a ,0x05,0x01}

    LsonHsonvIDLabel(s)Bool ’ exp’

    01d0x01d; f abc' ; f a’b’ ; g a’ d

    0x011c0x02 f a ; f ab ; f ab ’ ; f a’b c+d

    0x010x02 b0x03 f a' bc+d

    0x030x02a0x04 f (a+b)c+d

    10x01c0x05 g a; g ab ; g ab’ c’+d

    0x010x05a0x06 gac’+d

  • 8/9/2019 06 BDD 2014

    28/39

    Exercise 1-B (cont’)

    28

    Humans candraw the BDDrepresented in

    theUnique_Table:

    Simpleor

    Elaborated

    a

    10

    b

    f

    d

    c

    a

    10

    b

    d

    c

    0x04

    0x03

    0x02

    0x01

    f a' f a ; f ab ; f ab’ ; f a’b

    d; f abc' ; f a’b’

    c

    a

    g

    c

    a

    f g

    g a; g

    ab; g

    ab’

    LsonHsonvIDLabel(s)Bool ’ exp’

    01d0x01d; f abc' ; f a’b’ ; g a’ d

    0x011c0x02 f a ; f ab ; f ab ’ ; f a’b c+d

    0x010x02 b0x03 f a' bc+d

    0x030x02a0x04 f (a+b)c+d

    10x01c0x05 g a; g ab ; g ab’ c’+d

    0x010x05a0x06 gac’+d

    0x06

    0x05

  • 8/9/2019 06 BDD 2014

    29/39

    Exercise 1-C The function is : h = f + gFirst we’ll decompose h (some of functions) :

    h = a(f a + g a ) + a’(f a’ + g a’ )

    h a = f a + g a =

    = c + d + c’ + d = 1

    h a' = f a’ + g a’ =

    =b •c + d + d = b •c + d = f a’

    Meaning we already have the sums in the unique table.

    We have to build the new node:29

    LsonHsonvIDLabel(s)Bool ’ exp’

    01d0x01d; f abc' ; f a’b’ ; g a’ d

    0x011c0x02 f a ; f ab ; f ab ’ ; f a’b c+d0x010x02 b0x03 f a' bc+d

    0x030x02a0x04 f (a+b)c+d

    10x01c0x05 g a; g ab ; g ab’ c’+d

    0x010x05a0x06 gac’+d

    0x031a0x07h f+g

  • 8/9/2019 06 BDD 2014

    30/39

    Build bdd and UT entry for: h = f + g

    Simple BDD add cofactors:

    Exercise 1-C (h )

    0 a

    1 f a`

    h

    1

    LsonHsonvLabel

    01aA

    01bB

    01cC

    01dD

    D1cf abDf ab bf a`f a`f ab af 1 DcgabD gab ag

    f a`1ah 30

    a

    10

    b

    d

    c

    0x04

    0x03

    0x02

    0x01

    f a' f a ; f ab ;

    f ab’ ; f a’b

    d; f abc' ; f a’b’

    c

    a

    f g

    g a; g ab ; g ab’

    a

    h

    0x070x06

  • 8/9/2019 06 BDD 2014

    31/39

    Build bdd and UT entry for: h = f + g

    Simple BDD add cofactors:

    Exercise 1-C (h )

    0

    a

    1 f a`

    h

    1

    LsonHsonvLabel

    01aA

    01bB

    01cC

    01dD

    D1cf abDf ab bf a`f a`f ab af 1 DcgabD gab ag

    f a`1ah

    a

    1 0

    h

    b

    c

    d

    f a`

    D f ab

    Partial BDD:

    31

  • 8/9/2019 06 BDD 2014

    32/39

    ROBDD with Complement Edges

    • These are two different BDDs.

    • There is no need to store them both !• We can store just one, with a polarity value.• BDD building recursion can be stopped if F’ is found

    (not only if F is found).

    0 a

    1

    10

    0 a

    1

    01

    A A`Consider the two following BDDs:

    32

  • 8/9/2019 06 BDD 2014

    33/39

    ROBDD with Complement Edges

    • The dot notation:• The dot means : “invert the final result you get”.

    • The dot can be only on “ else ” edge to keep the BDD canonical. • Using complement edges reduces the number of BDDs, but

    increases the data and work on the remaining BDDs.• Not very intuitive - hard to draw and read.

    0

    a

    1

    1

    A` A

    33

    0 a

    1

    10

    A

    0 a

    1

    01

    A`

    0 a

    1

    10

    A

  • 8/9/2019 06 BDD 2014

    34/39

    Exrecise: Build ROBDDwith Complement Edges

    f = abd’ + ab’d + a’c + a’c’d

    a

    1 0

    f

    b

    c

    d d

    34

  • 8/9/2019 06 BDD 2014

    35/39

    Exrecise: Build ROBDDwith Complement Edges

    f = abd’ + ab’d + a’c + a’c’d

    a

    1 0

    f

    b

    c

    d d

    a

    1

    f

    b

    c

    d d

    35

  • 8/9/2019 06 BDD 2014

    36/39

    Exrecise: Build ROBDDwith Complement Edges

    f = abd’ + ab’d + a’c + a’c’d

    a

    1 0

    f

    b

    c

    d d

    a

    1

    f

    b

    c

    d d

    a

    1

    f

    b

    c

    d d

    36

  • 8/9/2019 06 BDD 2014

    37/39

    Exrecise: Build ROBDDwith Complement Edges

    f = abd’ + ab’d + a’c + a’c’d

    a

    1

    f

    b

    c

    d

    37

  • 8/9/2019 06 BDD 2014

    38/39

    Exrecise: Build ROBDDwith Complement Edges

    f = abd’ + ab’d + a’c + a’c’d

    a

    1

    f

    b

    c

    d

    a

    1

    f

    b

    c

    d

    38

  • 8/9/2019 06 BDD 2014

    39/39

    Exrecise: Build ROBDDwith Complement Edges

    f = abd’ + ab’d + a’c + a’c’d

    a

    1

    f

    b

    c

    d

    a

    1

    f

    b

    c

    d

    a

    1

    f

    b

    c

    d

    39