1 / 50

Reversible Logic Circuit Synthesis

Reversible Logic Circuit Synthesis. Vivek V. Shende, Aditya K. Prasad, Igor L. Markov and John P. Hayes University of Michigan. Outline. Motivation Real-world Applications Theoretical Advantages Links to Quantum Computation Background Theoretical Results Synthesis of Optimal Circuits

Download Presentation

Reversible Logic Circuit Synthesis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Reversible Logic Circuit Synthesis Vivek V. Shende, Aditya K. Prasad, Igor L. Markov and John P. Hayes University of Michigan

  2. Outline • Motivation • Real-world Applications • Theoretical Advantages • Links to Quantum Computation • Background • Theoretical Results • Synthesis of Optimal Circuits • An Application to Quantum Computing

  3. Real-world Applications • Many inherently reversible applications • Info. is re-coded, but none is lost or added • Digital signal processing • Cryptography • Communications • Computer graphics • Network congestion modeling

  4. Theoretical Advantages • Information conservation laws in physics • Thermodynamics ties irreversibility to dissipated heat: every lost bit causes an energy loss • C. Bennett, 1973, IBM J. of R & D • Energy-lossless circuits (Time  ∞ ) • must be information-lossless • have been built:S. Younis and T. Knight, 1994, Workshop on Low Power Design

  5. Links to Quantum Computation • Quantum operations are all reversible • M. Nielsen and I. Chuang, Quantum Computation and Quantum Information, Cambridge Univ. Press 2000 • Every (classical) reversible circuit may be implemented in quantum technology, with overhead • “Pseudo-classical” subroutines of quantum algos • Can be implemented in classical reversible logic circuits • S. Betteli, L. Serafini, and T. Calarco, 2001, http://xxx.lanl.gov/abs/cs.PL/0103009

  6. Outline • Motivation • Background • Reversibility • Permutations • Known Facts • Theoretical Results • Synthesis of Optimal Circuits • An Application to Quantum Computing

  7. Reversibility in Logic Gates • Definition: reversible logic gate • #input wires = #output wires • Permutes the set of input values • Examples • Inverter • 2-input, 2-output SWAP (S) gate • k-CNOT gate • (k+1)-inputs and (k+1)-outputs • Values on the first k wires are unchanged • The last value is flipped if the first k were all 1

  8. Reversibility in Logic Circuits • Definition:A combinational logic circuit is reversible iff • It contains only reversible gates • It has no fan-out • It is acyclic (as a directed multi-graph) • Theorem:A reversible circuit must • Have as many input wires as output wires • Permute the set of input values

  9. A Reversible Circuit and Truth Table Equivalent to a single CNOT gate

  10. Circuit Equivalences • Circuit equivalences: useful in synthesis • More will be shown later

  11. Reversible Circuits & Permutations • A reversible gate (or circuit) with n inputs and n outputs has • 2n possible input values • 2n possible output values • The function it computes on this set must, by definition, be a permutation • The set of such permutations is called S2n

  12. Basic Facts About Permutations • Permutations are multiplied by first applying one, then the other • example: (1,2)◦(2,3) = (1,3,2) • A transposition • permutes exactly two elements • does not change any others • Every permutation can be writtenas a product of transpositions

  13. Even Permutations • Consider all possible decompositionsof a permutation into transpositions • Theorem: The parity of the numberof transpositions is constant • Definition: Even permutations are those for which the number of transpositions is even

  14. Known Facts • Fact 1: Consider a reversible circuit • n+1 inputs and n+1 outputs • Built from gates which have at most n inputs and n outputs • Must compute an even permutation • Fact 2: A universal gate library • CNOT, NOT, and TOFFOLI (“CNT”) • Temporary storage may be required

  15. Temporary Storage

  16. Outline • Motivation • Background • Theoretical Results • Zero-storage Circuits • Reversible De Morgan’s Laws • Synthesis of Optimal Circuits • An Application to Quantum Computing

  17. Minimizing Temporary Storage • Consider CNT circuits • Theorem: even permutations computableby circuits without temporary storage • Theorem: odd permutations computablewith one line of temporary storage • Same holds for NT- and CNTS-circuits • The proof is constructive and may be used as a synthesis heuristic

  18. C- and N-circuits • N-circuits need at most one gate per wire • Can cancel inverters • C-circuits on k wires act as k × k matrices • By reversibility, the matrix must be invertible • A C(x,y) gate is a row-addition matrix which adds the x-th row to the y-th • Can get all invertible matrices

  19. T-circuits • T-circuits fix 0, 2i • These have only one 1 in their binary expansion • T-circuits on 4+ wires compute even perms. • In fact, any circuit in which no gate involves all the wires computes an even permutation • T. Toffoli, "Reversible Computing", Tech. Memo MIT/LCS/TM-151, MIT Lab for Comp. Sci, 1980. • Any permutation satisfying the above constraints can be computed in a T-circuit

  20. T-circuits • Assume #wires > 3 • Decompose an even permutation into a product of disjoint transpositions • (a,b)(c,d) is okay, (a,b)(b,c) is not • But (a,b)(b,c) = [(a,b)(d,e)] [(d,e)(b,c)] • Explicitly construct a circuit to computean arbitrary pair of disjoint transpositions

  21. Computing Disjoint Trans. Pairs • Use an (n-2) generalized Toffoli gate on n wires • Can compute z = (2n-1, 2n-2)(2n-3, 2n-4) • Can be simulated by T gates (no temporary storage) • A. Barenco et al.: ``Elementary Gates For Quantum Computation'', Physi. Review A (52), 3457-3467, 1995 • Can compute a permutation p sending: • a→2n-1, b→2n-2, c→2n-3, d→2n-4 • Use these constructions to compute a given pair of disjoint transpositions • p-1zp = (a,b)(c,d)

  22. CT|N-circuits • A CT|N-circuit is a CNT-circuit with all the N gates at the right end • To convert a CNT-circuit into CT|N form • Write down rules for interchanging N gates with C and T gates • Push all the N gates to the end • Like pushing inverters to the front of (irreversible) AND/OR/NOT-circuits

  23. Reversible De Morgan’s Laws

  24. T|C-circuits • Similar rules exist for interchanging TOFFOLI and CNOT gates

  25. Reversible De Morgan’s Laws (2)

  26. T|C-circuits • However, it is not always possibleto push all C gates to the inputs • A T|C-circuit’s permutation must fix 0, and map the elements 2i to linearly independent vectors • Recall: T-circuits fix 0, 2i, and C-circuits compute invertible linear transformations • A permutation can be computed by a T|C-circuit if it satisfies the above requirements • The permutation (1,2)(3,4) does not • We will see that it can be computed by a CT-circuit

  27. T|C|T-circuits • Given any even permutation fixing zero • Can multiply it by an even permutation fixing 0, 2iso that the product fixes 0, and takes inputs 2i to linearly independent outputs • A T-circuit can simulate the former • A T|C circuit can simulate the latter • So, any zero-fixing even permutation can be computed by a T|C|T-circuit

  28. T|C|T|N-circuits • Let p be an even permutation • There is an N-circuit taking 0 to p(0) • Unique up to canceling redundant gates • Say this N-circuit computes the permutation n • The permutation pn-1 fixes 0, and can be computed by a T|C|T-circuit P’ • Then the circuit P’N computes p • Theorem: any even permutation can be computed by a T|C|T|N-circuit

  29. Comments on Circuit Length • For “long” CNT-circuits, this algorithm produces circuits which are suboptimal by at worst a logarithmic factor (in the number of wires) • Converting a CNT-circuit to a CT|N-circuit increases circuit size by about a factor of 3 • We do not know any good algorithm to convert CNT-circuits to T|C|T|N-circuits, or even if this conversion may be done with polynomial length increase

  30. Outline • Motivation • Background • Theoretical Results • Synthesis of Optimal Circuits • Optimality • DFID Search Algorithm • Circuit Libraries • An Application to Quantum Computing

  31. Optimality • The cost of a circuit is its gate count • Other cost functions can be considered • Definition:optimal reversible circuit • no circuit with fewer gates computes the same permutation • Theorem: a sub-circuit of an optimal circuit is optimal • Proof: otherwise, can improve the sub-circuit

  32. The Search Procedure • Depth First Iterative Deepening Search • Checks all possible circuits of cost 1, then all possible circuits of cost 2, etc… • Avoids the memory blowup of BFS • Still finds optimal solutions (unlike DFS) • Checking circuits of cost less than n • Is much faster than processing cost-n circuits

  33. Dynamic Prog + Circuit Libraries • DFID search requires a subroutine to checkall circuits of cost n, for arbitrary n • Called iteratively for 1…n • Only need to check locally optimal circuits • Build optimal circuit library bottom up by DP • Index optimal circuits by computed permutation • In practice use hash_map datastruct from STL

  34. Synthesis Algorithm

  35. Empirical Circuit Synthesis • Consider all reversible functions on 3 wires(8! = 40,320 functions) • For each gate library fromN, C, T, NC, CT, NT, CNT, CNTS • Is it universal? • How many functions can it synthesize? • How long does it take to synthesize circuits? • What are largest optimal circuits?

  36. Optimal Circuit Sizes

  37. Largest Optimal Circuits

  38. Why Circuit Libraries? • Large speedup relative to just branching • Can be calculated from previous table • Calculated values are very large • In practice, the table cannot be generated in several hours without circuit libraries • With libraries, the table takes less than 10 min

  39. Outline • Motivation • Background • Theoretical Results • Synthesis of Optimal Circuits • An Application to Quantum Computing • Grover’s Search • Pseudo-classical Synthesis

  40. Quantum Circuits • Necessarily reversible • Information stored on qubits • Superposition allows linear combinations of 0 and 1 to be stored • All reversible gates still allowed • Many other gates used as well

  41. Grover’s Search • A quantum algorithm for associative search(input is not sorted) • Search criterion: a classical one-output function f • L. K. Grover, “A Framework For Fast Quantum Mechanical Algorithms”, STOC 1998 • M. Nielsen and I. Chuang, 2000 • Runs in time O(√N) • any classical algorithm provably requires (N ) time • Requires a subroutine (oracle) that • changes the phase (sign) of all basis states (bit-strings)that match the search criterion f

  42. Grover Oracle Circuits • To change the sign of a bit-string • Initialize a qubit to |0> - |1> • Compute the classical one-output function f • XOR the qubit with f • Whenever f=1, the sign (phase) will change

  43. Sample Grover Oracle Circuit

  44. Grover Oracle Circuit Synthesis • Thus, the design of Grover search circuitsfor a givenf • Is reduced to reversible synthesis • Can be solved optimally by our methods

  45. ROM-based Circuits • Desired circuits must alter phase of basis states • All bits except one must be restored to input values • Previous work studied ROM-based circuits • Constraint: ROM qubits can never change • B. Travaglione et al., 2001, http://xxx.lanl.gov/abs/quant-ph/0109016 • Theorems + heuristic synthesis algorithms • Our work: synthesis of pseudo-classical circuits • 3 read-only “ROM” wires that can never change • 1 wire that can be changed during computation, but must be restored by end • 1 wire on which function is computed

  46. Synthesis Algorithms Compared • Heuristic synthesis of ROM-based circuits • Proposed by Travaglione et al, 2001 • Based on EXOR-sum decomposition (“XOR”) • Imposed a restriction: at most one control bit per gate can be on a ROM bit • Optimal synthesis (as described earlier) • with restriction from Travaglione (“OPT T”) • without this restriction (“OPT”)

  47. Sizes of 3+2 ROM-circuits

  48. Discussion of Empirical Results • The EXOR-SUM heuristic is sub-optimal • All methods able to synthesize all 256 fns • “OPT T” can synthesize as many as “OPT”: B. Travaglione et al., 2001 • “OPT” results symmetrical about 5-6 gates • Function x requires one fewer gate than 256-x • Explanation yet to be found • “XOR” results symmetrical about 13 gates

  49. Conclusions • Classical reversible circuitsas special-case quantum circuits • Existence theorems • Reversible De Morgan’s laws • Future research on optimization heuristics • Algorithm for synthesis of optimal circuits • Applicable to Grover’s search

  50. Thank You For Your Attention

More Related