G27
Self-checkedTier 1 12 min readdl.mux-demux

Multiplexers and demultiplexers

Selecting one of 2^n inputs with n select lines, the output equation, building larger multiplexers from smaller ones, implementing Boolean functions with a multiplexer using Shannon expansion, universality, and the demultiplexer.

Why it exists

A multiplexer (MUX) is a digital switch: it passes one of several data inputs to a single output, and the select lines say which. It is the circuit behind register-file reads, ALU result selection and bus sharing. It is also a universal building block: any Boolean function can be implemented by a multiplexer, which GATE tests with questions of the form "implement this function with a 4:1 multiplexer and what are the data inputs", "how many 2:1 multiplexers are needed for a 16:1", or "which function does this multiplexer circuit compute". The demultiplexer does the reverse: it routes one input to one of several outputs.

Prerequisites

You need the design flow from combinational design and minterm numbering from SOP, POS, minterms and maxterms.

Precise definitions

Multiplexer (2n2^n-to-1 MUX). It has 2n2^n data inputs I0,…,I2n−1I_0, \dots, I_{2^n - 1}, nn select lines Sn−1…S0S_{n-1} \dots S_0 and one output YY. The output is the data input whose index is the binary number on the select lines:

Y=∑i=02n−1mi(S) Ii.Y = \sum_{i=0}^{2^n - 1} m_i(S)\, I_i .

Here mi(S)m_i(S) is the minterm of the select variables. For the 2:1 and 4:1 cases:

Y2:1=S′I0+SI1,Y4:1=S1′S0′I0+S1′S0I1+S1S0′I2+S1S0I3.Y_{2:1} = S' I_0 + S I_1,\qquad Y_{4:1} = S_1'S_0' I_0 + S_1'S_0 I_1 + S_1S_0' I_2 + S_1S_0 I_3 .

A multiplexer often has an enable input EE: when E=0E = 0 the output is 0 (or off); Y=E⋅∑miIiY = E \cdot \sum m_i I_i.

Building larger multiplexers. A tree of smaller multiplexers works: the first level uses the low select bits and the next level uses the higher ones. The number of multiplexers needed to build a 2k2^k-to-1 multiplexer from 2-to-1 multiplexers is 2k−12^k - 1 (a binary tree with 2k2^k leaves). In general, build the first level with ⌈N/s⌉\lceil N / s \rceil multiplexers of size ss and repeat on their outputs. For example a 16:1 multiplexer needs 15 of size 2:1, or 4+1=54 + 1 = 5 of size 4:1; a 64:1 needs 21 of size 4:1.

Implementing a function with a multiplexer.

  • Direct method. An nn-variable function uses a 2n2^n-to-1 multiplexer with the variables on the select lines. Each data input is tied to the function's output (0 or 1) for that row of the truth table.
  • Shannon expansion method (one variable less). Use a 2n−12^{n-1}-to-1 multiplexer: connect n−1n - 1 of the variables to the select lines. For each select combination, the function is a function of the remaining variable xx alone, which is one of 00, 11, xx or x′x'. Connect that to the data input. So any nn-variable function needs a 2n−12^{n-1}-to-1 multiplexer and at most one inverter.
  • Repeating the Shannon expansion on more variables reduces the multiplexer size further, at the cost of more gates on the data inputs.

Universality. With the constants 0 and 1 available, a 2:1 multiplexer is functionally complete: NOT: I0=1I_0 = 1, I1=0I_1 = 0, select AA; AND: I0=0I_0 = 0, I1=BI_1 = B, select AA; OR: I0=BI_0 = B, I1=1I_1 = 1, select AA.

Demultiplexer (1-to-2n2^n DEMUX). One data input DD, nn select lines and 2n2^n outputs. The output selected by the select lines carries DD and all the others are 0: Yi=D⋅mi(S)Y_i = D \cdot m_i(S). A demultiplexer is exactly a decoder with DD used as its enable input, which is why the two are sold as one part (decoders and encoders).

How it works

Implement F(A,B,C)=∑m(1,2,6,7)F(A, B, C) = \sum m(1, 2, 6, 7) with a 4:1 multiplexer. Put AA and BB on the select lines S1S_1 and S0S_0. Group the truth table rows by (A,B)(A, B):

