while(cond) blockexecutes

reg [1:0] x; initial x = 0; always begin while(x < 3) begin x = x + 1; wait(1); end x = 0; endresults in the sequence 0,1,2,3,0,1,...for

A `for` loop, on the other hand, must have static upper and lower
bounds, and is unrolled at compile time. Thus, for example,

for(i = 0; i < 4; i = i + 1) block(i)is exactly equivalent to

block(0); block(1); block(2); block(3);The block in this case need not contain a wait statement.

2003-01-07