Jump to content

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

Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...