What is the difference between XX'image() and to_string()

F

fl

Guest
Hi,
From the book of Peter's The designer's guide to VHDL, I cannot tell
the difference between attribute: XX'image and to_string. Could anyone
explain that for me? Thanks a lot.
 
fl wrote:
Hi,
From the book of Peter's The designer's guide to VHDL, I cannot tell
the difference between attribute: XX'image and to_string.
The image attribute converts vhdl types to string equivalents.
This is built into the language for some types.
I expect that to_string is an example function
that does something similar, maybe on some other type.

-- Mike Treseler
 
fl wrote:
Hi,
From the book of Peter's The designer's guide to VHDL, I cannot tell
the difference between attribute: XX'image and to_string. Could anyone
explain that for me? Thanks a lot.
They are similar. to_string was added in the IEEE 1076-2008 revision.

to_string is overloadable, so for types for which the default is not
sufficient, we can overload the implicitly defined to_string in the
appropriate packages (which was done in the IEEE 1076-2008 revision).

For more on VHDL-2008, see our website:
http://www.synthworks.com/papers

Best,
Jim

P.S.
A little status on IEEE 1076-2008, it has passed ballot and
will be reviewed by REVCOM later this month. With their
approval (which is expected), it will then become 1076-2008.
From there IEEE will add a few pages (the forward matter stuff
documenting the working group members, the ballot group members, etc)
and then publish the document.

Since much of this standard was released by the Accellera working
group in July of 2006, vendors have already been working on the
features. As a user, I would submit requests for your favorite
features to be implemented to encourage them along in the process.
 
OOPS. I did not finish a few thoughts:
XXType'image(XX) is limited to scalars

to_string by default supports scalars and "one-dimensional array
type whose element type is a character type that contains only
character literals".

While 'image could have been simplified and extended, it still
would not be overloadable, which is the big benefit of to_string.

I expect this to be handy in report statements and the built-in
write (not textio). For example

write(OUTPUT, "Error: data value mismatch." &
"Expected value: " & to_string(Expected_Slv) &
"Actual value: " & to_string(Expected_Slv) & LF ) ;

In the context of write, writeline and report, LF was extended to
be a marker character to indicate produce an appropriate newline
for the OS you are using - in a similar fashion to \n in C except
that it cannot be quoted and put directly in a string.

Cheers,
Jim
 

Welcome to EDABoard.com

Sponsor

Back
Top