Changing files

Discussion in 'VHDL' started by ALuPin@web.de, Nov 16, 2006.

  1. Guest

    Hi,

    in the following process I write some data into a file:

    WRITEFILE: PROCESS(clk)
    FILE G: TEXT;
    VARIABLE L: LINE;
    VARIABLE P3 : string(1 TO 2) := "P3";
    VARIABLE homepage : string(1 TO 32):= "# Test";
    VARIABLE four : string(1 TO 3) := "4 4";
    VARIABLE space : string(1 TO 1) := " ";
    BEGIN
    IF falling_edge(clk) THEN
    IF rst_cnt=0 THEN
    FILE_OPEN(G, "test4x4readback.ppm", WRITE_MODE);

    WRITE(L, P3);
    WRITELINE(G, L);
    WRITE(L, homepage);
    WRITELINE(G, L);
    WRITE(L, four);
    WRITELINE(G, L);
    WRITE(L, 255);
    --WRITELINE(G, L);
    rst_cnt <= 1;
    ELSE

    IF ls_wr='1' THEN
    row_cnt <= row_cnt + 3;

    IF row_cnt MOD 24 = 0 OR row_cnt=0 THEN
    WRITELINE(G, L);
    END IF;

    WRITE(L, red); WRITE(L, space);
    WRITE(L, green); WRITE(L, space);
    WRITE(L, blue); WRITE(L, space);

    END IF;

    END IF;
    END IF;
    END PROCESS WRITEFILE;

    Now I want to close the corresponding file when some trigger occurs, at
    the same
    time I want to create a new file and begin to write to it.
    for example :

    #1 trigger
    If trigger='1' THEN
    close (file1);
    open(file2);
    end if;

    #2 trigger
    if trigger='1' THEN
    close(file2);
    open(file3);
    end if;
    ....

    How can I do that ? Do I have to declare the number of files I want to
    write to and
    how do I handle them?


    Thank you for your opinion.

    Rgds
    André
     
    , Nov 16, 2006
    #1
    1. Advertising

  2. wrote:

    > How can I do that ? Do I have to declare the number of files I want to
    > write to and
    > how do I handle them?


    I would

    1. Package constant arrays of records
    for static input.

    2. Declare variable arrays of records
    to collect variable report data.

    3. Write a procedure to format the report
    after the test is done.

    -- Mike Treseler
     
    Mike Treseler, Nov 16, 2006
    #2
    1. Advertising

  3. Guest

    Hi Mike,

    thank you for your response.
    Do you have some example on your homepage ?

    I have some doubts concerning your differentiation
    between constant and variable arrays of records
    for this application.

    So does that mean that the variable arrays stand for
    the definition of the different files (which contain
    image data in ppm format) ?

    Rgds
    André

    >
    > I would
    >
    > 1. Package constant arrays of records
    > for static input.
    >
    > 2. Declare variable arrays of records
    > to collect variable report data.
    >
    > 3. Write a procedure to format the report
    > after the test is done.
    >
    > -- Mike Treseler
     
    , Nov 17, 2006
    #3
  4. Jim Lewis Guest

    wrote:

    > #1 trigger
    > If trigger='1' THEN
    > close (file1);
    > open(file2);
    > end if;
    >
    > #2 trigger
    > if trigger='1' THEN
    > close(file2);
    > open(file3);
    > end if;
    > ...
    >
    > How can I do that ? Do I have to declare the number of files I want to
    > write to and
    > how do I handle them?


    You open and close based on the file handle, G in your
    example above. If you have closed the file handle you
    should be able to re-open it with a different file name.

    file_close (G);
    FILE_OPEN(G, "new_file.ppm", WRITE_MODE);

    Note that the file name is a string expression.

    Cheers,
    Jim
    --
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Jim Lewis
    Director of Training mailto:
    SynthWorks Design Inc. http://www.SynthWorks.com
    1-503-590-4787

    Expert VHDL Training for Hardware Design and Verification
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    Jim Lewis, Nov 17, 2006
    #4
  5. wrote:

    > thank you for your response.
    > Do you have some example on your homepage ?


    I'm not sure. It is in need of a new index.
    Look through these if you like:
    http://groups.google.com/groups/search?q=vhdl file comcast vhd treseler

    > I have some doubts concerning your differentiation
    > between constant and variable arrays of records
    > for this application.


    Stim data that doesn't change can be collected
    in a vhdl constant structure. This is the
    simplest case.

    > So does that mean that the variable arrays stand for
    > the definition of the different files (which contain
    > image data in ppm format) ?


    No. See Jim's reply for an answer to your file question.
    I am not a fan of using files other than
    vhdl packages for verification.

    -- Mike Treseler
     
    Mike Treseler, Nov 17, 2006
    #5
  6. Guest

    Hi,

    your help is appreciated.

    Thank you for your helpful suggestions.

    Rgds
    André
     
    , Nov 20, 2006
    #6
    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. Samridhi Kumar Shukla
    Replies:
    1
    Views:
    532
    Alvin Bruney
    Nov 30, 2003
  2. crazyprakash
    Replies:
    4
    Views:
    3,407
    adrian
    Oct 30, 2005
  3. Replies:
    4
    Views:
    974
    M.E.Farmer
    Feb 13, 2005
  4. Aaron Beall
    Replies:
    2
    Views:
    1,845
    Aaron Beall
    Sep 14, 2007
  5. VK
    Replies:
    3
    Views:
    187
    Dr J R Stockton
    Mar 15, 2007
Loading...

Share This Page