## Shifters

A shifter is a circuit that produces an N-bit output based on an N-bit data input and an M-bit control input, where the N output bits are place-shifted copies of the input bits, shifted some number of bits to the left or right as determined by the control inputs. As an example, the function of an 8-bit shifter capable of shifting one, two, or three bits to the right or left is illustrated in the top row of Fig. 1 below. The control signals enable several different functions: two bits (A1 and A0) to determine how many bit positions to shift (0, 1, 2, or 3); a fill signal (F) determines whether bits vacated by shift operations receive a ‘1’ or a ‘0’; a rotate signal (R = ‘1’ for rotate) determines whether shifted-out bits are discarded or recaptured in vacated bits; and a direction signal (D = ‘1’ for right) determines which direction the shift will take.

When bits are shifted left or right, some bits fall off one end of the shifter, and are simply discarded. New bits must then be shifted in from the opposite side. If no fill input signal exists, then 0’s are shifted in (otherwise, the fill input defines whether 1’s or 0’s are shifted in to vacated bits). Shifters that offer a rotate function recapture shifted-out bits in vacated bits as shown in the lower row of Fig. 1 above.

Based on the shifter functions *shift, rotate, direction, fill,* and *number of bits*, many different shifter circuits could be designed to operate on any number of inputs. As an example of a simple shifter design, the truth table in Fig. 2 shows input/output requirements for a four-bit shifter that can shift or rotate an input value left or right by one bit (R=0 for shift, R=1 for rotate, D=0 for left, D=1 for right). Note the truth table uses entered variables to compress the number of rows that would otherwise be required. A minimal circuit can be found from the truth table in Fig. 2 using pencil-and-paper methods or a computer-based minimization program.

Shifters are most often found in circuits that work with groups of signals that together represent binary numbers, where they are used to move data bits to new locations on a data bus (i.e., the data bit in position 2 could be moved to position 7 by right-shifting five times), or to perform simple multiplication and division operations (exactly why a bit might want to be moved from one location to another on a data bus is left for a later topic). A shifter circuit can multiply a number by 2, 4, or 8 simply by shifting the number right by 1, 2, or 3 bits (and similarly, a shifter can divide a number by 2, 4, or 8 by shifting the number left by 1, 2, or 3 bits).

## Important Ideas

- A shifter is a circuit that produces an N-bit output based on an N-bit data input and an M-bit control input, where the N output bits are place-shifted copies of the input bits, shifted some number of bits to the left or right as determined by the control inputs.
- Based on the shifter functions shift, rotate, direction, fill, and number of bits, many different shifter circuits could be designed to operate on any number of inputs.
- Shifters are most often found in circuits that work with groups of signals that together represent binary numbers, where they are used to move data bits to new locations on a data bus (i.e., the data bit in position 2 could be moved to position 7 by right shifting five times), or to perform simple multiplication and division operations.