diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index 939d1ab783..ea242ca841 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -886,6 +886,11 @@ class ConstraintExprVisitor final : public VNVisitor { m_taskp = new AstTask{nodep->fileline(), name + "_setup_constraint", m_genp}; nodep->user2p(m_taskp); iterateChildren(nodep); + if (AstConstraint* constrp = VN_CAST(nodep, Constraint)) { + m_taskp->addStmtsp(constrp->itemsp()->unlinkFrBackWithNext()); + } else if (AstWith* withp = VN_CAST(nodep, With)) { + m_taskp->addStmtsp(withp->exprp()->unlinkFrBackWithNext()); + } } };