How to open a document whose name is generated based on the current date and time

Discussion in 'VHDL' started by Weng Tianxiang, Sep 25, 2006.

  1. Hi,
    I would like to copy several segments of code in VHDL:
    1. Open a document whose name is generated based on the current date
    and time;
    2. Write data array into it;
    3. Close it.

    If you know, please give a tip.

    Thank you.

    Weng
    Weng Tianxiang, Sep 25, 2006
    #1
    1. Advertising

  2. Weng Tianxiang

    David Ashley Guest

    Re: How to open a document whose name is generated based on the currentdate and time

    Weng Tianxiang wrote:
    > Hi,
    > I would like to copy several segments of code in VHDL:
    > 1. Open a document whose name is generated based on the current date
    > and time;
    > 2. Write data array into it;
    > 3. Close it.
    >
    > If you know, please give a tip.
    >
    > Thank you.
    >
    > Weng
    >


    Perhaps have a where script you run the simulator,
    output the file to a known fixed name, then in the
    script rename the file to the data-based filename
    you'd like?

    Pass the output filename in as an argument to
    the simulator? Not that I know how to do this...

    -Dave

    --
    David Ashley http://www.xdr.com/dash
    Embedded linux, device drivers, system architecture
    David Ashley, Sep 25, 2006
    #2
    1. Advertising

  3. David Ashley wrote:
    > Weng Tianxiang wrote:
    > > Hi,
    > > I would like to copy several segments of code in VHDL:
    > > 1. Open a document whose name is generated based on the current date
    > > and time;
    > > 2. Write data array into it;
    > > 3. Close it.
    > >
    > > If you know, please give a tip.
    > >
    > > Thank you.
    > >
    > > Weng
    > >

    >
    > Perhaps have a where script you run the simulator,
    > output the file to a known fixed name, then in the
    > script rename the file to the data-based filename
    > you'd like?
    >
    > Pass the output filename in as an argument to
    > the simulator? Not that I know how to do this...
    >
    > -Dave
    >
    > --
    > David Ashley http://www.xdr.com/dash
    > Embedded linux, device drivers, system architecture


    Hi David,
    Good advice!

    I am using Window XP system and run ModelSim simulator.

    Please let me know what script software can be used and your
    recommendation.

    I would like to learn to write scripts under ModelSim simulation
    environment.

    Can you give some examples to let me start easier.

    Weng
    Weng Tianxiang, Sep 25, 2006
    #3
  4. Weng Tianxiang

    David Ashley Guest

    Re: How to open a document whose name is generated based on the currentdate and time

    Weng Tianxiang wrote:
    > David Ashley wrote:
    >
    >>Weng Tianxiang wrote:
    >>
    >>>Hi,
    >>>I would like to copy several segments of code in VHDL:
    >>>1. Open a document whose name is generated based on the current date
    >>>and time;
    >>>2. Write data array into it;
    >>>3. Close it.
    >>>
    >>>If you know, please give a tip.
    >>>
    >>>Thank you.
    >>>
    >>>Weng
    >>>

    >>
    >>Perhaps have a where script you run the simulator,
    >>output the file to a known fixed name, then in the
    >>script rename the file to the data-based filename
    >>you'd like?
    >>
    >>Pass the output filename in as an argument to
    >>the simulator? Not that I know how to do this...
    >>
    >>-Dave
    >>
    >>--
    >>David Ashley http://www.xdr.com/dash
    >>Embedded linux, device drivers, system architecture

    >
    >
    > Hi David,
    > Good advice!
    >
    > I am using Window XP system and run ModelSim simulator.
    >
    > Please let me know what script software can be used and your
    > recommendation.
    >
    > I would like to learn to write scripts under ModelSim simulation
    > environment.
    >
    > Can you give some examples to let me start easier.
    >
    > Weng
    >


    Weng,

    I use linux, it's inherently script friendly. However I think
    you can use DOS .bat files and use '%' syntax. Perhaps
    this page might help somehow:

    http://www.ericphelps.com/batch/samples/justtime.bat.txt

    -Dave


    --
    David Ashley http://www.xdr.com/dash
    Embedded linux, device drivers, system architecture
    David Ashley, Sep 25, 2006
    #4
  5. On 25 Sep 2006 10:12:27 -0700, "Weng Tianxiang" <>
    wrote:

    >I am using Window XP system and run ModelSim simulator.
    >
    >Please let me know what script software can be used and your
    >recommendation.
    >
    >I would like to learn to write scripts under ModelSim simulation
    >environment.



    Under ModelSim, it is probably easiest to use TCL.

    One option is to generate the filename (or even just the date/time) in
    TCL, and pass it into the "Run" command as the value of a generic of
    type String.

    - Brian
    Brian Drummond, Sep 26, 2006
    #5
  6. Brian Drummond wrote:
    > On 25 Sep 2006 10:12:27 -0700, "Weng Tianxiang" <>
    > wrote:
    >
    > >I am using Window XP system and run ModelSim simulator.
    > >
    > >Please let me know what script software can be used and your
    > >recommendation.
    > >
    > >I would like to learn to write scripts under ModelSim simulation
    > >environment.

    >
    >
    > Under ModelSim, it is probably easiest to use TCL.
    >
    > One option is to generate the filename (or even just the date/time) in
    > TCL, and pass it into the "Run" command as the value of a generic of
    > type String.
    >
    > - Brian


    Hi Brian and David,
    Could you please give some examples on the coding or the reference to
    the manual on how to do it?

    Thank you.

    Weng
    Weng Tianxiang, Sep 26, 2006
    #6
  7. On 26 Sep 2006 10:55:58 -0700, "Weng Tianxiang"
    <> wrote:

    >Could you please give some examples on the coding or the reference to
    >the manual on how to do it?


    hi Weng

    What do you want to do? (Sorry, I missed the first
    part of this thread somehow.) If you want to create
    an output file, something like this...

    # Put this into a .do file and source it into ModelSim
    proc filename_from_date {prefix} {
    set t [clock seconds]
    append prefix [clock format $t -format "%Y-%m-%d_%H-%M"]
    return $prefix
    }
    ########################################

    Now, when you type the command

    filename_from_date Report_File_

    you will get a result like

    Report_File_2006-09-21_21-45

    And you can use this result as the name of a file to open in Tcl...

    set file_handle [open [filename_from_date Report_File_] w]
    puts $file_handle "This is line 1 of the file"
    puts $file_handle "This is line 2"
    close $file_handle

    Is this anything like what you need?????
    --
    Jonathan Bromley, Consultant

    DOULOS - Developing Design Know-how
    VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

    Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK

    http://www.MYCOMPANY.com

    The contents of this message may contain personal views which
    are not the views of Doulos Ltd., unless specifically stated.
    Jonathan Bromley, Sep 26, 2006
    #7
  8. Jonathan Bromley wrote:
    > On 26 Sep 2006 10:55:58 -0700, "Weng Tianxiang"
    > <> wrote:
    >
    > >Could you please give some examples on the coding or the reference to
    > >the manual on how to do it?

    >
    > hi Weng
    >
    > What do you want to do? (Sorry, I missed the first
    > part of this thread somehow.) If you want to create
    > an output file, something like this...
    >
    > # Put this into a .do file and source it into ModelSim
    > proc filename_from_date {prefix} {
    > set t [clock seconds]
    > append prefix [clock format $t -format "%Y-%m-%d_%H-%M"]
    > return $prefix
    > }
    > ########################################
    >
    > Now, when you type the command
    >
    > filename_from_date Report_File_
    >
    > you will get a result like
    >
    > Report_File_2006-09-21_21-45
    >
    > And you can use this result as the name of a file to open in Tcl...
    >
    > set file_handle [open [filename_from_date Report_File_] w]
    > puts $file_handle "This is line 1 of the file"
    > puts $file_handle "This is line 2"
    > close $file_handle
    >
    > Is this anything like what you need?????
    > --
    > Jonathan Bromley, Consultant
    >
    > DOULOS - Developing Design Know-how
    > VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
    >
    > Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
    >
    > http://www.MYCOMPANY.com
    >
    > The contents of this message may contain personal views which
    > are not the views of Doulos Ltd., unless specifically stated.


    Hi Jonathan,
    What I want to do is:
    During ModelSim simulations, I want to generate two files:
    Each time when I start running the simulations, it will do:
    1. Put input data into an input file named after date and time;
    2. Put output data into an output file named with input data file
    appended with
    a string "-out".

    Input and output data are known to the vhdl file or to the wave.do
    file.

    My working operating system is Window XP.

    I don't know Tcl language and I would like to learn it if necessary;

    I am familiar with C and C++.

    This is my plan to do it:
    1. Transfer input and output data into ASCII string using VHDL
    language;
    2. Using vhdl procedures ieee.TEXTIO.all to write ASCII strings into a
    created file
    3. Using C language to do other things with the two files and generate
    report.

    Any advices?

    Thank you.

    Weng
    Weng Tianxiang, Sep 27, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,229
    Michael Borgwardt
    May 30, 2004
  2. ding feng
    Replies:
    2
    Views:
    2,790
    ding feng
    Jun 25, 2003
  3. Keith Cochrane
    Replies:
    2
    Views:
    602
    Keith Cochrane
    Aug 6, 2006
  4. dch3
    Replies:
    2
    Views:
    506
  5. Chad Thatcher
    Replies:
    4
    Views:
    78
    Chad Thatcher
    Feb 3, 2007
Loading...

Share This Page