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

Subversion Repositories uart_block

[/] [uart_block/] [trunk/] [hdl/] [iseProject/] [testUart_wishbone_slave.vhd] - Blame information for rev 37

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 leonardoar
--! Test uart_wishbone_slave (Main test module)
2
LIBRARY ieee;
3
USE ieee.std_logic_1164.ALL;
4
use ieee.std_logic_unsigned.all;
5
use ieee.std_logic_arith.all;
6
 
7
--! Use Global Definitions package
8
use work.pkgDefinitions.all;
9
 
10
ENTITY testUart_wishbone_slave IS
11
END testUart_wishbone_slave;
12
 
13
ARCHITECTURE behavior OF testUart_wishbone_slave IS
14
 
15
    -- Component Declaration for the Unit Under Test (UUT)
16
 
17
    COMPONENT uart_wishbone_slave
18 37 leonardoar
    Port ( RST_I : in  STD_LOGIC;                                                               --! Reset Input
19
           CLK_I : in  STD_LOGIC;                                                               --! Clock Input
20
           ADR_I0 : in  STD_LOGIC_VECTOR (1 downto 0);   --! Address input
21
           DAT_I0 : in  STD_LOGIC_VECTOR (31 downto 0);  --! Data Input 0
22
           DAT_O0 : out  STD_LOGIC_VECTOR (31 downto 0); --! Data Output 0
23
           WE_I : in  STD_LOGIC;                                                                        --! Write enable input
24
           STB_I : in  STD_LOGIC;                                                               --! Strobe input (Works like a chip select)
25
           ACK_O : out  STD_LOGIC;                                                              --! Ack output
26
 
27
                          -- NON-WISHBONE Signals
28
                          serial_in : in std_logic;                                                     --! Uart serial input
29
                          data_Avaible : out std_logic;                                         --! Flag to indicate data avaible                                       
30
                          serial_out : out std_logic
31
                          );
32 16 leonardoar
    END COMPONENT;
33
 
34
 
35
   --Inputs
36 37 leonardoar
   signal RST_I : std_logic := '0';                                                                                              --! Signal to connect with UUT
37
   signal CLK_I : std_logic := '0';                                                                                              --! Signal to connect with UUT
38
   signal ADR_I0 : std_logic_vector(1 downto 0) := (others => '0');       --! Signal to connect with UUT
39
   signal DAT_I0 : std_logic_vector(31 downto 0) := (others => '0');      --! Signal to connect with UUT
40 16 leonardoar
   signal WE_I : std_logic := '0';
41
   signal STB_I : std_logic := '0';
42
   signal serial_in : std_logic := '0';
43
 
44
        --Outputs
45 37 leonardoar
   signal DAT_O0 : std_logic_vector(31 downto 0);                                                        --! Signal to connect with UUT
46
   signal ACK_O : std_logic;                                                                                                            --! Signal to connect with UUT
47
   signal serial_out : std_logic;                                                                                               --! Signal to connect with UUT
48
        signal data_Avaible : std_logic;                                                                                                --! Signal to connect with UUT
49 16 leonardoar
 
50
   -- Clock period definitions (1.8432MHz)
51 18 leonardoar
   constant CLK_I_period : time := 20 ns; -- 0.543us (1.8432Mhz) 2ns (50Mhz)
52 16 leonardoar
 
53
BEGIN
54
 
55 36 leonardoar
        --! Instantiate the Unit Under Test (UUT)
56 16 leonardoar
   uut: uart_wishbone_slave PORT MAP (
57
          RST_I => RST_I,
58
          CLK_I => CLK_I,
59
          ADR_I0 => ADR_I0,
60
          DAT_I0 => DAT_I0,
61
          DAT_O0 => DAT_O0,
62
          WE_I => WE_I,
63
          STB_I => STB_I,
64
          ACK_O => ACK_O,
65
          serial_in => serial_in,
66 21 leonardoar
                         data_Avaible => data_Avaible,
67 16 leonardoar
          serial_out => serial_out
68
        );
