Write the bus-model service routine that preserves the phase of a periodic interrupt.
Hardware context: ap_soc machine timer in ap_clint. Periodic scheduling in an embedded controller
Write the bus-model service routine that preserves the phase of a periodic interrupt.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
sample | 12 | input of each check |
Full specification
In this ap_soc run you supply a SystemVerilog bus-functional routine in place of firmware. The judge runs each word store against the machine timer and samples its interrupt level. All numbers in the examples are hexadecimal.
last is the previous scheduled deadline. period is a nonzero unsigned interval in ticks. now is the time observed on entry. Schedule exactly one interval from last, even if the handler arrived late.
Compute modulo 2^64. Store through store_word(offset,value), which performs one completed aligned bus write. The compare register is live after each store.
Use exactly three writes. Park the low half at all ones, publish the new high half, then publish the final low half. Low and high offsets are 0x4000 and 0x4004 within ap_clint.
At each service, the logger also saves a captured PWM event in memory. Implement tick_record to construct that record. The manager supplies the high, low and high machine-time reads bracketing its sample.
Return all zeros if the high reads disagree or the timebase stopped during sleep. This logger has no independent real-time clock to reconstruct missing ticks.
| Bits of a valid record | Meaning |
|---|---|
| 68 | One for valid |
| 67 through 4 | Coherent 64-bit machine time |
| 3 through 1 | Clock offset at the start of the captured slot |
| 0 | PWM level at capture |
The peripheral divides by two and repeats four slots. Duty is the number of high slots, counting from slot zero. For captured slot two and duty three, the clock offset is four and the pin is high.
Examples
Example 1
Last 8, Interval 4, Service Time 9 (Hex)- Input
Last 8, interval 4, service time 9 (hex)
- Output
deadline = 0xc, pending = 0, ordered = 1
The schedule stays anchored at eight even though service began at nine.
Example 2
Last Fffffffe, Interval 4, Service Time 100000000 (Hex)- Input
Last fffffffe, interval 4, service time 100000000 (hex)
- Output
deadline = 0x100000002, pending = 0, ordered = 1
The sum carries into the high word before the driver publishes it.
Example 3
Last 180000000, Interval 80000001, Service Time 180000007 (Hex)- Input
Last 180000000, interval 80000001, service time 180000007 (hex)
- Output
deadline = 0x200000001, pending = 0, ordered = 1
The interval is unsigned. Both words of the next alarm change.
Constraints and Contract
- Implement rearm and tick_record in the provided bus model. The fixture observes accepted writes and the resulting hardware register.
Hints
Hint 1
Measure from the previous scheduled event.
Hint 2
Carry the unsigned interval across the word boundary.
Hint 3
Check the intermediate stores as well as the final register.
What the grader checks: Runs the real timer register slice with changing deadlines, including carries into each bit and full wrap. The log checks split reads, lost time, every capture slot and every supported duty.
284 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