Is there any difference between @cb and @posedge IF.clk

Hi forum,

For a SV interface with a clocking block (code below), Is there any difference between following two expressions?
Is there a possibility that these two events could be triggered at different time steps or in different regions of same time step ?

Expression 1) @( posedge IF.clk ) ( wait on posedge clk )
Expression 2) @ IF.cb ( wait on clocking block event which is posedge clk )

interface example ;
logic clk ;
logic enable;

clocking cb @(posedge clk )
default input #1 output #0;
output enable ;
endclocking

endinterface

virtual example IF ;

Thanks
Jibin

Yes there is a difference, and my recommendation is: when interacting with clocking blocks, only use the clocking block event @IF.cb as the synchronizing event. That includes not using the wait() statement or any other @IF.cb.variable expressions.

There are two reasons fort this recommendation.

There is a race condition if you use the @(posedge clk) and try to read a sampled clocking block variable. The race is between reading the old sampled value and the new sampled value. This is describe in a note in section 14.4 Input and output skews of the 1800-2012 LRM.

Although not explicitly stated in the LRM, a consequence of eliminating the above race is that because clocking block event comes after all clocking block variables are updated, if you wait on a clock block variable followed by a wait on a clocking block event, both event may occur in the same time slot. so write your code as

@(IF.cb iff !IF.CB.reset); // instead of wait (!IF.cb.reset)
...
@(IF.cb) // guaranteed to be 1 cycle later.

In reply to dave_59:

Thanks Dave

In reply to jibin:

Dave,

does this assume that the reset is synchronous? If not, are there any reccomendations on handling asynchronous resets with clocking blocks?

thanks