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

Subversion Repositories uart_fpga_slow_control_migrated

[/] [uart_fpga_slow_control/] [trunk/] [code/] [testbenches/] [tb_UART_control.vhd] - Blame information for rev 24

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 aborga
--------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer:                    Predonzani Mauro (predmauro@libero.it)
4
--
5
-- Create Date:   21:44:39 31/08/2011
6
-- Design Name:   
7
-- Module Name:   tb_UART_control.vhd
8
-- Project Name:  UART
9
-- Target Device:  
10
-- Tool versions:  
11
-- Description:   create a stimulus to test ab_top.vhd
12
-- 
13
-- VHDL Test Bench: ab_top
14
-- 
15
-- Dependencies:        ad_top.vhd
16
-- 
17
-- Revision:
18
-- Revision 0.01 - File Created
19
-- Additional Comments:
20
--------------------------------------------------------------------------------
21
LIBRARY ieee;
22
USE ieee.std_logic_1164.ALL;
23
USE ieee.std_logic_unsigned.all;
24
USE ieee.numeric_std.ALL;
25
 
26
ENTITY tb_ab_top IS
27
END tb_ab_top;
28
 
29
ARCHITECTURE behavior OF tb_ab_top IS
30
 
31
        -- Component Declaration for the Unit Under Test (UUT)
32
 
33
        COMPONENT ab_top
34
        PORT(
35
                clk_uart_29MHz_i   : in     std_logic;
36
                clk_uart_monitor_o : out    std_logic;
37
                uart_rst_i         : in     std_logic;
38
                uart_leds_o        : out    std_logic_vector(7 downto 0);
39
    uart_dout_o        : out    std_logic;
40
    uart_din_i         : in     std_logic);
41
        END COMPONENT;
42
 
43
        --Inputs
44
        signal sys_clk_i : std_logic := '0';
45
        signal uart_din_emu : std_logic := '0';
46
        signal uart_rst_emu : std_logic := '0';
47
 
48
        --Outputs
49
        signal uart_dout_emu : std_logic;
50
        signal s_br_clk_uart_o : std_logic;
51
        signal uart_leds_emu : std_logic_vector (7 downto 0);
52
 
53
        constant uart_clock_period : time := 34 ns;
54
        constant bit_period : time := uart_clock_period*32;
55
 
56
        type sample_array is array (natural range<>) of std_logic_vector (7 downto 0);
57
 
58
        constant test_data : sample_array :=
59
                (
60
                -- 1st data
61
                        X"00", -- BYTE1
62
                        X"20", -- BYTE2
63
                        X"08", -- BYTE3
64
                        X"40", -- BYTE4
65
                        X"80", -- BYTE5
66
                        X"20", -- BYTE6
67
                -- 2nd data     
68
                        X"00", -- BYTE1
69
                        X"30", -- BYTE2
70
                        X"09", -- BYTE3
71
                        X"41", -- BYTE4
72
                        X"81", -- BYTE5
73
                        X"21", -- BYTE6
74
                -- 3rd data
75
                        X"00", -- BYTE1
76
                        X"31", -- BYTE2
77
                        X"8A", -- BYTE3
78
                        X"44", -- BYTE4
79
                        X"88", -- BYTE5
80
                        X"6a", -- BYTE6
81
                -- 4th data     
82
                        X"00", -- BYTE1
83
                        X"32", -- BYTE2
84
                        X"08", -- BYTE3
85
                        X"40", -- BYTE4
86
                        X"80", -- BYTE5
87
                        X"20", -- BYTE6
88
                -- 5th data
89
                        X"00", -- BYTE1
90
                        X"40", -- BYTE2
91
                        X"08", -- BYTE3
92
                        X"40", -- BYTE4
93
                        X"80", -- BYTE5
94
                        X"20", -- BYTE6
95
                -- 6th data     
96
                        X"00", -- BYTE1
97
                        X"50", -- BYTE2
98
                        X"08", -- BYTE3
99
                        X"40", -- BYTE4
100
                        X"80", -- BYTE5
101
                        X"20", -- BYTE6
102
                -- 7th data     
103
                        X"80", -- BYTE1
104
                        X"00", -- BYTE2
105
                        X"00", -- BYTE3
106
                        X"00", -- BYTE4
107
                        X"00", -- BYTE5
108
                        X"00"  -- BYTE6
109
                        -- add other data
110
                );
111
 
112
BEGIN
113
 
114
        -- Instantiate the Unit Under Test (UUT)
115
 
116
        uut: ab_top PORT MAP(
117
                clk_uart_29MHz_i => sys_clk_i,
118
                clk_uart_monitor_o =>  s_br_clk_uart_o,
119
                uart_rst_i => uart_rst_emu,
120
                uart_leds_o => uart_leds_emu,
121
                uart_dout_o => uart_dout_emu,
122
                uart_din_i => uart_din_emu
123
        );
124
 
125
   uart_clock_process :process
126
   begin
127
                sys_clk_i <= '0';
128
                wait for uart_clock_period/2;
129
                sys_clk_i <= '1';
130
                wait for uart_clock_period/2;
131
   end process;
132
 
133
   -- Stimulus process
134
   stim_proc: process
135
   begin
136
                -- hold reset
137
                wait for 50 ns;
138
                uart_rst_emu <= '0';
139
                wait for uart_clock_period*10;
140
                uart_rst_emu <= '1';
141
                -- insert stimulus here 
142
                uart_din_emu  <= '1';
143
 
144
                wait for 10 us;
145
 
146
                -- look through test_data
147
                for j in test_data'range loop
148
                        -- tx_start_bit 
149
                        uart_din_emu <=  '0';
150
                        wait for bit_period;
151
 
152
                        -- Byte serializer
153
                        for i in  0 to 7 loop
154
                                uart_din_emu <= test_data(j)(i);
155
                                wait for bit_period;
156
                        end loop;
157
 
158
                        -- tx_stop_bit 
159
                        uart_din_emu <=  '1';
160
                        wait for bit_period;
161
                        wait for 5 us;
162
                end loop;
163
 
164
    wait;
165
   end process;
166
 
167
END;

powered by: WebSVN 2.1.0

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