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

2010 23rd International Conference on VLSI Design

An Efficient Design of a Reversible Barrel Shifter

Irina Hashmi Hafiz Md. Hasan Babu


Department of Computer Science & Engineering Department of Computer Science & Engineering
University of Dhaka University of Dhaka
Dhaka, Bangladesh Dhaka, Bangladesh
irina.hashmi@gmail.com hafizbabu@hotmail.com

Abstract
Designing reversible circuits using reversible gates have
several constraints [3]:
a. The fan-out of every signal is equal to one.
The key objective of today’s circuit design is to increase the
performance without the proportional increase in power b. Loops are not permitted in a strictly reversible system.
consumption. In this regard, reversible logic has become an On the other hand, data shifting and rotating is important
immensely promising technology in the field of low power and frequently used in arithmetic operations, variable-length
computing and designing. On the other hand, data shifting and coding, bit-indexing and many more. In this consequence,
rotating are required in many operations such as arithmetic barrel shifters which are capable of performing n-bit shifting
and logical operations, address decoding and indexing etc. In and rotating of data in a single cycle, are normally used in
this consequence, barrel shifters, which can shift and rotate embedded processors such as: digital signal processors [4] and
multiple bits in a single cycle, have become a common design high performance processors [5], high-speed/low-power
choice for high speed applications. For this reason, this paper applications [6] etc. However, only one paper [7] has been
presents an efficient design of a reversible barrel shifter. It proposed so far on reversible barrel shifter. Thus this research
has also been shown that the new circuit outperforms the focuses on designing an efficient barrel shifter and then
previously proposed one in terms of number of gates, number evaluates several significant parameters for this reversible
of garbage outputs, delay and quantum cost. circuit design.
The structure of the paper is as follows: Section II provides
the necessary background on reversible logic as well as the
definitions of some commonly used reversible logic gates.
Several irreversible barrel shifters are described in Section III.
Section IV presents the existing reversible barrel shifter as well
1. Introduction as our proposed one and discusses about some properties of the
proposed circuit. Then it compares the novel shifter to the
Reversible system does not allow information to be erased. existing one. Lastly, the conclusions and further studies are
Thus the reversible gates have the same number of inputs and discussed in Section VI.
outputs which means that the input stage can always be
retained from the output stage. Landauer [1] pointed out that in
an irreversible system, erasure of a single bit generates kTln2 2. Basic Definitions
joules of heat energy where k is Boltzmann’s constant of
1.38x10-23 and T is the absolute temperature of the
environment. Based on this observation, Bennett [2] showed, In this, section we present some definitions on reversible
for a reversible computer the heat dissipation is exactly kTln1 logic for future reference. Then we formally illustrate the
which is logically zero. Thus reversible computation is a highly commonly used reversible logic gates and mention their
potential field for upcoming low power/high performance quantum cost.
computing. For this reason, designing different reversible gates
and combinational circuits has gained considerable importance
than ever before.

1063-9667/10 $26.00 © 2010 IEEE 93


DOI 10.1109/VLSI.Design.2010.35
Definition 1. A Reversible Gate is an n-input, n-output Definition 6. The 3*3 Toffoli gate (TG) [11] is defined as
(denoted by n * n) circuit that uniquely maps the output vector follows: input vector Iv = (A, B, C) and output vector Ov = ( P
Ov to the corresponding input vector Iv where Iv = (I0, I1, I2 … Ik- = A, Q = B and R = AB⊕ C). The block diagram for 3*3
1, Ik,) and Ov = (O0, O1, O2 … Ok-1, Ok) [8]. Toffoli gate is shown in Figure 2. The quantum cost of Toffoli
gate is 5 [9].

Definition 2. To maintain the reversibility property of


reversible logic gates several dummy output signals are needed A P=A
to be produced in order to equal the number of input to that of
Toffoli
output. These signals are commonly known as Garbage B Gate Q=B
Outputs. For example, for reversible Exclusive-OR operation
Feynman gates are used which produce an extra dummy output C R = AB⊕C
along with its principal output signal to preserve reversibility.
The garbage output is denoted by P in Figure 1. Figure 2. Block diagram of a 3*3 Toffoli Gate.

A P=A
Feynman Definition 7. The input and output vector for 3*3 Fredkin
Gate gate (FR) [12] are defined as follows: Iv = ( A, B, C ) and Ov =
B P = A⊕B
(P=A, Q= AB ⊕ AC and R = AC ⊕ AB ). Figure 3 shows the
block diagram of a 3x3 Fredkin gate. The quantum cost of FR
Figure 1. Garbage output of Feynman Gate
is also 5 [9].

