Internals: Disambiguate variable references under with clauses of randomize() methods (#5277)

This commit is contained in:
Krzysztof Boroński
2024-08-02 11:45:17 -04:00
committed by GitHub
parent 54f9f4b6a9
commit 45ee949cc4
10 changed files with 516 additions and 102 deletions
+7
View File
@@ -36,12 +36,14 @@ class LinkLValueVisitor final : public VNVisitor {
bool m_setContinuously = false; // Set that var has some continuous assignment
bool m_setStrengthSpecified = false; // Set that var has assignment with strength specified.
bool m_setForcedByCode = false; // Set that var is the target of an AstAssignForce/AstRelease
bool m_setIfRand = false; // Update VarRefs if var declared as rand
VAccess m_setRefLvalue; // Set VarRefs to lvalues for pin assignments
// VISITs
// Result handing
void visit(AstNodeVarRef* nodep) override {
// VarRef: LValue its reference
if (m_setIfRand && !(nodep->varp() && nodep->varp()->isRand())) return;
if (m_setRefLvalue != VAccess::NOCHANGE) nodep->access(m_setRefLvalue);
if (nodep->varp() && nodep->access().isWriteOrRW()) {
if (m_setContinuously) {
@@ -321,6 +323,11 @@ class LinkLValueVisitor final : public VNVisitor {
}
}
}
void visit(AstConstraint* nodep) override {
VL_RESTORER(m_setIfRand);
m_setIfRand = true;
iterateChildren(nodep);
}
void visit(AstNode* nodep) override { iterateChildren(nodep); }