• 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 Design
  3. How to implement and if statement in the calculator

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 125
  • Views 23879
  • 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 implement and if statement in the calculator

LuisGutierrez
LuisGutierrez over 9 years ago

Hi all,

I am simulating a pre-regulator with an overvoltage reset and a deglitch filter. I use the function cross to determine when the output voltage crosses the reset value (both rising t1 and falling t2) and use this times to determine the violation time. 

t1 = cross(VT("/vout") 8.6 1 "rising" nil nil)

t2 = cross(VT("/vout") 8.6 1 "falling" nil nil)

However, in some of my corner simulations either the rising/falling edge or both is not triggered by the cross function and it evaluates to nil, giving me an evaluation error later on. I wonder if there is a way to implement and if statement that determines that whether t1,2 equals "nil" and then overrides their value to some numerical value that I can use later on.

I suppose that is done via the calculator special functions using calCreateSpecialFunction and calRegisterSpecialFunction. However, the usage of these functions is not quite clear in the manual. Any input/example on how to do this is much appreciated.

Regards,

Lucho.

  • Cancel
  • LuisGutierrez
    LuisGutierrez over 9 years ago

    Hi all,

    I managed to solve the issue by implementing the if statements within the expression as follows:

    if(cross(VT("/vout") 8.6 1 "rising" nil nil) == nil then t1=1 else t1=cross(VT("/vout") 8.6 1 "rising" nil nil))

    With this, if the expression evaluates to nil I assign my desired value there. If it passes normally, I get the result of the cross calculation. This ain't the most elegant way but for now it does the trick. I'm still interested in how to implement this in a custom function. I can't seem to be pass the arguments to the function properly; i.e. how to run the if with a value coming from the stack ?

    Bonus track: How to delete previously loaded functions via calRegisterSpecialFunction?

    Best regards,

    Lucho.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    Unknown said:

    Bonus track: How to delete previously loaded functions via calRegisterSpecialFunction?

    Lucho,

    I don't believe there is a way of doing this. However, since quitting virtuoso and re-starting will remove the registered functions anyway (unless  you're calling calRegisterSpecialFunction in the .cdsinit), there's not really a big need for an unregister function...

    Regards,

    Andrew.

    • 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