Fix interface localparam dependencies and arbitrary nesting (#6936) (#7128)

This commit is contained in:
em2machine
2026-03-03 06:55:59 -05:00
committed by GitHub
parent ed84f3adb2
commit 5821d0697c
152 changed files with 8247 additions and 562 deletions
+21 -1
View File
@@ -106,6 +106,9 @@ class ConstBitOpTreeVisitor final : public VNVisitorConst {
// CONSTRUCTORS
LeafInfo() = default;
LeafInfo(const LeafInfo& other) = default;
LeafInfo& operator=(const LeafInfo& other) = default;
LeafInfo(LeafInfo&& other) = default;
LeafInfo& operator=(LeafInfo&& other) = default;
explicit LeafInfo(int lsb)
: m_lsb{lsb} {}
@@ -2944,6 +2947,16 @@ class ConstVisitor final : public VNVisitor {
VL_DO_DANGLING(pushDeletep(nodep), nodep);
}
}
// Handle ARRAYSEL directly on InitArray (not through VarRef)
else if (VN_IS(nodep->bitp(), Const) && VN_IS(nodep->fromp(), InitArray)) {
const AstInitArray* const initarp = VN_AS(nodep->fromp(), InitArray);
const uint32_t bit = VN_AS(nodep->bitp(), Const)->toUInt();
const AstNode* const itemp = initarp->getIndexDefaultedValuep(bit);
if (VN_IS(itemp, Const)) {
const V3Number& num = VN_AS(itemp, Const)->num();
VL_DO_DANGLING(replaceNum(nodep, num), nodep);
}
}
m_selp = nullptr;
}
@@ -4172,7 +4185,14 @@ class ConstVisitor final : public VNVisitor {
if (m_required) {
if (VN_IS(nodep, NodeDType) || VN_IS(nodep, Range) || VN_IS(nodep, SliceSel)
|| VN_IS(nodep, Dot)) {
// Ignore dtypes for parameter type pins
// ignore
} else if (AstCellRef* const crp = VN_CAST(nodep, CellRef)) {
iterate(crp->exprp());
if (AstNode* const newp = crp->exprp()) {
crp->replaceWithKeepDType(newp->unlinkFrBack());
VL_DO_DANGLING(pushDeletep(crp), crp);
}
return;
} else {
nodep->v3error("Expecting expression to be constant, but can't convert a "
<< nodep->prettyTypeName() << " to constant.");