Home > Community > Forums > Custom IC SKILL > How do I clip a waveform vertically?

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: *

 How do I clip a waveform vertically? 

Last post Thu, Jul 4 2013 7:02 AM by Andrew Beckett. 1 replies.
Started by kitmonisit 03 Jul 2013 05:04 AM. Topic has 1 replies and 501 views
Page 1 of 1 (2 items)
Sort Posts:
  • Wed, Jul 3 2013 5:04 AM

    How do I clip a waveform vertically? Reply

    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.

    • Post Points: 20
  • Thu, Jul 4 2013 7:02 AM

    Re: How do I clip a waveform vertically? Reply

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

     


    • Post Points: 5
Page 1 of 1 (2 items)
Sort Posts:
Started by kitmonisit at 03 Jul 2013 05:04 AM. Topic has 1 replies.