DE-06: MUX, Decoders, Encoders, Comparators & PLDs — VLSI Trainers
Digital Electronics Series · DE-06

More Combinational Circuits

Multiplexers, Demultiplexers, Decoders (3-to-8, BCD-to-decimal, BCD-to-7-segment), Code Converters, Encoders, Priority Encoders, Magnitude Comparators, Parity Generator/Checker, and Programmable Logic Devices — FPLA, PAL, and PROM.

🔀 Multiplexers (MUX)

A multiplexer (MUX), also called a data selector, routes one of N data inputs to a single output line under the control of K select lines, where 2K = N. Only one input is connected to the output at a time.

4:1 Multiplexer — Structure and Operation 4:1 MUX X₀ X₁ X₂ X₃ X (output) S₁ S₀ Ḡ (enable) Select → Output S₁=0, S₀=0 → X = X₀ S₁=0, S₀=1 → X = X₁ S₁=1, S₀=0 → X = X₂ S₁=1, S₀=1 → X = X₃ Ḡ=1: all outputs disabled (X=0) Ḡ=0: normal multiplexing
Figure 1 — 4:1 MUX. The Boolean expression is X = X₀·S̄₁·S̄₀ + X₁·S̄₁·S₀ + X₂·S₁·S̄₀ + X₃·S₁·S₀. The enable terminal Ḡ is active-low — keeping it high disables the output; setting it low allows the selected input through.

Key MUX ICs

74157 Quadruple 2:1 MUX (4 × two-input MUXes on one chip)   74151A 8:1 MUX — 8 data inputs, 3 select lines, active-low enable   74150 16:1 MUX — 16 inputs, 4 select lines

🔗 MUX Expansion

Larger MUXes are built by cascading smaller ones. Two 4:1 MUXes form an 8:1 MUX — a NOT gate on the most-significant select line S₂ drives the enable of each 4:1 MUX, giving a third effective select terminal. When S₂=0, the first MUX (inputs X₀–X₃) is enabled; when S₂=1, the second MUX (inputs X₄–X₇) is enabled. Their outputs connect to a common OR gate for the final output.

General cascade rule. Two N:1 MUXes + one NOT gate + one OR gate = one 2N:1 MUX. Two 8:1 MUXes → 16:1 MUX. The enable terminal of each sub-MUX acts as the MSB of the combined select address.

📐 Implementing Boolean Functions with MUX

An N-input MUX can directly implement any Boolean function of log₂(N) variables — connect inputs to 0 or 1 per the truth table output column. With one fewer select line than variables, use the MSB as a variable-valued data input.

Full MUX method — N variables, N:1 MUX (direct)

Connect the variables to the select lines. For each input Xᵢ: set Xᵢ = 1 if the truth table output is 1 at row i, else Xᵢ = 0.

Example 6.1 — Realise F(A,B,C) = Σ(0,1,3,4,7) with an 8:1 MUX

Connect A, B, C to select lines S₂, S₁, S₀ respectively.

Input mapX₀=1 (m0) · X₁=1 (m1) · X₂=0 (m2) · X₃=1 (m3) · X₄=1 (m4) · X₅=0 (m5) · X₆=0 (m6) · X₇=1 (m7)
Tie X₀,X₁,X₃,X₄,X₇ to VCC (logic 1) and X₂,X₅,X₆ to GND (logic 0)

Reduced MUX method — N variables, (N−1)-select MUX

Use the MSB (A) as a data input. The other variables drive the select lines. For each pair of rows (A=0 and A=1 with same remaining variables), the data input Xᵢ is:

Example 6.3 — Realise F(A,B,C,D) = Σ(0,1,3,5,7,11,13,15) with an 8:1 MUX (3 select lines)

Use B,C,D as select lines S₂,S₁,S₀. MSB = A as data variable.

BCD=000m₀(A=0)=1, m₈(A=1)=0 → X₀=Ā
BCD=001m₁(A=0)=1, m₉(A=1)=0 → X₁=Ā
BCD=010m₂(A=0)=0, m₁₀(A=1)=0 → X₂=0
BCD=011m₃(A=0)=1, m₁₁(A=1)=1 → X₃=1
BCD=100m₄(A=0)=0, m₁₂(A=1)=0 → X₄=0
BCD=101m₅(A=0)=1, m₁₃(A=1)=1 → X₅=1
BCD=110m₆(A=0)=0, m₁₄(A=1)=0 → X₆=0
BCD=111m₇(A=0)=1, m₁₅(A=1)=1 → X₇=1
X₀=Ā, X₁=Ā, X₂=0, X₃=1, X₄=0, X₅=1, X₆=0, X₇=1

