Skip to content

rand_mode(0) left on from a debug helper

lifecycle-hook

rand_mode() switches randomization of a field off or on without touching its declaration. That’s handy for pinning a field while debugging, and easy to leave behind: the field is still declared rand, still compiles, and every other field keeps randomizing.

The constructor makes two rand_mode() calls: one turns randomization off for the whole object, the other turns it back on for one field. Which field is left pinned?

Fix the class below.

RequirementSeq_num varies across repeated randomize() calls, as channel already does.

Source on GitHub

rand_mode_leftover.sv