reading files help

Joined
Nov 16, 2006
Messages
1
Reaction score
0
hello,

i have written code to read in a file, being pgm format, it copies the first 4 lines as they just identifies the file properties, and then i want it to read integer values one by one and output to a file. the expected result should be same as the input file. can anyone tell me whats wrong with my code? any other suggestions how to go about it? and finally i have also been asked to create a memory array to store the information, is there any links or do you know howi would do this?

thank you in advance,

scott

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_textio.all;
use STD.textio.all;

entity file_io is
end file_io;

architecture sim of file_io is
file infile : text open READ_MODE is "input.txt";
file outfile : text open WRITE_MODE is "output.txt";
begin
fcopy : process
variable l: line;
variable number: integer;
variable h: line;
begin -- fcopy process
for i in 1 to 4 loop
readline(infile,l);
writeline(outfile,l);
end loop;
while not endfile(infile) loop
readline(infile,l);
read(l,number);
write(h,number);
writeline(outfile,h);
end loop;
file_close(infile);
file_close(outfile);
wait;
end process fcopy;
end sim;
 

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,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top