How to concatenate strings with integer in report statement?

Nate picture Nate · Apr 16, 2015 · Viewed 7.5k times · Source

I'm having trouble getting the following report statement to work:

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

Where a is of type in std_logic_vector(31 downto 0).

The error I'm getting is:

No feasible entries for infix operator "&".

I'm wanting to print out a string, concatenate the integer value, then concatenate another string.

What am I doing wrong?

Answer

user1155120 picture user1155120 · Apr 16, 2015

An example of using '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;

I used package numeric_std. The principle is the same, the name of the conversion routine is different.

'IMAGE is a predefined attribute that returns a string representation of a value of a type (in this case an INTEGER).

Your failure message was because there isn't an "&" concatenation operator available that knows how to concatenate an integer onto a string, so instead you provide the string image of the integer.

When run:

ghdl -r foo
foo.vhdl:13:9:@0ms:(report note): ERROR: instruction address '59' out of memory range.

And bits 7 downto 2 are "111011" from the bit string initialization, which just happens to equal 59 when represented as an integer.