diff --git a/src/V3Cast.cpp b/src/V3Cast.cpp index 7a482ec26..6f23fe88e 100644 --- a/src/V3Cast.cpp +++ b/src/V3Cast.cpp @@ -82,7 +82,8 @@ class CastVisitor final : public VNVisitor { } void ensureCast(AstNodeExpr* nodep) { if (castSize(nodep->backp()) != castSize(nodep) || !nodep->user1()) { - if (!nodep->isNull()) insertCast(nodep, castSize(nodep->backp())); + if (!nodep->isNull() && !nodep->isString() && !nodep->isDouble()) + insertCast(nodep, castSize(nodep->backp())); } } // cppcheck-suppress constParameterPointer // lhsp might be changed diff --git a/test_regress/t/t_cast_string.py b/test_regress/t/t_cast_string.py new file mode 100755 index 000000000..8a938befd --- /dev/null +++ b/test_regress/t/t_cast_string.py @@ -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() + +test.execute() + +test.passes() diff --git a/test_regress/t/t_cast_string.v b/test_regress/t/t_cast_string.v new file mode 100644 index 000000000..882b54d77 --- /dev/null +++ b/test_regress/t/t_cast_string.v @@ -0,0 +1,50 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain. +// SPDX-FileCopyrightText: 2026 Wilson Snyder +// SPDX-License-Identifier: CC0-1.0 + +module t; + + typedef struct { + string path; + int offset; + int size; + } uvm_hdl_path_slice; + + class ral_reg; + function void add_hdl_path(uvm_hdl_path_slice slices[], string kind = "RTL"); + foreach (slices[i]) begin + $display("Add %s", slices[i].path); + end + endfunction + endclass + + class Cls; + + rand ral_reg m_counters[4]; + + function new(); + foreach (this.m_counters[i]) begin + this.m_counters[i] = new; + end + endfunction + + function void build(); + foreach (this.m_counters[i]) begin + int J = i; + // this.m_counters[J] = ral_reg_slave_B1_COUNTERS::type_id::create( + // $sformatf("COUNTERS[%0d]", J),, get_full_name()); + this.m_counters[J].add_hdl_path('{'{$sformatf("COUNTERS[%0d]", J), -1, -1}}); + end + endfunction + endclass + + initial begin + Cls c; + c = new; + c.build; + $finish; + end + +endmodule diff --git a/test_regress/t/t_constraint_array_index_unsup.out b/test_regress/t/t_constraint_array_index_unsup.out index 1d9c596e4..85ff611a6 100644 --- a/test_regress/t/t_constraint_array_index_unsup.out +++ b/test_regress/t/t_constraint_array_index_unsup.out @@ -1,6 +1,6 @@ -%Warning-CONSTRAINTIGN: t/t_constraint_array_index_unsup.v:13:11: Unsupported: item.index in array reduction constraint 'with' clause; treating as state - 13 | data.sum() with (item.index) <= 10; - | ^~~ +%Warning-CONSTRAINTIGN: t/t_constraint_array_index_unsup.v:13:10: Unsupported: item.index in array reduction constraint 'with' clause; treating as state + 13 | data.sum() with (item.index) <= 10; + | ^~~ ... For warning description see https://verilator.org/warn/CONSTRAINTIGN?v=latest ... Use "/* verilator lint_off CONSTRAINTIGN */" and lint_on around source to disable this message. %Error: Exiting due to diff --git a/test_regress/t/t_constraint_array_limit.out b/test_regress/t/t_constraint_array_limit.out index 2394ae08a..af6772013 100644 --- a/test_regress/t/t_constraint_array_limit.out +++ b/test_regress/t/t_constraint_array_limit.out @@ -1,6 +1,6 @@ -%Warning-CONSTRAINTIGN: t/t_constraint_array_limit.v:15:10: Constraint array reduction ignored (array size 32 exceeds --constraint-array-limit of 16), treating as state - 15 | data.sum() with (item) < 1000; - | ^~~ +%Warning-CONSTRAINTIGN: t/t_constraint_array_limit.v:16:22: Constraint array reduction ignored (array size 32 exceeds --constraint-array-limit of 16), treating as state + 16 | constraint c {data.sum() with (item) < 1000;} + | ^~~ ... For warning description see https://verilator.org/warn/CONSTRAINTIGN?v=latest ... Use "/* verilator lint_off CONSTRAINTIGN */" and lint_on around source to disable this message. %Error: Exiting due to