如何在报表语句中将字符串与整数连接?

时间:2015-04-16 18:20:40

标签: vhdl modelsim intel-fpga quartus

我无法获得以下报告声明:

report "ERROR: instruction address '" & CONV_INTEGER(a(7 downto 2)) & "' out of memory range." severity failure;

a的类型为in std_logic_vector(31 downto 0)

我得到的错误是:

No feasible entries for infix operator "&".

我想打印出一个字符串,连接整数值,然后连接另一个字符串。

我做错了什么?

1 个答案:

答案 0 :(得分:3)

使用'IMAGE:

的示例
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity foo is 
end entity;

architecture fum of foo is
    signal a: std_logic_vector (31 downto 0) := x"deadbeef";
begin
    process (a)
    begin
        report "ERROR: instruction address '" & 
--          CONV_INTEGER(a(7 downto 2)) & 
            INTEGER'IMAGE(to_integer(unsigned (a(7 downto 2)))) &
        "' out of memory range." ;-- severity failure;
    end process;
end architecture;

我使用了包numeric_std。原理是一样的,转换例程的名称是不同的。

'IMAGE是一个预定义的属性,它返回一个类型值的字符串表示形式(在本例中为INTEGER)。

你的失败信息是因为没有“&”连接运算符可用,知道如何将整数连接到字符串,所以你提供整数的字符串图像。

运行时:

  

ghdl -r foo
  foo.vhdl:13:9:@ 0ms :(报告说明):ERROR:指令地址'59'超出内存范围。

第7位downto 2是来自位串初始化的“111011”,当表示为整数时恰好等于59.