Friday 26 January 2018

Weighted Distributions in SystemVerilog

In constrain random verification, it may take a long time for a particular corner case to be generated. Sometime even after running test-case for N number of time corner case may not be generated and you may see holes in functional coverage. To resolve this you can use a weighted distribution to drive stimulus in particular direction.

The dist keyword in systemverilog allows you to create weighted distributions so that some values are chosen more often than others. There are 2 different kind of distribution operators available in systemverilog.
The := operator assigns the specified weight to the item or, if the item is a range, to every value in the range. 
The :/ operator assigns the specified weight to the item or, if the item is a range, to the range as a whole. If there are n values in the range, the weight of each value is range_weight / n.

Limitation:
dist expressions cannot appear in other expressions.
dist operation shall not be applied to randc variables.

Let's go through below example to understand how it works,
----------------------------------------------------------------------------
----------------------------------------------------------------------------

Reference:
1) SystemVerilog LRM 2012
2) SystemVerilog for Verification 3rd edition by Chris Spear

No comments:

Post a Comment