Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Changing files

 
Thread Tools Search this Thread
Old 11-16-2006, 12:06 PM   #1
Default Changing files


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é



ALuPin@web.de
  Reply With Quote
Old 11-16-2006, 05:37 PM   #2
Mike Treseler
 
Posts: n/a
Default Re: Changing files

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
  Reply With Quote
Old 11-17-2006, 07:54 AM   #3
ALuPin@web.de
 
Posts: n/a
Default Re: Changing files

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


  Reply With Quote
Old 11-17-2006, 04:11 PM   #4
Jim Lewis
 
Posts: n/a
Default Re: Changing files

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 private.php?do=newpm&u=
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
  Reply With Quote
Old 11-17-2006, 04:47 PM   #5
Mike Treseler
 
Posts: n/a
Default Re: Changing files

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/sear...t+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
  Reply With Quote
Old 11-20-2006, 07:43 AM   #6
ALuPin@web.de
 
Posts: n/a
Default Re: Changing files

Hi,

your help is appreciated.

Thank you for your helpful suggestions.

Rgds
André

  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump