Minimal examples tested on GHDL 0.33
Read 4 input lines from stdin, and spit each one right back to stdout:
library std;
use std.textio.all;
library ieee;
use ieee.std_logic_1164.all;
entity tmp_tb is
end;
architecture behav of tmp_tb is
begin
process
variable my_line : line;
begin
for i in 3 downto 0 loop
readline(input, my_line);
writeline(output, my_line);
end loop;
wait;
end process;
end;
Read 4 integers from stdin and write them to a a signal. This can then be observed on a generated wave file. Uses: https://stackoverflow.com/questions/7271092/vhdl-convert-string-to-integer-best-way
architecture behav of tmp_tb is
constant clk_period : time := 1 ns;
signal my_integer : integer;
begin
process
variable my_line : line;
variable my_integer_var : integer;
begin
for i in 3 downto 0 loop
readline(input, my_line);
read(my_line, my_integer_var);
my_integer <= my_integer_var;
wait for clk_period / 2;
end loop;
wait;
end process;
end;
A bunch of stdout write examples on GitHub: https://github.com/cirosantilli/vhdl-cheat/blob/3721d42a1f1a8d3de3462ac70f90374c910f176e/write_tb.vhdl
Write integer as hex to stdout: https://stackoverflow.com/questions/37879954/how-to-write-an-integer-to-stdout-as-hexadecimal-in-vhdl