Search code examples
vhdl

VHDL: how to represent signed/unsigned as integer string when >32 bits


I am doing a bunch of DSP verification and for printing when assertions fail, I wrote these functions for signed and unsigned types:

    function to_string(arg : integer) return string is
    begin
        return integer'image(arg);
    end function;

    function to_string(arg : signed) return string is
    begin
        return to_string(to_integer(arg));
    end function;

    function to_string(arg : unsigned) return string is
    begin
        return to_string(to_integer(arg));
    end function;

However, they just broke as some of my results are larger than 32 bits wide. Is there a way in VHDL to provide an integer string representation of signed and unsigned types when they're greater than 32 bits wide? If not, can someone provide a function for providing the hex representation of these numbers to reduce the size of what is printed to the console?


Solution

  • Hex representation is provided for free in VHDL 2008 in the numeric_std package via the to_hstring function. to_string and to_ostring are also provided.

    These functions were provided for all bit-based types in their native packages. write, owrite and hwrite are also provided for writing to a line.