Immediate vs Concurrent Assertions in SystemVerilog, Tested on One Small Design
Immediate assertions check a value right now. Concurrent assertions check a pattern over clock edges. One tested file, five runs, and what VCS prints for each.
Immediate assertions check a value right now. Concurrent assertions check a pattern over clock edges. One tested file, five runs, and what VCS prints for each.
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…
In short: When you need an array of distinct values in a mixed order but do not need full randomness, you can skip constraints. Fill the array with known distinct values, such as the index itself, then call the built in shuffle() method to rearrange them. The result has no repeats and a random order,…
In short: rand_mode() turns one random variable on or off. When it’s off, randomize() leaves that variable’s value alone. constraint_mode() turns one constraint block on or off. When it’s off, the solver ignores that rule. They are independent: freezing a variable does not switch off the constraints that use it, which is why randomize() often…
In short: An assertion is a small rule that describes how a design should behave. If the design breaks the rule during simulation, the assertion fails and points you straight to the problem. The big advantages are early bug detection, better visibility into what went wrong, reuse in both simulation and formal tools, and a…
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…
randcase picks one weighted branch; randsequence builds a random sequence from productions. A simple example plus an 8-check UVM bench, tested on VCS.
How wait works in SystemVerilog: @event vs wait(event.triggered), ->>, wait(expression), wait fork and uvm_event, each run in one UVM bench on VCS.
A SystemVerilog mailbox passes messages between processes: put() adds, get() removes the oldest, and both can block. A UVM bench with 8 checks and the reused-handle bug, tested on VCS.
In short: dist makes some random values come up more often than others. := gives the weight to every value in a range, so a wider range gets more in total. :/ gives the weight to the range as a whole and splits it evenly. Weights are shares, not percentages. Other constraints always win over…