A priority encoder is a digital logic circuit that takes multiple input signals, determines which one has the highest priority, and outputs that input’s position as a binary number. It solves a fundamental problem in digital systems: when several signals arrive at the same time, something has to decide which one gets attention first.
Think of it like a hospital triage system. Multiple patients may arrive simultaneously, but the system always identifies and serves the most critical one first. A priority encoder does the same thing with electrical signals, and it does it almost instantly in hardware.
How a Priority Encoder Works
A standard encoder converts an active input line into a binary code. If input line 5 is active, the output is the binary representation of 5. The problem is that a standard encoder breaks when two or more inputs are active at the same time. It produces a meaningless output because it was designed to handle only one active input.
A priority encoder fixes this by assigning a rank to each input. The highest-numbered input always wins. If inputs 2, 3, and 5 are all active simultaneously, the output code corresponds to input 5 (“101” in binary) because it has the highest priority. Once input 5 goes inactive, the encoder automatically outputs the code for input 3, the next highest. Lower-priority inputs are effectively ignored as long as any higher-priority input remains active.
This ranking is built directly into the circuit’s logic. It isn’t something you configure or program. The physical wiring of the gates determines which input takes precedence.
The Truth Table
A 4-to-2 priority encoder is the simplest useful example. It has four inputs (I3, I2, I1, I0) and produces a 2-bit binary output (O1, O0), plus a validity signal (V). The inputs are ranked from I3 (highest priority) down to I0 (lowest).
- No inputs active: Output is 00, and V = 0 (meaning “ignore the output, nothing is happening”).
- Only I0 active: Output is 00, V = 1.
- I1 active (regardless of I0): Output is 01, V = 1.
- I2 active (regardless of I1 or I0): Output is 10, V = 1.
- I3 active (regardless of all others): Output is 11, V = 1.
The key detail is the “regardless of” part. In the truth table, lower-priority inputs are marked with “x,” meaning “don’t care.” Once I3 is active, it doesn’t matter what I2, I1, or I0 are doing. The encoder reports I3 and nothing else.
The Valid Bit
You might notice an ambiguity: when only I0 is active, the output is 00. When no inputs are active, the output is also 00. Without additional information, the system receiving that output can’t tell whether input 0 is genuinely active or nothing is happening at all.
That’s why priority encoders include a valid output, typically labeled V or GS (group select). When V = 1, the binary output is meaningful and points to a real active input. When V = 0, no inputs are active, and the output bits should be disregarded. This single extra bit eliminates the ambiguity entirely.
Common Hardware Chips
Two classic integrated circuits from the 7400 logic family handle priority encoding:
- 74LS148: An 8-to-3 priority encoder. It accepts eight input lines and produces a 3-bit binary output identifying the highest-priority active input.
- 74LS147: A 10-to-4 priority encoder. It encodes nine data lines into a 4-bit BCD (binary-coded decimal) output.
Both chips use active-low inputs, meaning an input is considered “active” when it’s pulled to logic 0 rather than logic 1. This is a common convention in TTL logic families. The 74LS148 also includes enable pins that allow multiple chips to be connected together, expanding the system to handle 16, 24, or more input lines by cascading encoders in stages.
Interrupt Handling in Processors
One of the most important real-world uses for priority encoders is managing hardware interrupts in computer systems. A microprocessor can only deal with one peripheral device at a time, but multiple devices (disk drives, keyboards, mice, printers, network adapters) may all request attention simultaneously. Each device sends an interrupt request (IRQ) signal, and the processor needs to know which one to handle first.
A priority encoder sits between the peripheral devices and the processor. Each device is wired to a specific input, and its position on the encoder determines its priority level. A disk drive handling critical data might be connected to a higher-priority input than a printer, for example. When multiple IRQs arrive at once, the encoder outputs the binary code for the highest-priority device, and the processor services that device first. Once it’s done, the encoder automatically presents the next highest pending request.
Flash Analog-to-Digital Converters
Priority encoders also play a central role in flash ADCs, which are the fastest type of analog-to-digital converter. A flash ADC works by comparing an incoming analog voltage against many reference levels simultaneously, using a bank of comparators. For an 8-bit converter, that’s 255 comparators, all firing at once.
The comparators produce a “thermometer code,” where every comparator below the input voltage outputs a 1 and every comparator above it outputs a 0. The priority encoder then converts this pattern into a clean binary number by identifying the highest-order active comparator and encoding its position. Without the priority encoder, the raw comparator outputs would be unusable by the rest of the digital system.
Priority Encoders vs. Standard Encoders
A standard encoder assumes exactly one input is active at any given time. If that assumption holds, it works perfectly and uses simpler logic. But in most real systems, you can’t guarantee that only one signal will be active. Multiple interrupts fire at once. Multiple comparators trip simultaneously. Multiple sensors trigger together.
The priority encoder handles all of these cases gracefully because conflict resolution is built into its logic. The tradeoff is slightly more complex circuitry, but in practice this cost is negligible. Priority encoders have largely replaced standard encoders in any application where simultaneous inputs are possible, which is nearly every practical application. The standard encoder is mostly a teaching tool for understanding the concept before the priority version is introduced.

