Wrap stream into CvtPackedToArray if it is on rhs of assign to unpacked

Signed-off-by: Ryszard Rozak <rrozak@antmicro.com>
This commit is contained in:
Ryszard Rozak 2025-04-03 09:59:32 +02:00
parent 2eb9076381
commit 49f19d24f6
1 changed files with 12 additions and 0 deletions

View File

@ -1586,6 +1586,12 @@ class WidthVisitor final : public VNVisitor {
userIterateAndNext(nodep->lhsp(), WidthVP{SELF, BOTH}.p());
// Type set in constructor
}
void visit(AstCvtPackedToArray* nodep) override {
if (nodep->didWidthAndSet()) return;
// Opaque returns, so arbitrary
userIterateAndNext(nodep->fromp(), WidthVP{SELF, BOTH}.p());
// Type set in constructor
}
void visit(AstTimeImport* nodep) override {
// LHS is a real number in seconds
// Need to round to time units and precision
@ -5180,6 +5186,12 @@ class WidthVisitor final : public VNVisitor {
// if (debug()) nodep->dumpTree("- assign: ");
AstNodeDType* const lhsDTypep
= nodep->lhsp()->dtypep(); // Note we use rhsp for context determined
if (VN_IS(nodep->lhsp()->dtypep(), NodeArrayDType)
&& VN_IS(nodep->rhsp(), NodeStream)) {
AstNodeExpr* const rhsp = nodep->rhsp()->unlinkFrBack();
nodep->rhsp(new AstCvtPackedToArray{rhsp->fileline(), rhsp, lhsDTypep});
}
iterateCheckAssign(nodep, "Assign RHS", nodep->rhsp(), FINAL, lhsDTypep);
// if (debug()) nodep->dumpTree("- AssignOut: ");
}