Why SystemVerilog Randomization Fails (and How to Debug It)
randomize() returned 0? Six causes of SystemVerilog randomization failure, how to read the VCS solver log, a 5-minute triage, and a demo with real logs.
randomize() returned 0? Six causes of SystemVerilog randomization failure, how to read the VCS solver log, a 5-minute triage, and a demo with real logs.
A divider and a PLL both make new clocks from one reference, but you cannot check them the same way. A UVM bench with three planted bugs shows why.
How RISC-V teams prove a core is right: compare every retired instruction against an instruction set simulator. A working UVM bench, four planted bugs, and what an AI-written golden model caught that mine missed.
In short: A constraint override happens when a child class declares a constraint with the same name as one in its parent. The child version replaces the parent version, so the solver uses only the child rule. If instead the child uses a different name, both constraints stay active and must be satisfied together, and…
randomize() works on a class object; std::randomize() works on plain variables. One tested UVM file, real VCS output, and the traps: with, local::, overflow, failures.
Three ways to get randc-style no-repeat values from a rand variable, run on VCS: a history list, a pool with a rand index, and shuffle. Which is fastest.
In short: To fill an array with values that never repeat, mark the array rand and add one line: constraint c { unique {arr}; }. The solver then gives every element a different value. On an old simulator that doesn’t know unique, use a nested foreach with !=. And if you don’t need the solver…
Make an array of unique values without randomize(): fill and shuffle, formulas, pick until unused and a shuffled pool. A simple example plus an 8-check UVM bench, tested on VCS.
rand_mode freezes a variable, constraint_mode drops a rule. A simple example plus an 8-check UVM bench with the frozen-variable trap and real VCS solver messages, tested on VCS.
In short: To enable or disable one specific constraint, call constraint_mode() on the named block, not on the whole object: obj.block_name.constraint_mode(0) switches that one rule off, and obj.block_name.constraint_mode(1) switches it back on. Every other constraint keeps working. Called with no argument on a named block it returns the current state, 1 for enabled and 0…