Write the service loop for a FIFO monitor's overflow event. Serve every overflow exactly once with its own note and announcement time, however early or late it comes.
Hardware context: FIFO monitor announcing overflows through a uvm_event, with a sticky overflow flag. Write a service loop that waits on an overflow event without missing or repeating one.
A FIFO monitor announces each overflow by triggering a uvm_event #(ovf_note). The note carries the overflow's number and the FIFO level. As in the design's status flag, an overflow stays pending until it is serviced. While the event is on, the monitor holds the next announcement back until the event is turned off.
Write run_service. It starts once, at a time the test chooses, and runs until the end of the test. Call serve(note, announced_at) exactly once for every overflow, with that overflow's own note and the time it was announced. The note does not carry the time. Start each service as soon as the overflow is pending and the previous service has ended. serve takes a fixed time, and the next overflow may be announced while it runs.
The overflows can come before your service starts, in the same time step as your wait, while you serve, or long after.
Full specification
class ovf_service extends ovf_service_base;
`uvm_component_utils(ovf_service)
function new(string name, uvm_component parent); super.new(name, parent); endfunction
task run_service();
// Serve every overflow announced on ev exactly once, with its own note
// and the time it was announced.
endtask
endclass
| Given | What it does |
|---|---|
ev | The monitor's event, typed uvm_event #(ovf_note). Set before your service starts. |
serve(n, announced_at) | Records the note and waits svc_ns. Each of these counts as a fault: a null note, a note served before, a wrong announcement time, a late start. |
| The monitor | Triggers ev with a fresh note per overflow. Waits with wait_off() while ev is on. |
Each case is its own monitor, event and service. The test reads the counts at 400 ns.
Examples
Example 1
An Overflow Before the Service Starts- Input
service starts at 10 ns, 5 ns per service; overflows at 2, 30, 60 ns
- Output
announced = 3, served = 3, served_overflows = {1, 2, 3}
The first overflow fires at 2 ns, before the service waits. Only a wait that reads the event's state sees it at 10 ns. The other two follow while nothing is pending.
Example 2
The Next Overflow Arrives During a Service- Input
service starts at 0 ns, 8 ns per service; overflows at 20, 21, 50 ns
- Output
announced = 3, served = 3, served_overflows = {1, 2, 3}
Overflow 1 is consumed at 20 ns, so the monitor announces overflow 2 at 21 ns, during the 8 ns service. When the service waits again at 28 ns, that trigger is in the past.
Example 3
An Overflow in the Very Step the Service Starts- Input
service starts at 10 ns, 10 ns per service; overflows at 10, 20, 30 ns
- Output
announced = 3, served = 3, served_overflows = {1, 2, 3}
The service starts at 10 ns, the step of the first trigger. Whether the trigger or the wait runs first must not matter.
Constraints and Contract
- Keep the class name and the task's signature.
- Use only
evto learn about overflows; do not poll the monitor. - Never call
servewithout a note from the event.
Hints
Hint 1
Which waiting call still returns if the overflow was announced before you started waiting?
Hint 2
The event stays on after it fires. What must you do so the next wait does not return for the same overflow?
Hint 3
The note and its time live in the event. What happens to them when the event is reset, or triggered again?
What the grader checks: Your service runs against seven real monitors, each with its own event, start time and service time. The counts come from the notes and times your loop passed to serve. They are checked against the monitor's own record of each announcement, which your code cannot read.
7 checks on UVM · 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