mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
handle constant format field widths (#3946)
This commit is contained in:
+8
-1
@@ -1084,12 +1084,19 @@ private:
|
||||
const string format = nodep->text();
|
||||
auto pos = format.cbegin();
|
||||
bool inPct = false;
|
||||
string width;
|
||||
for (; pos != format.cend(); ++pos) {
|
||||
if (!inPct && pos[0] == '%') {
|
||||
inPct = true;
|
||||
width = "";
|
||||
} else if (!inPct) { // Normal text
|
||||
result += *pos;
|
||||
} else { // Format character
|
||||
if (std::isdigit(pos[0])) {
|
||||
width += pos[0];
|
||||
continue;
|
||||
}
|
||||
|
||||
inPct = false;
|
||||
|
||||
if (V3Number::displayedFmtLegal(tolower(pos[0]), false)) {
|
||||
@@ -1101,7 +1108,7 @@ private:
|
||||
nodep, "Argument for $display like statement is not constant");
|
||||
break;
|
||||
}
|
||||
const string pformat = std::string{"%"} + pos[0];
|
||||
const string pformat = std::string{"%"} + width + pos[0];
|
||||
result += constp->num().displayed(nodep, pformat);
|
||||
} else {
|
||||
switch (tolower(pos[0])) {
|
||||
|
||||
Reference in New Issue
Block a user