Fix misoptimizing away `$urandom` (#5703).
This commit is contained in:
parent
bb871728c9
commit
dfe28f7ed0
1
Changes
1
Changes
|
|
@ -23,6 +23,7 @@ Verilator 5.033 devel
|
||||||
* Fix pattern assignment to real inside struct (#5713).
|
* Fix pattern assignment to real inside struct (#5713).
|
||||||
* Fix %p format output for real inside struct (#5713).
|
* Fix %p format output for real inside struct (#5713).
|
||||||
* Fix segfault when only enum value referenced in package (#5714). [Dan Katz]
|
* Fix segfault when only enum value referenced in package (#5714). [Dan Katz]
|
||||||
|
* Fix misoptimizing away `$urandom` (#5703). [Parker Schless]
|
||||||
* Fix matching language extension options including dots.
|
* Fix matching language extension options including dots.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1820,7 +1820,6 @@ public:
|
||||||
return "VL_RANDOM_SEEDED_%nq%lq(%li)";
|
return "VL_RANDOM_SEEDED_%nq%lq(%li)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isWide()) {
|
if (isWide()) {
|
||||||
return "VL_RANDOM_%nq(%nw, %P)";
|
return "VL_RANDOM_%nq(%nw, %P)";
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1830,6 +1829,7 @@ public:
|
||||||
bool cleanOut() const override { return false; }
|
bool cleanOut() const override { return false; }
|
||||||
bool isGateOptimizable() const override { return false; }
|
bool isGateOptimizable() const override { return false; }
|
||||||
bool isPredictOptimizable() const override { return false; }
|
bool isPredictOptimizable() const override { return false; }
|
||||||
|
bool isPure() override { return !m_reset && !seedp(); }
|
||||||
int instrCount() const override { return INSTR_COUNT_PLI; }
|
int instrCount() const override { return INSTR_COUNT_PLI; }
|
||||||
bool sameNode(const AstNode* /*samep*/) const override { return true; }
|
bool sameNode(const AstNode* /*samep*/) const override { return true; }
|
||||||
bool combinable(const AstRand* samep) const {
|
bool combinable(const AstRand* samep) const {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ module t;
|
||||||
int valuea;
|
int valuea;
|
||||||
int valueb;
|
int valueb;
|
||||||
int valuec;
|
int valuec;
|
||||||
|
int igna;
|
||||||
|
int ignb;
|
||||||
|
int ignc;
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
// $random unlike $urandom updates the value if given
|
// $random unlike $urandom updates the value if given
|
||||||
|
|
@ -32,7 +35,29 @@ module t;
|
||||||
|
|
||||||
valuea = $urandom(10);
|
valuea = $urandom(10);
|
||||||
valueb = $urandom(10);
|
valueb = $urandom(10);
|
||||||
if (valuea !== valueb) $stop;
|
valuec = $urandom(10);
|
||||||
|
if (valuea !== valueb && valueb != valuec) $stop;
|
||||||
|
|
||||||
|
valuea = $urandom(10);
|
||||||
|
valueb = $urandom(11);
|
||||||
|
valuec = $urandom(12);
|
||||||
|
if (valuea == valueb && valueb == valuec) $stop; // May false fail 1 in 1^64
|
||||||
|
|
||||||
|
$urandom(10);
|
||||||
|
valuea = $urandom;
|
||||||
|
$urandom(10);
|
||||||
|
valueb = $urandom;
|
||||||
|
$urandom(10);
|
||||||
|
valuec = $urandom;
|
||||||
|
if (valuea != valueb && valueb != valuec) $stop; // May false fail 1 in 1^64
|
||||||
|
|
||||||
|
igna = $urandom(10);
|
||||||
|
valuea = $urandom;
|
||||||
|
ignb = $urandom(10);
|
||||||
|
valueb = $urandom;
|
||||||
|
ignc = $urandom(10);
|
||||||
|
valuec = $urandom;
|
||||||
|
if (valuea != valueb && valueb != valuec) $stop; // May false fail 1 in 1^64
|
||||||
|
|
||||||
valuea = $urandom(10);
|
valuea = $urandom(10);
|
||||||
valueb = $urandom();
|
valueb = $urandom();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue