Multiplexer — The Digital Switch

Imagine a railway junction with multiple incoming tracks converging into a single outgoing track. A switch determines which incoming train gets to pass. A multiplexer (MUX) is the digital equivalent of that switch.

A basic 2-to-1 MUX has two data inputs (A and B), one select input (S), and one output. When S=0, the output equals A. When S=1, the output equals B. The select input is a control wire — it doesn't carry data, it makes a decision. This is fundamentally different from gates like AND or OR where both inputs are data.

Multiplexers are everywhere inside a processor. The ALU uses them to select which operation's result to output. The register file uses them to select which register to read. The program counter uses them to choose between "increment normally" or "jump to a new address." Without multiplexers, routing data inside a CPU would be impossible.

Practical example. In your processor's register file, you might have four 8-bit registers. To read register 2, a 4-to-1 multiplexer with 2 select bits (binary 10 = register 2) connects register 2's 8 output wires to the internal data bus. The other three registers are disconnected. The select bits come from the instruction decoder — the opcode literally chooses which register to read.