我有以下代码:
library ieee;
use ieee.std_logic_1164.all;
use std.textio.all;
entity read_fail is
end entity read_fail;
architecture test of read_fail is
begin
process
variable l : line;
constant s : string(2 to 5) := "1111";
variable a : std_logic_vector( 3 downto 0);
begin
l := new string'(s);
read(l, a);
DEALLOCATE(l);
report "done read";
wait;
end process;
end architecture;
并且在ActiveHDL中运行时,出现以下错误:
RUNTIME: Fatal Error: RUNTIME_0047 std_logic_1164-body.vhdl (1114): Index 1 out of range (2 to 5)
现在,我可以知道为什么会这样,但是我不确定这是否是LRM故障,或者Aldec是否有自己的实现? LRM中没有任何东西(我可以找到)指定该行必须从索引1开始。
如果我将a更改为bit_vector,则没有问题(因为我假设字符串在读取过程中具有别名,或者使用了“范围”)
如果存在LRM /库问题,最好在VHDL 2018/19中修复它。
编辑
所以这似乎是Aldec问题,解决方法是对返回的切片重新编号:
procedure renumber (l : inout line) is
variable tmp : line;
begin
tmp := new string(1 to l'length);
tmp.all := l.all;
DEALLOCATE(l);
l := tmp;
end procedure;
答案 0 :(得分:1)
肯定,IEEE std_logic_1164包主体不是由Aldec定义的,而是仍然由IEEE分发的。请简单地在其他模拟器中关闭此程序包的加速,以获得与Aldec相同的结果。