What Is a Decoder?
A decoder is a logic circuit that reads the binary code at its input and activates only the single output corresponding to it. It decodes n inputs into 2ⁿ outputs.
How Does It Work?
For example, a 2-to-4 decoder reads a 2-bit input (00, 01, 10, 11) and activates only the one of four outputs corresponding to the input; the others stay inactive.
Address Decoding
This is its most common use: it decodes a processor's address lines to determine which memory or peripheral chip is selected (it generates "chip select").
| Type | Input → Output |
|---|---|
| 2:4 | 2 inputs, 4 outputs |
| 3:8 | 3 inputs, 8 outputs |
| 4:16 | 4 inputs, 16 outputs |
Difference From an Encoder
A decoder converts a binary code into a single active output; an encoder does the opposite: it converts the active input into a binary code. The two are opposite operations.
Where Is It Used?
Memory/peripheral addressing, driving a 7-segment display, keypad scanning and use as a demux. Common ICs: 74HC138 (3:8), 74HC139.
BCD and 7-Segment Decoder
A special type of decoder takes a BCD (binary-coded decimal) input and drives the correct segments of a 7-segment display (e.g. the 7447). So the microcontroller sends only the digit's BCD value instead of each segment individually.
Common Mistakes
- Active level: most decoder outputs are active-low (LOW); this must not be overlooked.
- Not using enable: the enable terminal is critical in address decoding.
- Confusing with an encoder: their functions are opposite.
Frequently Asked Questions
What does the 74HC138 do?+
Can a decoder be used as a demux?+
Search parts related to "What Is a Decoder?"
Find the right part by comparing price, stock and distributors.