• 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. RF Design
  3. Waveform calculator - Integration operation wrt to an independent...

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 63
  • Views 4941
  • 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

Waveform calculator - Integration operation wrt to an independent variable

DKaraca
DKaraca over 3 years ago

Hello,

I have a question about the use of calculator functions. I believe his is a rather tricky one.

I run a power sweep in a single tone HB simulation for an amplifier, say with a input power sweep range from -30dBm to 10dBm.

Then I calculate the AMAM (single tone amplitude distortion) by plotting (PowerGain_vs_InputPower)-(PowerGain@-30dBm). Let's call this function AMAM(Pin).

I want to integrate the following from 0.1 to 10, for each swept value of Pin (x being an independent variable):

x * { AMAM(x * Pin_W) - AMAM(Pin_W) } * dx

Due to the AMAM(x * Pin_W) term, the calculation can of course be done only for a Pin range of -20dBm to 0dBm in this case (otherwise AMAM(Pin) function is invalid given the integration range is from 0.1 to 10).

Is there a way to do this using cadence calculator?

My cadence version is ICADVM20.1-64b.500.20

Thanks in advance.

BR,

Denizhan Karaca

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

    I don't really understand the equation you are trying to integrate - it seems rather odd. What does it actually mean? The only way I can think of doing this would be to write a custom SKILL function which took the waveform for the expression (PowerGain_vs_InputPower)-(PowerGain@-30dBm) which would be versus the input power, and then for each input power point you construct a waveform with your values x from 0.1 to 10 (in however many steps you want) and then call integ on that, and then construct a new waveform versus input power with that integration result. 

    It's rather weird though. I'd show you an example but I suspect I've not understood what you're trying to do because it makes no sense to me. So rather than spending time writing code that is possibly completely wrong because I've misunderstood, I'd sooner you explain this more clearly...

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • DKaraca
    DKaraca over 3 years ago in reply to Andrew Beckett

    Hi Andrew,

    Thanks for your prompt reply.

    Reading your interpretation of my question, I believe you have understood what I'm trying to do pretty well.

    Unfortunately, I cannot share what exactly I'm try to achieve with this due to confidentiality reasons. However, I would much appreciate if you could show me an example skill code.

    We can also think of this as a more generic case rather than a HB simulation related topic.

    Say that I have an output waveform f(t), where t is the swept variable.

    For each swept value of t, I want to calculate:

    ∫ x * { f(x*t) - f(t) } dx, with an integral range of 0.1 to 10. And then construct a new waveform versus t, as you suggested.

    BR,

    Denizhan Karaca

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to DKaraca

    Hi Denizhan,

    Having thought about this more, I think the main reason for my confusion is that (I think) you have got mixed units - so for example, if the power sweep was done using the input power in dBm, then your AMAM  expression would be a function of the input power in dBm and so multiplying by x would make no sense. Instead you'd do: AMPM(dB10(x)+Pin). I've now just realised that you've used Pin_W to indicate that it's in Watts as opposed to Pin. Also I think the multiplication by dx was a mistake and just an indication that you wanted to do an integral.

    Assuming you have got the expression for (PowerGain_vs_InputPower)-(PowerGain@-30dBm) and that produces the power gain in dB, then it would be something like this:

    procedure(CCFpowerInteg(powerGainExpr startX stopX stepX)
      let((origXVec xVec yVec outYVec intXVec intYVec points clipped startDB stopDB
          len firstX lastX nPoints outWave Pin Pgain powerVal waveToInteg)
        cond(
          (drIsWaveform(powerGainExpr)
            origXVec=drGetWaveformXVec(powerGainExpr)
            ;----------------------------------------------------------------
            ; Find the first and last x points and then clip the waveform to
            ; the range the x*Pin_W won't got out of range
            ;----------------------------------------------------------------
            startDB=dB10(startX)
            stopDB=dB10(stopX)
            firstX=drGetElem(origXVec 0)
            lastX=drGetElem(origXVec drVectorLength(origXVec)-1)
            clipped=clip(powerGainExpr firstX-startDB lastX-stopDB)
            ;----------------------------------------------------------------
            ; Prepare the vectors to read the values plus output vector and also
            ; the x-axis for the waveform to be integrated
            ;----------------------------------------------------------------
            xVec=drGetWaveformXVec(clipped)
            yVec=drGetWaveformYVec(clipped)
            len=drVectorLength(clipped)
            outYVec=drCreateVec('double len)
            ; this is a linear range of points
            points=linRg(startX stopX stepX)
            nPoints=length(points)
            intXVec=drCreateVec('double points)
            ;----------------------------------------------------------------
            ; Iterate over each point in the clipped waveform and read the 
            ; x-value (Pin) and y-value (Pgain)
            ;----------------------------------------------------------------
            for(i 0 len-1
              intYVec=drCreateVec('double nPoints)
              Pin=drGetElem(xVec i)
              Pgain=drGetElem(yVec i)
              ;--------------------------------------------------------------
              ; let's assume that the power gain is not in dB - otherwise
              ; some appropriate scaling would be needed.
              ; Compute the y-points for the waveform to be integrated
              ;--------------------------------------------------------------
              foreach(x points
                ;------------------------------------------------------------
                ; since the x-axis is in dBm, I think you can just
                ; add x in dB to the input power
                ;------------------------------------------------------------
                powerVal=x*(value(powerGainExpr dB10(x)+Pin)-Pgain)
                drAddElem(intYVec powerVal)
              )
              waveToInteg=drCreateWaveform(intXVec intYVec)
              drAddElem(outYVec integ(waveToInteg))
            )
            outWave=drCreateWaveform(xVec outYVec)
          )
          (famIsFamily(powerGainExpr)
            famMap('CCFpowerInteg powerGainExpr startX stopX stepX)
          )
          (t
            error("CCFpowerInteg: can't handle %L\n" powerGainExpr)
          )
        )
      )
    )

    Note this is completely untested as I have nothing sensible to try it on (plus I've no idea what exactly it should be doing since it doesn't make much sense to me, as I mentioned). Hopefully you can adapt it to suit your needs.

    For anything more in-depth I suggest you contact customer support where you may be able to be less circumspect.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to DKaraca

    Hi Denizhan,

    Having thought about this more, I think the main reason for my confusion is that (I think) you have got mixed units - so for example, if the power sweep was done using the input power in dBm, then your AMAM  expression would be a function of the input power in dBm and so multiplying by x would make no sense. Instead you'd do: AMPM(dB10(x)+Pin). I've now just realised that you've used Pin_W to indicate that it's in Watts as opposed to Pin. Also I think the multiplication by dx was a mistake and just an indication that you wanted to do an integral.

    Assuming you have got the expression for (PowerGain_vs_InputPower)-(PowerGain@-30dBm) and that produces the power gain in dB, then it would be something like this:

    procedure(CCFpowerInteg(powerGainExpr startX stopX stepX)
      let((origXVec xVec yVec outYVec intXVec intYVec points clipped startDB stopDB
          len firstX lastX nPoints outWave Pin Pgain powerVal waveToInteg)
        cond(
          (drIsWaveform(powerGainExpr)
            origXVec=drGetWaveformXVec(powerGainExpr)
            ;----------------------------------------------------------------
            ; Find the first and last x points and then clip the waveform to
            ; the range the x*Pin_W won't got out of range
            ;----------------------------------------------------------------
            startDB=dB10(startX)
            stopDB=dB10(stopX)
            firstX=drGetElem(origXVec 0)
            lastX=drGetElem(origXVec drVectorLength(origXVec)-1)
            clipped=clip(powerGainExpr firstX-startDB lastX-stopDB)
            ;----------------------------------------------------------------
            ; Prepare the vectors to read the values plus output vector and also
            ; the x-axis for the waveform to be integrated
            ;----------------------------------------------------------------
            xVec=drGetWaveformXVec(clipped)
            yVec=drGetWaveformYVec(clipped)
            len=drVectorLength(clipped)
            outYVec=drCreateVec('double len)
            ; this is a linear range of points
            points=linRg(startX stopX stepX)
            nPoints=length(points)
            intXVec=drCreateVec('double points)
            ;----------------------------------------------------------------
            ; Iterate over each point in the clipped waveform and read the 
            ; x-value (Pin) and y-value (Pgain)
            ;----------------------------------------------------------------
            for(i 0 len-1
              intYVec=drCreateVec('double nPoints)
              Pin=drGetElem(xVec i)
              Pgain=drGetElem(yVec i)
              ;--------------------------------------------------------------
              ; let's assume that the power gain is not in dB - otherwise
              ; some appropriate scaling would be needed.
              ; Compute the y-points for the waveform to be integrated
              ;--------------------------------------------------------------
              foreach(x points
                ;------------------------------------------------------------
                ; since the x-axis is in dBm, I think you can just
                ; add x in dB to the input power
                ;------------------------------------------------------------
                powerVal=x*(value(powerGainExpr dB10(x)+Pin)-Pgain)
                drAddElem(intYVec powerVal)
              )
              waveToInteg=drCreateWaveform(intXVec intYVec)
              drAddElem(outYVec integ(waveToInteg))
            )
            outWave=drCreateWaveform(xVec outYVec)
          )
          (famIsFamily(powerGainExpr)
            famMap('CCFpowerInteg powerGainExpr startX stopX stepX)
          )
          (t
            error("CCFpowerInteg: can't handle %L\n" powerGainExpr)
          )
        )
      )
    )

    Note this is completely untested as I have nothing sensible to try it on (plus I've no idea what exactly it should be doing since it doesn't make much sense to me, as I mentioned). Hopefully you can adapt it to suit your needs.

    For anything more in-depth I suggest you contact customer support where you may be able to be less circumspect.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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