slang
slang copied to clipboard
Add more lint warnings
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~~
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?
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.