Verilog Implementation of Reversible Logic Gate

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

International Journal of Engineering Research in Electronic and Communication

Engineering (IJERECE) Vol 3, Issue 3, March 2016

Verilog Implementation of Reversible Logic Gate


[1]
P Sravani [2] V Sai Koushik [3] D Srinivas
[1]
Assistant Professor [2][3] B.E Scholor
[1][2][3]
Department of ECE, Matrusri Engineering College, Hyderabad, Telangana, India
Abstract- Technologies day-to-day are becoming smaller, faster and more complex than its previous technologies being developed.
Increase in clock frequency to achieve good speed and increase in number of transistors packed onto the chip to achieve complexity
of a conventional system results in increased power consumption. All the gates used to perform Boolean algebra based
computations by the use of silicon based semiconductor technology in a Conventional logic system are irreversible in nature.

This is due to the mismatch of inputs and outputs. Reversible Logic is gaining interest in the recent past due to its less
heat dissipating characteristics. This logic circuit maps to its unique input to the output and ensure one to one mapping and basis
for emerging applications like DNA Computing, Bioinformatics, Nanotechnologies, Quantum Computing, Quantum Dot Cellular
Data, Adiabatic CMOS, Thermodynamics, Low power Design and Optical Computing to produce zero power dissipation under
ideal conditions.

This paper presents the combinational circuit and Verilog code for the basic Reversible Logic gates which are important
(Feynman, Double Feynman, Fredkin, Toffoli and peres ). Every Logic circuit which is combinational uses all these basic
Reversible Logic Gates and can be verified through Simulation using Verilog HDL.

Keywords— Reversible Logic gates, Quantum Computing, Reversible Logic, Feynman, Fredkin, Toffoli and peres.

I. INTRODUCTION The most prominent application of reversible logic


lies in quantum computers [3]. A quantum computer will be
Energy dissipation is one of the major issues in viewed as a quantum network (or a family of quantum
present day technology. Energy dissipation due to networks) composed of quantum logic gates; It has
information loss in high technology circuits and systems applications in various research areas such as Low Power
constructed using irreversible hardware was demonstrated CMOS design, quantum computing, nanotechnology, DNA
by R. Landauer[1] in the year 1960. According to computing etc.,
Landauer’s principle, the loss of one bit of information lost, Quantum networks composed of quantum logic
will dissipate kT*ln(2) joules of energy where, k is the gates; each gate performing an elementary unitary operation
Boltzmann’s constant and k=1.38x10-23 J/K, T is the on one, two or more two–state quantum systems called
absolute temperature in Kelvin[1]. The primitive qubits. Each qubit represents an elementary unit of
combinational logic circuits dissipate heat energy for every information; corresponding to the classical bit values 0 and
bit of information that is lost during the operation. This is 1. Any unitary operation is reversible and hence quantum
because according to second law of thermodynamics, networks effecting elementary arithmetic operations such as
information once lost cannot be recovered by any methods. addition, multiplication and exponentiation cannot be
Bennett [2] showed that if a computation is carried directly deduced from their classical Boolean counterparts
out in Reversible logic zero energy dissipation is possible, (classical logic gates such as AND or OR are clearly
as the amount of energy dissipated in a system is directly irreversible).Thus, quantum arithmetic must be built from
related to the number of bits erased during computation. The reversible logical components [3]. Reversible computation
design that does not result in information loss is irreversible. in a system can be performed only when the system
A set of reversible gates are needed to design reversible comprises of reversible gates. A circuit/gate is said to be
circuit. Several such gates are proposed over the past reversible if the input vector can be uniquely recovered from
decades. the output vector and there is a one-to-one correspondence
According to Moore’s law the numbers of between its input and output assignments [4-6].
transistors will double every 18 months. Thus energy
conservative devices are the need of the day. The amount of In order to achieving an optimized reversible
energy dissipated in a system bears a direct relationship to circuit, some points should be considered:
the number of bits erased during computation. Reversible 1) Fan-out is forbidden.
circuits are those circuits that do not lose information. 2) Feedback and loop are not allowed.
3) Delay should be minimum.

155
International Journal of Engineering Research in Electronic and Communication
Engineering (IJERECE) Vol 3, Issue 3, March 2016

4) Optimization parameters should be minimum.


Input + constant input = output + garbage. [7]
The parameters such as number of reversible gates,
number of constant inputs, garbage outputs, and quantum As with reversible gates, a reversible circuit has the
cost (QC) can be named as optimization parameters and are same number of input and output wires; the reversible
defined as: circuit with n inputs is called an n X n circuit or a circuit on
1) The inputs, which equal to 0 or 1, are constant n wires.
inputs.
2) Garbage outputs are output vectors which do not E. Quantum cost:
generate any useful function.
3) Quantum cost refers to the cost of the circuit in Quantum cost refers to the cost of the circuit in
terms of primitive gate [7]. terms of the cost of a primitive gate. It is calculated knowing
the number of primitive reversible logic gates (1*1 or 2*2)
II. BASIC DEFINITIONS OF REVERSIBLE LOGIC required to realize the circuit.

