ECE 665 – Computer Algorithms 1 ECE 665 Spring 2004 ECE 665 Spring 2004 Computer Algorithms Binary Decision Diagrams Implementation Issues Slides adopted.

Slides:



Advertisements
Similar presentations
Model Checking Lecture 4. Outline 1 Specifications: logic vs. automata, linear vs. branching, safety vs. liveness 2 Graph algorithms for model checking.
Advertisements

Representing Boolean Functions for Symbolic Model Checking Supratik Chakraborty IIT Bombay.
Introduction to Computer Science 2 Lecture 7: Extended binary trees
Planning based on Model Checking Dept. of Information Systems and Applied CS Bamberg University Seminar Paper Svetlana Balinova.
CS357 Lecture: BDD basics David Dill 1. 2 BDDs (Boolean/binary decision diagrams) BDDs are a very successful representation for Boolean functions. A BDD.
The Volcano/Cascades Query Optimization Framework
Binary Trees CSC 220. Your Observations (so far data structures) Array –Unordered Add, delete, search –Ordered Linked List –??
Class Presentation on Binary Moment Diagrams by Krishna Chillara Base Paper: “Verification of Arithmetic Circuits using Binary Moment Diagrams” by.
© 2011 Carnegie Mellon University Binary Decision Diagrams Part Bug Catching: Automated Program Verification and Testing Sagar Chaki September.
ECE 667 Student Presentation Gayatri Prabhu [1]. *PHDD: An Efficient Graph Representation for Floating Point Circuit Verification – Y. Chen, R. Bryant,
© 2011 Carnegie Mellon University Binary Decision Diagrams Part Bug Catching: Automated Program Verification and Testing Sagar Chaki September.
ECE 667 Synthesis & Verification - Boolean Functions 1 ECE 667 Spring 2013 ECE 667 Spring 2013 Synthesis and Verification of Digital Circuits Boolean Functions.
Binary Decision Diagrams. ROBDDs Slide 2 Example Directed acyclic graph non-terminal node terminal node What function is represented by the graph?
ECE 667 Synthesis and Verification of Digital Systems
1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.
Spring 07, Feb 13 ELEC 7770: Advanced VLSI Design (Agrawal) 1 ELEC 7770 Advanced VLSI Design Spring 2007 Binary Decision Diagrams Vishwani D. Agrawal James.
DATE-2002TED1 Taylor Expansion Diagrams: A Compact Canonical Representation for Symbolic Verification M. Ciesielski, P. Kalla, Z. Zeng B. Rouzeyre Electrical.
ECE Synthesis & Verification - Lecture 18 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Word-level.
Boolean Functions and their Representations
Rolf Drechlser’s slides used
1 CSEP590 – Model Checking and Automated Verification Lecture outline for July 16, 2003.
Reachability Analysis using AIGs (instead of BDDs?) 290N: The Unknown Component Problem Lecture 23.
ECE Synthesis & Verification - Lecture 9b 1 ECE 697B (667) Fall 2004 ECE 697B (667) Fall 2004 Synthesis and Verification of Digital Systems Boolean.
Taylor Expansion Diagrams (TED): Verification EC667: Synthesis and Verification of Digital Systems Spring 2011 Presented by: Sudhan.
ECE Synthesis & Verification - Lecture 10 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.
 2001 CiesielskiBDD Tutorial1 Decision Diagrams Maciej Ciesielski Electrical & Computer Engineering University of Massachusetts, Amherst, USA
ECE 667 Synthesis & Verification - BDD 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Binary Decision Diagrams (BDD)
ENGG3190 Logic Synthesis “Binary Decision Diagrams” BDDs Winter 2014 S. Areibi School of Engineering University of Guelph.
 2000 M. CiesielskiPTL Synthesis1 Synthesis for Pass Transistor Logic Maciej Ciesielski Dept. of Electrical & Computer Engineering University of Massachusetts,