ABA Brows C=0C = 0, C=1C = 1FF in terms of CCdata input
000, 1CCI0=CI_0 = C
011, 0C′C'I1=C′I_1 = C'
100, 00I2=0I_2 = 0
111, 11I3=1I_3 = 1

The animation fills the table row by row. The columns are the function, the four data inputs as functions of CC, and the multiplexer output YY (choose the data input selected by ABA B); the function and the output are compared.

A function of three variables on a 4:1 multiplexer

Computed exactly, not typed
ABCF=sum m(1,2,6,7)I0=CI1=C'I2=0I3=1Y=mux(S1=A,S0=B)
000······
001······
010······
011······
100······
101······
110······
111······

Step 0

Claim: connecting A and B to the select lines of a 4:1 multiplexer and wiring its data inputs to C, C', 0 and 1 gives the function F = sum m(1, 2, 6, 7). For each select value the output is just one data input.

0 / 9
computed by script: exact integer, Fraction and truth-table evaluation (IEEE 754 patterns via Python struct where used), not typed by hand. python3 scripts/gen-dl-traces.py

Worked examples

EX 1The multiplexer equation in a program

Easy

The program evaluates the 4:1 multiplexer above on every input, checks it against the function, and counts multiplexers and the constants trick.

#include <stdio.h>
 
static int mux4(int s1, int s0, int i0, int i1, int i2, int i3) {
    int in[4] = { i0, i1, i2, i3 };
    return in[2 * s1 + s0];
}
 
int main(void) {
    int bad = 0;
    printf("A B C | F  Y\n");
    for (int m = 0; m < 8; m++) {
        int a = (m >> 2) & 1, b = (m >> 1) & 1, c = m & 1;
        int f = m == 1 || m == 2 || m == 6 || m == 7;
        int y = mux4(a, b, c, !c, 0, 1);
        printf("%d %d %d | %d  %d\n", a, b, c, f, y);
        bad += f != y;
    }
    printf("mismatches: %d\n", bad);
    int cmp = 0;
    for (int s = 0; s < 2; s++) {
        cmp += (s ? 0 : 1) != !s;                   /* NOT: I0 = 1, I1 = 0 */
        for (int b = 0; b < 2; b++) {
            cmp += (s ? b : 0) != (s && b);         /* AND: I0 = 0, I1 = b */
            cmp += (s ? 1 : b) != (s || b);         /* OR:  I0 = b, I1 = 1 */
        }
    }
    printf("2:1 mux with constants as AND, OR, NOT mismatches: %d\n", cmp);
    int two_to_one = 0, left = 16;
    while (left > 1) {
        two_to_one += left / 2;
        left /= 2;
    }
    printf("16:1 from 2:1 muxes: %d\n", two_to_one);
    int four_to_one = 0;
    left = 16;
    while (left > 1) {
        four_to_one += left / 4;
        left /= 4;
    }
    printf("16:1 from 4:1 muxes: %d\n", four_to_one);
    return 0;
}
A B C | F  Y
0 0 0 | 0  0
0 0 1 | 1  1
0 1 0 | 1  1
0 1 1 | 0  0
1 0 0 | 0  0
1 0 1 | 0  0
1 1 0 | 1  1
1 1 1 | 1  1
mismatches: 0
2:1 mux with constants as AND, OR, NOT mismatches: 0
16:1 from 2:1 muxes: 15
16:1 from 4:1 muxes: 5

The data inputs C,C′,0,1C, C', 0, 1 reproduce the function on all 8 rows. The two counts are the numbers of 2:1 and 4:1 multiplexers for a 16:1 selector.

EX 2Which input is selected?

Easy

A 4:1 multiplexer has select lines S1S0=10S_1 S_0 = 10. The index is 102=210_2 = 2, so Y=I2Y = I_2. With S1S0=11S_1 S_0 = 11, Y=I3Y = I_3. The equation shows why: only the minterm S1S0′S_1 S_0' is 1 for S1S0=10S_1S_0 = 10.

EX 3A three-variable function on an 8:1 multiplexer, directly

Medium

