← Back to blogDemultiplexer

Demultiplexer Tutorial: 1-to-4 and 1-to-8 (DEMUX)

A demultiplexer routes one input to one of several outputs based on a select code. Learn the truth tables, gate-level designs, and where DEMUX shows up in CPUs.

DennyDenny
7 min read
Chalkboard feature illustration for “Demultiplexer Tutorial: 1-to-4 and 1-to-8 (DEMUX)”

TL;DR: A demultiplexer (DEMUX) is a combinational circuit that takes one data input and routes it to one of 2n2^n output lines, with the destination chosen by an n-bit select code. All non-selected outputs are held at 0. A DEMUX is functionally a decoder whose enable input has been replaced by the data input.

The demultiplexer is the routing counterpart of the multiplexer: a multiplexer picks one of many inputs to drive one output, while a demultiplexer takes one input and steers it to one of many outputs. Inside a CPU, DEMUX-shaped decode logic can decide which register accepts a write, which memory bank receives a qualified strobe, or which functional unit receives an enable. The selected path is one-hot, but the block should not be assumed safe for routing a raw clock; clock networks require dedicated gating or clock-multiplexer resources with explicit timing guarantees.

What is a demultiplexer?

A demultiplexer is a combinational circuit with one data input D, n select inputs Sn−1…S0S_{n-1}\ldots S_0, and 2n2^n output lines Y2n−1…Y0Y_{2^n-1}\ldots Y_0. The output addressed by the binary value of S equals D; every other output is 0. Symbolically:

Yi=D⋅miY_i = D \cdot m_i

where mim_i is the i-th minterm of the select inputs — that is, the AND of the select bits in the appropriate polarity to produce a 1 only when S = i.

This formulation makes the relationship to a decoder explicit: a decoder produces mim_i on each output line YiY_i. A demultiplexer produces D⋅miD \cdot m_i. Replace the decoder’s enable input with D, and the decoder becomes a demultiplexer. The 74139 IC (dual 2-to-4 decoder/demultiplexer) and the 74138 IC (3-to-8 decoder/demultiplexer) are sold as both, because the same silicon does both jobs.

For the multiplexer counterpart and the broader pair, see Multiplexers Demystified: The Data Traffic Controller.

The 1-to-2 demultiplexer

The smallest useful DEMUX has one data input, one select input, and two outputs:

SDY1Y0
0000
0101
1000
1110

The boolean equations:

  • Y0=D⋅S‾Y_0 = D \cdot \overline{S}
  • Y1=D⋅SY_1 = D \cdot S

Two AND gates and one inverter — that is the entire circuit. The pattern generalizes: each output is D ANDed with the appropriate minterm of the select inputs.

The 1-to-4 demultiplexer

Two select bits give four outputs:

S1S0Y3Y2Y1Y0
00000D
0100D0
100D00
11D000

Boolean equations:

  • Y0=D⋅S1‾⋅S0‾Y_0 = D \cdot \overline{S_1} \cdot \overline{S_0}
  • Y1=D⋅S1‾⋅S0Y_1 = D \cdot \overline{S_1} \cdot S_0
  • Y2=D⋅S1⋅S0‾Y_2 = D \cdot S_1 \cdot \overline{S_0}
  • Y3=D⋅S1⋅S0Y_3 = D \cdot S_1 \cdot S_0

Four 3-input ANDs and two inverters. Each AND output is exactly one of the four minterms of (S1,S0)(S_1, S_0) gated by D.

The structural similarity to a 2-to-4 decoder gives one implementation: produce the four select minterms, then AND each minterm with D. The result is a 1-to-4 demultiplexer. This Boolean decomposition is useful for reasoning, but it does not predict a physical implementation. A standard-cell library, programmable-logic fabric, synthesis constraints, polarity, fan-in and available enable pins determine which gates or cells are actually used. See Decoders and Encoders: Driving a 7-Segment Display for the decoder side. The AND operation that qualifies each output is covered in The AND Gate: Foundation of Digital Logic.

A standalone block is at /docs/demultiplexer-1to4; the toggleable simulator model is at /template/1-to-4-demultiplexer.

The 1-to-8 demultiplexer

Three select bits give eight outputs. The truth table doubles in height; each row sets a single YiY_i to D and the other seven to 0. The general equation:

Yi=D⋅∏j=02Sj(bj)Y_i = D \cdot \prod_{j=0}^{2} S_j^{(b_j)}

