From 22d6bb818027064b5522019723835bf7b4140a38 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 11 Sep 2024 08:41:11 -0400 Subject: [PATCH] Fix display with multiple string formats (#5311). --- Changes | 1 + src/V3Width.cpp | 2 +- test_regress/t/t_display.out | 1 + test_regress/t/t_display.v | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 164d4a7c2..94f5d189c 100644 --- a/Changes +++ b/Changes @@ -26,6 +26,7 @@ Verilator 5.029 devel * Add method to check if there are VPI callbacks of the given type (#5399). [Kaleb Barrett] * Improve Verilation thread pool (#5161). [Bartłomiej Chmiel, Antmicro Ltd.] * Improve performance of V3VariableOrder with parallelism (#5406). [Bartłomiej Chmiel, Antmicro Ltd.] +* Fix display with multiple string formats (#5311). [Luiza de Melo] * Fix performance of V3Trace when many activity blocks (#5372). [Deniz Güzel] * Fix REALCVT warning on integral timescale conversions (#5378). [Liam Braun] * Fix multidimensional function return value selects (#5382). [Gökçe Aydos] diff --git a/src/V3Width.cpp b/src/V3Width.cpp index c9a2c1d73..82ddd46ac 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -5181,7 +5181,7 @@ class WidthVisitor final : public VNVisitor { ch = 'g'; } else if (argp && argp->isString()) { ch = '@'; - } else if (nodep->missingArgChar() == 'd' && argp->isSigned()) { + } else if (argp && nodep->missingArgChar() == 'd' && argp->isSigned()) { ch = '~'; } else if (basicp) { ch = nodep->missingArgChar(); diff --git a/test_regress/t/t_display.out b/test_regress/t/t_display.out index 0c5fe4274..dee744f90 100644 --- a/test_regress/t/t_display.out +++ b/test_regress/t/t_display.out @@ -65,6 +65,7 @@ assoc_c='{} [0] hello, from a very long string. Percent %s are literally substituted in. hello, from a concatenated string. hello, from a concatenated format string [0]. +two 2 args 3with commas extra argument: 0 0 : pre argument after empty: > < diff --git a/test_regress/t/t_display.v b/test_regress/t/t_display.v index 2cf490fc2..c1c5634fd 100644 --- a/test_regress/t/t_display.v +++ b/test_regress/t/t_display.v @@ -164,6 +164,7 @@ module t; "hel", "lo, fr", "om a very long string. Percent %s are literally substituted in."); $display("hel", "lo, fr", "om a concatenated string."); $write("hel", "lo, fr", "om a concatenated format string [%0t].\n", $time); + $display("two %d", 2, " args %d", 3, "with commas"); $display("extra argument: ", $time); $display($time,, ": pre argument",, "after"); $display("empty: >%s<", "");