• 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 properly handle wave family in custom calculator...

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 143
  • Views 16481
  • 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 properly handle wave family in custom calculator function

alexstepanov75
alexstepanov75 over 7 years ago

Hi,

I needed a function that will resample waveform using points from another waveform.

So I wrote function below:

;Function to resample sourceWave by points from pointsWave
;sourceWave waveform to be resamled
;pointsWave from this waveform points taken to resample sourceWave
procedure( resampleByWave(sourceWave pointsWave)
let( (xVec yVec wave yFactor numOfPoints thisX sweepVal i sweepName sweepValues currentSourceWave currentPointsWave sweepValType)
cond(
(drIsWaveform(sourceWave)
;printf("%L\n" sourceWave->??)
wave=drCreateEmptyWaveform()
xVec=drGetWaveformXVec(pointsWave);x vector created from pointsWave
numOfPoints=drVectorLength(xVec)
yVec=drCreateVec(drType(drGetWaveformYVec(sourceWave)) numOfPoints);empty y vector
for( i 0 sub1(numOfPoints);for each point from pointsWave
thisX=drGetElem(xVec i);x value
currentValue=value(sourceWave thisX );y value from sourceWave corresponding to x value from pointsWave
drAddElem(yVec currentValue);add y element
);for
drPutWaveformXVec(wave xVec)
drPutWaveformYVec(wave yVec)

wave~>leafSignalTypeName=sourceWave~>leafSignalTypeName
wave~>leafDataSet=sourceWave~>leafDataSet
wave~>leafAnalysisType=sourceWave~>leafAnalysisType
);drIsWaveform(sourceWave)
(famIsFamily(sourceWave)
sweepName=famGetSweepName(sourceWave)
sweepValues=famGetSweepValues(sourceWave)
sweepValType=type(car(sweepValues))
case(sweepValType
('fixnum wave=famCreateFamily(sweepName 'intlong))
('flonum wave=famCreateFamily(sweepName 'float))
('string wave=famCreateFamily(sweepName 'string))
(t error("resampleByWave: unable to understand type %L\n" sweepValType))
);case
foreach( sweepVal sweepValues
currentSourceWave=famValue(sourceWave sweepVal)
currentPointsWave=famValue(pointsWave sweepVal)
famAddValue(wave sweepVal resampleByWave(currentSourceWave currentPointsWave ))
);foreach
);famIsFamily(sourceWave)
(t
error("resampleByWave: invalid waveform %L\n" sourceWave)
);t
);cond
wave
);let
);proc

I am not sure about a case when input waveforms are family of plots. Is this part of the code correct? 

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 7 years ago

    Your code is unnecessarily complicated in the famIsFamily branch. You should just be able to do:

    (famIsFamily(sourceWave)
      famMap('resampleByWave sourceWave pointsWave)
    )

    This takes care of iterating through the families (you could have families, or families of families, or families of families of families - etc) and then applying the resampleByWave to the layer beneath and reconstructing the curves or families from that.

    Note, I didn't test your code (lack of indentation made it hard to read too); my suggestion is however the way I do this all the time.

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • alexstepanov75
    alexstepanov75 over 7 years ago in reply to Andrew Beckett

    Andrew,

    Thank you for replay. I have two additional questions:

    1. I saw examples of famMap usage like you described. I checked manual for function famMap. It says "Applies a function with a set of arguments to each member of a family". It is not clear if an argument can be family too. In my case, pointsWave can be family of plots exactly like sourceWave, and resampleByWave should be applied to appropriate pairs. So will famMap work properly if used like you proposed?

    2. How can I copy past code with indentation? I tried a couple of formattings but in each case spaces at the beginning of line removed.

    Alex.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to alexstepanov75

    Alex,

    Yes, famMap will iterate over families in all the arguments together, so it will work pair-wise as you desire.

    The second question I can't really answer, as it almost certainly depends on what platform you're running your web browser on and which browser you're using. I use Mac and Safari (mostly) and Chrome (occasionally). I do from time to time have problems with preserving indentation - but I've not really done an exhaustive analysis of what works when (it has changed over time with different versions of the forum software too).

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to alexstepanov75

    Alex,

    Yes, famMap will iterate over families in all the arguments together, so it will work pair-wise as you desire.

    The second question I can't really answer, as it almost certainly depends on what platform you're running your web browser on and which browser you're using. I use Mac and Safari (mostly) and Chrome (occasionally). I do from time to time have problems with preserving indentation - but I've not really done an exhaustive analysis of what works when (it has changed over time with different versions of the forum software too).

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Curtisma
    Curtisma over 7 years ago in reply to Andrew Beckett

    I have had luck using the <pre> tag by going to tools-> source code.  I think you could also do this by selecting the block -> pre formatting option.  Then I just copy in my code with tabs.

    • 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