Fix force of unpacked arrays (#7579) (#7580)

Fixes #7579.
This commit is contained in:
Zubin Jain 2026-05-14 22:58:16 +08:00 committed by GitHub
parent c518abd22a
commit 4a1f17e75f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 46 additions and 1 deletions

View File

@ -318,3 +318,4 @@ emmettifelts
Ícaro Lima
Yogish Sekhar
24bit-xjkp
Zubin Jain

View File

@ -1123,7 +1123,12 @@ class ForceReplaceVisitor final : public VNVisitor {
return;
}
AstVarRef* const baseRefp = m_state.getOneVarRef(nodep);
AstNode* const basep = AstArraySel::baseFromp(nodep, true);
AstVarRef* const baseRefp = VN_CAST(basep, VarRef);
if (!baseRefp) {
iterateChildren(nodep);
return;
}
AstVar* const varp = baseRefp->varp();
const ForceState::VarForceInfo* const varInfo = m_state.getVarInfo(varp);
// Skip non-forceable reads, reads we intentionally protected earlier, and intermediate

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of either the GNU Lesser General Public License Version 3
# or the Perl Artistic License Version 2.0.
# SPDX-FileCopyrightText: 2026 Wilson Snyder
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('simulator')
test.compile(verilator_flags2=["--trace"])
test.execute()
test.passes()

View File

@ -0,0 +1,21 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// Minimal reproducer for Verilator 5.048 internal error:
// V3Force.cpp:216: `force` assignment has no VarRef on LHS
//
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2026 Zubin Jain
// SPDX-License-Identifier: CC0-1.0
module t;
logic forced_sig;
typedef struct {
logic [1:0] d[0:1];
} payload_t;
payload_t s;
initial begin
force forced_sig = 1'b1;
$finish(0);
end
endmodule