Jump to content
Sign in to follow this  
gbbrown

randomize and $dist_normal?

Recommended Posts

Is there a way to make the randomization of variables via randomize() use one of the different RNGs listed in 20.15 of the IEEE Std 1800 (such as $dist_normal or others)?  Or does the use of one of the alternative RNGs require manually doing randomization via direct calls to those utility functions ($dist_normal, etc) in the post_ or pre_randomize() functions?

 

Greg

Share this post


Link to post
Share on other sites

Try putting the dist_normal in a function used by a constraint.

 

class A;
   int seed = $urandom;
   int tmp;
   rand int ii;
   rand int mean;
   constraint c{ii == normal(mean);}
   function int normal(int mean);
      return $dist_normal(seed, mean,10);
   endfunction
   constraint mn {mean inside {[200:400]};}
endclass : A
   A a = new;
   initial repeat(10) begin
      int tmp;
      a.randomize();
      tmp = a.seed;
      $display("%p %d",a, $dist_normal(tmp,a.mean, 10));
   end
endmodule : top

 

Dave Rich

Mentor Graphics

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×