【问题标题】:Function to_hstring from std.textio is not working [VHDL]来自 std.textio 的函数 to_hstring 不起作用 [VHDL]
【发布时间】:2020-11-15 21:31:09
【问题描述】:

我尝试从 Stack Overflow (How to write an integer to stdout as hexadecimal in VHDL?) 运行一些代码,结果发现 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; 

以及编译器的输出:

【问题讨论】:

  • to_string 函数不是 std.textio 的一部分。它们与类型位于相同的包中。所以对于std_logic_vectorto_(h/o)string 存在于包std_logic_1164 中。 std.textio 定义如何将文本输出到文件。
  • @Tricky 在阅读了这个问题的答案 (stackoverflow.com/questions/37879954/…) 后,我认为 std.textio 是使用 to_(h/o) 字符串的要求,这些函数是其中的一部分。但现在我明白了,谢谢!

标签: vhdl active-hdl


【解决方案1】:

在写问题时,我再次阅读 (How to write an integer to stdout as hexadecimal in VHDL?),发现提到了 VHDL-2008。之后我检查了我的编译命令(由 Active-HDL 自动生成),结果发现 VHDL-2002 是编译命令的默认值:

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

以下是部分内容

help acom

输出

以及程序执行的输出:

【讨论】:

  • 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 下载。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多