Implement F=AB+A′CF = AB + A'C with an 8:1 multiplexer. Its minterms are A′B′CA'B'C (index 1), A′BCA'BC (3), ABC′ABC' (6) and ABCABC (7), so F=∑m(1,3,6,7)F = \sum m(1, 3, 6, 7). Connect AA, BB, CC to S2S_2, S1S_1, S0S_0 and tie I1=I3=I6=I7=1I_1 = I_3 = I_6 = I_7 = 1 and I0=I2=I4=I5=0I_0 = I_2 = I_4 = I_5 = 0.

EX 4The same function on a 4:1 multiplexer

Medium

For F=AB+A′C=∑m(1,3,6,7)F = AB + A'C = \sum m(1, 3, 6, 7), use AA and BB as selects. Pairs of rows (C=0,C=1)(C = 0, C = 1): AB=00AB = 00: rows 0, 1 give (0,1)(0, 1), so I0=CI_0 = C. AB=01AB = 01: rows 2, 3 give (0,1)(0, 1), so I1=CI_1 = C. AB=10AB = 10: rows 4, 5 give (0,0)(0, 0), so I2=0I_2 = 0. AB=11AB = 11: rows 6, 7 give (1,1)(1, 1), so I3=1I_3 = 1. Data inputs: C,C,0,1C, C, 0, 1 (no inverter needed).

EX 5Counting multiplexers

GATE level

(a) A 32:1 multiplexer built from 2:1 multiplexers needs 32−1=3132 - 1 = 31 of them.

(b) A 64:1 multiplexer from 4:1 multiplexers needs 16+4+1=2116 + 4 + 1 = 21.

(c) A 16:1 multiplexer from 4:1 multiplexers needs 4+1=54 + 1 = 5 (the program confirms 5 and, for 2:1 multiplexers, 15).

(d) The number of select lines of a 2n2^n:1 multiplexer is nn, so a 32:1 multiplexer has 5 select lines.

EX 6Functional completeness of a 2:1 multiplexer

GATE level

With the constants 0 and 1 the 2:1 multiplexer gives NOT (I0=1,I1=0I_0 = 1, I_1 = 0), AND (I0=0,I1=BI_0 = 0, I_1 = B) and OR (I0=B,I1=1I_0 = B, I_1 = 1); the program checks these (the counted mismatches are 0). Since AND, OR and NOT together are complete, so is the multiplexer. Without constants a 2:1 multiplexer is not complete: built only from the input variables, every output it can produce is 0 when all inputs are 0, so the constant 1 and the function NOT cannot be made.

EX 7Demultiplexer as decoder

GATE level

A 1-to-4 demultiplexer with D=1D = 1 and select S1S0=10S_1 S_0 = 10 has output Y2=1Y_2 = 1 and Y0=Y1=Y3=0Y_0 = Y_1 = Y_3 = 0. With D=0D = 0 every output is 0. A 2-to-4 decoder with enable EE behaves identically: its enable is the demultiplexer's data input.

Cheat box

Cheat box

  • Y=∑mi(S) IiY = \sum m_i(S)\, I_i. 2:1: Y=S′I0+SI1Y = S'I_0 + S I_1. A 2n2^n:1 MUX has nn select lines.
  • 2k2^k:1 from 2:1 multiplexers: 2k−12^k - 1. 16:1 from 4:1: 5. 64:1 from 4:1: 21.
  • Function of nn variables on a 2n2^n:1 MUX: data inputs are the truth-table column. On a 2n−12^{n-1}:1 MUX: data inputs are 00, 11, xx or x′x' (xx = the variable not on the selects).
  • 2:1 MUX plus constants is functionally complete (NOT, AND, OR).
  • DEMUX: Yi=D⋅mi(S)Y_i = D \cdot m_i(S) = decoder with enable DD.
  • MUX is the circuit for the Shannon expansion f=xf1+x′f0f = x f_1 + x' f_0.

Traps and GATE patterns

Connections

A decoder produces the minterms and a multiplexer selects among them, so the two are duals in use; a demultiplexer is a decoder with an enable. Multiplexers implement every function of SOP and POS forms, and their completeness is a case of functional completeness. A table of outputs stored in memory is the same idea in bulk: see ROM and PLA. In the processor the multiplexers choose the ALU input or the register to write (ALU design).

PYQs

10 previous year questions from your book. I re-solved each one myself (8 by running or simulating, 2 by reasoning only); the book's key is shown next to my answer. All PYQs

