__ABSTRACT__

* *

A barrel shifter is a digital circuit that can shift a data word by a specified number of bits in one clock cycle. It can be implemented as a sequence of multiplexers (MUX), and in such an implementation the output of one MUX is connected to the input of the next MUX in a way that depends on the shift distance. The number of multiplexers required for an n-bit word is n X log2(n). A common usage of a barrel shifter is in the hardware implementation of floating-point arithmetic. A barrel shifter, comprising: an n-bit by n-bit transistor array arranged into n rows and n columns, wherein the source of a transistor in one row is connected to the source of a transistor in the next row; a first plurality of multiplexors, each having a first and a second input and an output; a second plurality of multiplexors each having inputs and an output, each multiplexor selecting one of three inputs depending on the data length; and a third plurality of multiplexors, each having a first and a second input and an output, the output is coupled to one transistor in each row of the array beginning with a transistor in a corresponding bit position in the second row and continuing with transistors in ascending bit positions.

* ** *

** HDL LANGUAGE : **VHDL

** SIMULATOR : **ISE SIMULATOR

** SYNTHESIS TOOL : **XILINX 9.1i

** TARGET DEVICE : **FPGA

** FAMILY : **SPARTAN 3E

__INTRODUCTION__

__1.1 Introduction to barrel shifter__

A hardware device that can shift or rotate a data word by any number of bits in a single operation. It is implemented like a {multiplexer}, each output can be connected to any input depending on the shift distance.

A barrel shifter is a digital circuit that can shift a data word by a specified number of bits. It can be implemented as a sequence of multiplexers. In this implementation, the output of one MUX is connected to the input of the next MUX in a way that depends on the shift distance. The number of multiplexers required is *n**log2(*n*), for an *n* bit word. Four common word sizes and the number of multiplexers needed are listed below:

- 64-bit — 64 * log2(64) = 64 * 6 = 384
- 32-bit — 32 * log2(32) = 32 * 5 = 160
- 16-bit — 16 * log2(16) = 16 * 4 = 64
- 8-bit — 8 * log2(8) = 8 * 3 = 24

Basically, a barrel shifter works to shift data by incremental stages which avoids extra clocks to the register and reduces the time spent shifting or rotating data (the specified number of bits are moved/shifted/rotated the desired number of bit positions in a single clock cycle). A barrel shifter is commonly used in computer-intensive applications, such as Digital Signal Processing (DSP), and is useful for most applications that shift data left or right - a normal style for C programming code.

Rotation (right) is similar to shifting in that it moves bits to the left. With rotation, however, bits which "fall off" the left side get tacked back on the right side as lower order bits, while in shifting the empty space in the lower order bits after shifting is filled with zeros.

Data shifting is required in many key computer *op*erations from address decoding to computer arithmetic. Full barrel shifters are often on the critical path, which has led most research to be directed toward speed optimizations. With the advent of mobile computing, power has become as important as speed for circuit designs. In this project wepresent a range of 32-bit barrel shifters that vary at the gate, architecture, and environment levels.

__FUNCTION OF BARREL SHIFTER__

Each shifter will be designed as** **a 16-bit shifter that receives a 16-bit input data value along with a two’s compliment encoded shift value, and will produce a 16- bit shifted result. This section will describe the internal design characteristics for each shifter.

__2.1 Architecture____ __

There are two common architectural layouts for shifts, array shifterand logarithmic shifters. An array shifter(Fig. 1) decodes the shift value into individual shift bit lines that mesh across all input data values. At each crossing point, a gate will either allow or not allow the input data value to pass to the output line, controlled by a shift bit line. The advantage of this design is that there is only ever one gate between the input data lines and the output data lines, so it is fast. The disadvantages of this design are the requirement for a decoder, and the fact that each input data line sees a load from every shift bit line.

**Fig. 1: Structure of an array shifter.**

In a logarithmic shifter(Fig. 2*), *the shifter is divided into *loga(n) *stages, where *n *is the input data length. Each bit of the encoded shift value is sent to a different stage of the shifter. Each stage handles a single, powerof- two shift. The input data will be shifted or not shifted by each of the stages in sequence. Five stages would be required when considering **32 **bit data. The advantage of a log shifter is that it has small area and does not require a decoder, but the disadvantage is that there are five levels of gates separating the input data from the output data.

