diff --git a/Changes b/Changes index d2707bbec..7dc8d7e66 100644 --- a/Changes +++ b/Changes @@ -30,6 +30,7 @@ Verilator 5.015 devel * Fix false MULTITOP on bound interfaces (#4438). [Alex Solomatnikov] * Fix internal error on real conversion (#4447). [vdhotre-ventana] * Fix lifetime unknown error on enum.name (#4448). [jwoutersymatra] +* Fix display %x formatting of real. Verilator 5.014 2023-08-06 diff --git a/src/V3Width.cpp b/src/V3Width.cpp index a279cf416..dbae4389d 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -4815,6 +4815,16 @@ private: } break; } + case 'b': // FALLTHRU + case 'o': // FALLTHRU + case 'x': { + if (argp) { + AstNodeExpr* const nextp = VN_AS(argp->nextp(), NodeExpr); + if (argp->isDouble()) spliceCvtS(argp, true, 64); + argp = nextp; + } + break; + } case 'p': { // Pattern const AstNodeDType* const dtypep = argp ? argp->dtypep()->skipRefp() : nullptr; const AstBasicDType* const basicp = dtypep ? dtypep->basicp() : nullptr; diff --git a/test_regress/t/t_dict_ref_type.pl b/test_regress/t/t_assoc_ref_type.pl similarity index 100% rename from test_regress/t/t_dict_ref_type.pl rename to test_regress/t/t_assoc_ref_type.pl diff --git a/test_regress/t/t_dict_ref_type.v b/test_regress/t/t_assoc_ref_type.v similarity index 100% rename from test_regress/t/t_dict_ref_type.v rename to test_regress/t/t_assoc_ref_type.v diff --git a/test_regress/t/t_display.out b/test_regress/t/t_display.out index 3a8033e7d..4d6c52c96 100644 --- a/test_regress/t/t_display.out +++ b/test_regress/t/t_display.out @@ -3,6 +3,7 @@ [0] In top.t.sub.write_m.subblock (sub) [0] In top.t.sub2.write_m (sub2) [0] In top.t.sub2.write_m.subblock2 (sub2) +a: -0.4=> 0.4 0 0 0 [0] Back \ Quote " [0] %b=000001100 %0b=1100 %b=00000101010111011101110111100110011001100 %0b=101010111011101110111100110011001100 %b=000001010101111000001001000110100010101100111100000010010001101000101011001111000 %0b=1010101111000001001000110100010101100111100000010010001101000101011001111000 [0] %B=000001100 %0B=1100 %B=00000101010111011101110111100110011001100 %0B=101010111011101110111100110011001100 %B=000001010101111000001001000110100010101100111100000010010001101000101011001111000 %0B=1010101111000001001000110100010101100111100000010010001101000101011001111000 diff --git a/test_regress/t/t_display.v b/test_regress/t/t_display.v index 24aa8f428..f04f26cb0 100644 --- a/test_regress/t/t_display.v +++ b/test_regress/t/t_display.v @@ -21,11 +21,13 @@ module t; sub sub (); sub2 sub2 (); + sub3 sub3 (); initial begin $write("[%0t] In %m: Hi\n", $time); sub.write_m; sub2.write_m; + sub3.write_m; // Escapes $display("[%0t] Back \\ Quote \"", $time); // Old bug when \" last on the line. @@ -229,3 +231,18 @@ module sub2; end endtask endmodule + +module sub3; + function real copyr(input real r); + copyr = r; + endfunction + + real a, d; + + task write_m; + a = 0.4; + // verilator lint_off REALCVT + $display("a: -0.4=> %.1f %0d %0x %0b", copyr(a), copyr(a), copyr(a), copyr(a)); + // verilator lint_on REALCVT + endtask +endmodule