Barrel shifter

Schematic of a 4-bit crossbar barrel shifter. 'x' denotes input bits and y denotes output bits.

In computing, a barrel shifter is a combinational logic circuit that can shift a data word by a variable number of bit positions as specified by a binary input value. It may zero the vacated bits of the output word and thus perform a logical shift operation (e.g., logical shift left), or it may rotate all bits of the input word, either by design or as specified by one or more function select inputs.

A barrel shifter is often used to shift and rotate words in microprocessors, typically within a single clock cycle.

For example, consider a four-bit barrel shifter, with inputs A, B, C and D. The shifter can cycle the order of the bits ABCD as DABC, CDAB, or BCDA; in this case, no bits are lost. That is, it can shift all of the outputs up to three positions to the right (and thus make any cyclic combination of A, B, C and D). The barrel shifter has a variety of applications, including being a useful component in microprocessors (alongside the ALU).