Digital logic

multiplexer (mux)

Picture a railway switchyard where several tracks all feed toward a single outgoing line. A switch operator throws a lever, and exactly one incoming track gets connected through to that line while the rest are ignored. A multiplexer is that switch operator in silicon: it has several data inputs, one output, and a separate select input whose job is to pick which one of the data inputs gets passed through to the output. Change the select value and you instantly reroute a different input to the same output wire.

More precisely, a multiplexer (almost always shortened to mux) is a combinational building block: in its common power-of-two form it has 2ⁿ data inputs, n select lines, and one output. The n select bits form a binary address — with two select bits you can name input 0, 1, 2, or 3, and the mux drives whichever one you addressed straight onto the output. (Widths that aren't a power of two, like a 3-to-1 mux, are perfectly ordinary too; they just leave some addresses unused.) Because the choice depends only on the current inputs — there is no memory — a mux settles to its answer as soon as the signals propagate through its gates. Internally it is just a small nest of AND, OR, and NOT gates, but you almost never draw it that way; "mux" is the unit you reason in.

The mux is the fundamental choose primitive of digital design, and it shows up everywhere once you start looking. Every time hardware has to ask "use this value or that one?" — selecting which register feeds an arithmetic unit, steering one of many results back to a CPU's output, or implementing the `if`/`case` choice you wrote in Verilog — a synthesis tool almost certainly built a mux to do it. Its mirror image is the demultiplexer, which takes one input and routes it out to one of many destinations.

// 2-to-1 mux: sel picks between a and b
assign y = sel ? a : b;

A 2-to-1 multiplexer — when sel is 1 the output y follows a, otherwise it follows b.

The name comes from the telephone-era practice of multiplexing — sharing one expensive line among many signals. In digital logic the word narrowed to mean this specific select-one-of-many block, and engineers pronounce it "mux" so habitually that the full word rarely gets spoken aloud.

Also called
muxdata selectorselector多路复用器多工器数据选择器資料選擇器