• 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. Get the frequency for design variable sweep in AC/XF/SP...

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 125
  • Views 8362
  • 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

Get the frequency for design variable sweep in AC/XF/SP analysis

ZoltanT
ZoltanT over 5 years ago

Hello everybody,

I am looking for a way to access the simulation frequency for AC/XF/SP analysis when not the frequency, but a variable was swept for a given frequency. Something similar to VAR("temp"). Unfortunately multiple variations of this theme, like VAR("freq"), did not work for me. I am looking for such a  solution to avoid writing any magic numbers in my post-processing OCEAN equations.

Thanks,
Zoltan

  • Cancel
Parents
  • ShawnLogan
    ShawnLogan over 5 years ago

    Dear ZoltanT,

    ZoltanT said:
    I am looking for a way to access the simulation frequency for AC/XF/SP analysis when not the frequency, but a variable was swept for a given frequency.

    As I am sure you know, if the frequency is the sweep variable in an AC analysis, the xval() function will provide the frequency for an output. However, as you noted, since you are not sweeping the frequency but instead a design variable, the xval() function will not provide the frequency. In this case, xval() will provide the design variable you are sweeping.

    I am not sure if the solution I use might be acceptable to you, but it will provide the value of the frequency you defined in the AC analysis simulation.

    In the example test schematic I show in Figure 1 of a passive summer, I perform an AC analysis at 10 kHz with the design variable res_ohms varied from 1 to 100 with 20 points per decade. As noted, I save the output current through an ideal capacitor connected to a new DC source whose DC value is 0 and whose AC value is 1. With the ideal capacitor value defined as 1/(2*pi), the current flowing through the capacitor (which will be all imaginary) is the frequency at which the simulation was performed. I've also attached a short ocean script that shows the operations I use to get the frequency and its value. I hope this helps ZoltanT provide a possible solution to your quandry!

    Shawn

    Figure 1

    freq.ocn

    simulator('spectre)
    defMathConstants('MyConsts)
    pi = MyConsts.PI

    results = strcat("<path_to_your_results_directory>/psf")
    openResults(results)
    selectResult("ac-ac")
    outputs()
    i_cap = getData("/i_cap/PLUS" ?result "ac-ac" ?resultsDir results)
    sim_freq = value(imag(i_cap) 10)
    printf("Simulated frequency = %.3f kHz.\n" sim_freq/1e3)

    exit()

    Output of script freq.ocn:

    ocean> MyConsts
    ocean> 3.141593
    ocean> ocean> "/projects/apdserdes_1/sdn7pg5/users/sml/simulation/spectre/test_fft/spectre/schematic/distributed/example_sc_sweep_res_ohms_10k/psf"
    ocean> Loading viva.cxt
    "/projects/apdserdes_1/sdn7pg5/users/sml/simulation/spectre/test_fft/spectre/schematic/distributed/example_sc_sweep_res_ohms_10k/psf"
    ocean> stdobj@0x2d77c320
    ocean> ("/vcap_0" "/vout" "/vsin2" "/vsin1" "/vcap_1"
    "/i_cap/PLUS"
    )
    ocean> srrWave:0x31523020
    ocean> 10000.0
    ocean> Simulated frequency = 10.000 kHz.
    t

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ZoltanT
    ZoltanT over 5 years ago in reply to ShawnLogan

    Thanks ShawnLogan! Great and simple idea, which fall outside the box I was thinking in. I thought that such a parameter has to be accessible and I was focused on finding how it is possible. Measuring the frequency instead is a very simple, fast and effective workaround.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 5 years ago in reply to ZoltanT

    I probably would have solved it an even simpler way, which is to create a variable called (say) singlefreq, and then used VAR("singlefreq") as frequency on the ac form, and then you can access VAR("singlefreq") in your scripts afterwards too.

    I'm sure this came up recently on the forums, but the right answer would be for spectre to write the frequency into the result database. It does write the sweep values - so you can do"

    resultParam("start" ?result 'ac)
    resultParam("stop" ?result 'ac)

    what would be useful is if it also wrote "freq" into the results, so you could do:

    resultParam("freq" ?result 'ac)

    This would be a simple (and useful) enhancement request in my opinion.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 5 years ago in reply to Andrew Beckett

    Hi Andrew,

    Andrew Beckett said:
    I probably would have solved it an even simpler way, which is to create a variable called (say) singlefreq, and then used VAR("singlefreq") as frequency on the ac form, and then you can access VAR("singlefreq") in your scripts afterwards too.

    That is a good idea Andrew - I neglected to think of that - great!

    Andrew Beckett said:

    what would be useful is if it also wrote "freq" into the results, so you could do:

    resultParam("freq" ?result 'ac)

    This would be a simple (and useful) enhancement request in my opinion.

    I agree with your thought - that would be a nice enhancement.

    Thank you for adding your suggestion and insights!

    Shawn

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • ShawnLogan
    ShawnLogan over 5 years ago in reply to Andrew Beckett

    Hi Andrew,

    Andrew Beckett said:
    I probably would have solved it an even simpler way, which is to create a variable called (say) singlefreq, and then used VAR("singlefreq") as frequency on the ac form, and then you can access VAR("singlefreq") in your scripts afterwards too.

    That is a good idea Andrew - I neglected to think of that - great!

    Andrew Beckett said:

    what would be useful is if it also wrote "freq" into the results, so you could do:

    resultParam("freq" ?result 'ac)

    This would be a simple (and useful) enhancement request in my opinion.

    I agree with your thought - that would be a nice enhancement.

    Thank you for adding your suggestion and insights!

    Shawn

    • 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