1 / 51

April 25, 2011

April 25, 2011. A Constructive Group Theory based Algorithm for Reversible Logic Synthesis. Main Ideas . We know many representations of reversible circuits, such as reversible vectors, truth tables, Kmaps and permutative unitary matrices.

ashanti
Télécharger la présentation

April 25, 2011

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. April 25, 2011

  2. A Constructive Group Theory based Algorithm for Reversible LogicSynthesis

  3. Main Ideas • We know many representations of reversible circuits, such as reversible vectors, truth tables, Kmaps and permutative unitary matrices. • In this lecture we will learn one more useful representation – a set of cycles. • A cycle can be decomposed to transpositions. Set of transpositions is another representation. • This is the initial paper in “group-theory approach to quantum circuits synthesis”

  4. Background • Reversible logic plays an important role in quantum computing; • oracles are reversible (permutative) circuits. • Any computing system of irreversible logic gates leads inevitably to energy dissipation. • To avoid power dissipation, circuits must be constructed from reversible gates. • De Vos – CMOS • Optical • DNA • Nano-technologies • There are a lot of research on the construction of reversible logic gates and circuits: • De Vos 1998, group theory. • Kerntopf 2000, enumerative – decision diagrams. • Perkowski et al. 2001, exor logic, spectral, group theory, heuristic, genetic algorithm, exhaustive. • Markov et al 2002, exhaustive, group theory. • Yang et al, 2003 – group theory approach – GAP and exhaustive search • Miller, Dueck and Maslov 2003, spectral and heuristic non-optimal algorithm • Aggrawal and Jha 2004, heuristic RM-transformation-based.

  5. Definition 1 (Binary reversible gate): • Let B = {0, 1}. • A binary logic circuit fwith n inputs and outputs is denoted by a binary multiple-output function f : Bn Bn. • Let B1,…, Bn  Bn and P1,…, Pn  Bnbe the input and output vectors, • where B1,…, Bn are input variables • and P1,…, Pnare output variables. • There are 2n different assignments for the input vectors. • A binary logic circuit f is reversible if it is a one-to-one and onto function (bijection). • A binary reversible logic circuit with n inputs and n outputs is also called an n-qubit binary reversible gate. • There are a total of (2n)! different n-qubit binary reversible circuits.

  6. Permutations, Cycles and Transpositions

  7. Permutation groups and their relationshipwith reversible circuits • Definition 2 (Permutation):Let M = {d1, d2 , , dk}. • A bijection of M onto itself is called a permutation on M. • The set of all permutations on M forms a group under composition of mappings, called a symmetric group onM. • It is denoted by Sk. • A permutation group is simply a subgroup of a symmetric group.

  8. Mappings and cycles • A mapping s : M  M can be written as: ( d1 , d2 ,.., dk di1 , di2 ,.., di1(1) ( • Here we use a product of disjoint cycles (Definition 3) as an alternative notation for a mapping. • For example, • d1 , d2 , d3 ., d4 , d5 , d6 , d7 , d8 , d9 • d1, d4 , d7 , d2 ,d5 , d8 , d3 , d6 , d9(2) • can be written as (d2, d4) (d3, d7) (d6, d8). ( (

  9. F(a14) = a14 F(1101) = 1101 F(13) = 13 Identity minterm 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Identity function as a mapping Identity function as a circuit

  10. Simple function Simple function has many identity minterms, N is small The function is a single 2-cycle (6,7) 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Toffoli gate as a mapping Toffoli gate as a circuit

  11. Simple function Simple function has no identity minterms The function has four 2-cycles (0,1), (2,3), (4,5) and (6,7) N is high but function is simple 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Identity function as a mapping Identity function as a circuit

  12. Problem to be solved has simple formulation It is a kind of “Rubik Cube” game 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Toffoli Feynman Feynman Fredkin

  13. Patterns based on transpositions and costs based on transpositions

  14. How many minterms in distance k cycle Distance Histogram of a function 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 6 How many minterms in distane k cycle 0 1 2 3 Distance k cycle 8 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 Distance k cycle

  15. Notation • Denote “( )” as the identity mapping (i.e., direct wiring) and call this the unity element in a permutation group. • A product f * g of two permutations applies mapping fbeforeg.

  16. Cascading gates and permutations • A n-qubit reversible circuit is a permutation in S2n, and vice versa. • Cascading two gates is equivalent to multiplying two permutations in S2n. • Thus, in what follows, we will not distinguish a n-qubit reversible circuit from a permutation in S2n.

  17. Definition 3 (‘j’-cycle): • Let Sk be a symmetric group of symbols {d1, d2,…,dk}, then (di1 , di2 ,…, dij ) is called a ‘j’-cycle, • where j  k, 1  i1 , i2 ,…, ij k. 01234567 01234567 Cycle (0,1,2,3)

  18. Realizations of the same cycle 0 1 00 Cost 1+2=3 012 01 11 (0,1,2) = (0,2) * (1,2) 10 We should select the set of 2-cycles with the minimum total distance 0 1 00 Cost 1+1=2 012 01 11 (0,1,2) = (0,1) * (0,2) This is better 10

  19. Definition 4 (NOT gate): • A NOT gate Nj connects an inverter to the j-th wire, i.e.: Pj = Bj 1, Pi = Bi , if i  j . 1  j  n: • An example NOT gate is shown in figure 1.

  20. Definition 5 (‘n-1’-CNOT gate): • A ‘n-1’-Controlled-NOT (CNOT) gate Cjis defined as follows: • If m  j, then Pm = Cj (Bm) = Bm . • If m = j, and Bi = 1 for all i  j, then Pj = Cj (Bj ) = Bj 1; else, Pj = Bj . • An example ‘4’-CNOT gate is shown in figure 2. • A ‘n-1’-CNOT gate is a generalized Toffoli gate where two inputs control an output of another input. These are “big Toffoli gates” that we want to avoid in general

  21. MMD and New methods • MMD is a specific algorithm that processes permutation vectors (truth table) in such a way that the set of self-mapping minterms grows from top. • This can be rewritten to our new notation. • But this is only one way of realizing permutation from transpositions. • We should investigate more of them.

  22. MMD method 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 We add identity minterms from top MMD method can start from function with small N and make it a new function with big N Our idea here is to decompose to 2-cycles of the minimum total distance

  23. How many minterms in distane k cycle Distance 3 function – Miller 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 6 0 1 2 3 Distance k cycle Distance 1 function – Toffoli Distance 2 function – Fredkin 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

  24. Programs for reversible logic Perform heuristic search with one ordering MMD Perform heuristic search with many orderings Function (permutation) with high N MMDS Template Greedy Distance Perform local optimization to reduce costs of gates Reduce N Decompose to smallest distance gates Function with small N This can be greedy or evolutionary algorithm

  25. III. THEORETICAL RESULTS on decomposing to cycles • The process to constructively synthesize any ‘n’-qubit reversible circuit by Not and ‘n-1’- CNOT gates without ancilla qubits. • Lemma 1:Every permutation can be decomposed to some ‘2’-cycles. 2-cycle = transposition

  26. Hamming Distance one Transpositions or “Neighboring 2-cycles” • Remark 1: • This lemma is a well-known result in group theory • Definition 6 (neighboring ‘2’-cycle): • If two n-dimension vectors u, s have only one bit difference, we call the permutation (u, s) a neighboring ‘2’-cycle.

  27. Realizations of the same cycle 0 1 00 Cost 1+2=3 012 01 11 (0,1,2) = (0,2) * (1,2) 10 We should select the set of 2-cycles with the minimum total distance 0 1 00 Cost 1+1=2 012 01 11 (0,1,2) = (0,1) * (0,2) This is better 10

  28. Lemma 2: • Suppose between u and s, there is only one bit Bj different, and i same bits are zeros. • These zero bits are Bi1 ,…, Bil . • Then, (u , s) = Ni1 * … * Nil * Cj * Nil * … * Ni1 (4) This is a distance 1 decomposition of a 2-cycle

  29. Lemma 3: Decomposition to distance-1 transpositions If two n-dimension vectors u , s have k bits different, then there is an ordered set M = {d1, d2 ,.., dk+1 } such that d1 = u , dk+1 = s and for any i, 1 i < k + 1, there is only one bit difference between di and di+1, and (u , s) = (d1, d2)(d2 , d3) … (dk , dk+1) (dk , dk-1) … (d2 , d1) (5) This is a decomposition of a 2-cycle to 1-distance cycles. Total distance cost should be minimized

  30. Decomposing to sequences of neighbor minterms in transpositions • In order to make the number of NOT gates as small as possible, we give two rules for constructing the ordered set M. • If the number of 1’s in the vector u is more than that in s, then d1 = u , dk+1 = s. Else, d1 = s , dk+1 = u. • In the different bits between u and s, change the zero bit to one first, then change one bit to zero bit. • For example, if u = (0 , 1 , 0 , 0 , 0 ), s = (0 , 0 , 1 , 1 , 1), then k = 4; d1 = s , d5 = u and, d2 , d3 , d4 are given in the following table.

  31. Hamming Distance and “Distance-Gates” Various Distance 3 gates 0 1 00 When F(a) = b, (or (a,b) is a 2-cycle) Hamming distance of a and b is 3 01 11 10 All Distance 1 gates 0 1 00 When F(a) = b, Hamming distance of a and b is 1 01 11 10

  32. REMOVAL OF NOT gates • can remove a pair of the adjacent NOT gates in the same quantum wire. • Lemma 4: (complexity of NOT gates) • In decomposing ‘2’-cycle (u , s) to NOT gates and ‘n-1’-CNOT gates, suppose there are j bits different between u and s, and there are j0 zero bits in these bits in d1 and j1 one bits in these bits in d1, where j0 j1, then the number of NOT gates is no more than 2(j - 2) + 2(j0 - 1) if j0 1 , or 2(j-1) if j0 = 0.

  33. Theorem 1: • For a given n-qubit reversible circuit f, if there are Ndistinct input patterns that are different from their corresponding outputs, where N  2n, and the other (2n - N) input patterns are the same as their outputs, then this circuit can be synthesized by at most 2n * N‘(n - 1)’- CNOT gates and 4n2 * N NOT gates without ancilla qubit.

  34. Theorem 2: All n-qubit reversible circuits can be constructed by: • less than 2n * 2nNOT gates • and less than (2n - 1) * 2n ‘n - 1’-CNOT gates • without ancilla qubit.

  35. ALGORITHM • Step 1. • Check the truth table of f to determine before using equation 3 and lemma 3, whether we need NOT gates or not. • Step 2. • After step 1, write the reversible circuit in a product of cycles form. • For every cycle (d1, d2 ,…, dk), calculate the number riof different bits between diand di+1, i = 1, 2 ,…, k where dk+1 = d1. • Let rjbe the maximal number. • The basic idea to decompose the reversible circuit by equation 3 is to break the mapping relation from dj to dj+1 without increasing the number of different bits between adjacent vectors. • (d1, d2 ,…, dk) = (dj , dj+1) (dj , dj+2 , dj+3 ,…, d1) (6)

  36. ALGORITHM (cont) • Recursively repeating this process, we decompose the reversible circuit to ‘2’-cycles. • Step 3. • Decompose every ‘2’-cycles by NOT and ‘n-1’-CNOT gates by Lemma 3, two rules in remark 2, lemma 2, and remove pairs of adjacent NOT gates when possible.

  37. COMPLETE SYNTHESIS EXAMPLE WITH NON-MINIMIZED TOFFOLI GATES

  38. SYNTHESIS EXAMPLE • Given a binary reversible circuit f which has a truth table as shown in Table II. • Therefore, f = (a1, a3, a4 , a16) (a2 , a6 , a14). • Step 1. • The total number of changed vectors is 7, less than 24-1 = 8, thus, we deal with the input reversible circuit f without pre-cascading NOT gates. • Step 2. • Decompose each cycle into the product of 2-cycles by using equation 6.

  39. a4=1100 a16=1111 d2 N2 * N2= () a4=1100 a3=0100 (a1,a3,a4,a16) (a2,a6,a14) d1 a6=1010 a6=1010 (a4,a16) (a4,a3) (a1, a3) (a6,a14) (a6,a2) a2=1000 a14=1011 d2 d1 d1 d1 d1 d1 d1 inverters

  40. C3

  41. (a4,a16) (a4,a3) (a1, a3) (a6,a14) (a6,a2) d2 d1 d1 d1 d1 • The synthesis process is finished, and f is decomposed into the product of 12 NOT gates and 7 ‘n-1’-CNOT gates, shown in figure 3. C3 N3 C4

  42. IMPROVED SYNTHESIS METHOD BASED ON “DISTANCE GATE”

  43. New idea = a better way to implement transpositions (13,14) a b c d a a4=1101 b c a16=1110 d d2 Realization of transposition (1101, 1110) = (13,14) HD =2

  44. New idea = a better way to implement transpositions (12,15) a b c d a b a4=1100 1 0 1 c c a16=1111 0 1 d d d2 d2 Realization of transposition (1100, 1111) = (12,15) a b 0 1 HD =2 0 c c 1 0 d d

  45. New idea = a better way to implement transpositions (12,15) a b c d 1 a 1 a4=1100 b 1 1 0 0 c c a16=1111 1 1 d d d2 Realization of transposition (1100, 1111) = (12,15) 1 a 1 b 0 0 1 1 HD =2 c c 0 0 d d

  46. New idea = a better way to implement transpositions (12,11) a b c d 1 a 1 1 1 1 a4=1100 b 0 0 0 c c 11001100 no change a16=1101 0 0 0 d d d2 Realization of transposition (1001, 1110) = (9,14) 1 a 1 1 0 1 b 0 0 HD =2 0 c c 0 11011101 no change 1 1 1 1 d d

  47. New idea = a better way to implement transpositions a b c d 1 a 1 0 0 0 a4=1001 b 1 1 1 c c 1 a16=1110 0 0 0 0 d d d2 10101010 Realization of transposition (1001, 1110) = (9,14) 1 a 1 1 0 1 1 b 1 0 HD =2 0 c c 1 10011110 0 1 1 0 d d Here we see the transposition in action

  48. Distance gates • The gates shown in last few slides are called “Distance gates”. • They are all inexpensive and realize transpositions. • By adding inverters on inputs and outputs of these gates a wider category (called family) of these gates is created. • We should consider the widest family and find synthesis methods (algorithms) for them.

  49. CONCLUSIONS • The concept of decomposition of permutation to cycles • The concept of decomposition of cycle to 2-cycles • The concept of distance-k-gates and decomposition with smallest total distance • A constructive algorithm for synthesizing reversible circuits by NOT and ‘n-1’-CNOT gates • Synthesis examples based on this algorithm, which show that even by hand, synthesizing any ‘4’-qubit reversible circuit is not difficult. Especially for functions with small N. • The computational complexity of our synthesis algorithm is exponentially lower than the complexity of breadth-first search based synthesis algorithm. • To be used as part of a comprehensive system of programs

  50. CONCLUSIONS • Knowledge reduces search – group theory • Knowledge is not sufficient to find minimal solution – search is necessary • Role for evolutionary algorithms, PSO, immune, etc • We found some heuristics, more are needed. • Based on last section, the method can be improved, which is a good project.

More Related