From Wikipedia, the free encyclopedia
A barrel shifter is a digital circuit that can shift a data word by any number of bits in a single cycle. It is implemented as a sequence of multiplexors: 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 multiplexors required is n*log2(n), where n is the computer's register size. Four common word sizes and the number of multiplexors needed are listed below:
- 64-bit -- 64 * log2(64) = 64 * 6 = 384
- 32-bit -- 32 * log2(32) = 32 * 5 = 160
The barrel shifter is used in floating-point arithmetic hardware. For a floating-point and or subtract operation, the fractions of the numbers must be aligned, which requires shifting the smaller number (in magnitude) to the right, increasing its exponent, until it matches the exponent of the larger number. This is done by subtracting the exponents, and using the barrel shifter to shift the smaller number to the right by the difference, in one cycle. If a simple shifter were used, shifting by n bit positions would require n clock cycles.
Ref. University of Hamburg's Java Barrel shifter


