# VHDL217: "case" statement should not have too many "when" clauses ## Summary ```{raw} html

Count: 1

ReliabilitySecurityMaintainabilityCode attributeEffort to fixTags
MEDIUM-MEDIUMAdaptability | Focused30minsynthesis, understandability, performance, vscode, simulation, linter
``` ## Description ```{raw} html

case statement with too many when clauses may produce design with poor performance and/or hard to understand. Design should be rethought to split large case statements.

Related rules

Noncompliant code example

With maxNumberOfWhenClauses parameter set to 4:

architecture a of e is
begin
  process (data_in) is
  begin
    case data_in is
      when s1 =>
        data_out <= "000";
      when s2 =>
        data_out <= "010";
      when s3 =>
        data_out <= "100";
      when s4 =>
        data_out <= "110";
      when s5 => -- Noncompliant: 5 'when' clauses
        data_out <= "001";
    end case;
  end process;
end architecture;

Compliant solution

With maxNumberOfWhenClauses parameter set to 4:

architecture a of e is
begin
  process (data_in) is
  begin
    case data_in is
      when s1 =>
        data_out <= "000";
      when s2 =>
        data_out <= "010";
      when s3 =>
        data_out <= "100";
      when s4 =>
        data_out <= "110";
    end case;
  end process;
end architecture;
``` ## Parameters ```{raw} html

Count: 1

ParameterValueDescription
maxNumberOfWhenClauses16Maximum allowed number of 'when' clauses.
``` ```{raw} html ```