There are two types of gates that are required for these shifters: the array shifter requires switches that will either propagate or not propagate an input data

bit, and the log shifter requires 2-to-1 muxes to propagate either a shifted or a non-shifted bit. In this project we will consider two types of CMOS switches: (1) ntype pass transistor switch; and **(2) **a full transmission gate switch; and we will consider four types of mux designs: (1) n-type pass transistor mux; (2) full transmission mux; (3) a static CMOS mux; and **(4) **a dynamic logic mux. The pass transistor and transmission gates are simple and fast, but will require occasional buffering to strengthen the signals in the log shifters. The static and dynamic gates are self buffering so no additional buffers are needed, but contain more transistors. The dynamic gate design is the only type that requires a clock signal for a precharge stage. Figure **3 **shows schematics for each gate design.__ __

__2.2 ARRAY SHIFT:__

An array shifter consists of four different shifts in each type of shift the data is shifted uniquely, depending on the direction and specification of the data to be shifted the shifts are titled. In the enclosed vhdl code for barrel shifter condition 1 specifies whether the shift desired is an array shift or logical shift. If the condition 1 is high then the array shift is implemented for shifting the bits in the user specified data. After the declaration of condition1 the desired shift is implemented by the next condition i.e condition2. In this condition the user can specify one of the four types of shifts by passing binary digits specified. The four types of array shifts are as follows

- Left shifting
- Right shifting
- Right Rotation
- Left Rotation

__2.2.1 LEFT SHIFTING:__

In the left shifting the given 16 bit data is shifted bit wise in left side. The number of bits to be shifted is intialized by the condition3. Depending on the number of bits to be shifted specified in condition 3 the given data is shifted bit wise to left and zeros are appended in the other side. For example let us consider a 4 bit input data as

Din= 0110. Let us assume the condition2 as 00 i.e left shifter and condition3 as 0001 i.e a single bit shift in left direction. Now the 4 bit data present in din is shifted to its left by one bit continuously till all the 4 bits are shifted. Therefore the output data is Dout=1100,1000,0000.

__2.2.2 RIGHT SHIFTING:__

In the right shifting the given 4 bit data is shifted bit wise in right side. The number of bits to be shifted is intialized by the condition3. Depending on the number of bits to be shifted specified in condition 3 the given data is shifted bit wise to right and zeros are appended in the other side. For example let us consider a 4 bit input data as

Din= 0110. Let us assume the condition2 as 01 i.e right shifter and condition3 as 0001 i.e a single bit shift in right direction. Now the 4 bit data present in din is shifted to its right by one bit continuously till all the 4 bits are shifted. Therefore the output data is Dout=0011,0001,0000

__2.2.3 RIGHT ROTATION:__

Right rotation is similar to right shifting, except that additional hardware is required to determine which values get shifted into the upper bits of the output. We consider three options: (1) a wrap around least significant bit for right rotation; (2) a sign bit for arithmetic right shifting; and (3) *GND *for signed magnitude right shifting. **A **3-to-1 control mux was added to each wrap around bit line. This mux allows either the rotation wrap-around bit, the sign bit, or *GND *to be selected. For example let us consider a 4 bit input data as Din= 0110. Let us assume the condition2 as 10 i.e right rotation and condition3 as 0001 i.e a single bit shift . Now the 4 bit data present in din is shifted to its right by one bit continuously till all the 4 bits are shifted. Therefore the output data is Dout=0011,1001,1100

__2.2.4 LEFT ROTATION:____ __

Left rotations can be accomplished by rotating right 32 - *Rotatereft *bits. *Rotate,i,ht *can be calculated by taking the two's-compliment of the *Rotateleft *value, which requires inverting all the *Rotateleft *bits and adding one. The inversion of the *Rotateleft *bits can be accomplished by adding muxes that pass either the shift bit or its inverse. The addition of one to *Rotateleft* can be accomplished in two ways: (1) include a 5 bit incrementor; or (2) add an additional one-bit shift stage.

Left shifting can be performed by right shifting 16 - *S h i f t l e f t *bits, and including an additional row of pull down gates that mask out the lower *n *bits of the *n* bit left shift. **A **second method is to initially reverse the input data bits and perform a right shift of length *Shiftleft, *and finally reverse the output bits. For example let us consider a 4 bit input data as Din= 0110. Let us assume the condition2 as 11 i.e. left rotation and condition3 as 0001 i.e a single bit shift . Now the 4 bit data present in din is shifted to its left by one bit continuously till all the 4 bits are shifted. Therefore the output data is Dout=1100,1001,0011,0110.

