I can print an integer
as decimal to stdout with:
library std;
use std.textio.all;
entity min is
end min;
architecture behav of min is
begin
process is
variable my_line : line;
begin
write(my_line, 16);
writeline(output, my_line);
wait;
end process;
end behav;
which outputs:
16
But how to output instead either:
10
0x10
Assuming an integer i
, and VHDL-2008, you could use:
write(output, integer'image(i) & LF); -- Plain integer value
write(output, "0x" & to_hstring(to_signed(i, 32)) & LF); -- Hexadecimal representation
You need to have use std.textio.all;
for this to work. Change the 32
to reduce the length of the hex value. I chose 32 so that it can represent any integer value in most simulators.
These will also work for report
statements, e.g.
report "i = 0x" & to_hstring(to_signed(i, 32));