Fix $display of signed/unsigned without format (#3207).

This commit is contained in:
Wilson Snyder 2021-11-17 18:50:52 -05:00
parent 0abc856be9
commit 2ccf49031b
6 changed files with 18 additions and 3 deletions

View File

@ -21,6 +21,7 @@ Verilator 4.215 devel
* Improve --thread verilation-time performance.
* Fix array method names with parenthesis (#3181) (#3183). [Teng Huang]
* Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA]
* Fix $display of signed/unsigned without format (#3207). [Julie Schwartz]
* Fix nested generate if genblk naming (#3189). [yanx21]
* Fix display of empty string constant (#3207). [Julie Schwartz]
* Fix %0 format on $value$plusargs.

View File

@ -3916,6 +3916,8 @@ private:
ch = 'g';
} else if (argp && argp->isString()) {
ch = '@';
} else if (nodep->missingArgChar() == 'd' && argp->isSigned()) {
ch = '~';
} else {
ch = nodep->missingArgChar();
}

View File

@ -88,7 +88,7 @@ module Vt_debug_emitv___024root;
$fflush(t.fd);
$fscanf(t.fd, "%d", t.sum);
;
$fdisplay(32'h69203d20, "%d", t.sum);
$fdisplay(32'h69203d20, "%~", t.sum);
$fwrite(t.fd, "hello");
$readmemh(t.fd, t.array);
$readmemh(t.fd, t.array, 32'sh0);
@ -161,7 +161,7 @@ module Vt_debug_emitv___024root;
else begin
$display("0");
end
$display("%d%d", t._Vpast_0_0t._Vpast_1_0,
$display("%~%~", t._Vpast_0_0t._Vpast_1_0,
t._Vpast_1_0);
t.str = $sformatf("cyc=%~", t.cyc);
;

View File

@ -51,6 +51,12 @@ o: 014 014
b: 000001100 000001100
-1431655766
-1431655766
4294967294
4294967294
2863311530
2863311530
[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].

View File

@ -142,6 +142,12 @@ module t;
$writeb; $displayb;
$writeb("b: "); $writeb(nine); $writeb(" "); $displayb(nine);
$writeo; $displayo;
$display("%d", $signed(32'haaaaaaaa)); // -1431655766
$display($signed(32'haaaaaaaa)); // -1431655766
$display("%d", $unsigned(-2)); // 4294967294
$display($unsigned(-2)); // 4294967294
$display("%d", 32'haaaaaaaa); // 2863311530
$display(32'haaaaaaaa); // 2863311530
$display("[%0t] %s%s%s", $time,
"hel", "lo, fr", "om a very long string. Percent %s are literally substituted in.");

View File

@ -1,6 +1,6 @@
[0] hello v=12345667
[0] Hello2
d: 12 12
d: 12 12
h: 0000000c 0000000c