• 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. A stochastic model in Verilog A for Monte Carlo simulat...

Stats

  • Locked Locked
  • Replies 29
  • Subscribers 125
  • Views 33218
  • 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

A stochastic model in Verilog A for Monte Carlo simulation

UUinfini
UUinfini over 11 years ago

 Hello Guys,

I have a problem for Veriglog A in Cadence, I hope you can help me. In fact I need to elaborate a stochastic model by coding in Verilog A executed under Cadence. My aim is to offer a model with which the customers can do the Monte Carlo Analysis. But I used the functions like "$random", "$temperature" etc. to generate a seed for obtaining a parameter which changes each time of simulation. But finally it changes just according to the real time of simulation, but not according to different times of simulation. Do you have any experiences like this? Thank you for you response.

Best regards,

UU

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    You need to use the cds_inherited_parameter attribute on a parameter which you are going to have a mismatch definition of in the statistics block. For example, this VerilogA module:

    `include "disciplines.vams"

    module res(vp, vn);

    inout vp, vn;

    electrical vp, vn;

    (* cds_inherited_parameter *) parameter real monteres = 0;

    parameter real r = 1k;

    localparam real r_effective = r + monteres; // nominal resistance plus

    // monte-carlo mismatch effect

    analog

    V(vp, vn) <+ (r_effective)*I(vp, vn);

    endmodule

    And I'm simulating this from this netlist:

    //
    parameters monteres=0

    statistics {
      mismatch {
        vary monteres dist=gauss std=5
      }
    }

    R1 (n1 0) res
    I1 (n1 0) isource dc=1m

    ahdl_include "monteres.va"

    monte montecarlo numruns=10 variations=mismatch {
       dc dc
       export vdc=oceanEval("v(\"n1\" ?result 'dc)")
    }

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • UUinfini
    UUinfini over 11 years ago

     Thank you very much, I will try it.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • UUinfini
    UUinfini over 11 years ago

     Hello Andrew,

    Thank you for your answer. How can we do the simulation with the second code? Is it written in a file".scs" ? And then how do we execute the simulation Monte Carlo? Thank you in advance for your answer.

    Best regards,

    UU

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    You can run it with "spectre monteres.scs" for example, and the results will be in monteres.raw - including an mcdata file showing the variation of the points.

    Or you could create a veriloga view in virtuoso for the model, place an instance of it in a testbench similar to what I've done here, and then create a model file (called stats.scs, say) containing just the parameters and statistics block, and then include that as a model file in ADE - and then setup the monte carlo as you would usually in ADE.

    I just created a simple text-only example to show the principle without needing a database.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • UUinfini
    UUinfini over 11 years ago

    Hello Andrew,

    Thank you for your guide. I have done as you said but it doesn't work, perhaps I have made some errors. I have created two files :

    1 source.va 

    // VerilogA for source
    `include "constants.vams"
    `include "disciplines.vams"

    module source(a,b,c);
    inout a;
         inout b,c;
         electrical a,b,c;
         integer seed;
         (*cds_inherited_parameter*)parameter real seedin = 0;
         analog begin
         seed=seedin;
         V(b) <+ cos(seed*100000000);
         V(c) <+ sin($abstime*300000000);
         $strobe("hello,I'm glad to meet you",seedin);
         end
    endmodule

    2 source.scs

    simulator lang=spectre
    ahdl_include "source.va"
    parameters seedin=0
    statistics {
      mismatch {
        vary seedin dist=gauss std=5
      }
    }

    .  Do you see any errors? Thank you.

    Best regards,

    UU

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    Not sure what you mean by "it doesn't work". I created a simple circuit containing an instance of source, and then ran a monte carlo analysis:

    include "source.scs"

    I1 (a b c) source
    r1 (a 0) resistor r=1k
    r2 (b 0) resistor r=1k
    r3 (c 0) resistor r=1k

    monte montecarlo numruns=10 variations=mismatch savefamilyplots=yes {
       tran tran stop=10n
    }

    This outputs a lot of stuff, but in particular it says (for each iteration of the monte carlo):

     hello,I'm glad to meet you -3.38873
    hello,I'm glad to meet you -3.38873
    hello,I'm glad to meet you -3.38873
    .hello,I'm glad to meet you -3.38873
    ..hello,I'm glad to meet you -3.38873
    ...hello,I'm glad to meet you -3.38873

    and then later:

         gmin = 1 pS                                           


    hello,I'm glad to meet you 2.42183
    hello,I'm glad to meet you 2.42183
    hello,I'm glad to meet you 2.42183
    .hello,I'm glad to meet you 2.42183
    ..hello,I'm glad to meet you 2.42183

    (you're strobing on each timestep iteration, so because I ran a transient, it strobes multiple times).

    Because I ran with saving family plots, you can see your signal b in the monte carlo (see attached picture).

    Andrew.

    • monte.png
    • View
    • Hide
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • UUinfini
    UUinfini over 11 years ago
    First, I created a simple circuit

    Then a simulation Monte Carlo

    In the end the error came always like:

    Can you see what errors may I have?

    Thank you.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago
    UU,

    I see you sent me a direct email. As I am on vacation at the moment with limited access to my email, please post here (and make sure any pictures are uploaded via the options tab when posting). That way everyone can see the issue and possibly help out. 

    I couldn't  see the error in your email anyway. 

    Andrew
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • UUinfini
    UUinfini over 11 years ago
    Hello Andrew,

    When I created the file "source.scs" and "source.va" and did the Monte Carlo simulation with a simple circuit and importing "source.scs" as library, the following error came:
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • UUinfini
    UUinfini over 11 years ago

     

     Hello Andrew,

    I created the file "source.scs" and "source.va" and then executed the simulation Monte Carlo with "source.scs" imported as library using a simple circuit, and the attached error came.

    Best regards,

    UU

     

    • error.jpg
    • View
    • Hide
    • 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