__2.3 LOGICAL SHIFT:__

A logical shifter consists of four different shifts in each type of shift the data is shifted uniquely, depending on the direction and specification of the data to be shifted the shifts are titled. In the enclosed vhdl code for barrel shifter condition 1 specifies whether the shift desired is an a logical shift or array shift. If the condition 1 is low then the logical shift is implemented for shifting the bits in the user specified data. After the declaration of condition1 the desired shift is implemented by the next condition i.e condition2. In this condition the user can specify one of the four types of shifts by passing binary digits specified. The four types of a logical shifts are as follows

- Logical Left shifting
- Logical Right shifting
- Logical Right Rotation
- Logical Left Rotation

__2.3.1 LOGICAL LEFT SHIFTING:__

In the logical left shifting the given 16 bit data is shifted bit wise in left side. The number of bits to be shifted is not user defined. In the logical shift 2n bits are sifted at a time where n=0,1,2,3…. The condition3 is not significant for logical shift. When the value of n=0 the number of shifts is a single bit shift and when n=2 the number of shifts is 4 and zeros are appended in the other side. For example let us consider a 4 bit input data as Din= 0110. Let us assume the condition2 as 00 i.e logical left shifter . Now the 4 bit data present in din is shifted to its left by one bit initially and goes on till all the 4 bits are shifted. Therefore the output data is Dout= 1100,0000.

__2.3.2 LOGICAL RIGHT SHIFTING:__

In the logical right shifting the given 16 bit data is shifted bit wise in right side. The number of bits to be shifted is not user defined. In the logical shift 2n bits are shifted at a time where n=0,1,2,3…. The condition3 is not significant for logical shift. When the value of n=0 the number of shifts is a single bit shift and when n=2 the number of shifts is 4 and zeros are appended in the other side. For example let us consider a 4 bit input data as Din= 0110. Let us assume the condition2 as 01 i.e logical right shifter . Now the 4 bit data present in din is shifted to its right by one bit initially and goes on till all the 4 bits are shifted. Therefore the output data is Dout= 0011,0000.

__2.3.3 LOGICAL RIGHT ROTATION:__

In the logical right rotation the given 16 bit data is shifted bit wise in right side. The number of bits to be shifted is not user defined. In the logical shift 2n bits are shifted at a time where n=0,1,2,3…. The condition3 is not significant for logical shift. When the value of n=0 the number of shifts is a single bit shift and when n=2 the number of shifts is 4 . instead of zeros getting appended the most significant bits are shifted to least significant bit positions. For example let us consider a 4 bit input data as Din= 0110. Let us assume the condition2 as 10 i.e logical right rotation . Now the 4 bit data present in din is shifted to its right by one bit initially and goes on till all the 4 bits are shifted. Therefore the output data is Dout= 0011,1100.

__2.3.4 LOGICAL LEFT ROTATION:__

In the logical left rotation the given 16 bit data is shifted bit wise in left side. The number of bits to be shifted is not user defined. In the logical shift 2n bits are shifted at a time where n=0,1,2,3…. The condition3 is not significant for logical shift. When the value of n=0 the number of shifts is a single bit shift and when n=2 the number of shifts is 4 . instead of zeros getting appended the most significant bits are shifted to least significant bit positions. For example let us consider a 4 bit input data as Din= 0110. Let us assume the condition2 as 11 i.e logical left rotation . Now the 4 bit data present in din is shifted to its left by one bit initially and goes on till all the 4 bits are shifted. Therefore the output data is Dout= 0011,1100.

**Applications of barrel shifter**

- Digital Signal Processing
- Array Processing
- Graphics
- Database Addressing
- High Speed Arithmetic Processors

__ FUTURE SCOPE:__

The design has been done for the 16-bit Barrel Shifter. The core can be used to design for further designs of 32-bit , 64-bit and so on to be utilized in DSP Processors and any communication systems like USB transmitters etc.

**Download your Full Reports for Barrel Shifter**

**Tags : **

Advertisements
####
Sponsored Links:-