Skip to content
GATEiit

GATE EC · Digital Circuits

Decoders

How an n-to-2^n decoder generates every minterm, how enables and active-low outputs work, how to implement functions and build larger decoders, plus encoders, priority encoders and memory address decoding as GATE asks them.

Before you start

This topic comes before: Multiplexers, ROM, SRAM, DRAM

Concept notes

1. What a decoder does

An n-to-2n decoder has n inputs and 2n outputs. For each input code exactly one output is active: output Di is active when the input equals i. So each output is one minterm of the inputs:

Di=E⋅mi

where E is the enable. When the decoder is disabled, all outputs are inactive.

A 2-to-4 decoder needs four 2-input AND gates (three-input if the enable is included) and two inverters; a 3-to-8 decoder needs eight 3-input AND gates.

Active-low outputs. Many decoder ICs (for example a 3-to-8 decoder like the 74138) have active-low outputs: the selected output goes to 0 and all others stay at 1, so Diˉ=mi‾. Enables may also be active low; such a chip works only when every enable is at its active level.

Decoder vs demultiplexer. A 2-to-4 decoder with enable is a 1-to-4 demultiplexer: feed the data to E and use A1A0 as the select lines. The data appears on the selected output.

Always note which input is the MSB: with inputs A1A0 and A1 as MSB, the code A1A0=10 activates D2, not D1.

2-to-4decoderA1A0E (enable)D00D11D22D33E A1 A0 | D0 D1 D2 D30   x   x  |  0   0   0   01   0   0  |  1   0   0   01   0   1  |  0   1   0   01   1   0  |  0   0   1   01   1   1  |  0   0   0   1D0 = E·A1'A0'D1 = E·A1'A0D2 = E·A1A0'D3 = E·A1A0
A 2-to-4 decoder with enable: each output is one minterm of A1 A0 (A1 is the MSB), and all outputs are 0 when E = 0.

2. Implementing Boolean functions with a decoder

Since a decoder produces all minterms, any function of n variables is a decoder plus one gate. Several functions of the same inputs can share one decoder, each with its own gate.

Decoder outputs F=∑m(S) is Gate on outputs in S
Active high OR of Di, i∈S OR
Active low NAND of Diˉ, i∈S NAND

Using the complement set (the minterms not in F) is cheaper when F has many minterms:

Decoder outputs Gate on outputs not in S Gives
Active high NOR F
Active low AND F

Why active low with AND works: the AND of mjˉ over j∉S is ∑j∉Smj‾=F′‾=F.

Analysis questions run the other way: given which outputs go into which gate, write the minterms that the gate collects, then decide whether the gate gives the sum or its complement. For active-low outputs into an AND gate, F is the complement of the sum of the minterms connected.

Example: a full adder from a 3-to-8 active-high decoder needs two OR gates: S=∑m(1,2,4,7) and Cout=∑m(3,5,6,7).

3. Building larger decoders

Enables let small decoders combine into large ones.

3-to-8 from two 2-to-4 decoders (figure): A1A0 go to both chips. The MSB A2 enables the upper chip directly and the lower chip through an inverter. So A2=0 selects D0–D3 and A2=1 selects D4–D7. Without enable inputs this needs extra AND gates.

Decoder trees. To build an n-to-2n decoder from k-to-2k decoders (with enable), the last level has 2n/2k decoders driven by the low k bits. Their enables come from a smaller decoder tree driven by the high bits. Count level by level:

Build From Count
4-to-16 2-to-4 4+1=5
6-to-64 2-to-4 16+4+1=21
6-to-64 3-to-8 8+1=9
4-to-16 3-to-8 2 (plus an inverter on A3)

When the top level needs only two enables, an inverter does the job (as in the 3-to-8 and 4-to-16-from-3-to-8 cases); a chip with two enables of opposite polarity, one active high and one active low, avoids even the inverter.

Memory address decoding uses the same idea. With 2m-word chips in a larger address space, the low m address bits go to every chip, and a decoder on the next higher bits drives the chip selects. Chip k on output Dk covers addresses k⋅2m to (k+1)2m−1, offset by any fixed higher bits.

