Keyword: CASE
Case is a sequential statement used within a process, procedure or function that selects and executes one statement sequence among a list of alternatives, based on the value of a given expression. The expression must be of a discrete type or a one-dimensional array type.
A case statement includes—in this order—the following:
(1) the reserved word "case",
(2) the expression to be evaluated,
(3) the reserved word "is",
(4) the reserved word "when" followed by a choice and the sequence of statements to be executed if the expression evaluates to be that choice,
(5) optionally, subsequent "when" statements similar to (4),
(6) optionally, the reserved words "when others" followed by the sequence of statements to be executed if the expression evaluates to be any value other than those specified in the "when" statements above,
(7) the reserved words "end case".
Because the case statement chooses one and only one alternative for execution, all possible values for the expression must be covered in "when" statements.
A case statement is distinguished from a chain of if-then-else statements in that no priority is implied for the conditions specified.
Example
case current_state is
when IDLE =>
if start_key = ‘1’ then
current_state <= READ0;
end if;
when READ0 =>
current_state <= READ1;
when READ1 =>
current_state <= READX;
when READX =>
current_state <= WRITE0;
when WRITE0 =>
current_state <= WRITEX;
when WRITEX =>
current_state <= IDLE;
end case;
LRM
8.8
See also