如何从VHDL中的文本文件中读取32位std_logic_vector数据

时间:2015-04-29 08:08:01

标签: vhdl

我想从文本文件中读取32位有符号数,并将其存储在变量中。我有整数读取程序,但它不适用于std_logic_vector类型。

1 个答案:

答案 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