ECE 667 Synthesis and Verification of Digital Systems
1 High-Level Design Verification using Taylor Expansion Diagrams: First Results Priyank Kalla ECE Department University of Utah Maciej Ciesielski ECE Department.
Building Suffix Trees in O(m) time Weiner had first linear time algorithm in 1973 McCreight developed a more space efficient algorithm in 1976 Ukkonen.
1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.
By Tariq Bashir Ahmad Taylor Expansion Diagrams (TED) Adapted from the paper M. Ciesielski, P. Kalla, Z. Zeng, B. Rouzeyre,”Taylor Expansion Diagrams:
Maps A map is an object that maps keys to values Each key can map to at most one value, and a map cannot contain duplicate keys KeyValue Map Examples Dictionaries:
ECOE 560 Design Methodologies and Tools for Software/Hardware Systems Spring 2006 Serdar Taşıran.
Digitaalsüsteemide verifitseerimise kursus1 Formal verification: BDD BDDs applied in equivalence checking.
B-Tree. B-Trees a specialized multi-way tree designed especially for use on disk In a B-tree each node may contain a large number of keys. The number.
B. Alizadeh Advanced Logic Design (2008) 1 / 55 Decision Diagrams.
Courtesy RK Brayton (UCB) and A Kuehlmann (Cadence) 1 Logic Synthesis Binary Decision Diagrams.
Identifying Reversible Functions From an ROBDD Adam MacDonald.
Binary Decision Diagrams (BDDs)
November,2000University of Southern California1 Introduction to Binary Decision Diagrams - Shesha Shayee K. Raghunathan.
ECE Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.
CS 267: Automated Verification Lecture 6: Binary Decision Diagrams Instructor: Tevfik Bultan.
The Volcano Query Optimization Framework S. Sudarshan (based on description in Prasan Roy’s thesis Chapter 2)
Algorithmic Software Verification V &VI. Binary decision diagrams.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
Notes on Sequence Binary Decision Diagrams: Relationship to Acyclic Automata and Complexities of Binary Set Operations Shuhei Denzumi1, Ryo Yoshinaka2,
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
Sets of Digital Data CSCI 2720 Fall 2005 Kraemer.
 2007 Pearson Education, Inc. All rights reserved C Arrays.
Binary decision diagrams (BDD’s) Compact representation of a logic function ROBDD’s (reduced ordered BDD’s) are a canonical representation: equivalence.
Author: Haoyu Song, Murali Kodialam, Fang Hao and T.V. Lakshman Publisher/Conf. : IEEE International Conference on Network Protocols (ICNP), 2009 Speaker:
PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting.
1 Class Presentation on Binary Moment Diagrams by Krishna Chillara Base Paper: “Verification of Arithmetic Circuits with Binary Moment Diagrams” by Randal.
BDDs1 Binary Tree Representation The recursive Shannon expansion corresponds to a binary tree Example: Each path from the root to a leaf corresponds to.
Boolean Functions 1 ECE 667 ECE 667 Synthesis and Verification of Digital Circuits Boolean Functions Basics Maciej Ciesielski Univ.
BINARY TREES Objectives Define trees as data structures Define the terms associated with trees Discuss tree traversal algorithms Discuss a binary.
Data Structure and Algorithms
Test complexity of TED operations Use canonical property of TED for - Software Verification - Algorithm Equivalence check - High Level Synthesis M ac iej.
Binary Decision Diagrams Prof. Shobha Vasudevan ECE, UIUC ECE 462.
IT 60101: Lecture #121 Foundation of Computing Systems Lecture 13 Trees: Part VIII.
ECE 667 Synthesis and Verification of Digital Systems
Multi-Way Search Trees
Binary Decision Diagrams
Binary Decision Diagrams
Binary Decision Diagrams
Example: Verification
Presentation transcript:

