Priority Encoder
Given multiple active inputs, finding the highest-priority one quickly.
Problem
Multiple interrupt lines or request signals are active simultaneously. How does hardware instantly determine which one to service first?
How it works
A priority encoder has N input lines and outputs the binary index of the highest-priority active input (plus a "valid" bit indicating at least one input is active). Priority is fixed by position: input Nā1 has highest priority, input 0 has lowest.
For example, an 8-to-3 priority encoder: if inputs 2, 5, and 7 are all active, the output is
Implementation: can be built as a cascade of OR gates and simple logic. For an 8-input encoder, the critical path is just 3ā4 gate delays regardless of which input is active.
Leading zero detection is a priority encoder in disguise: given a binary number, finding the position of the most significant 1 is exactly the same as finding the highest-priority active input. This is critical for floating-point normalization and variable-length shift operations.
For example, an 8-to-3 priority encoder: if inputs 2, 5, and 7 are all active, the output is
111 (binary 7) because input 7 has the highest priority.Implementation: can be built as a cascade of OR gates and simple logic. For an 8-input encoder, the critical path is just 3ā4 gate delays regardless of which input is active.
Leading zero detection is a priority encoder in disguise: given a binary number, finding the position of the most significant 1 is exactly the same as finding the highest-priority active input. This is critical for floating-point normalization and variable-length shift operations.
Key insightA priority encoder answers "which is the most important active signal?" in constant time: the hardware equivalent of finding the MSB.