-
Notifications
You must be signed in to change notification settings - Fork 0
/
UART_TB.vhd
153 lines (111 loc) · 3.54 KB
/
UART_TB.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY UART_TB IS
END UART_TB;
ARCHITECTURE behavior OF UART_TB IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT UART
PORT(
UART_RESET_ALL_TX : IN std_logic;
UART_RESET_ALL_RX : IN std_logic;
UART_CLK : IN std_logic;
UART_START : IN std_logic;
UART_CTS : IN std_logic;
UART_B_IN : IN std_logic_vector(0 to 6);
UART_AVAILABLE : OUT std_logic;
UART_TX_OUT : OUT std_logic;
UART_RX_IN : IN std_logic;
UART_STOP_RX_IN : IN std_logic;
UART_DATA_OUT : OUT std_logic_vector(6 downto 0);
UART_RTS_OUT : OUT std_logic;
UART_END_ERR_OUT : OUT std_logic;
UART_PAR_ERR_OUT : OUT std_logic;
UART_READY_OUT : OUT std_logic
);
END COMPONENT;
--Inputs
signal L_UART_RESET_ALL_TX : std_logic;
signal L_UART_RESET_ALL_RX : std_logic;
signal L_UART_CLK : std_logic;
signal L_UART_START : std_logic;
signal L_UART_B_IN : std_logic_vector(0 to 6);
signal L_UART_RX : std_logic;
signal L_UART_STOP_RX_IN : std_logic;
--Outputs
signal L_UART_AVAILABLE : std_logic;
signal L_UART_DATA_OUT : std_logic_vector(6 downto 0);
signal L_UART_RTS : std_logic;
signal L_UART_END_ERR_OUT : std_logic;
signal L_UART_PAR_ERR_OUT : std_logic;
signal L_UART_READY_OUT : std_logic;
-- Clock period definitions
constant UART_CLK_period : time := 50 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: UART PORT MAP (
UART_RESET_ALL_TX => L_UART_RESET_ALL_TX,
UART_RESET_ALL_RX => L_UART_RESET_ALL_RX,
UART_CLK => L_UART_CLK,
UART_START => L_UART_START,
UART_CTS => L_UART_RTS,
UART_B_IN => L_UART_B_IN,
UART_AVAILABLE => L_UART_AVAILABLE,
UART_TX_OUT => L_UART_RX,
UART_RX_IN => L_UART_RX,
UART_STOP_RX_IN => L_UART_STOP_RX_IN,
UART_DATA_OUT => L_UART_DATA_OUT,
UART_RTS_OUT => L_UART_RTS,
UART_END_ERR_OUT => L_UART_END_ERR_OUT,
UART_PAR_ERR_OUT => L_UART_PAR_ERR_OUT,
UART_READY_OUT => L_UART_READY_OUT
);
-- Clock process definitions
UART_CLK_process :process
begin
L_UART_CLK <= '0';
wait for UART_CLK_period/2;
L_UART_CLK <= '1';
wait for UART_CLK_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
wait for 100 ns;
L_UART_RESET_ALL_TX <= '1';
L_UART_RESET_ALL_RX <= '1';
L_UART_STOP_RX_IN <= '0';
L_UART_START <= '0';
wait for UART_CLK_period*10;
L_UART_RESET_ALL_TX <= '0';
L_UART_RESET_ALL_RX <= '0';
L_UART_B_IN <= "1100100";
L_UART_START <= '1';
wait for UART_CLK_period*16*10;
L_UART_B_IN <= "1011100";
wait for UART_CLK_period*16*2;
L_UART_STOP_RX_IN <= '1';
wait for UART_CLK_period*16*15;
L_UART_STOP_RX_IN <= '0';
L_UART_B_IN <= "1010100";
wait for UART_CLK_period*16*1;
L_UART_START <= '0';
wait for UART_CLK_period*16*9;
L_UART_B_IN <= "1010110";
L_UART_START <= '1';
wait for UART_CLK_period*8;
L_UART_START <= '0';
wait for UART_CLK_period*8;
wait for UART_CLK_period*16*9;
L_UART_B_IN <= "0010110";
L_UART_START <= '1';
wait for UART_CLK_period*16*10;
L_UART_B_IN <= "1010111";
wait for UART_CLK_period*16*10;
L_UART_B_IN <= "1010110";
wait for UART_CLK_period*16*10;
L_UART_B_IN <= "0101111";
wait for UART_CLK_period*16;
L_UART_START <= '0';
wait;
end process;
END;