ECE 665 – Computer Algorithms 1 ECE 665 Spring 2004 ECE 665 Spring 2004 Computer Algorithms Binary Decision Diagrams Implementation Issues Slides adopted (with permission) from A. Kuehlmann, UC Berkeley 2003

ECE 665 – Computer Algorithms 2 Outline ROBDD’sROBDD’s TED’sTED’s –Canonical representations Implementation of ROBDD’sImplementation of ROBDD’s –ITE Operator –Unique Table –Computed Table –Garbage collection –Variable ordering Other Decision DiagramsOther Decision Diagrams

ECE 665 – Computer Algorithms 3 ROBDD’s Directed acyclic graph (DAG)Directed acyclic graph (DAG) one root node, two terminals 0, 1one root node, two terminals 0, 1 each node, two children, and a variableeach node, two children, and a variable Shannon co-factoring tree, except reduced and ordered (ROBDD)Shannon co-factoring tree, except reduced and ordered (ROBDD) –Reduced: any node with two identical children is removedany node with two identical children is removed two nodes with isomorphic BDD’s are mergedtwo nodes with isomorphic BDD’s are merged –Ordered: Co-factoring variables (splitting variables) always follow the same order along all pathsCo-factoring variables (splitting variables) always follow the same order along all paths x i 1 < x i 2 < x i 3 < … < x i n

ECE 665 – Computer Algorithms 4 Example Two different orderings, same function. a bb cc d 0 1 c+bd b root node c+d c d f = ab+a’c+bc’d a c d b 01 c+bd d+b b 1 0

ECE 665 – Computer Algorithms 5 ROBDD Ordered BDD (OBDD) Input variables are ordered - each path from root to sink visits nodes with labels (variables) in ascending order. a cc b 0 1 ordered order = a,c,b Reduced Ordered BDD (ROBDD) - reduction rules: 1.if the two children of a node are the same, the node is eliminated: f = vf + vf 2.if two nodes have isomorphic graphs, they are replaced by one of them These two rules make it so that each node represents a distinct logic function. a b c c 0 1 not ordered b

ECE 665 – Computer Algorithms 6  Arithmetic functions (F: Int  Int )  Treat F as a function of integers  Taylor Expansion (around x=0): F(x) = F(0) + x F’(0) + ½ x 2 F’’(0) + …  Notation F(x=0) 0-child F’(x=0) 1-child ½ F’’(x=0) 2-child ====== etc. F(x) = 0-child + x (1-child) + x 2 (2-child)/2 + … F(x) = 0-child + x (1-child) + x 2 (2-child)/2 + … Taylor Expansion Diagram (TED) x F(0) F’(0) F’’(0)/2 … F(x)

7 TED – a few Examples (A+B)(A+2C) 1 0 B C A B x0 x1 x2 x x0 x1 x X 2 = (8x 3 + 4x 2 + 2x 1 + x 0 ) 2

ECE 665 – Computer Algorithms 8 TED: Composition & Manipulation  Analogous to BDD & *BMD, TED:  Requires an ordering of variables  Has to be reduced  Has to be normalized, such that  Reduced Ordered Normalized TED: Canonical!  Composition of TED:  f = g + h; APPLY(+, g, h)  f = g * h; APPLY(*, g, h)  f = g – h; APPLY(+, g, APPLY(*, -1, h))

9 Properties of TED  Canonical  Compact  Linear for polynomials of arbitrary degree  TED for X k, k = const, with n bits, has k(n-1)+1 nodes  *BMD is polynomial in n  Can contain symbolic, word-level, and Boolean variables  It is not a Decision Diagram n = 4, k = 2 1 x0 x1 x2 x x0 x1 x X 2 = (8x 3 + 4x 2 + 2x 1 + x 0 ) 2

