8.8 CASE

...
ENTITY e IS
    ...
BEGIN
    ...
END e ;

...
ARCHITECTURE a OF e IS
    ...
BEGIN
    ...
END a ;

...
CONFIGURATION c
        OF e IS
    ...
    ...
    ...
END

...
PACKAGE pkg IS
    ...
    ...
    ...
END pkg ;

case_statement ::=
[ case _label : ]
    case expression is
        case_statement_alternative
        { case_statement_alternative }
    end case [ case _label ];

..
PACKAGE BODY pck
        IS
    ...
    ...
    ...
END pck ;

...
b: BLOCK IS
    ...
BEGIN
    ...
END BLOCK b ;

FUNCTION f (...)
    RETURN r IS
    ...
BEGIN
    ...
END f ;

PROCEDURE p (...) IS
    ...
BEGIN
    ...
END p ;

p : PROCESS
    ...
BEGIN
    ...
END PROCESS p ;

8.8.1 Further definition

label ::= identifier

expression ::=
    relation { and relation }
    | relation { or relation }
    | relation { xor relation }
    | relation [ nand relation ]
    | relation [ nor relation ]

case_statement_alternative ::=
    when choices =>
    sequence_of_statements

8.8.2 Examples

CASE a IS
   WHEN '0' => s <= "0000" AFTER 2 ns ;
   WHEN '1' => s <= "1111" AFTER 2 ns ;
END CASE ;

The value of bit a is checked. If it is 0 then s is
assigned the value 0000 after 2 ns, otherwise it
is assigned the value 1111 , also after 2 ns.

CASE int_value IS
   WHEN 0       => int := 5 ;
   WHEN 1 | 2 | 8 => int := int_value ;
   WHEN 3 TO 7  => int := int_value+5;
   WHEN 9       => NULL ;
   WHEN OTHERS    => int := 0 ;
END CASE ;

The value of the integer int_value is checked.
If it is 0 then int is assigned the value 5 ; if it is 1 , 2
or 8 int is assigned the value of int_value ;
if it is between 3 and 7 int is assigned the value
int_value + 5 ; if it is 9 no action is carried out. For all
other values of int_value int is assigned the value 0 .

CASE two_bit'( a_enable & b_enable ) IS
   WHEN "00" => s <= zero AFTER 1 ns ;
   WHEN "10" => s <= a AFTER 1 ns ;
   WHEN "01" => s <= b AFTER 2 ns ;
   WHEN "11" => s <= one AFTER 1 ns ;
END CASE ;


Depending on the value of the expression
two_bit '( a_enable & b_enable ), s is assigned
the corresponding value after a certain delay.