EcrioniX Logic

The Barrel Shifter Circuit

A Barrel Shifter is a digital circuit that can shift a data word by a specified number of bits in a single clock cycle. Unlike a standard shift register which shifts one bit per clock cycle, a barrel shifter uses purely combinational logic (Multiplexers) to shift data instantly.

It is a critical component in ALUs (Arithmetic Logic Units) for operations like multiplication, division, and floating-point arithmetic.

1. Why "Combinational"?

Sequential shift registers require $N$ clock cycles to shift $N$ bits. A Barrel Shifter accomplishes this in essentially zero time (gate propagation delay only) by routing the input bits to the correct output positions using a network of multiplexers.

2. Architecture: The Mux Array

A standard $N$-bit barrel shifter is constructed using $\log_2(N)$ stages of multiplexers. For a 4-bit shifter:

  • Stage 1 (Controlled by S0): Shifts data by 1 bit if $S0=1$, or passes through if $S0=0$.
  • Stage 2 (Controlled by S1): Shifts data by 2 bits if $S1=1$, or passes through if $S1=0$.

By combining these stages, any shift from 0 to 3 positions can be achieved (e.g., Shift 3 = Shift 2 + Shift 1).

3. Operation Modes

Logical Shift

Left (LSL): Bits move left. Zeros fill in from the right.
Right (LSR): Bits move right. Zeros fill in from the left.

Rotate (Circular)

Rotate Left (ROL): Bits shifted out from the left wrap around to the right.
Rotate Right (ROR): Bits shifted out from the right wrap around to the left.

4. Applications

  • DSP Processors: Fast scaling and normalization of data.
  • Floating Point Units: Aligning mantissas during addition/subtraction.
  • Bit Field Manipulation: Extracting or packing data packets in networking.

Data Input (4-Bit)

D3D2D1D0
Value: 0 (0x0)

Shift Control

Shift Amount 0
Operation Mode

Output Result

0
0
0
0
2-Stage Mux Array
MUX 1 0 STAGE 1 (Shift 1) S0 STAGE 2 (Shift 2) S1 D3 D2 D1 D0