From 2770ddf071e5a9e8611462947fed7b02d6cbcf7a Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 15 Dec 2022 07:38:53 -0500 Subject: [PATCH] Optimize expansion of extend operators. --- src/V3Expand.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index 5efbb7592..86091a572 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -341,6 +341,18 @@ private: VL_DO_DANGLING(replaceWithDelete(nodep, newp), nodep); } } + bool expandWide(AstNodeAssign* nodep, AstExtend* rhsp) { + UINFO(8, " Wordize ASSIGN(EXTEND) " << nodep << endl); + if (!doExpand(nodep)) return false; + AstNodeExpr* const lhsp = nodep->lhsp(); + for (int w = 0; w < lhsp->widthWords(); ++w) { + addWordAssign(nodep, w, newAstWordSelClone(lhsp, w)); + } + for (int w = rhsp->widthWords(); w < nodep->widthWords(); ++w) { + addWordAssign(nodep, w, new AstConst{nodep->fileline(), AstConst::SizedEData{}, 0}); + } + return true; + } void visit(AstSel* nodep) override { if (nodep->user1SetOnce()) return; // Process once @@ -854,6 +866,8 @@ private: did = expandWide(nodep, rhsp); } else if (AstConcat* const rhsp = VN_CAST(nodep->rhsp(), Concat)) { did = expandWide(nodep, rhsp); + } else if (AstExtend* const rhsp = VN_CAST(nodep->rhsp(), Extend)) { + did = expandWide(nodep, rhsp); } else if (AstReplicate* const rhsp = VN_CAST(nodep->rhsp(), Replicate)) { did = expandWide(nodep, rhsp); } else if (AstAnd* const rhsp = VN_CAST(nodep->rhsp(), And)) {