Repeated value with $dist_exponential


      bit[7:0] [3:0] dist_value;
         foreach (dist_value[j]) begin
             mem_data = $dist_exponential(0,60);
            dist_value[j] = mem_data;
            preload_cov.sample(mem_data);
         end

I seem to be getting the same value from $dist_exponential() when i am trying to substitute it for $urandom(). Is there something strange about the way you drive this function or do i need a set amount of calls to form the sequence? When tracking the distribution with a cover group i end up with over 2.6m hits on the same bin.

In reply to Phill_Ferg:
All of the functions in section 20.15 of the 1800-2012 LRM are manually seeded to be backward compatible with Verilog. The first argument to each routine is supposed to be a variable whose initial value is used as an initial seed, and is updated with the a new seed after returning from the function. If you supply the same seed value each time you call the function, you will generate the same random number returned.

To get the localized and thread-stable seeding behavior of SystemVerilog, I suggest you use $urandom to generate a seed for $dist_exponential()

begin 
  bit[7:0] [3:0] dist_value;
  int seed;
  seed = $urandom;
         foreach (dist_value[j]) begin
             mem_data = $dist_exponential(seed,60);
            dist_value[j] = mem_data;
            preload_cov.sample(mem_data);
         end
end

In reply to dave_59:

Thanks Dave, i hadn’t read the LRM throughly here, i just assumed that since $urandom is grouped beside $dist_exponential that they would act in similar manner. The seeding would be implicit for both.

Thanks!