how to show a number in output text?

A

Amit

Hello group,

I'm learning to write a testbench so in part of the code I increment
a variable to count number of errors during simulation.

now, I need to know how I can print out a message showing number of
detected errors as following:

Found n error(s).

where n is the value in the counter variable.

Any help is appreciated.

p.s. I thought using & to concatenate would work but no

report "Found " & err_cnt & " error(s)" !!!! (wrong)
 
P

Pinhas

Concatenation works perfectly ... on strings, but err_cnt isn't a
string.

What you need depends on the type of err_cnt.
If it is integer, simply
report "Found " & integer'image(err_cnt)  & " error(s)"
will do.

- Brian

Some examples (from an AHB monitor VHDL code) at
h--p://bknpk.no-ip.biz/AHB_MON/ahb_mon_1.html
You may also find this page intresting as well:
http://bknpk.no-ip.biz/I2C/leon_2.html
VHDL component to generate VCD waves to replace GHDL VCD wave dump
option
 
A

Amit

Currently what you have to do is (as others have noted):
report "Found " & integer'image(err_cnt) & " error(s)"

IN VHDL-2008 (which some vendors are starting to look at) you can do this:

report "Found " & to_string(err_cnt) & " error(s)"

The "to_string" function is overloaded for EVERY type, so you can use it
on STD_LOGIC_VECTOR, UNSIGNED, Boolean, etc...



Thanks to all for your comments and help.

Regards,
Amit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top