Internals: Minor cleanups preparing for initialization fixes. No functional change.

This commit is contained in:
Wilson Snyder 2026-02-07 14:16:12 -05:00
parent 9068e2e5b5
commit bbb231dfe2
12 changed files with 52 additions and 45 deletions

View File

@ -291,7 +291,7 @@ public:
VNumRange declRange() const VL_MT_STABLE { return VNumRange{hi(), lo()}; }
AstNodeModule* classOrPackagep() const { return m_classOrPackagep; }
void classOrPackagep(AstNodeModule* classpackagep) { m_classOrPackagep = classpackagep; }
bool isConstrainedRand() { return m_constrainedRand; }
bool isConstrainedRand() const { return m_constrainedRand; }
void markConstrainedRand(bool flag) { m_constrainedRand = flag; }
};

View File

@ -1367,7 +1367,7 @@ public:
return resultp()->isPure();
}
bool sameNode(const AstNode*) const override { return true; }
bool hasResult() { return m_hasResult; }
bool hasResult() const { return m_hasResult; }
void hasResult(bool flag) { m_hasResult = flag; }
};
class AstFError final : public AstNodeExpr {

View File

@ -2110,26 +2110,26 @@ public:
if (flag) m_funcLocalSticky = true;
}
void funcReturn(bool flag) { m_funcReturn = flag; }
bool gotNansiType() const { return m_gotNansiType; }
void gotNansiType(bool flag) { m_gotNansiType = flag; }
bool gotNansiType() { return m_gotNansiType; }
bool hasStrengthAssignment() const { return m_hasStrengthAssignment; }
void hasStrengthAssignment(bool flag) { m_hasStrengthAssignment = flag; }
bool hasStrengthAssignment() { return m_hasStrengthAssignment; }
void isDpiOpenArray(bool flag) { m_isDpiOpenArray = flag; }
bool isDpiOpenArray() const VL_MT_SAFE { return m_isDpiOpenArray; }
void isDpiOpenArray(bool flag) { m_isDpiOpenArray = flag; }
bool isHideLocal() const { return m_isHideLocal; }
void isHideLocal(bool flag) { m_isHideLocal = flag; }
bool isHideProtected() const { return m_isHideProtected; }
void isHideProtected(bool flag) { m_isHideProtected = flag; }
void noCReset(bool flag) { m_noCReset = flag; }
bool noCReset() const { return m_noCReset; }
void noReset(bool flag) { m_noReset = flag; }
void noCReset(bool flag) { m_noCReset = flag; }
bool noReset() const { return m_noReset; }
void noSubst(bool flag) { m_noSubst = flag; }
void noReset(bool flag) { m_noReset = flag; }
bool noSubst() const { return m_noSubst; }
void substConstOnly(bool flag) { m_substConstOnly = flag; }
void noSubst(bool flag) { m_noSubst = flag; }
bool substConstOnly() const { return m_substConstOnly; }
void overriddenParam(bool flag) { m_overridenParam = flag; }
void substConstOnly(bool flag) { m_substConstOnly = flag; }
bool overriddenParam() const { return m_overridenParam; }
void overriddenParam(bool flag) { m_overridenParam = flag; }
void trace(bool flag) { m_trace = flag; }
void isLatched(bool flag) { m_isLatched = flag; }
bool isForceable() const { return m_isForceable; }

View File

