Sequential Processing 55
Inside this process statement, the value of int_ais always assumed to
be a positive value greater than 0. If the value of int_ais negative or zero,
then an error condition results and the calculation should not be com-
pleted. If the value of int_ais less than or equal to 0, then the IFstate-
ment is true and the EXITstatement is executed. The loop is immediately
terminated, and the next statement executed is the assignment statement
to yafter the LOOPstatement.
If this were a complete example, the designer would also want to alert
the user of the model that a significant error had occurred. A method to
accomplish this function would be with an ASSERTstatement, which is dis-
cussed later in this chapter.
The EXITstatement has three basic types of operations. The first involves
an EXITstatement without a loop label, or a WHENcondition. If these
conditions are true, then the EXITstatement behaves as follows.
The EXITstatement only exits from the most current LOOPstatement
encountered. If an EXITstatement is inside a LOOPstatement that is
nested inside another LOOPstatement, the EXITstatement only exits the
inner LOOPstatement. Execution still remains in the outer LOOPstate-
ment. The exit statement only exits from the most recent LOOPstatement.
This case is shown in the previous example.
If the EXITstatement has an optional loop label, then the EXITstate-
ment, when encountered, completes the execution of the loop specified by
the loop label. Therefore, the next statement executed is the one following
the END LOOPof the labeled loop. Here is an example:
PROCESS(a)
BEGIN
first_loop: FOR i IN 0 TO 100 LOOP
second_loop:FOR j IN 1 TO 10 LOOP
... ...
EXIT second_loop; -- exits the second loop only
... ...
EXIT first_loop; -- exits the first loop and second
EXIT first_loop; -- loop
END LOOP;
END LOOP;
END PROCESS;
The first EXITstatement only exits the innermost loop because it com-
pletes execution of the loop labeled second_loop. The last EXITstatement
completes execution of the loop labeled first_loop, which exits from the
first loop and the second loop.