From 655910d4866d805dd45862a228d5f9d2b90c3ede Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 1 Jan 2022 17:10:14 -0500 Subject: [PATCH] Fix associative array first method as statement (#3228). --- Changes | 1 + src/V3Width.cpp | 1 + test_regress/t/t_assoc.v | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/Changes b/Changes index 427a10d85..e699ac150 100644 --- a/Changes +++ b/Changes @@ -29,6 +29,7 @@ Verilator 4.217 devel * Fix break under foreach loop (#3230). * Fix VL_STREAML_FAST_QQI with 64 bit left-hand-side (#3232) (#3235) * Fix $sformat of inputs/outputs (#3236). [Adrien Le Masle] +* Fix associative array first method as statement (#3228). [Adrien Le Masle] * Fix associative array foreach loop (#3229). * Fix $fclose not accepting expressions (#3237). [Julie Schwartz] * Fix $random not updating seed (#3238). [Julie Schwartz] diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 01fc120e1..451786cbb 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -2680,6 +2680,7 @@ private: nodep->name(), // first/last/next/prev index_exprp->unlinkFrBack()); newp->dtypeSetSigned32(); + if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "exists") { // function int exists(input index) // IEEE really should have made this a "bit" return methodOkArguments(nodep, 1, 1); diff --git a/test_regress/t/t_assoc.v b/test_regress/t/t_assoc.v index 1425573c5..9e20a7626 100644 --- a/test_regress/t/t_assoc.v +++ b/test_regress/t/t_assoc.v @@ -44,6 +44,12 @@ module t (/*AUTOARG*/ i = a.prev(k); `checkh(i, 0); v = $sformatf("%p", a); `checks(v, "'{'h2:\"bared\", 'h3:\"fooed\"} "); + a.first(k); `checks(k, 4'd2); + a.next(k); `checks(k, 4'd3); + a.next(k); + a.last(k); `checks(k, 4'd3); + a.prev(k); `checks(k, 4'd2); + a.delete(4'd2); i = a.size(); `checkh(i, 1);