• 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. Calculator custom function, SKILL script - output is not...

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 892
  • 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

Calculator custom function, SKILL script - output is not plotting

JDUAD
JDUAD 10 months ago

Hello,

My custom SKILL function is not properly working and I can't figure why the output vector is not plotting. Is somebody have some experience writting SKILL scirpt for calculator custom function ?

my code:

"

procedure(average_freq_on_periodic_sample(wave start stop period)

  cond(

    (drIsWaveform(wave)

      let((xVec yVec len lastXVal outXVec outYVec start_sample stop_sample sample outWave)

        xVec=drGetWaveformXVec(wave)
        yVec=drGetWaveformYVec(wave)
        len=drVectorLength(xVec)
        lastXVal=drGetElem(xVec len-1)
       

        outXVec= nil  
        outYVec= nil  
                     

        sample = 0

        for(i 0 (round lastXVal/period)-1
          start_sample = sample + start
          stop_sample = sample + stop
          outYVec = append( outYVec list(average(clip(VT("/clkout") start_sample stop_sample ))))
          outXVec = append( outXVec list(sample))
          sample = sample + period

          printf("%f \n", average(clip(VT("/clkout") start_sample stop_sample ) ))
      
        )
    printf("final ylist %L \n", outYVec)
  ;
      ;--------------------------------------------------------
      ; Construct final waveform, set expression and return
      ;--------------------------------------------------------
      outWave=drCreateWaveform(drCreateVec('double outXVec) drCreateVec('double outYVec))
      famSetExpr(outWave 'average_freq_on_periodic_sample(,famGetExpr(wave) ,start ,stop ,period))
      outWave

      )
    )

    (famIsFamily(wave)

      famMap('average_freq_on_periodic_sample wave start stop period)

    )

    (t

      error("myFunction cannot handle argument %L\n" wave)

    )
  )
)

"

Thanks!

  • Cancel
  • Andrew Beckett
    Andrew Beckett 10 months ago

    The first thing I saw was that inside the loop it's doing VT("/clkout")

              outYVec = append( outYVec list(average(clip(VT("/clkout") start_sample stop_sample ))))

    That would be rather odd for a calculator function to reference a fixed signal. My assumption is that you should be using wave at this point (it's also in the printf shortly afterwards). If I change it to wave then the function works (it's a bit slow though).

    It appears to be computing a periodic average, so maybe you can use this instead: Periodic Average function for ViVA calculator (written by me)?

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • JDUAD
    JDUAD 10 months ago in reply to Andrew Beckett

    Thank you Andrew, your correction solves my problem.

    This function's purpose is to perform periodic frequency average using frequency(clip(wave start_sample stop_sample) rather than the average(clip (wave start_sample stop_sample). However,  the output plot does not correspond to the calculus performed inside the function (different from print output). Do you have any clues on this issue?

    Regards,
    JDU

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett 10 months ago in reply to JDUAD

    I don't understand. Your code uses average (I thought that was a bit odd, since that doesn't chime with the function name) and the points produced in the waveform do match the information printed out within (I checked with an example).

    I can only assume that you've updated the code and something else is wrong? If so, please post the updated code, as guessing what might be wrong is rather difficult. Maybe you could also illustrate it with an example showing the problem?

    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