• 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. getting the number of points in a waveform, or the number...

Stats

  • Locked Locked
  • Replies 8
  • Subscribers 125
  • Views 20960
  • 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

getting the number of points in a waveform, or the number of events...

MarkGr15
MarkGr15 over 10 years ago

I want to count the number of times an analog waveform crosses a threshold. It will do so , lets say 3 times, in a period in time (I am going to clip the time period in the Spectre calculator).

This is what I am trying, it creates a waveform (N time points, with associated values).

overCurrentXingsInClip1=cross(clip(VT("/fb_top1/I_buck_nonlinear/I0/overcurrent_det")  20u 40u ) 1.8/2 1 "rising"  t "time"  )

I want the number of time points.  Is there a way to get this?

The goal is to count the number of crossings, mind you. If there is another way to skin the cat, I'm open to that.

Thanks

Mark

  • Cancel
  • ShawnLogan
    ShawnLogan over 10 years ago

    Hi Mark,

    > I want the number of time points.  Is there a way to get this?

    I have used the cross() function but with the "cycle" argument in lieu of "time". I then determine the length of the vector. I've attached a sample of the code below.

    zcross_hsclki = cross(hsclki_clipped 0 0 "rising" t "cycle")

    xvector = drGetWaveformXVec(zcross_hsclki)

    xvector_length = drVectorLength(xvector)

    printf("Vector phase length = %d.\n" xvector_length)

    This might do what you want - assuming I understand your intent Mark!

    Shawn

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

    Actually this can be done more simply:

    overCurrentXingsInClip1=length(cross(clip(VT("/fb_top1/I_buck_nonlinear/I0/overcurrent_det")  20u 40u ) 1.8/2 0 "rising"  t "time"  ))

    The cross function can return a list of crossings if 0 is given as the edge number. Most calculator functions don't deal with lists, so we can use the SKILL length() function to measure the number of entries in the list.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • MarkGr15
    MarkGr15 over 10 years ago

    Andrew, 

    I cut and pasted your code, and got this error message:

    ocean> overCurrentXingsInClip1=length(cross(clip(VT("/fb_top1/I_buck_nonlinear/I0/overcurrent_det") 20u 40u ) 1.8/2 0 "rising" t "time" ))
    *Error* length: argument must be a list or an array - srrWave:0x213cb080
    ocean>

    Mark

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

    Hi Mark,

    Sorry, I didn't try your code, and so didn't notice that you had the "multiple occurrence" option set. Rather perversely, you need to have it set to "single occurrence" (which corresponds to having the last two arguments to the cross() function set to nil), and then it should work.

    The multiple occurrence feature was added at some point later, and will generate a waveform with all the crossing points - which would require you to use an approach similar to Shawn's suggestion, but if you use the older "single occurrence" capability, you can set the edge number to 0 and get a list of the crossings (which is normally not useful in the calculator because it can't deal with SKILL lists of stuff).

    So that should be:

    overCurrentXingsInClip1=length(cross(clip(VT("/fb_top1/I_buck_nonlinear/I0/overcurrent_det")  20u 40u ) 1.8/2 0 "rising" nil nil  ))

    Hopefully that will work for you!

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • MarkGr15
    MarkGr15 over 10 years ago
    Shawn, thanks! That works... I'd still like to know if Andrew's approach can be made to work , if possible.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    Unknown said:
    Shawn, thanks! That works... I'd still like to know if Andrew's approach can be made to work , if possible.

    Hopefully you can try my new suggestion - maybe you'd not seen that when you replied?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 10 years ago

    Great Mark! 

    Thank you for letting me know!

    I'm also going to keep Andrew's suggestion in my back pocket as it seems more efficient.

    Shawn

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

    Hi Andrew


    I have tried it out, it works.

    Besides, I take the concept from your "movingAvg", to make a moving version of counting the crossing point within a moving time window across the simulation time.

    the user application can be: counting the glitches before/after transition. And there is no need to specify when the transition happens.

    And it allows multiple transitions during the simulation.


    Best Regards

    Yi

    • 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