Multiplexer
A multiplexer selects one of several data inputs and routes it to a single output under the control of select lines.
What it does
A multiplexer, or mux, is a controlled switch. It has several data inputs, one output, and a set of select lines. The select value chooses which data input is connected to the output. A mux with 2 to the n data inputs needs n select lines.
Two-to-one example
| S | OUT |
|---|---|
| 0 | D0 |
| 1 | D1 |
With one select line, S=0 passes D0 and S=1 passes D1. The Boolean form is OUT = (NOT S AND D0) OR (S AND D1).
Building larger muxes
- A 4-to-1 mux uses two select lines and one AND term per data input.
- Wider muxes are built as trees of smaller muxes to limit fan-in.
- A bank of identical muxes sharing select lines routes multi-bit words.
- Adding an enable input allows the output to be forced inactive.
A universal function block
A mux can implement any Boolean function directly: wire the function's truth-table outputs to the data inputs and drive the select lines with the variables. This makes the multiplexer a flexible logic element, a role it plays inside field-programmable devices.
In code
python
def mux(inputs, sel):
return inputs[sel] # sel indexes the chosen data inputWhere it appears
Multiplexers route data in processors, select register sources for an arithmetic unit, share pins among functions, and serialize parallel data. The reverse operation, sending one input to a chosen output, is a demultiplexer.