2-to-4(lower)D0–D3A1A0E2-to-4(upper)D4–D7A1A0EA1A0A2A2'A2 = 0: lower chip enabledA2 = 1: upper chip enabled
A 3-to-8 decoder from two 2-to-4 decoders: A2 enables one chip directly and the other through an inverter.

4. Encoders and priority encoders

An encoder does the reverse of a decoder: 2n inputs, n outputs giving the index of the active input. An 8-to-3 encoder has Y2=I4+I5+I6+I7, Y1=I2+I3+I6+I7, Y0=I1+I3+I5+I7, assuming exactly one input is active.

This simple encoder fails in two cases: when two inputs are active (the outputs OR together into a wrong code), and when no input is active (output 000 looks the same as I0 active).

A priority encoder fixes both. It outputs the index of the highest-priority active input and adds a valid output V that is 1 when at least one input is active. For a 4-to-2 priority encoder with I3 highest:

I3 I2 I1 I0 Y1 Y0 V
0 0 0 0 x x 0
0 0 0 1 0 0 1
0 0 1 x 0 1 1
0 1 x x 1 0 1
1 x x x 1 1 1

So Y1=I3+I2, Y0=I3+I2ˉI1, V=I3+I2+I1+I0.

A BCD-to-7-segment decoder is a code converter, not an n-to-2n decoder: each segment output is a separate function of the 4 BCD bits, usually with the codes 1010–1111 as don't-cares.

Formulas to remember

Decoder output
Di=E⋅mi,i=0,1,…,2n−1
Function from active-high outputs
F=∑i∈SDi
Function from active-low outputsNAND of the outputs in S, or AND of the outputs not in S
F=∏i∈SDiˉ‾=∏j∉SDjˉ
Decoder tree countk-to-2k decoders with enable, n a multiple of k
2n2k+2n22k+⋯+1
Chip address rangeChip on decoder output Dk, 2m words per chip
k⋅2m  to  (k+1) 2m−1

Common mistakes

  • With active-low outputs, using an OR gate on the minterm outputs; the correct gate is NAND (or AND on the complement set).
  • Forgetting that an AND of active-low outputs gives the complement of the sum of the connected minterms.
  • Swapping the MSB and LSB inputs, which moves the active output from D1 to D2 and changes every function.
  • Counting only the last level of a decoder tree and missing the decoders that drive the enables.
  • Treating an all-zero output of a plain encoder as input I0 active; without a valid bit it may mean no input is active.
  • In address decoding, ignoring the fixed high-order bits that gate the decoder's enable, which shifts the whole address range.

Worked examples

Try each step yourself, then reveal the working.

Example 1: Full adder with a 3-to-8 decoder

numerical

Implement a full adder (inputs A, B, Cin, with A as MSB) using a 3-to-8 decoder with active-high outputs and OR gates.

  1. Step 1: Write the sum as minterms.

    Try it on paper first.

Example 2: Reading an active-low decoder circuit

numerical

A 3-to-8 decoder with active-low outputs has inputs A (MSB), B, C. Outputs D1ˉ, D3ˉ and D6ˉ go to a 3-input AND gate. Find F.

  1. Step 1: Write each connected output as a complemented minterm.

    Try it on paper first.

Example 3: Counting decoders in a tree

numerical

How many 2-to-4 decoders (with enable) are needed for a 6-to-64 decoder, and how many 3-to-8 decoders?

  1. Step 1: Count 2-to-4 decoders level by level.

    Try it on paper first.

Example 4: Address range of a memory chip

conceptual

A system with a 16-bit address bus has eight 1 KB memory chips. Address lines A9–A0 go to every chip; a 3-to-8 decoder on A12A11A10 (with A12 as MSB) drives the chip selects, and is enabled only when A15=A14=A13=0. Which addresses does the chip on output D5 respond to?

  1. Step 1: Fix the bits that select the chip.

    Try it on paper first.

Previous year questions

1 official GATE EC question on this topic, newest first.

Topic test

9 questions: up to 1 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.

Mark as mastered

Loading your progress…

My revision notes

Notes written by the GATEiit team against the official GATE EC syllabus; being checked by a reviewer. Updated 2026-11-28. Spotted a mistake? Use Report an issue on any question, or contact us.