• 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 to deal with multiple waveform families as input for...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 14915
  • 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 to deal with multiple waveform families as input for the special functions defined for calculator

fatcat1206
fatcat1206 over 9 years ago

Hi All

I am developing a special function used in the calculator. It would process 2 waveforms.

I have finished the code if the 2 waveforms are single "waveform" (drIsWaveform() ==> t).

I met some difficulties when the input waveforms are "family" (famIsFamiliy() ==>t).

I take a look on the existing example of the special function, there the "family" waveform is handle by "famMap()" function.

Unfortunately, such function can only map the defined special function to 1 waveform, not 2.

I did some research inside the community, and found the function "abUnwrapFamily()", provided by Andrew Beckett; it would unwrap the "family" and return a list of "waveform".

It helps to deal the situation when the input arguments are "family".

The consequence is that, as during the "unwrap" of the family, the hierarchical structure of sweepName and sweepValue is gone.

Then when I try to split the strips inside the VIVA, I cannot split the output waveforms based on the sweep parameter.

I'd like to know, is there a more proper way to deal with multiple family waveforms as the input argument for the special function in the calculator.

Best Regards

Yi

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    Hi Yi,

    If the first argument is a family, and subsequent arguments are families, they should be expanded too at the same time - there's no need to use abUnwrapFamily() - I've had to use that in special cases only to solve specific issues - but not when I'm expecting to provide a consistent result in ADE. 

    See the example below - this should work with two families passed in (provided the families are consistent - I've not tested how this works with heterogenous data):

    /* abApplyToTwoWaves.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       May 28, 2014 
    Modified   
    By         
    
    NOTE: Doesn't work that well yet... (mainly calculator bit,
    function itself is fine)
    
    Function to apply a binary function (i.e. two arguments) to
    every element of a pair of waveforms. For example:
    
    abApplyToTwoWaves(lambda((a b) if(abs(a)<abs(b) a-b 0.0)) wave1 wave2)
    
    or
    
    abApplyToTwoWaves('myFunc wave1 wave2)
    
    (where myFunc takes two arguments and operates on numbers, say).
    
    Can also add to the Skill User Defined Function using:
    
    abRegApplyToTwoWavesSpecialFunction()
    
    ***************************************************
    
    SCCS Info: @(#) abApplyToTwoWaves.il 05/28/14.16:30:05 1.1
    
    */
    
    /***************************************************************
    *                                                              *
    *                (abCreateApplyToTwoWavesForm)                 *
    *                                                              *
    *      Create the form needed to enter the function name       *
    *                                                              *
    ***************************************************************/
    (defun abCreateApplyToTwoWavesForm ()
      (let (func)
        (setq func (ahiCreateStringField
                     ?name 'func
                     ?prompt "Function"
                     ?value "plus"
                     )
              )
        (calCreateSpecialFunctionsForm
          'abApplyToTwoWavesForm
          (list (list func 0:0 280:20 140))
          )
        )
      )
    
    /***************************************************************
    *                                                              *
    *             (abApplyToTwoWavesSpecialFunctionCB)             *
    *                                                              *
    *            Callback for the registration function            *
    *                                                              *
    ***************************************************************/
    (defun abApplyToTwoWavesSpecialFunctionCB ()
      (calCreateSpecialFunction
        ?formSym 'abApplyToTwoWavesForm
        ?formInitProc 'abCreateApplyToTwoWavesForm
        ?formTitle "Apply to Wave"
        ?formCallback "abApplyToTwoWavesFormCB()"
        )
      )
    
    /********************************************************************
    *                                                                   *
    *                     (abApplyToTwoWavesFormCB)                     *
    *                                                                   *
    * 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 abApplyToTwoWavesFormCB ()
      (let (form)
        (setq form (hiGetCurrentForm))
        ; messy - because can't build expression easily.
        (calCalcInput
          'expression
          (sprintf nil "' %s %s"
                   (concat (getq (getq form func) value))
                   (calGetBuffer))
          )
        (calSpecialFunctionInput 'abApplyToTwoWaves list('STACK))
        t
        )
      )
    
    /******************************************************************
    *                                                                 *
    *              (abRegApplyToTwoWavesSpecialFunction)              *
    *                                                                 *
    * Function to actually register the user defined special function *
    *                                                                 *
    ******************************************************************/
    (defun abRegApplyToTwoWavesSpecialFunction ()
      (calRegisterSpecialFunction
        (list "abApplyToTwoWaves" 'abApplyToTwoWavesSpecialFunctionCB)
        )
      t
      )
    
    /******************************************************************
    *                                                                 *
    *                 (abApplyToTwoWaves func arg)                    *
    *                                                                 *
    *  And finally, the function that does the work. You give it the  *
    *  name of a binary function (takes two arguments) which works on *
    *    numbers, and then this is applied to all members of the two  *
    *                waveforms. Handles families too.                 *
    *                                                                 *
    ******************************************************************/
    (defun abApplyToTwoWaves (func arg1 arg2)
      (cond 
        ((numberp arg1) (funcall func arg1 arg2))
        ((drIsDataVector arg1) (vecMap 'abApplyToTwoWaves func arg1 arg2))
        ((drIsWaveform arg1) 
         ;-------------------------------------------------------------------
         ; 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 'abApplyToTwoWaves func arg1 arg2))
           (setq yVec (drGetWaveformYVec new))
           (unless (getq yVec units)
             (putpropq yVec (getq (drGetWaveformYVec arg1) units) units)
             )
           new
           )
         )
        ((famIsFamily arg1) (famMap 'abApplyToTwoWaves func arg1 arg2))
        (t
          (error "abApplyToTwoWaves: can't apply %L to %L and %L\n"
                 func arg1 arg2)
          )
        )
      )
    

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • fatcat1206
    fatcat1206 over 9 years ago
    Hi Andrew

    Thank you for the reply.
    I give it for a try, it works.
    This make the situation much easier.

    Maybe you can add this comment and example into the document.

    Best Regards

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