Fix display with no % printing assoc array (#4376).

This commit is contained in:
Wilson Snyder 2023-11-11 15:28:44 -05:00
parent 4636a7f14b
commit cad2780219
4 changed files with 20 additions and 15 deletions

View File

@ -23,6 +23,7 @@ Verilator 5.019 devel
* Remove deprecated options (#4663). [Geza Lore]
* Optimize timing-delayed queue (#4584). [qrqiuren]
* Fix VPI TOP level variable iteration (#3919) (#4618). [Marlon James]
* Fix display with no % printing assoc array (#4376). [Alex Solomatnikov]
* Fix scheduling of external force signals (#4577) (#4668). [Geza Lore]
* Fix a memory leak in V3Fork (#4628). [Krzysztof Boroński]
* Fix linking parameterized hierarchical blocks and recursive hierarchical blocks (#4654). [Anthony Donlon]

View File

@ -4843,6 +4843,21 @@ private:
} else if (inPct) {
inPct = false;
bool added = false;
const AstNodeDType* const dtypep = argp ? argp->dtypep()->skipRefp() : nullptr;
const AstBasicDType* const basicp = dtypep ? dtypep->basicp() : nullptr;
if (ch == '?') { // Unspecified by user, guess
if (argp && argp->isDouble()) {
ch = 'g';
} else if (argp && argp->isString()) {
ch = '@';
} else if (nodep->missingArgChar() == 'd' && argp->isSigned()) {
ch = '~';
} else if (basicp) {
ch = nodep->missingArgChar();
} else {
ch = 'p';
}
}
switch (std::tolower(ch)) {
case '%': break; // %% - just output a %
case 'm': break; // %m - auto insert "name"
@ -4871,8 +4886,6 @@ private:
break;
}
case 'p': { // Pattern
const AstNodeDType* const dtypep = argp ? argp->dtypep()->skipRefp() : nullptr;
const AstBasicDType* const basicp = dtypep ? dtypep->basicp() : nullptr;
if (basicp && basicp->isString()) {
added = true;
newFormat += "\"%@\"";
@ -4944,19 +4957,6 @@ private:
}
break;
}
case '?': { // Unspecified by user, guess
if (argp && argp->isDouble()) {
ch = 'g';
} else if (argp && argp->isString()) {
ch = '@';
} else if (nodep->missingArgChar() == 'd' && argp->isSigned()) {
ch = '~';
} else {
ch = nodep->missingArgChar();
}
if (argp) argp = VN_AS(argp->nextp(), NodeExpr);
break;
}
default: { // Most operators, just move to next argument
if (argp) argp = VN_AS(argp->nextp(), NodeExpr);
break;

View File

@ -61,6 +61,7 @@ b: 000001100 000001100
4294967294
2863311530
2863311530
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].

View File

@ -19,6 +19,8 @@ module t;
string svs = "sv-str";
reg [31:0] regstr = "meep";
reg [5:0] assoc_c[int];
sub sub ();
sub2 sub2 ();
sub3 sub3 ();
@ -156,6 +158,7 @@ module t;
$display($unsigned(-2)); // 4294967294
$display("%d", 32'haaaaaaaa); // 2863311530
$display(32'haaaaaaaa); // 2863311530
$display("assoc_c=", assoc_c); // Default to %p
$display("[%0t] %s%s%s", $time,
"hel", "lo, fr", "om a very long string. Percent %s are literally substituted in.");