Skip to content

Commit 0adba99

Browse files
committed
Fix attempting static init on automatic vars
1 parent 0366b32 commit 0adba99

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/slang_frontend.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2852,7 +2852,7 @@ struct PopulateNetlist : public TimingPatternInterpretor, public ast::ASTVisitor
28522852

28532853
auto varinit = ast::makeVisitor([&](auto&, const ast::VariableSymbol &sym) {
28542854
slang::ConstantValue initval = nullptr;
2855-
if (sym.getInitializer())
2855+
if (sym.getInitializer() && sym.lifetime == ast::VariableLifetime::Static)
28562856
initval = sym.getInitializer()->eval(initial_eval.context);
28572857
initial_eval.context.createLocal(&sym, initval);
28582858
}, [&](auto&, const ast::InstanceSymbol&) {

tests/various/regress.sv

+13
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,16 @@ module r6;
4444
logic a, b;
4545
assign {>>{ a }} = b;
4646
endmodule
47+
48+
module r7submod(input logic [3:0] i);
49+
logic [3:0] w;
50+
assign w = i + 1;
51+
endmodule
52+
53+
module r7(input logic [3:0] i, output logic [3:0] out);
54+
r7submod submod(.i(i));
55+
always_comb begin
56+
automatic logic [3:0] w_fetched = submod.w;
57+
out <= w_fetched;
58+
end
59+
endmodule

0 commit comments

Comments
 (0)