【发布时间】:2020-12-15 11:33:46
【问题描述】:
我有一个文本文件,其中包含计算的预期输出和一个 vhdl 测试台,其中包含一个进行计算的被测模块。这个想法是用文件中的预期输出来计算模块的输出。
该模块在 32 位上工作,文件包含最大 32 位的整数值列表(逐行)。问题是我写了一段代码来比较模块的每个输出和文件的每个输出,但这给了我一个奇怪的错误。
代码是这个:
process
variable line_v : line;
file read_file : text;
variable read_int : integer;
variable read_string: string(1 to 10); --Max integer on 32 bit is 4294967295: 10 chars
begin
file_open(read_file, "mat2.mem", read_mode);
for i in 0 to 31 loop
for j in 0 to 31 loop
readline(read_file, line_v);
read(line_v, read_string);
row <= std_logic_vector(TO_UNSIGNED(i, row'length));
col <= std_logic_vector(TO_UNSIGNED(j, col'length));
wait for 2 ns; -- after 2 ns, I have the result available on 32 bit std_logic_vector "data"
assert unsigned(data) = integer'value(read_string) report "ERROR! Result not equal to expected one!";
end loop;
end loop;
file_close(read_file);
end process;
我收到的错误是这个(根据模拟器数据包含3413424693):
错误:值字符串“3413424693”无法解释为整数类型
我该如何解决这个问题?
谢谢
【问题讨论】:
-
EEE Std 1076-2008 16.2 类型和对象的预定义属性,T'VALUE(X) “限制:如果参数不是 T 类型的文字的有效字符串表示形式或如果结果不属于 T 隐含的子类型。"特定实现中 INTEGER 的范围可从其“低”和“高”属性的值确定。”提供minimal reproducible example。我该如何解决这个问题?考虑包 numeric_bit 或 numeric_std 以及一个输出为无符号类型。输入将是位字符串文字形式的文本字段。
-
Synopsys 包 std_logic_textio 的等效项已合并到各自的 -2008 包 std_logic_1164 和 numeric_std 中。 Synopsys 包 std_logic_textio 和 -2008 numeric_std 包含对无符号类型的读取。在 -2008 位字符串文字中可能有一个十进制基数以及一个长度前缀。否则为二进制、八进制或十六进制。