Side-by-side comparison
| Parameter | Encoder | Decoder |
|---|---|---|
| Function | Many inputs → fewer outputs (compression) | Fewer inputs → many outputs (expansion) |
| Typical Configuration | 2^n inputs → n outputs | n inputs → 2^n outputs |
| Priority Handling | 74HC147: priority encoder (highest active input wins) | 74HC138: no priority, one output active per code |
| Typical IC | 74HC148 (8:3), 74HC147 (10:4 BCD) | 74HC138 (3:8), 7447 (BCD:7-seg) |
| Invalid Input Handling | Priority encoder handles multiple active inputs | All outputs inactive if enable is deasserted |
| Output Type | Binary / BCD code | One-hot or seven-segment drive signals |
| Enable Pin | EI (enable input) on 74HC148 | G1, G2A, G2B on 74HC138 |
| Cascading | Use EO (enable output) and GS pins of 74HC148 | Use G1 enable to cascade 74HC138 to 4:16 |
| Application | Keyboard encoding, interrupt priority | Memory decoding, display driving, address selection |
| Output Polarity | Active-low outputs on 74HC148 | Active-low outputs on 74HC138 |
Key differences
An encoder compresses: 8 active-low inputs become a 3-bit binary code in the 74HC148. The priority encoder (74HC147) goes further — if inputs 7 and 3 are both active, output reflects 7 because higher priority wins. A decoder expands: a 3-bit binary input activates exactly one of 8 output lines in the 74HC138. The 7447 BCD-to-seven-segment decoder is not a true binary decoder — it drives multiple outputs simultaneously based on a 4-bit lookup. Confusing these two directions causes logic errors in address decoding and display driving.
When to use Encoder
Use an encoder (74HC148) when multiple interrupt sources must be prioritised and a single interrupt vector code sent to the CPU, such as in an 8085-compatible interrupt controller.
When to use Decoder
Use a decoder (74HC138) when a binary address must select exactly one peripheral, such as assigning unique chip-select lines to RAM, ROM, and I/O in an 8051-based memory map.
Recommendation
For both exams and interviews, choose the 74HC138 decoder for address decoding tasks — it is the most tested IC in this category. For keyboard and interrupt encoding, choose the 74HC148 and note that it outputs active-low inverted BCD.
Exam tip: University examiners test the truth table of the 74HC148 priority encoder — note that outputs are active-low inverted binary and practice deriving the output for simultaneous inputs at positions 5 and 2.
Interview tip: Interviewers at embedded companies ask how you would connect a 74HC148 to an 8085 interrupt system; explain the role of EO and GS pins in cascading two 74HC148s to handle 16 inputs.