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
- An n:2ⁿ decoder outputs the minterms m₀ … m₂ₙ₋₁.
- To implement F, OR together the outputs for each minterm of F (NAND them if the outputs are active-low).
- An encoder with 2ⁿ inputs has n outputs; a priority encoder reports the highest active input and a valid bit.
- 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.
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).
| D3 | D2 | D1 | D0 | 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 |
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
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.