V5.3.2 The Interrupt That Came Too Early

HardFix35 minVerilator + your C over DPI · serverReview the topic

A lockstep bench tells its model about interrupts the moment the core's pins change. On a good chip it reports a mismatch at the first interrupt. Repair it so the model takes every interrupt exactly where the core did, and still catches a core that ignores one.

Hardware context: Interrupts of ap_soc v1.5 and the model: the core's snapshot in mip against the pins. Repairing a bench that tells the model at the pins.

The given lockstep.c works for programs with no interrupts. For interrupts it keeps a list of pin events, recorded by the bench. It tells the model of each change once the chip's records pass its cycle. Run it: on the good chip it reports a difference in the first interrupt's neighbourhood. Its device answers and its compare work, so this file holds a full answer to The Lockstep Loop: solve that problem first.

Repair the notification so that the model takes each interrupt on the record where the core took it. The checking must stay honest. A record whose mip shows an enabled, pending line that the core did not take must still be reported.

The traces are two programs recorded on ap_soc v1.5. One takes a software interrupt, a timer interrupt during a loop, a GPIO interrupt through ap_plic and a timer wake from wfi. The other is the tour of lesson V5.1.

Full specification
Linemip bitPin of the coreRaised by
MSIP3 (8)irq_softwareap_clint MSIP
MTIP7 (128)irq_timerap_clint MTIME against MTIMECMP
MEIP11 (2048)irq_externalap_plic

ap_iss_set_interrupts(cpu, mask, levels) sets the lines of mask to the bits of levels and leaves the others. A record's mip field holds the three lines as the core sampled them for that record. That snapshot decided whether it was interrupted.

The pin events are what the bench saw on the core's pins, with the cycle of each change. cycles[i] is the cycle of record i. Both are given to you, so either method can be written.

Examples

Example 1

Four Interrupts and a Wake from Wfi on the Good Chip
Input
irq program as recorded
Output
record_index_plus_1 = 0, field = 0

All 298 records agree, four interrupts among them. The given bench instead reports record 13 (counting from 0), field 4 (next_pc).

Example 2

The Tour of the Trace on the Good Chip
Input
tour program as recorded
Output
record_index_plus_1 = 0, field = 0

All 67 records agree.

Example 3

Private: An Enabled Timer Line the Core Did Not Take
Input
irq program; record 39, field 24 (mip) changed by 80
Output
record_index_plus_1 = 40, field = 4

Record 39 now shows the timer line high, with MIE and MTIE set, and the core went on. The model traps there: record 39 (counting from 0), field 4 (next_pc).

Constraints and Contract

  • One file, lockstep.c. Keep device_read, device_write and the packing of the result; repair how the model learns of interrupts.
  • A case returns 0 when every record agrees, else the first record and field that differ, as in lockstep.h.
  • Some cases change one field of one record, the way a faulty core would; their labels say only "Private".

Hints

Hint 1

Count the records between the cycle the timer pin rose and the record that took the interrupt. Why is that not zero?

Hint 2

Which value tells you what the core saw, in this record, when it decided?

Hint 3

A mask decides which lines you are allowed to change. Can a line ever go low again with your mask?

What the grader checks: Each case replays recorded records of ap_soc v1.5, some with one field of one record changed. It checks the first record and field your bench reports. It does not check the latency from a pin to the core, which no model compare can see.

6 checks on Verilator + your C over DPI · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 2 problems on this path

Report a problem with this page

Your code CSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Four Interrupts and a Wake from Wfi on the Good Chip

Input
irq program as recorded
Expected output
record_index_plus_1 = 0, field = 0

All 298 records agree, four interrupts among them. The given bench instead reports record 13 (counting from 0), field 4 (next_pc).

Run samples executes all 3 public checks. Check all tests runs 6 checks on the server.

Verilator + your C over DPI · server