Decide whether a machine interrupt is taken, and which one, from the pending bits, the enable bits and the global enable.
Hardware context: ap_soc machine trap entry and return. Machine-mode firmware and deadline analysis
Three kinds of interrupt reach the processor. The registers mip and mie hold one bit for each kind. Work out whether an interrupt is taken now, and report the cause code of the kind that is taken.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
trial | 10 | input of each check |
Full specification
Bit 11 of mip and of mie belongs to the external interrupt, bit 3 to the software interrupt and bit 7 to the timer interrupt. The cause code of a kind equals its bit number. Every other bit of both registers must be ignored.
These bit numbers, and the order below, are RISC-V facts. They are stated from common knowledge and are not checked against the specification.
Examples
Example 1
First Observation- Input
mip=0x80, mie=0x80, global enable=1
- Output
take = 1, cause = 7
The timer is pending and enabled, and the global enable is 1. Its cause code is 7.
Example 2
Second Observation- Input
mip=0x888, mie=0x88, global enable=1
- Output
take = 1, cause = 3
The external kind is pending but not enabled. Of the two kinds that pass, software comes before the timer.
Example 3
Third Observation- Input
mip=0x800, mie=0x800, global enable=0
- Output
take = 0, cause = 0
The external kind passes its own gate. The global enable is 0, so nothing is taken and the cause is 0.
Constraints and Contract
- A kind passes when its pending bit and its enable bit are both 1. take is 1 when at least one kind passes and global_ie is 1.
- When take is 1, cause is the code of the first kind that passes, in the order external, software, timer. When take is 0, cause is 0.
Hints
Hint 1
For each of the three bit numbers, combine the pending bit and the enable bit.
Hint 2
It stands in front of all three kinds together.
Hint 3
More than one kind may pass. Report the first one in the stated order, and 0 when nothing is taken.
What the grader checks: Every combination of the three pending bits, the three enable bits and the global enable; every other bit of both registers set alone and beside a real request; random words.
218 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 4 problems on this path