ECE 665 – Computer Algorithms 10 ROBDD’s (The Canonical Side) General idea:General idea: –instead of: exploring sub-cases by enumerating them in time store sub-cases in memory –KEY: two hashing mechanisms: –unique table: find identical sub-cases and avoid replication –computed table: reduce redundant computation of sub-cases Representation of a logic function as graph (DAG):Representation of a logic function as graph (DAG): –many logic functions can be represented compactly - usually better than SOP’s Can be made canonical !!Can be made canonical !! –Shift the effort in a Boolean reasoning engine from SAT algorithm to representation Many logic operations can be performed efficiently on BDD’s:Many logic operations can be performed efficiently on BDD’s: –usually linear in size of result - tautology and complement are constant time Size of BDD critically dependent on variable orderingSize of BDD critically dependent on variable ordering

ECE 665 – Computer Algorithms 11 Efficient Implementation of BDD’s Unique Table: avoids duplication of existing nodesavoids duplication of existing nodes –Hash-Table: hash-function(key) = value –identical to the use of a hash-table in AND/INVERTER circuits Computed Table: avoids re-computation of existing resultsavoids re-computation of existing results hash value of key collision chain hash value of key No collision chain

ECE 665 – Computer Algorithms 12 Efficient Implementation of BDD’s BDDs is a compressed Shannon co-factoring tree:BDDs is a compressed Shannon co-factoring tree: f = v f v + v f vf = v f v + v f v leafs are constants “0” and “1”leafs are constants “0” and “1” Three components make ROBDDs canonical (Proof: Bryant 1986):Three components make ROBDDs canonical (Proof: Bryant 1986): –unique nodes for constant “0” and “1” –identical order of case splitting variables along each paths –hash table that ensures: (node(f v ) = node(g v ))  (node(f v ) = node(g v ))  node(f) = node(g)(node(f v ) = node(g v ))  (node(f v ) = node(g v ))  node(f) = node(g) –provides recursive argument that node(f) is unique when using the unique hash- table v 0 1 f fvfv fvfv

ECE 665 – Computer Algorithms 13 Implementation Variables are totally ordered: If v < w then v occurs “higher” up in the ROBDD Top variable of a function f is a variable associated with its root node. Example: f = ab + a’bc + a’bc’. Order is (a < b < c). f a = b, f  a = b a b 01 f b is top variable of f b 01 f reduced f does not depend on a, since f a = f  a. Each node is written as a triple: f = (v,g,h) where g = f v and h = f  v. We read this triple as: We read this triple as: f = if v then g else h = ite (v,g,h) = vg+v ’ h v f 01 h g 10 f v g h mux v is top variable of f

ECE 665 – Computer Algorithms 14 ITE Operator ITE operator can implement any two variable logic function. There are 16 such functions corresponding to all subsets of vertices of B 2 : TableSubset Expression Equivalent Form AND(f, g) fgite(f, g, 0) 0010f > g f  gite(f,  g, 0) 0011f ff 0100f < g  fgite(f, 0, g) 0101g gg 0110XOR(f, g) f  gite(f,  g, g) 0111OR(f, g) f + gite(f, 1, g) 1000NOR(f, g) f + gite(f, 0,  g) 1001 XNOR(f, g) f  g ite(f, g,  g) 1010NOT(g)  gite(g, 0, 1) 1011f  g f +  gite(f, 1,  g) 1100NOT(f)  fite(f, 0, 1) 1101f  g  f + gite(f, g, 1) 1110NAND(f, g) fg ite(f,  g, 1)

ECE 665 – Computer Algorithms 15 Unique Table - Hash Table Before a node (v, g, h ) is added to BDD data base, it is looked up in the “unique-table”. If it is there, then existing pointer to node is used to represent the logic function. Otherwise, a new node is added to the unique-table and the new pointer returned.Before a node (v, g, h ) is added to BDD data base, it is looked up in the “unique-table”. If it is there, then existing pointer to node is used to represent the logic function. Otherwise, a new node is added to the unique-table and the new pointer returned. Thus a strong canonical form is maintained. The node for f = (v, g, h ) exists iff(v, g, h ) is in the unique-table. There is only one pointer for (v, g, h ) and that is the address to the unique-table entry.Thus a strong canonical form is maintained. The node for f = (v, g, h ) exists iff(v, g, h ) is in the unique-table. There is only one pointer for (v, g, h ) and that is the address to the unique-table entry. Unique-table allows single multi-rooted DAG to represent all users’ functions:Unique-table allows single multi-rooted DAG to represent all users’ functions: hash index of key collision chain

