• 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
  • AMSboston
    AMSboston over 15 years ago
    Andrew,
    Thanks a lot for your help.
    I modified the code below to also recalculate newFreq0.
    When I do so I get the correct result.
    The purpose of this code is to find the HD of signals that are above Nyquist and therefore I had to recalculate freq0 & freqN.
    If you get a chance maybe you can explain the following:
    I actually don't understand the syntax of the solution.
    If the condition that it's a family is satisfied then famMap iterates over every Waveform in the family and calculates a newFreq, which it then applies to the DFT function.
    The syntax is confusing because famMap calls CCSharmonicDistNEW from within CCSharmonicDistNEW.
    How does it work? (I realize this may be a dumb question because it works by recursion, so maybe nothing needs to be said:)
    Thanks for your help!
    ##############################################################################
    procedure( CCSharmonicDistNEW( tranwave dftFrom dftTo numSample freqN freq0)
      cond(
       ; handle ordinary waveforms
       (drIsWaveform(tranwave)
         let( (res dftwave newFreqN newFreq0)
           dftwave = dft(tranwave,dftFrom ,dftTo,numSample,"Rectangular",1,1)
           newFreqN=abs(round(freqN/250e6)*250e6-freqN)
           newFreq0=abs(round(freq0/250e6)*250e6-freq0)
           res = db20( mag(value(dftwave newFreqN))/mag(value(dftwave newFreq0)))
           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)
       )
      )
    )
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • AMSboston
    AMSboston over 15 years ago
    Andrew,
    Thanks a lot for your help.
    I modified the code below to also recalculate newFreq0.
    When I do so I get the correct result.
    The purpose of this code is to find the HD of signals that are above Nyquist and therefore I had to recalculate freq0 & freqN.
    If you get a chance maybe you can explain the following:
    I actually don't understand the syntax of the solution.
    If the condition that it's a family is satisfied then famMap iterates over every Waveform in the family and calculates a newFreq, which it then applies to the DFT function.
    The syntax is confusing because famMap calls CCSharmonicDistNEW from within CCSharmonicDistNEW.
    How does it work? (I realize this may be a dumb question because it works by recursion, so maybe nothing needs to be said:)
    Thanks for your help!
    ##############################################################################
    procedure( CCSharmonicDistNEW( tranwave dftFrom dftTo numSample freqN freq0)
      cond(
       ; handle ordinary waveforms
       (drIsWaveform(tranwave)
         let( (res dftwave newFreqN newFreq0)
           dftwave = dft(tranwave,dftFrom ,dftTo,numSample,"Rectangular",1,1)
           newFreqN=abs(round(freqN/250e6)*250e6-freqN)
           newFreq0=abs(round(freq0/250e6)*250e6-freq0)
           res = db20( mag(value(dftwave newFreqN))/mag(value(dftwave newFreq0)))
           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)
       )
      )
    )
    • 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