Visual walkthrough — Barrel shifters
This page is the picture version of the parent note. Read it slowly; each step has one figure that is the argument.
Step 1 — What "shift" even looks like
WHAT. Before any circuit, let us agree what a shift does to a row of bits. A word is just a line of boxes, each holding a or a . We number the boxes from the right: box , box , box , … The number in a box is its index . "Shift left by " means: whatever sat in box now sits in box . Everything slides toward the high-index (left) end.
WHY. If we cannot say precisely which box copies from which box, we cannot build wires. The whole circuit is nothing but "box gets its value from box ".
PICTURE. In the figure, the pale-yellow arrows show every bit hopping box to the left. The box that would need input from box (off the right edge) has no source — so we pour in a (chalk-pink). That pink zero is the "fill" and it is the heart of the difference between shift and rotate later.

Step 2 — Why not just shift by 1, over and over?
WHAT. The simplest shifter moves everything by exactly one box. To shift by 7, you would feed the output back in and run it 7 times.
WHY IT'S BAD. Each pass costs a clock tick. Shift-by-7 = 7 ticks; shift-by- = ticks. A processor shifts every cycle, so a -cycle shifter would freeze the whole pipeline. We need the answer in one pass — a purely input-driven, no-clock (combinational) device.
PICTURE. The figure stacks the slow machine (a staircase of tiny 1-hops, one per clock, drawn in chalk-blue with a ticking clock) against the goal (one big jump, pale-yellow). The visual contrast — many small stairs vs. one leap — is the entire motivation.

Step 3 — The trick: any distance is a sum of powers of two
WHAT. Instead of jumps of , allow only jumps that are powers of two: Then every distance is built by switching some of these jumps ON and the rest OFF.
WHY THIS WORKS. Every whole number has exactly one binary form — it is a sum of distinct powers of two (Binary Number Representation). Example: . So to move , switch on the -jump, the -jump, the -jump, leave the -jump off. No number needs two copies of the same jump, which is why one switch per power of two is enough.
PICTURE. The figure shows a row of ON/OFF sliders labelled . Above each, its binary weight; the ON sliders (pale-yellow, lit) are and their little jumps chain into one big -arrow at the bottom.

Step 4 — One switch = one 2-to-1 multiplexer
WHAT. Each ON/OFF slider is, in hardware, a 2-to-1 multiplexer (see Multiplexers). A 2:1 mux is a chalk-drawn "Y": two input wires, one select wire , one output. When the top input passes; when the bottom input passes.
WHY A MUX AND NOT SOMETHING ELSE. We need a device that answers one yes/no question — "do I take the un-shifted bit, or the shifted-by- bit?" A 2:1 mux is exactly that question in silicon; nothing simpler chooses between two wires under one control bit.
PICTURE. The figure draws one output bit fed by two candidate wires: (the "stay put" bit, chalk-blue) into input , and (the "shifted" bit, pale-yellow) into input . The select line tips the switch.

Step 5 — A whole stage is one row of these muxes
WHAT. Stage is copies of that mux side by side — one mux per output box — all sharing the same select bit . When the entire row shifts by ; when the entire row passes straight through.
WHY. Every output box needs its own decision ("did I get a shifted bit or a stay-put bit?"), but they must all obey the same switch, or the word would tear apart. Hence one shared , muxes.
PICTURE. The figure shows stage (jump of ) on a small word: the diagonal pale-yellow wires carry each up to box ; the vertical chalk-blue wires are the pass-through path. The boxes at the bottom right () are fed chalk-pink s.

Step 6 — Cascade the stages; the shifts add up
WHAT. Stack the stages in a column: the output of stage feeds stage , whose output feeds stage , and so on. Stage contributes to the total displacement.
WHY THE SUM COMES OUT RIGHT. Passing a bit through stage after stage just adds each stage's jump. The bits that get through jumps of , then , then have moved places. That is precisely — the same sum from Step 3, now realised as a physical stack.
PICTURE. The figure is a vertical cascade for , . Lit stages (, pale-yellow) show their diagonal jumps; the dark stage (, dimmed) is a straight pass-through. A single bit is tracked (chalk-pink dot) from box to box .

Step 7 — The degenerate & edge cases (never skip these)
WHAT & WHY & PICTURE. Four scenarios you must be sure about, each drawn in its own panel:
- (shift by nothing). All , every stage passes straight through. Output = input. The circuit always has this case — it is the "identity" and costs no extra hardware.
- (the maximum). For , : all stages ON. This is the busiest wiring; the picture shows every diagonal lit at once.
- Fill vs. wrap at the edge. For a logical shift, boxes with take a (chalk-pink). For a rotate, those same boxes take the bit that fell off — index (chalk-blue loop-around wire). Same mux, different wire.
- Order doesn't change the data. Because stages only add displacements, swapping stage order still totals . The picture shows two orderings landing the same bit in the same box.

Step 8 — Why the whole thing is fast (the payoff)
WHAT. Count the pictures we drew: stages, each stage muxes.
WHY IT MATTERS. A signal crosses only mux layers top-to-bottom, so delay grows logarithmically — the same trick behind carry-lookahead adders and behind why float normalisation can shift a mantissa in one cycle.
PICTURE. The figure plots the naïve shifter's delay (, a steep line) against the barrel shifter's delay (, a nearly flat curve), with marked: stages, muxes.

The one-picture summary
One figure compresses the whole derivation: the binary digits of on the left flip the stage switches; each ON stage adds its power-of-two jump; the jumps chain into the total displacement on the right.

Recall Feynman retelling — the whole walkthrough in plain words
Picture a shelf of books you want to slide any number of spaces in one push. You are only allowed helpers who each push by a fixed jump: one pushes by 1, one by 2, one by 4, one by 8. To move the books 13 spaces you switch ON the 8-helper, the 4-helper, and the 1-helper (because ) and leave the 2-helper off. Each helper is a tiny two-way switch (a multiplexer): OFF means "leave the book where it is", ON means "hand it to the book that's a jump away". Stack the helpers in a column — the book falls through them one after another and lands exactly 13 spaces over. If a book would slide off the right edge, you either drop a blank (a shift) or send it back in from the left (a rotate) — same helpers, just a different wire for the edge. With only 4 helpers you cover every distance from 0 to 15, and a signal only ever crosses 4 layers, which is why the whole thing is lightning fast.
Connections
- Multiplexers — the 2:1 mux of Step 4 is the atom of every stage.
- Binary Number Representation — Step 3's sum-of-powers is just binary.
- Combinational Circuits — no clock; Step 2's motivation.
- Shift and Rotate Operations — Step 7's two flavours.
- Logarithmic Delay Structures — Step 8's depth.
- Floating Point Normalization — a real consumer of single-cycle shifts.