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

[proper-parameter-declaration] change default behaviour #2195

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

sconwayaus
Copy link
Contributor

As discussed in #2160 and #2190, this follow up PR changes the default behaviour of the proper-parameter-declaration to raise a violation if a parameter is declared in a package, and allow localparam's instead. The use of localparam's in packages is preferred as it is more in line with the System Verilog LRM IEEE Std 1800™-2017.

Section 6.20.4 (LRM 2017 and older) states "parameters" in packages are treated as a synonym for a localparam, so tools should treat parameters as localparam's in a package. More intuitively, as parameters are overidable, a parameter in a package doesn't make sense in that packages are constant and not parameterisable.

Users can revert to the old behaviour by adding the following to their '.rules.verible_lint' file:
package_allow_parameter:true;package_allow_localparam:false

System Verilog LRM IEEE Std 1800™-2017: 6.20.4 Local parameters (localparam)

Local parameters are identical to parameters except that they cannot directly be modified by defparam statements (see 23.10.1) or instance parameter value assignments (see 23.10.2). Local parameters can be assigned constant expressions (see 11.2.1) containing parameters, which in turn can be modified with defparam statements or instance parameter value assignments.

Unlike nonlocal parameters, local parameters can be declared in a generate block, package, class body, or compilation-unit scope. In these contexts, the parameter keyword shall be a synonym for the localparam keyword.

Local parameters may be declared in a module’s parameter_port_list. Any parameter declaration appearing in such a list between a localparam keyword and the next parameter keyword (or the end of the list, if there is no next parameter keyword) shall be a local parameter. Any other parameter declaration in such a list shall be a nonlocal parameter that may be overridden as described in 23.10.

If you got this far, thanks for reading 👍

…declared in packages. The use of localparams in packages is prefered and is more in line wit the LRM (System Verilog LRM IEEE Std 1800™-2017, Section 6.20.4)
@hzeller hzeller merged commit 23cda0c into chipsalliance:master Jun 11, 2024
33 of 34 checks passed
@hzeller
Copy link
Collaborator

hzeller commented Jun 11, 2024

Thanks!

@sconwayaus sconwayaus deleted the proper_package_localparam branch June 16, 2024 11:37
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.

None yet

2 participants