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 24

Go to most recent revision | 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
    PORT(
19
         RST_I : IN  std_logic;
20
         CLK_I : IN  std_logic;
21
         ADR_I0 : IN  std_logic_vector(1 downto 0);
22
         DAT_I0 : IN  std_logic_vector(31 downto 0);
23
         DAT_O0 : OUT  std_logic_vector(31 downto 0);
24
         WE_I : IN  std_logic;
25
         STB_I : IN  std_logic;
26
         ACK_O : OUT  std_logic;
27
         serial_in : IN  std_logic;
28 21 leonardoar
                        data_Avaible : out std_logic;                                                                                   -- Indicate that the receiver module got something
29 16 leonardoar
         serial_out : OUT  std_logic
30
        );
31
    END COMPONENT;
32
 
33
 
34
   --Inputs
35
   signal RST_I : std_logic := '0';
36
   signal CLK_I : std_logic := '0';
37
   signal ADR_I0 : std_logic_vector(1 downto 0) := (others => '0');
38
   signal DAT_I0 : std_logic_vector(31 downto 0) := (others => '0');
39
   signal WE_I : std_logic := '0';
40
   signal STB_I : std_logic := '0';
41
   signal serial_in : std_logic := '0';
42
 
43
        --Outputs
44
   signal DAT_O0 : std_logic_vector(31 downto 0);
45
   signal ACK_O : std_logic;
46
   signal serial_out : std_logic;
47 21 leonardoar
        signal data_Avaible : std_logic;
48 16 leonardoar
 
49
   -- Clock period definitions (1.8432MHz)
50 18 leonardoar
   constant CLK_I_period : time := 20 ns; -- 0.543us (1.8432Mhz) 2ns (50Mhz)
51 16 leonardoar
 
52
BEGIN
53
 
54
        -- Instantiate the Unit Under Test (UUT)
55
   uut: uart_wishbone_slave PORT MAP (
56
          RST_I => RST_I,
57
          CLK_I => CLK_I,
58
          ADR_I0 => ADR_I0,
59
          DAT_I0 => DAT_I0,
60
          DAT_O0 => DAT_O0,
61
          WE_I => WE_I,
62
          STB_I => STB_I,
63
          ACK_O => ACK_O,
64
          serial_in => serial_in,
65 21 leonardoar
                         data_Avaible => data_Avaible,
66 16 leonardoar
          serial_out => serial_out
67
        );
68
 
69
   -- Clock process definitions
70
   CLK_I_process :process
71
   begin
72
                CLK_I <= '0';
73
                wait for CLK_I_period/2;
74
                CLK_I <= '1';
75
                wait for CLK_I_period/2;
76
   end process;
77
 
78
 
79
   -- Stimulus process
80
   stim_proc: process
81
   begin
82
      -- Reset the slave
83 19 leonardoar
                RST_I <= '1';
84
                serial_in <= '1';
85 18 leonardoar
      wait for CLK_I_period;
86 16 leonardoar
                RST_I <= '0';
87 18 leonardoar
                wait for CLK_I_period;
88 16 leonardoar
 
89
      -- Configure the clock... 
90
                ADR_I0 <= "00";
91
                WE_I <= '1';
92
                STB_I <= '1';
93
                DAT_I0 <= conv_std_logic_vector(50000000, (nBitsLarge));
94
                wait until ACK_O = '1';
95
                WE_I <= '0';
96
                STB_I <= '0';
97
                ADR_I0 <= (others => 'U');
98
                wait for CLK_I_period;
99
 
100
                -- Configure the Baud... 
101
                ADR_I0 <= "01";
102
                WE_I <= '1';
103
                STB_I <= '1';
104
                DAT_I0 <= conv_std_logic_vector(115200, (nBitsLarge));
105
                wait until ACK_O = '1';
106
                WE_I <= '0';
107
                STB_I <= '0';
108
                ADR_I0 <= (others => 'U');
109 23 leonardoar
                wait for CLK_I_period*40;
110 16 leonardoar
 
111
                -- Ask to send some data...(0xC4)
112
                ADR_I0 <= "10";
113
                WE_I <= '1';
114
                STB_I <= '1';
115
                DAT_I0 <= x"000000C4";
116
                wait until ACK_O = '1';
117
                WE_I <= '0';
118
                STB_I <= '0';
119
                ADR_I0 <= (others => 'U');
120 23 leonardoar
                wait for CLK_I_period*5000;
121 18 leonardoar
 
122 17 leonardoar
                -- Receive 0x55 value (01010101)
123
                serial_in <= '0'; -- Start bit
124
                wait for 8.68 us;
125
 
126
                serial_in <= '1';
127
      wait for 8.68 us;
128
                serial_in <= '0';
129
      wait for 8.68 us;
130
                serial_in <= '1';
131
      wait for 8.68 us;
132
                serial_in <= '0';
133
      wait for 8.68 us;
134
                serial_in <= '1';
135
      wait for 8.68 us;
136
                serial_in <= '0';
137
      wait for 8.68 us;
138
                serial_in <= '1';
139
      wait for 8.68 us;
140
                serial_in <= '0';
141
      wait for 8.68 us;
142
 
143
                -- Stop bit here
144 19 leonardoar
                serial_in <= '1';
145 23 leonardoar
                wait for CLK_I_period*5000;
146 18 leonardoar
 
147 24 leonardoar
                -- Check content by reading the register (Should be 0x55)
148
                ADR_I0 <= "11";
149
                WE_I <= '0';
150
                STB_I <= '1';
151
                wait until ACK_O = '1';
152
                STB_I <= '0';
153
                ADR_I0 <= (others => 'U');
154
                wait for CLK_I_period*5000;
155 23 leonardoar
 
156 24 leonardoar
                -- Ask to send some data...(0x55)
157
                ADR_I0 <= "10";
158
                WE_I <= '1';
159
                STB_I <= '1';
160
                DAT_I0 <= x"00000055";
161
                wait until ACK_O = '1';
162
                WE_I <= '0';
163
                STB_I <= '0';
164
                ADR_I0 <= (others => 'U');
165
                wait for CLK_I_period*5000;
166
 
167
 
168 16 leonardoar
 
169
      -- Stop Simulation
170
                assert false report "NONE. End of simulation." severity failure;
171
   end process;
172
 
173
END;

powered by: WebSVN 2.1.0

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