U17.1.2 The Reply That Came First

MediumImplementUVM · serverReview the topic

Write the wait for a reply event with a time limit. Take a reply from the request's own time step and ignore an older one. Leave the waiter count right when you give up.

Hardware context: FIFO monitor announcing overflows through a uvm_event, with a sticky overflow flag. Collect a reply event within a time limit, including a reply that came in the request's own time step.

A client sends a request and then calls get_rsp to collect the reply. The responder announces each reply by triggering rsp, a uvm_event #(rsp_note), and nobody ever resets that event. A fast responder can answer in the same time step as the request. Its trigger may run just before your wait starts or just after.

Write get_rsp. Return the first reply triggered in the request's own time step or later, within limit_ns nanoseconds. A reply from an earlier time step answers an older request: ignore it, even though the event is still on. If no reply comes in time, return null exactly limit_ns after the call. A call that gives up must leave rsp.get_num_waiters() at 0.

Full specification
What you write
class rsp_client extends rsp_client_base;
  `uvm_component_utils(rsp_client)
  function new(string name, uvm_component parent); super.new(name, parent); endfunction
  task get_rsp(int unsigned limit_ns, output rsp_note r);
    // Return the reply to the request just sent, or null once limit_ns has passed.
    rsp.wait_trigger_data(r);
  endtask
endclass
GivenWhat it does
rspThe reply event. Triggered with a fresh note per reply; never reset.
limit_nsHow long to wait. No reply in the cases arrives exactly at the limit.
The testCalls get_rsp right after each request and reads, when it returns, the reply, the time taken and rsp.get_num_waiters().
Simulator noteWhat to do
Verilator 5.052 loses an output argument when a task called inside a fork ... join_any branch writes it into a variable declared outside the branch. IEEE 1800-2023 §13.3 copies it out when the called task ends, so the variable should get it.Receive into a variable declared inside the branch, then copy it to a local of your task.
Verilator 5.052 also refuses to compile an assignment to your task's own output r inside such a branch after a wait.Set r after the join_any, from that local.

Each case is its own client and event. The test runs for 300 ns.

Examples

Example 1

A Reply in the Same Step, Before You Wait
Input
limit 8 ns; request 1 at 10 ns: reply in the same step, before the call; request 2 at 30 ns: reply 4 ns later
Output
request1_reply = 1, request1_after_ns = 0, request2_reply = 2, request2_after_ns = 4, request3_reply = 15, request3_after_ns = 255, request3_waiters_left = 15, request4_reply = 15, request4_after_ns = 255, request4_waiters_left = 15, requests_returned = 2

At 10 ns the responder triggers before get_rsp starts. The reply still belongs to this request, so the call returns it at once. Request 4 does not exist, so its fields read 15, 255 and 15.

Example 2

A Reply to the Previous Request Is Still On
Input
limit 8 ns; request 1 at 10 ns: reply 3 ns later; request 2 at 20 ns: no reply; request 3 at 40 ns: reply in the same step, after the call
Output
request1_reply = 1, request1_after_ns = 3, request2_reply = 0, request2_after_ns = 8, request3_reply = 3, request3_after_ns = 0, request4_reply = 15, request4_after_ns = 255, request4_waiters_left = 15, requests_returned = 3

Reply 1 came at 13 ns and the event stays on. Request 2 at 20 ns must not take it. It gets no reply, returns null at 28 ns and leaves no waiter behind.

Example 3

A Reply That Comes After the Limit
Input
limit 5 ns; request 1 at 10 ns: reply 8 ns later; request 2 at 25 ns: reply 4 ns later
Output
request1_reply = 0, request1_after_ns = 5, request2_reply = 2, request2_after_ns = 4, request3_reply = 15, request3_after_ns = 255, request3_waiters_left = 15, request4_reply = 15, request4_after_ns = 255, request4_waiters_left = 15, requests_returned = 2

Reply 1 comes at 18 ns, 3 ns after request 1 gave up. Request 2 at 25 ns ignores it and takes its own reply at 29 ns.

Constraints and Contract

  • Keep the class name and the task's signature.
  • Learn about replies only through rsp; do not reset it or trigger it.
  • Return within limit_ns of the call, every time.

Hints

Hint 1

Which wait forgives a trigger that ran earlier in the same time step, but not one from an earlier step?

Hint 2

Race the wait against a delay of limit_ns, and stop whichever branch is still running.

Hint 3

A wait you kill still counts as a waiter. Which call takes it out of the count?

What the grader checks: Your task runs against eight request schedules with real triggers before, during and after each call. The test reads the reply, the time taken and the waiter count after every call.

8 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

Report a problem with this page

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

A Reply in the Same Step, Before You Wait

Input
limit 8 ns; request 1 at 10 ns: reply in the same step, before the call; request 2 at 30 ns: reply 4 ns later
Expected output
request1_reply = 1, request1_after_ns = 0, request2_reply = 2, request2_after_ns = 4, request3_reply = 15, request3_after_ns = 255, request3_waiters_left = 15, request4_reply = 15, request4_after_ns = 255, request4_waiters_left = 15, requests_returned = 2

At 10 ns the responder triggers before `get_rsp` starts. The reply still belongs to this request, so the call returns it at once. Request 4 does not exist, so its fields read 15, 255 and 15.

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

UVM · server