Encoders and Decoders in Digital Electronics
1. Introduction
Encoders and decoders are important combinational logic circuits used in digital electronics to convert information from one representation into another.
An encoder converts an active input signal into a coded binary output.
A decoder converts a binary input code into a corresponding output signal or output pattern.
Both circuits are widely used in computers, communication systems, digital displays, keyboards, memory systems, and microcontrollers.
2. Encoder
An encoder is a combinational logic circuit that converts one of several input signals into a binary code.
For example, an 8-to-3 encoder has eight input lines and three output lines. Each input corresponds to a unique binary code.
The number of output bits required for an encoder with input lines is generally:
Here, is the number of output bits, and is the number of input lines. This assumes the circuit encodes up to distinct input choices.
Main features of an encoder
- Multiple input lines
- Fewer output lines
- Binary-coded output
- Combinational logic operation
- Often requires a valid-input or priority mechanism
3. Block Diagram of an Encoder
8-to-3 Encoder
8 Input Lines
D₀, D₁, D₂, D₃, D₄, D₅, D₆, D₇
ENCODER
Converts the active input into binary
3 Binary Output Bits
A₂, A₁, A₀
An 8-to-3 encoder can represent eight different input choices using three binary output bits because:
4. Types of Encoders
Common types of encoders include:
- 4-to-2 encoder
- 8-to-3 encoder
- 16-to-4 encoder
- Priority encoder
- Decimal-to-BCD encoder
- Keyboard encoder
Each type is designed for a particular input format or application.
5. 4-to-2 Binary Encoder
A 4-to-2 encoder has four input lines and two output lines.
Assuming exactly one input is HIGH at a time, the encoder generates the binary code corresponding to the active input.
Let the inputs be , and the outputs be .
Truth table
| Active input | Binary output | ||
|---|---|---|---|
| 0 | 0 | 00 | |
| 0 | 1 | 01 | |
| 1 | 0 | 10 | |
| 1 | 1 | 11 |
The output equations are:
Here, represents the OR operation.
These equations assume that only one input is active at a time. If multiple inputs are HIGH, a basic encoder may produce an ambiguous or unintended code.
Example
If input is HIGH and all other inputs are LOW, the output is:
Therefore, the encoder represents input number 2 as binary 10.
6. Priority Encoder
A priority encoder is an encoder that assigns priority to inputs when multiple inputs are active simultaneously.
In a basic encoder, multiple active inputs can make the output ambiguous. A priority encoder solves this problem by selecting the highest-priority active input.
For example, suppose has the highest priority in a 4-to-2 priority encoder.
| Selected input | Output | ||||
|---|---|---|---|---|---|
| 1 | X | X | X | 11 | |
| 0 | 1 | X | X | 10 | |
| 0 | 0 | 1 | X | 01 | |
| 0 | 0 | 0 | 1 | 00 | |
| 0 | 0 | 0 | 0 | None | 00* |
Here, X means either 0 or 1. The asterisk indicates that 00 alone cannot distinguish input from no active input; practical priority encoders often include a valid output for this reason.
Applications of priority encoders
- Interrupt handling in processors
- Keyboard input processing
- Resource selection in digital systems
- Arbitration circuits
- Control systems with competing requests
7. Decimal-to-BCD Encoder
A decimal-to-BCD encoder converts a decimal digit from 0 to 9 into its 4-bit Binary-Coded Decimal (BCD) representation.
For example:
- Decimal 0 becomes
0000 - Decimal 4 becomes
0100 - Decimal 7 becomes
0111 - Decimal 9 becomes
1001
BCD represents each decimal digit separately using four binary bits. A decimal-to-BCD encoder is useful when decimal input must be processed or displayed digitally.
Applications
- Numeric keypads
- Digital calculators
- Digital measurement instruments
- Decimal display systems
8. Decoder
A decoder is a combinational logic circuit that converts a binary input code into a corresponding output signal or pattern.
A decoder with binary input bits can have up to output lines.
For example, a 2-to-4 decoder has two binary inputs and four output lines.
The maximum number of outputs is:
Here, is the number of input bits and is the number of output lines.
Main features of a decoder
- Fewer input lines than output lines
- Binary input code
- Multiple output lines
- Usually activates one output for each valid input combination
- May include an enable input
9. Block Diagram of a Decoder
2-to-4 Decoder
2 Binary Input Bits
A₁, A₀
DECODER
Converts binary input into an output selection
4 Output Lines
Y₀, Y₁, Y₂, Y₃
A 2-to-4 decoder interprets the two input bits as a binary number and activates the corresponding output in a standard active-high implementation.
10. Types of Decoders
Common types include:
- 1-to-2 decoder
- 2-to-4 decoder
- 3-to-8 decoder
- 4-to-16 decoder
- BCD-to-decimal decoder
- BCD-to-seven-segment decoder
- Address decoder
The type of decoder depends on the number and format of its input bits and the intended output.
11. 2-to-4 Decoder
A 2-to-4 decoder has two inputs, and , and four outputs, through .
Each input combination activates one output.
Truth table
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 0 | 1 |
This table assumes an enabled decoder with active-high outputs.
Boolean expressions
Each output corresponds to one unique binary input combination.
Example
If the input is:
Then output becomes HIGH, while all other outputs remain LOW.
Therefore:
12. BCD-to-Seven-Segment Decoder
A BCD-to-seven-segment decoder converts a 4-bit BCD input into control signals for a seven-segment display.
A seven-segment display contains seven individual segments, commonly labeled . By turning selected segments ON and others OFF, the display can show decimal digits.
For example, the decimal digit 1 typically uses segments and , while the digit 8 uses all seven segments.
Seven-Segment Display
The seven segments are controlled individually to form decimal digits.
Applications
- Digital clocks
- Calculators
- Digital meters
- Electronic counters
- Numeric display panels
The exact output logic depends on whether the display uses common-anode or common-cathode wiring.
13. Address Decoder
An address decoder converts a binary address into a selection signal for a particular memory location or device.
For example, a system with three address bits can represent eight distinct addresses:
An address decoder can use these three bits to select one of eight memory blocks or devices, depending on the circuit design.
Applications
- RAM and ROM selection
- Memory mapping
- Peripheral device selection
- Microprocessor systems
- Digital control circuits
14. Difference Between Encoder and Decoder
| Feature | Encoder | Decoder |
|---|---|---|
| Main function | Converts an active input into a binary code | Converts a binary code into an output selection |
| Inputs | Usually many | Usually fewer |
| Outputs | Usually fewer | Usually many |
| Conversion | Input signals to coded output | Coded input to output signals |
| Example | 8-to-3 encoder | 3-to-8 decoder |
| Applications | Keyboards, interrupts | Displays, memory selection |
15. Relationship Between Encoders and Decoders
Encoders and decoders perform complementary coding functions.
An encoder reduces a selection among multiple input lines to a compact binary code. A decoder interprets a binary code and activates the corresponding output.
For example, a keypad can use an encoder to represent a pressed key as a binary code. A receiving circuit can then use decoding logic to identify the code or select an appropriate output.
However, a decoder does not necessarily recover every detail of an encoder's original input: that depends on whether the original encoding was unambiguous and whether its validity information was preserved.
16. Applications of Encoders and Decoders
Both circuits are used in:
- Computers and microprocessors
- Digital communication systems
- Keyboards and keypads
- Digital display systems
- Memory address selection
- Interrupt handling
- Industrial automation
- Microcontroller-based electronics
- Digital control systems
17. Summary
An encoder converts an active input into a compact binary code, while a decoder converts a binary code into a corresponding output selection or pattern.
Encoders are especially useful when several input choices must be represented using fewer bits. Decoders are useful when a binary code must select a device, memory location, or display pattern.
Together, these circuits are fundamental building blocks of combinational logic and are widely used in computers, communication systems, and digital electronics.