Fix associative array next/prev/first/last mis-propagating constants (#5435).

This commit is contained in:
Wilson Snyder 2024-09-07 15:25:35 -04:00
parent d01b917062
commit c83ee391bb
5 changed files with 35 additions and 1 deletions

View File

@ -33,6 +33,7 @@ Verilator 5.029 devel
* Fix sformatf internal error on initial automatics (#5423). [Todd Strader]
* Fix clearing trigger of events with no sensitivity trees (#5426). [Arkadiusz Kozdra, Antmicro Ltd.]
* Fix driving clocking block in reactive region (#5430). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix associative array next/prev/first/last mis-propagating constants (#5435). [Ethan Sifferman]
Verilator 5.028 2024-08-21

View File

@ -215,7 +215,7 @@ public:
return names[m_e];
}
const char* arrow() const {
static const char* const names[] = {"[RV] <-", "[LV] =>", "[LV] <=>", "--"};
static const char* const names[] = {"[RV] <-", "[LV] =>", "[LRV] <=>", "--"};
return names[m_e];
}
VAccess()

View File

@ -3432,6 +3432,7 @@ class WidthVisitor final : public VNVisitor {
|| nodep->name() == "prev") {
methodOkArguments(nodep, 1, 1);
AstNodeExpr* const index_exprp = methodCallAssocIndexExpr(nodep, adtypep);
methodCallLValueRecurse(nodep, index_exprp, VAccess::READWRITE);
newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(),
nodep->name(), // first/last/next/prev
index_exprp->unlinkFrBack()};

View File

@ -121,6 +121,29 @@ module t (/*AUTOARG*/
`checkh(sum, 1 + 2);
end
begin // Issue #5435
int a;
int ok;
int dict [int];
dict[3] = 'h13;
dict[4] = 'h14;
dict[5] = 'h15;
a = 4;
ok = dict.first(a);
if (a != 3) $stop;
if (ok != 1) $stop;
a = 4;
ok = dict.next(a);
if (a != 5) $stop;
if (ok != 1) $stop;
a = 4;
ok = dict.last(a);
if (a != 5) $stop;
if (ok != 1) $stop;
end
$write("*-* All Finished *-*\n");
$finish;
end

View File

@ -18,6 +18,11 @@
: ... note: In instance 't'
18 | v = a.first();
| ^~~~~
%Error-UNSUPPORTED: t/t_assoc_method_bad.v:18:13: Unsupported: Non-variable on LHS of built-in method 'first'
: ... note: In instance 't'
18 | v = a.first();
| ^~~~~
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error: t/t_assoc_method_bad.v:19:13: The 2 arguments passed to .next method does not match its requiring 1 arguments
: ... note: In instance 't'
19 | v = a.next(k, "bad2");
@ -26,6 +31,10 @@
: ... note: In instance 't'
20 | v = a.last();
| ^~~~
%Error-UNSUPPORTED: t/t_assoc_method_bad.v:20:13: Unsupported: Non-variable on LHS of built-in method 'last'
: ... note: In instance 't'
20 | v = a.last();
| ^~~~
%Error: t/t_assoc_method_bad.v:21:13: The 2 arguments passed to .prev method does not match its requiring 1 arguments
: ... note: In instance 't'
21 | v = a.prev(k, "bad2");