UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
140 Views
Registered: ‎08-07-2018

Use some equivalent for $display in vhdl

Jump to solution

Greetings ... someone can help me find an equivalent, or some way to perform this operation in vhdl.

$display( "//! g1_wbus_stack.v: ADDR = 0x%08x, WDATA=0x%08x" , o_wbus_addr,o_wbus_data);

Any help is welcome, thanks in advance.

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Adventurer
Adventurer
122 Views
Registered: ‎03-28-2014

Re: Use some equivalent for $display in vhdl

Jump to solution

This doesn't get you there entirely, but you can use the 'IMAGE attribute to print the integer representation of the value. For example:

assert false report "g1_wbus_stack.v: ADDR = " & INTEGER'IMAGE(o_wbus_addr) & ",WDATA= " & integer'Image(o_wbus_data) severity note;

where I'm expecting o_wbus_addr to be integer type. If it isn't you'll have to do a type conversion.

3 Replies
Highlighted
Adventurer
Adventurer
123 Views
Registered: ‎03-28-2014

Re: Use some equivalent for $display in vhdl

Jump to solution

This doesn't get you there entirely, but you can use the 'IMAGE attribute to print the integer representation of the value. For example:

assert false report "g1_wbus_stack.v: ADDR = " & INTEGER'IMAGE(o_wbus_addr) & ",WDATA= " & integer'Image(o_wbus_data) severity note;

where I'm expecting o_wbus_addr to be integer type. If it isn't you'll have to do a type conversion.

89 Views
Registered: ‎01-08-2012

Re: Use some equivalent for $display in vhdl

Jump to solution

Here's the same thing less verbosely:

report "g1_wbus_stack.v: ADDR = " & INTEGER'IMAGE(o_wbus_addr) & ",WDATA= " & integer'Image(o_wbus_data);

This probably wouldn't work though, as the signals (?) are probably std_logic_vector, so the code might need to be:

report "g1_wbus_stack.v: ADDR = " & INTEGER'IMAGE(to_integer(unsigned(o_wbus_addr))) & ",WDATA= " & integer'Image(to_integer(unsigned(o_wbus_data)));

Well, that's rather ugly.  This is why most VHDL users I know implement their own package of "to_string" and "to_hex_string" functions that are overloaded to support all types that need printing.  Unfortunately, such packages aren't standardised (or if they are, they aren't supported by the tools).

AFAIK, VHDL is incapable (by design!) of implementing "varargs" - a function with a variable number of parameters of different type (even though it does support optional parameters and default values).  This means that it won't ever be able to do printf-like formatting.

0 Kudos
Scholar richardhead
Scholar
77 Views
Registered: ‎08-01-2012

Re: Use some equivalent for $display in vhdl

Jump to solution

@allanherriman

VHDL has standardised to_string - VHDL 2008 has a to_string function for all standard types. In addition, all bit-based types (std_logic_vector, (un)signed, bit_vector) have to_hstring and to_ostring functions also. Even better, these are now part of their respective libraries, so the non-standard std_logic_textio is redundant.

So VHDL 2008 allows (with no special libraries or custom packages)

report "g1_wbus_stack.v: ADDR = 0x" & to_hstring(o_wbus_addr) & ",WDATA= 0x" & to_hstring(o_wbus_data);

The big problem is, Vivado STILL doesnt support these new functions in their simulator.