printf() function like C in VHDL ?

2027 views
Skip to first unread message

Jerome Chaix

unread,
Jan 28, 1999, 3:00:00 AM1/28/99
to
Is there an existing function in VHDL which is the equivalent of
printf(%d, var) in language C ?
jerome_chaix.vcf

Umesh Chandra Gowda

unread,
Jan 28, 1999, 3:00:00 AM1/28/99
to

Hi Jerome,

The easiest way to implement the printf("%d\n", var) function in VHDL is by using VHDL-93. The solution would be as follows:

...
architecture tb of design_testbench is
file output : text open write_mode is "output.dat";
...
variable li : line;
...
write (li, string'("The number is: ") & integer'IMAGE(i));
writeline ( output, li );

The IMAGE attribute is just great and works also with other variable types. If your design is in VHDL-87 you still can mix VHDL-93 testbench files (at least with Modelsim).

Regards,
Umesh Gowda

**********************************************************
* Umesh Gowda +358 9 4131 2458 (Direct) *
* ASIC Dvelopment +358 40 503 7028 (Mobile) *
* Tellabs Oy +358 9 4131 2200 (Fax) *
* FIN-02630 Espoo http://www.tellabs.fi *
* Finland http://www.hut.fi/~ugowda *
* *
* Umesh.Gowda@replace_with_tellabs.fi OR *
* ugo...@cc.replace_with_hut.fi *
**********************************************************


Jerome Chaix <jerome...@mentorg.com> writes:

>This is a multi-part message in MIME format.
>--------------A31D2781A163B7C7CA2E5B0E
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit

>Is there an existing function in VHDL which is the equivalent of
>printf(%d, var) in language C ?

>--------------A31D2781A163B7C7CA2E5B0E
>Content-Type: text/x-vcard; charset=us-ascii;
> name="jerome_chaix.vcf"
>Content-Transfer-Encoding: 7bit
>Content-Description: Card for Jerome Chaix
>Content-Disposition: attachment;
> filename="jerome_chaix.vcf"

>begin:vcard
>n:Chaix;Jerome
>tel;home:04 93 65 45 87
>tel;work:04 92 94 24 60
>x-mozilla-html:TRUE
>url:http://www.mentorg.com
>org:Mentor Graphics
>adr:;;CICA 2229 Route des cretes;sophia-antipolis;;;France
>version:2.1
>email;internet:jerome...@mentorg.com
>x-mozilla-cpt:;-1
>fn:Jerome Chaix
>end:vcard

>--------------A31D2781A163B7C7CA2E5B0E--


Edwin Naroska

unread,
Jan 28, 1999, 3:00:00 AM1/28/99
to
Hi,

Jerome Chaix wrote:

> Is there an existing function in VHDL which is the equivalent of
> printf(%d, var) in language C ?

There is a C-style fprintf package available free upon request
from www.easic.com . See

http://www.easics.com/method/inhouse.html


--
Edwin


Paul Mc Canny

unread,
Jan 28, 1999, 3:00:00 AM1/28/99
to
Jerome Chaix wrote:
>
> Is there an existing function in VHDL which is the equivalent of
> printf(%d, var) in language C ?
>
> ---------------------------------------------------------------
>
> Name: jerome_chaix.vcf
> Part 1.2 Type: text/x-vcard
> Encoding: 7bit
> Description: Card for Jerome Chaix

is it

assert false
report "<message>"
severity NOTE;

I've only started using VHDL recently but I think this is right.

Paul Mc Canny

Rubel Ahmed

unread,
Feb 10, 2019, 4:42:18 PM2/10/19
to
On Thursday, January 28, 1999 at 3:00:00 AM UTC-5, Jerome Chaix wrote:
> Is there an existing function in VHDL which is the equivalent of
> printf(%d, var) in language C ?

I do the following and it works for me. though I am a noob.

assert false
report "show me what you got: "&integer'image(myVar) severity NOTE;

KJ

unread,
Feb 10, 2019, 6:05:39 PM2/10/19
to
You can also simply use the 'report' without having to 'assert'. When the report clause is used as part of an assert statement, the default severity is ERROR, but when you just use the report statement by itself, the default severity is 'NOTE'[1]. So an even simpler equivalent to 'printf' would be

report "show me what you got: "&integer'image(myVar);

Kevin Jennings

[1] Refer to sections 10.3 (Assertion statement) and 10.4 (Report statement).

Nicolas Matringe

unread,
Feb 11, 2019, 4:22:50 PM2/11/19
to
Do you realize you just replied to a 20 years old thread ?

Nicolas

Rubel Ahmed

unread,
Feb 11, 2019, 4:45:28 PM2/11/19
to
No, i did not notice at the first look. But it felt so good to find the age of this post, i spent 10 minutes reading the History of google groups.

gnuarm.del...@gmail.com

unread,
Feb 11, 2019, 5:00:21 PM2/11/19
to
Some things are timeless.... :)

Rick C.

francis cagney

unread,
Nov 13, 2020, 6:43:58 AM11/13/20
to
Actually I came here because I was wondering about a printf for vhdl. 21 year old thread updated less than 2 years ago.

There are 2 printf type implementations

https://github.com/xcthulhu/coded_aperture_vhdl

c_vhdl library has null terminated strings, regex, stdio, and variable argument printf or sprintf, fprintf. It has not been maintained since 10 years.

https://github.com/suoto/hdl_string_format

This one was last updated 5 years ago and is limited

Ömer Ziya AYDIN

unread,
Sep 10, 2021, 10:16:49 AM9/10/21
to
12 Şubat 2019 Salı tarihinde saat 00:22:50 UTC+3 itibarıyla Nicolas Matringe şunları yazdı:
That's amazing lol

Nikolaos Kavvadias

unread,
Sep 13, 2021, 1:30:24 PM9/13/21
to
Στις Παρασκευή, 10 Σεπτεμβρίου 2021 στις 4:16:49 μ.μ. UTC+2, ο χρήστης Ömer Ziya AYDIN έγραψε:
> 12 Şubat 2019 Salı tarihinde saat 00:22:50 UTC+3 itibarıyla Nicolas Matringe şunları yazdı:
> > On 10/02/2019 22:42, Rubel Ahmed wrote:
> > > On Thursday, January 28, 1999 at 3:00:00 AM UTC-5, Jerome Chaix wrote:
> > >> Is there an existing function in VHDL which is the equivalent of
> > >> printf(%d, var) in language C ?

I used to have the package described in http://bear.ces.cwru.edu/VHDL/doc/snug2002_20040606_slides.pdf

and had used it once or twice.
Reply all
Reply to author
Forward
0 new messages