Build the register view for four synchronized GPIO pins. Let a driver tell a held level from an edge remembered while masked.
Hardware context: Peripheral interrupt register bank. Peripheral register design
A service driver needs to inspect all four causes while interrupts are disabled. Two pins can change again before software gets there.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
step | 12 | input of each check |
Full specification
Raw bits 1 and 0 follow the matching pin levels continuously. Bits 3 and 2 each remember a sampled rising edge on that pin.
A rising clock with rst_n low clears the two saved flags and both history bits, regardless of inputs. Otherwise sample both upper pins every rising clock.
Consume bits 1 and 0 acknowledge raw bits 3 and 2 respectively. A concurrent rise on that lane wins over consume.
Each enable bit gates the matching raw bit into masked. The irq output is high when any masked cause is active. Both respond between clocks.
Examples
Example 1
Reset Sample- Input
Reset edge, pins=0, enable=0, consume=0
- Output
raw = 0x0, masked = 0x0, irq = 0
Both live pins are low and reset clears the edge history.
Example 2
Two Causes- Input
Clock edge, pins=5, enable=1, consume=0
- Output
raw = 0x5, masked = 0x1, irq = 1
Pin 2 rises while pin 0 is high. Only pin 0 can request service.
Example 3
Switch Masks- Input
Before the next edge, pins=0, enable=4, consume=0
- Output
raw = 0x4, masked = 0x4, irq = 1
The live cause disappears. Enabling the saved edge exposes it immediately.
Constraints and Contract
- Keep pin_bank and its ports. Inputs are synchronous, known binary values. Reset affects only stored state.
Hints
Hint 1
Separate live observations from stored observations.
Hint 2
Track a previous sample even when reporting is disabled.
Hint 3
Check one lane, then try two different causes together.
What the grader checks: The fixture samples both between clocks and after active edges. Pin synchronization lies upstream.
234 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 2 problems on this path