C
C. Hymans
Guest
Hi,
I have two questions about nonblocking assignments and their interaction
with other constructs.
1. In the following program, does the simulator necessarily have to
display "Hello!" ?
module main;
reg x;
initial begin
x = 0;
#1;
x <= 1;
x <= 0;
end
always @(posedge x) $display("Hello!");
endmodule
It seems that according to the IEEE standard (5.4.1), the updates
associated with nonblocking assignments must all be performed in the
same order as the code. And so, the last process must wake up.
However, I am not sure this is really important that a simulator conform
to this.
2. Then, I don't quite understand which must be executed first between #
0-delayed process or nonblocking assignments' update.
Consider the following program:
module main;
reg x;
initial begin
x = 0;
#1;
x <= 1;
$display("0: %b", x);
#0 $display("1: %b", x);
#0 $display("2: %b", x);
#0 $display("3: %b", x);
#1 $display("-: %b", x);
end
endmodule
When does the nonblocking assignment's update really take place ? When
does x become 1 ?
From the IEEE standard, I first understood that inactive events are
executed before nonblocking assignments' update events and so I thought
only the last display would show 1. However, I tested this on 2
simulators and got 2 different outputs. I am puzzled.
Thank you in advance for your answers,
Charles
I have two questions about nonblocking assignments and their interaction
with other constructs.
1. In the following program, does the simulator necessarily have to
display "Hello!" ?
module main;
reg x;
initial begin
x = 0;
#1;
x <= 1;
x <= 0;
end
always @(posedge x) $display("Hello!");
endmodule
It seems that according to the IEEE standard (5.4.1), the updates
associated with nonblocking assignments must all be performed in the
same order as the code. And so, the last process must wake up.
However, I am not sure this is really important that a simulator conform
to this.
2. Then, I don't quite understand which must be executed first between #
0-delayed process or nonblocking assignments' update.
Consider the following program:
module main;
reg x;
initial begin
x = 0;
#1;
x <= 1;
$display("0: %b", x);
#0 $display("1: %b", x);
#0 $display("2: %b", x);
#0 $display("3: %b", x);
#1 $display("-: %b", x);
end
endmodule
When does the nonblocking assignment's update really take place ? When
does x become 1 ?
From the IEEE standard, I first understood that inactive events are
executed before nonblocking assignments' update events and so I thought
only the last display would show 1. However, I tested this on 2
simulators and got 2 different outputs. I am puzzled.
Thank you in advance for your answers,
Charles