• 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. Harmonic Parametric

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 14166
  • 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

Harmonic Parametric

AMSboston
AMSboston over 15 years ago

Hi,

Below is a SKILL  to find the Harmonic Frequency distortion level.

If I run a single simulation I get the correct answer.

 However, if I run a Parametric Sweep of VAR("fin") I get the following error:

*Error* round: argument #1 should be a number (type template = "n") - drwave:213939744.

 I get the error because "FreqN" is a vector.

How do I modify the script below such that it can handle a Parametric Sweep?

BTW, if freqN was a list or a vector I could make the code work with a foreach command.

However, freqN is not a list, nor is it a vector.

What is it?

####################################################################### 

procedure( CCSharmonicDistNEW( tranwave dftFrom dftTo numSample freqN freq0)
     let( (res dftwave newFreqN)
     dftwave = dft(tranwave,dftFrom ,dftTo,numSample,"Rectangular",1,1)
newFreqN=abs(round(freqN/250e6)*250e6-freqN)
     res = db20( mag(value(dftwave newFreqN))/mag(value(dftwave freq0)))
     res
)
)

 ocnPrint(CCSharmonicDistNEW(VT("/XQDCA/RECONSTRUCTED") 42.2n 298.2n 64 3*VAR("fin") VAR("fin")))
############################################################################################

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 15 years ago

    Note I have not tested this, but this is the approach normally taken:

    procedure( CCSharmonicDistNEW( tranwave dftFrom dftTo numSample freqN freq0)
      cond(
       ; handle ordinary waveforms
       (drIsWaveform(tranwave)
         let( (res dftwave newFreqN)
           dftwave = dft(tranwave,dftFrom ,dftTo,numSample,"Rectangular",1,1)
           newFreqN=abs(round(freqN/250e6)*250e6-freqN)
           res = db20( mag(value(dftwave newFreqN))/mag(value(dftwave freq0)))
           res
         )
       )
       ; and family waveforms
       (famIsFamily(tranwave)
         famMap('CCSharmonicDistNEW tranwave dftFrom dftTo numSample freqN freq0)
       )
       ; oh dear, help!
       (t
         error("CCSharmonicDistNEW - can't handle %L\n" tranwave)
       )
      )
    )
    

    The idea is that you use famMap to iterate over the family members (recursively) - hence the cond() to determine if the waveform is a family. As each family member is visited by famMap, it will call the function with the inner level, and do the same thing again, until it reaches a conventional waveform. Then as the famMap returns, it will collect all the results into families, and so on.

    There are a few examples of using this on Cadence Online Support.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 15 years ago

    Note I have not tested this, but this is the approach normally taken:

    procedure( CCSharmonicDistNEW( tranwave dftFrom dftTo numSample freqN freq0)
      cond(
       ; handle ordinary waveforms
       (drIsWaveform(tranwave)
         let( (res dftwave newFreqN)
           dftwave = dft(tranwave,dftFrom ,dftTo,numSample,"Rectangular",1,1)
           newFreqN=abs(round(freqN/250e6)*250e6-freqN)
           res = db20( mag(value(dftwave newFreqN))/mag(value(dftwave freq0)))
           res
         )
       )
       ; and family waveforms
       (famIsFamily(tranwave)
         famMap('CCSharmonicDistNEW tranwave dftFrom dftTo numSample freqN freq0)
       )
       ; oh dear, help!
       (t
         error("CCSharmonicDistNEW - can't handle %L\n" tranwave)
       )
      )
    )
    

    The idea is that you use famMap to iterate over the family members (recursively) - hence the cond() to determine if the waveform is a family. As each family member is visited by famMap, it will call the function with the inner level, and do the same thing again, until it reaches a conventional waveform. Then as the famMap returns, it will collect all the results into families, and so on.

    There are a few examples of using this on Cadence Online Support.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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