Changing files

A

ALuPin

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é
 
M

Mike Treseler

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
 
A

ALuPin

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é
 
J

Jim Lewis

#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:[email protected]
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
M

Mike Treseler

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top