Consider the below example:
module test;
reg a;
initial begin
a = 1'b0;
a <= 1'b1;
$display(a);
end
endmodule
The above example displays 0. My reason is because the non-blocking assignment will be assigned at step 3 of the "Stratified Event Queue" while the blocking assignment and $display are done at step 1. If I modify the example as:
module test;
reg a;
initial begin
a = 1'b0;
a <= 1'b1;
$display(a);
$monitor(a);
end
endmodule
Then 0 and 1 are printed because, I assume $monitor is executed at step 4 of the Event Queue(?). But if I modify the example further:
module test;
reg a;
initial begin
a = 1'b0;
a <= 1'b1;
$monitor(a);
$display(a);
end
endmodule
Again the output is: 0 and 1 -- which I did not expect. I expected 1 and 1 to be printed because $monitor will be evaluated at step 4 of the Event Queue, by which time, "a" is already 1. After that we have $display, which should print 1.
References I could find talk about "current simulation time" and the "stratified event queue" but I'm not sure how it works.
I appreciate your explanation! Thanks