Start for free Book a free session

Matching case statement

VHDL-2008 introduced the matching case statement, written as case?. It compares the expression and the choices with the matching equality operator ?=. A '-' in a choice of a std_logic based type thus matches any value in that position of the expression (LRM 10.9, 9.2.3).

A case statement has to carry the question mark in both places or in neither: a statement that starts with case? has to end with end case? (LRM 10.9). Sigasi reports a non-matching pair as an error (rule 51). Such code does not compile.

VHDL
architecture rtl of arbiter is
  signal request : std_logic_vector(2 downto 0);
  signal grant   : std_logic_vector(2 downto 0);
begin
  process(request) is
  begin
    case? request is
      when "1--"  => grant <= "100";
      when "01-"  => grant <= "010";
      when "001"  => grant <= "001";
      when others => grant <= "000";
    end case;  -- the question mark is missing

    case? request is
      when "1--"  => grant <= "100";
      when "01-"  => grant <= "010";
      when "001"  => grant <= "001";
      when others => grant <= "000";
    end case?; -- matches the case? at the start
  end process;
end architecture;