Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Rule: Implicit case default #281

Merged
merged 29 commits into from
Jun 3, 2024

Conversation

ShreChinno
Copy link
Contributor

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

@DaveMcEwan
Copy link
Contributor

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.

Comment on lines +20 to +27
This rule is a more lenient version of `case_default`. It adapts to a specific
coding style of setting default values to signals at the top of a procedural
block to ensure that signals have a default value regardless of the logic in the
procedural block. As such, this rule will only consider values set
**unconditionally** at the top of the procedural block as a default and will
disregard assignments made in conditional blocks like `if`/`else`, etc. If this
coding style is not preferred, it is strongly suggested to use the rules
mentioned below as they offer stricter guarantees.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaveMcEwan, thanks for your feedback. I have updated the explanation to indicate that this rule is not as strict as the alternatives. Is there anything else you might want to add or perhaps rephrase?

@dalance
Copy link
Owner

dalance commented Jun 3, 2024

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

@dalance dalance merged commit e3986ad into dalance:master Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Rule: Implicit case default
5 participants