• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC Design
  3. Verilog-AMS variable with randomly selected value at each...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 125
  • Views 4593
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Verilog-AMS variable with randomly selected value at each Monte Carlo sample

DomiHammerfall
DomiHammerfall over 1 year ago

Dear community

I would like to create a Verilog-AMS module where a variable is initialized to a random value for each sample in a Monte Carlo analysis, i.e. something like that:

integer seed;
real random_value;
analog initial begin
    seed = $random;
    random_value = $rdist_normal(seed, 0, 1.0);
end

Problem: random_value never changes in a Monte Carlo simulation. Why? My understanding is that $random returns a new number with every call - at least that's what the documentation claims. A look into the log files confirms that the seed indeed never changes,

Additional note: I am aware that Spectre actually does not exit with every MC iteration. ADE assigns a certain number of point to a job. But even setting the maximum number of points per job to 1 in the monte Carlo form does not change the outcome.

Another note: It is technically not the best practice to achieve the randomness by just setting a random seed, and then drawing one sample from a probability distribution. Rather, the seed should stay the same during the whole MC analysis but every iteration draws another sample from the probability distribution function. Is there a way to achieve that?

Thanks in advance for any help.

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago

    The trouble is that $random will also use the same seed each time.

    You could try:

    seed=$cds_get_mc_trial_number();

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • DomiHammerfall
    DomiHammerfall over 1 year ago in reply to Andrew Beckett

    Dear Andrew

    Thank you very much for you support.

    I can confirm that this indeed works.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information