• 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. How to deposit simulation result into a file?

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 143
  • Views 17986
  • 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 deposit simulation result into a file?

Alex Liao
Alex Liao over 10 years ago

Hi, I am wondering is there a way to save an output into a file, like a .txt which it is easy to read from.

 

Specifically, in the "Setting outputs" of Virtuoso Analog Design Environment (ADE) I have: 

Name: PhaseMargin

Expression: (phaseMargin((VF("/Vout") / (VF("/Vin+") - VF("/Vin-")))) + 180)

 

After simulation, I got 80 degree displayed.

But is there a way to save this '80' into a .txt file?

I am using SpectreS as the simulator. I think there are some commands to output results.

 

Any answer is appreciated.

Thanks,

Alex


  • Cancel
  • skillUser
    skillUser over 10 years ago

    Hi Alex,

    You can use the ocnPrint() function, use the ?output argument to specify the file that you want to write to, and ?numberNotation if you wish to format the output (e.g. 'scientific, 'engineering) and ?precision to control the significant digits to output.

    Hopefully this is all you need.

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Alex Liao
    Alex Liao over 10 years ago

    Hi Lawrence,

     

    Thanks for your quick response.

     I did the experiment and got an desired output.

    What I did is just to use ADE to do the simulation and to save the ocean script. After that I open the saved script and add the ocnPrint() function.

    When I opened the saved ocean script, I found it mimiced the action of simulation by having a "run()". I think it relates to the run_simulation command which is "spectre + escchars + log ../psf/spectre.out -env artist5.1.0 -format psfbin -raw ../psf -E -cols 80 raw/Mydesign". 

     I am curious about the different of run_simulation between using spectre command and using ocean script. I have to know how does the “ocean script version of run()” relate to the circuit_netlist.

     In my work, I need to vary the netlist and send the modified netlist back to re-run the simulation and get data from, maybe ocnPrint(). It looks like an loop. All the process are executed by code without interference with GUI. Therefore, I want to know how to make modified netlist work or refected in "run()" or maybe other ocean scripts, which are responsible for run_simulation purpose.  

     

    Thanks,

    Alex 

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 10 years ago

    Hi Alex,

    it depends on what needs altering, but you might do that alteration from within Ocean, for example a design variable (desVar() command) or the simulation temperature (temp() command).  If you are changing the circuit itself then you might be able to use createNetlist() (after you have specified the design using design(library cell view) [insert your actual string values for library etc.]  Ocean uses the 'raw' netlist for the circuit and builds the 'simulation netlist' up around it using the environment you specify with various Ocean commands, whereas the spectre standalone invocation needs the complete netlist which includes the circuit and all of the simulation parameters.  The design() comman can use the path to the 'raw' netlist or the library,cell and view format, in the latter case it can (re)create the circuit netlist as neede, or re-use the existing one.

    I may be a little off here since I don't play with Ocean all too often, but hopefully the above notes are correct and helpful.

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Alex Liao
    Alex Liao over 10 years ago

    Hi Lawrence,

     I understand what you were saying.

    The spectre standalone command is written in the file runSpectre:

    spectre +escchars +log ../psf/spectre.out -env artist5.1.0 -format psfbin  -raw ../psf -E -cols    80 raw/design

    The  raw/design is the generated spectre netlist which is usually named spectreFinal. It has everything inside, the core netlist (device with paremeters and connections) plus variable assignment and simulation settings. The spectreFinal is the generated netlist from Spectre command (maybe Skill language). Do not worry about it right now.

    The simulation result is in ../psf.

    Q1 here: Is there any way (command style) to extract data and save it (say, the phaseMargin) into a txt fire after executing runSpectre? I tried to use ocnPrint(), but failed. So I think the ocnPrint() can only be executed following a Ocean version simulation which is the design() and run() stuff. 

     

    While the Ocean methodology takes the raw netlist, other variable assignment and simulation settings are written in Ocean format. 

    I have a piece of Ocean script here. I want to have a discussion here. And I think this would provide help to many newcomers who want to study the command way executing simulation.

     

     ocnWaveformTool( 'wavescan )

    simulator( 'spectreS )

    design(  "/users/.../simulation/OP_AMP/spectreS/schematic/netlist/OP_AMP.C")

    resultsDir( "/users/.../simulation/OP_AMP/spectreS/schematic" )

    path( "/home/aaia11/models" )

    analysis('ac ?start "1"  ?stop "1G"  )

    analysis('dc ?oppoint "rawfile"  ?save "allpub"  )

    desVar(   "vd" 600m       )

    desVar(   "l" 2.55u          )

    desVar(   "Ibias" 430.36n            )

    temp( 27 ) 

    includeFile( "/CMC/kits/cmosp18.5.2/models/spectre/icfspectre.init" )

    run()

    selectResult( 'dcOp )

    plot(getData("/Vout") )

    selectResult( 'ac )

    plot(getData("/Vout") )

    Gain = dB20((VF("/Vout") / (VF("/Vin+") - VF("/Vin-"))))

    plot( Gain ?expr '( "Gain" ) )

    PhaseMargin = (phaseMargin((VF("/Vout") / (VF("/Vin+") - VF("/Vin-")))) + 180)

     

    ocnPrint( ?output "./netlist/results.txt" ?numberNotation 'scientific phaseMargin((VF("/Vout") / (VF("/Vin+") - VF("/Vin-")))) + 180) 

     

     

    I did not see any netlist generation statement. The only netslist that displayed is OP_AMP.C. When I opened it, there is only simulator selection information and a statement of 'USE mylib_OP_AMP_schematic'. I did not see any device information. But I did a bit experiment. I found when I use ADE to generate raw netlist a mylib_OP_AMP_schematic.s is shown up. It records all device information. Therefore I attempted to modify the width of a MOSFET to an unreasonable number and "ocean -replay test.ocn". The plotted graph and the saved data changes. So I know the .s file is the one that I want to modify. [we call it device netlist for now]

    Q2: My question is how does the ocean script know the .s file is the device netlist to be used? Is it through the clue that:

     design("/users/.../simulation/OP_AMP/spectreS/schematic/netlist/OP_AMP.C")'  

    The run() command always tries to find the netlist used in 'design()', which is OP_AMP.C in this example and the OP_AMP.C file would find the device netlist which is .s file through 'USE mylib_OP_AMP_schematic', which means the ‘USE XXX’ statement equals to 'include XXX.s.' Am I correct on his name binding and associated reasoning?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 10 years ago

     Hi Alex,

    Why are you using SpectreS I wonder, instead of the more current Spectre ? I have not seen anyone using SpectreS in years and I am pretty rusty on the details (e.g. the flow used, and how the netlist differs from a 'spectre direct' netlist).  Unless you are strongly tied to SpectreS for some reason I would recommend migrating to Spectre if you - there's not anything wrong with it, but it is really old (and may not even be currently supported?).

    Q1 - you did not say why/how the ocnPrint() command did not work.  You can use an OCEAN script with the results from a command-line spectre run, you need to tell OCEAN where the results are using the openResults() command - you may get some warnings but you should be able to read the results from the appropriate psf directory (give the path to the 'psf' directory including the psf at the end of the path).  You can try to develop the script interactively and type commands at the ocean> prompt, so you can open the results and then check to see if you can select the ac, dcOp or dc results set (selectResult() command with either 'ac or "ac" as an argument, for example). The ocnPrint() command should do what you want (NOTE: do not use ?numberNotation 'none for a scalar result, this is currently broken).

     

    Q2 - Yes, the design() command in OCEAN is how to either point to the lib/cell/view to be used, or the 'raw' netlist for that design - if the former method is used then OCEAN can renetlist the design, otherwise it will just use the raw netlist provided.   I cannot remember if you said which version you are using but if it is IC61x then the command line version of ocean can netlist, but if using IC5x then you would need to be in 'icfb' or similar in order to perform netlisting.  As noted above I'm rusty on the spectreS flow, but I would guess that the "USE" statement is equivalent to an include statement.

    Hope this helps!

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Alex Liao
    Alex Liao over 10 years ago

    Hi Lawrence,

    Big thanks to you. I understand what you were saying. Because I were doing a circuit verification and the circuit associated with its artist state are from another guy. He used spectreS and I did not convert it yet. Is hspice the latest or spectre is better if consider a conversion? 

     

    I tried the openResults() and then went to ocnPrint(). It worked so as to my initial purpose. Use runSimulation to get data and use ocnPrint() to get the result.

    Q1: One thing about the result.txt is that I do not know how to format it. Say I want to write some plain text before each print result.

    For example ( ";statement" is an comment according the SKILL):

    ********************** ** ;plainText 

    Gain is: ;plainText 

      65dB ;ocnPrint Result

    PhaseMargin is: ;plainText 

    80 ;ocnPrint Result

    GainBandwidth is: ;plainText 

    5MHZ  ;ocnPrint Result

    ************************* ;plainText 

    Also I am thinking even I could write the result.txt using C++ for instance, if I run the ocnPrint() the second time, it would overwrite my previous contents. Is there a way to control how to write to a file? better use one ocnPrint() to write multiple wave/variable or execute multiple ocnPrint()s?

     Q2A:

    When I have the getResult.ocn, I use:

    ocean -replay getResult.ocn or ocean -restore getResult.ocn  (Any difference?)

    to execute it. 

     

    Q2B: After executing the ocean script it always make the command line go into ocean interactive mode.

    Because I am going to call this iteratively through C++ System("call command"), a bit worried about being into ocean interactive mode.

    Therefore I tried  icfb -nograph -restore getResult.ocn

    I get error message:

     *WARNING* Could not locate rgb.txt file in /usr/lib/X11

    *WARNING* This file is required for color operations with the non-graphical

    *WARNING* X server and many WARNING messages may follow this one!

    /users/vlsi/CMC/tools/cadence/IC5141USR6_lnx86/tools.lnx86/dfII/bin/Xndx: error while loading shared libraries: libgdbm.so.2: cannot open shared object file: No such file or directory.

     

    When I delete the -nograph, it can run but bring up me a icfb window which is not good in the case of C++ iterative call of the ocnScript. I could have thousand of icfb popped up. Any idea on why I cannot proceed with -nograph property? or a way of not stepping into ocean interactive mode after execution of ocnScript?

     

    Kind Regards,

    Alex 

    • 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