DigitalFactory

VHDL file I/O

산들바람 2009. 12. 17. 20:07
library
Use std.textio.all;

routines
read( )
readline( )
write( )
writeline( )



examples
read_ex : process
file my_file           : text is in "./reading.txt";
variable text_line  : line;
variable tmp        : bit_vector(15 downto 0);
begin
  while not endfile(my_file) loop
    readline(my_file, text_line);
    read(text_line, tmp);
    wait until clk = '0';
  end loop;
end process;

read_ex2 : process(clk)
file my_life           : text is in "./reading.txt";
variable text_line   : line;
variable tmp         : bit_vector(15 downto 0);
begin
  if(clk = '1' and clk'event) then
    readline(my_file, text_line);
    read(text_line, tmp);
  end if;
end process;


write_ex : process(clk)
file my_file          : text is out "./writing,txt";
variable text_line  : line;
begin
  if(clk = '1' and clk'event) then
    write(text_line, integer'(conv_integer(out_data)));
    write(my_file, text_line);
  end if;
end process;