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 DesignCPU 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 ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsLogic Gates FundamentalsImplementing Boolean Functions with GatesKarnaugh Map SimplificationCombinational Circuit DesignEncoders, Decoders, and Priority Encoders

Longest path: 78 steps · 326 total prerequisite topics

Prerequisites (1)

Leads To (2)