Multiplexer
A multiplexer, usually called a mux, is a digital circuit that selects one of several input signals and routes it to a single output, with a separate set of select lines determining which input gets through at any given moment. A mux with four data inputs needs two select lines to choose among them, because two binary select bits can distinguish exactly four combinations — in general, an N-to-1 multiplexer needs the base-2 logarithm of N select lines, which is why mux sizes almost always come in powers of two. How a multiplexer actually routes a signal, from multiple candidates down to one chosen output, looks like this:
A few things are worth knowing about why a multiplexer is one of the most heavily used building blocks on a chip, far beyond its role as a simple signal switch:
A multiplexer's select-line count grows logarithmically with the number of inputs, not linearly, which is exactly why a mux scales so efficiently as the number of signals that need to share one path grows. Choosing among 2 inputs needs just 1 select line, choosing among 8 needs 3, choosing among 64 needs only 6 — each additional select line doubles the number of inputs that can be addressed, because the select lines are being decoded as a binary address rather than used one-per-input. This efficient scaling is precisely why a mux is the standard tool whenever many signals need to share a single, narrower path: a 64-to-1 mux routes any one of 64 full-width signals to one output using only 6 control bits, a far cheaper proposition than wiring 64 separate dedicated paths all the way to wherever that data needs to go.
A multiplexer's job isn't restricted to steering data signals around a chip — the same select-and-route mechanism is also a complete tool for implementing arbitrary logic functions, a trick called using a mux as a lookup table. Because a mux's output depends entirely on which input is selected, wiring fixed 0s and 1s onto its data inputs instead of live signals turns the select lines themselves into the logic function's actual inputs — the mux then outputs whatever fixed value was wired to the input address matching the select lines, reproducing any truth table that fits within its input count. This is precisely the mechanism behind a field-programmable gate array's lookup tables, the basic programmable logic cell that an FPGA is built from: each lookup table is fundamentally a multiplexer with its data inputs loaded from on-chip configuration memory, letting the same hardware implement a different logic function simply by changing what's stored in that memory.
Bus arbitration — deciding which of several devices gets to use a shared communication path at any given moment — is a direct, large-scale application of the same selection principle a small mux implements at the gate level. When multiple functional blocks on a chip, say several processor cores or peripheral controllers, all need occasional access to one shared memory bus, a multiplexer sits at the point where their individual paths converge, with an arbitration circuit driving the select lines to grant access to exactly one requester at a time based on priority or round-robin rules. This is the same core problem a tiny 2-to-1 mux solves for a pair of signals, just scaled up to arbitrate among many competing devices for a shared, expensive resource — the mux's job stays identical even as the stakes and scale grow dramatically.
A demultiplexer performs the exact inverse operation — one input routed out to one of several possible outputs based on select lines — and recognizing that symmetry explains why the two are almost always discussed as a pair. Where a multiplexer answers "which of these many inputs should become my one output," a demultiplexer answers "which of my many outputs should this one input become," using the identical select-line decoding logic in the opposite direction. The two are frequently chained together in real designs: a demultiplexer fans a signal out to one of several destinations, and a multiplexer elsewhere fans several sources back down to one shared path, together forming the standard pattern for sharing one physical resource — a bus, a test pin, a communication channel — among many logical signals that each only need it some of the time.
Read a multiplexer as a logarithmically efficient selector, not just a simple switch: its select-line count scales as the logarithm of its input count rather than growing one-for-one, which is exactly what makes it the standard tool for sharing a scarce path among many signals, for building programmable logic out of configuration memory, and for arbitrating access to any resource that multiple parts of a chip need but can't all use simultaneously.