• 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 5075
  • 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
  • Andrew Beckett
    Andrew Beckett over 8 years ago

    A few things:

    1. I'd probably avoid using the prefix "ab" as it tends to mean that people see the code and think it came from me (which it didn't here). Use your own initials or a unique prefix for your company.
    2. You could potentially do this using a "sampled" pnoise analysis which inserts an ideal sampler in the output of the circuit which would cause the noise to be aliased. 
    3. There were a few things that were wrong - you had some parts of the code referencing the wrong waveform, you were using sum() - which isn't a function, and there were odd mistakes here and there. Anyway, I rewrote the code in C-style (probably easier to read if you're not familiar with LISP) and corrected it. I think this is OK now...
    /***************************************************************
    *                                                              *
    *           (abAliasSignal waveform fsample fmin fmax)         *
    *                                                              *
    * Given a waveform, a sampling freq, and freq range compute    *
    *                     the aliased signal.                      *
    *                                                              *
    ***************************************************************/
    procedure(abAliasSignal(waveform fsample fmin fmax)
      cond(
        ;---------------------------------------------------------------------
        ; Handle ordinary waveform
        ;---------------------------------------------------------------------
        (drIsWaveform(waveform)
          let((len lastX sourceYVec xVec yVec clippedwave (result 0) resultnew
              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=floor(lastX/(fsample/2.0))
            ; Sum all of the signal of the clipped waveform into 1st nyquist
            for(n 0 nmax-1
              resultnew=
                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+resultnew
            )
            ;------------------------------------------------------------------
            ; 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('abAliasSignal waveform fsample fmin fmax)
        ) ; family
        (t
          error("abAliasSignal - can't handle %L\n" waveform)
        )
      ) ; cond
    )

    Regards,

    Andrew.

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

    Thanks for the fixes, Andrew. I will also give the pnoise option a try.

    I thought the "ab" was for your initials, but I wasn't sure - I will remove that from the code and update the file later.

    --

    I can follow your code and everything looks good to me, but when I click on the function in the calculator, no form appears. Did you see anything wrong in the rest of the code?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 8 years ago

    Hi Michael,

    Before I look at that, which IC version are you using? There is an easier way in IC617 which means you don't have to write the form code...

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • mcunning
    mcunning over 8 years ago
    Version IC6.1.6
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 8 years ago

    It's in the code that builds the form:

    You need to not reference "waveform" because that's not known when the form is launched (the errors are suppressed by default - you can re-enable them using sstatus(errsetTrace t)). So I commented these four lines out and made the fmin/fmax values fixed defaults.

    (procedure (abCreateAliasSignalForm)
      (let (fsample fmin fmax xVec startfreq endfreq len)
           (setq fsample (ahiCreateStringField
    		    ?name 'fsample
    		    ?prompt "Sampling Frequency"
    		    ?value ""
    		    ))
           /*
           (setq xVec (drGetWaveformXVec waveform))
           (setq len drVectorLength(xVec))
           (setq startfreq (drGetElem xVec 0))
           (setq endfreq (drGetElem xVec (sub1 len)))
           */
           (setq fmin (ahiCreateStringField
    		    ?name 'fmin
    		    ?prompt "Min Freq"
    		    ?value "0"
    		    ))
           (setq fmax (ahiCreateStringField
    		    ?name 'fmax
    		    ?prompt "Max Freq"
    		    ?value "1G"
    		    ))
           (calCreateSpecialFunctionsForm
    	'abAliasSignalForm
    	(list
     
    	  (list fsample 0:0  180:20 90)
    	  (list fmin 0:30  180:20 90)
              (list fmax 0:60  180:20 90)
    	)
           )
      )
    )


    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • 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

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