Cover dist dedup arms and drop unreachable chain guard
This commit is contained in:
parent
c99e17065a
commit
0e09102fb6
|
|
@ -4566,7 +4566,6 @@ class RandomizeVisitor final : public VNVisitor {
|
|||
// frozen variable requires only membership, not a freshly drawn bucket.
|
||||
AstNode* gateFrozenDist(AstNode* chainp, AstDist* distp,
|
||||
const std::vector<DistBucket>& buckets, AstVar* randModeVarp) {
|
||||
if (!chainp) return chainp;
|
||||
FileLine* const fl = distp->fileline();
|
||||
AstNodeExpr* gatep = nullptr;
|
||||
std::unordered_set<const AstVar*> gatedVars;
|
||||
|
|
|
|||
|
|
@ -82,6 +82,19 @@ class MultiVar;
|
|||
constraint c {(x + y) dist {10 := 9, 1000 := 1};}
|
||||
endclass
|
||||
|
||||
class DupVar;
|
||||
rand uint x;
|
||||
constraint c {(x + x) dist {10 := 9, 20 := 1};}
|
||||
endclass
|
||||
|
||||
class DupMember;
|
||||
rand Sub s;
|
||||
constraint c {(s.x + s.x) dist {10 := 9, 20 := 1};}
|
||||
function new();
|
||||
s = new;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
class RtWeight;
|
||||
rand uint x;
|
||||
uint w;
|
||||
|
|
@ -259,6 +272,48 @@ module t;
|
|||
`checkd(m.y, 500);
|
||||
end
|
||||
|
||||
// Same var twice in the dist expression, frozen: membership of 2*x decides.
|
||||
begin
|
||||
DupVar d;
|
||||
d = new;
|
||||
ok = d.randomize();
|
||||
`checkd(ok, 1);
|
||||
d.x.rand_mode(0);
|
||||
d.x = 5;
|
||||
for (int i = 0; i < 8; ++i) begin
|
||||
ok = d.randomize();
|
||||
`checkd(ok, 1);
|
||||
`checkd(d.x, 5);
|
||||
end
|
||||
d.x = 7;
|
||||
for (int i = 0; i < 8; ++i) begin
|
||||
ok = d.randomize();
|
||||
`checkd(ok, 0);
|
||||
`checkd(d.x, 7);
|
||||
end
|
||||
end
|
||||
|
||||
// Same sub-object member twice in the dist expression, frozen.
|
||||
begin
|
||||
DupMember dm;
|
||||
dm = new;
|
||||
ok = dm.randomize();
|
||||
`checkd(ok, 1);
|
||||
dm.s.x.rand_mode(0);
|
||||
dm.s.x = 5;
|
||||
for (int i = 0; i < 8; ++i) begin
|
||||
ok = dm.randomize();
|
||||
`checkd(ok, 1);
|
||||
`checkd(dm.s.x, 5);
|
||||
end
|
||||
dm.s.x = 7;
|
||||
for (int i = 0; i < 8; ++i) begin
|
||||
ok = dm.randomize();
|
||||
`checkd(ok, 0);
|
||||
`checkd(dm.s.x, 7);
|
||||
end
|
||||
end
|
||||
|
||||
// Runtime weight of zero excludes the bucket's values (18.5.3): frozen
|
||||
// there must fail; nonzero weight on the same frozen value succeeds.
|
||||
r = new;
|
||||
|
|
|
|||
Loading…
Reference in New Issue