From 2d8d8add4240c39267dc15b311e3149767316d1f Mon Sep 17 00:00:00 2001 From: Sunimali Rathnayake Date: Tue, 18 Aug 2026 01:06:53 -0500 Subject: [PATCH] Fix public table offsets larger than 32 bits (#8135) --- docs/CONTRIBUTORS | 1 + include/verilated.h | 4 ++-- test_regress/t/t_public_flat_rw_large_offset.py | 16 ++++++++++++++++ test_regress/t/t_public_flat_rw_large_offset.v | 11 +++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test_regress/t/t_public_flat_rw_large_offset.py create mode 100644 test_regress/t/t_public_flat_rw_large_offset.v diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index e929b64c3..1672555b0 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -354,3 +354,4 @@ Zixi Li Zubin Jain Àlex Torregrosa Ícaro Lima +Sunimali Rathnayake diff --git a/include/verilated.h b/include/verilated.h index 3588d0f48..a498ccaf8 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -165,7 +165,7 @@ enum VerilatedVarFlags : uint32_t { struct VlVarTableEntry final { static constexpr int kMaxDims = 3; // Max packed+unpacked dims a table row holds const char* namep; // VPI-facing (protected) variable name, string literal - uint32_t byteOffset; // offsetof of storage member from module instance base + size_t byteOffset; // offsetof of storage member from module instance base VerilatedVarType vltype; uint32_t vlflags; // Direction + flags (VLVD_*/VLVF_*) uint8_t udims; // udims + pdims <= kMaxDims @@ -865,7 +865,7 @@ public: // But internals only - called from verilated modules, VerilatedSyms // One scope, consumed by VerilatedScope::scopesConstructFromTable(); replaces // per-scope 'new VerilatedScope{...}' statements, which compiles faster at scale. struct VlScopeTableEntry final { - uint32_t ptrOffset; // offsetof of the target __Vscopep_* member within the Syms object + size_t ptrOffset; // offsetof of the target __Vscopep_* member within the Syms object const char* namep; // Scope suffix name (protected), string literal const char* identp; // Identifier with escapes removed (protected) const char* defnamep; // Definition name (SCOPE_MODULE only), else "" diff --git a/test_regress/t/t_public_flat_rw_large_offset.py b/test_regress/t/t_public_flat_rw_large_offset.py new file mode 100644 index 000000000..1a778a551 --- /dev/null +++ b/test_regress/t/t_public_flat_rw_large_offset.py @@ -0,0 +1,16 @@ +#!/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=["--public-flat-rw -CFLAGS -Werror"]) + +test.passes() diff --git a/test_regress/t/t_public_flat_rw_large_offset.v b/test_regress/t/t_public_flat_rw_large_offset.v new file mode 100644 index 000000000..cdc6a0ca7 --- /dev/null +++ b/test_regress/t/t_public_flat_rw_large_offset.v @@ -0,0 +1,11 @@ +// DESCRIPTION: Verilator: Test public variable offsets larger than 32 bits +// +// This file ONLY is placed under the Creative Commons Public Domain. +// SPDX-FileCopyrightText: 2026 Wilson Snyder +// SPDX-License-Identifier: CC0-1.0 + +module t; + longint padding1[1<<28]; + longint padding2[1<<28]; + longint padding3[1<<28]; +endmodule