pc and uart compile
[hwmod.git] / src / beh_pc_communication_tb.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
4 use work.gen_pkg.all;
5 use work.textmode_vga_component_pkg.all;
6 use work.textmode_vga_pkg.all;
7 use work.textmode_vga_platform_dependent_pkg.all;
8
9 -- this is for test file io
10 use std.textio.all;
11
12 entity beh_pc_communication_tb is
13 end entity beh_pc_communication_tb;
14
15 architecture sim of beh_pc_communication_tb is
16                 type byte_file_type is file of hbyte;
17                 signal sys_clk : std_logic;
18                 signal sys_res_n : std_logic;
19                 signal btn_a : std_logic;
20                 signal tx_new : std_logic;
21                 signal tx_done : std_logic;
22                 signal rx_new : std_logic;
23                 signal d_get : std_logic;
24                 signal d_done : std_logic;
25                 signal rx_data, tx_data : std_logic_vector(7 downto 0);
26
27                 signal d_zeile : hzeile;
28                 signal d_spalte : hspalte;
29                 signal d_char : hbyte;
30 begin
31         -- display
32         inst : entity work.pc_communication(beh)
33         port map (
34                 sys_clk => sys_clk,
35                 sys_res_n => sys_res_n,
36
37                 --button
38                 btn_a => btn_a,
39
40                 --uart_tx
41                 tx_data => tx_data,
42                 tx_new => tx_new,
43                 tx_done => tx_done,
44
45                 --uart_rx
46                 rx_data => rx_data,
47                 rx_new => rx_new,
48
49                 -- History
50                 d_zeile => d_zeile,
51                 d_spalte => d_spalte,
52                 d_get => d_get,
53                 d_done => d_done,
54                 d_char => d_char
55         );
56
57         clk : process
58         begin
59                 sys_clk <= '0';
60                 wait for 15 ns;
61                 sys_clk <= '1';
62                 wait for 15 ns;
63         end process clk;
64
65         stub_history : process
66                 file f : byte_file_type open read_mode is "../../src/pc_communication.test";
67                 variable rb : hbyte;
68         begin
69                 wait until rising_edge(d_get);
70                 assert not endfile(f) report "test beendet" severity failure;
71                 read(f, rb);
72                 wait for 30 ns;
73                 d_char <= rb;
74                 d_done <= '1';
75                 wait for 15 ns;
76                 d_done <= '0';
77         end process stub_history;
78
79         reset_and_button : process
80         begin
81                 -- init & reset
82                 -- we only simulate pressing of button a by now!
83                 sys_res_n <= '0';
84                 wait for 100 ns;
85                 sys_res_n <= '1';
86
87                 btn_a <= '1';
88                 wait for 15ns;
89                 btn_a <= '0';
90                 wait;
91         end process reset_and_button;
92
93 end architecture sim;