Forum Discussion
Altera_Forum
Honored Contributor
10 years agoWhat simulator are you using? writing NUL to a text file works just fine for me
use std.textio.all;
entity test_chars is
end entity test_chars;
architecture test of test_chars is
begin
process
file f : text;
variable l : line;
begin
FILE_OPEN(f, "test.txt", write_mode);
write(l, NUL & "This string is started and ended with a NUL" & NUL);
-- confirm all chars
for i in l'range loop
write(OUTPUT, l.all(i) & " (" & integer'image(character'pos(l.all(i))) & ")" & LF);
end loop;
writeline(f, l);
FILE_CLOSE(F);
FILE_OPEN(f, "test.txt");
readline(f,l);
--confirm all chars again
for i in l'range loop
write(OUTPUT, l.all(i) & " (" & integer'image(character'pos(l.all(i))) & ")" & LF);
end loop;
FILE_CLOSE(f);
wait;
end process;
end architecture test;