Writing to stdout in VHDL

M

moshezsb

I am trying to write a debug message to stdout. It appears that the only
way
to do this is with the assert command.
So, in Verilog, I would type
$display ("mem[%d] = %d", i, mem);

In VHDL I get something like
assert (1=0) report "mem[" & integer'image(i) & "] = " &
integer'image(mem)) severity note;

Is this the only way to do this? Does textio only work on a file or can it
be used on stdout?
 
S

Steffen Netz

Hello,

the package textio defines the files:
INPUT
OUTPUT.

You can write to OUTPUT, which writes to stdout.

S.Netz
 
M

Mike Treseler

moshezsb said:
In VHDL I get something like
assert (1=0) report "mem[" & integer'image(i) & "] = " &
integer'image(mem)) severity note;

Is this the only way to do this?


This would do the same thing:

report "mem("
& integer'image(i)
& ") = "
& integer'image(mem(i));

-- Mike Treseler
 
M

Mariusz

Hello.
Could you write sample with use package textio to write a debug message.

Now I'm use syntax: assert report ...... as Steffen Netz.

Thx
 
S

Steffen Netz

Hy Mariusz,

look at the example below.
Caution the first ( commented) form of the file declaration is vhdl93,
the second vhdl87!


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
USE STD.TEXTIO.ALL;
USE IEEE.STD_LOGIC_TEXTIO.ALL;

deassemble : PROCESS (trig)
-- FILE reportfile : text IS OUT "deassemble.ir";
FILE reportfile : text OPEN WRITE_MODE IS "deassemble.ir";

VARIABLE befehl: line;
BEGIN
IF trig'event AND trig = '1' AND trig'last_value = '0' THEN
IF dec = '1' THEN
write(befehl,now);
write(befehl,string'(" -> "));
hwrite(befehl,adr);
write(befehl,string'(" : "));
hwrite(befehl,ir);

writeline(REPORTFILE,befehl); -- writes to "deassemble.ir"
writeline(OUTPUT,befehl); -- writes to std_output
end if;
end process;

regard,
Steffen
 
M

Mariusz

Hello.
Thx for sample code.
But i have problem with writes to "deassemble.ir"

In output window is next error
# Error: COMP96_0093: shft_reg.vhd : (69, 14): Actual parameter types in
subprogram call do not match subprogram formal parameter types.

I use first and second form file declaration .

Mariusz
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top