Hi All,
I am trying to access text files with binary data in it using the TEXTIO package, but i get errors saying cant access files or file does not exist...below is the copy of the program i am using, please correct me if i am doing anything wrong:
USE WORK.TEXTIO.ALL;
ENTITY square IS
PORT( go : IN std_logic);
END square;
ARCHITECTURE simple OF square IS
BEGIN
PROCESS(go)
FILE infile : TEXT IS IN "/1.txt";
FILE outfile : TEXT IS OUT "/2.txt";
VARIABLE out_line, my_line : LINE;
VARIABLE int_val : INTEGER;
BEGIN
WHILE NOT( ENDFILE(infile)) LOOP
-- read a line from the input file
READLINE( infile, my_line);
-- read a value from the line
READ( my_line, int_val);
if(int_val='0')
THEN int_val := '1';
elsif(int_val='1')
THEN int_val := '0';
else
int_val := '0';
end if;
-- write the changed value to the line
WRITE( out_line, int_val);
-- write the line to the output file
WRITELINE( outfile, out_line);
END LOOP;
END PROCESS;
END simple;
I am trying to access text files with binary data in it using the TEXTIO package, but i get errors saying cant access files or file does not exist...below is the copy of the program i am using, please correct me if i am doing anything wrong:
USE WORK.TEXTIO.ALL;
ENTITY square IS
PORT( go : IN std_logic);
END square;
ARCHITECTURE simple OF square IS
BEGIN
PROCESS(go)
FILE infile : TEXT IS IN "/1.txt";
FILE outfile : TEXT IS OUT "/2.txt";
VARIABLE out_line, my_line : LINE;
VARIABLE int_val : INTEGER;
BEGIN
WHILE NOT( ENDFILE(infile)) LOOP
-- read a line from the input file
READLINE( infile, my_line);
-- read a value from the line
READ( my_line, int_val);
if(int_val='0')
THEN int_val := '1';
elsif(int_val='1')
THEN int_val := '0';
else
int_val := '0';
end if;
-- write the changed value to the line
WRITE( out_line, int_val);
-- write the line to the output file
WRITELINE( outfile, out_line);
END LOOP;
END PROCESS;
END simple;