Fiveable

🔌Intro to Electrical Engineering Unit 15 Review

QR code for Intro to Electrical Engineering practice questions

15.3 Encoders and decoders

15.3 Encoders and decoders

Written by the Fiveable Content Team • Last updated August 2025
Written by the Fiveable Content Team • Last updated August 2025
🔌Intro to Electrical Engineering
Unit & Topic Study Guides

Encoder and Decoder Fundamentals

Encoders and decoders convert data between different formats in digital systems. Encoders compress many input lines into fewer output lines (like turning a decimal value into binary), while decoders expand fewer input lines into many output lines (binary back to decimal). You'll see these everywhere: keyboard input processing, memory address selection, and driving numeric displays.

Encoders

An encoder takes 2n2^n input lines and produces nn output lines. Only one input should be active at a time, and the encoder outputs the binary code that corresponds to that input.

  • A basic 8-to-3 encoder has 8 input lines (labeled 0 through 7) and 3 output lines (representing bit positions A2A_2, A1A_1, A0A_0)
  • When input line 5 is activated, the outputs read 101 in binary
  • A common application is keyboards: pressing a key activates one input line, and the encoder generates a unique binary code the processor can read

The limitation of a basic encoder is that it assumes only one input is active at a time. If multiple inputs go high simultaneously, the output is unpredictable. That's where priority encoders come in (covered below).

Decoders

A decoder does the reverse: it takes nn input lines and activates one of 2n2^n output lines. You feed it a binary code, and it selects the corresponding output.

  • A 3-to-8 decoder has 3 input lines and 8 output lines (labeled 0 through 7)
  • Applying binary 110 (decimal 6) to the inputs activates output line 6 while all other outputs remain inactive
  • Decoders are heavily used in memory address decoding, where a binary address selects a specific memory chip or location, and in data demultiplexing, where one data stream gets routed to one of several destinations
Encoders, Converting from Decimal to Binary

Enable Inputs

Most encoders and decoders include an enable (sometimes called "strobe") input that controls whether the device is active.

  • When enable is active, the device operates normally
  • When enable is inactive, all outputs are forced to a known state (typically all HIGH or all LOW, depending on active-low or active-high design)
  • Enable inputs are essential when you connect multiple decoders to a shared bus. You activate only the one you need, preventing output conflicts. For example, two 3-to-8 decoders can be combined into a 4-to-16 decoder by using the fourth address bit to enable one decoder while disabling the other.

Encoder Types and Applications

Encoders, atmel - Reading 2 Quadrature encoders using a single Arduino Due - Electrical Engineering Stack ...

Priority Encoders

A standard encoder breaks if two inputs go active at the same time. A priority encoder solves this by assigning each input a priority level and always outputting the binary code for the highest-priority active input.

  • Each input line has a fixed priority ranking (typically, higher-numbered inputs have higher priority)
  • A valid output (sometimes labeled VV or "any") tells you whether any input is currently active. This matters because an output of 00 could mean "input 0 is active" or "no inputs are active." The valid bit removes that ambiguity.

Example: In a 4-input priority encoder with inputs 0 through 3, suppose inputs 1 and 3 are both active. The encoder ignores input 1 and outputs 11 (binary for 3), since input 3 has higher priority.

A classic application is interrupt handling in microprocessors. Multiple devices might request attention at the same time, and the priority encoder ensures the most urgent interrupt gets serviced first.

Decoder Types and Applications

BCD Decoders

A BCD (Binary-Coded Decimal) decoder takes a 4-bit binary input representing a single decimal digit (0 through 9) and activates one of 10 output lines. The six input combinations above 9 (1010 through 1111) are invalid in BCD and typically produce no active output.

Example: If the inputs are A=1,B=0,C=0,D=1A=1, B=0, C=0, D=1 (reading ABCD=1001ABCD = 1001), the decoder activates output line 9, since binary 1001 equals decimal 9. All other output lines stay inactive.

BCD decoders show up in calculators and digital instruments wherever binary data needs to map to individual decimal digits.

7-Segment Display Decoders

A 7-segment display decoder takes a 4-bit binary input and generates the specific combination of signals needed to light up segments on a 7-segment LED display. This is different from a BCD decoder: instead of activating one of ten lines, it drives seven segment lines (labeled a through g) in the right pattern to form a visible digit.

The seven segments are arranged in a figure-8 pattern, with an optional decimal point (dp):

  • Segments a, b, c, d, e, f form the outer loop
  • Segment g is the middle horizontal bar

Example: To display the digit "5," the decoder activates segments a, f, g, c, and d while keeping segments b and e off. To display "0," all segments except g are lit.

These decoders are found in digital clocks, multimeters, microwave panels, and any device that shows numeric readouts. The decoder handles all the segment logic internally, so the rest of your circuit only needs to provide the 4-bit binary value.