GATE 2026 · Set 2 · NAT · 2 marksQ1 · page 174 of the book
Consider the digital circuit shown below with two
input lines A and B, two select lines S0 and S1, and
an output line Y. The blocks Q and M represent an
active-high 2:4 decoder and a 4-to-1 multiplexer,
respectively.
Out
of
16
possible
input
combinations, the number of combinations that
produce Y = 1 is __________. (Answer in integer).
year not read yetQ3 · page 174 of the book
A Boolean digital circuit is composed using two 4-
input multiplexers (M1 and M2) and one 2-input
multiplexer (M3) as shown in the figure. X0-X7 are
the inputs of the multiplexers M1 and M2 and could
be connected to either 0 or 1. The select lines of the
multiplexers are connected to Boolean variables A, B
and C as shown.

Which one of the following set of values of (X0, X1,
X2, X3, X4, X5, X6, X7) will realise the Boolean
function A'+ A'⋅C' + A⋅ B'⋅C?
  • (a)(1, 1, 0, 0, 1, 1, 1, 0)
  • (b)(1, 1, 0, 0, 1, 1, 0, 1)
  • (c)(1, 1, 0, 1, 1, 1, 0, 0)
  • (d)(0, 0, 1, 1, 0, 1, 1, 1)
GATE 2022 · MCQ · 2 marksQ4 · page 174 of the book
Consider a digital display system (DDS) shown in the
figure that displays the contents of register X. A 16-
bit code word is used to load a word in X, either from
S or from R. S is a 1024-word memory segment and
R is a 32-word register file. Based on the value of
mode bit M, T selects an input word to load in X. P
and Q interface with the corresponding bits in the
code word to choose the addressed word. Which one
of the following represents the functionality of P, Q,
and T?

DIGITAL LOGIC
  • (a)P is 10:1 multiplexer;Q is 5: 1 multiplexer; T is 2: 1 multiplexer
  • (b)P is 10: 210 decoder; Q is 5: 25 decoder;T is 2: 1 encoder
  • (c)P is 10:210 decoder; Q is 5: 25 decoder; T is 2: 1 multiplexer
  • (d)P is 1: 10 de-multiplexers; Q is 1: 5 de- multiplexers; T is 2: 1 multiplexer
GATE 2021 · Set 2 · MCQQ5 · page 175 of the book
Which one of the following circuits implements the
Boolean function given below? f (x, y, z) = m0 +
m1 + m3 + m4 + m5 + m6, where mi is the ith min-
term.
  • (a)
  • (b)
  • (c)
  • (d)
GATE 2020 · NAT · 1 markQ7 · page 175 of the book
A multiplexer is placed between a group of 32
registers and an accumulator to regulate data
movement such that at any given point in time the
content of only one register will move to the
accumulator. The minimum number of select lines
needed for the multiplexer is _____.
GATE 2014 · Set 1 · MCQ · 2 marksQ11 · page 176 of the book
Consider the 4-to-1 multiplexer with two select
lines S1 and S0 given below

The minimal sum of products form of the output X
is
  • (a)P ̅Q + QR ̅ + PQ ̅R
  • (b)P ̅Q + P ̅QR ̅ + PQR ̅ + PQ ̅R
  • (c)PQR + P ̅QR ̅ + QR ̅ + PQ ̅R
  • (d)PQR
GATE 2014 · Set 3 · MCQ · 1 markQ12 · page 176 of the book
Consider the following combinational function
block involving four Boolean variables x, y, a, b
where x, a, b are inputs and y is the output.

f(x,y,a,b)

{

if(x is 1)y =a;

else y=b;

}

Which one of the following digital logic blocks is
the most suitable for implementing this function?
  • (a)Full adder
  • (b)Priority encoder
  • (c)Multiplexer
  • (d)Flip-flop
GATE 2010 · MCQQ15 · page 177 of the book
The Boolean expression of the output of the
multiplexer shown below is
  • (a)(P ⊕ Q ⊕ R)̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅
  • (b)P ⊕ Q ⊕ R
  • (c)P + Q̅ + R
  • (d)(P + Q + R)̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅
GATE 2006 · MCQQ19 · page 177 of the book
Consider the circuit below. Which one of the
following options correctly represents f(x,y,z)
  • (a)xz̅ + xy + y̅z
  • (b)xz̅ + xy +y̅z̅
  • (c)xz + xy + y̅z̅
  • (d)xz + xȳ + y̅z
