• 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. User Defined Skill Function - Alias Waveform

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 143
  • Views 5076
  • 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

User Defined Skill Function - Alias Waveform

mcunning
mcunning over 8 years ago

Hello,

I would like to create a function that performs ideal aliasing on the output waveform of a simulation (particularly output noise). In other words, I want all the nyquist bands within a specified frequency range to be folded down to the first nyquist zone. The best approach I could think of was to manually clip, shift, flip, and add the noise voltage within each nyquist band to each other. This works well, but high frequency aliasing requires a lot of equations.

Here is the waveform calculator formula of several additions (up to fourth nyquist) for reference:

(clip(Vno2 0 VAR("fnyq")) + rshift(flip(clip(Vno2 VAR("fnyq") (2 * VAR("fnyq")))) (2 * VAR("fnyq"))) + lshift(clip(Vno2 (2 * VAR("fnyq")) (3 * VAR ("fnyq"))) (2 * VAR("fnyq"))) + rshift(flip(clip(Vno2 (3 * VAR("fnyq")) (4 * VAR("fnyq")))) (4 * VAR("fnyq")))

where

Vno2 = (getData("out" ?result "noise")**2)

fnyq is defined in the design variables

I have also linked my attempt at a custom SKILL function, but it does not run. I don't have much background with SKILL, so I could have some bad code, but I've tried to follow the documentation and available scripts as best as possible.

I would appreciate it if someone could take a look at my code and help me debug it or present a better option. Thanks.

----------------------------------------------------------

mcAliasSignal.il

  • Cancel
Parents
  • mcunning
    mcunning over 8 years ago

    Thanks, the function works fine now (although formatting on here was more trouble than I expected):

    -------------------------------------------------

     

    /* AliasSignal.il

     

    Language   SKILL

    Date       Feb 20, 2017

    Modified   Mar 27, 2017

    By         M.L.Cunningham

     

     

    Performs an ideal aliasing of a signal. You specify the sampling

    frequency, half of which it (effectively) folds down all the signal

    into.

     

    ; register the AliasSignal() special function with the calculator

    RegAliasSignalSpecialFunction()

     

    ; example of usage:

    AliasSignal ((getData("out" ?result "noise")**2) 2G 1K 100G)

     

    NOTE: It is important that the appropriate signal be passed to the function (i.e. a power quantity).

    ****************************************************/

     

    /*******************************************************************************

    *  DISCLAIMER: The following code is provided for Cadence customers to use at  *

    *   their own risk. The code may require modification to satisfy the           *

    *   requirements of any user. The code and any modifications to the code may   *

    *   not be compatible with current or future versions of Cadence products.     *

    *   THE CODE IS PROVIDED "AS IS" AND WITH NO WARRANTIES, INCLUDING WITHOUT     *

    *   LIMITATION ANY EXPRESS WARRANTIES OR IMPLIED WARRANTIES OF MERCHANTABILITY *

    *   OR FITNESS FOR A PARTICULAR USE.                                           *

    *******************************************************************************/

     

     

    /***************************************************************

    *                                                              *

    *                 (CreateAliasSignalForm)                      *

    *                                                              *

    *            Create the form for the aliased signal            *

    *                                                              *

    ***************************************************************/

     

    (procedure (CreateAliasSignalForm)

      (let (fsample fmin fmax xVec startfreq endfreq len)

           (setq fsample (ahiCreateStringField

                      ?name 'fsample

                      ?prompt "Sampling Frequency"

                      ?value ""

                      ))

           (setq fmin (ahiCreateStringField

                      ?name 'fmin

                      ?prompt "Min Freq"

                      ?value "0"

                      ))

           (setq fmax (ahiCreateStringField

                      ?name 'fmax

                      ?prompt "Max Freq"

                      ?value "1G"

                      ))

           (calCreateSpecialFunctionsForm

           'AliasSignalForm

           (list

             (list fsample 0:0  210:20 130)

             (list fmin 0:30  210:20 130)

              (list fmax 0:60  210:20 130)

           )

           )

      )

    )

     

    /********************************************************************

    *                                                                   *

    *                 (AliasSignalSpecialFunctionCB)                    *

    *                                                                   *

    *  Callback for the alias signal special function, which assembles  *

    *                the expression from the form values                *

    *                                                                   *

    ********************************************************************/

     

    (procedure (AliasSignalSpecialFunctionCB)

      (calCreateSpecialFunction

       ?formSym 'AliasSignalForm

       ?formInitProc 'CreateAliasSignalForm

       ?formTitle "Alias Signal"

       ?formCallback "calSpecialFunctionInput( 'AliasSignal '(fsample fmin fmax))"

       ))

     

    /***************************************************************

    *                                                              *

    *              (RegAliasSignalSpecialFunction)                 *

    *                                                              *

    *              Register the alias signal function              *

    *                                                              *

    ***************************************************************/

     

    (procedure (RegAliasSignalSpecialFunction)

      (calRegisterSpecialFunction

       (list "AliasSignal" 'AliasSignalSpecialFunctionCB))

      t

      )

     

    /***************************************************************

    *                                                              *

    *          (AliasSignal waveform fsample fmin fmax)            *

    *                                                              *

    *   Given a waveform, a sampling freq, and freq range compute  *

    *   the aliased signal.                                        *

    *                                                              *

    ***************************************************************/

     

    procedure(AliasSignal(waveform fsample fmin fmax)

     cond(

     

     ;---------------------------------------------------------------------

     ; Handle ordinary waveform

     ;---------------------------------------------------------------------

     (drIsWaveform(waveform)

       let((len lastX sourceYVec xVec yVec clippedwave (result 0) nyqband nmax)

     

     ;------------------------------------------------------------------

     ; Clip the signal and alias the signal in the range specified

     ;------------------------------------------------------------------

       clippedwave=clip(waveform fmin fmax)

       xVec=drGetWaveformXVec(clippedwave)

       len=drVectorLength(xVec)

       lastX=drGetElem(xVec sub1(len))

     

     ; Find the maximum nyquist sideband

       nmax=ceiling(lastX/(fsample/2.0))

     

     ; Sum all of the signal of the clipped waveform into 1st nyquist

       for(n 0 nmax-1

         nyqband=

       if(oddp(n) then

         rshift(flip(clip(clippedwave n*fsample/2 (n+1)*fsample/2)) (n+1)*fsample/2)

       else

         lshift(clip(clippedwave n*fsample/2 (n+1)*fsample/2) n*fsample/2)

       )

         result=result+nyqband

         result=clip(result fmin fsample/2)

       )

     

     ;------------------------------------------------------------------

     ; Copy units and axis name across from source waveform

     ;------------------------------------------------------------------

     

       sourceYVec=drGetWaveformYVec(waveform)

       yVec=drGetWaveformYVec(result)

       yVec->units=sourceYVec->units

       yVec->name=sourceYVec->name result

       )

     ) ; waveform

     

     ;---------------------------------------------------------------------

     ; Handle family

     ;---------------------------------------------------------------------

     

     (famIsFamily(waveform)

     famMap('AliasSignal waveform fsample fmin fmax) )

     ; family

     (t

     error("AliasSignal - can't handle %L\n" waveform)

     )

     ) ; cond

    )

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • mcunning
    mcunning over 8 years ago

    Thanks, the function works fine now (although formatting on here was more trouble than I expected):

    -------------------------------------------------

     

    /* AliasSignal.il

     

    Language   SKILL

    Date       Feb 20, 2017

    Modified   Mar 27, 2017

    By         M.L.Cunningham

     

     

    Performs an ideal aliasing of a signal. You specify the sampling

    frequency, half of which it (effectively) folds down all the signal

    into.

     

    ; register the AliasSignal() special function with the calculator

    RegAliasSignalSpecialFunction()

     

    ; example of usage:

    AliasSignal ((getData("out" ?result "noise")**2) 2G 1K 100G)

     

    NOTE: It is important that the appropriate signal be passed to the function (i.e. a power quantity).

    ****************************************************/

     

    /*******************************************************************************

    *  DISCLAIMER: The following code is provided for Cadence customers to use at  *

    *   their own risk. The code may require modification to satisfy the           *

    *   requirements of any user. The code and any modifications to the code may   *

    *   not be compatible with current or future versions of Cadence products.     *

    *   THE CODE IS PROVIDED "AS IS" AND WITH NO WARRANTIES, INCLUDING WITHOUT     *

    *   LIMITATION ANY EXPRESS WARRANTIES OR IMPLIED WARRANTIES OF MERCHANTABILITY *

    *   OR FITNESS FOR A PARTICULAR USE.                                           *

    *******************************************************************************/

     

     

    /***************************************************************

    *                                                              *

    *                 (CreateAliasSignalForm)                      *

    *                                                              *

    *            Create the form for the aliased signal            *

    *                                                              *

    ***************************************************************/

     

    (procedure (CreateAliasSignalForm)

      (let (fsample fmin fmax xVec startfreq endfreq len)

           (setq fsample (ahiCreateStringField

                      ?name 'fsample

                      ?prompt "Sampling Frequency"

                      ?value ""

                      ))

           (setq fmin (ahiCreateStringField

                      ?name 'fmin

                      ?prompt "Min Freq"

                      ?value "0"

                      ))

           (setq fmax (ahiCreateStringField

                      ?name 'fmax

                      ?prompt "Max Freq"

                      ?value "1G"

                      ))

           (calCreateSpecialFunctionsForm

           'AliasSignalForm

           (list

             (list fsample 0:0  210:20 130)

             (list fmin 0:30  210:20 130)

              (list fmax 0:60  210:20 130)

           )

           )

      )

    )

     

    /********************************************************************

    *                                                                   *

    *                 (AliasSignalSpecialFunctionCB)                    *

    *                                                                   *

    *  Callback for the alias signal special function, which assembles  *

    *                the expression from the form values                *

    *                                                                   *

    ********************************************************************/

     

    (procedure (AliasSignalSpecialFunctionCB)

      (calCreateSpecialFunction

       ?formSym 'AliasSignalForm

       ?formInitProc 'CreateAliasSignalForm

       ?formTitle "Alias Signal"

       ?formCallback "calSpecialFunctionInput( 'AliasSignal '(fsample fmin fmax))"

       ))

     

    /***************************************************************

    *                                                              *

    *              (RegAliasSignalSpecialFunction)                 *

    *                                                              *

    *              Register the alias signal function              *

    *                                                              *

    ***************************************************************/

     

    (procedure (RegAliasSignalSpecialFunction)

      (calRegisterSpecialFunction

       (list "AliasSignal" 'AliasSignalSpecialFunctionCB))

      t

      )

     

    /***************************************************************

    *                                                              *

    *          (AliasSignal waveform fsample fmin fmax)            *

    *                                                              *

    *   Given a waveform, a sampling freq, and freq range compute  *

    *   the aliased signal.                                        *

    *                                                              *

    ***************************************************************/

     

    procedure(AliasSignal(waveform fsample fmin fmax)

     cond(

     

     ;---------------------------------------------------------------------

     ; Handle ordinary waveform

     ;---------------------------------------------------------------------

     (drIsWaveform(waveform)

       let((len lastX sourceYVec xVec yVec clippedwave (result 0) nyqband nmax)

     

     ;------------------------------------------------------------------

     ; Clip the signal and alias the signal in the range specified

     ;------------------------------------------------------------------

       clippedwave=clip(waveform fmin fmax)

       xVec=drGetWaveformXVec(clippedwave)

       len=drVectorLength(xVec)

       lastX=drGetElem(xVec sub1(len))

     

     ; Find the maximum nyquist sideband

       nmax=ceiling(lastX/(fsample/2.0))

     

     ; Sum all of the signal of the clipped waveform into 1st nyquist

       for(n 0 nmax-1

         nyqband=

       if(oddp(n) then

         rshift(flip(clip(clippedwave n*fsample/2 (n+1)*fsample/2)) (n+1)*fsample/2)

       else

         lshift(clip(clippedwave n*fsample/2 (n+1)*fsample/2) n*fsample/2)

       )

         result=result+nyqband

         result=clip(result fmin fsample/2)

       )

     

     ;------------------------------------------------------------------

     ; Copy units and axis name across from source waveform

     ;------------------------------------------------------------------

     

       sourceYVec=drGetWaveformYVec(waveform)

       yVec=drGetWaveformYVec(result)

       yVec->units=sourceYVec->units

       yVec->name=sourceYVec->name result

       )

     ) ; waveform

     

     ;---------------------------------------------------------------------

     ; Handle family

     ;---------------------------------------------------------------------

     

     (famIsFamily(waveform)

     famMap('AliasSignal waveform fsample fmin fmax) )

     ; family

     (t

     error("AliasSignal - can't handle %L\n" waveform)

     )

     ) ; cond

    )

    • 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