I’ve created an interface monitor that looks like what i have below. But, on the output of my analysis port it shows that sometimes the “data” value captured at a certain clock cycle is actually the valid data from the previous cycle; in other words the posedge of clock happens but clearly the propagation of values has not reached all the signals at the same time. In the waves i see that the signals did change at the right time and my DUT has no delays on it’s output. This struck me as a race condition with my simulator, and the issue does go away if i sample at the negedge of clock or insert some kind of delay to push the reading of the signals further back in the scheduler (aka using #0;). I’ve been doing some reading on the forum about if using #0; is the correct method here and I’ve gotten mixed answers; is there a better way? Am I missing something here?
typedef struct {
logic valid;
logic data;
} mon_t;
interface probe_if (input clk, input rst, input logic valid, input data_t data);
class probe_t extends uvm_component;
/* uvm boilerplate */
virtual task run_phase(uvm_phase phase);
mon_t mon;
forever begin
@(posedge clk);
// #0; // <-- fixes the problem
// @(negedge clk); // <-- also fixes the problem
if (valid !== 1) continue;
mon.valid = valid;
mon.data = data;
the_analysis_port.write(mon);
end
endtask
endclass
endinterface
bind /* to wherever */