where bjb_j is the j-th bit of i and Sj(1)=SjS_j^{(1)} = S_j, Sj(0)=Sj‾S_j^{(0)} = \overline{S_j}. In plain English: each output is D ANDed with the minterm corresponding to its index. Eight 4-input ANDs and three inverters realize the entire function.

The 74138 IC implements this with active-low outputs (so the selected output goes to 0 and the others stay at 1) and three enable inputs that all must be in the right state to allow any output to assert. The active-low convention is convenient for chip-select fanout in memory systems — a typical use case where the DEMUX selects which RAM chip receives a read strobe.

The DigiSim model lives at /docs/demultiplexer-1to8 with the simulator template at /template/1-to-8-demultiplexer. The smaller 1-to-2 case is at /template/1-to-2-demultiplexer and the parent block at /docs/demultiplexer.

DEMUX from a decoder + AND

A direct gate-level implementation is to take decoder minterms and AND each one with the data input. For a 1-to-8 DEMUX:

S2,S1,S0 ──► 3-to-8 decoder ──► 8 minterm lines m0..m7

D ──┐
    ├── AND ── Y0  (D AND m0)
    ├── AND ── Y1  (D AND m1)
    ...
    └── AND ── Y7  (D AND m7)

If suitable decoded select terms already exist, a design may be able to reuse them. The actual cost is not necessarily “eight AND gates”: synthesis may absorb the enable into complex gates or dedicated decoder cells, while routing load and timing can make another structure preferable. Treat the diagram as a Boolean specification and let the target technology and implementation tools determine its physical form.

Use case 1: register file write port

A CPU register file has many registers and one or more write ports. For each ordinary single-destination write port, the destination index is decoded into one-hot write enables. The one-bit global write-enable acts like D in a DEMUX; its selected output enables one register. The multi-bit result bus is normally fanned out to the data inputs of all registers, and only the enabled register captures it. Routing the result bus itself would require one routing element per data bit and is not what a single-bit DEMUX symbol represents.

For a 16-register file, a 4-to-16 destination decoder qualified by write-enable produces the one-hot controls; a 32-register file uses a 5-to-32 equivalent. Real register files may have several write ports, banked arrays, hard-wired registers, collision rules and implementation-specific decoders, so the simple DEMUX model is an instructional starting point rather than a complete microarchitecture.

Use case 2: qualified enable and write-strobe distribution

Do not feed a raw clock through an ordinary combinational DEMUX. A select transition or unequal path delay can create a runt pulse, extra edge, duty-cycle distortion or skew. ASIC flows use characterized integrated clock-gating cells and glitch-controlled clock multiplexers; FPGAs provide dedicated clock-enable and clock-routing resources. In many synchronous designs, the global clock remains on the clock network and a one-hot enable selects which registers update.

A DEMUX can route a synchronous enable or a qualified memory-write strobe when its select inputs meet the required timing. In a banked memory, address decoding and the global write-enable combine to assert one bank’s write control. The data bus may be broadcast to the banks, while only the selected bank captures it. Hazard analysis, pulse-width requirements and setup/hold constraints still apply to the control path.

Use case 3: serial-to-parallel routing and audio switching

A 1-to-N DEMUX combined with a counter and storage can implement serial-to-parallel write steering: the counter scans the select inputs, and each incoming bit is presented to a different storage channel. A latch or flip-flop at each destination must capture and retain its bit; a DEMUX alone exposes only the current input on the currently selected output.

Related one-hot steering also appears in scanned displays, actuator enables and channel-selection logic. Analog switches can route an analog source among destinations, but their bidirectional behavior, on-resistance, bandwidth, charge injection and break-before-make timing are not captured by the digital AND-gate model.

DEMUX vs decoder: when to use which

The two blocks are dual-purpose silicon, but the language differs:

TermInputsOutputsTypical use
Decodern select + 1 enable2n2^n minterm linesAddress decoding, opcode decoding
DEMUXn select + 1 data2n2^n data linesQualified enable, strobe or single-bit data routing

If the input being routed is just an enable, the block is being used as a decoder. If the input being routed carries actual data, the block is being used as a demultiplexer. The IC is the same; the role differs.

Build it and route a single bit

Start with the 1-to-4 case at /template/1-to-4-demultiplexer and walk through the four select positions while toggling D — only one output follows D on each setting, while the others stay at 0. Then move to /template/1-to-8-demultiplexer for the wider version. To model a register write port, drive D with a one-bit write-enable, connect the outputs to register load controls, and fan the multi-bit data bus separately to the registers. The same one-hot control principle appears in a CPU flags register, where qualified enables determine which stored status bits update.

Apply the concept in a simulator model.