69
 
70
   -- Clock process definitions
71
   CLK_I_process :process
72
   begin
73
                CLK_I <= '0';
74
                wait for CLK_I_period/2;
75
                CLK_I <= '1';
76
                wait for CLK_I_period/2;
77
   end process;
78
 
79
 
80
   -- Stimulus process
81
   stim_proc: process
82
   begin
83
      -- Reset the slave
84 19 leonardoar
                RST_I <= '1';
85
                serial_in <= '1';
86 18 leonardoar
      wait for CLK_I_period;
87 16 leonardoar
                RST_I <= '0';
88 18 leonardoar
                wait for CLK_I_period;
89 16 leonardoar
 
90
      -- Configure the clock... 
91
                ADR_I0 <= "00";
92
                WE_I <= '1';
93
                STB_I <= '1';
94
                DAT_I0 <= conv_std_logic_vector(50000000, (nBitsLarge));
95
                wait until ACK_O = '1';
96
                WE_I <= '0';
97
                STB_I <= '0';
98
                ADR_I0 <= (others => 'U');
99
                wait for CLK_I_period;
100
 
101
                -- Configure the Baud... 
102
                ADR_I0 <= "01";
103
                WE_I <= '1';
104
                STB_I <= '1';
105
                DAT_I0 <= conv_std_logic_vector(115200, (nBitsLarge));
106
                wait until ACK_O = '1';
107
                WE_I <= '0';
108
                STB_I <= '0';
109
                ADR_I0 <= (others => 'U');
110 23 leonardoar
                wait for CLK_I_period*40;
111 16 leonardoar
 
112
                -- Ask to send some data...(0xC4)
113
                ADR_I0 <= "10";
114
                WE_I <= '1';
115
                STB_I <= '1';
116
                DAT_I0 <= x"000000C4";
117
                wait until ACK_O = '1';
118
                WE_I <= '0';
119
                STB_I <= '0';
120
                ADR_I0 <= (others => 'U');
121 23 leonardoar
                wait for CLK_I_period*5000;
122 18 leonardoar
 
123 17 leonardoar
                -- Receive 0x55 value (01010101)
124
                serial_in <= '0'; -- Start bit
125
                wait for 8.68 us;
126
 
127
                serial_in <= '1';
128
      wait for 8.68 us;
129
                serial_in <= '0';
130
      wait for 8.68 us;
131
                serial_in <= '1';
132
      wait for 8.68 us;
133
                serial_in <= '0';
134
      wait for 8.68 us;
135
                serial_in <= '1';
136
      wait for 8.68 us;
137
                serial_in <= '0';
138
      wait for 8.68 us;
139
                serial_in <= '1';
140
      wait for 8.68 us;
141
                serial_in <= '0';
142
      wait for 8.68 us;
143
 
144
                -- Stop bit here
145 19 leonardoar
                serial_in <= '1';
146 23 leonardoar
                wait for CLK_I_period*5000;
147 18 leonardoar
 
148 24 leonardoar
                -- Check content by reading the register (Should be 0x55)
149
                ADR_I0 <= "11";
150
                WE_I <= '0';
151
                STB_I <= '1';
152
                wait until ACK_O = '1';
153
                STB_I <= '0';
154
                ADR_I0 <= (others => 'U');
155
                wait for CLK_I_period*5000;
156 23 leonardoar
 
157 24 leonardoar
                -- Ask to send some data...(0x55)
158
                ADR_I0 <= "10";
159
                WE_I <= '1';
160
                STB_I <= '1';
161
                DAT_I0 <= x"00000055";
162
                wait until ACK_O = '1';
163
                WE_I <= '0';
164
                STB_I <= '0';
165
                ADR_I0 <= (others => 'U');
166
                wait for CLK_I_period*5000;
167
 
168
 
169 16 leonardoar
 
170
      -- Stop Simulation
171
                assert false report "NONE. End of simulation." severity failure;
172
   end process;
173
 
174
END;

powered by: WebSVN 2.1.0

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