ECE 665 – Computer Algorithms 16 Recursive Formulation of ITE v = top-most variable among the three BDD’s f, g, h

ECE 665 – Computer Algorithms 17 Computed Table Keep a record of (F, G, H ) triplets already computed by the ITE operator –software cache ( “cache” table) –simply hash-table without collision chain (lossy cache)

ECE 665 – Computer Algorithms 18 Extension - Complement Edges Combine inverted functions by using complemented edge –similar to circuit case –reduces memory requirements –BUT MORE IMPORTANT: makes some operations more efficient (NOT, ITE)makes some operations more efficient (NOT, ITE) 01 G GG only one DAG using complement pointer 01 G 01 GG two different DAGs

ECE 665 – Computer Algorithms 19 Extension - Complement Edges To maintain strong canonical form, need to resolve 4 equivalences: VV VV VV VV Solution: Always choose one on left, i.e. the “then” leg must have no complement edge.

ECE 665 – Computer Algorithms 20 Ambiguities in Computed Table Standard Triples: ite(F, F, G )  ite(F, 1, G ) ite(F, G, F )  ite(F, G, 0 ) ite(F, G,  F )  ite(F, G, 1 ) ite(F,  F, G )  ite(F, 0, G ) To resolve equivalences:ite(F, 1, G )  ite(G, 1, F ) ite(F, 0, G )  ite(  G, 1,  F ) ite(F, G, 0 )  ite(G, F, 0 ) ite(F, G, 1 )  ite(  G,  F, 1 ) ite(F, G,  G )  ite(G, F,  F ) To maximize matches on computed table: 1. First argument is chosen with smallest top variable. 2. Break ties with smallest address pointer. (breaks PORTABILITY!!!!!!!!!!) Triples: ite(F, G, H )  ite (  F, H, G )  ite (F,  G,  H)  ite (  F,  H, G) Choose the one such that the first and second argument of ite should not be complement edges(i.e. the first one above).

