The next statement terminates the current iteration of a loop, then continues with the first statement in the loop. The syntax follows.
next [ label ] [ when condition ] ;
A next statement with no label terminates the current iteration of the innermost enclosing loop. When you specify a loop label, the current iteration of that named loop is terminated.
The optional when clause executes its next statement when its condition (a Boolean expression) evaluates to TRUE.
The following example uses the next statement to copy bits conditionally from bit vector B to bit vector A only when the next condition evaluates to TRUE. The resulting circuit is shown in the figure following the example.
signal A, B, COPY_ENABLE: BIT_VECTOR (1 to 8);
. . .
A <= -00000000";
. . .
-- B is assigned a value, such as -01011011"
-- COPY_ENABLE is assigned a value, such as -11010011"
. . .
for I in 1 to 8 loop
next when COPY_ENABLE(I) = '0';
A(I) <= B(I);
end loop;
Figure 6.7 Circuit for next Statement |
The example below shows the use of nested next statements in named loops. This example processes in the following manner.
The processing continues in this manner until it is completed.
signal X, Y: BIT_VECTOR(0 to 7);
A_LOOP: for I in X'range loop
. . .
B_LOOP: for J in Y'range loop
. . .
next A_LOOP when I < J;
. . .
end loop B_LOOP;
. . .
end loop A_LOOP;