How to write an integer to stdout as hexadecimal in VHDL?
问题 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 回答1: 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);