6.13 Decoder: Converting a Binary Code Into One-of-Many Outputs
Explain how a decoder converts an n-bit binary input code into exactly one activated output among 2^n outputs, and correctly account for active-high versus active-low output conventions.
A decoder is a combinational circuit that performs the inverse operation of an encoder: it takes an n-bit binary code as input and activates exactly one of 2^n possible outputs, the one whose index matches the binary value presented on the input. Decoders are used wherever a compact binary address or code needs to be translated into a signal that selects or activates exactly one specific destination among many — memory address decoding, seven-segment display driving, and instruction opcode decoding in a CPU's control unit are all direct applications of this same basic principle.
The core decoding operation
A decoder with n binary input lines produces 2^n output lines, and for any given n-bit input combination, exactly one of those 2^n outputs is activated while all the others remain inactive. This is structurally very similar to a demultiplexer (indeed, a demultiplexer can be thought of as a decoder with an added data-input signal that modulates which value, rather than always a fixed logic 1, gets placed on the selected output) — but a decoder's canonical purpose is specifically to translate a binary code into a one-hot 'which single position was selected' signal.
Internally, each of the 2^n outputs is typically produced by a single AND gate that takes all n input lines (each either directly or through a NOT gate, depending on whether that input bit needs to be 0 or 1 for this particular output to be the selected one) — this is exactly the minterm-generating structure from Boolean algebra: each decoder output directly implements one minterm of the n input variables.
Worked structure: 3 inputs to 8 outputs
The spec's canonical example is a 3-to-8 decoder: 3 input lines produce 8 output lines, since 2^3 = 8. For any 3-bit binary input value, exactly one of the eight outputs (matching that input value's numeric index) becomes active, and the remaining seven stay inactive. This is the same 2^n relationship that governs multiplexers, demultiplexers, and encoders throughout this module — n binary lines always correspond to exactly 2^n distinguishable positions.
Active-high versus active-low outputs
A crucial practical detail — and the spec's own tricky problem for this topic — is that decoder outputs are not universally 'active when high'. Many real decoder chips (and many decoder designs used inside larger circuits) use active-low outputs, meaning the selected output is driven to logic 0 while every unselected output is held at logic 1 — the exact opposite polarity from what might be assumed by default. Always check whether a specific decoder's outputs are active-high or active-low before wiring it into a larger design, since connecting an active-low decoder output to logic expecting an active-high signal (or vice versa) will produce a circuit that appears to select the wrong output, or every output except the intended one.
This active-high/active-low distinction is not unique to decoders — it appears throughout digital design (enable signals, reset signals, chip-select lines) — but decoders are one of the most common places a designer actually encounters and must correctly handle it, since so many real decoder ICs (such as the classic 74-series 3-to-8 decoder chips) are specifically built with active-low outputs for direct compatibility with active-low chip-select conventions used elsewhere in memory and peripheral interfacing.
Decoder structure
3 inputs -> 8 outputs (general: n inputs -> 2^n outputs)
For any n-bit input value, exactly one of the 2^n outputs is activated; all others remain inactive.
Always verify: is the "activated" state logic 1 (active-high) or logic 0 (active-low)
for this specific decoder?Code Examples
This is the spec's own worked example structure: 3 inputs → 8 outputs. With input 101 (binary 5), exactly one output, Y5, is driven active (here, to logic 1 under the active-high convention), while every other output stays at logic 0. Expected result: Y5 = 1 (active), all other outputs = 0
Input 101 (decimal 5) activates output Y5 exclusively, under an active-high output convention.
This demonstrates the spec's tricky problem directly: always check whether outputs are active-high or active-low. The identical input (101, decimal 5) still selects Y5 in both conventions, but whether 'selected' means Y5=1 or Y5=0 completely depends on which convention the specific decoder chip or design uses — reading the wrong convention would lead an engineer to conclude, incorrectly, that Y5 was not selected at all (since it appears at 0, which looks 'inactive' under the active-high assumption).
The same input still selects Y5 under either convention — but 'selected' means Y5=1 for active-high and Y5=0 for active-low.
Common mistake: Reading an active-low decoder's outputs as if they were active-high, and concluding the wrong output (or no output) was selected.
Input: A2 A1 A0 = 1 0 1 (binary 5)
Outputs Y0..Y7 (active-high: selected output = 1, all others = 0):
Y0=0 Y1=0 Y2=0 Y3=0 Y4=0 Y5=1 Y6=0 Y7=0
Only Y5 is activated, matching the input value 5.Input: A2 A1 A0 = 1 0 1 (binary 5), same as before
Outputs Y0..Y7 (active-LOW: selected output = 0, all others = 1):
Y0=1 Y1=1 Y2=1 Y3=1 Y4=1 Y5=0 Y6=1 Y7=1
Y5 is STILL the selected output -- but its active state is now logic 0, not logic 1.
Downstream logic must be built (or configured) to expect this inverted polarity.3-to-8 decoder block diagram
A decoder converts a binary code into a one-hot activation of exactly one of 2^n outputs.
A2 A1 A0
| | |
+--+--+---> [ 3-to-8 Decoder ] ---> Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
(exactly one Yi activated per input code;
check datasheet/design for active-high vs. active-low)Important Rules
n binary input lines produce 2^n output lines.
For any given input code, exactly one output is activated; all others remain inactive.
Always confirm whether a decoder's outputs are active-high (selected = 1) or active-low (selected = 0) before integrating it into a larger design.
Each decoder output typically implements one minterm of the input variables, directly connecting decoder design to Boolean minterm expansion from Module 4.
Where decoders are used
Decoders are fundamental to memory-address decoding, where a binary address must select exactly one memory chip or memory bank among several sharing a data bus (often using active-low chip-select outputs, which is precisely why the active-high/active-low distinction matters so much in practice); to seven-segment display drivers, which decode a 4-bit BCD digit into the correct pattern of active segments; and to CPU control-unit instruction decoding, where a binary opcode is decoded to activate exactly the one control signal path corresponding to the instruction currently being executed.
Assuming every decoder's outputs are active-high (selected output = 1) without checking the specific chip's or design's documentation.
Always verify whether a given decoder's outputs are active-high or active-low before wiring it into a circuit, since many common decoder ICs use active-low outputs.
The spec's tricky problem states this directly: always check whether outputs are active-high or active-low. Assuming the wrong convention leads to misreading which output is genuinely selected, potentially causing a design to malfunction in a way that is confusing to debug because the decoder's internal logic is otherwise working correctly.
[tricky] Why is it important to always check whether a decoder's outputs are active-high or active-low before using it in a design? A. Because the selected output is logic 1 under active-high but logic 0 under active-low, and misreading this convention can lead to concluding the wrong output (or no output) was selected B. Because active-low decoders have fewer total outputs than active-high decoders C. Because active-high decoders cannot be used with binary inputs, only active-low ones can D. The active-high/active-low distinction is purely cosmetic and never affects circuit behavior
A. Because the selected output is logic 1 under active-high but logic 0 under active-low, and misreading this convention can lead to concluding the wrong output (or no output) was selected — The spec's tricky problem states this directly: always check whether outputs are active-high or active-low. The same input still selects the same output index under either convention, but the actual logic level representing 'selected' is inverted between the two, which can cause a design to misinterpret decoder output if the wrong convention is assumed.
For a 3-to-8 decoder, how many output lines are activated for any single, given 3-bit input code? A. Exactly one B. Exactly three, matching the number of input lines C. All eight simultaneously D. Zero, until a separate enable signal is also asserted
A. Exactly one — A decoder's defining behavior is to activate exactly one of its 2^n outputs for any given n-bit input code — that one-hot activation (exactly one output selected, all others inactive) is what makes a decoder useful for translating a binary address or code into a single selection signal.
A 2-to-4 decoder has active-low outputs. For input A1A0=11 (binary 3), what is the state of each of its 4 outputs (Y0, Y1, Y2, Y3)?
Input 11 (binary 3) selects output index 3, i.e., Y3. Under an active-low convention: Y0=1, Y1=1, Y2=1, Y3=0 (Y3 is the selected output, driven to logic 0; every other output stays at logic 1, its inactive state).
First determine which output index is selected by the input value, then apply the active-low convention (selected = 0, all others = 1).