diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 620f5d4be..9bc7bebe2 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -404,6 +404,7 @@ class TaskVisitor final : public VNVisitor { bool m_inSensesp = false; // Are we under a senitem? bool m_inNew = false; // Are we under a constructor? int m_modNCalls = 0; // Incrementing func # for making symbols + int m_unconVarNum = 0; // Unique bad connection variable // STATE - across all visitors DpiCFuncs m_dpiNames; // Map of all created DPI functions @@ -520,7 +521,7 @@ class TaskVisitor final : public VNVisitor { void connectPort(AstVar* portp, AstArg* argp, const string& namePrefix, AstNode* beginp, bool inlineTask) { - AstNodeExpr* const pinp = argp->exprp(); + AstNodeExpr* pinp = argp->exprp(); if (inlineTask) { portp->unlinkFrBack(); pushDeletep(portp); // Remove it from the clone (not original) @@ -530,15 +531,28 @@ class TaskVisitor final : public VNVisitor { } else { UINFO(9, " Port " << portp); UINFO(9, " pin " << pinp); - if (inlineTask) { - pushDeletep(pinp->unlinkFrBack()); // Cloned in assignment below - VL_DO_DANGLING(argp->unlinkFrBack()->deleteTree(), argp); // Args no longer needed - } if (portp->isWritable() && VN_IS(pinp, Const)) { pinp->v3error("Function/task " + portp->direction().prettyName() // e.g. "output" + " connected to constant instead of variable: " + portp->prettyNameQ()); - } else if (portp->isRef() || portp->isConstRef()) { + // Make temp pin to tie it off + AstVar* const varp = new AstVar{pinp->fileline(), VVarType::STMTTEMP, + "__VfuncUnconn_" + portp->name() + "__" + + std::to_string(m_unconVarNum++), + portp->dtypep()}; + m_modp->addStmtsp(varp); + AstVarScope* const newvscp = new AstVarScope{pinp->fileline(), m_scopep, varp}; + m_scopep->addVarsp(newvscp); + AstVarRef* const repp = new AstVarRef{pinp->fileline(), newvscp, VAccess::WRITE}; + pinp->replaceWith(repp); + pushDeletep(pinp); + pinp = repp; + } + if (inlineTask) { + pushDeletep(pinp->unlinkFrBack()); // Cloned in assignment below + VL_DO_DANGLING(argp->unlinkFrBack()->deleteTree(), argp); // Args no longer needed + } + if (portp->isRef() || portp->isConstRef()) { bool refArgOk = false; if (VN_IS(pinp, VarRef) || VN_IS(pinp, MemberSel) || VN_IS(pinp, StructSel) || VN_IS(pinp, ArraySel)) { diff --git a/test_regress/t/t_lib_clk_vec.v b/test_regress/t/t_lib_clk_vec.v index 17ffabc48..eacd68dd0 100644 --- a/test_regress/t/t_lib_clk_vec.v +++ b/test_regress/t/t_lib_clk_vec.v @@ -55,7 +55,7 @@ module top; // Conclude when all counters reach 10 begin - static bit done = 1'b1; + automatic bit done = 1'b1; for (int i = 0; i < N; ++i) begin if (cnt[i] != 10) done = 1'b0; end diff --git a/test_regress/t/t_lint_implicitstatic_bad.py b/test_regress/t/t_lint_implicitstatic_bad.py index 20b96a7d7..71ef8b6c0 100755 --- a/test_regress/t/t_lint_implicitstatic_bad.py +++ b/test_regress/t/t_lint_implicitstatic_bad.py @@ -9,11 +9,8 @@ import vltest_bootstrap -test.scenarios('simulator') +test.scenarios('vlt') -test.compile(fails=test.vlt_all, expect_filename=test.golden_filename) - -if not test.vlt_all: - test.execute() +test.compile(fails=True, expect_filename=test.golden_filename) test.passes() diff --git a/test_regress/t/t_lint_implicitstatic_bad.v b/test_regress/t/t_lint_implicitstatic_bad.v index e2d60dcc2..6b3fc9d11 100644 --- a/test_regress/t/t_lint_implicitstatic_bad.v +++ b/test_regress/t/t_lint_implicitstatic_bad.v @@ -39,7 +39,7 @@ module t ( endfunction initial begin - int i_no_has_init = 1; // <--- Warning: want explicit lifetime + int i_no_has_init = 1; // <--- Warning: IMPLICIT STATIC automatic int i_automatic_has_init = 1; // Ok static int i_static_has_init = 1; // Ok $finish; diff --git a/test_regress/t/t_virtual_interface_param.v b/test_regress/t/t_virtual_interface_param.v index 6caaacf4c..529f4ae43 100644 --- a/test_regress/t/t_virtual_interface_param.v +++ b/test_regress/t/t_virtual_interface_param.v @@ -14,7 +14,7 @@ module t; m #(.p(2)) m_i (); initial begin - static virtual b_if #(2) vif = m_i.b; + automatic virtual b_if #(2) vif = m_i.b; automatic int y = m_i.b.x; if (vif.x != 2) $stop; diff --git a/test_regress/t/t_virtual_interface_param_bind.v b/test_regress/t/t_virtual_interface_param_bind.v index d957791ae..72b87ddeb 100644 --- a/test_regress/t/t_virtual_interface_param_bind.v +++ b/test_regress/t/t_virtual_interface_param_bind.v @@ -14,8 +14,8 @@ module t; typedef virtual b_if vif_t; initial begin - static vif_t vif = t.m_i.if_bind; - static int y = t.m_i.if_bind.x; + automatic vif_t vif = t.m_i.if_bind; + automatic int y = t.m_i.if_bind.x; if (vif.x != 1) $stop; if (y != 1) $stop;