Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > array of file?

Reply
Thread Tools

array of file?

 
 
hemang
Guest
Posts: n/a
 
      11-03-2006
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

 
Reply With Quote
 
 
 
 
Mike Treseler
Guest
Posts: n/a
 
      11-03-2006
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
 
Reply With Quote
 
 
 
 
hemang
Guest
Posts: n/a
 
      11-03-2006

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

 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      11-03-2006
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
 
Reply With Quote
 
hemang
Guest
Posts: n/a
 
      11-03-2006
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..

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
const and array of array (of array ...) Mara Guida C Programming 3 09-03-2009 07:54 AM
length of an array in a struct in an array of structs in a struct in an array of structs Tuan Bui Perl Misc 14 07-29-2005 02:39 PM
Length of Array of Array of Array Tom Perl Misc 3 12-20-2004 05:23 PM
How to combine 2 int Array into ONE int Array ? S300 Java 4 08-19-2003 07:04 PM
hashed array in array need the keys... and length Daniel Perl 1 08-14-2003 06:49 PM



Advertisments