use std.textio.all;
use IEEE.STD_LOGIC_TEXTIO.ALL;
file output_file :text; //fid
variable fstatus :file_open_status;
variable buf :line; //buffer
//文件打开函数
file_open(file_open_status, fid, file_name, file_permission);
//从文件中读入一行内容存入buffer当中
readline(fid, buffer);
//每次从buffer中读取一个数据,以空格作为结束符
read(buffer, variable);
//将buffer中的内容写入文件的一行
writeline(fid, buffer);
//将变量的内容写入到buffer当中
write(buffer, variable);
//当fid 设置为 input 或者 output 时,表示从控制台读入或输出内容,比如
write(output,"Hello");
//当写入内容为字符串常量时,可以直接用
write(fid, string);
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_TEXTIO.ALL;
use std.textio.all;
use IEEE.numeric_std.ALL;
entity sim_test2 is
end sim_test2;
architecture Behavioral of sim_test2 is
signal data :std_logic_vector(11 downto 0) := x"000";
begin
process
file output_file :text;
variable fstatus :file_open_status;
variable buf :line;
variable temp1,temp2,temp3 :integer;
begin
file_open(fstatus, output_file, "output.txt",read_mode);
readline(output_file, buf);
read(buf, temp1);
read(buf, temp2);
read(buf, temp3);
data<=std_logic_vector(to_unsigned(temp1, 4) & to_unsigned(temp2, 4) & to_unsigned(temp3, 4));
file_close(output_file);
wait;
end process;
end Behavioral;
实现功能: