array of file?

H

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 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 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 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
 
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..
 

Welcome to EDABoard.com

Sponsor

Back
Top