• 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. Manipulate and export data from ViVa

Stats

  • Locked Locked
  • Replies 12
  • Subscribers 125
  • Views 17482
  • 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

Manipulate and export data from ViVa

BaaB
BaaB over 9 years ago

I have two signals as in the picture below.

I would like to measure some information and export them to a table or a file something like this:

Pulse width     fall time

614n                738n

696n                686n

581n                660n

660n                672n

  ...                     ...

I am wondering if there is a way to do that. It would be a great help. Otherwise, I have to do it manually with hundreds points.

Thank you.

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    I think you could do this with the dutyCycle and fallTime functions in the calculator. Both allow you to generate the value versus cycle number. For the duty cycle, you'd need to divide by 100 and multiply by the period to get the actual pulse width. For fallTime, it normally does it 10 to 90% rather than peak to peak - mainly because the peak may not be precisely in the same place - so you could probably just measure the 10% to 90% fallTime and then multiply by 1.25 to get the peak to peak value?

    If you can generate both expressions in the calculator, you can then send each to a table (using the table button in the calculator) and then you'll have both sets of results.

    Something like that (I very quickly tried it out with some made up data and it seemed a reasonable approach). I'll leave the details to you as it will depend on your data and precisely what you're trying to measure.

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • BaaB
    BaaB over 9 years ago

    Thanks for help!

    I used dutycycle and it is OK. However, could you tell me how can I get the period of the signal versus cycle?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago
    You can use the freq function in the calculator (and then take 1/x of that). This allows you to compute the frequency versus cycle, and obviously the reciprocal is the period.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • BaaB
    BaaB over 9 years ago

    Thanks.

    For the fall time, is there a function to find difference between the location where inductor current is maximum and the location where inductor current is zero versus cycle?

    I think your method works but because I need a high accuracy so hope there is a better method.

    Also, if I use fallTime function, I have to specify the initial and final value. The final value is 0 but the initial value is not a constant. That is what I am facing now.

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

    I'm part way through writing something that finds the local peaks and troughs in each cycle. It's not entirely trivial, so may need a bit more time before I've finished it (I'm doing it between other tasks).

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • BaaB
    BaaB over 9 years ago
    Well, thank you very much for your kindness!
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    This code should do it. See the example in the comments. Making this flexible is what took a bit of time. It probably could do with a bit more testing:

    /* abGetCyclePeaks.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Mar 23, 2016 
    Modified   
    By         
    
    Function to calculate the peak values (or times of peak values)
    within each period. Has some tolerances built in so that it should
    detects when it first reaches the peak and filters out numerical
    noise.
    
    Example - measure fall time (peak to peak) in each period:
    
    abGetCyclePeaks(v("ramp" ?result 'tran) "rising" "max" ?yValues "x")-
        abGetCyclePeaks(v("ramp" ?result 'tran) "rising" "min" ?yValues "x")
    
    ***************************************************
    
    SCCS Info: @(#) abGetCyclePeaks.il 03/23/16.22:27:05 1.1
    
    */
    
    /*******************************************************************
    *                                                                  *
    *      (abGetCyclePeaks wave crossType minMax [?mode "auto"]       *
    *         [?threshold 0.0] [?yValues "y"] [?xName "cycle"]         *
    *                  [?reltol 1e-3] [?abstol 1e-6])                  *
    *                                                                  *
    *     For each cycle - identified by the rising or falling (or     *
    *     either, but that's not so likely to be used) crossing of     *
    *     the threshold (which is controlled by the ?mode argument     *
    *  "auto" means automatic, "user" means as specified) - find the   *
    * "min" or "max" value of the signal within the cycle. In order to *
    * filter out numerical noise on the signal influencing the precise *
    *     position of the peak, only look at changes bigger than a     *
    *   reltol+abstol type delta from the previously found peak. The   *
    *   resulting waveform can be plotted versus "cycle" or "time",    *
    *    and the yValues can be either the y or x values at the peak.  *
    *                                                                  *
    *******************************************************************/
    
    (defun abGetCyclePeaks (wave crossType minMax @key (mode "auto") 
                                 (threshold 0.0) (yValues "y") (xName "cycle") 
                                 (reltol 1e-3) (abstol 1e-6) "gSSSfSSff")
      (cond
        ((drIsWaveform wave)
         (let (xVec yVec len outX outY newXVec newYVec newWave cycleNum lastY 
                    thisY localPeakX localPeakY direction func absdelta tolerance)
           ;-----------------------------------------------------------------
           ; Validate the arguments to ensure they are valid strings
           ;-----------------------------------------------------------------
           (foreach validInfo
                 `(
                   (crossType ,(setq crossType (get_string crossType))
                              ("rising" "falling" "either"))
                   (minMax ,(setq minMax (get_string minMax)) ("min" "max"))
                   (?mode ,(setq mode (get_string mode)) ("auto" "user"))
                   (?xName ,(setq xName (get_string xName)) ("cycle" "time"))
                   (?yValues ,(setq yValues (get_string yValues)) ("y" "x"))
                   )
                 (unless (member (cadr validInfo) (caddr validInfo))
                   (error "abGetCyclePeaks: %s argument must be one of \"%s\": %L\n"
                          (car validInfo)
                          (buildString (caddr validInfo) "\",\"")
                          (cadr validInfo))
                   )
                 )
           (when (equal mode "auto")
             (setq threshold (average wave)))
           (setq func (if (equal minMax "max") 'greaterp 'lessp))
           (setq xVec (drGetWaveformXVec wave))
           (setq yVec (drGetWaveformYVec wave))
           (setq len (drVectorLength xVec))
           (setq cycleNum 0)
           (setq lastY (drGetElem yVec 0))
           (setq localPeakY lastY)
           (setq localPeakX (drGetElem xVec 0))
           ;-----------------------------------------------------------------
           ; Iterate through all the points
           ;-----------------------------------------------------------------
           (for i 1 (sub1 len)
                (setq thisY (drGetElem yVec i))
                ;------------------------------------------------------------
                ; Determine if this is a transition, and if so, which direction
                ;------------------------------------------------------------
                (setq direction
                      (cond 
                        ((and (lessp lastY threshold)
                              (geqp thisY threshold)) "rising")
                        ((and (geqp lastY threshold)
                              (lessp thisY threshold)) "falling")
                        (t nil)))
                ;------------------------------------------------------------
                ; Assuming it's a crossing in the right direction, record
                ; the peak in that cycle (doesn't do it before the first
                ; transition though)
                ;------------------------------------------------------------
                (if (or (equal crossType direction)
                        (and (equal crossType "either") direction))
                  (progn
                    (when (greaterp cycleNum 0)
                      (setq outX 
                            (tconc outX (if (equal xName "cycle") cycleNum 
                                          localPeakX)))
                      (setq outY (tconc outY 
                                        (if (equal yValues "y") 
                                          localPeakY localPeakX)))
                      )
                    (setq localPeakX (drGetElem xVec i))
                    (setq localPeakY thisY)
                    (postincrement cycleNum)
                    )
                  ;----------------------------------------------------------
                  ; Otherwise see if the peak has been exceeded
                  ;----------------------------------------------------------
                  (when (funcall func thisY localPeakY)
                    (setq absdelta (abs (difference thisY lastY)))
                    (setq tolerance (plus (times (max (abs thisY) (abs lastY)) 
                                                 reltol) abstol))
                    (when (greaterp absdelta tolerance)
                      (setq localPeakX (drGetElem xVec i))
                      (setq localPeakY thisY)
                      )
                    )
                  )
                (setq lastY thisY)
                )
           ;-----------------------------------------------------------------
           ; Construct output vectors and waveforms with the right
           ; attributes
           ;-----------------------------------------------------------------
           (setq newXVec (drCreateVec 
                           (if (equal xName "cycle") 'intlong 'double) (car outX)))
           (setq newYVec (drCreateVec 'double (car outY)))
           (putpropq newXVec (if (equal xName "cycle") "" (getq xVec units)) units)
           (putpropq newXVec 
                     (if (equal xName "cycle") "cycle" (getq xVec name)) name)
           (putpropq newYVec 
                     (if (equal yValues "y") 
                       (getq yVec units) 
                       (getq xVec units)) 
                     units)
           (putpropq newYVec 
                     (if (equal yValues "y")
                       (getq yVec name)
                       (getq xVec name))
                     name)
           (setq newWave (drCreateWaveform newXVec newYVec))
           (famSetExpr newWave 
                       `(abGetCyclePeaks ,(famGetExpr wave) crossType minMax 
                                         ?mode ,mode ?threshold ,threshold 
                                         ?yValues yValues ?xName ,xName 
                                         ?reltol ,reltol ?abstol ,abstol))
           newWave
           )
         )
        ((famIsFamily wave)
         (famMap 'abGetCyclePeaks minMax ?mode mode ?threshold threshold 
                 ?yValues yValues ?xName xName ?reltol reltol ?abstol abstol)
         )
        (t
          (error "abGetCyclePeaks: Cannot handle %L\n" wave)
          )
        )
      )
    

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • BaaB
    BaaB over 9 years ago

    Thanks a lot for these help.

    I am just a beginner. Could you tell me how to run this code?

    Also if I want to write kind of this code, what language or something that I should learn? 

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

    To use the code, you can use the load() function to load it. Put it in a file (abGetCyclePeaks.il) and then in the CIW:

    load("abGetCyclePeaks.il")

    You can put this line in your .cdsinit too (put the full path to the file if necessary).

    The code is written in SKILL - which is a LISP variant. In fact all your calculator expressions are SKILL too - so to actually use the function, you'd need to type the function call (as shown the comments) into the calculator buffer. It's possible to add it as a custom function in IC617 easily through the UI - I'll post how to do that a little later.

    I tend to write my code using LISP syntax. To make it a bit easier to understand for those less familiar with SKILL, I've reformatted it into C-style below. This is equivalent, so there's no performance benefit in using either format - it's just the parser allows these alternative approaches to writing the code, because more engineers are probably familiar with a C-style than a LISP-style.

    Regards,

    Andrew.

    /* abGetCyclePeaks.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Mar 23, 2016 
    Modified   
    By         
    
    Function to calculate the peak values (or times of peak values)
    within each period. Has some tolerances built in so that it should
    detects when it first reaches the peak and filters out numerical
    noise.
    
    Example - measure fall time (peak to peak) in each period:
    
    abGetCyclePeaks(v("ramp" ?result 'tran) "rising" "max" ?yValues "x")-
        abGetCyclePeaks(v("ramp" ?result 'tran) "rising" "min" ?yValues "x")
    
    ***************************************************
    
    SCCS Info: @(#) abGetCyclePeaks.il 03/23/16.22:27:05 1.1
    
    */
    
    /*******************************************************************
    *                                                                  *
    *      (abGetCyclePeaks wave crossType minMax [?mode "auto"]       *
    *         [?threshold 0.0] [?yValues "y"] [?xName "cycle"]         *
    *                  [?reltol 1e-3] [?abstol 1e-6])                  *
    *                                                                  *
    *     For each cycle - identified by the rising or falling (or     *
    *     either, but that's not so likely to be used) crossing of     *
    *     the threshold (which is controlled by the ?mode argument     *
    *  "auto" means automatic, "user" means as specified) - find the   *
    * "min" or "max" value of the signal within the cycle. In order to *
    * filter out numerical noise on the signal influencing the precise *
    *     position of the peak, only look at changes bigger than a     *
    *   reltol+abstol type delta from the previously found peak. The   *
    *   resulting waveform can be plotted versus "cycle" or "time",    *
    *    and the yValues can be either the y or x values at the peak.  *
    *                                                                  *
    *******************************************************************/
    
    procedure(abGetCyclePeaks(wave crossType minMax @key (mode "auto") 
        (threshold 0.0) (yValues "y") (xName "cycle") 
        (reltol 1e-3) (abstol 1e-6) "gSSSfSSff")
      cond(
        (drIsWaveform(wave)
          let((xVec yVec len outX outY newXVec newYVec newWave cycleNum lastY 
              thisY localPeakX localPeakY direction func absdelta tolerance)
            ;----------------------------------------------------------------
            ; Validate the arguments to ensure they are valid strings
            ;----------------------------------------------------------------
            foreach(validInfo
              `(
                (crossType ,(crossType=get_string(crossType))
                ("rising" "falling" "either"))
                (minMax ,(minMax=get_string(minMax)) ("min" "max"))
                (?mode ,(mode=get_string(mode)) ("auto" "user"))
                (?xName ,(xName=get_string(xName)) ("cycle" "time"))
                (?yValues ,(yValues=get_string(yValues)) ("y" "x"))
              )
              unless(member(cadr(validInfo) caddr(validInfo))
                error("abGetCyclePeaks: %s argument must be one of \"%s\": %L\n"
                  car(validInfo)
                  buildString(caddr(validInfo) "\",\"")
                  cadr(validInfo))
                )
            )
            when(mode=="auto"
              threshold=average(wave)
            )
            func=if(minMax=="max" 'greaterp 'lessp)
            xVec=drGetWaveformXVec(wave)
            yVec=drGetWaveformYVec(wave)
            len=drVectorLength(xVec)
            cycleNum=0
            lastY=drGetElem(yVec 0)
            localPeakY=lastY
            localPeakX=drGetElem(xVec 0)
            ;----------------------------------------------------------------
            ; Iterate through all the points
            ;----------------------------------------------------------------
            for(i 1 sub1(len)
              thisY=drGetElem(yVec i)
              ;--------------------------------------------------------------
              ; Determine if this is a transition, and if so, which direction
              ;--------------------------------------------------------------
              direction=
                cond( 
                  (lastY<threshold && thisY>=threshold "rising")
                  (lastY>=threshold && thisY<threshold "falling")
                  (t nil)
                )
              ;--------------------------------------------------------------
              ; Assuming it's a crossing in the right direction, record
              ; the peak in that cycle (doesn't do it before the first
              ; transition though)
              ;--------------------------------------------------------------
              if(crossType==direction || crossType=="either" && direction then
                when(cycleNum>0
                  outX=tconc(outX if(xName=="cycle" cycleNum localPeakX))
                  outY=tconc(outY if(yValues=="y" localPeakY localPeakX))
                )
                localPeakX=drGetElem(xVec i)
                localPeakY=thisY
                cycleNum++
              else
                ;------------------------------------------------------------
                ; Otherwise see if the peak has been exceeded
                ;------------------------------------------------------------
                when(funcall(func thisY localPeakY)
                  absdelta=abs(thisY-lastY)
                  tolerance=max(abs(thisY) abs(lastY))*reltol+abstol 
                  when(absdelta>tolerance
                    localPeakX=drGetElem(xVec i)
                    localPeakY=thisY
                  )
                )
              )
              lastY=thisY
            ) ; for
            ;----------------------------------------------------------------
            ; Construct output vectors and waveforms with the right
            ; attributes
            ;----------------------------------------------------------------
            newXVec=drCreateVec(if(xName=="cycle" 'intlong 'double) car(outX))
            newYVec=drCreateVec('double car(outY))
            newXVec->units=if(xName=="cycle" "" xVec->units)
            newXVec->name=if(xName=="cycle" "cycle" xVec->name)
            newYVec->units=if(yValues=="y" yVec->units xVec->units)
            newYVec->name=if(yValues=="y" yVec->name xVec->name)
            newWave=drCreateWaveform(newXVec newYVec)
            famSetExpr(newWave 
              `abGetCyclePeaks(,famGetExpr(wave) crossType minMax 
                 ?mode ,mode ?threshold ,threshold 
                 ?yValues yValues ?xName ,xName 
                 ?reltol ,reltol ?abstol ,abstol)
            )
            newWave
          )
        )
        (famIsFamily(wave)
          famMap('abGetCyclePeaks minMax ?mode mode ?threshold threshold 
            ?yValues yValues ?xName xName ?reltol reltol ?abstol abstol
          )
        )
        (t
          error("abGetCyclePeaks: Cannot handle %L\n" wave)
        )
      )
    )
    

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • BaaB
    BaaB over 9 years ago

    Thank you.

    I have just tried the function as the attached file. I don't know how to send the signal so I export it into excel files.

    Sorry, I couldn't attach the file here.

    1.Triangangle wave test execl file:

    http://www.filedropper.com/trianglewave

    2. Result in excel file:

    http://www.filedropper.com/outputfallingtime

    I can't explain how the result is 14 cycles here. Also because you use minimum value, the result is not accurate for calculating fall time here.

    In this case, it seems that the measured result is something like period.

    I am reading the code so hopefully I can modify it to measure the fall time between maximum value and the point where it crosses zero first time in each cycle.

    • 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