• 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. How do I clip a waveform vertically?

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 143
  • Views 18375
  • 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

How do I clip a waveform vertically?

kitmonisit
kitmonisit over 12 years ago

It is possible to clip a waveform along the x-axis using the clip function. How do I perform a clip along the y-axis?

I'm trying to separately take the integral of all positive values and all negative values of a waveform, and vertical clipping is how I thought I'd do it.

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    Don't think there's anything built in, but easy enough to implement something using the code below.

    For example, define:

    procedure(MyClipVal(val) cond((val<1 1) (val>4 4) (t val)))

    This is clipping anything below 1 or above 4. Then load the code below, and call abRegApplyToWaveSpecialFunction().

    You can then have your waveform in the calculator, bring up the SKILL User Defined Functions, pick abApplyToWave, and enter the function name as MyClipVal. See the attached picture which shows this in action.

    /* abApplyToWave.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       May 24, 2011 
    Modified   A.D.Beckett 
    By         May 31, 2011 
    
    Function to apply a unary function to every element
    in a waveform. For example:
    
    abApplyToWave('round waveform)
    
    Can also add to the Skill User Defined Function using:
    
    abRegApplyToWaveSpecialFunction()
    
    ***************************************************
    
    SCCS Info: @(#) abApplyToWave.il 05/31/11.17:24:41 1.2
    
    */
    
    /***************************************************************
    *                                                              *
    *                  (abCreateApplyToWaveForm)                   *
    *                                                              *
    *      Create the form needed to enter the function name       *
    *                                                              *
    ***************************************************************/
    (defun abCreateApplyToWaveForm ()
      (let (func)
        (setq func (ahiCreateStringField
                     ?name 'func
                     ?prompt "Function"
                     ?value "round"
                     )
              )
        (calCreateSpecialFunctionsForm
          'abApplyToWaveForm
          (list (list func 0:0 280:20 140))
          )
        )
      )
    
    /***************************************************************
    *                                                              *
    *               (abApplyToWaveSpecialFunctionCB)               *
    *                                                              *
    *            Callback for the registration function            *
    *                                                              *
    ***************************************************************/
    (defun abApplyToWaveSpecialFunctionCB ()
      (calCreateSpecialFunction
        ?formSym 'abApplyToWaveForm
        ?formInitProc 'abCreateApplyToWaveForm
        ?formTitle "Apply to Wave"
        ?formCallback "abApplyToWaveFormCB()"
        )
      )
    
    /********************************************************************
    *                                                                   *
    *                       (abApplyToWaveFormCB)                       *
    *                                                                   *
    * Callback for the form. Bit complicated because need the arguments *
    * to be with the waveform not first, and with a single quote before *
    *                        the function name.                         *
    *                                                                   *
    ********************************************************************/
    (defun abApplyToWaveFormCB ()
      (let (form)
        (setq form (hiGetCurrentForm))
        (calCalcInput
          'expression
          (sprintf nil "abApplyToWave('%s %s)"
                   (concat (getq (getq form func) value))
                   (calGetBuffer))
          )
        t
        )
      )
    
    /******************************************************************
    *                                                                 *
    *                (abRegApplyToWaveSpecialFunction)                *
    *                                                                 *
    * Function to actually register the user defined special function *
    *                                                                 *
    ******************************************************************/
    (defun abRegApplyToWaveSpecialFunction ()
      (calRegisterSpecialFunction
        (list "abApplyToWave" 'abApplyToWaveSpecialFunctionCB)
        )
      t
      )
    
    /******************************************************************
    *                                                                 *
    *                    (abApplyToWave func arg)                     *
    *                                                                 *
    *  And finally, the function that does the work. You give it the  *
    *  name of a unary function (takes one argument) which works on   *
    * numbers, and then this is applied to all members of a waveform. *
    *                      Handles families too.                      *
    *                                                                 *
    ******************************************************************/
    (defun abApplyToWave (func arg)
      (cond 
        ((numberp arg) (funcall func arg))
        ((drIsDataVector arg) (vecMap 'abApplyToWave func arg))
        ((drIsWaveform arg) 
         ;-------------------------------------------------------------------
         ; Create new waveform, but transfer units if not set on 
         ; new waveform already. This ensures plotting on the same y-axis
         ;-------------------------------------------------------------------
         (let (new yVec)
           (setq new (wfMap 'abApplyToWave func arg))
           (setq yVec (drGetWaveformYVec new))
           (unless (getq yVec units)
             (putpropq yVec (getq (drGetWaveformYVec arg) units) units)
             )
           new
           )
         )
        ((famIsFamily arg) (famMap 'abApplyToWave func arg))
        (t
          (error "abApplyToWave: can't apply %L to %L\n"
                 func arg)
          )
        )
      )

     

    • clipped.png
    • View
    • Hide
    • 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