Overview
Weighted distribution is used in constrained-random verification to control how often different stimulus choices are generated. In the cited microcode-stimulus generator, tests provide a set of weighted values that direct the generator toward the required mix of instructions, and the constraint solver applies those weights to control the distribution of generated opcode types.
Role in constrained-random generation
SystemVerilog constraint-language constructs can describe legal combinations of microcode-instruction attributes while also giving precise control over the distribution of values for individual fields. This lets a generator bias stimulus rather than relying on purely uniform or sequential randomization.
In the described opcode-generator architecture, weighted distribution appears at two levels:
- Upper generator layer: a SystemVerilog random-sequence construct uses weighted knobs to control the distribution of high-level items.
- Lower opcode layer: the opcode class is randomized with additional constraints and weights supplied by the upper layer.
Together, these weights guide the generator toward the desired instruction mix and opcode-type distribution.
Purpose
Weighted distribution is used to shape generated stimulus across meaningful opcode and instruction-attribute values. In the AMD/Synopsys example, the approach supports distribution control and biasing intended to hit corner cases while using a hierarchical constrained-random method.
Relationship to opcode generators
An opcode generator can use weighted distribution to decide the relative frequency of opcode categories or instruction types. The cited architecture uses weighted knobs in the upper layer and passes constraints and weights into the randomized opcode class in the lower layer.