我想从文本文件中读取32位有符号数,并将其存储在变量中。我有整数读取程序,但它不适用于std_logic_vector类型。
答案 0 :(得分:0)
使用VHDL-2008,它可以像:
#container
" test.txt"文本文件然后包含:
0001001000110100XXXXXXXXZZZZZZZZ
使用VHDL-2002,library ieee;
use ieee.std_logic_1164.all;
use std.textio.all;
architecture syn of tb is
begin
process is
file txt_file : text;
variable line_v : line;
variable slv_v : std_logic_vector(31 downto 0);
variable good_v : boolean;
begin
-- Write text file with std_logic_vector
file_open(txt_file, "test.txt", write_mode);
slv_v := X"1234" & "XXXXXXXX" & "ZZZZZZZZ" ;
write(line_v, slv_v);
writeline(txt_file, line_v);
file_close(txt_file);
-- Read text file with std_logic_vector
file_open(txt_file, "test.txt", read_mode);
readline(txt_file, line_v);
report "line_v: " & line_v.all;
read(line_v, slv_v, good_v);
file_close(txt_file);
-- Done
wait;
end process;
end architecture;
/ std_logic_vector
程序不支持write
,但Synopsys软件包read
可用于提供以下程序:
ieee.std_logic_textio