• 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. Mixed-Signal Design
  3. ocean script if statement not workiing

Stats

  • Locked Locked
  • Replies 11
  • Subscribers 65
  • Views 10722
  • 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

ocean script if statement not workiing

NewScreenName
NewScreenName over 2 years ago

Hi all,

I am new in the use of ocean script, but I would like to perform the following task: use ADE assembler calculator cross() function on a signal, but when a certain design variable A has value 0, then the cross() function should return 0 (rather than nil, 0*nil would still evaluate to nil, so I cannot just multiply them).

I thought to approach this by an IF statement, I tried to look at an ocean documentation, so I created a file called myFile.ocn, loaded it in the outputs setup and its content is:

if (VAR("A")==0 0 cross(vtime('tran "/mySignal") (0.5 * VAR("vsupply")) 1 "rising" nil nil nil))

But that returns eval err. In the ocean reference it is stated that:

"if if( g_condition g_thenExpression [g_elseExpression] ) => g_result Description Evaluates g_condition, typically a relational expression, and runs g_thenExpression if the condition is true (that is, its value is non-nil); otherwise, runs g_elseExpression. The value returned by if is the value of the corresponding expression evaluated.

What am I doing wrong? ADE shows an eval err (it is the case even when I replace the cross() function from the IF with just a number)

Thank you very much

Best regards

  • Cancel
  • ShawnLogan
    ShawnLogan over 2 years ago in reply to NewScreenName

    Dear NewScreenName,

    NewScreenName said:
    here was indeed a syntax error in how I formulated the nested second if which should have prevented returning nil in my simulation, but did not.

    I am glad you found that! Unfortunately, ocean is not very forgiving of even small syntax errors - which makes it a challenge to debug. I guess I do not have to tell you that now.

    Good luck!

    • 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