std.textio 中的函数to_hstring不起作用 [VHDL]

Function to_hstring from std.textio is not working [VHDL]

提问人:Петр Воротинцев 提问时间:11/16/2020 更新时间:11/16/2020 访问量:4022

问:

我试图从 Stack Overflow 运行一些代码(如何在 VHDL 中将整数写入 stdout 作为十六进制?),结果发现to_hstring不起作用(即使 std 库是 VHDL 的标准)。我正在使用 Active-HDL 9.1(问题的根源可能出在旧版本的 Active-HDL 中)。我是VHDL编码的新手,所以我相信我错过了一些明显的东西。感谢您的帮助!

示例代码如下:

library ieee,std;
    use std.textio.all;
    use ieee.std_logic_1164.all;
    use ieee.numeric_std.all;

entity min is
end min;

architecture behav of min is
begin
    process is
    begin
        report "i = 0x" & to_hstring(to_signed(16, 32));
    end process;
end behav; 

编译器的输出:enter image description here

VHDL 主动 HDL

评论

1赞 Tricky 11/16/2020
to_string函数不是 std.textio 的一部分。它们与类型位于相同的包中。所以对于 ,存在于包中。 定义如何将文本输出到文件。std_logic_vectorto_(h/o)stringstd_logic_1164std.textio
0赞 Петр Воротинцев 11/16/2020
@Tricky 看完这个问题的答案(stackoverflow.com/questions/37879954/...我认为 std.textio 是使用 to_(h/o) 字符串的要求,这些函数是其中的一部分。但现在我明白了,谢谢!

答:

1赞 Петр Воротинцев 11/16/2020 #1

在写这个问题时,我又读了一遍(如何在VHDL中将整数写成stdout作为十六进制?),发现提到了VHDL-2008。之后,我检查了我的编译命令(由 Active-HDL 自动生成),结果发现 VHDL-2002 是编译命令的默认命令:enter image description here

将参数更改为 -2008 后,一切正常:

enter image description here

以下是

help acom

输出

enter image description here

以及程序执行的输出:

enter image description here

评论

0赞 11/16/2020
to_string、to_hstring、to_ostring的函数声明及其在IEEE库中IEEE软件包中声明的数组类型的别名,并合并到-2008修订版中,都可以在这些相同的软件包中找到。参见 IEEE Std 1076-008 附录 E,IEEE Std 1076-2002 的更改。IEEE Std 1076.2-1996、IEEE Std 1164-1993 和 IEEE Std 1076.3-1997 被修订版 -2008 取代。这些软件包的源代码可从 IEEE-SA 下载。