A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Encoders, Decoders, and Priority Encoders

College Depth 77 in the knowledge graph ☐ I know this ☆ Set as goal
104topics build on this
326prerequisites beneath it
See this on the map →
Combinational Circuit Design→→CPU DatapathMemory Organization and Addressing
encoder decoder combinational address-decoding

Core Idea

A decoder takes an n-bit input and activates exactly one of 2n output lines — used to select memory locations or I/O devices given an address. An encoder performs the inverse, converting one active input line into an n-bit code. A priority encoder handles multiple simultaneous inputs by encoding the highest-priority active line. These circuits are fundamental in memory addressing, instruction decoding, and interrupt handling in computer systems.

How It's Best Learned

Design a 2-to-4 decoder and a 4-to-2 encoder from truth tables. Extend to a 3-to-8 decoder and verify all 8 output combinations. Build a simple priority encoder and trace its behavior when multiple inputs are simultaneously active.

Common Misconceptions

Explainer

From your study of combinational circuit design, you know how to build circuits whose outputs depend purely on their current inputs. Encoders and decoders are among the most practically important combinational circuits in computer architecture, and they perform complementary translations between two representations of information: a one-hot encoding (where exactly one line among many is active) and a binary encoding (a compact multi-bit code).

A decoder takes an *n*-bit binary input and activates exactly one of 2n output lines. Think of it as an address translator: given the binary address `01`, a 2-to-4 decoder asserts output line 1 (the second line, counting from zero) and deasserts the other three. Internally, each output line is an AND gate that checks for a specific input pattern. Output 0 is AND(A', B'), output 1 is AND(A', B), output 2 is AND(A, B'), and output 3 is AND(A, B). Decoders are everywhere in computer systems — they select which memory chip responds to a given address, they activate the correct register in a register file, and inside the CPU's control unit, they decode instruction opcodes into control signals that drive the datapath.

An encoder performs the inverse operation: given 2n input lines with exactly one active, it produces the *n*-bit binary code identifying which line is active. A 4-to-2 encoder with input line 2 active outputs `10`. The practical limitation of a simple encoder is that it assumes exactly one input is active at a time. When multiple inputs can be active simultaneously — as happens in interrupt systems where several devices may request attention at once — you need a priority encoder. A priority encoder assigns a fixed priority ordering to the input lines (typically higher-numbered inputs have higher priority) and outputs the binary code of the highest-priority active input, along with a "valid" bit indicating that at least one input is active.

These circuits compose naturally into larger systems. A 3-to-8 decoder can be built from two 2-to-4 decoders plus an inverter, using the third input bit to enable one decoder and disable the other. Similarly, decoders with enable inputs can be cascaded to build address decoding logic for an entire memory system: a top-level decoder selects which memory bank is active, and within each bank, a lower-level decoder selects the specific word line. This hierarchical composition means you rarely need to design a massive decoder from scratch — you build it from smaller, well-understood pieces, which is a recurring pattern in digital design.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Encoders, Decoders, and Priority Encoders

Longest path: 78 steps · 326 total prerequisite topics

Prerequisites (1)

Leads To (2)