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.
The monitor starts and immediately hits this line. It waits.
At time 10, rst goes from 1 to 0. This event triggers the monitor to continue.
The simulation time is now 10. The monitor proceeds to the forever loop.
forever begin ... end
The monitor enters the loop and hits the next line.
repeat(2) @(posedge aif.clk);
This is the crucial part. This statement means: "Wait for a positive edge of the clock. Then, wait for another positive edge of the clock."
The current simulation time is 10. A posedge clk just happened. The @(posedge aif.clk) construct waits for the next one.
First wait: The monitor waits until time 30 for the next posedge clk.
Second wait: The monitor has now completed one wait. It executes the @(posedge aif.clk) again. It waits for the next posedge clk after time 30, which is at time 50.
The repeat(2) block is now complete. The simulation time is 50.
t.a = aif.a; ... send.write(t);
These lines execute immediately after the repeat(2) block finishes.
Therefore, the monitor samples the DUT signals and sends the transaction to the scoreboard at time 50.
Summary of the Timeline
Time (ns)
Event
Monitor's Action
0
clk=0, rst=1
Waiting at @(negedge aif.rst);
10
rst goes to 0 (negedge), clk goes to 1 (posedge)
Unblocked. Enters forever loop. Starts waiting at repeat(2) @(posedge aif.clk);
30
clk goes to 1 (posedge)
Completes the first of the two waits.
50
clk goes to 1 (posedge)
Completes the second of the two waits. The repeat block is finished.
50
(immediately after the posedge)
Executes t.a = ..., send.write(t);
70
(next loop iteration)
The monitor will finish its next repeat(2) block.
Why is it coded this way? (Synchronization)
This timing is intentional. The typical flow is:
Driver: Drives inputs a and b on a clock edge (e.g., at t=10).
DUT (Design Under Test): Takes one full clock cycle to compute the output y. The result will be stable by the next clock edge (e.g., at t=30).
Monitor: Waits for two cycles (repeat(2)) to ensure it is sampling the DUT's output after it has had time to settle and is not in a transition phase. By waiting until t=50, it is safely sampling the result that was calculated for the inputs driven at t=10.