Signals has no drivers when created the AST in a test case #713
-
Hi, TEST_CASE("Not assigned on reset") {
auto tree = SyntaxTree::fromText(R"(
module top;
logic clk;
logic rst_n;
logic a, b;
always_ff @(posedge clk or negedge rst_n) begin
if (~rst_n) begin
a <= '0;
b <= 1'b1;
end else begin
a <= 1'b1;
end
end
endmodule
)");
Compilation compilation;
compilation.addSyntaxTree(tree);
auto& root = compilation.getRoot();
OnlyAssignedOnReset visitor;
bool result = visitor.check(root);
CHECK(result == false);
} Late on, in the code inside void handle(const VariableSymbol& symbol) {
if (symbol.drivers().empty())
return;
auto firstDriver = *symbol.drivers().begin();
... When variables If instead of creating a test to run the Do you have any idea why I'm seeing this difference in the execution? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
AST nodes are lazily created and evaluated, so you need to visit the whole tree in order to ensure you have found all of the drivers. The getAllDiagnostics function will do that for you (internally using an ElabVisitor to do it) so you can just make sure that's called before doing any of your own checks. |
Beta Was this translation helpful? Give feedback.
AST nodes are lazily created and evaluated, so you need to visit the whole tree in order to ensure you have found all of the drivers. The getAllDiagnostics function will do that for you (internally using an ElabVisitor to do it) so you can just make sure that's called before doing any of your own checks.