R
Robert Willy
Guest
Hello,
When I run the simulation of the below code, I am surprised after thinking
in more detail. nonblocking has two parts in operation: evaluation and
assignment. In this code snippet, delay 5 units is on the left assignment.
Although I looks like understanding it, I get puzzled after thinking it in
detail: Both C and D change to '02' after 5 delay units of C being '01':
Note: I use clock period=20 units
reg [2:0] C, D;
always @(posedge clk)
begin
#5 C <= 1;
#5 C <= 1+C;
D <= C + 1;
end
The even more puzzling thing is after I comment out the second '#5' line:
always @(posedge clk)
begin
#5 C <= 1;
D <= C + 1;
end
It is found D changes to '02' after 20 delay units of C being '01'!
That is, D changes to '02' after 5 delay units of the second clock rising
edge.
I don't find a useful explanation yet. Could you give me a short description
of the above two examples on the events to C and D?
Best Regards,
When I run the simulation of the below code, I am surprised after thinking
in more detail. nonblocking has two parts in operation: evaluation and
assignment. In this code snippet, delay 5 units is on the left assignment.
Although I looks like understanding it, I get puzzled after thinking it in
detail: Both C and D change to '02' after 5 delay units of C being '01':
Note: I use clock period=20 units
reg [2:0] C, D;
always @(posedge clk)
begin
#5 C <= 1;
#5 C <= 1+C;
D <= C + 1;
end
The even more puzzling thing is after I comment out the second '#5' line:
always @(posedge clk)
begin
#5 C <= 1;
D <= C + 1;
end
It is found D changes to '02' after 20 delay units of C being '01'!
That is, D changes to '02' after 5 delay units of the second clock rising
edge.
I don't find a useful explanation yet. Could you give me a short description
of the above two examples on the events to C and D?
Best Regards,