Ugenz Academy/IoT Tutorial

Encoders And Decoders

9 min read1,641 words

Reading progress

Keep learning

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 NN input lines is generally:

n=⌈log⁡2N⌉\boxed{n=\lceil\log_2 N\rceil}

Here, nn is the number of output bits, and NN is the number of input lines. This assumes the circuit encodes up to NN 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:

23=82^3=8

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 D0,D1,D2,D3D_0,D_1,D_2,D_3, and the outputs be Y1,Y0Y_1,Y_0.

Truth table

Active inputY1Y_1Y0Y_0Binary output
D0D_00000
D1D_10101
D2D_21010
D3D_31111

The output equations are:

Y1=D2+D3\boxed{Y_1=D_2+D_3} Y0=D1+D3\boxed{Y_0=D_1+D_3}

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 D2D_2 is HIGH and all other inputs are LOW, the output is:

Y1Y0=10\boxed{Y_1Y_0=10}

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 D3D_3 has the highest priority in a 4-to-2 priority encoder.

D3D_3D2D_2D1D_1D0D_0Selected inputOutput
1XXXD3D_311
01XXD2D_210
001XD1D_101
0001D0D_000
0000None00*

Here, X means either 0 or 1. The asterisk indicates that 00 alone cannot distinguish input D0D_0 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 nn binary input bits can have up to 2n2^n output lines.

For example, a 2-to-4 decoder has two binary inputs and four output lines.

The maximum number of outputs is:

N=2n\boxed{N=2^n}

Here, nn is the number of input bits and NN 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, A1A_1 and A0A_0, and four outputs, Y0Y_0 through Y3Y_3.

Each input combination activates one output.

Truth table

A1A_1A0A_0Y0Y_0Y1Y_1Y2Y_2Y3Y_3
001000
010100
100010
110001

This table assumes an enabled decoder with active-high outputs.

Boolean expressions

Y0=A1‾,A0‾Y_0=\overline{A_1}\\,\overline{A_0} Y1=A1‾A0Y_1=\overline{A_1}A_0 Y2=A1A0‾Y_2=A_1\overline{A_0} Y3=A1A0Y_3=A_1A_0

Each output corresponds to one unique binary input combination.

Example

If the input is:

A1A0=10A_1A_0=10

Then output Y2Y_2 becomes HIGH, while all other outputs remain LOW.

Therefore:

Y2=1\boxed{Y_2=1}

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 a,b,c,d,e,f,ga,b,c,d,e,f,g. By turning selected segments ON and others OFF, the display can show decimal digits.

For example, the decimal digit 1 typically uses segments bb and cc, 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:

23=82^3=8

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

FeatureEncoderDecoder
Main functionConverts an active input into a binary codeConverts a binary code into an output selection
InputsUsually manyUsually fewer
OutputsUsually fewerUsually many
ConversionInput signals to coded outputCoded input to output signals
Example8-to-3 encoder3-to-8 decoder
ApplicationsKeyboards, interruptsDisplays, 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.

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy