virtual task run_phase(uvm_phase phase);
@(negedge aif.rst);
forever begin
repeat(2)@(posedge aif.clk);
t.a = aif.a;
t.b = aif.b;
t.y = aif.y;
`uvm_info("MON", $sformatf("Data send to Scoreboard a : %0d , b : %0d and y : %0d", t.a,t.b,t.y), UVM_NONE);
send.write(t);
end
endtask
////////
clock is always #10 aif.clk = ~aif.clk;
here I have one issue he said @(negedge aif.rst);
so that means if negedge rst happens at 10 and clk also happens at 10 seconds
repeat(2)@(posedge aif.clk); does that mean i this line repeat(2)@(posedge aif.clk); happens at 30 or at 50
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Let's walk through the timing to understand exactly when the repeat(2)@(posedge aif.clk); statement completes its wait.
For example, assume the following:
The clock is generated by:
systemverilog
always #10 aif.clk = ~aif.clk;
This gives a clock period of 20 time units. (If the clock starts at 0 at time 0, then it toggles to 1 at time 10, back to 0 at time 20, to 1 at time 30, and so on.)
The monitor’s run_phase begins with:
systemverilog
@(negedge aif.rst);
Suppose the reset is driven so that its falling edge (negedge) occurs at time 10. (That is, at time 10 the reset goes from 1 to 0.)
Now, after the negedge is detected (at time 10), the code immediately enters the forever loop:
systemverilog
forever begin
repeat(2)@(posedge aif.clk);
// ... code using aif signals ...
end
Let's analyze the repeat(2)@(posedge aif.clk);:
Event Semantics for @(negedge aif.rst):
When the negedge of aif.rst occurs at time 10, the process resumes. However, note that in event control constructs—even if the negedge and a posedge might appear “simultaneous” (for example, if the reset falls at exactly time 10 and the clock rises at time 10), the simulation engine schedules events in a well-defined order (with delta cycles). In many cases, the event control that just triggered (the negedge) completes its aim and the process then "checks" for further events starting from the next delta.
When Do the Next @(posedge aif.clk) Events Occur?
Given a clock with rising edges at times 10, 30, 50, ... (as explained below):
If aif.clk starts at 0 at time 0, then toggling at time 10 → 1 (first rising edge), time 20 → 0, time 30 → 1 (second rising edge), time 40 → 0, time 50 → 1 (third rising edge), etc.
Now, if the negedge of reset is detected at time 10, one must consider whether that posedge at time 10 is “consumed” by the reset wait or not. In SystemVerilog, event controls typically complete in the same simulation time (but in a newer delta cycle). In many cases, if the trigger event happens at time 10, the process does not consider the same event for subsequent waits—it will wait for events that occur after it resumes.
This means that even though the clock toggles at time 10, the repeat(2)@(posedge aif.clk); will not “see” that same posedge. It will wait for the next two rising edges.
Timing Summary:
Time 10:
aif.clk rising edge occurs.
aif.rst negedge occurs and triggers the wait.
After resuming at time 10:
The first @(posedge aif.clk) in the repeat(2) will then wait for the next rising edge, which will be at time 30.
The second @(posedge aif.clk) will then wait for the following rising edge at time 50.
Thus, the repeat(2)@(posedge aif.clk); construct completes its wait at time 50. After time 50, the monitor will sample the signals (aif.a, aif.b, aif.y) and send the transaction to the scoreboard.
Final Answer
If the negedge of aif.rst occurs at time 10 (coinciding with a posedge on the clock), the repeat(2)@(posedge aif.clk); will complete at time 50.