Questions: Encoders, Decoders, and Priority Encoders
5 questions to test your understanding
Score: 0 / 5
Question 1 Multiple Choice
A 3-to-8 decoder receives the binary input 101. Which output line is activated?
AOutput line 3
BOutput line 4
COutput line 5
DOutput lines 1, 3, and 5 simultaneously — one for each active input bit
A 3-to-8 decoder interprets its 3-bit input as a binary number and activates exactly one of 8 output lines. 101 in binary equals 5 in decimal, so output line 5 is asserted and all others are deasserted. Option D represents the key misconception: the decoder does not activate one output per set input bit. It activates the single output corresponding to the binary address. The entire point of a decoder is the translation from compact binary encoding to one-hot selection.
Question 2 Multiple Choice
A computer system has 8 peripheral devices that may simultaneously generate interrupt signals. What type of circuit is needed to produce a 3-bit code identifying which interrupt to service?
AA 3-to-8 decoder
BA basic 8-to-3 encoder
CA priority encoder
DA multiplexer with a 3-bit select
A basic 8-to-3 encoder assumes exactly one input is active at a time — if multiple inputs assert simultaneously, its output is undefined or incorrect. Since multiple interrupt sources can fire at once, a priority encoder is required: it accepts multiple simultaneous inputs, selects the highest-priority active one, and outputs its 3-bit binary code along with a 'valid' signal. This is precisely the interrupt controller's job in real systems, and why priority encoders are a standard building block for interrupt handling.
Question 3 True / False
A basic 4-to-2 encoder will produce incorrect output if two or more of its input lines are simultaneously asserted.
TTrue
FFalse
Answer: True
True. A simple encoder is designed assuming exactly one of its 2^n input lines is active at any time. Its output lines are ORed together in ways that only produce a valid binary code for single-active-input scenarios. When two inputs are simultaneously active, their OR-combined outputs produce a code that may correspond to neither active input — it could be the code of a third, inactive input. Priority encoders solve this by using additional logic to identify and encode only the highest-priority active input.
Question 4 True / False
A decoder and a demultiplexer perform identical functions and can usually be used interchangeably in digital circuit design.
TTrue
FFalse
Answer: False
False. A decoder and a demultiplexer are closely related but functionally distinct. A decoder takes an n-bit binary address and asserts the corresponding one-of-2^n output line — it translates an address into a selection. A demultiplexer routes a single data input signal to one of several output lines selected by a control address. The difference is that a DEMUX carries a data value through to the selected output, while a decoder simply asserts or deasserts selection lines. A decoder can be used as a DEMUX by treating the enable pin as the data input, but they are not interchangeable in general.
Question 5 Short Answer
Explain the complementary relationship between encoders and decoders in terms of what information each converts and to what representation, and give one practical application of each in a computer system.
Think about your answer, then reveal below.
Model answer: A decoder takes a compact binary code (n bits) and produces a one-hot output (exactly one of 2^n lines active) — it expands a binary address into a selection signal. An encoder does the inverse: given one active line among many, it produces the compact binary code identifying which line is active. Practical decoder application: memory address decoding — a 3-to-8 decoder selects which of 8 RAM chips responds to a given address bus value. Practical encoder application: keyboard encoding — when a key is pressed, an encoder converts the active key line into a binary scancode the CPU can process.
The complementary nature is fundamental to how data moves between binary-coded formats (used for compact storage and transmission) and one-hot formats (used for direct hardware selection and activation). CPU instruction decoding uses decoders to translate opcode bits into control signals that activate specific datapath components. Interrupt controllers use priority encoders to convert multiple simultaneous interrupt lines into a single prioritized interrupt number.