Call `pre`/`post_randomize` on `randomize() with` (#5412)
Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
This commit is contained in:
parent
d896f1ff08
commit
675d9a641e
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -10,11 +10,15 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
|
|||
|
||||
scenarios(simulator => 1);
|
||||
|
||||
compile(
|
||||
);
|
||||
if (!$Self->have_solver) {
|
||||
skip("No constraint solver installed");
|
||||
} else {
|
||||
compile(
|
||||
);
|
||||
|
||||
execute(
|
||||
);
|
||||
execute(
|
||||
);
|
||||
}
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,14 @@ module t (/*AUTOARG*/);
|
|||
if (c.pre != 10) $stop;
|
||||
if (c.r != RANDOMIZED) $stop;
|
||||
if (c.post != 30) $stop;
|
||||
|
||||
c = new;
|
||||
rand_result = c.randomize() with { r == RANDOMIZED; };
|
||||
if (rand_result != 1) $stop;
|
||||
if (c.pre != 10) $stop;
|
||||
if (c.r != RANDOMIZED) $stop;
|
||||
if (c.post != 30) $stop;
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue