S6.10.1 The Machine Timer

MediumImplement25 minIcarus Verilog · serverReview the topic

Keep a machine deadline live while a 32-bit writer prepares its replacement.

Hardware context: ap_soc machine timer in ap_clint. Periodic scheduling in an embedded controller

Keep a machine deadline live while a 32-bit writer prepares its replacement.

Signals in the Timeline

SignalWidthRole
sample12input of each check
Full specification

This exercise adds a staging register to a machine timer. That register is an ap_soc exercise choice. All controls are sampled on the rising edge.

Synchronous reset wins over every input. Clear mtime and set both the active 64-bit deadline and the staged low word to all ones.

Otherwise restore_time loads time_in. In its absence tick increments mtime modulo 2^64. Hold time on other edges.

write_lo saves word_in without publishing it. write_hi publishes word_in as the high half with the previously staged low half. If both writes occur, use the old staging value for the commit.

Time updates and programming are independent. Drive pending whenever unsigned mtime has reached or passed the active deadline. Reevaluate after writes as well as ticks.

Examples

Example 1

Reset the Alarm
Input
Reset the alarm
Output
time = 0x0, pending = 0

Reset starts at time zero with the deadline at its maximum.

Example 2

Stage Low Word 2 and Tick
Input
Stage low word 2 and tick
Output
time = 0x1, pending = 0

Time advances to one while the old deadline remains active.

Example 3

Commit High Word 0 and Tick
Input
Commit high word 0 and tick
Output
time = 0x2, pending = 1

The committed deadline is two. This same edge advances time to two.

Constraints and Contract

  • Implement machine_alarm with the given ports. pending is a level and has no acknowledge input.

Hints

Hint 1

Restore takes priority over an ordinary tick.

Hint 2

Keep separate storage for the proposed and active values.

Hint 3

Compare the current time with the published deadline after each edge.

What the grader checks: Checks each of the 64 deadline bits in isolation, reset collisions, staging collisions, carry and wrap.

345 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

Report a problem with this page

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

Reset the Alarm

Input
Reset the alarm
Expected output
time = 0x0, pending = 0

Reset starts at time zero with the deadline at its maximum.

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

Icarus Verilog · server