A P=A
Definition 3. The calculation of quantum cost (QC) has
several approximations. Firstly the quantum cost of every 2*2 Fredkin
B Gate R = A'C ⊕ AB
gate is the same [9] and it is 1. Secondly, since each 1*1 gate
can always be included to any 2*2 gate that precedes or follows C Q = A'B ⊕AC
it, the quantum cost of the 1*1 gate is considered to be zero.
Thus every reversible gate is a combination of 1x1 or 2x2 Figure 3. Block diagram of a 3*3 Fredkin Gate.
reversible gate. So the quantum cost of a reversible circuit
calculates the total number of 2*2 gates used.

Definition 4. The delay of a logic circuit is the maximum 3. Barrel Shifter


number of gates in a path from any input line to any output
line. The definition is based on the following two assumptions
[9]: A barrel shifter is a combinational circuit which has n-input
and n-output and m select lines that controls bit shift operation.
a) Each gate performs the computation in one unit time. Since multiple and variable bit shifting are more desirable than
b) All inputs to the circuit is known before the single bit operations several irreversible barrel shifters have
computation begins. been proposed in that consequence. Barrel shifters can be
From the above definition the delay of the logic circuit in unidirectional which performs the shift/rotate operation to left
Figure 1 is obviously 1 as this is the only gate from any input (or right) or bidirectional that are capable of shifting/rotating to
to output line. the both directions.
Now we will define some popular reversible gates which In [13], an irreversible shifter has been described. This
will be needed in our work. shifter shown in Figure 4 consists of several transmission paths
which are built from simple n-type transistors. The control lines
operate vertically, the input lines rise diagonally and the output
Definition 5. The input vector, Iv and output vector, Ov for lines run horizontally. At a time exactly one control line is set
2*2 Feynman Gate (FE) [10] is defined as follows: Iv = (A, B) which turns on all the switches in a single column. The length
and Ov = (P = A and Q=A ⊕ B). Figure 1 shows the block of the shifting is determined by the position of the selected
diagram of the reversible Feynman gate. Feynman gates are column. Thus all the inputs are shunted to the output lines. This
typically used as copying gates. If Iv = (A, B=0) then Ov = (P = shifter is very simple in design and transmission delay is
A and Q=A). The quantum cost of FE is 1. minimal while the circuit requires large area.

94
parameters include total number of gates to be used in the
design, garbage outputs, delay and quantum cost of the circuit.

4. Reversible barrel shifter


In this section we will discuss about the existing
reversible barrel shifter and then we will propose the new one.
After that, we will prove some properties of the proposed
shifter and then make a comparative study between the
existing and the proposed one.

Figure 4. Section of a Barrel Shifter [13] 4.1. Existing Reversible Barrel Shifter

The existing shifter is a unidirectional logarithmic shifter


Another design choice for multiple data shifting is consists of multiplexers. A 3x3 Fredkin Gate works as simple
logarithmic barrel shifter as shown in Figure 5. An n-bit (2:1) multiplexers. Feynman gates are used for producing fan
logarithmic barrel shifter has a total of log2 (n) stages. Each outs. The shifter with n-bit data value and k-bit shift value will
stage determines whether to shift or not to shift the input data. require the following number of gates according to [7]:
If the control bit sk ( where k = 0, 1, … (log2(n)-1) ) is set to 1 Number of Fredkin Gates f = (2k-1) x n
then the stage k will shift the input 2k times otherwise the input
will remain unchanged. Logarithmic shifter is more efficient in Number of Feynman Gates g = n x (2k-1)
terms of design as well as area but delay cost is large [7].
Number of Garbage Outputs GO = f + k = k + [(2k-1) x n]

The shifter from [7] with 4-bit data value and 2-bit shift value
Input
is shown in Figure 6.
n

s0 20 Shifter

n
1
s1 2 Shifter
.
.
. n
.
k-1
sk-1 2 Shifter

n
Left/ Right
Output

Figure 5. (n, k ) Logarithmic Barrel Shifter Figure 6. Reversible (4, 2) Barrel Shifter proposed in [7]

Several other complex design patterns for irreversible The existing shifter is complex in design and requires
shifter have also been proposed. Barrel shifter using large number of gates. As a result the total number of garbage
multipliers [14], MUX based data reversal barrel shifter and outputs is high. Thus there is great room for improving the
shifter/rotator with overflow flag have also been discussed in circuit complexity, total number of gates and garbage outputs,
[15]. But only one paper [7] has been published so far on delay and quantum cost.
reversible barrel shifter. In the next section we will discuss
about this existing one and then propose our novel reversible 4.2. Proposed Reversible Barrel Shifter
circuit. Then we will also make a comparative study between
these two based on several designing parameters. The
For efficient designing of a reversible circuit several criteria
are needed to be considered:

95
a. Minimize the number of gates as possible.
b. Minimize the quantum cost of the circuit.
c. Total number of garbage outputs and usage of
constant inputs should be minimized.
By maintaining the above parameters and observing the
previous design, we have proposed a novel logarithmic
Reversible Barrel Shifter. The proposed barrel shifter is a left
rotating shifter which uses Fredkin gates for reversible (2:1)
multiplexing and Feynman Gates for producing fan outs.