@ -68,7 +68,7 @@ class BeginVisitor final : public VNVisitor {
// STATE - for current visit position (use VL_RESTORER)
AstNodeModule* m_modp = nullptr; // Current module
AstNodeFTask* m_ftaskp = nullptr; // Current function/task
AstNode* m_liftedp = nullptr; // Local nodes we are lifting into m_ftaskp
AstNode* m_liftedp = nullptr; // Local nodes we are lifting into m_ftaskp
string m_displayScope; // Name of %m in $display/AstScopeName
string m_namedScope; // Name of begin blocks above us
string m_unnamedScope; // Name of begin blocks, including unnamed blocks

View File

@ -144,6 +144,8 @@ class EmitCFunc VL_NOT_FINAL : public EmitCConstInit {
} m_emitDispState;
protected:
VL_DEFINE_DEBUG_FUNCTIONS;
EmitCLazyDecls m_lazyDecls{*this}; // Visitor for emitting lazy declarations
bool m_useSelfForThis = false; // Replace "this" with "vlSelf"
bool m_usevlSelfRef = false; // Use vlSelfRef reference instead of vlSelf pointer

View File

@ -350,6 +350,7 @@ class DynScopeVisitor final : public VNVisitor {
void visit(AstNodeModule* nodep) override {
VL_RESTORER(m_modp);
if (!VN_IS(nodep, Class)) m_modp = nodep;
VL_RESTORER(m_id);
m_id = 0;
iterateChildren(nodep);
}
@ -385,10 +386,12 @@ class DynScopeVisitor final : public VNVisitor {
bindNodeToDynScope(varp, framep);
}
for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
AstAssign* const asgnp = VN_CAST(stmtp, Assign);
UASSERT_OBJ(asgnp, stmtp, "Invalid node under block item initialization part of fork");
bindNodeToDynScope(asgnp->lhsp(), framep);
iterate(asgnp->rhsp());
if (AstAssign* const asgnp = VN_CAST(stmtp, Assign)) {
bindNodeToDynScope(asgnp->lhsp(), framep);
iterate(asgnp->rhsp());
} else {
stmtp->v3fatalSrc("Invalid node under block item initialization part of fork");
}
}
for (AstNode* stmtp = nodep->forksp(); stmtp; stmtp = stmtp->nextp()) {

View File

@ -2545,7 +2545,7 @@ class VlTest:
if out != '':
print(out)
self.copy_if_golden(fn1, fn2)
self.error("SAIF files don't match!")
self.error("SAIF files miscompare")
def _vcd_read(self, filename: str) -> dict:
data = {}

View File

@ -56,6 +56,7 @@ module t;
// verilator lint_off INFINITELOOP
// verilator lint_off INITIALDLY
// verilator lint_off INSECURE
// verilator lint_off INSIDETRUE
// verilator lint_off LATCH
// verilator lint_off LITENDIAN
// verilator lint_off MINTYPMAXDLY
@ -103,6 +104,7 @@ module t;
// verilator lint_off UNOPTFLAT
// verilator lint_off UNOPTTHREADS
// verilator lint_off UNPACKED
// verilator lint_off UNSATCONSTR
// verilator lint_off UNSIGNED
// verilator lint_off UNUSED
// verilator lint_off UNUSEDGENVAR

View File

@ -0,0 +1,25 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2023 Antmicro Ltd
// SPDX-License-Identifier: CC0-1.0
module t;
initial begin
int x = 0;
while (x < 10) begin : outer_loop
int y = 0;
while (y < x) begin : inner_loop
static int a = 0;
a++;
y++;
end
x++;
end
if (outer_loop.inner_loop.a != 45) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule

View File

@ -1,6 +1,6 @@
%Warning-STATICVAR: t/t_static_in_loop_unsup.v:14:24: Static variable with assignment declaration declared in a loop converted to automatic
14 | static int a = 0;
| ^
%Warning-STATICVAR: t/t_static_in_loop.v:13:20: Static variable with assignment declaration declared in a loop converted to automatic
13 | static int a = 0;
| ^
... For warning description see https://verilator.org/warn/STATICVAR?v=latest
... Use "/* verilator lint_off STATICVAR */" and lint_on around source to disable this message.
%Error: Exiting due to

View File

@ -10,6 +10,7 @@
import vltest_bootstrap
test.scenarios('vlt')
test.top_filename = "t/t_static_in_loop.v"
test.lint(fails=True, expect_filename=test.golden_filename)

View File

@ -1,26 +0,0 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2023 Antmicro Ltd
// SPDX-License-Identifier: CC0-1.0
module t;
initial begin
int x = 0;
while (x < 10) begin : outer_loop
int y = 0;
while (y < x) begin : inner_loop
static int a = 0;
a++;
y++;
end
x++;
end
if (outer_loop.inner_loop.a != 45) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule