Fix $sformat with array arguments (#5330).

This commit is contained in:
Wilson Snyder 2024-08-08 03:32:07 -04:00
parent 18fc3e6089
commit c2e44dbd99
3 changed files with 13 additions and 1 deletions

View File

@ -57,6 +57,7 @@ Verilator 5.027 devel
* Fix Python3 path discovery in make flows to avoid mixing system and user python interpreters (#5307) [Markus Krause]
* Fix make flows to pass PYTHON3 (like PERL) (#5307) (#5308). [Markus Krause]
* Fix stringify in nested preprocessor macros (#5323). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix $sformat with array arguments (#5330). [Abe Jordan]
* Fix ==? and !=? with X values.
* Fix CPU time being zero.
* Fix inline function ref port persistence.

View File

@ -1203,7 +1203,7 @@ class WidthVisitor final : public VNVisitor {
userIterateAndNext(nodep->attrp(), WidthVP{SELF, BOTH}.p());
AstNode* const selp = V3Width::widthSelNoIterEdit(nodep);
if (selp != nodep) {
nodep = nullptr;
VL_DANGLING(nodep);
userIterate(selp, m_vup);
return;
}
@ -5051,6 +5051,11 @@ class WidthVisitor final : public VNVisitor {
}
}
void visit(AstSFormat* nodep) override {
assertAtStatement(nodep);
userIterateAndNext(nodep->fmtp(), WidthVP{SELF, BOTH}.p());
userIterateAndNext(nodep->lhsp(), WidthVP{SELF, BOTH}.p());
}
void visit(AstSFormatF* nodep) override {
// Excludes NodeDisplay, see below
if (m_vup && !m_vup->prelim()) return; // Can be called as statement or function

View File

@ -17,6 +17,7 @@ module t;
reg [48*8:1] str2;
string str3;
reg [39:0] instruction_str [1:0];
real r;
@ -87,6 +88,11 @@ module t;
`ifdef TEST_VERBOSE $display("str3=%0s", str3); `endif
if (str3 != "foo") $stop;
$sformat(instruction_str[0], "%s", "Hello");
$sformat(instruction_str[1], "%s", "World");
if (instruction_str[0] != "Hello") $stop;
if (instruction_str[1] != "World") $stop;
$write("*-* All Finished *-*\n");
$finish;
end