Case |
LRM §8.8. |
The case statement selects for execution one of several alternative sequences of statements; the alternative is chosen based on the value of the associated expression.
[ label: ] case expression is when choices => sequential_statements when choices => sequential_statements ... end case [ label ]; choices = choice | ... choice = constant_expression | range | others -- the last choice
A case statement is a sequential statement which conditionally executes one branch only, depending on the value of the expression at the top of the case statement
The case statement contains a list of alternatives starting with the when reserved word, followed by one or more choices and a sequence of statements.
An alternative may contain several choices, which must be of the same type as the expression appearing in the case statement. For each expression there should be at least one locally static choice. The values of each choice must be unique (no duplication of values is allowed).
When all explicitly listed choices do not cover all the alternatives (all the values available for an expression of given type) the others choice must be used because the choice statements must cover all the alternatives.
C1: case Addr is when 1 => A <= '0'; when 2 => A <= '1'; B <= '1'; when 3 => A <= '0'; B <= '1'; when others => A <= '1'; B <= '0'; end case C1;