Home > Community > Forums > Custom IC SKILL > Harmonic Parametric

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Harmonic Parametric 

Last post Fri, Dec 4 2009 1:05 PM by AMSboston. 5 replies.
Started by AMSboston 02 Dec 2009 12:02 PM. Topic has 5 replies and 1466 views
Page 1 of 1 (6 items)
Sort Posts:
  • Wed, Dec 2 2009 12:02 PM

    • AMSboston
    • Not Ranked
    • Joined on Fri, Nov 27 2009
    • Posts 5
    • Points 70
    Harmonic Parametric Reply

    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")))
    ############################################################################################

    • Post Points: 20
  • Fri, Dec 4 2009 7:58 AM

    Re: Harmonic Parametric Reply

    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.

    • Post Points: 20
  • Fri, Dec 4 2009 11:06 AM

    • AMSboston
    • Not Ranked
    • Joined on Fri, Nov 27 2009
    • Posts 5
    • Points 70
    Re: Harmonic Parametric Reply
    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)
       )
      )
    )
    • Post Points: 20
  • Fri, Dec 4 2009 11:48 AM

    Re: Harmonic Parametric Reply
    Hi Dan,

    In pseudo code, famMap does:

    result=emptyFamily()
    foreach(familyMember tranwave
    indivResult=CCSharmonicDistNEW(familyMember dftFrom ...)
    addToFamily(result indivResult)
    )

    famMap essentially loops over the members of its second argument, calling the named function with all the specified arguments (but tranwave is replaced by the family member).

    So if you have a single dimensional family (a family of waveforms), it calls itself with each waveform in turn, and constructs either a waveform (if the result is a scalar) or a family (if the result is a wave).

    For families of families, it's going to peel one layer off at a time as it recursively calls the function with one fewer layer.

    Hope that helps to clarify it?

    Regards,

    Andrew
    • Post Points: 5
  • Fri, Dec 4 2009 12:25 PM

    Re: Harmonic Parametric Reply
    Apologies for the lack of indenting - the perils of replying via email.

    Regards,

    Andrew
    • Post Points: 20
  • Fri, Dec 4 2009 1:05 PM

    • AMSboston
    • Not Ranked
    • Joined on Fri, Nov 27 2009
    • Posts 5
    • Points 70
    RE: Harmonic Parametric Reply
    Andrew,
    Thanks.
    • Post Points: 5
Page 1 of 1 (6 items)
Sort Posts:
Started by AMSboston at 02 Dec 2009 12:02 PM. Topic has 5 replies.