📡 Demultiplexers (DEMUX)

A demultiplexer is the reverse of a MUX — it routes a single data input to one of 2N output lines selected by N control bits. Also called a data distributor.

1:4 Demultiplexer — Boolean Expressions and Operation 1:4 DEMUX X (data) X₀ = X·S̄₁·S̄₀ X₁ = X·S̄₁·S₀ X₂ = X·S₁·S̄₀ X₃ = X·S₁·S₀ S₁ S₀
Figure 2 — 1:4 DEMUX. Each output is a 3-input AND gate with the data signal X, and the appropriate combination of S₁ and S₀ (complemented or not). A decoder with Enable = data input behaves as a DEMUX.

Key ICs: 74155 Dual 1:4 DEMUX (= 2:4 decoder)   74138 1:8 DEMUX (= 3:8 decoder)   74154 1:16 DEMUX (= 4:16 decoder)

Decoder = DEMUX. A 2:4 decoder with Enable can directly serve as a 1:4 DEMUX — connect the Enable pin as the data input and the address pins (A,B) as the select lines. This dual-use is why decoder and DEMUX ICs share the same part numbers.

🔓 Decoders — 3-to-8 and 4-to-16

A decoder accepts an N-bit binary input and asserts exactly one of 2N output lines — the one corresponding to the input value. All other outputs remain inactive.

ABCEnable EActive outputExpression
0001Y₀Ā·B̄·C̄
0011Y₁Ā·B̄·C
0101Y₂Ā·B·C̄
0111Y₃Ā·B·C
1001Y₄A·B̄·C̄
1011Y₅A·B̄·C
1101Y₆A·B·C̄
1111Y₇A·B·C
Any0NoneAll Y = 0

Implementing SOP Functions with Decoders

Each output Yᵢ of a decoder is exactly minterm mᵢ. To implement any SOP function, OR together the decoder outputs corresponding to the minterms in the function. One decoder can implement multiple functions simultaneously — much more economical than one MUX per function.

Example 6.4 — Implement three functions simultaneously using one 4-to-16 decoder
F₁= Σ(0,1,2,4,6,7,12,14) → OR gate: Y₀+Y₁+Y₂+Y₄+Y₆+Y₇+Y₁₂+Y₁₄
F₂= Σ(3,5,8,10,13,15) → OR gate: Y₃+Y₅+Y₈+Y₁₀+Y₁₃+Y₁₅
F₃= Σ(5,6,7,11,12) → OR gate: Y₅+Y₆+Y₇+Y₁₁+Y₁₂
One 4-to-16 decoder + three OR gates implements all three functions. Enable pin tied to logic 1 (active high decoder).

Cascading Decoders: 4-to-16 from two 3-to-8

Connect the 4th input bit to the Enable of each 3-to-8 decoder through a NOT gate. When the MSB is 0, decoder 1 is enabled (covers outputs 0–7); when MSB is 1, decoder 2 is enabled (covers outputs 8–15).

🔢 BCD-to-Decimal Decoder

Converts a 4-bit BCD input (0000–1001) to one of ten active output lines (0–9). Also called a 4-to-10 line decoder. The six illegal codes (1010–1111) produce no output.

Key IC: 74LS42 / 7442 — BCD-to-decimal decoder. Built with NAND gates → active-low outputs (selected output goes LOW, others stay HIGH). Used in numeric display driving and BCD demultiplexing.

🖥️ BCD-to-7-Segment Decoder

Drives a 7-segment LED display from a 4-bit BCD input. The seven segments a–g are independently controlled by seven Boolean expressions, each derived from K-map minimisation of the display truth table.

0
1
2
3
4
5
6
7
8
9

Segment expressions (K-map minimised from truth table)

SegmentMinimal Boolean ExpressionSegments lit for…
aA + C + B·D + B̄·C̄0,2,3,5,6,7,8,9
bB̄ + C·D + C̄·D̄0,1,2,3,4,7,8,9
cB̄ + C̄ + D0,1,3,4,5,6,7,8,9
dA + B·D̄ + B̄·C̄ + B̄·C·D0,2,3,5,6,8
eB̄·D̄ + C·D̄0,2,6,8
fA + C̄·D̄ + B·C̄ + B·D̄0,4,5,6,8,9
gA + B·C̄ + B̄·C + C·D̄2,3,4,5,6,8,9

Key ICs: 7447 BCD-to-7-seg decoder/driver (active-low outputs, 15V max)   7446 Same as 7447 but 30V max. Both provide Lamp Test (LT̄), Ripple Blank Input (RB̄Ī), and Ripple Blank Output (R̄B̄O) for leading-zero blanking in multi-digit displays.

