array of file?

Discussion in 'VHDL' started by hemang, Nov 3, 2006.

  1. hemang

    hemang Guest

    Hi,

    I want to write a vhdl testbench which will write some results to file
    at each clock edge. The testbench is generic with a parameter called
    number_of_channels. For each channel, I want to write the results to
    different file "results_<channel_number>.txt"

    The file name can be created dynamically but the file pointer that I
    need to use the std.textio functions like writeline cannot be created.

    -----------------
    process (clk)
    type text_file_array is array(0 to number_of_channels -1 ) of text; --
    <-- fails in compilation
    variable results_file : text_file_array;
    ....
    begin
    if clk'event and clk='1' then
    for index in 0 to number_of_channels-1 loop
    write(results_line,"junk");
    writeline(results_file(index), results_line);
    end loop;
    end if;
    end process;
    --------------------

    It seems that VHDL-93 LRM prevents "Elements of file type in composite
    types".

    Any idea how I can achieve this? Different package or via procedure
    etc?

    Thanks
    hemang, Nov 3, 2006
    #1
    1. Advertising

  2. hemang wrote:

    > It seems that VHDL-93 LRM prevents "Elements of file type in composite
    > types".


    True.
    >
    > Any idea how I can achieve this? Different package or via procedure
    > etc?


    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 3, 2006
    #2
    1. Advertising

  3. hemang

    hemang Guest

    Mike Treseler wrote:
    >
    > I would
    >
    > 1. Package constant arrays of records
    > for static input.
    >
    > 2. Declare variable arrays of records
    > to collect variable report data.


    I have started going this route. I am collecting the results in arrays
    of variables.
    >
    > 3. Write a procedure to format the report
    > after the test is done.


    Using a single file variable, I change the pointer once I write the
    collected set of data for one channel and move to the next. This seems
    to be working, but it limits the length of simulation I can do because
    of collection of report data and now if run into memory issues, I will
    have to create a block of data to record and then open file, go to the
    end of the file, write to it, close file to be opened again for the
    next block of data.

    do you see any issues in doing anything like this? (probably the only
    thing I haven't done so far is to go to the end of the file)

    Thanks Mike,

    Regards
    Hemang
    hemang, Nov 3, 2006
    #3
  4. hemang wrote:

    > Using a single file variable, I change the pointer once I write the
    > collected set of data for one channel and move to the next. This seems
    > to be working, but it limits the length of simulation I can do because
    > of collection of report data and now if run into memory issues, I will
    > have to create a block of data to record and then open file, go to the
    > end of the file, write to it, close file to be opened again for the
    > next block of data.


    I would just keep the file open and dump it all,
    chan1, chan2, ... chanN.


    > do you see any issues in doing anything like this? (probably the only
    > thing I haven't done so far is to go to the end of the file)


    Try it and see. Simulators are very efficient
    storing native types. If I had to break it up,
    I would make the test channel generic
    and run a tcl loop of vsim -G runs.

    -- Mike Treseler
    Mike Treseler, Nov 3, 2006
    #4
  5. hemang

    hemang Guest

    Thanks Mike.

    A summary of other responses from elsewhere..
    I received a few responses with different variations to tackle the
    problem

    1. Uses generate statement around entity or process and get multiple
    files (one file pointer defined using concatenated string with the
    entity or process). Folks mentioned that this might be a problem if the
    number of files to open are too many (don't know the exact limit..
    may be 1000 for 1000 channels?) and modelsim and at times OS can
    prevent keeping so many files open at the same time

    2. Rapidly open, append, and then close each channel file as I go
    through the capture loop. This is painful in terms of simulation time.


    3. Write all the results in a single file (with appropriate tags to
    identify the results/channel pair) and then do post processing of that
    file to create the individual channel files either in vhdl or C or
    otherwise.

    4. Write all the results in records or arrays and then write the
    results to the different file using a single file pointer (which jumps
    from one to next after completing the current channels results
    writing).. This is memory intensive and can limit the amount of
    simulation results that can be captured)

    Workaround for 4 is to then write all the results in a fixed size array
    and once the array is full, trigger the file writing and then close the
    files and continue with the results capturing. Reopen the file, go to
    the end of the file and write the next set of block of results.. This
    is complicated, but works around all OS and memory limitations.


    At this time, I got the case 4 to work in my environment..
    hemang, Nov 3, 2006
    #5
    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. Daniel
    Replies:
    1
    Views:
    1,052
    Kevin Collins
    Aug 14, 2003
  2. Denis Palas
    Replies:
    2
    Views:
    666
    Daniel Pitts
    Dec 19, 2006
  3. Mara Guida

    const and array of array (of array ...)

    Mara Guida, Sep 2, 2009, in forum: C Programming
    Replies:
    3
    Views:
    490
    David RF
    Sep 3, 2009
  4. Tom
    Replies:
    3
    Views:
    209
    salsablr
    Dec 20, 2004
  5. Tuan  Bui
    Replies:
    14
    Views:
    473
    it_says_BALLS_on_your forehead
    Jul 29, 2005
Loading...

Share This Page