mirror of
https://github.com/verilator/verilator.git
synced 2026-10-07 10:33:13 +02:00
Fix foreach on associative arr with the same logic and update the tests (#5530)
This commit is contained in:
+7
-3
@@ -427,7 +427,8 @@ AstNode* V3Begin::convertToWhile(AstForeach* nodep) {
|
||||
AstNode* bodyPointp = new AstBegin{nodep->fileline(), "[EditWrapper]", nullptr};
|
||||
AstNode* newp = nullptr;
|
||||
AstNode* lastp = nodep;
|
||||
// subfromp used to traverse each dimension of multi-d queue/dyn-arr's
|
||||
// subfromp used to traverse each dimension of multi-d variable-sized unpacked array (queue,
|
||||
// dyn-arr and associative-arr)
|
||||
AstNodeExpr* subfromp = fromp->cloneTreePure(false);
|
||||
// Major dimension first
|
||||
for (AstNode *argsp = loopsp->elementsp(), *next_argsp; argsp; argsp = next_argsp) {
|
||||
@@ -477,13 +478,16 @@ AstNode* V3Begin::convertToWhile(AstForeach* nodep) {
|
||||
first_varp->usedLoopIdx(true);
|
||||
first_varp->lifetime(VLifetime::AUTOMATIC);
|
||||
AstNodeExpr* const firstp
|
||||
= new AstCMethodHard{fl, fromp->cloneTreePure(false), "first",
|
||||
= new AstCMethodHard{fl, subfromp->cloneTreePure(false), "first",
|
||||
new AstVarRef{fl, varp, VAccess::READWRITE}};
|
||||
firstp->dtypeSetSigned32();
|
||||
AstNodeExpr* const nextp
|
||||
= new AstCMethodHard{fl, fromp->cloneTreePure(false), "next",
|
||||
= new AstCMethodHard{fl, subfromp->cloneTreePure(false), "next",
|
||||
new AstVarRef{fl, varp, VAccess::READWRITE}};
|
||||
nextp->dtypeSetSigned32();
|
||||
AstVarRef* varRefp = new AstVarRef{fl, varp, VAccess::READ};
|
||||
subfromp = new AstCMethodHard{fl, subfromp, "at", varRefp};
|
||||
subfromp->dtypep(fromDtp);
|
||||
AstNode* const first_clearp
|
||||
= new AstAssign{fl, new AstVarRef{fl, first_varp, VAccess::WRITE},
|
||||
new AstConst{fl, AstConst::BitFalse{}}};
|
||||
|
||||
Reference in New Issue
Block a user