Skip to content

Commit

Permalink
Fix case with with clause
Browse files Browse the repository at this point in the history
Signed-off-by: Ryszard Rozak <[email protected]>
  • Loading branch information
RRozak committed Nov 22, 2024
1 parent c03a322 commit 1523e55
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/V3Randomize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,11 @@ class RandomizeMarkVisitor final : public VNVisitor {
void visit(AstMemberSel* nodep) override {
if (!m_constraintExprGenp) return;
iterateChildrenConst(nodep);
nodep->user1(nodep->fromp()->user1() && nodep->varp()->rand().isRandomizable());
// Member select are randomized when both object and member are marked as rand.
// Variable references in with clause are converted to member selects and their from() is
// of type AstLambdaArgRef. They are randomized too.
bool randObject = nodep->fromp()->user1() || VN_IS(nodep->fromp(), LambdaArgRef);
nodep->user1(randObject && nodep->varp()->rand().isRandomizable());
}
void visit(AstNodeModule* nodep) override {
VL_RESTORER(m_modp);
Expand Down

0 comments on commit 1523e55

Please sign in to comment.