Call pre/post_randomize on randomize() with (#5412)

Signed-off-by: Krzysztof Bieganski <[email protected]>
This commit is contained in:
Krzysztof Bieganski
2024-08-28 19:42:49 +02:00
committed by GitHub
parent d896f1ff08
commit 675d9a641e
3 changed files with 20 additions and 4 deletions
+4
View File
@@ -1918,6 +1918,8 @@ class RandomizeVisitor final : public VNVisitor {
AstFunc* const randomizeFuncp = V3Randomize::newRandomizeFunc(
m_memberMap, classp, m_inlineUniqueNames.get(nodep), false);
addPrePostCall(classp, randomizeFuncp, "pre_randomize");
// Detach the expression and prepare variable copies
const CaptureVisitor captured{withp->exprp(), m_modp, classp};
@@ -1975,6 +1977,8 @@ class RandomizeVisitor final : public VNVisitor {
new AstVarRef{nodep->fileline(), VN_AS(randomizeFuncp->fvarp(), Var), VAccess::WRITE},
new AstAnd{nodep->fileline(), basicRandomizeFuncCallp, solverCallp}});
addPrePostCall(classp, randomizeFuncp, "post_randomize");
// Replace the node with a call to that function
nodep->name(randomizeFuncp->name());
nodep->addPinsp(captured.getArgs());