4.3. Design procedure of the proposed shifter


Figure 7. Proposed Reversible (4, 2) Barrel Shifter
In this section we will first present the algorithm for
shift/rotate operation of an (n, k) reversible barrel shifter. Then
we will explain the shifter with the example and appropriate
diagram of a (4, 2) shifter. Based on the above idea, a (4, 2) logarithmic barrel shifter
has been illustrated in Figure 7. The circuit uses a total of 6
Fredkin gates, 4 Feynman gates and produces 6 Garbage
Algorithm: Shift/Rotate operation of an (n, k) barrel outputs. The Quantum cost of the circuit has also been
shifter. evaluated according to [9]. The calculation shows that the
Quantum Cost of the proposed (4, 2) circuit is 34. According to
Input: Data Input Set I (io, i1 … in-1), n = total number of the definition 5, the unit delay of the above circuit is 6 as there
data input bit. exists maximum of 6 gates between any input to any output
line.
Control input Set S (s0, s1, … sk), k = log2 (n).
Output: Desired shift/rotate output set O (o1, o2, … oi).
begin 4.4. Properties of the proposed Reversible Barrel
Step 1: for k <- 0 to log2(n) Shifter
Step 2: do if sk = 1 From the above explanation and designing procedure we
Step 3. then left shift /rotate I 2k times will now present several important properties of the proposed
(n, k) reversible barrel shifter.
Step 4. else I remains same
end. Theorem 1. A unidirectional reversible barrel shifter with
n-bit data input and k-bit shift value can be realized with at
least fr number of Fredkin Gates for multiplexing where,
The circuit works as follows: Each stage of Fredkin gate
shifts the input according to the control value of sk. Suppose, to fr = n(k-1) + n/2
design a (4, 2) shifter which takes i0, i1, i2, i3 as data inputs and
s0s1 = 11 as select input. So the input will be shifted 20 + 21 = 3
Proof: The proposed barrel shifter requires n Fredkin gates
for each stage except the last stage of multiplexing. For the
times to the left. Thus the sequence of the shift/rotate operation
design pattern, the last stage of multiplexing requires n/2
will be i1i2i3 i0 for the first stage and then i3i0i1i2 for the next. On
numbers of Fredkin gates. Thus if the total number of stages is
the other hand, for the select input s0s1 = 00, the input sequence
k, then a (k-1) number of stages will have a total of n(k-1)
will remain same for both stages of multiplexing.
Fredkin Gates. So the circuit can be realized with at least
Thus, each Fredkin gate chooses between two input lines it n(k-1) + n/2 number of Fredkin gates.
receives and performs the appropriate operation according to
the select input of that particular stage. Hence, for the first
stage (Stage 0) of above (4:2) shifter, the first Fredkin gate will Theorem 2. Let n be the total number of data input bits
either select input i0 or i1, the second one will do either i1 or i2 and k be the shift value bit of a unidirectional reversible shifter.
and so on. All other stages perform the selection task in the Let fe be the total number of Feynman Gates for producing fan
same way. outs, then
fe = n(k-1)

96
Proof: Each Feynman gate produces two copies of single GO 244 52
input as described in Section 4. For the proposed n-bit barrel D 132 28
shifter each stage requires copying each input twice, but for the
fr 992 144
design pattern the last stage of the shifter does not need the
copying circuits. So the circuit can be realized with at least (32, 5) fe 992 128
n(k-1) number of Feynman Gates for fan out operations. GO 997 133
D 517 52

Theorem 3. Let n be the total number of data input bit and fr = Total number of Fredkin gates
k be the shift value of a unidirectional reversible barrel shifter. fe = Total number of Feynman gates
Let GO be the total number of garbage outputs of the proposed GO = Total number of Garbage Outputs
shifter, then D = Total Delay of the circuit
GO = n(k-1) + k
Proof: The number of Garbage output is proportional to
the number of Fredkin gates as each Fredkin gate except the Table 2. Comparison of the quantum cost of the barrel
last one of each stage produces at least one garbage bit. The shifters
last Fredkin gate of each stage adds an extra garbage bit to the Existing Design [7]
(n, k) Proposed Design
shifter. On the other hand, for the last stage of shifting
operation the cascaded Fredkin gates produces only one extra (4, 2) 72 34
bit. Thus the (k-1) number of stages produce a total of n(k- (8, 3) 336 116
1)+(k-1) Garbage bits and last stage adds only one garbage bit. (16, 4) 1440 328
Thus, the proposed shifter produces n(k-1) + (k-1) + 1 which is
n(k-1)+ k number of garbage outputs. (32, 5) 5952 848

