VHDL1066: Objects of different lengths should not be compared
Summary
| Reliability | Security | Maintainability | Code attribute | Effort to fix | Tags |
|---|---|---|---|---|---|
| HIGH | - | - | Intentionality | Logical | 30min | synthesis, bug-finder, do254, cnes, cnes-std-06600, do254-cp7, linty-ultra |
Description
Noncompliant code example
entity top is
port (
A : in std_logic_vector(1 downto 0);
B : in std_logic_vector(2 downto 0);
Z : out std_logic
);
end;
architecture rtl of top is
begin
process (A, B) is
begin
if (A = B) then
Z <= '1';
else
Z <= '0';
end if;
end process;
end;
Compliant solution
entity top is
port (
A : in std_logic_vector(2 downto 0);
B : in std_logic_vector(2 downto 0);
Z : out std_logic
);
end;
architecture rtl of top is
begin
process (A, B) is
begin
if (A = B) then
Z <= '1';
else
Z <= '0';
end if;
end process;
end;
Comparing objects of different lengths always returns false. Thus, such comparisons should be removed.
Parameters
No parameters.