slang icon indicating copy to clipboard operation
slang copied to clipboard

Add more lint warnings

Open MikePopoloski opened this issue 3 years ago • 6 comments

Ideas for things that should be checked:

  • ~~Implicit conversions in constexprs that change value~~
  • ~~empty loop/if body~~
  • header guard mismatch
  • misleading if else indentation
  • ~~implicit conversions~~
  • self-assign
  • shadowing names
  • ~~signedness issues~~
  • ~~switch coverage of enum~~
  • uninitialized vars in constexprs
  • unreachable code
  • ~~unused variables~~
  • ~~unused typedef~~
  • ~~unused parameters~~
  • ~~posedge of multi-bit value~~
  • latches, blocking assignments in ffs
  • dangling else
  • ~~missing return~~
  • comparisons that always eval to same result
  • ~~enums in set membership ops~~

MikePopoloski avatar Apr 17 '22 14:04 MikePopoloski

Hi, I would like to add the following lint rule: Register only assigned on reset. The reason is that most synthesis tools will complain about this.

The following code snipped would trigger this warning:

logic my_register;
always_ff @(posedge clk or negedge rst) begin
    if (~rst) begin
        my_register <= '0;
    end else begin
        ...
        { other signals but no, my_register }
        ...
    end
end

Where it would be the best place to put the code to detect this scenario?

Sustrak avatar Jul 08 '22 06:07 Sustrak

I think it would be easiest as a post-processing task once the AST is constructed. You can walk the tree, find all variables and then loop through their drivers by calling getFirstDriver() / getNextDriver() and look at the places it's assigned.

MikePopoloski avatar Jul 09 '22 12:07 MikePopoloski