Four inputs, two selector bits — pick any one and send it through. A ready-made routing circuit you can open in the TorchAnvil simulator.
The 2-to-1 mux uses a single selector bit to choose between two inputs.
Want to choose between four? You need two selector bits, because
two bits can name four different things: 00, 01, 10, 11. Each
combination picks a different input — I0, I1, I2, or I3 — and
forwards just that one to the output.
The selector bits S1 S0 act as a two-bit address. Each input has a
unique "permission pattern" made of S1/S0 and their negations:
I0 is allowed through when S1 S0 = 00 → gated by NOT S1 AND NOT S0I1 when S1 S0 = 01 → gated by NOT S1 AND S0I2 when S1 S0 = 10 → gated by S1 AND NOT S0I3 when S1 S0 = 11 → gated by S1 AND S0Each input runs through two AND gates in series to check both bits of
its pattern, then all four gated signals meet in a small OR tree:
OR(I0-gated, I1-gated) and OR(I2-gated, I3-gated), with a final OR
merging both halves. Only one path can be live at a time — the other
three are silenced by their AND gates — so the ORs really just forward
the survivor.
The formula, if you like it compact:
Out = (I0 · !S1 · !S0) + (I1 · !S1 · S0) + (I2 · S1 · !S0) + (I3 · S1 · S0)
A 4-to-1 mux is the generalization of the 2-to-1 and the template for
every wider mux. With n selector bits you address 2^n inputs.
Real CPUs use 8-to-1, 16-to-1, or wider muxes on their register files
to pick which register feeds the ALU on any given cycle. This pattern
also appears anywhere you're routing data from many sources to one
destination: video switchers, network crossbars, the inside of a
cache controller.
Notice the decoder hiding inside: the four AND pairs that gate each input are doing exactly what a 2-to-4 decoder does — turning two selector bits into four one-hot enable lines.
I levers on. Now sweep S1 S0 through 00 → 01 → 10 → 11. Out stays lit all the way — you're always pointing at
some input that's on.I2 on. The lamp lights only when S1 S0 = 10. The mux
is a spotlight — turn the selector dial and it sweeps across the
inputs.S1 S0 matches the input you set
to see the pattern.