# How the below verilog code run when it find positive edge of clock?

rd=1;
case1=2 ;
i=2;
n1=23;
always @(posedge clka)
begin
counter=counter+1;
if (rd==1) begin
#5 window[i]<=douta;     ~~~~~~~~~~~ Statement1
case(i)
endcase
#5 i<=i+1;
end
end


The statement inside always block in verilog is sequential. At the positive edge of clock :

counter=counter+1
if (rd==1) (true)


Confusion: My confusion is that as case statement is occur first because window[i]=douta (after 5 unit time). After this statement 2 occur or statement 1 and statement occur at same time.

Please anyone clear my doubt after how statement inside always block in this case run. Thank you

Time X:    if-statement

What you are running into is confusion about blocking vs non-blocking assignment. This is a nice example as to why it is called non-blocking assignment. When you hit the line #5 window[i]<=douta;, the simulator will wait 5 time units, then schedule window[i] to take on the value of douta at the end of the current time step. Because you used the non-blocking assignment operator, the execution of the always block continues to the next statements, which is the case statement. Since the assigns here are blocking assignments, they are executed immediately. Then, the #5 is hit (after the case), so the scheduler schedules the next execution for 5 time units in the future. Then it moves on to anything else it needs to do. Finally, it comes back (still within time step X+5) and completes all the non-blocking assignments (like window[i]<=douta). Thats why you are seeing what looks like non-inorder execution of your always block.