Abstract A classical problem in logic synthesis is
Abstract A classical problem in logic synthesis is to find a sum-of-product (SOP) Boolean expression with the minimum number of product terms that implements a Boolean function. In this work, we focus on a related yet different synthesis problem targeted toward probabilistic computation. In our scenario, we want to synthesize a Boolean function that covers an exact number of minterms, say m minterms. This is the only requirement; which m minterms are covered does not matter. The objective is to find a SOP Boolean expression with the minimum number of product terms with this property. Solving this problem provides a solution to the problem of generating arbitrary probability values from unbiased input probabilities values of 0. 5 with combinational logic. Two-Level Logic Synthesis for Probabilistic Computation We first show a method for constructing a set of product terms to cover exactly m minterms; this gives an upper bound. Then, as our major contribution, we propose a method for deriving a lower bound. We show that the problem of finding such a lower bound can be converted into an optimization problem which we call the optimal subtraction problem. We solve it with dynamic programming. Experiments on benchmarks show that for some numbers m, the lower bound meets the upper bound, indicating that the solution corresponding to the upper bound is optimal. For some other numbers m, the gap between the lower bound and the upper bound is small, indicating that the solution corresponding to the upper bound is nearly optimal. Weikang Qian and Marc D. Riedel ECE Department, University of Minnesota Probabilistic Computation What is it? Problem: A Special One Why need it? • Digital circuit operating on random bit streams P(x = 1) = 0. 4 0, 1, 0, 0, 1, 1, 0, 0 How to design it? • In test: Weighted random pattern generation Stochastic Bit Streams: Probability 3/6 P(z = 1) = 0. 2 Probability Generator … 0, 0, 0, 1, 0, 0, 0 1, 0, 1, 1, 0, 0, 1 P(y = 1) = 0. 5 p 1 0, 1, 1, 0 Random Sources Deterministic Hardware p 2 Digital Circuit p 3 Ultimate Question: Given number of inputs n and integer m, find a SOP expression with the minimum number of products to cover m minterms. Optimization Flow λ = Lower bound on the number of cubes to cover m minterms Exists λ cubes to cover m interms? Focus of this work Definitions and Preliminaries • V( f ): number of minterms covered by f • B(m): number of ones of binary number m • B((1011)2) = 3 • Boolean product, also known as cube, denoted by c • If cube c contains k literals, V(c) = 2 n − k • • How to count number of minterms? Y q ? Upper Bound Theorem 2: If there exists λ cubes to cover m minterms, then we can find a, b ≥ 0 such that: m = a − b; B(a) ≤ 2λ − 1; B (b) ≤ 2λ − 1 Theorem 1: If B(m) = λ, then an upper bound is λ Proof: • • Synthesize cubes so that cube ck has n − ik literals and cubes ck and cl are disjoint, for any 0 ≤ k < l ≤ λ − 1. Proof: • In equation of Inclusion-Exclusion Principle, put “plus” terms together to get a; put “minus” terms together to get b • We can show B(a) ≤ 2λ − 1, B (b) ≤ 2λ − 1 • m = a − b Mutually Disjoint Lower bound is the minimum λ satisfying the above property λ=λ+1 Generalization of Optimal Subtraction Problem Case 1: 0 & carry 0 (… 000 mk …m 0)2 + (… ? ? ? b*k…b*0)2 Case 2: 0 & carry 1 (… 000 mk …m 0)2 + (… ? ? ? b*k…b*0)2 Carry 0 Then, ? ? ? = 000 Carry 1 Then, ? ? ? = 000 or 111 Case 3: 1 & carry 0 (… 111 mk …m 0)2 + (… ? ? ? b*k…b*0)2 Case 4: 1 & carry 1 (… 111 mk …m 0)2 + (… ? ? ? b*k…b*0)2 Carry 0 Then, ? ? ? = 000 or 001 Carry 1 Then, ? ? ? = 000 • Given m = (md…m 0)2, 0 ≤ i ≤ d, l, ξ in {0, 1}, define problem Q(i, l, ξ) as: Find a, b ≥ 0 to minimize B(a) such that • B(b) ≤ l • a = (md…mi)2 + b + ξ • Optimal solution a*(i, l, ξ) and b*(i, l, ξ). • Optimal cost: A(i, l, ξ) = B(a*(i, l, ξ)) Optimal Subtraction Problem: Q(0, t, 0) Optimal Structure of Problem Q Q(i, l, 0) Q(j, l, 0) Case (mj − 1…mi) = (1… 1) Q(i, l, 1) Q(j, l, 0) Q(i, l, 1) Q(j, l, 1) (A(i, l, 1) = min{A(j, l, 0) + 1, A(j, l − j + i, 1)}) • Treat m as alternating zeros and ones: Exist 0 = i 0 < i 1 < • • • < i 2 q = d + 1 • m[i 2 r + 1 − 1, i 2 r] = (1… 1), m[i 2 r + 2 − 1, i 2 r + 1] = (0… 0) Case: m[i 2 r + 2 − 1, i 2 r + 1] = (0… 0) m[i 2 r + 1 − 1, i 2 r] = (1… 1) Case: m[i 2 r + 1 − 1, i 2 r] = (1… 1) m[i 2 r − 1, i 2 r − 1] = (0… 0) Q(i 2 r, l, 0) Q(i 2 r − 1, l, 1) Q(i 2 r + 1, l, 0) Q(j, l − 1, 1) (A(i, l, 0) = min{A(j, l, 0) + j − i, A(j, l − 1, 1)}) Q(i 2 r + 1, l − 1, 1) Q(i 2 r, l, 0) A(i 2 r, l, 0) = min{A(i 2 r + 1, l − 1, 1), A(i 2 r + 2, l, 0) + i 2 r + 1 − i 2 r} Q(0, t, 0) Q(i 2 r, l − i 2 r + i 2 r − 1, 1) Q(i 2 r + 1, l − i 2 r + i 2 r − 1, 1) Q(i 2 r + 2, l, 0) A(i 2 r − 1, l, 1) = min{A(i 2 r, l, 0) + 1, A(i 2 r + 1, l − i 2 r + i 2 r − 1, 1)} 1 1 1 1 1 Example: m = (101101)2 Optimal Subtraction Problem a − b = (101101)2 Given m, t ≥ 0, find a, b ≥ 0 to minimize B(a) such that • B(b) ≤ t • m = a − b λ=2 X • B(a) ≤ 2λ − 1 = 2 • B(b) ≤ 2λ − 1 = 1 • No solution! Find lower bound by solving optimal subtraction problem: • Set t = 2λ − 1 • If min B(a) > 2λ − 1, then lower bound > λ λ=3 • B(a) ≤ 2λ − 1 = 4 • B(b) ≤ 2λ − 1 = 3 • a = (110001)2, b = (100)2 Lower bound: λ = 3 Q(i 2, t 2, 0) Q(i 1, t 1, 1) • • • Q(i 2 q − 4, t 2 q − 4, 0) Q(i 3, t 3, 1) • • • Q(i 2 q − 3, t 2 q − 3, 1) Optimal Cost Table T • T(2 r, l) = A(i 2 r, l, 0) • T(2 r − 1, l) = A(i 2 r − 1, l, 1) 2 q − 1 2 q − 2 2 q − 3 2 q − 4 ⁞ 0 0 1 y * * ⁞ * 1 1 1 * * ⁞ * 2 1 1 * * ⁞ * … … … ⁞ … t 1 1 * * ⁞ * • Base Case: • T(2 q − 1, *) and T(2 q − 2, *) • General Cases: Recursive Relation Q(j, l, 0) Q(i, l, 0) Q(j, l − j + i, 1) 1 Solving Optimal Subtraction Problem by Dynamic Programming Optimization Problem Q Case (mj − 1…mi) = (0… 0) 1 Lower Bound and Optimal Subtraction Problem (OSP) N (a*, b* denotes optimal solution) 1 • Each input combination has probability 1/2 n • If the Boolean function has m minterms, then q = m/2 n end Observation of Optimal Solution of OSP 1 Question 1: What could q be? Answer: q = m/2 n Example: m = (1011)2, n = 4 Inclusion-Exclusion Principle Combinational Logic Question 2: How to implement q = m/2 n? Answer: choose m minterms, BUT … A Hard Question: Which m minterms to choose? Example: q = 7/16 0. 5 ? Probability 4/6 Two-Level Logic Synthesis 0. 5 q 1 q 2 q 3 q 4 1, 1, 0, 1 P(z = 1) = P(x = 1) P(y = 1) 0. 5 Other Probabilities Needed Input Probabilities • Hardware implementation of probabilistic algorithm • Transform probabilities into probabilities Independent Q(i 2 q − 2, t 2 q − 2, 0) Q(i 2 q − 1, t 2 q − 1, 1) • T(2 r, l) = min{T(2 r + 1, l − 1), T(2 r + 2, l) + i 2 r + 1 − i 2 r} • T(2 r − 1, l) = min{T(2 r, l) + 1, T(2 r + 1, l − i 2 r + i 2 r − 1)} Example: m = (01100101111)2, t = 3 0 1 2 3 3 4 7 5 4 3 2 1 0 1 1 1 2 2 3 4 2 1 1 1 2 2 3 3 1 1 1 2 • 2 q = 6 • i 0 = 0, i 1 = 4, i 2 = 5, i 3 = 6, i 4 = 8, i 5 = 10 Optimal Cost: 2 Optimal Solution: • b* = (10001)2 • a* = (1000000)2 Experimental Results on modified Espresso benchmarks: circuit newapla 1 exp shift newcond in 2 in 1 bca x 1 dn ts 10 #cubes #inputs 6 14 21 28 30 55 72 80 128 12 8 19 11 19 16 26 27 22 #minterms (hex) 109 59 7 FF 01 288 66950 6900 94000 49 E 0 D 80 7 FFF 8 lower bound 3 3 2 3 4 3 3 3 2 upper bound 3 4 12 3 8 4 3 10 16 Upper Bound Optimal!
- Slides: 1