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 21

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
                wait for CLK_I_period;
110
 
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 19 leonardoar
                wait for CLK_I_period*500;
121 18 leonardoar
 
122 20 leonardoar
                -- Receive data from serial
123 18 leonardoar
                ADR_I0 <= "11";
124 19 leonardoar
                WE_I <= '0';
125
                STB_I <= '1';
126
                wait for CLK_I_period*100; -- Error !!!!! (Should not need this!!)
127 18 leonardoar
 
128 20 leonardoar
                -- Receive data... (Should work by retainning the last received value...)
129 17 leonardoar
                -- Receive 0x55 value (01010101)
130
                serial_in <= '0'; -- Start bit
131
                wait for 8.68 us;
132
 
133
                serial_in <= '1';
134
      wait for 8.68 us;
135
                serial_in <= '0';
136
      wait for 8.68 us;
137
                serial_in <= '1';
138
      wait for 8.68 us;
139
                serial_in <= '0';
140
      wait for 8.68 us;
141
                serial_in <= '1';
142
      wait for 8.68 us;
143
                serial_in <= '0';
144
      wait for 8.68 us;
145
                serial_in <= '1';
146
      wait for 8.68 us;
147
                serial_in <= '0';
148
      wait for 8.68 us;
149
 
150
                -- Stop bit here
151 19 leonardoar
                serial_in <= '1';
152 18 leonardoar
 
153 19 leonardoar
                wait until ACK_O = '1';
154 20 leonardoar
                wait for CLK_I_period*100;
155
                STB_I <= '0';
156
                wait for CLK_I_period*100;
157
 
158
                -- Read byte sent...
159
                ADR_I0 <= "10";
160
                WE_I <= '0';
161
                STB_I <= '1';
162
                wait until ACK_O = '1';
163 19 leonardoar
                wait for CLK_I_period*100;
164 16 leonardoar
 
165
      -- Stop Simulation
166
                assert false report "NONE. End of simulation." severity failure;
167
   end process;
168
 
169
END;

powered by: WebSVN 2.1.0

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