Skip to content

Commit

Permalink
Add body to randomize only if expression exists after being processed
Browse files Browse the repository at this point in the history
Signed-off-by: Ryszard Rozak <[email protected]>
  • Loading branch information
RRozak committed Dec 4, 2024
1 parent 16e73af commit f39e625
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/V3Randomize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,10 +884,12 @@ 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());
if (AstConstraint* const constrp = VN_CAST(nodep, Constraint)) {
if (constrp->itemsp()) {
m_taskp->addStmtsp(constrp->itemsp()->unlinkFrBackWithNext());
}
} else if (AstWith* const withp = VN_CAST(nodep, With)) {
if (withp->exprp()) m_taskp->addStmtsp(withp->exprp()->unlinkFrBackWithNext());
}
}
};
Expand Down

0 comments on commit f39e625

Please sign in to comment.