• 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 A: Generate different $random values for each Monte...

Stats

  • Replies 6
  • Subscribers 125
  • Views 962
  • Members are here 0

Verilog A: Generate different $random values for each Monte Carlo iteration

MC20250412421
MC20250412421 25 days ago

Hi everyone !

I have a Verilog A block that uses the $random function as is (without any seed defined inside the Verilog A code). I have noticed while running Monte Carlo (default settings) that the Verilog A would always generate the exact same $random values for each MC iteration. 
I assume it is because the Monte Carlo seed which is 12345 is being fed into the Verilog A $random function ?
If that's the case, what is the best way to generate $random values that are different for each MC iteration ?

Thanks in advance for your answers !

  • Sign in to reply
  • Cancel
  • JankoK
    JankoK 24 days ago

    Hi,

    Interesting question... 

    I guess you could do something similar to this:

    How to do Monte Carlo mismatch variation on a VerilogA model

    That model deck is just a separate .scs (model file) where you add your statements (don't forget to include it in you Model Libraries). You can also define process{} too, for process variations, under that statistical statement.

    Let me know if it worked.

    Disclaimer: I have not tried this myself. 

    BR

    /Janko

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 24 days ago in reply to JankoK

    Janko's proposal is probably the best solution, but another way could be to use How to pass the monte carlo trial (iteration) number to VerilogA module? - this could then be used to set the seed per iteration.  That approach is better if your model is producing a sequence of random numbers rather than modelling a local/global variation effect.

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • MC20250412421
    MC20250412421 24 days ago in reply to JankoK

    Thanks a bunch for that answer !

    While Andrew's answer was a simpler solution for my problem (just having a different seed for each MC run), you showed me something I had no idea how to do before and that I'll be using from now on.

    So again, thanks a lot for that and have a great day !

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • MC20250412421
    MC20250412421 24 days ago in reply to Andrew Beckett

    Thanks a lot !

    Your solution was the simplest for my $random problem (just having a different seed each MC run) so I went with it. Though the values aren't as random as I would like since the seeds are known and using this technique on single runs will always return the same $random values. I was wondering if there was a more volatile environment variable that could be read from verilog A, perhaps something like unix time ?

    No worries if such a thing doesn't exist, I'm just curious if you know something.

    Have a great day !

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 23 days ago in reply to MC20250412421

    Normally people want repeatability in simulations over being different on every run, but you could use $simparam("systime") to get a time-based value (and maybe combine this with the iteration number) as covered in How can you access the current date from a system call in VerilogA?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • MC20250412421
    MC20250412421 22 days ago in reply to Andrew Beckett

    Really cool ! 

    This was what I was looking for.

    Thanks a lot : )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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