ECE 665 – Computer Algorithms 21 Use of Computed Table Often BDD packaged use optimized implementations for special operationsOften BDD packaged use optimized implementations for special operations –e.g. ITE_Constant (check whether the result would be a constant) –AND_Exist (AND operation with existential quantification) All operations need a cache for decent performanceAll operations need a cache for decent performance –local cache for one operation only - cache will be thrown away after operation is finished (e.g. AND_Existfor one operation only - cache will be thrown away after operation is finished (e.g. AND_Exist keep inter-operational (ITE, …)keep inter-operational (ITE, …) –special cache for each operation does not need to store operation typedoes not need to store operation type –shared cache for all operations better memory handlingbetter memory handling needs to store operation typeneeds to store operation type

ECE 665 – Computer Algorithms 22 Variable Ordering Static variable orderingStatic variable ordering –variable ordering is computed up-front based on the problem structure –works very well for many combinational functions that come from circuits we actually build general scheme: control variables firstgeneral scheme: control variables first DFS order is pretty good for most casesDFS order is pretty good for most cases –work bad for unstructured problems e.g. using BDDs to represent arbitrary setse.g. using BDDs to represent arbitrary sets –lots of research in ordering algorithms simulated annealing, genetic algorithmssimulated annealing, genetic algorithms give better results but extremely costlygive better results but extremely costly

ECE 665 – Computer Algorithms 23 Dynamic Variable Ordering Changes the order in the middle of BDD applicationsChanges the order in the middle of BDD applications –must keep same global order Problem: External pointers reference internal nodes!!!Problem: External pointers reference internal nodes!!! BDD Implementation:... External reference pointers attached to application data structures

ECE 665 – Computer Algorithms 24 Dynamic Variable Ordering Theorem (Friedman): Permuting any top part of the variable order has no effect on the nodes labeled by variables in the bottom part. Permuting any bottom part of the variable order has no effect on the nodes labeled by variables in the top part. Trick: Two adjacent variable layers can be exchanged by keeping the original memory locations for the nodesTrick: Two adjacent variable layers can be exchanged by keeping the original memory locations for the nodes a bb c ccc f f0f0 f1f1 f 00 f 01 f 10 f 11 mem 1 mem 2 mem 3 b b b c ccc f f0f0 f1f1 f 00 f 01 f 10 f 11 a a mem 1 mem 2 mem 3

ECE 665 – Computer Algorithms 25 Dynamic Variable Ordering BDD sifting:BDD sifting: –shift each BDD variable to the top and then to the bottom and see which position had minimal number of BDD nodes –efficient if separate hash-table for each variable –can stop if lower bound on size is worse then the best found so far –shortcut: two layers can be swapped very cheaply if there is no interaction between themtwo layers can be swapped very cheaply if there is no interaction between them –expensive operation, sophisticated trigger condition to invoke it grouping of BDD variables:grouping of BDD variables: –for many applications, pairing or grouping variables gives better ordering e.g. current state and next state variables in state traversale.g. current state and next state variables in state traversal –grouping them for sifting explores ordering that are otherwise skipped

ECE 665 – Computer Algorithms 26 Garbage Collection Very important to free and ruse memory of unused BDD nodesVery important to free and ruse memory of unused BDD nodes –explicitly free’d by an external bdd_free operation –BDD nodes that were temporary created during BDD operations Two mechanism to check whether a BDD is not referenced:Two mechanism to check whether a BDD is not referenced: –Reference counter at each node increment whenever node gets one more reference (incl. External)increment whenever node gets one more reference (incl. External) decrement when node gets de-references (bdd_free from external, de- reference from internal)decrement when node gets de-references (bdd_free from external, de- reference from internal) counter-overflow -> freeze nodecounter-overflow -> freeze node –Mark and Sweep algorithm does not need counterdoes not need counter first pass, mark all BDDs that are referencedfirst pass, mark all BDDs that are referenced second pass, free the BDDs that are not markedsecond pass, free the BDDs that are not marked need additional handle layer for external referencesneed additional handle layer for external references

ECE 665 – Computer Algorithms 27 Garbage Collection Timing is very crucial because garbage collection is expensiveTiming is very crucial because garbage collection is expensive –immediately when node gets free’ed bad because dead nodes get often reincarnated in next operationbad because dead nodes get often reincarnated in next operation –regular garbage collections based on statistics collected during BDD operations –“death row” for nodes to keep them around for a bit longer Computed table must be cleared since not used in reference mechanismComputed table must be cleared since not used in reference mechanism Improving memory locality and therefore cache behavior:Improving memory locality and therefore cache behavior: –sort free’ed BDD nodes to

ECE 665 – Computer Algorithms 28 BDD Derivatives MDD: Multi-valued BDDsMDD: Multi-valued BDDs –natural extension, have more then two branches –can be implemented using a regular BDD package with binary encoding advantage that binary BDD variables for one MV variable do not have to stay together -> potentially better orderingadvantage that binary BDD variables for one MV variable do not have to stay together -> potentially better ordering ADDs: (Analog BDDs) MTBDDsADDs: (Analog BDDs) MTBDDs –multi-terminal BDDs –decision tree is binary –multiple leafs, including real numbers, sets or arbitrary objects –efficient for matrix computations and other non-integer applications FDDs: Free BDDsFDDs: Free BDDs –variable ordering differs –not canonical anymore and many more …..and many more …..