• 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 15982
  • 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

    I just tried this and don't see it varying (I didn't run in ADE, but running multiple simulations gave consistent results, both with a VerilogAMS model run with AMS Designer (xrun), or with Spectre if it was Verilog-A). I don't see why running from ADE would (or could) change that.

    Which simulator and version are you using?

    Andrew

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

    Is this the info that you are asking about?

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

    No, it's the simulator version I want. The iC version won't affect the simulation results. What version does it show at the top of the simulator log when you run the simulator? I'm assuming it's an XCELIUM version if you're running that recent an IC version, but which version?

    Regards,

    Andrew

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

    One more screenshot...

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

    xrun(64): 19.02-a001: (c) Copyright 1995-2019 Cadence Design Systems, Inc.
    TOOL: xrun(64) 19.02-a001: Started on Apr 11, 2022 at 15:18:30 PDT

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

    Also, there are multiple instantiations of this resistor in the testbench, and all of the resistors have the same value at each time point.  Here is the Rval for six of the resistors that I instantiated.

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

    Here is another version statement from the log file, if it helps:

    Spectre (R) Circuit Simulator
    Version 17.1.0.515.isr12 64bit -- 14 Jan 2019

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

    OK, I misread what you were doing - I thought you were complaining that it was varying over multiple simulations with single run sweeps and corners, whereas the issue is that your resistor is time varying. That's because your Rval is computed at each iteration.

    You want:

    @(initial_step) Rval = $rdist_normal( seed, Rmean, Rstdev, "instance" );

    within the analog block (within the analog begin/end).

    Andrew

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

    Excellent, that solved the change vs. timepoint issue, but the value is not changing vs. Monte Carlo run.  

    For the first MC run shown above, I had a "fixed" seed as a parameter on the module.  On the second MC run I pulled the seed assignment into the initial block as well (similar to the example in the $rdist_normal section of the manual) but this didn't help.

    `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;
    integer seed;
    real Rval;

    analog
    begin

    @(initial_step)
    begin
      seed = 23;
      Rval = $rdist_normal( seed, Rmean, Rstdev, "instance" );
    end

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

    end

    endmodule

    The manual seems to suggest that I just need to have the "instance" parameter set for the $rdist_normal function.

    "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."

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

    The Rval is not changing per instance or per MC iteration.  Here are six instances and 10 MC iterations:

    • 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