Skip to content

Commit

Permalink
verilog: analysis: checkers: Update always_comb_rule
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Sierszulski <[email protected]>
  • Loading branch information
msierszulski committed Feb 15, 2023
1 parent ed187c5 commit a108c4c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions verilog/analysis/checkers/always_comb_rule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,22 @@ static const Matcher& AlwaysStarMatcher() {
return matcher;
}

static const Matcher& AlwaysStarMatcherWithParentheses() {
static const Matcher matcher(NodekAlwaysStatement(
AlwaysKeyword(), AlwaysStatementHasEventControlStarAndParentheses()));
return matcher;
}

void AlwaysCombRule::HandleSymbol(const verible::Symbol& symbol,
const SyntaxTreeContext& context) {
// Check for offending use of always @*
verible::matcher::BoundSymbolManager manager;
if (AlwaysStarMatcher().Matches(symbol, &manager)) {
violations_.insert(LintViolation(symbol, kMessage, context));
}
if (AlwaysStarMatcherWithParentheses().Matches(symbol, &manager)) {
violations_.insert(LintViolation(symbol, kMessage, context));
}
}

LintRuleStatus AlwaysCombRule::Report() const {
Expand Down
8 changes: 8 additions & 0 deletions verilog/analysis/checkers/always_comb_rule_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ TEST(AlwaysCombTest, FunctionFailures) {
{"module m;\ninitial begin end\nendmodule"},
{"module m;\n", {kToken, "always"}, " @* begin end\nendmodule"},
{"module m;\n", {kToken, "always"}, " @(*) begin end\nendmodule"},
{"module m;\n", {kToken, "always"}, " @( *) begin end\nendmodule"},
{"module m;\n", {kToken, "always"}, " @(* ) begin end\nendmodule"},
{"module m;\n", {kToken, "always"}, " @( * ) begin end\nendmodule"},
{"module m;\n", {kToken, "always"}, " @(/*t*/*) begin end\nendmodule"},
{"module m;\n", {kToken, "always"}, " @(*/*t*/) begin end\nendmodule"},
{"module m;\n",
{kToken, "always"},
" @(/*t*/*/*t*/) begin end\nendmodule"},
{"module m;\nalways_ff begin a <= b; end\nendmodule"},
{"module m;\nalways_comb begin a = b; end\nendmodule"},
};
Expand Down

0 comments on commit a108c4c

Please sign in to comment.