VHDL167: Pure functions should not use external signals or variables

Summary

Count: 1

ReliabilitySecurityMaintainabilityCode attributeEffort to fixTags
LOW--Intentionality | Logical2minsynthesis, vscode, simulation, linter

Description

Noncompliant code example

architecture a of e is
  signal s : std_logic;

  pure function f1 return type1 is -- Noncompliant: Mark this function as "impure" instead or remove the usage of the "s" signal
  begin
    s <= '1';
    return sig;
  end;

  function f2 return type1 is -- Noncompliant: Mark this function as "impure" or remove the usage of the "s" signal
  begin
    s <= '0';
    return sig;
  end;

begin
end;

Compliant solution

architecture a of e is
  signal s : std_logic;

  impure function f1 return type1 is -- Compliant
  begin
    s <= '1';
    return sig;
  end;

  impure function f2 return type1 is -- Compliant
  begin
    s <= '0';
    return sig;
  end;

begin
end;

Pure functions should not use external signals or variables.

Parameters

No parameters.