/* abSumValues.il Group Custom IC (UK), Cadence Design Systems Ltd. Language SKILL Date Oct 15, 2018 Modified Three calculator functions to help with analysing sampled data - also useful for multi-sample transient noise measurements (e.g. counting the number of transient noise runs where an output was high) abSumValues(wave) abCountGreaterThan(wave threshold) abCountLessThan(wave threshold) To add all three to the calculator, use the "fx" button in the calculator or expression builder - the definition for the form is included in the code below. *************************************************** SCCS Info: @(#) abSumValues.il 10/15/18.10:33:24 1.1 */ /***************************************************************** * * * (abSumValues wave) * * * * Sum the y values, ignoring the x values. Useful for sampled * * data as it purely adds up the y values rather than integrating * * * *****************************************************************/ (defun abSumValues (wave) (cond ((drIsWaveform wave) (let (len yVec (sum 0)) (setq yVec (drGetWaveformYVec wave)) (setq len (drVectorLength yVec)) (for i 0 (sub1 len) (setq sum (plus sum (drGetElem yVec i))) ) sum)) ((famIsFamily wave) (famMap 'abSumValues wave)) (t (error "abSumValues - can't handle %L\n" wave) ) ) ) /*************************************************************** * * * (abCountGreaterThan wave threshold) * * * * Count the number of y values which are greater than the * * specified threshold * * * ***************************************************************/ (defun abCountGreaterThan (wave threshold) (cond ((drIsWaveform wave) (let (len yVec (sum 0)) (setq yVec (drGetWaveformYVec wave)) (setq len (drVectorLength yVec)) (for i 0 (sub1 len) (when (greaterp (drGetElem yVec i) threshold) (postincrement sum) )) sum)) ((famIsFamily wave) (famMap 'abCountGreaterThan wave)) (t (error "abCountGreaterThan - can't handle %L\n" wave) ) ) ) /***************************************************************** * * * (abCountLessThan wave threshold) * * * * Count the number of y values which are less than the specified * * threshold * * * *****************************************************************/ (defun abCountLessThan (wave threshold) (cond ((drIsWaveform wave) (let (len yVec (sum 0)) (setq yVec (drGetWaveformYVec wave)) (setq len (drVectorLength yVec)) (for i 0 (sub1 len) (when (lessp (drGetElem yVec i) threshold) (postincrement sum) )) sum)) ((famIsFamily wave) (famMap 'abCountLessThan wave)) (t (error "abCountLessThan - can't handle %L\n" wave) ) ) ) ; ;;;;;;;;;;;;;;;;;;;;;;;;;; GUI builder information ;;;;;;;;;;;;;;;;;;;;;;;;;;; ocnmRegGUIBuilder( '(nil function abSumValues name abSumValues description "Sum the y values, ignoring x values" category ("Custom Functions") analysis (nil general (nil args (wave ) signals (nil wave (nil prompt "Waveform" tooltip "Waveform" ) ) params(nil ) inputrange t ) ) outputs(result) ) ) ; ;;;;;;;;;;;;;;;;;;;;;;;;;; GUI builder information ;;;;;;;;;;;;;;;;;;;;;;;;;;; ocnmRegGUIBuilder( '(nil function abCountGreaterThan name abCountGreaterThan description "Count the number of y values greater than threshold" category ("Custom Functions") analysis (nil general (nil args (wave threshold ) signals (nil wave (nil prompt "Waveform" tooltip "Waveform" ) ) params(nil threshold (nil prompt "Threshold" tooltip "Threshold" guiRowHint 1 type float default 0.0 required t ) ) inputrange t ) ) outputs(result) ) ) ; ;;;;;;;;;;;;;;;;;;;;;;;;;; GUI builder information ;;;;;;;;;;;;;;;;;;;;;;;;;;; ocnmRegGUIBuilder( '(nil function abCountLessThan name abCountLessThan description "Count the number of y values less than the threshold" category ("Custom Functions") analysis (nil general (nil args (wave threshold ) signals (nil wave (nil prompt "Waveform" tooltip "Waveform" ) ) params(nil threshold (nil prompt "Threshold" tooltip "Threshold" guiRowHint 1 type float default 0.0 required t ) ) inputrange t ) ) outputs(result) ) )