Skip to content

Commit

Permalink
Fix issue where multi-driver checks for called subroutines didn't app…
Browse files Browse the repository at this point in the history
…ly when one of the source procedures was a plain always block
  • Loading branch information
MikePopoloski committed Mar 8, 2024
1 parent a34e29b commit 97a57fb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 1 addition & 3 deletions source/ast/expressions/CallExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,8 @@ Expression& CallExpression::fromArgs(Compilation& compilation, const Subroutine&
// If this subroutine is invoked from a procedure, register drivers for this
// particular procedure to detect multiple driver violations.
if (!thisClass) {
if (auto proc = context.getProceduralBlock();
proc && proc->isSingleDriverBlock() && !context.scope->isUninstantiated()) {
if (auto proc = context.getProceduralBlock(); proc && !context.scope->isUninstantiated())
addSubroutineDrivers(*proc, symbol, *result);
}
}

return *result;
Expand Down
28 changes: 28 additions & 0 deletions tests/unittests/ast/ExpressionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3191,3 +3191,31 @@ endmodule
REQUIRE(diags.size() == 1);
CHECK(diags[0].code == diag::BadStreamSize);
}

TEST_CASE("Multi-driven errors through call expressions from normal always block") {
auto tree = SyntaxTree::fromText(R"(
module top(input clk, input reset);
logic c;
function logic m(logic d);
c = d;
return c;
endfunction
logic a, b;
always_ff @(posedge clk) begin
a <= m(a);
end
always @(posedge reset) begin
b <= m(a);
end
endmodule
)");

Compilation compilation;
compilation.addSyntaxTree(tree);

auto& diags = compilation.getAllDiagnostics();
REQUIRE(diags.size() == 1);
CHECK(diags[0].code == diag::MultipleAlwaysAssigns);
}

0 comments on commit 97a57fb

Please sign in to comment.