The Shifter

Here's a little trick:

In the previous figure, X (that's really X3X2X1X0) is always two times A (A2A1A0). A nice feature of binary numbers is that to multiply a number by two, all that is needed is to shift it left one position. Just like in decimal where 007 shifted left is 070--ten times larger--so 001 (one) shifted left is 010 (two). This works for any binary number. Two times 011 (three) is 110 (six), and 1111 (fifteen) times two is 11110 (thirty).

So we have a way to multiply by two. But what about four? Just shift left twice. And using multiplexers, we can control how much to shift our input. Below, the input S, controls what X is in relation to A.

Here if S is 00 then X = A (because X3=A3, X2=A2, X1=A1, and X0=A0). If S is 01 then X = 2A (X3=A2, X2=A1, X1=A0, and X2=0). Likewise when S is 10, X = 4A, and when it's 11, X = 8A.

Mirror this and we can also shift right, thereby dividing by two. It's a simple device, but it can be quite useful at times.