svlint icon indicating copy to clipboard operation
svlint copied to clipboard

New Rule: Implicit case default

Open ShreChinno opened this issue 1 year ago • 1 comments

This pull request is a simple case implementation for implicit case default. It keeps track of implicitly defined variables in a vector and references it when it encounters it under the case statement. Passes if there is a default case defined.

Relevant Issues

  • closes dalance/svlint#268

ShreChinno avatar Mar 22 '24 20:03 ShreChinno

Thanks @ShreChinno and @ronitnallagatla

Since it's trivial to construct cases where this rule will pass where it shouldn't, I think there should be some very clear warnings in the explanation. My concern is that users might use this instead of the stricter versions, and not realise that it doesn't provide the same strength of guarantees.

This will pass, but shouldn't:

always_comb begin
  if (foo) begin // Initialisation is conditional.
    a = 1;
  end

  case (bar)
    5: a = 5;
    6: a = 6;
    // no default
  endcase
end

The always_comb should ensure a compile-time error because a infers state, but the point of the stricter rules is that you don't need to wait until compilation.

DaveMcEwan avatar Apr 01 '24 20:04 DaveMcEwan

The additional exlanation seems to be good. I'll merge this PR.

dalance avatar Jun 03 '24 01:06 dalance