I'm basically aware that the Verilog scheduler is inherently indeterminate, but I really don't understand why that's the case with the following code (I've simulated both cases with Icarus and Incisive on EDA Playground). The differences between the TB_A
and TB_B
is in the order of the initial
and always
blocks.
Case A:
module TB_A ();
reg nrst;
reg signal;
initial
nrst = 1'b0;
always @(negedge nrst)
signal = 1'b1;
initial
#10 $display("value is: %b",signal);
endmodule
Case B:
module TB_B ();
reg nrst;
reg signal;
always @(negedge nrst)
signal = 1'b1;
initial
nrst = 1'b0;
initial
#10 $display("value is: %b",signal);
endmodule
I would expect that at T=0 the transition on nrst
occurs and inevitably triggers the always
block, putting signal
at 1. This happens in Case B but not in Case A, where is displayed the value x for signal
. In other words I wouldn't expect indeterminacy in this case, but evidently I'm missing something. Switching to SystemVerilog doesn't change anything.