• 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 SKILL
  3. Different distribution function in verilog A

Stats

  • Locked Locked
  • Replies 8
  • Subscribers 143
  • Views 17816
  • 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

Different distribution function in verilog A

Shobhitkareer
Shobhitkareer over 6 years ago

Hi Everyone,

I'm new to verilog A and  using spectre as my simulator in IC 617, I'm trying to generate model variance file and made the following model (courtesy Verilog A reference book)

statistics {

  mismatch {

    vary monteres dist=gauss std=5

   }

}

My question is can we change from gaussian distribution to poisson or chi distribution? If yes, how and where can I find them.

Thank you in advance

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago

    For a start, that is not Verilog-A - it's a spectre statistics block that describes how a spectre parameter varies. Which book did you find that in? It looks like an example I created in the past (even the standard deviation is the same value I used).

    Anyway, spectre supports dist being gauss, unif and lnorm for Gaussian, Uniform and Log Normal respectively. See "spectre -h montecarlo" for more detail. It does not support the other distributions - and I can't see how it would make sense for Poisson at least - that's a discrete distribution that expresses the probability of a given number of events occurring in a fixed interval of time or space, which doesn't sound like the kind of thing you'd vary with monte carlo. I've never heard of anyone asking for Poisson or Chi (or any variant of Chi) distribution - I'm not convinced it makes any sense. You can of course warp the distribution however you want in any expression you use this random variable in.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Shobhitkareer
    Shobhitkareer over 6 years ago in reply to Andrew Beckett

    Hi Andrew,

    I actually saw the example in Cadene Verilo-A language reference 18.1, 

    I read  about the random number generation in the verilog A but I couldnt figure out how to simulate it withing the code for a certain parameter like resistivity. Quoted from the same reference book "  Verilog-A provides functions that generate random numbers in the following distribution patterns: poisson, normal, exponential"

    And for the background I just want to compare how the gaussian and poisson distribution result vary in a particular area I know is worst affected due to noise from other circuit, assuming event will be discrete,  i hope I'm making a valid point here.

    regards

    shobhit

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to Shobhitkareer

    Hi Shobhit,

    That example is not about generating random numbers with particular distributions - that's on how to inherit a parameter which is being varied in monte carlo simulation - that's where each sample has a different value of a parameter based on a distribution. To produce random numbers (during a simulation) using poisson or chi squared distribution you need to use the $rdist_poisson or $rdist_chi_square functions. Something like this:

    `include "disciplines.vams"
    
    module randdist(poisson,chi);
    output poisson,chi;
    electrical poisson,chi;
    
    parameter real period=1u;
    parameter real mean=5;
    parameter integer dof=4;
    parameter integer seed=1234;
    parameter real td=0; 
    parameter real trf=1n; 
    
    real rpoisson,rchi;
    
    analog begin
        @(timer(0,period)) begin
    	rpoisson=$rdist_poisson(seed,mean);
    	rchi=$rdist_chi_square(seed,dof);
    	// $display(rpoisson,rchi);
        end
        V(poisson) <+ transition(rpoisson,td,trf);
        V(chi) <+ transition(rchi,td,trf);
    end
    
    endmodule
    

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Shobhitkareer
    Shobhitkareer over 6 years ago in reply to Andrew Beckett

    Hi Andrew,

    I couldnt initiate the symbol for this in schematic, the error I faced is it would make schematic go in recursive. As I just started with verilog A I dont know how to simulate it any other simulator.

    To solve this I thought to change the $rdist_poisson to $dist_poisson to make it compatible to digital context but it didnt make any sense to me. Additionally, I would like to comment that in the reference file its mention that there is one more argument called string, which provides support for monte carlo, but there is no example on how to initiate that it either. 

    Thank you in advance

    Regards

    Shobhit

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to Shobhitkareer

    Hi Shobhit,

    I can only imagine with the inability to instantiate the symbol, that you're trying to put the schematic and the veriloga view as both being views of the same cell - you need to have a different  cellName for the place where you instantiate the symbol corresponding to the veriloga view.

    I don't see why changing $rdist_poisson to $dist_poisson would help in any way to solve this - that sounds like a simple Virtuoso usage problem. It sounds as if you're in desperate need of some training?

    As for using these functions in a way that works for Monte Carlo, then you need to use them to initialise a parameter, rather than calling them as I did in the example above. In the example above, they are called each time the timer event occurs, which means they would change during the simulation - hence the third string wouldn't be terribly meaningful. For a monte-carlo type usage, you'd need something like this:

    `include "disciplines.vams"
    
    module randdist(poisson,chi);
    output poisson,chi;
    electrical poisson,chi;
    
    parameter real period=1u;
    parameter real mean=5;
    parameter integer dof=4;
    parameter integer seed=1234;
    parameter real td=0; 
    parameter real trf=1n; 
    parameter real rpoisson_mis=$rdist_poisson(seed,mean,"instance");
    parameter real rpoisson_proc=$rdist_poisson(seed,mean,"global");
    parameter real rchi_mis=$rdist_chi_square(seed,dof,"instance");
    parameter real rchi_proc=$rdist_chi_square(seed,dof,"global");
    
    analog begin
        @(initial_step) begin
    	$display("%M Poisson:     ",$cds_get_mc_trial_number(),rpoisson_proc,rpoisson_mis);
    	$display("%M Chi Squared: ",$cds_get_mc_trial_number(),rchi_proc,rchi_mis);
        end
        V(poisson) <+ transition(rpoisson_proc+rpoisson_mis,td,trf);
        V(chi) <+ transition(rchi_proc+rchi_mis,td,trf);
    end
    
    endmodule

    Then with two instances in my design - here's my simple spectre netlist:

    //
    parameters myparam=0.0;
    I1 (poisson chi) randdist
    R1 (poisson 0) resistor r=1k
    R2 (chi 0) resistor r=1k
    I2 (poisson2 chi2) randdist
    R3 (poisson2 0) resistor r=1k
    R4 (chi2 0) resistor r=1k
    
    ahdl_include "randdist2.va"
    
    statistics {
        process {
    	vary myparam dist=gauss std=1.0
        }
        mismatch {
    	vary myparam dist=gauss std=0.1
        }
    }
    mc montecarlo numruns=10 variations=all {
        tran tran stop=100m
    }

    Notice that because this is a trivial example, I need to add at least something in a statistics block just to allow monte carlo to run without errors.

    I then get (I'm just showing the appropriate lines from the spectre output log):

    I2 Poisson:      0  2  2 
    I2 Chi Squared:  0  8.74968  8.74968 
    I1 Poisson:      0  2  2 
    I1 Chi Squared:  0  8.74968  8.74968 
    I2 Poisson:      1  2  4 
    I2 Chi Squared:  1  8.74968  7.73248 
    I1 Poisson:      1  2  2 
    I1 Chi Squared:  1  8.74968  8.74968 
    I2 Poisson:      2  4  2 
    I2 Chi Squared:  2  7.73248  5.94456 
    I1 Poisson:      2  4  9 
    I1 Chi Squared:  2  7.73248  3.27589 
    I2 Poisson:      3  9  6 
    I2 Chi Squared:  3  3.27589  4.23019 
    I1 Poisson:      3  9  6 
    I1 Chi Squared:  3  3.27589  1.82658 
    I2 Poisson:      4  2  8 
    I2 Chi Squared:  4  5.94456  1.96276 
    I1 Poisson:      4  2  3 
    I1 Chi Squared:  4  5.94456  1.78829 
    I2 Poisson:      5  6  5 
    I2 Chi Squared:  5  1.82658  9.96347 
    I1 Poisson:      5  6  8 
    I1 Chi Squared:  5  1.82658  2.03603 
    I2 Poisson:      6  6  4 
    I2 Chi Squared:  6  4.23019  0.904921 
    I1 Poisson:      6  6  6 
    I1 Chi Squared:  6  4.23019  3.36746 
    I2 Poisson:      7  3  4 
    I2 Chi Squared:  7  1.78829  9.76985 
    I1 Poisson:      7  3  13 
    I1 Chi Squared:  7  1.78829  3.11418 
    I2 Poisson:      8  8  3 
    I2 Chi Squared:  8  1.96276  4.81002 
    I1 Poisson:      8  8  8 
    I1 Chi Squared:  8  1.96276  1.83433 
    I2 Poisson:      9  8  6 
    I2 Chi Squared:  9  2.03603  7.22916 
    I1 Poisson:      9  8  3 
    I1 Chi Squared:  9  2.03603  1.33414 
    I2 Poisson:      10  5  5 
    I2 Chi Squared:  10  9.96347  14.956 
    I1 Poisson:      10  5  4 
    I1 Chi Squared:  10  9.96347  2.95343 

    As you can see, the two instances have a common value for each iteration number for the "_proc" (process/global) parameter, but a different value for the "_mis" (mismatch/instance) parameter.

    Regards,

    Andrew.

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Shobhitkareer
    Shobhitkareer over 6 years ago in reply to Andrew Beckett

    Thank you Andrew for very detailed explanation, it is working now. I'll also take in your suggestion of getting some training as well.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Shobhitkareer
    Shobhitkareer over 6 years ago in reply to Andrew Beckett

    Dear Andrew,

    Just to clarify shouldnt  ahdl_include "randdist2.va" be "ahdl_include "randdist.va", since that file is being used in the .scs file.

    Regards

    Shobhit

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to Shobhitkareer

    Hi Shobhit,

    The filename is not that important - it's just whatever you call the file containing the VerilogA. It could just as well have been called "helicopter.va" or "purplebanana.va". In this case the original model I wrote was in a file called "randdist.va" and the second version in "randdist2.va". In both cases they contained a module called randdist.

    Regards,

    Andrew.

    • 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