Comparison

Encoder vs Decoder

When you press key "5" on a 10-key calculator keypad, a 74HC147 priority encoder converts that active-low keypress into a 4-bit BCD code that the microcontroller reads. At the seven-segment display, a 7447 BCD-to-seven-segment decoder converts the same 4-bit code back into seven output signals to light the correct segments. These two ICs appear together in almost every data-entry circuit, and confusing their direction is a common exam mistake.

EEE, ECE, EI

Side-by-side comparison

ParameterEncoderDecoder
FunctionMany inputs → fewer outputs (compression)Fewer inputs → many outputs (expansion)
Typical Configuration2^n inputs → n outputsn inputs → 2^n outputs
Priority Handling74HC147: priority encoder (highest active input wins)74HC138: no priority, one output active per code
Typical IC74HC148 (8:3), 74HC147 (10:4 BCD)74HC138 (3:8), 7447 (BCD:7-seg)
Invalid Input HandlingPriority encoder handles multiple active inputsAll outputs inactive if enable is deasserted
Output TypeBinary / BCD codeOne-hot or seven-segment drive signals
Enable PinEI (enable input) on 74HC148G1, G2A, G2B on 74HC138
CascadingUse EO (enable output) and GS pins of 74HC148Use G1 enable to cascade 74HC138 to 4:16
ApplicationKeyboard encoding, interrupt priorityMemory decoding, display driving, address selection
Output PolarityActive-low outputs on 74HC148Active-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.

More Digital Electronics comparisons