• 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. Generate csv file for result of each simulation

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 125
  • Views 12167
  • 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

Generate csv file for result of each simulation

Holz
Holz over 4 years ago

Hello,

I'm running a simulation with 50000 sweep points and I want to export result of each simulation into a csv file, so I want to have 50000 csv files.

As already mentioned in https://community.cadence.com/cadence_technology_forums/f/custom-ic-design/48506/how-to-get-values-of-sampling-points, it's possible to use the "sweep variable" as "VAR()" in Ocean script, but in my case, I have many sweep parameters and I don't care about which result is related to which parameter, what I want to realize is like a for loop:

                                              for (N=1,N<=50000,N++)

                                                    generate ("result_N.csv")

How can I realize it? Another question is, when I use "awySaveToCSV" to save the sampled input and output waves, I also have two time step columns, can I delete one in ocean script?

Thanks for help!

Regards,

Holz

  • Cancel
  • ShawnLogan
    ShawnLogan over 4 years ago

    Dear Holz,

    Holz said:

    but in my case, I have many sweep parameters and I don't care about which result is related to which parameter, what I want to realize is like a for loop:

                                                  for (N=1,N<=50000,N++)

                                                        generate ("result_N.csv")

    How can I realize it?

    This can be readily accomplished using an ocean script, Holz.

    Holz said:
    Another question is, when I use "awySaveToCSV" to save the sampled input and output waves, I also have two time step columns, can I delete one in ocean script?

    An ocean script can call a UNIX command using its system() function and hence one can use the UNIX cut and paste commands or issue an awk command. As an example, I created a test_in.csv file and illustrate the use of the UNIX cut command to remove the time columns with the exception of the first time column:$ cat test_in.csv

    $cat test_in.csv

    Time1,wave1,Time2,wave2
    0,0.25,0,0.125
    1,0.5,1,0.25
    2,0.75,2,0.375
    3,1.0,3,0.50
    $ cut -d"," -f1,2,4 test_in.csv
    Time1,wave1,wave2
    0,0.25,0.125
    1,0.5,0.25
    2,0.75,0.375
    3,1.0,0.50
    $ cut --complement -d"," -f3 test_in.csv
    Time1,wave1,wave2
    0,0.25,0.125
    1,0.5,0.25
    2,0.75,0.375
    3,1.0,0.50

    I can create an ocean script to invoke the command "cut --complement -d"," -f3 test_in.csv" on the sample input file and store it in the new output file test_out.csv as follows:

    $cat cut_function.ocn

    simulator 'spectre

    sprintf(filename_in "test_in.csv")
    sprintf(filename_out "test_out.csv")

    ; or alternately
    ;
    ; filename = strcat("test_in.csv")

    sprintf(cut_field_3_command "cut --complement -d\",\" -f3")
    sprintf(apply_cut_command "%s %s > %s" cut_field_3_command filename_in filename_out)
    system(apply_cut_command)
    exit()

    Running the ocean command using:

    $ocean < cut_function.ocn

    The ocean script, output log, test_in.csv, and test_out.csv file are attached as a compressed archive.

    At this point, I am thinking you might consider learning to write an ocean script as this will easily allow you to create and customize the output formatting and create your 50,000 files with their simulation number in the filename.

    Shawn

    cut_osc_script_sml_080721.zip

    • 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