• 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. Unable to do calculations involving variables in Ocean

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 143
  • Views 13246
  • 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

Unable to do calculations involving variables in Ocean

Anik1989
Anik1989 over 12 years ago

Hi all,

 

Sorry if this question has been answered before but my search didn't reveal anything.  I am having trouble with the following lines in my script:

 

------------------------------------------------- 

 ocnWaveformTool( 'wavescan )

simulator( 'spectre )

design("/home/a5islam/simulation/complete_circuit/spectre/schematic/netlist/netlist")

resultsDir("/home/a5islam/simulation/complete_circuit/spectre/schematic")

modelFile('("/CMC/kits/cmosp35.4.3/models/B3V/mm0355v.scs" "tt"))

;frequency of the sine wave input [Hz]

freq = 2

printf("Frequency: %L\n", freq)

tduration = 1*(1/freq)

printf("Duration: %L\n", tduration)

 -------------------------------------

The output of the file is:

Frequency: 2

Duration: 0

I think that when I calculate tduration using (1/freq), it fails to get the value of "freq". If I replace "freq" with its numeric value 2, then duration is 0.5 as expected.

 

In a related note, Cadence also complains when I try to use the following code:

 tduration=1e-3 

 analysis('tran ?start "0" ?stop tduration)

But if I replace tduration with its numeric value, the analysis runs fine.  

Is there some special way to access the values of variables in Ocean that I'm not aware of?  

Two things I should mention:

(i) If I declare all my variables as design variables and use VAR(""), there are no problems whatsoever. However, this seems like an excessive and tedious solution. 

(ii) I am saving my script as an .ocn file and then typing Load("FileName.ocn") in the CIW to run the script. Not sure if this has any bearing on the current situation.

 

Any advice is appreciated!

 

Anik 

 

  • Cancel
Parents
  • skillUser
    skillUser over 12 years ago

    Hi Anik,

    The problem appears to be that you are performing integer division in your code, hence 1/2 yields 0.  You can force your hand by doing something like 1.0/freq - this should solve your problem here.

    I have not looked into your second issue, but I see that the start is "0" and the tduration is just 1e-3, so perhaps you could try a string for the second argument, e.g. sprintf(nil "%g" tduration) ?

    Hope this helps!

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • skillUser
    skillUser over 12 years ago

    Hi Anik,

    The problem appears to be that you are performing integer division in your code, hence 1/2 yields 0.  You can force your hand by doing something like 1.0/freq - this should solve your problem here.

    I have not looked into your second issue, but I see that the start is "0" and the tduration is just 1e-3, so perhaps you could try a string for the second argument, e.g. sprintf(nil "%g" tduration) ?

    Hope this helps!

    Lawrence.

    • 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