How to change the probability distribution of random variables of SystemVerilog?

This is for SystemVerilog. I know that you can specify weights for values ​​or ranges of values ​​in a set of values ​​from which a random variable is selected, but what if you want to get a good Gaussian distribution? How do you write such a restriction?

+3
source share
2 answers

When randomize is called, this class will generate values ​​for the variable "value" with a normal (Gaussian) distribution, the mean and standard deviation of which are 100 and 20, respectively. I have not tested this, but it should work.

class C;

  int seed = 1;
  rand int mean;
  rand int std_deviation;
  rand int value;

  function int gaussian_dist();
    return $dist_normal( seed, mean, std_deviation );
  endfunction

  constraint c_parameters {
    mean == 100;
    std_deviation == 20;
  }

  constraint c_value { value == gaussian_dist(); }

endclass
+5
source

, , , , , .

, Steve K, VCS G-2012.09 ( ) - :

  • mean std_deviation, gaussian_dist(), rand. , pre_randomize(), .
  • gaussian_dist() , . $dist_normal seed, seed .

:

class C;

  int seed = 1;
  int mean = 100;
  int std_deviation = 20;
  rand int value;

  function int gaussian_dist (int seed);
    return $dist_normal (seed, mean, std_deviation);
  endfunction

  constraint c_value { value == gaussian_dist (seed); }

endclass

, "", $dist_normal, , - seed ( seed $dist_normal ).

pre_randomize() post_randomize() , constraint.

+2

Source: https://habr.com/ru/post/1746071/


All Articles