Home / Learn Verilog / Priority Encoder
Priority Encoder
Highest set bit wins.
Bottom lineHighest set bit wins.
Breaking it down
The basic idea
A priority encoder reports the position of the highest-priority active input.
Why this comes up
Interrupt controllers and arbiters.
The mechanics
Use if/else-if chain from highest priority.
Where it is used
- Everyday RTL design
- FPGA and ASIC projects
- Testbenches and debugging
Try it
Priority encoderVerilog: edit and run
Multiple bits set is fine: the top one wins.
Quick check
1. Input 4'b0110 priority output?
Bit 2 is the highest set.