Skip to content

Commit

Permalink
Convert systemverilog constraints to crave constraints
Browse files Browse the repository at this point in the history
Signed-off-by: Ryszard Rozak <rrozak@antmicro.com>
  • Loading branch information
RRozak committed Nov 15, 2023
1 parent 2bca877 commit bcd960d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/V3Randomize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ class RandomizeVisitor final : public VNVisitor {
funcp->addStmtsp(callp->makeStmt());
}
}
AstTask* newSetupConstraintsTask(AstClass* nodep) {
auto* funcp = VN_AS(m_memberMap.findMember(nodep, "_setup_constraints"), Task);
if (!funcp) {
funcp = new AstTask{nodep->fileline(), "_setup_constraints", nullptr};
funcp->classMethod(true);
funcp->isVirtual(nodep->isExtended());
nodep->addMembersp(funcp);
}
return funcp;
}

// VISITORS
void visit(AstNodeModule* nodep) override {
Expand Down Expand Up @@ -357,6 +367,10 @@ class RandomizeVisitor final : public VNVisitor {
auto* genp = new AstVar(fl, VVarType::MEMBER, "constraint",
nodep->findBasicDType(VBasicDTypeKwd::RANDOM_GENERATOR));
nodep->addMembersp(genp);
auto* newp = VN_AS(m_memberMap.findMember(nodep, "new"), NodeFTask);
UASSERT_OBJ(newp, nodep, "No new() in class");
auto* taskp = newSetupConstraintsTask(nodep);
newp->addStmtsp(new AstTaskRef{fl, taskp->name(), nullptr});

nodep->user1(false);

Expand Down

0 comments on commit bcd960d

Please sign in to comment.