Skip to content

Commit

Permalink
Change the default behaviour to raise a violation if parameter's are …
Browse files Browse the repository at this point in the history
…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)
  • Loading branch information
sconwayaus committed Jun 11, 2024
1 parent 48a03f3 commit 7093960
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ const LintRuleDescriptor &ProperParameterDeclarationRule::GetDescriptor() {
.param = {
{
.name = "package_allow_parameter",
.default_value = "true",
.default_value = "false",
.description = "Allow parameters in packages (treated as a "
"synonym for localparam).",
},
{
.name = "package_allow_localparam",
.default_value = "false",
.default_value = "true",
.description = "Allow localparams in packages.",
},
}};
Expand Down
4 changes: 2 additions & 2 deletions verilog/analysis/checkers/proper_parameter_declaration_rule.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class ProperParameterDeclarationRule : public verible::SyntaxTreeLintRule {
private:
std::set<verible::LintViolation> violations_;

bool package_allow_parameter_ = true;
bool package_allow_localparam_ = false;
bool package_allow_parameter_ = false;
bool package_allow_localparam_ = true;
};

} // namespace analysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ TEST(ProperParameterDeclarationRuleTest, RejectPackageParameters) {
"endmodule"},
};

RunConfiguredLintTestCases<VerilogAnalyzer, ProperParameterDeclarationRule>(
kTestCases,
"package_allow_parameter:false;package_allow_localparam:true");
RunLintTestCases<VerilogAnalyzer, ProperParameterDeclarationRule>(kTestCases);
}

// Tests that the expected number of localparam usage violations are found.
Expand Down Expand Up @@ -221,7 +219,9 @@ TEST(ProperParameterDeclarationRuleTest, AllowPackageParameters) {
"endpackage"},
};

RunLintTestCases<VerilogAnalyzer, ProperParameterDeclarationRule>(kTestCases);
RunConfiguredLintTestCases<VerilogAnalyzer, ProperParameterDeclarationRule>(
kTestCases,
"package_allow_parameter:true;package_allow_localparam:false");
}

} // namespace
Expand Down
2 changes: 1 addition & 1 deletion verilog/tools/lint/testdata/endif_comment.sv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package endif_comment;
`ifdef FOOBAR
parameter int P = 4;
localparam int P = 4;
`endif
endpackage

0 comments on commit 7093960

Please sign in to comment.