• 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. Mixed-Signal Design
  3. verilogams $rdist_normal for random resistor value in a...

Stats

  • Locked Locked
  • Replies 14
  • Subscribers 64
  • Views 16027
  • 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

verilogams $rdist_normal for random resistor value in a transient simulation

AndyD93
AndyD93 over 3 years ago

I'm trying to generate a Gaussian random resistor value for each transient simulation with the following verilogams code:

`include "constants.vams"
`include "disciplines.vams"

module Rrandom (va, vb);

inout va, vb;
electrical va, vb;
parameter real Rmean = 200.0*63.0;
parameter real Rstdev = 100;
parameter integer seed = 23;

real Rval;

analog
begin
  Rval = $rdist_normal( seed, Rmean, Rstdev, "instance" );
  I(va, vb) <+ V(va,vb)/Rval;
end

endmodule

When I run in "Single Run, Sweeps and Corners" mode the Rval is changing on every timepoint.  Here is a plot of the Rval for one of the resistors in the netlist:

But I'd like to have a single value for the resistor throughout the simulation (not changing per timepoint).  I tried moving the $rdist_normal outside the analog block as a "parameter real" similar to the example shown in the "Cadence Verilog-A Language Reference 21.1" in the $arandom section (but using $rdist_normal) but that gives me a syntax error.

`include "constants.vams"
`include "disciplines.vams"

module Rrandom (va, vb);

inout va, vb;
electrical va, vb;
parameter real Rmean = 200.0*63.0;
parameter real Rstdev = 100;
parameter integer seed = 23;

parameter real Rval = $rdist_normal( seed, Rmean, Rstdev, "instance" );

analog
begin
  I(va, vb) <+ V(va,vb)/Rval;
end

endmodule

How can I get resistor with a Gaussian distribution that does not change every simulation timepoint in the transient run?

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to AndyD93

    See How to generate unique random numbers for multiple instances based on Monte Carlo iteration number ($cds_get_mc_trial_number)

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • AndyD93
    AndyD93 over 3 years ago in reply to Andrew Beckett

    Thanks for the reference to the article, now I'm one step closer,  When I use $cds_get_mc_trial_number the random variable is changing vs. MC run.  That works nicely, but to get a different random number each instance...

    I understand what they are doing in the example given.  But according to the manual, the $arandom or $rdist_normal "string" argument should be able to take care of this: 

    "string is an optional argument and provides support for Monte Carlo analysis. If string is
    set to global, then one value is generated for each Monte Carlo trial. If string is set to
    instance, then one value is generated for each instance that references this value, and a
    new set of values for these instances is generated for each Monte Carlo trial."

    [Verilog-A Language Reference 21.1]

    Am I missing something here?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to AndyD93
    AndyD93 said:
    Sorry to say it, but honestly the tb.count that is used in the example for each instance seems like a kludge to me

    I completely agree. That was precisely what I thought when I saw it. Some of these are workarounds due to gaps in the standards coverage (note that coverage of VerilogA might be slightly different from VerilogAMS; no simulator covers absolutely everything in the LRM because there are quite a lot of esoteric things in the standard which nobody is pushing for; not to say that this feature is esoteric!).

    For example, in the VerilogAMS LRM it shows using localparam to do this, but since we don't support an initialiser on a localparam, that doesn't work.

    Please contact customer support - then an Application Engineer can explore this properly, and ensure that change requests are filed to support the standard way of doing this rather than a workaround (there may be a better workaround, but unfortunately I don't have the bandwidth this week or next to explore this further myself; too many balls in the air at the moment with the day job!).

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • AndyD93
    AndyD93 over 3 years ago in reply to Andrew Beckett

    Andrew, thank you so much for your help here, it is highly appreciated.  I removed my "kludge" remarks from my post, just to be more polite.  :)  I will submit a ticket about this, because I am still interested in knowing how to use the "string" argument as it is presented in the documentation that I showed.  It is there for a reason, and it seems like it should work.  Like I said earlier, maybe I'm missing something or not understanding the details on how to use it properly.

    Thanks again for all your help!

    • 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