VHDL027: Identical expressions should not be used on both sides of a binary operator
Summary
| Reliability | Security | Maintainability | Code attribute | Effort to fix | Tags |
|---|---|---|---|---|---|
| HIGH | - | - | Intentionality | Logical | 10min | synthesis, vscode, simulation, linter |
Description
Using the same value on either side of a binary operator is almost always a mistake. In the case of logical operators, it is either a copy/paste error and therefore a bug, or it is simply wasted code, and should be simplified.
This rule ignores +, &, *, and **.
Noncompliant code example
if a = a then -- always true ... end if; if a /= a then -- always false ... end if; if a = b AND a = b then -- if the first one is true, the second one is too ... end if; if a = b OR a = b then -- if the first one is true, the second one is too ... end if; j := 5 / 5; -- always 1 k := 5 - 5; -- always 0
Compliant solution
if a = b then ... end if; if a = b then ... end if; j := 1; k := 0;
Parameters
No parameters.