1 | LIBRARY ieee ;
|
2 | LIBRARY std ;
|
3 | USE ieee.NUMERIC_STD.all ;
|
4 | USE ieee.std_logic_1164.all ;
|
5 | USE ieee.std_logic_textio.all ;
|
6 | USE ieee.std_logic_unsigned.all ;
|
7 | USE std.textio.all ;
|
8 | ENTITY tx_test_bench IS
|
9 | GENERIC (
|
10 | baud_rate_divisor : INTEGER := 520 );
|
11 | END ;
|
12 |
|
13 | ARCHITECTURE tx_test_bench_arch OF tx_test_bench IS
|
14 | SIGNAL i_inclk : STD_LOGIC ;
|
15 | SIGNAL led_testing : STD_LOGIC;
|
16 | SIGNAL i_tx_start : STD_LOGIC ;
|
17 | SIGNAL o_tx_line_busy : STD_LOGIC ;
|
18 | SIGNAL i_tx_data_bits : STD_LOGIC_VECTOR (0 to 7) ;
|
19 | SIGNAL o_serial_data : STD_LOGIC ;
|
20 | SIGNAL o_tx_done : STD_LOGIC ;
|
21 | SIGNAL i_reset : STD_LOGIC ;
|
22 |
|
23 | COMPONENT uart_tx
|
24 | GENERIC (
|
25 | baud_rate_divisor : INTEGER );
|
26 | PORT (
|
27 | i_inclk : in STD_LOGIC ;
|
28 | led_testing : out STD_LOGIC;
|
29 | i_tx_start : in STD_LOGIC ;
|
30 | o_tx_line_busy : out STD_LOGIC ;
|
31 | i_tx_data_bits : in STD_LOGIC_VECTOR (0 to 7);
|
32 | o_serial_data : out STD_LOGIC ;
|
33 | o_tx_done : out STD_LOGIC ;
|
34 | i_reset : in STD_LOGIC );
|
35 | END COMPONENT ;
|
36 | BEGIN
|
37 | DUT : uart_tx
|
38 | GENERIC MAP (
|
39 | baud_rate_divisor => baud_rate_divisor )
|
40 | PORT MAP (
|
41 | i_tx_start => i_tx_start ,
|
42 | i_inclk => i_inclk ,
|
43 | i_tx_data_bits => i_tx_data_bits ,
|
44 | o_serial_data => o_serial_data ,
|
45 | o_tx_line_busy => o_tx_line_busy ,
|
46 | o_tx_done => o_tx_done ,
|
47 | led_testing => led_testing,
|
48 | i_reset => i_reset ) ;
|
49 |
|
50 |
|
51 |
|
52 | -- "Clock Pattern" : dutyCycle = 50
|
53 | -- Start Time = 0 ps, End Time = 100 ms, Period = 20 ns
|
54 | Process
|
55 | Begin
|
56 | i_inclk <= '0' ;
|
57 | wait for 10 ns ;
|
58 | i_inclk <= '1' ;
|
59 | wait for 10 ns ;
|
60 | -- dumped values till 100 ps
|
61 |
|
62 | End Process;
|
63 |
|
64 |
|
65 | -- "Constant Pattern"
|
66 | -- Start Time = 0 ps, End Time = 10 ps, Period = 0 ps
|
67 | Process
|
68 | Begin
|
69 | wait until rising_edge(led_testing);
|
70 | i_tx_start <= '1' ;
|
71 | i_tx_data_bits <= "10101010" ;
|
72 | wait until rising_edge(led_testing);
|
73 | i_tx_start <= '0';
|
74 | wait until o_tx_done<='1';
|
75 | ---- dumped values till 10 ps
|
76 | wait;
|
77 | End Process;
|
78 |
|
79 | end;
|