In general, a barrel shifter can implement arithmetic shifting, logical
shifting and rotation functions. For instance, an N-bit barrel shifter
can shift left or right by N-1 bits. The signals for the input, output,
and shift functions for an N-bit barrel shifter are given as following:
Data In = (2*N-1 bit)
Shift Amount = (log2 (N) bit)
Data out = (N bit)
It should be clear that the principal distinction between a barrel shifter
and an ordinary shifter is the amount of bits being shifted at one time.
A common shifter will usually only shift one bit per cycle, whereas, a
barrel shifter can shift many bits at once.
Objective:
Our objective
was to design, simulate, and layout a circuit for an 8 bit Barrel Shifter.
The functionality of the shifter includes logical shifting, arithmetic
shifting, and rotation.
The first
step was designing the circuit. This was accomplished by using a
Mentor Graphics tool called Design Architect. The design was then
broken into smaller pieces so we could easily build and test each function
of the circuit. Since the design uses 8 bits, we decided it should
shift in stages. The first stage would shift by four bits, the second
by 2, and the third shifted by 1 bit for a total of 7 bits being shifted.
A total of twenty-four 4-to-1 Multiplexers were used in our design, 8 Multiplexers
for each stage. The Multiplexers at each stage would shift in bits
according to the shift amount. As an example, if the shift amount
was 4, only the first stage would be activated allowing the bits to be
shifted only by 4. To allow "zero's to shift in while logical
shifting, we simply hard wired "zero's" at each of the inputs on the first
stage of Multiplexers. Using this technique, logical shifting was
obtained.
Our next goal
was arithmetic shifting. This function was very simple to implement.
All that was needed was one AND gate connected to the last four inputs
on the first stage. This would copy the MSB (most significant bit)
and shift it in according to the shift amount. That is, if MSB is
"one", it would be shifted in 4 times if the shift amount was also 4 (only
right shifting carries the MSB).
Finally, we
wanted the Barrel Shifter to rotate. We noticed, when logical shifting,
that the bits shifted were "falling off" the ends of the Multiplexers.
To rotate the bits, we needed to "catch" these bits which were being lost.
To do this, a 2-to-1 Multiplexer was implemented in the circuit for every
lost bit. Thus, the design required twelve 2-to-1 Multiplexers.
(see circuit schematic)