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