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 19

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
         serial_out : OUT  std_logic
29
        );
30
    END COMPONENT;
31
 
32
 
33
   --Inputs
34
   signal RST_I : std_logic := '0';
35
   signal CLK_I : std_logic := '0';
36
   signal ADR_I0 : std_logic_vector(1 downto 0) := (others => '0');
37
   signal DAT_I0 : std_logic_vector(31 downto 0) := (others => '0');
38
   signal WE_I : std_logic := '0';
39
   signal STB_I : std_logic := '0';
40
   signal serial_in : std_logic := '0';
41
 
42
        --Outputs
43
   signal DAT_O0 : std_logic_vector(31 downto 0);
44
   signal ACK_O : std_logic;
45
   signal serial_out : std_logic;
46
 
47
   -- Clock period definitions (1.8432MHz)
48 18 leonardoar
   constant CLK_I_period : time := 20 ns; -- 0.543us (1.8432Mhz) 2ns (50Mhz)
49 16 leonardoar
 
50
BEGIN
51
 
52
        -- Instantiate the Unit Under Test (UUT)
53
   uut: uart_wishbone_slave PORT MAP (
54
          RST_I => RST_I,
55
          CLK_I => CLK_I,
56
          ADR_I0 => ADR_I0,
57
          DAT_I0 => DAT_I0,
58
          DAT_O0 => DAT_O0,
59
          WE_I => WE_I,
60
          STB_I => STB_I,
61
          ACK_O => ACK_O,
62
          serial_in => serial_in,
63
          serial_out => serial_out
64
        );
65
 
66
   -- Clock process definitions
67
   CLK_I_process :process
68
   begin
69
                CLK_I <= '0';
70
                wait for CLK_I_period/2;
71
                CLK_I <= '1';
72
                wait for CLK_I_period/2;
73
   end process;
74
 
75
 
76
   -- Stimulus process
77
   stim_proc: process
78
   begin
79
      -- Reset the slave
80 19 leonardoar
                RST_I <= '1';
81
                serial_in <= '1';
82 18 leonardoar
      wait for CLK_I_period;
83 16 leonardoar
                RST_I <= '0';
84 18 leonardoar
                wait for CLK_I_period;
85 16 leonardoar
 
86
      -- Configure the clock... 
87
                ADR_I0 <= "00";
88
                WE_I <= '1';
89
                STB_I <= '1';
90
                DAT_I0 <= conv_std_logic_vector(50000000, (nBitsLarge));
91
                wait until ACK_O = '1';
92
                WE_I <= '0';
93
                STB_I <= '0';
94
                ADR_I0 <= (others => 'U');
95
                wait for CLK_I_period;
96
 
97
                -- Configure the Baud... 
98
                ADR_I0 <= "01";
99
                WE_I <= '1';
100
                STB_I <= '1';
101
                DAT_I0 <= conv_std_logic_vector(115200, (nBitsLarge));
102
                wait until ACK_O = '1';
103
                WE_I <= '0';
104
                STB_I <= '0';
105
                ADR_I0 <= (others => 'U');
106
                wait for CLK_I_period;
107
 
108
                -- Ask to send some data...(0xC4)
109
                ADR_I0 <= "10";
110
                WE_I <= '1';
111
                STB_I <= '1';
112
                DAT_I0 <= x"000000C4";
113
                wait until ACK_O = '1';
114
                WE_I <= '0';
115
                STB_I <= '0';
116
                ADR_I0 <= (others => 'U');
117 19 leonardoar
                wait for CLK_I_period*500;
118 18 leonardoar
 
119 19 leonardoar
                -- Receive data
120 18 leonardoar
                ADR_I0 <= "11";
121 19 leonardoar
                WE_I <= '0';
122
                STB_I <= '1';
123
                wait for CLK_I_period*100; -- Error !!!!! (Should not need this!!)
124 18 leonardoar
 
125 17 leonardoar
                -- Receive data...
126
                -- Receive 0x55 value (01010101)
127
                serial_in <= '0'; -- Start bit
128
                wait for 8.68 us;
129
 
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
                serial_in <= '1';
143
      wait for 8.68 us;
144
                serial_in <= '0';
145
      wait for 8.68 us;
146
 
147
                -- Stop bit here
148 19 leonardoar
                serial_in <= '1';
149 18 leonardoar
 
150 19 leonardoar
                wait until ACK_O = '1';
151
                wait for CLK_I_period*100;
152 16 leonardoar
 
153
      -- Stop Simulation
154
                assert false report "NONE. End of simulation." severity failure;
155
   end process;
156
 
157
END;

powered by: WebSVN 2.1.0

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