In this section some important factors in reversible F. Flexibility:


logic are explained. The main object in reversible logic
theory is the reversible function, which is defined as Flexibility refers to the universality of a reversible
follows. logic gate in realizing more functions [14].

A. Reversible Function: G. Gate Level:

The Boolean function f(x1, x2 … xn) of n Boolean This refers to the number of levels in the circuit
variables is called reversible if: which are required to realize the given logic functions.
1. The number of outputs is equal to the number of
inputs. H. Hardware Complexity:
2. Any output pattern maps to a unique input pattern.
This refers to the total number of logic operation in
In other words, reversible functions are those that perform a circuit. Means the total number of AND, OR and EXOR
permutations of the set of input vectors [7-9]. operation in a circuit [11] and [15].
For an (n, k) function, i.e. function with n-input k-
output, it is necessary to add inputs and/or outputs to make it I. Design Constraints for Reversible Logic Circuits:
reversible. This leads to the following definition.
Reversible logic imposes many design constraints
B. Reversible logic gate: that need to be either ensured or optimized for implementing
any particular Boolean functions.
Reversible Gates are circuits in which number of outputs is 1) In reversible logic circuit the number of inputs
equal to the number of inputs and there is a one to one must be equal to the number of outputs.
correspondence between the vector of inputs and outputs 2) For each input pattern there must be a unique
[10- 12]. It not only helps us to determine the outputs from output pattern.
the inputs but also helps us to uniquely recover the inputs 3) Each output will be used only once, that is, no fan
from the outputs. out is allowed.
4) The resulting circuit must be acyclic.
C. Ancilla inputs/ constant inputs:

Anicilla inputs are used to denote the present value III. REVERSIBLE LOGIC GATES
inputs that were added to an (n, k) function to make it
reversible. The constant inputs are known as ancilla inputs. In this section, we describe all about reversible
[13]. logic and reversible logic gates. Though it is already briefly
described about garbage outputs, in this section we will
D. Garbage outputs: define these with more appropriate Reversible logic gates.

Garbage is the number of outputs added to make an (i) NOT Gate: 1*1 NOT gate is the simplest among all the
n-input k-output function ((n; k) function) reversible. The reversible gates where the gate has only one input (A) and
relation between garbage outputs and constant inputs is [7]
156
International Journal of Engineering Research in Electronic and Communication
Engineering (IJERECE) Vol 3, Issue 3, March 2016

one output (B) such that B = A’. The block diagram for 1*1
NOT gate is shown in Fig.3.1. (Quantum Cost = 0)

Figure 3.1: 1x1 NOT GATE

Code :

module NOTGATE( input A, output P );


assign P = ~A; Figure 3.4: combinational circuit diagram of 1x1 CNOT
endmodule GATE

(iii) Double Feynman Gate: Let Iv and Ov be the input and


output vector of a 3*3 Double Feynman Gate respectively,
where Iv = (A, B, C) and Ov = (P=A, Q=A⊕B, R=A⊕C).
Fig.3.5 shows the 3*3 Double Feynman gate. (Quantum
Cost = 2)

Figure 3.2: combinational circuit diagram of 1x1 NOT


GATE
Figure 3.5: 3x3 DOUBLE FEYNMAN GATE
(ii) Feynman Gate: Let Iv and Ov be the input and output
vector of a 2*2 Feynman gate (FG) [16,17] respectively,
Code:
where Iv= (A,B) and Ov = (P=A, Q=A⊕B). The block
diagram for 2*2 Feynman gate is shown in Fig.3.3.
Module Double_Feynman( input A, B, C, output P, Q, R
(Quantum Cost = 1)
);
assign P = A;
assign Q = A^B;
assign R = A^C;
endmodule

Figure 3.3: 2x2 FEYNMAN GATE (CNOT GATE)


Code:

module Feynman( input A, B, output P, Q );


assign P = A;
assign Q = A^B;
endmodule

157
International Journal of Engineering Research in Electronic and Communication
Engineering (IJERECE) Vol 3, Issue 3, March 2016

Figure 3.8: combinational circuit diagram of 3x3


TOFFOLI GATE

(v) Fredkin Gate: Let Iv and Ov be the input and output