🔄 Code Converters

A code converter transforms a binary word from one encoding to another — for example 8421 BCD to Gray code, or Gray to 8421. The method: build a truth table with the input code as input variables and the output code as output variables, then minimise each output bit’s expression using K-maps.

8421 → Gray Code Conversion (from K-map minimisation)
X (MSB)= b·c̄·d̄ + b·c·d + a·b̄ + a·b·c̄·d + a·b·c·d̄  → simplified: X = a·b̄ + ā·b·c̄ + ā·b·c·d
Y= ā·b·c̄ + ā·b·c·d + a·b̄·c̄ + a·b̄·c·d
Z= ā·c̄·d + ā·c·d̄ + a·c̄·d̄·d̄ + a·c·d
W= ā·d + a·d̄
Realised with NAND gates (2-level SOP→NAND-NAND conversion). PROM 16×4 can also implement all four output bits simultaneously.

📝 Encoders

An encoder is the reverse of a decoder — it has 2N (or fewer) input lines, exactly one of which is HIGH at a time, and produces an N-bit binary output code identifying which input is active.

Octal-to-Binary Encoder (8-line to 3-line)

Output bitBoolean ExpressionHIGH when input is…
X₀ (LSB)D₁ + D₃ + D₅ + D₇D₁, D₃, D₅, or D₇
X₁D₂ + D₃ + D₆ + D₇D₂, D₃, D₆, or D₇
X₂ (MSB)D₄ + D₅ + D₆ + D₇D₄, D₅, D₆, or D₇

Decimal-to-BCD Encoder (10-line to 4-line)

OutputExpression
X₀D₁ + D₃ + D₅ + D₇ + D₉
X₁D₂ + D₃ + D₆ + D₇
X₂D₄ + D₅ + D₆ + D₇
X₃D₈ + D₉
Limitation of basic encoders. If two or more inputs are simultaneously active, the output is meaningless — it will be the OR of the corresponding output expressions. The priority encoder (next section) solves this by always encoding the highest-active input.

Priority Encoders

A priority encoder handles simultaneous inputs by always outputting the code for the highest-numbered active input. If D₄ and D₈ are both HIGH, the output is BCD for 8 (D₈ has higher priority).

Decimal-to-BCD Priority Encoder output expressions

OutputPriority expression (highest input wins)
X₀D₁·D̄₂·D̄₄·D̄₆·D̄₈ + D₃·D̄₄·D̄₆·D̄₈ + D₅·D̄₆·D̄₈ + D₇·D̄₈ + D₉
X₁D₂·D̄₄·D̄₅·D̄₈·D̄₉ + D₃·D̄₄·D̄₅·D̄₈·D̄₉ + D₆·D̄₈·D̄₉ + D₇·D̄₈·D̄₉
X₂D₄·D̄₈·D̄₉ + D₅·D̄₈·D̄₉ + D₆·D̄₈·D̄₉ + D₇·D̄₈·D̄₉
X₃D₈ + D₉

Key ICs: 74147 Decimal-to-BCD priority encoder (active-low I/O)   74148 Octal-to-binary priority encoder (active-low I/O, enable input, cascade outputs for hex expansion)

⚖️ Magnitude Comparator

Compares two binary numbers P and Q and asserts one of three outputs: P>Q, P=Q, or P<Q. The XNOR gate is the 1-bit equality detector — it outputs 1 when both bits are identical.

4-bit Comparator expressions (P₃P₂P₁P₀ vs Q₃Q₂Q₁Q₀)

ConditionBoolean Expression
Pₛ = Qₛ(P₃⊙Q₃)·(P₂⊙Q₂)·(P₁⊙Q₁)·(P₀⊙Q₀)   — AND of all XNOR bit equalities
Pₛ > QₛP₃·Q̄₃ + (P₃⊙Q₃)·P₂·Q̄₂ + (P₃⊙Q₃)·(P₂⊙Q₂)·P₁·Q̄₁ + … ·P₀·Q̄₀
Pₛ < QₛP̄₃·Q₃ + (P₃⊙Q₃)·P̄₂·Q₂ + (P₃⊙Q₃)·(P₂⊙Q₂)·P̄₁·Q₁ + … ·P̄₀·Q₀
Cascading comparators. IC 7485 is a 4-bit comparator with three cascade inputs (P>Q, P=Q, P<Q). Chain two ICs for 8-bit comparison: connect outputs of the less-significant IC to the cascade inputs of the more-significant IC. Set the cascade inputs of the LSB IC to: “=” = 1, “>” = 0, “<" = 0.

🛡️ Parity Generator / Checker

