Barrel shifter

From Wikipedia, the free encyclopedia

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 multiplexors. In this particular 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 multiplexors required is n*log2(n), for an n bit word. 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
  • 16-bit — 16 * log2(16) = 16 * 4 = 64
  • 8-bit — 8 * log2(8) = 8 * 3 = 24

For example a four-bit barrel shifter, with inputs A, B, C and D. The shifter can cycle the order of the bits ABCD. 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 vital component in microprocessors (alongside the ALU).

The barrel shifter is used in floating-point arithmetic hardware. For a floating-point add or subtract operation, the mantissae of the numbers must be aligned, which requires shifting the smaller number 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.

[edit] External links

[edit] References

This article was originally based on material from the Free On-line Dictionary of Computing, which is licensed under the GFDL.

In other languages