4.5. Comparative study between the reversible barrel 5. Conclusion


shifters

Comparing with the existing barrel shifter to the proposed In this paper, an efficient novel logarithmic reversible
one, we observe the result shown in Table 1 and Table 2. From Barrel Shifter has been proposed. Then based on reversible
Table 1 we can see that the proposed circuit requires less circuit designing criteria several theorems have been proposed
number of gates, produce less garbage outputs. The delay costs for total number of gates required by the combinational circuit.
(D) of the two circuits have also been calculated according to The Garbage outputs, delay and quantum cost have also been
the definition [4]. The quantum cost of the circuit, calculated estimated. At last a comparison study between the only existing
according to the [9], is also shown in Table 2 which proves that circuit and the proposed one has been shown. At present, the
the present circuit performs much efficiently than the previous proposed barrel shifter is capable of left shift/rotate. Future
one. The performance improves as the size of the circuit grows. enhancements include bi-directional shift and shift/rotate
operations, logical or arithmetic shift operations. In that case,
more control inputs are needed to be added in the circuit.
Table 1. Comparative study of the reversible barrel
shifters
Existing Proposed
6. References
Criteria
(n, k) Design [7] Design
fr 12 6 [1] Rolf Landauer, "Irreversibility and Heat Generation in the
(4, 2) Computing Process," IBM Journal of Research and Development,
fe 12 4
vol. 5, pp. 183-191, 1961.
GO 14 6
D 10 6 [2] C.H. Bennett, Logical reversibility of computation, IBM J. Res.
fr 56 20 Dev. 17 (1973) 525-532.
(8, 3) fe 56 16
59 19 [3] Hafiz Md. Hasan Babu, Md. Rafiqul Islam, Ahsan Raja
GO
Chowdhury and Syed Mostahed Ali Chowdhury, “Reversible Logic
D 35 14 Synthesis for Minimization of Full-adder Circuit”, IEEE Conference
fr 240 56 on Digital System Design 2003, Euro-Micro’03, Belek, Antalya,
(16, 4) Fe 240 48 Turkey, 2003, pp. 50-54.

97
[4] Voyiatzis, D. Gizopoulos, and A. Paschalis, “Accumulator-Based
Test Generation for Robust Sequential Fault Testing in DSP Cores in
Near-Optimal Time” , IEEE Transactions on Very Large Scale
Integration (VLSI) Systems, Vol. 13, No. 9, pp. 1079– 1086,
September 2005.

[5] Paul Metzgen, “Optimizing a High Performance 32- Bit Processor


for Programmable Logic”, Proceedings of International Symposium
on System on Chip, 16-18 Nov. 2004.

[6] Thomas Conway, “Galois Field Arithmetic OverGF(pm) For


High-Speed/Low-Power Error-Control Applications”, IEEE
Transactions on Circuits and Systems, Vol. 51, No. 4, April 2004.

[7] Gorgin, S.; Kaivani, A, “Reversible Barrel Shifters,” Computer


System and applications, 2007. AICCSA apos;07. IEEE/ACS
International Conference on Volume, Issue , 13-16 May 2007
Page(s): 479 – 483.

[8] Ashis Kumer Biswas, Lafifa Jamal and Hafiz Md. Hasan Babu,
“An Efficient Design of Parallel Loading Shift Register Using
Reversible Flip-Flops,” Advanced Technical Program, VLSI-SOC,
16th IFIP/IEEE international conference on very large scale
integration, 13-15 October, 2008.

[9] Ashis Kumer Biswas, Md. Mahmudul Hasan, Ahsan Raja


Chowdhury, Hafiz Md. Hasan Babu, “Efficient approaches for
designing reversible binary coded decimal adders,” Volume 39, Issue
12 (December 2008), p. 1693-1703, ISSN:0026-2692, Elsevier
Science Publishers B. V.

[10] Richard P.Feynman, "Quantum mechanical computers,"


Foundations of Physics, vol. 16, no. 6, pp. 507-531, 1986.

[11] E. Fredkin, T. Toffoli, Conservative logic, International Journal


of heoretical Physics 21 (1982) 219-253.

[12] Edward Fredkin and Tommaso Toffoli, "Conservative Logic,"


International Journal of Theoretical Physics, vol. 21, pp. 219-253,
1982.

[13] Wayne Wolf , Modern VLSI design, Prentice Hall, 2002.

[14] Paul Gigliotti, Implementing Barrel Shifters Using Multipliers,


XAPP195 (v1.1) August 17, 2004.

[15]Pillmeier, Matthew R.;Schulte, Michael J.;Walters, Eugene G.,


“Design alternatives for barrel shifters, ” III Advanced Signal
Processing, Algorithms, Architectures, and Implementations XII.
Edited by Luk, Franklin T. Proceedings of the SPIE, Volume 4791,
pp.436-447 (2002).

98

You might also like