How do we define Weighted Distribution Constraint in SystemVerilog

 In SystemVerilog how do we define constraint to have values a higher probability than others?

For this we use an Weighted Distribution concept using "dist"  syntax

For e.g

   class Transcation;

                 rand bit [1:0]     src_addr, dst_addr;

                 constraint  c_distribution  {

                             src_addr   dist   { 5 := 2, [7:9] := 3};

                             dst_addr  dist    { 5: /2 ,  [7:9] : /3};

                   }

    endclass


The above two expression  '5:=2'  and '5:/2' are equivalent

[7:9] := 3 says to make the weight for each value in the range equal to 3

[7:9] :/3  says to divide the weight across each value in the range



Comments

Popular posts from this blog

How Disable Constraints in SystemVerilog

What is Class based Randomization and how do we define ?

How to define a Cyclic Randomization in SystemVerilog