• 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
  • 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
Reply
  • 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
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