Computing Library › Classical Logic Gates
Classical Logic Gates

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

SOUT
0D0
1D1

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 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 input

Where 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.