Logo
All chapters
Volume II: Digital Logic  ›  Combinational Logic

Encoders

The reverse of a decoder: turns one active line into its binary code.

PrevDecoders
NextMultiplexers

Description

A circuit that outputs the binary code of an asserted input line. It compresses many status lines into a compact code (e.g. interrupts). OR-combine input indices; a priority encoder picks the highest active line.

  • A plain encoder assumes exactly one input is active.
  • A priority encoder handles multiple actives by choosing the highest.
  • A 'valid' output flags whether any input is active at all.
  • What: A circuit that outputs the binary code of an asserted input line.
  • Why: It compresses many status lines into a compact code (e.g. interrupts).
  • How: OR-combine input indices; a priority encoder picks the highest active line.
  • Where: Interrupt controllers, keypad scanning, position encoding.
  • When: When one of many events must be reported as a number.
  • O1 = I2 + I3
  • O0 = I1 + I3

At a glance

What

A circuit that outputs the binary code of an asserted input line.

Why

It compresses many status lines into a compact code (e.g. interrupts).

How

OR-combine input indices; a priority encoder picks the highest active line.

Where

Interrupt controllers, keypad scanning, position encoding.

When

When one of many events must be reported as a number.

Think of it like…

The reverse of the buzzer panel: a doorbell rings and the system tells you which flat number it was. If several ring at once, a priority encoder reports the most important one.

Priority encoding

  • A plain encoder assumes exactly one input is active.
  • A priority encoder handles multiple actives by choosing the highest.
  • A 'valid' output flags whether any input is active at all.

4-to-2 priority encoder (highest wins)

Active inputOutputValid
none000
I0001
I1011
I2101
I3111

Black-box view

I0I1I2I34-to-2 Encoderblack boxO1O0

Inputs on the left → outputs on the right · particles show signal direction

Logic diagram

0O10O0I10I20I30OROR

Click inputs to toggle · glowing wires carry 1 · particles show signal direction

The 5 Whys

  1. 1

    Why an encoder? To compress many lines into a small code.

  2. 2

    Why compress? Buses and registers carry codes, not one-hot lines.

  3. 3

    Why priority? Two inputs may assert at once and must be resolved.

  4. 4

    Why a valid bit? Code 00 is ambiguous between 'I0' and 'none'.

  5. 5

    Root cause: encoding is the inverse mapping that packs selections back into numbers.

Cheat sheet

Working principle

  • OR-combine input indices; a priority encoder picks the highest active line.
  • A circuit that outputs the binary code of an asserted input line.

Formulas & Boolean expressions

  • O1 = I2 + I3
  • O0 = I1 + I3

Key facts

  • A plain encoder assumes exactly one input is active.

Why it exists

  • Root cause: encoding is the inverse mapping that packs selections back into numbers.
PrevDecoders
NextMultiplexers