OpenCores
URL https://opencores.org/ocsvn/modbus/modbus/trunk

Subversion Repositories modbus

[/] [modbus/] [trunk/] [enlace/] [uart_TB.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 guanucolui
 
2
-- VHDL Test Bench Created from source file uart_rs232.vhd -- 21:28:36 07/21/2010
3
--
4
-- Notes: 
5
-- This testbench has been automatically generated using types std_logic and
6
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends 
7
-- that these types always be used for the top-level I/O of a design in order 
8
-- to guarantee that the testbench will bind correctly to the post-implementation 
9
-- simulation model.
10
--
11
LIBRARY ieee;
12
USE ieee.std_logic_1164.ALL;
13
USE ieee.numeric_std.ALL;
14
 
15
ENTITY uart_rs232_uart_TB_vhd_tb IS
16
END uart_rs232_uart_TB_vhd_tb;
17
 
18
ARCHITECTURE behavior OF uart_rs232_uart_TB_vhd_tb IS
19
 
20
        COMPONENT uart_rs232
21
        PORT(
22
                clk : IN std_logic;
23
                reset : IN std_logic;
24
                send_data : IN std_logic;
25
                data_in : IN std_logic_vector(7 downto 0);
26
                even_odd : IN std_logic;
27
                rxd : IN std_logic;
28
                txd : OUT std_logic;
29
                transmitter_busy : OUT std_logic;
30
                send_done : OUT std_logic;
31
                data_out : OUT std_logic_vector(7 downto 0);
32
                parity_error : OUT std_logic;
33
                start_error : OUT std_logic;
34
                stop_error : OUT std_logic;
35
                discrepancy_error : OUT std_logic;
36
                receiver_busy : OUT std_logic;
37
                new_data : OUT std_logic
38
                );
39
        END COMPONENT;
40
 
41
        SIGNAL clk :  std_logic;
42
        SIGNAL reset :  std_logic;
43
        SIGNAL send_data :  std_logic;
44
        SIGNAL data_in :  std_logic_vector(7 downto 0);
45
        SIGNAL even_odd :  std_logic;
46
        SIGNAL rxd :  std_logic;
47
        SIGNAL txd :  std_logic:='1';
48
        SIGNAL transmitter_busy :  std_logic;
49
        SIGNAL send_done :  std_logic;
50
        SIGNAL data_out :  std_logic_vector(7 downto 0);
51
        SIGNAL parity_error :  std_logic;
52
        SIGNAL start_error :  std_logic;
53
        SIGNAL stop_error :  std_logic;
54
        SIGNAL discrepancy_error :  std_logic;
55
        SIGNAL receiver_busy :  std_logic;
56
        SIGNAL new_data :  std_logic;
57
 
58
 
59
        signal comiezo  :       std_logic_vector(7 downto 0):= "01010101";
60
        signal segundo :        std_logic_vector(7 downto 0):= "11100111";
61
     signal dospuntos : std_logic_vector(7 downto 0):= "00111010";               --: ascii
62
     signal cero         :      std_logic_vector(7 downto 0):= "00110000";               --0 ascii
63
        signal siete     :      std_logic_vector(7 downto 0):="00110111";                --7 ascii
64
        signal uno      :       std_logic_vector(7 downto 0):="00110001";                --1 ascii
65
        signal ocho     :std_logic_vector(7 downto 0):= "00111000";              --8 ascii
66
        signal la_a     :std_logic_vector(7 downto 0):=  "01000001";             --A ascii
67
        signal cinco   :std_logic_vector(7 downto 0):=   "00110101";             --5 ascii
68
        signal la_f     :std_logic_vector(7 downto 0):= "01000110";              --F ascii
69
        signal cr               :std_logic_vector(7 downto 0):= "00001101";              --CR ascii
70
        signal lf               :std_logic_vector(7 downto 0):= "00001010";              --LF ascii
71
 
72
 
73
 
74
           -- Clock period definitions
75
   constant clk_period : time := 20ns;
76
 
77
 
78
BEGIN
79
 
80
        uut: uart_rs232 PORT MAP(
81
                clk => clk,
82
                reset => reset,
83
                send_data => send_data,
84
                data_in => data_in,
85
                even_odd => even_odd,
86
                rxd => rxd,
87
                txd => txd,
88
                transmitter_busy => transmitter_busy,
89
                send_done => send_done,
90
                data_out => data_out,
91
                parity_error => parity_error,
92
                start_error => start_error,
93
                stop_error => stop_error,
94
                discrepancy_error => discrepancy_error,
95
                receiver_busy => receiver_busy,
96
                new_data => new_data
97
        );
98
 
99
            -- Clock process definitions
100
   clk_process :process
101
   begin
102
                clk <= '0';
103
                wait for clk_period/2;
104
                clk <= '1';
105
                wait for clk_period/2;
106
   end process;
107
 
108
 
109
 
110
-- *** Test Bench - User Defined Section ***
111
   tb : PROCESS
112
   BEGIN
113
 
114
                wait for 100ns;
115
                reset <= '1';
116
                send_data <='0';
117
                data_in <= "00000000";
118
                even_odd <= '1';
119
                wait for 100ns;
120
                reset <= '0';
121
 
122
--trama 1               
123
                wait for 300us;
124
                rxd <= '0';
125
                wait for  104us;
126
                for i in 0 to 7 loop
127
                rxd <= comiezo(i);
128
                        wait for 104us;
129
                end loop;
130
                rxd <= '0';
131
                wait for 104us;
132
                rxd <= '1';
133
 
134
--trama 2               
135
                wait for 500us;
136
                rxd <= '0';
137
                wait for  104us;
138
                for i in 0 to 7 loop
139
                rxd <= segundo(i);
140
                        wait for 104us;
141
                end loop;
142
                rxd <= '0';
143
                wait for 104us;
144
                rxd <= '1';
145
 
146
 --trama dos puntos             
147
                wait for 500us;
148
                rxd <= '0';
149
                wait for  104us;
150
                for i in 0 to 7 loop
151
                rxd <= dospuntos(i);
152
                        wait for 104us;
153
                end loop;
154
                rxd <= '0';
155
                wait for 104us;
156
                rxd <= '1';
157
 
158
 --trama dire alto       0 ascii
159
                wait for 500us;
160
                rxd <= '0';
161
                wait for  104us;
162
                for i in 0 to 7 loop
163
                rxd <= cero(i);
164
                        wait for 104us;
165
                end loop;
166
                rxd <= '0';
167
                wait for 104us;
168
                rxd <= '1';
169
 
170
 --trama dire bajo       7 ascii
171
                wait for 500us;
172
                rxd <= '0';
173
                wait for  104us;
174
                for i in 0 to 7 loop
175
                rxd <= siete(i);
176
                        wait for 104us;
177
                end loop;
178
                rxd <= '0';
179
                wait for 104us;
180
                rxd <= '1';
181
 
182
 
183
 --trama función alto    0 ascii
184
                wait for 500us;
185
                rxd <= '0';
186
                wait for  104us;
187
                for i in 0 to 7 loop
188
                rxd <= cero(i);
189
                        wait for 104us;
190
                end loop;
191
                rxd <= '0';
192
                wait for 104us;
193
                rxd <= '1';
194
 
195
 --trama función bajo    1 ascii
196
                wait for 500us;
197
                rxd <= '0';
198
                wait for  104us;
199
                for i in 0 to 7 loop
200
                rxd <= uno(i);
201
                        wait for 104us;
202
                end loop;
203
                rxd <= '0';
204
                wait for 104us;
205
                rxd <= '1';
206
 
207
 
208
 --trama dato1 alto      8 ascii
209
                wait for 500us;
210
                rxd <= '0';
211
                wait for  104us;
212
                for i in 0 to 7 loop
213
                rxd <= ocho(i);
214
                        wait for 104us;
215
                end loop;
216
                rxd <= '0';
217
                wait for 104us;
218
                rxd <= '1';
219
 
220
 --trama dato1 bajo      A ascii
221
                wait for 500us;
222
                rxd <= '0';
223
                wait for  104us;
224
                for i in 0 to 7 loop
225
                rxd <= la_a(i);
226
                        wait for 104us;
227
                end loop;
228
                rxd <= '0';
229
                wait for 104us;
230
                rxd <= '1';
231
 
232
 --trama dato2 alto      5 ascii
233
                wait for 500us;
234
                rxd <= '0';
235
                wait for  104us;
236
                for i in 0 to 7 loop
237
                rxd <=  cinco(i);
238
                        wait for 104us;
239
                end loop;
240
                rxd <= '0';
241
                wait for 104us;
242
                rxd <= '1';
243
 
244
 --trama dato2 bajo      f ascii
245
                wait for 500us;
246
                rxd <= '0';
247
                wait for  104us;
248
                for i in 0 to 7 loop
249
                rxd <=  la_f(i);
250
                        wait for 104us;
251
                end loop;
252
                rxd <= '0';
253
                wait for 104us;
254
                rxd <= '1';
255
 
256
 --trama cr
257
                wait for 500us;
258
                rxd <= '0';
259
                wait for  104us;
260
                for i in 0 to 7 loop
261
                rxd <=  cr(i);
262
                        wait for 104us;
263
                end loop;
264
                rxd <= '0';
265
                wait for 104us;
266
                rxd <= '1';
267
 
268
 --trama lf
269
                wait for 500us;
270
                rxd <= '0';
271
                wait for  104us;
272
                for i in 0 to 7 loop
273
                rxd <=  lf(i);
274
                        wait for 104us;
275
                end loop;
276
                rxd <= '0';
277
                wait for 104us;
278
                rxd <= '1';
279
 
280
 
281
        data_in <= "10101101";
282
        wait for 200us;
283
        send_data <= '1';
284
        wait for 120us;
285
        send_data <= '0';
286
 
287
 
288
 
289
      wait; -- will wait forever
290
   END PROCESS;
291
-- *** End Test Bench - User Defined Section ***
292
 
293
END;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.