Skip to content
digiwleeaLearn
Open the lab →

The multiplexer

Choosing a signal

7 min read

A multiplexer (mux) is a data selector: its select inputs choose which one of several data inputs is passed through to the single output. It is the switch that decides which source drives a wire or bus.

You met this block already, tucked inside the register bit: the part that chose between new data D and the held value Q. Pulled out on its own it is called a multiplexer, or mux: a selector that takes several data inputs and one select input, and passes exactly one data input through to the output. It is how a CPU decides which value to put on the bus, so it shows up everywhere from here on. Try the smallest one live in the 2:1 multiplexer circuit.

The 2-to-1 mux

Start with two data inputs A and B and one select line SEL. The rule is simple: when SEL = 1 the output is A; when SEL = 0 the output is B. One control bit chooses between two data bits. Wider muxes follow the same recipe; see the live 8-to-1 multiplexer build and the 16-to-1 multiplexer built as a tree of 4-to-1 muxes.
Picture a set of railway points: two tracks (A and B) merge into one, and the lever (SEL) decides which incoming track the single outgoing track is connected to. The data just rides through; the control line throws the switch. A mux is that lever for signals.
SELABY
0000
0011
0100
0111
1000
1010
1101
1111
When SEL = 0, Y follows B (look at the top four rows: Y equals B). When SEL = 1, Y follows A (bottom four rows: Y equals A).

Building it from gates

The logic is a sum of two guarded terms. Pass A through only when SEL is 1, pass B through only when SEL is 0, and OR the two results. Since SEL and NOT SEL are never both 1, at most one term is live at a time, so the OR just forwards whichever one is active.
Y = (A·SEL) + (B·SEL')
  1. Invert SEL with a NOT to get NOT SEL.
  2. AND A with SEL: this is A when selected, else 0.
  3. AND B with NOT SEL: this is B when selected, else 0.
  4. OR the two AND outputs. Exactly one can be nonzero, so Y is the chosen input.
A 2-to-1 multiplexer (MUX2) selecting A or B by SEL. This is the exact selector from the register bit, drawn on its own. Open it in the lab and flip SEL to watch the output switch between A and B.

Wider muxes: choosing from four

To choose among four inputs D0-D3 you need a 2-bit select S1 S0, because two bits count to four. The clean way is a small tree: one mux picks D1 vs D0, a second picks D3 vs D2 (both steered by S0), and a third mux picks between those two results using S1. The output is D numbered by the binary value S1 S0. The same trick scales: eight inputs need a 3-bit select, sixteen need 4 bits.
Try it
On the 4-input mux tree, you set the select to S1 S0 = 10. Which data input D0-D3 reaches the output? And in general, how does the select code name the chosen input?
Build it in the lab ↗
To select a whole byte instead of a single bit, use eight muxes in parallel, all sharing the same SEL line, one per bit position. That is a bus-wide 2-to-1 mux: it routes one of two 8-bit buses onto the output, which is exactly how a CPU points its bus at one source or another.
A mux chooses a value. Its mirror image routes a value to one of several places, and its close cousin selects one line out of many from an address. That addressing block is the decoder, and together the mux and decoder are how memory and registers get wired to a shared bus.
Spot the fault
A1B0SELZYX
Look at SEL
Float (Z)
The select line was left unconnected, so it floats at Z instead of a clean 0 or 1. With no definite select the mux cannot choose a branch and its output goes indeterminate (X). Drive SEL from a real signal (an input, a control line, or an address bit); a mux is only as trustworthy as its select.

Frequently asked

What is a multiplexer?

A multiplexer (mux) is a data selector: its select inputs choose which one of several data inputs is passed through to the single output. It is the switch that decides which source drives a wire or bus.

How does a multiplexer work?

A multiplexer works like a rotary switch: the binary number on its select lines picks which one of its data inputs is routed through to the single output, and all the other inputs are ignored. Inside, each input is ANDed with its own decode of the select value and the results are ORed together, so exactly one input's value ever reaches the output. With n select bits it chooses among 2^n inputs.

How does a 2-to-1 multiplexer work?

It has two data inputs A and B and one select line SEL. The logic is Y = (A AND SEL) OR (B AND NOT SEL): when SEL = 1 the output is A, when SEL = 0 it is B. Exactly one term is ever live, so the OR just forwards the chosen input. The live multiplexer from NAND gates builds the same circuit from four NANDs.

How many select bits does a multiplexer need?

To choose among 2^n inputs you need an n-bit select. So 2 inputs need 1 select bit, 4 inputs need 2 bits, 8 inputs need 3 bits. The select read as a binary number is the index of the chosen input.

What is the difference between a multiplexer and a decoder?

A multiplexer chooses one of many inputs and forwards it to a single output. A decoder does the opposite addressing job: it takes a binary address and activates exactly one of many output lines. Mux is many-to-one, decoder is one-of-many.

What is the difference between a multiplexer and an encoder?

A multiplexer routes data: the binary number on its select lines picks which of 2^n data inputs is forwarded to the single output. An encoder produces an address: given 2^n lines with exactly one high, it outputs the n-bit number of the active line, and carries no data through at all. They also face opposite ways around the address: a mux consumes an address to move a value, an encoder generates the address itself (inside a mux, the select lines are decoded, the encoder's inverse job).

What is a 4-to-1 multiplexer?

A 4-to-1 multiplexer selects one of four data inputs (D0 to D3) using two select lines, since two bits address four choices. Its logic is Y = D0 S1' S0' + D1 S1' S0 + D2 S1 S0' + D3 S1 S0: four AND gates decoded by the select lines, feeding one OR. You can also build it from three 2-to-1 muxes. See a live, gate-level build in how to build a 4-to-1 multiplexer.

What is the difference between a multiplexer and a demultiplexer?

A multiplexer picks one of many inputs and sends it to a single output; a demultiplexer does the reverse, sending one input to one of many outputs, chosen by the same kind of select lines. Compare the live 4-to-1 multiplexer with the 1-to-4 demultiplexer.

Which ICs are multiplexers?

Common 7400-series parts are the 74HC151 (one 8-to-1 multiplexer), the 74HC153 (two 4-to-1) and the 74HC157 (four 2-to-1). The 74HC151 and 74HC157 run live with their pinouts.

Every lesson here builds toward one thing: a working CPU, from the transistor up.

Open the free lab →Or test yourself: the free placement exam takes 15 minutes →
Found this useful? Share itShare on X
Written by Taceddin SancakCreator of digiwleea. These lessons and the switch-level simulator every diagram runs on grew out of one goal: understand computers from the transistor up by building one.