Home > Community > Forums > Custom IC Design > ocean script: ocnPrint

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 ocean script: ocnPrint 

Last post Wed, Feb 18 2009 3:36 AM by leongec. 2 replies.
Started by Sirrius 05 Jan 2009 11:08 PM. Topic has 2 replies and 6496 views
Page 1 of 1 (3 items)
Sort Posts:
  • Mon, Jan 5 2009 11:08 PM

    • Sirrius
    • Top 500 Contributor
    • Joined on Wed, Aug 13 2008
    • Posts 22
    • Points 275
    ocean script: ocnPrint Reply

    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

     

    • Post Points: 20
  • Tue, Jan 6 2009 8:42 AM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,587
    • Points 15,915
    Re: ocean script: ocnPrint Reply

    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.

    • Post Points: 20
  • Wed, Feb 18 2009 3:36 AM

    • leongec
    • Top 500 Contributor
    • Joined on Sun, Feb 1 2009
    • Posts 20
    • Points 265
    Re: ocean script: ocnPrint Reply

     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

    • Post Points: 5
Page 1 of 1 (3 items)
Sort Posts:
Started by Sirrius at 05 Jan 2009 11:08 PM. Topic has 2 replies.