mirror of
https://github.com/verilator/verilator.git
synced 2026-10-07 18:42:58 +02:00
This commit is contained in:
+21
-1
@@ -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.");
|
||||
|
||||
Reference in New Issue
Block a user