这不起作用。每当我将变量line_content:string(1到4)更改为string(1到20)时,似乎都会出现错误。
它表示存在断言失败:字符串读取失败。 断言失败了。 模拟失败。
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use STD.textio.all;
ENTITY read_file IS
END read_file;
ARCHITECTURE beha OF read_file IS
BEGIN
-- Read process
process
file file_pointer : text;
variable line_content : string(1 to 20);
variable line_num : line;
begin
--Open the file read.txt from the specified location for reading(READ_MODE).
file_open(file_pointer,"1.txt",READ_MODE);
while not endfile(file_pointer) loop --till the end of file is reached continue.
readline (file_pointer,line_num); --Read the whole line from the file
--Read the contents of the line from the file into a variable.
READ (line_num,line_content);
report line_content;
end loop;
file_close(file_pointer); --after reading all the lines close the file.
wait;
end process;
end beha;