Computing Library › Digital Logic & Circuits
Digital Logic & Circuits

Multiplexer

A multiplexer selects one of several data inputs and routes it to a single output under control of select lines.

What it does

A multiplexer, or mux, is a data selector. It has 2^n data inputs, n select lines, and one output. The binary value on the select lines chooses which data input reaches the output. A 2-to-1 mux picks between two inputs with one select bit.

2-to-1 logic

Kronos motion — control room

For a 2-to-1 mux with inputs D0 and D1 and select S, the output is Y = (NOT S AND D0) OR (S AND D1). When S = 0 the output follows D0; when S = 1 it follows D1.

Truth table

SD0D1Y
0000
0101
1000
1011

Uses

Multiplexers route signals in a datapath: selecting which register feeds an operation, choosing between an immediate and a register value, or picking the next program counter source. Larger muxes are built by cascading smaller ones in a tree.

As a function generator

A 2^n-to-1 mux can implement any Boolean function of n variables by wiring the function's truth-table outputs to the data inputs and the variables to the select lines. This makes the mux a universal building block.

In code

python
y = d1 if s else d0