Representing integer multiplication using BDDs
Håvard Raddum and Srimathi Varadharajan Simula@UiB
Representing integer multiplication using BDDs Hvard Raddum and - - PowerPoint PPT Presentation
Representing integer multiplication using BDDs Hvard Raddum and Srimathi Varadharajan Simula@UiB What is a BDD? Can be defined and understood in different ways Only one description given here BDD explained A BDD is a directed acyclic
Håvard Raddum and Srimathi Varadharajan Simula@UiB
Can be defined and understood in different ways Only one description given here
A BDD is a directed acyclic graph, drawn from top to bottom
1 2 4 3 5 6
Every node can have two outgoing edges, the 0-edge and the 1-edge
1
d g e 1
d g e
3 2
Nodes are arranged in horizontal levels
1 6 5 4 3 2 7 8 9
Level i Level i+1 Level i+2
No edges between nodes on same level
Only one node on highest and lowest levels
T
Top node, source node Bottom node, sink node
1 6 5 4 3 2 7 8 9
x1+x5 x2 x0+x2+x3+x6
Linear combination of variables associated with each level, except bottom level
Other descriptions: only single variables associated with levels
1 1 1 1 1 1
Values in path assigned to linear combinations associated with levels
x1 + x2 = 1 x0 + x2 + x3 = 0 x2 + x3 = 0
How to construct multiplication BDD?
1 2 n-1 n n+1 2n-2 columns Column k consists of all terms piqj where i+j=k Column k contributes 2k∑piqj to the value of N
column 0
variable pi, qj appearing in column k Basic building block: pi qj piqj=0 piqj=1
1
p0 q0 p0q0=0 p0q0=1 keep track of value of N computed so far
When construction of column k is complete, delete nodes with values inconsistent with Nk
1
p0 q0 N=…011
N=…011
1 3 1
p0 q0
col 0
p0 p1 q0 q1
col 1
3 1 5
col 2
1
p0 q0
1 3 3
p0 p1 q0 q1
col 0 col 1 col 2
3
N=…011
3 7 7 3 11 7 3 11 15
col 2
p0 q2 p1 p2 q1 q0
col 3
3
col 2
3 7 7 3 11 3 11
p0 q2 p1 p2 q1 q0
col 3
col k-1
v v+2k v+t*2k v v+2k v+2*2k v+t*2k v+(t+1)*2k v v+2k v+2*2k v+(s-1)*2k v+s*2k
col k col k+1
pi qj
col 2n-3
v v+22n-2 v+t*22n-2 v v+22n-2 v+2*22n-2 v+t*22n-2 v+(t+1)*22n-2
pn-1 qn-1
col 2n-2
Only keep node with value N. This becomes the bottom node of the BDD
891 nodes > 2110 paths N=31439
How to find values of p and q?
BDD will always be
1
p0 q0 The two top levels give p0=q0=1 Fix p0=q0=1 in whole BDD by deleting 0-edges going out from levels with p0 or q0
p1 q1 p2 p1 q1 q2
Gives p1=q1 Replace q1 with p1
Depending on value of N, some more linear equations can be extracted from top of BDD
x y x y
x x x
whole BDD:
levels get equal variables
qj such that pq=N
p=211 and q=149
p=149 and q=211 Only two paths remain Number of nodes in BDD was never above 891 during solving
p0 p1 p2 p3 p4 p5 p6 p7 q0 q1 q2 q3 q4 q5 q6 q7
algorithm has complexity ≈ √N ≈ 2n, measured as maximum number of nodes in BDD during solving
tricks
All levels with p4 merged and moved to the top
p4
p4
All levels with q7 merged and moved to the top
q7 p0 q0
q6 p5 q5 p6 q4 p7 q3 p5 q6 p6 q5 p7 q4 p6 q6 p7 q5 p7 q6
q7=0 ⇓ q6=1 p5=1 q5=1 p6=1 q4=1 p7=1 q3=1