If Else Priority Encoder
When several interrupts arrive in the same cycle, the controller must pick one. An if/else chain builds that priority from the order of its conditions.
The module evaluates an 8-bit interrupt request vector and outputs the index of the highest-priority active interrupt. Interrupt 0 (the least significant bit) has the highest priority, and interrupt 7 (the most significant bit) has the lowest priority. If any interrupt is active, a valid flag is asserted.
This module is purely combinational. There is no clock or reset.
| Signal | Direction | Width | Description |
|---|---|---|---|
irq |
input | 8 | Interrupt request vector; each bit represents an independent interrupt source |
irq_id |
output | 3 | Index of the highest priority active interrupt; defaults to 0 if none are active |
valid |
output | 1 | Asserted (1) if at least one interrupt is active, 0 otherwise |
Constraints
- The circuit must be purely combinational with no latches
irq[0]possesses the highest priority, whileirq[7]possesses the lowest priority- When
irqis all zeros,irq_idmust explicitly output 0 andvalidmust output 0
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.
Part of Synthesis Intuition
Problem 6 of 25 in the Synthesis Intuition track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks