← 🔌 Combinational Circuits
Subtopic 4 of 6

3.4Decoders and encoders

The idea

A decoder turns an n-bit code into one active line out of 2ⁿ; an encoder does the opposite. Because a decoder produces every minterm, a function is just an OR of the right lines.

Think of it like this: A hotel desk: a room number comes in and exactly one key hook lights up.

Why it exists

Decoder-based implementation and priority encoders are common 1 and 2 mark questions.

How it works

  1. An n:2ⁿ decoder outputs the minterms m₀ … m₂ₙ₋₁.
  2. To implement F, OR together the outputs for each minterm of F (NAND them if the outputs are active-low).
  3. An encoder with 2ⁿ inputs has n outputs; a priority encoder reports the highest active input and a valid bit.
  4. A big decoder is built from smaller ones with enable inputs.

Worked example: Sum bit of a full adder with a 3:8 decoder

S = Σm(1,2,4,7), so use one 4-input OR on Y1, Y2, Y4, Y7. The carry Cout = Σm(3,5,6,7) is another 4-input OR on the same decoder.

Now play with it

  • →Press A⊕B⊕C and count the inputs of the OR gate.
  • →In the encoder, raise D1 and D3 together and see the priority encoder pick 3.

A 3:8 decoder makes all 8 minterms; click the ones that belong to F.

Active-high decoder + OR gate4-input OR
Active-low decoder (74138 style) + NAND4-input NAND
Using the zeros instead4-input NOR (F = (ΣF′)′)
Decoder outputs / inputs8 / 3

One decoder serves many functions at once: each extra output function just needs its own OR (or NAND) gate on the same decoder lines. A 3:8 decoder with an enable can be combined to build bigger decoders (4:16 from two 3:8 and the MSB driving the enables).

Y1 Y0none
Valid V0
Noteno input active: Y is meaningless without V
D3D2D1D0Y1Y0V
0000xx0
0001001
001x011
01xx101
1xxx111

Priority encoder equations: Y1 = D3 + D2, Y0 = D3 + D2′D1, V = D3 + D2 + D1 + D0. An n-input encoder has ⌈log₂ n⌉ outputs.

Check yourself

The number of inputs of the OR gate needed to build the sum of a full adder from a 3:8 decoder is

Remember: Decoder = all the minterms; function = OR of its minterm lines.
Exam notes (the dense version)

An n:2ⁿ decoder produces all 2ⁿ minterms (one output high); any function is then an OR of the right outputs, and many functions can share one decoder. With active-low outputs (74138) use a NAND for the OR. A larger decoder is built from smaller ones using enable inputs (4:16 from two 3:8 plus the MSB as enable select). A demultiplexer is a decoder whose enable is the data input. An encoder does the reverse (2ⁿ inputs, n outputs); a priority encoder resolves several active inputs by picking the highest priority and adds a valid output.

Previous year questions: Combinational Circuits (10)

PYQs are grouped by topic, so this is the full set for Combinational Circuits; try the ones that match this subtopic. Open all 10 on the topic page.