Minimization Techniques for Reversible Logic Synthesis Outline • • • • • • • Why reversible logic? The building blocks The synthesis problem Some solutions Optimization Finding identities Remaining problems Reversible Logic Synthesis Slide 2 Reversible Logic inputs circuit network outputs • from the output you can determine the input (bijection) • Why would we want this? • Landauer's principle: every bit of information lost consumes energy kT ln2 • k is the Boltzman constant • T is the temperature 21 Synthesis Logic 2.9 10 Joule • energy loss is small Reversible Slide 3 Applications • Quantum Computing – necessarily reversible • Low power CMOS – In adiabatic circuits, current is restricted to flow across devices with low voltage drop and the energy stored on their capacitors is recycled • Optical Computing • Nano-technologies – Billiard Ball Model (BBM) Reversible Logic Synthesis Slide 4 Standard Gates • which ones are reversible? and not Embedding a non-reversible function into a reversible one How many ways? xor or Reversible Logic Synthesis Slide 5 Reversible Gates • Feynman gate (controlled not) x x y x y • Toffoli gate x x y y z xy z Synthesis • Generalized ToffoliReversible gateLogic more control lines Slide 6 Reversible Gates • Fredkin gate (controlled swap) x x y yx’ + zx z zx’ + yx • Generalized Fredkin gate more control lines Reversible Logic Synthesis Slide 7 Restrictions • No fan-out • No back-feeds Reversible Logic Synthesis Slide 8 Restrictions • No fan-out • No back-feeds Cascade of Gates inputs g1 g2 … gi gi+1 … gn-1 gn Reversible Logic Synthesis output Slide 9 Function Representation • How do we represent a reversible function? – truth table – BDDs • Is there an easy check to see that the function is reversible? Reversible Logic Synthesis Slide 10 Synthesis • Given a reversible function find a network of gates that realize the function • Cost should be near minimal • Possible cost assumptions: – Each gate has the same cost – The cost of each gate reflects its actual implementation cost Reversible Logic Synthesis Slide 11 Approach 1 inputs Reversible transformation Reversible Logic Synthesis outputs Slide 12 Approach 1 Reversible Transformation T1 inputs inputs G A T E Reversible Transformation T2 Reversible Logic Synthesis outputs outputs Slide 13 Conditions • T2 should be “simpler” than T1 • How do you measure simplicity? – Hamming distance – Spectral techniques • Questions: – Will it converge? – How good is the result? • Improvements – Look ahead – Backtracking Reversible Logic Synthesis Slide 14 Approach 2 Input 000 001 010 011 100 101 110 111 Output 000 001 100 011 111 101 010 110 Reversible Logic Synthesis Slide 15 Approach 2 Input 000 001 010 011 100 101 110 111 Output 000 001 100 011 111 101 010 110 These are correct Reversible Logic Synthesis Slide 16 Approach 2 Input 000 001 010 011 100 101 110 111 Output 000 001 100 011 111 101 010 110 These are correct Step 1: move up 100 to 110 Reversible Logic Synthesis Slide 17 Approach 2 Input 000 001 010 011 100 101 110 111 Output 000 001 100 011 111 101 010 110 These are correct Step 1: move up 100 to 110 a a b b c c Reversible Logic Synthesis Slide 18 Approach 2 Input 000 001 010 011 100 101 110 111 Output 000 001 100 011 111 101 010 110 These are correct Step 1: move up 100 to 110 a a b b c c Reversible Logic Synthesis Slide 19 Approach 2 Input 000 001 010 011 100 101 110 111 Output 000 001 100 011 111 101 010 110 These are correct Step 1: move up 100 to 110 a a b b c c Reversible Logic Synthesis Input 000 001 010 011 100 101 110 111 Output 000 001 110 011 101 111 010 100 Slide 20 Approach 2 Input 000 001 010 011 100 101 110 111 Output 000 001 110 011 101 111 010 100 These are correct Step 2: move down 110 to 010 Reversible Logic Synthesis Slide 21 Approach 2 Input 000 001 010 011 100 101 110 111 Output 000 001 110 011 101 111 010 100 These are correct Step 2: move down 110 to 010 a a b b c c Reversible Logic Synthesis Slide 22 Approach 2 Input 000 001 010 110 100 101 110 111 Output 000 001 110 011 101 111 010 100 These are correct Step 2: move down 110 to 010 a a b b c c Reversible Logic Synthesis Input 000 001 010 011 100 101 110 111 Output 000 001 010 111 101 011 110 100 Slide 23 Approach 2 Input 000 001 010 011 100 101 110 111 Output 000 001 110 011 101 111 010 100 Step 2: move down 110 to 010 a a b b c c Reversible Logic Synthesis Input 000 001 010 011 100 101 110 111 Output 000 001 010 111 101 011 110 100 Slide 24 Approach 2 Input 000 001 010 011 100 101 110 111 Output 000 001 010 111 101 011 110 100 Reversible Logic Synthesis Slide 25 Approach 2 Input 000 001 010 011 100 101 110 111 Output 000 001 010 111 101 011 110 100 c c b b a a Reversible Logic Synthesis Slide 26 Advantages/Disadvantages • • • • • • Always converges Fast No look ahead Several optimizations are possible May not be optimal Worst case? Reversible Logic Synthesis Slide 27 Approach 3 • Local transformation • Replace a sequence of gates with another • For example replace 3 gates with 2 Reversible Logic Synthesis Slide 28 Reversible Logic Synthesis Slide 29 Approach 3 • Use Identity circuits for local transformations inputs g1 g2 … gi gi+1 … gn-1 gn Reversible Logic Synthesis identity Slide 30 Approach 3 inputs g1 g2 … gi gi+1 … gn-1 gn identity F-1(X) F(X) Reversible Logic Synthesis Slide 31 Approach 3 inputs g1 g2 … gi gi+1 … gn-1 gn identity F-1(X) F(X) Replace this sequence of gates Reversible Logic Synthesis Slide 32 Approach 3 inputs g1 g2 … gi gi+1 … gn-1 gn identity F-1(X) F(X) with this sequence of gates Replace this sequence of gates Reversible Logic Synthesis Slide 33 Template Description • As a class - an identity that is not reducible by another template • A template may be rotated • A template may be applied in reverse order • Size 2 ==> Duplicate gates (may be deleted) • Size 3 ==> There are none • Size 4 ==> Passing rule Reversible Logic Synthesis Slide 34 Template Class — Size 5 A line may be duplicated A line may be removed Reversible Logic Synthesis Slide 35 How many classes of identities are there? Size Identities Classes 1 0 2 1 3 0 4 2 5 1 6 3 7 2 8 16 9 56 Reversible Logic Synthesis Slide 36 The Templates: Application Reversible Logic Synthesis Slide 37 The quest for identities • Exhaustive searches are not feasible • A feasible approach (to find size n identities): – Find all functions of size n/2 • With limited number of lines • With some canonical order – Pair each function with its inverse – If no reduction is possible ==> we found a new template Reversible Logic Synthesis Slide 38 A new approach • Start with an identity that has target lines only • For any subset of gates that preserve the identity a new control line may be added • Example: Reversible Logic Synthesis Slide 39 Recent Advances • Automatic template encoding • Application of iterative minimization heuristics • Progress in calculating “real quantum cost” – Using gates NOT, CNOT, V, and V+ – Quantum templates • Using SAT to find exact results Reversible Logic Synthesis Slide 40 Future Work • Handling don’t cares (can be done with SAT) • Billiard ball implementation of reversible circuits (via cellular arrays) • Better representation for reversible functions – Truth table is not adequate – Some form of BDD (possibly Davio) • Minimization with aid of group theory Reversible Logic Synthesis Slide 41