a multiplexer
/ MUL-ti-plex-er /
A multiplexer, or mux, is hardware's way of saying 'choose one of these'. Picture a railway switch with several incoming tracks and one outgoing track: a control lever decides which incoming track is connected to the output. A mux has several data inputs, one output, and some select inputs; the value on the select lines picks which data input is passed straight through to the output, and the rest are ignored. It is the physical embodiment of an if-then-else or a switch statement — choosing a value based on a condition.
A 2-to-1 mux has two data inputs (call them I0 and I1), one select line S, and one output Y. When S=0 the output Y equals I0; when S=1 it equals I1. As a Boolean expression Y = (S' AND I0) OR (S AND I1) — a couple of AND gates gated by S and its inverse, joined by an OR. To choose among more inputs you use more select bits: a 4-to-1 mux has 2 select lines (00 picks I0, 01 picks I1, 10 picks I2, 11 picks I3), and in general a 2^n-to-1 mux needs n select lines. Wider data is handled by stacking identical muxes, one per bit.
Why it matters: the mux is everywhere inside a processor because so much of computing is selection. The datapath uses muxes to choose, say, whether an arithmetic unit's second operand comes from a register or from an immediate value baked into the instruction, or which result to write back. Control signals are simply the select lines, and the control unit's job is largely to set them correctly each cycle. So when you read that 'the control unit steers the datapath', the steering wheel is, very literally, a bank of multiplexers.
A thermostat that shows either the indoor or outdoor temperature on one display uses a 2-to-1 mux: I0 = indoor reading, I1 = outdoor reading, S = the 'outdoor' button. Press the button (S=1) and the display shows I1; release it (S=0) and it shows I0. One output, two sources, a single select bit.
A mux is an if-statement made of wires: the select line is the condition, the data inputs are the branches.
A mux selects one input to send to one output. Its mirror image, the demultiplexer, does the reverse — routing one input to one of several outputs — and is closely related to a decoder; do not confuse the two directions.