vector of a 3*3 Fredkin Gate [18,20] respectively, where
Iv=(A,B,C) and Ov=(X=A,Y=A’B⊕AC , Z=A’C⊕AB).
Figure 3.6: combinational circuit diagram of 3x3 Fig. 3.9 shows the block diagram of 3*3 Fredkin gate.
DOUBLE FEYNMAN GATE (Quantum Cost = 5)

(iv) Toffoli Gate: Let Iv and Ov be the input and output


vector of a 3*3 Toffoli Gate (TG) [18,19] respectively,
where Iv =(A, B, C) and Ov=(P=A, Q=B, R=AB⊕ C).
Fig.3.7 shows the 3*3 Toffoli gate. (Quantum Cost = 5)

Figure 3.9: 3x3 FREDKIN GATE

Code:

Figure 3.7: 3x3 TOFFOLI GATE module Fredkin( input A, B, C, output X, Y, Z );


assign X = A;
Code: assign Y =((~A)&B) ^ (A&C);
assign Z =((~A)&C) ^( A&B);
module Toffoli( input A,B,C, output P,Q,R ); endmodule
assign P = A;
assign Q = B;
assign R = (A&B)^C;
endmodule

Figure 3.10: combinational circuit diagram of 3x3


FREDKIN GATE

158
International Journal of Engineering Research in Electronic and Communication
Engineering (IJERECE) Vol 3, Issue 3, March 2016

(vi) Peres Gate: Let Iv and Ov be the input and output Carry = ((A XOR B) C) XOR AB
vector of a 3*3 Peres Gate [18,20,21] respectively, where
Iv=(A,B,C) and Ov=(X=A,Y=A⊕B , Z=AB⊕C). Fig. 3.11 For this we go with peres gate as it has low
shows the block diagram of 3*3 Peres gate. (Quantum Cost quantum cost as compared with the discussed above basic
= 4) Reversible Logic gates. The Peres implemented Full Adder
with its corresponding quantum cost is shown in the figure
4.1

Figure 3.11: 3x3 PERES GATE


Code:

module Peres(input A,B,C, output X,Y,Z ); Figure 4.1:Full Adder using Peres Gates
assign X = A;
assign Y =A^B; Code:
assign Z =(A&B)^C;
endmodule module FULLADDER( input A,B,Cin, output SUM,Cout
);
Peres P1(A,B,0,G1,G2,G3);
Peres P2(G2,Cin,G3,G4,SUM,Cout);
endmodule

Figure 4.2: Full Adder using Peres Gates

This PFA (Peres Full Adder) can be taken as a


Figure 3.12: combinational circuit diagram of 3x3 PERES block as shown in figure 4.3 in order to facilitate the
GATE notation of its expansion with a Quantum Cost equal to 8.
The inputs order was also changed to better fit in an
Peres Gate [11] is an important gate which has a low expansion diagram and the logic diagram is given in figure
quantum cost as compared to other gates. A single Peres 4.4.
gate can give generate and propagate outputs when the third
input C = 0. Two Peres gates can be combined to form a full
adder.

IV. 4-BIT ADDER USING PFA (PERES FULL


ADDER) BLOCK:

Some of the most used universal quantum


gates[21] and their quantum cost are shown in figures
3.1,3.3,3.5,3.7 and 3.9. All these gates are used for Figure 4.3: PFA as a block
implementing any logical function therefore they can also
implement the full adder functions sum and carry.
Sum = A XOR b XOR C

159
International Journal of Engineering Research in Electronic and Communication
Engineering (IJERECE) Vol 3, Issue 3, March 2016

2. Management of digital power involves moving it to


where it is needed.
3. Digital heat refers to disordered bit patterns that are
no good to anyone.
4. Management of digital heat involves moving it to
where it can be dumped.

VII. CONCLUSION
Figure 4.4: PFA traditional logic implementation.
This paper presents Verilog CODE for all
Once we take the PFA as a block, we can derive Reversible Logic Gates, which provide us to design Verilog
the algorithm to implement an n-bits adder. This algorithm CODE of any complex combinational circuit. Here we have
was implemented in this design for a 4-bit adder and can be tried to make the Verilog code as much as possible. We can
seen in figure 4.5. simulate and synthesis it using Xilinx 15.1 software and
verified using Z series board and also calculate the power
consumption and compare it with the irreversible
Combinational Circuits.

REFERENCES

1. R.Landauer, “Irreversibility and Heat Generation in


the Computational Process”, IBM Journal of
Research and Development, 5,pp. 183-191,1961.

2. C.H.Bennett, “Logical Reversibility of


