• 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. Convert output of "waveVsWave()" into derivable waveform...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 4455
  • 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

Convert output of "waveVsWave()" into derivable waveform by ordering X and Y values

dontpanic
dontpanic over 7 years ago

Hi all! I'd like to take the derivative of waveforms that I obtain using the waveVsWave() function. The problem is that using the "deriv()" function doesn't work (I guess) because the X and Y values of such waveforms are not properly arranged.

For example: in a TRAN simulation of an SC amplifier I get input and output waveforms Vout(t) and Vin(t), and use waveVsWave() to obtain a plottable "Vout(Vin)" waveform. However, using deriv() on it produces incorrect results, I suspect because the X values of the waveform are not monotonic, but arranged according to the original independent variable "t" (e.g. for a coherently-sampled sine input at Nyquist frequency the X values alternate polarity with every sample, and so do the corresponding Y-values at the output of the amplifier).

In the above example, how could I process the output of waveVsWave() so that I can use deriv() to calculate dVout/dVin = effective gain of the amplifier, including distortion components (different from Vout/Vin ratio!)?

I suspect all what is needed is a skill function to process the "Vout(Vin)" waveform (so as to order its elements: X-values monotonically, and Y-values according to the ordering of the X-values), but this goes beyond my Skill capabilities.

Thanks and regards,

Jorge.

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago

    Hi Jorge,

    You could use the code in this article: 11584412 . I'll post both bits of code here that are needed - hopefully this will solve the problem for you?

    /* abSortXValues.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Aug 26, 2009 
    Modified   
    By         
    
    Function to sort the inner sweep to be sorted by x-value.
    For harmonic data (such as that from pac, qpac), the order is
    by harmonic number - so if you try to use the value() function,
    you may get garbage results because value() expects the x-axis
    to be monotonic.
    
    Usually you would use the harmonic() function to get a particular
    harmonic - this is to allow you to get a fixed frequency instead
    (if you're doing a sweep of frequency, you may not be interested
    in a fixed harmonic id).
    
    Usage:
    
    a=abSortXValues(v("/net6"))
    plot(value(a 100k))
    
    Uses abWaveToList.il
    
    ***************************************************
    
    SCCS Info: @(#) abSortXValues.il 08/26/09.12:32:13 1.1
    
    */
    
    (defun abSortXValues (wave)
      (cond
        ((drIsWaveform wave)
         ;-------------------------------------------------------------------
         ; Sort each waveform to be ordered by the x-values
         ;-------------------------------------------------------------------
         (artListToWaveform (sortcar (abWaveToList wave) 'lessp))
         )
        ((famIsFamily wave)
         (let (new)
           (setq new (famMap 'abSortXValues wave))
           ;-----------------------------------------------------------------
           ; Remove any harmonic information, because it won't be correct
           ; as the order of the underlying waveforms no longer matches
           ;-----------------------------------------------------------------
           (remprop new 'harmonic)
           (remprop new '__harmonicList)
           new
           )
         )
        (t 
          (error "abSortXValues - can't handle %L\n" wave)
          )
        ) ; cond
      ) ; defun

    /* abWaveToList.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Nov 17, 2003 
    Modified   
    By         
    
    Convert a waveform to a list
    
    ***************************************************
    
    SCCS Info: @(#) abWaveToList.il 11/17/03.15:08:15 1.1
    
    */
    
    /************************************************************************
    *                                                                       *
    *                  (abWaveToList wave @key transpose)                   *
    *                                                                       *
    *    Take a waveform object, and return it as a list of xy pairs. Or    *
    * if transpose is set, it returns a list of x values followed by a list *
    *                             of y values.                              *
    *                                                                       *
    ************************************************************************/
    
    (procedure (abWaveToList wave @key transpose)
      (let (xList yList xyList len
            (xVec (drGetWaveformXVec wave))
            (yVec (drGetWaveformYVec wave))
            )
           (setq len (drVectorLength xVec))
           ;-----------------------------------------------------------------
           ; Return value of this if is the list
           ;-----------------------------------------------------------------
           (if transpose
               (progn
                (for i 0 (sub1 len)
                     (setq xList (tconc xList (drGetElem xVec i)))
                     (setq yList (tconc yList (drGetElem yVec i)))
                     )
                (list (car xList) (car yList))
                )
               ; else
               (progn
                (for i 0 (sub1 len)
                     (setq xyList (tconc xyList (list (drGetElem xVec i)
                                                      (drGetElem yVec i))))
                     )
                (car xyList)
                )
               ) ; if
           ) ; let
      ) ; procedure
    

    Regards,

    Andrew.

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

    Thanks a million, Andrew! Worked like a charm!!! Smiley

    • 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