Sequential Processing 49
sequence_of_statements
sequence_of_statements ::=
{sequential_statement}
choices ::=
choice{| choice}
choice ::=
SIMPLE_expression|
discrete_range|
ELEMENT_simple_name|
OTHERS
A CASEstatement consists of the keyword CASEfollowed by an expression
and the keyword IS. The expression either returns a value that matches one
of the CHOICESin a WHENstatement part, or matches an OTHERSclause. If the
expression matches the CHOICEpart of a WHEN choices =>clause, the
sequence_of_statementsfollowing is executed. After these statements are
executed, control is transferred to the statement following the END CASE
clause.
Either the CHOICESclause must enumerate every possible value of
the type returned by the expression, or the last choice must contain an
OTHERSclause.
Let’s look at some examples to reinforce what the BNF states:
CASE instruction IS
WHEN load_accum =>
accum <= data;
WHEN store_accum =>
data_out <= accum;
WHEN load|store =>
process_IO(addr);
WHEN OTHERS =>
process_error(instruction);
END CASE;
The CASEstatement executes the proper statement depending on the
value of input instruction. If the value of instruction is one of the choices
listed in the WHENclauses, then the statement following the WHENclause
is executed. Otherwise, the statement following the OTHERSclause is ex-
ecuted. In this example, when the value of instruction is load_accum, the
first assignment statement is executed. If the value of instruction is load
or store, the process_IOprocedure is called.
If the value of instruction is outside the range of the choices given, then
the OTHERSclause matches the expression and the statement following the