• 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. How can I use stddev calculator function multiple times...

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 126
  • Views 9354
  • 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

How can I use stddev calculator function multiple times on a transient plot?

delgsy
delgsy over 2 years ago

Hello,
This plot below is obtained by sampling transient plot with multiple run transient noise using value function from calculator.
Then I want to calculate the standard deviation of the data at specific times when the signal is sampled.
So at the end I need to get standard_deviation vs time plot.
How can I do that?

What I do now is using this expression :
stddev(value(v("/VOUT" ?result "tran") 1.5e-07))
The result is correct, but I need to do it one by one.



  • Cancel
  • Andrew Beckett
    Andrew Beckett over 2 years ago

    This can be done (with a little additional function to workaround a designed feature of swapSweep) by sampling the waveform, using swapSweep to change the x-axis to be the swept variable (the 12.XXk in your legend) and then using stddev on the result. The reason for the additional function is that normally swapSweep disallows swapping the axis if the inner sweep is time or freq (mostly because for a big transient waveform that could lead to an immense number of family members), so we can trick our way around that by using the abSetXName code below - simply put that in a file and then load via the "fx" button in the calculator function panel.

    As a little example, I had this spectre netlist:

    //
    
    parameters nseed=1
    V1 (slope 0) vsource type=pulse rise=500n val0=-5m val1=15m
    R1 (slope out) resistor r=1
    
    sweepSeed sweep param=nseed start=1 stop=100 step=1 {
      tran tran stop=500n noisefmax=10G noisescale=4 noiseseed=nseed
    }

    I then used this expression:

    stddev(swapSweep(abSetXName(sample(v("out" ?result "sweepSeed_tran-sweep") 0 5e-07 "linear" 5e-08) t ) "nseed" nil) ?type "sample" ?continuous nil )

    (note, I am changing the x name to "t" rather than "time" to fool the swapSweep). I could of course change it back again after the stddev if I wanted it to be "time" again. The stddev is using the sampled standard deviation and is treating the values as discrete (so ignoring the x-axis when computing the standard deviation).

    This results in this graph:

    Finally, here's the abSetXName code I mentioned above:

    /* abSetXName.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Oct 08, 2022 
    Modified   
    By         
    
    abSetXName(waveform "time")
    
    sets the name on the X axis a waveform to be "time"
    
    To use in the calculator (from IC617) use the fx button in the Function
    Panel to register the code. The GUI Builder template is included
    
    ***************************************************
    
    SCCS Info: @(#) abSetXName.il 10/08/22.14:24:45 1.1
    
    */
    
    /****************************************************************
    *                                                               *
    *                   (abSetXName wave name)                      *
    *                                                               *
    * Sets the name on the x axis of a waveform or the members of a *
    *                           family.                             *
    *                                                               *
    ****************************************************************/
    
    (defun abSetXName (wave name)
      (cond 
        ((drIsWaveform wave)
         (putpropq (drGetWaveformXVec wave) name name)
         wave
         )
        ((famIsFamily wave)
         (famMap 'abSetXName wave name)
         )
        (t wave)
        )
      )
    
    ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;; GUI builder information ;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ocnmRegGUIBuilder(
     '(nil
      function abSetXName
      name abSetXName
      description "Set the name on the x-axis of the waveform"
      category ("Custom Functions")
      analysis (nil
          general (nil
            args (wave name )
              signals (nil
                    wave (nil
                          prompt "Waveform"
                          tooltip "wave"
                          )
               )
              params(nil
                     name (nil
                           prompt "Name"
                           tooltip "name"
                           guiRowHint 1
                           type string
                           required t
                     )
              )
            inputrange t
          )
      )
      outputs(result)
     )
    )
    

    Hope that helps!

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • delgsy
    delgsy over 2 years ago in reply to Andrew Beckett

    Hi Andrew,

    From your calculator expression, I can follow until abSetXName but the x axis still show "time" instead of "t".



    Changing manually the x axis name into t and than applying Swapsweep does not work as well because it seems that the software cannot find "nseed" in your expression.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 2 years ago in reply to delgsy

    Apologies - it seems that if you put t in the form (I'd originally typed in the expression before I added the calculator integration stuff, so I didn't notice this), it omits the quotation marks. If you call the new name "tim" or "ti" then it's OK (or if you edit the expression afterwards in the buffer to surround the t  with quotation marks (i.e. "t").

    After that you'll need to use an appropriate variable as the axis to swap with - it was nseed in my case, but I think Iteration seems appropriate in your case as that's one of the other variables - then you'll be able to do this over your Monte Carlo iterations (assuming that's what you were doing here). The column headings in the legend would tell you the swept variables names. In essence, you want the new x-axis after the swapSweep to be the axis you want to compute the standard deviation over.

    Andrew

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

    This new version of the code will work even if you use t as the axis name:

    /* abSetXName.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Oct 08, 2022 
    Modified   
    By         
    
    abSetXName(waveform "time")
    
    sets the name on the X axis a waveform to be "time"
    
    To use in the calculator (from IC617) use the fx button in the Function
    Panel to register the code. The GUI Builder template is included
    
    ***************************************************
    
    SCCS Info: @(#) abSetXName.il 10/08/22.15:24:36 1.2
    
    */
    
    /****************************************************************
    *                                                               *
    *                   (abSetXName wave name)                      *
    *                                                               *
    * Sets the name on the x axis of a waveform or the members of a *
    *                           family.                             *
    *                                                               *
    ****************************************************************/
    
    (defun abSetXName (wave name)
      (when (symbolp name)
        (setq name (symbolToString name)))
      (cond 
        ((drIsWaveform wave)
         (putpropq (drGetWaveformXVec wave) name name)
         wave
         )
        ((famIsFamily wave)
         (famMap 'abSetXName wave name)
         )
        (t wave)
        )
      )
    
    ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;; GUI builder information ;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ocnmRegGUIBuilder(
     '(nil
      function abSetXName
      name abSetXName
      description "Set the name on the x-axis of the waveform"
      category ("Custom Functions")
      analysis (nil
          general (nil
            args (wave name )
              signals (nil
                    wave (nil
                          prompt "Waveform"
                          tooltip "wave"
                          )
               )
              params(nil
                     name (nil
                           prompt "Name"
                           tooltip "name"
                           guiRowHint 1
                           type string
                           required t
                     )
              )
            inputrange t
          )
      )
      outputs(result)
     )
    )
    

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • delgsy
    delgsy over 2 years ago in reply to Andrew Beckett

    It works! Thank you very much.

    • 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