Computation”, IBM J.Research and Development,
pp.525-532, November1973.
Figure 4.5: 4-bits adder implementation
3. Vlatko Vedral, Adriano Bareno and Artur Ekert,
V. DISADVANTAGES “QUANTUM Networks for Elementary Arithmetic
Operations”, arXiv:quantph/ 9511018 v1, nov
1. However, in order to attain the supposed benefits of 1995.
reversible computation, the reversible machine must
actually be run backwards to attain its original state. If this
is not happening then typically the machine is heated up and 4. Perkowski, M., A. Al-Rabadi, P. Kerntopf, A.
thus it stops its working. Buller, M. Chrzanowska-Jeske, A. Mishchenko, M.
Azad Khan, A. Coppola, S.Yanushkevich, V.
2. You must make sure weather your computation was Shmerko and L. Jozwiak, ―”A general
performed with no errors when reversible machine actually decomposition for reversible logic”, Proc.
be run backwards - otherwise chaos (and not the original RM’2001, Starkville, pp: 119-138, 2001..
starting condition) may result when the machine is run
backwards. 5. Perkowski, M. and P. Kerntopf, ―”Reversible
Logic. Invited tutorial”, Proc. EURO-MICRO, Sept
So: do you think is the reversible logic a waste of time? No. 2001, Warsaw, Poland.
Reversible logic is of substantial significance.

VI. ADVANTAGES 6. Hafiz Md. Hasan and A.R. Chowdhury, ―”Design


of Reversible Binary Coded decimal Adder by
What do digital power management and digital heat using Reversible 4 – bit Parallel Adder”, VLSI
management even mean? Design 2005, pp. 255 – 260, Kolkata, India, Jan
2005.
1. Digital power refers to ordered bit patterns, which
can be used to do digital work. 7. B.Raghu kanth, B.Murali Krishna, M. Sridhar,
V.G. Santhi Swaroop ―”A DISTINGUISH

160
International Journal of Engineering Research in Electronic and Communication
Engineering (IJERECE) Vol 3, Issue 3, March 2016

BETWEEN REVERSIBLE AND 16. Milburn, Gerard.j., The Feynman processor perseus
CONVENTIONAL LOGIC GATES”, International books 1998
Journal of Engineering Research and Applications
(IJERA) ISSN: 2248-9622 www.ijera.com Vol. 2, 17. Feynman R., 1985. Quantum mechanical
Issue 2,Mar-Apr 2012, pp.148-151 computers, Optics News, 11: 11-20.

8. D. Maslov, Reversible logic synthesis, Ph.D. thesis,


18. E. fredkin, T. Toffoli, “Conservative Logic”,
The Faculty of Computer Science, The University International Journal of Theory of Physics,21,
of New Brunswick, Canada, 2003 1982, pp 219-253

9. D. Maslov, G.W. Dueck, Garbage in reversible


19. Toffoli T., 1980. Reversible computing, Tech
designs of multiple output functions, in Memo MIT/LCS/TM-151, MIT Lab for Computer
Proceedings of the 6th International Symposium on Science.
Representations and Methodology of Future
Computing Technologies (RM 2003), Trier,
Germany, pp. 162–170, March 2003 20. P.D. Picton, “ Fredkin gates as the basic for
comparison of different logic designs”, Synthesis
and optimization of logic system, London, VK,
10. Ashis Kumer Biswas, Md. Mahmudul Hasan,
1994.
Moshaddek Hasan, Ahsan Raja Chowdhury and
Hafiz Md. Hasan Babu. ―”A Novel Approach to
Design BCD Adder and Carry Skip BCD Adder”. 21. Peres, A. 1985. Reversible logic and quantum
21st International Conference on VLSI Design, computers. Physical Review A, 32: 3266-3276.
1063-9667/08 $25.00 © 2008 IEEE DOI
10.1109/VLSI.2008.37.

11. Abu Sadat Md. Sayem, Masashi Ueda.”


Optimization of reversible sequential circuits”.
Journal of Computing, Volume 2, Issue 6, June
2010, ISSN 2151-9617.

12. H.Thapliyal and N. Ranganathan, ―”Design of


reversible sequentialcircuits optimizing quantum
cost, delay and garbage outputs”, ACMJournal of
Emerging Technologies in Computing Systems,
vol. 6, no.4, Article 14, pp. 14:1–14:35, Dec. 2010.

13. J.Smoline and David P.DiVincenzo, ―”Five two-


qubit gates are sufficient to implement the quantum
fredkin gate”, Physics Review A, vol. 53, no.4, pp.
2855-2856,1996.

14. M. Haghparast,K. Navi, “A Novel Reversible BCD


Adder For Nanotechnology Based Systems”,
American Journal of Applied Sciences 5 (3):
282‐288, 2008,ISSN 1546‐9239.

15. Abu Sadat Md. Sayem, Masashi Ueda.‖


Optimization of reversible sequential circuits‖.
Journal ofComputing, Volume 2, Issue 6, June
2010, ISSN 2151-9617.

161

You might also like