• 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. ocean script: ocnPrint

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 125
  • Views 16688
  • 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: ocnPrint

Sirrius
Sirrius over 16 years ago

Hello All

I am trying to write the entire wave (ie, time vs values) into a text file. The problem is that I am overwriting the file with the latest values of waves. What I need to do is to append the information in one file, as I execute my ocean script.

Here is my piece of code:

(some code here)

;run analysis
analysis( 'tran ?stop "500n" ?errpreset "moderate")

;save all the waveforms
save( 'all )

;run the simulation
run()

;select the results now
selectResult( 'tran )

;print the data to a text file
m0=vm("/mult_output<0>")
m1=vm("/mult_output<1>")
m2=vm("/mult_output<2>")
m3=vm("/mult_output<3>")
m4=vm("/mult_output<4>")
m5=vm("/mult_output<5>")
m6=vm("/mult_output<6>")
m7=vm("/mult_output<7>")
m8=vm("/mult_output<8>")
m9=vm("/mult_output<9>")
m10=vm("/mult_output<10>")
m11=vm("/mult_output<11>")
m12=vm("/mult_output<12>")
m13=vm("/mult_output<13>")
m14=vm("/mult_output<14>")
m15=vm("/mult_output<15>")

;*********First Print**************
ocnPrint( ?output "results.txt" ?numberNotation 'scientific ?numSpaces 1 m0 m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12 m13 m14 m15 )
;ocnPrint( output_file ?numberNotation 'scientific ?numSpaces 1 m0 m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12 m13 m14 m15 )
drain( output_file )
c0=vm("/cmp_out<0>")
c1=vm("/cmp_out<1>")
c2=vm("/cmp_out<2>")
c3=vm("/cmp_out<3>")
c4=vm("/cmp_out<4>")
c5=vm("/cmp_out<5>")
c6=vm("/cmp_out<6>")
c7=vm("/cmp_out<7>")
c8=vm("/cmp_out<8>")
c9=vm("/cmp_out<9>")
c10=vm("/cmp_out<10>")
c11=vm("/cmp_out<11>")
c12=vm("/cmp_out<12>")
c13=vm("/cmp_out<13>")
c14=vm("/cmp_out<14>")
c15=vm("/cmp_out<15>")
;***************Second Print**********************
ocnPrint( ?output "results.txt" ?numberNotation 'scientific ?numSpaces 1 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 )
;ocnPrint( output_file ?numberNotation 'scientific ?numSpaces 1 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 )
close( output_file )

 

So, what happens here is that the information written by the second print statement overwrites the first one. I also tried the p_port method (the lines have been commented), as it outputs to the screen.

I tried fprintf also, but, it always write only the last of the values in the signal vector. 

Can someone please suggest something?

 

Thanks a lot!

 

Sirrius

 

  • Cancel
  • skillUser
    skillUser over 16 years ago

    Hi Sirrius,

    I have not played with this just now, but I am somewhat surprised that using the p_port input to the ocnPrint function does not work.

    The way that I would expect to use this is to open the file in append mode, print to it with multiple ocnPrint statements and even fprintf statements, and then close the port.  Something like:

      filePtr = outfile("myfile" "a")
      ;; some code, then print
      ocnPrint( ?output filePtr ... )
      ;; some more code, then print
      ocnPrint( ?output filePtr ... )
      ;; even more code, then print
      frintf( filePtr ... )
      ;; done, close the file handle
      close( filePtr )
    

    If you call ocnPrint with a filename for ?outfile, then I believe that it would open the file in "w" (write) mode each time and effectively overwrite the contents of the file each time.

    I hope that the above helps.

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • leongec
    leongec over 16 years ago

     hi, i got one question regarding to the ocnprint. the following is my script


    f1=1
    f2=2
    f3=3

    q1=4

    q2=5

    q3=6


    ocnPrint(?output "/home/result.txt"  f1,q1)
    ocnPrint(?output "/home/result.txt"  f2,q2)
    ocnPrint(?output "/home/result.txt"  f3,q3)

    i would like to print the f2 and q2 in the next line of f1 and q1, but i realize that the latest print will replace the older one, how can i use the "append" command to fix my problem??

     

    thank you for your advice

    • 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