GATE 2024 · Set 1 · NAT · 2 marksQ5 · page 184 of the book
Consider a digital logic circuit consisting of three 2-
to-1 multiplexers M1, M2, and M3 as shown
below. X1 and X2 are inputs of M1. X3 and X4 are

DIGITAL LOGIC
inputs of M2. A, B, and C are select lines
of M1, M2, and M3, respectively.

For an instance of inputs X1= 1, X2= 1, X3= 0,
and X4= 0, the number of combinations
of A, B, C that give the output Y= 1 is
____________.

Self-check

Question 1

How many 2:1 multiplexers are needed to build an 8:1 multiplexer?

Show answer

8−1=78 - 1 = 7: four in the first level, two in the second, one in the third.

Question 2

Implement F(A,B,C)=∑m(0,3,5)F(A,B,C) = \sum m(0, 3, 5) with a 4:1 multiplexer with selects AA and BB. What are the data inputs?

Show answer

Row pairs: AB=00AB = 00: rows 0, 1 give (1,0)(1, 0), so I0=C′I_0 = C'. AB=01AB = 01: rows 2, 3 give (0,1)(0, 1), so I1=CI_1 = C. AB=10AB = 10: rows 4, 5 give (0,1)(0, 1), so I2=CI_2 = C. AB=11AB = 11: rows 6, 7 give (0,0)(0, 0), so I3=0I_3 = 0.

Question 3

What is the output of a 4:1 multiplexer with I0=0I_0 = 0, I1=1I_1 = 1, I2=1I_2 = 1, I3=0I_3 = 0 and selects S1S0S_1 S_0?

Show answer

The output is 1 when S1≠S0S_1 \ne S_0 and 0 otherwise, so Y=S1⊕S0Y = S_1 \oplus S_0: a multiplexer with data inputs 0, 1, 1, 0 is an XOR gate.

Question 4

How many select lines and data inputs does a multiplexer have if it is used to choose among 20 sources?

Show answer

⌈log⁡220⌉=5\lceil \log_2 20 \rceil = 5 select lines, so a 32:1 multiplexer is needed (12 inputs left unused or tied off).

Revision card

One-screen revision

  • Y=∑mi(S)IiY = \sum m_i(S) I_i; 2n2^n inputs, nn selects. 2k2^k:1 from 2:1 needs 2k−12^k - 1 multiplexers.
  • Function of nn variables on a 2n−12^{n-1}:1 MUX: data inputs are 0, 1, xx, x′x'.
  • 2:1 MUX with constants makes NOT, AND, OR (complete).
  • DEMUX Yi=D mi(S)Y_i = D\, m_i(S) is a decoder with enable DD.

References

  • ·Mano and Ciletti, Digital Design, 5th ed., Chapter 4 Combinational Logic (multiplexers, demultiplexers) and Chapter 3 (Boolean function implementation)
  • ·Kohavi and Jha, Switching and Finite Automata Theory, Multiplexer realisation of switching functions

Verification

The multiplexer equation, the 0/1/x/x' data inputs for every three-variable function on a 4:1 multiplexer, functional completeness of the 2:1 multiplexer with constants, the counts of multiplexers needed for larger sizes, and the demultiplexer-as-decoder identity are checked in scripts/enum-checks/dl_comb.py. The truth-table animation is computed by scripts/gen-dl-traces.py and checked in tests/dl-traces.test.ts. The C program is compiled and run by npm run verify:c. Textbook chapter titles are from memory; the independent second pass has not been run, so the page stays draft. SECOND PASS (2026-11-02, done by the assistant, not a human check): every Self-check question was solved before the printed answer was read and all agreed; the definitions, worked examples, cheat box and traps were read claim by claim and the numbers re-derived by hand or by a small script (conversions, signed ranges and flags, IEEE 754 fields and custom formats, Boolean identities and counts, K-map groups, adder carries, BCD correction, flip-flop conversions, counter sequences and T equations, state reduction, Quine-McCluskey rounds and covers, floating-point alignment and rounding); long C programs were not re-read line by line (they are compiled and compared by npm run verify:c, and their printed outputs were checked against the prose); tables and animations are machine output and were read, not re-run; No other defect found. Status raised to self-checked; verified needs a textbook or human check.

last verified: never