Skip to content

Commit

Permalink
Get constraints from class
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 e120993 commit bd2f27c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/V3Randomize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,17 @@ class RandomizeVisitor final : public VNVisitor {
AstVar* const randModeVarp = getRandModeVar(classp);
if (randModeVarp) addSetRandMode(randomizeFuncp, localGenp, randModeVarp);

// Get constraints from the class
classp->foreachMember([&](AstClass* const clp, AstConstraint* const constrp) {
AstTask* const setupTaskp = VN_AS(constrp->user2p(), Task);
UASSERT_OBJ(setupTaskp, constrp, "Constraint should have setup task generated before");
AstTaskRef* const setupRefp = new AstTaskRef{
fl, setupTaskp->name(),
new AstArg{fl, "constraint", new AstVarRef{fl, localGenp, VAccess::READWRITE}}};
setupRefp->taskp(setupTaskp);
randomizeFuncp->addStmtsp(
wrapIfConstraintMode(classp, constrp, new AstStmtExpr{fl, setupRefp}));
});
// Generate constraint setup code and a hardcoded call to the solver
AstNode* const capturedTreep = withp->exprp()->unlinkFrBackWithNext();
randomizeFuncp->addStmtsp(capturedTreep);
Expand Down

0 comments on commit bd2f27c

Please sign in to comment.