我找到了解决方案。如果我想直接以 8 位部分解释数据,我需要使用字符类型的文件并使用'POS属性将它们转换为整数。然后我可以将这些整数转换为位向量。我是这样做的:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_bit.ALL;
LIBRARY std;
USE std.textio.all;
...
TYPE t_char_file IF FILE OF character;
TYPE t_byte_arr IS ARRAY (natural RANGE <>) OF bit_vector(7 DOWNTO 0);
SIGNAL read_arr_byte : t_byte_arr(0 to 199);
...
read_file: PROCESS (start) IS
FILE file_in : t_char_file OPEN read_mode IS "./38478.bin"; -- open the frame file for reading
VARIABLE char_buffer : character;
BEGIN
IF start'EVENT AND start = '1' THEN
FOR i IN read_arr_byte'RANGE LOOP
read(file_in, char_buffer);
read_arr_byte(i) <= bit_vector(to_unsigned(character'POS(char_buffer), 8));
END LOOP; -- i
file_close(file_in);
END IF;
END PROCESS read_file;