Adds or verifies a parity bit to detect single-bit transmission errors. Built from a tree of XOR gates — XOR naturally counts odd numbers of 1s.

Parity Generator and Checker System TRANSMITTER Data: A,B,C,D (4 bits) Generator: XOR tree of A,B,C,D P = A⊕B⊕C⊕D (even parity: P=0 if even count of 1s in data) Sends: A B C D P (5 bits) channel (noise?) RECEIVER Receives: A′B′C′D′P′ (5 bits) Checker: XOR tree of all 5 bits P₂ = A′⊕B′⊕C′⊕D′⊕P′ P₂=0: No error detected ✓ P₂=1: Single-bit error! ✗ IC 74180 8-bit parity generator/checker Works on 9-bit code (8 data + 1 parity) Even or odd parity
Figure 3 — Parity system. The generator (XOR tree) produces a parity bit. At the receiver, the checker XORs all received bits including the parity bit. If the result is 0, the received data is correct. A result of 1 means a single-bit error occurred. Key IC: 74180.

💾 Programmable Logic Devices — FPLA, PAL, PROM

PLDs are MSI/LSI chips containing arrays of AND and OR gates with fusible (programmable) interconnections. A designer programs the device by selectively blowing fuses to implement any desired SOP Boolean function, replacing many discrete ICs with a single chip.

FPLA
AND arrayProgrammable
OR arrayProgrammable
FlexibilityHighest — both arrays user-defined
DownsideMore complex to program and test
Example840: 14 inputs, 32 AND, 6 OR gates
PAL
AND arrayProgrammable
OR arrayFixed (hard-wired)
FlexibilityGood — each output limited to fixed OR inputs
DownsideFixed OR limits product terms per output
Use caseMost common PLD type for SOP logic
PROM
AND arrayFixed (all minterms)
OR arrayProgrammable
FlexibilityAny combination of 2ⁿ minterms
DownsideAND array always generates all minterms
Example16×4 PROM: 4 address bits, 4 data outputs
Example 6.9 — Implement three functions using 16×4 PROM
Y₀= Σ(0,1,4,5,8,9,10,14,15) → program OR array row 0 to connect to these AND (minterm) rows
Y₁= Σ(2,3,4,9,10,11,13,15) → program OR array row 1
Y₃= Σ(5,6,7,10,13) → program OR array row 3
The 16×4 PROM has 16 AND gates (one per minterm 0–15) hardwired. Programming fuses the OR connections. Unused product terms have their fuses blown open.
PROM for code conversion. A 16×4 PROM can simultaneously implement four output functions of four input variables — ideal for code converters (BCD→Gray, Binary→BCD, etc.) where all four output bits must be generated from the same 4-bit input. Program once, replace multiple TTL ICs.

📋 Quick Reference

DeviceFunctionSelect/Control LinesKey ICs
MUX N:1Routes one of N inputs to 1 outputlog₂(N) select + enable74151A (8:1), 74150 (16:1)
DEMUX 1:NRoutes 1 input to one of N outputslog₂(N) select + enable74138 (1:8), 74154 (1:16)
Decoder N-to-2ᴺActivates one of 2ᴺ outputsN inputs + enable74138 (3-to-8), 74LS42 (BCD-to-10)
Encoder 2ᴺ-to-NConverts one active input to N-bit code2ᴺ inputs74147 (priority, active-low)
Priority encoderEncodes highest-active input2ᴺ inputs + enable74147 (decimal), 74148 (octal)
ComparatorP>Q, P=Q, P<Q outputsTwo N-bit inputs + cascade7485 (4-bit, cascadable)
Parity Gen/ChkGenerate or verify parity bit (XOR tree)N data inputs + parity in74180 (8-bit)
BCD→7-segDrives 7-segment LED display4-bit BCD input7447 (15V), 7446 (30V)
FPLAProgrammable AND + programmable ORUser-programmed fuses840: 14in, 32 AND, 6 OR
PALProgrammable AND + fixed ORUser-programmed AND fusesStandard PAL families
PROMFixed AND (all minterms) + programmable ORAddress = input; data = output16×4, 256×8 etc.
MUX boolean function ruleData input Xᵢ
Output = 0 for both A=0 and A=10
Output = 1 for both A=0 and A=11
Output = A (0 when A=0, 1 when A=1)A
Output = Ā (1 when A=0, 0 when A=1)Ā
Coming next — DE-07: Logic Families — the electronic hardware behind every gate. RTL, DCTL, I²L, DTL, HTL, TTL (totem-pole, open-collector, tri-state), Schottky TTL, ECL, NMOS/PMOS, and CMOS — with fan-out, propagation delay, noise margin, power dissipation, and a full family comparison table.
Scroll to Top