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

Subversion Repositories wishbone_uart_controller

[/] [wishbone_uart_controller/] [branches/] [uartcontroller/] [testbench/] [testprocessor.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 themassau
--------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer:
4
--
5
-- Create Date:   20:07:53 05/23/2013
6
-- Design Name:   
7
-- Module Name:   C:/Users/boris/Documents/projects/usb_io_processor/test_IOprocessor.vhd
8
-- Project Name:  usb_io_processor
9
-- Target Device:  
10
-- Tool versions:  
11
-- Description:   
12
-- 
13
-- VHDL Test Bench Created by ISE for module: processor
14
-- 
15
-- Dependencies:
16
-- 
17
-- Revision:
18
-- Revision 0.01 - File Created
19
-- Additional Comments:
20
--
21
-- Notes: 
22
-- This testbench has been automatically generated using types std_logic and
23
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends
24
-- that these types always be used for the top-level I/O of a design in order
25
-- to guarantee that the testbench will bind correctly to the post-implementation 
26
-- simulation model.
27
--------------------------------------------------------------------------------
28
LIBRARY ieee;
29
USE ieee.std_logic_1164.ALL;
30
 
31
-- Uncomment the following library declaration if using
32
-- arithmetic functions with Signed or Unsigned values
33
--USE ieee.numeric_std.ALL;
34
 
35
ENTITY test_IOprocessor IS
36
END test_IOprocessor;
37
 
38
ARCHITECTURE behavior OF test_IOprocessor IS
39
 
40
    -- Component Declaration for the Unit Under Test (UUT)
41
 
42
    COMPONENT processor
43
    PORT(
44
         ACK_I : IN  std_logic;
45
         CLK_I : IN  std_logic;
46
         DAT_I : IN  std_logic_vector(7 downto 0);
47
         RST_I : IN  std_logic;
48
         ADR_O : OUT  std_logic_vector(7 downto 0);
49
         CYC_O : OUT  std_logic;
50
         DAT_O : OUT  std_logic_vector(7 downto 0);
51
         STB_O : OUT  std_logic;
52
         WE_O : OUT  std_logic;
53
         RX : IN  std_logic;
54
         TX : OUT  std_logic
55
        );
56
    END COMPONENT;
57
 
58
 
59
   --Inputs
60
   signal ACK_I : std_logic := '0';
61
   signal CLK_I : std_logic := '0';
62
   signal DAT_I : std_logic_vector(7 downto 0) := (others => '0');
63
   signal RST_I : std_logic := '0';
64
   signal RX : std_logic := '0';
65
 
66
        --Outputs
67
   signal ADR_O : std_logic_vector(7 downto 0);
68
   signal CYC_O : std_logic;
69
   signal DAT_O : std_logic_vector(7 downto 0);
70
   signal STB_O : std_logic;
71
   signal WE_O : std_logic;
72
   signal TX : std_logic;
73
 
74
   -- Clock period definitions
75
  constant CLK_I_period : time := 20 ns;
76
        constant response : time := 21 ns;
77
        constant datatime        : time := CLK_I_period*217 ;
78
        signal input : std_logic_vector(7 downto 0);
79
        signal resievedata : std_logic_vector(7 downto 0);
80
BEGIN
81
 
82
        -- Instantiate the Unit Under Test (UUT)
83
   uut: processor PORT MAP (
84
          ACK_I => ACK_I,
85
          CLK_I => CLK_I,
86
          DAT_I => DAT_I,
87
          RST_I => RST_I,
88
          ADR_O => ADR_O,
89
          CYC_O => CYC_O,
90
          DAT_O => DAT_O,
91
          STB_O => STB_O,
92
          WE_O => WE_O,
93
          RX => RX,
94
          TX => TX
95
        );
96
 
97
   -- Clock process definitions
98
   CLK_I_process :process
99
   begin
100
                CLK_I <= '0';
101
                wait for CLK_I_period/2;
102
                CLK_I <= '1';
103
                wait for CLK_I_period/2;
104
   end process;
105
 
106
 
107
   -- Stimulus process
108
   -- Stimulus process
109
   stim_proc: process
110
        begin
111
                RX<='1';
112
                RST_I<='1';
113
                wait for 101 ns;
114
                RST_I<='0';
115
                wait for datatime ;
116
 
117
                RX<='0';
118
                input<="0000"&"0010";--opcode + const & reg
119
                wait for datatime ;
120
                for i in 0 to 7 loop
121
                        RX<=input(i);
122
                        wait for datatime;
123
                end loop;
124
                RX<='1';
125
                wait for datatime;
126
                                RX<='0';
127
                input<="0000"&"0010";--opcode + const & reg
128
                wait for datatime ;
129
                for i in 0 to 7 loop
130
                        RX<=input(i);
131
                        wait for datatime;
132
                end loop;
133
                RX<='1';
134
                wait for datatime;
135
                RX<='0';
136
                input<="0000"&"0000";--opcode + const & reg
137
                wait for datatime ;
138
                for i in 0 to 7 loop
139
                        RX<=input(i);
140
                        wait for datatime;
141
                end loop;
142
                RX<='1';
143
                wait for datatime;
144
                                RX<='0';
145
                input<="1000"&"0000";--opcode + const & reg
146
                wait for datatime ;
147
                for i in 0 to 7 loop
148
                        RX<=input(i);
149
                        wait for datatime;
150
                end loop;
151
                RX<='1';
152
                wait for datatime;
153
                                wait for datatime;
154
                                RX<='0';
155
                input<="1001"&"1100";--opcode + const & reg
156
                wait for datatime ;
157
                for i in 0 to 7 loop
158
                        RX<=input(i);
159
                        wait for datatime;
160
                end loop;
161
                RX<='1';
162
                wait for datatime;
163
                wait;
164
 
165
      wait;
166
   end process;
167
respons: process
168
begin
169
                wait until STB_O='1';
170
                wait for response;
171
                ack_i<='1';
172
                DAT_I<="11001101";
173
                wait until STB_O='0';
174
                wait for 2 ns ;
175
                ack_i<='0';
176
                DAT_I<=x"00";
177
                wait until STB_O='1';
178
                wait for response ;
179
                ack_i<='1';
180
                DAT_I<=x"ee";
181
                wait until STB_O='0';
182
                wait for 2 ns ;
183
                ack_i<='0';
184
                DAT_I<=x"00";
185
                wait until STB_O='1';
186
                wait for response ;
187
                ack_i<='1';
188
                DAT_I<=x"15";
189
                wait until STB_O='0';
190
                wait for 2 ns ;
191
                ack_i<='0';
192
                DAT_I<=x"00";
193
                wait until STB_O='1';
194
                wait for response ;
195
                ack_i<='1';
196
                DAT_I<=x"28";
197
                wait until STB_O='0';
198
                wait for 2 ns ;
199
                ack_i<='0';
200
                DAT_I<=x"00";
201
 end process;
202
 
203
recieve: process
204
        begin
205
        ---eerste byte
206
--      wait until tx ='0';
207
--      wait for datatime ;
208
--      wait for 1 ns;
209
--      wait for datatime ;
210
--      for i in 0 to 7 loop
211
--                      resievedata(i)<=TX;
212
--                      wait for datatime ;
213
--      end loop;
214
--      wait for 1 ns;
215
--      assert resievedata="11001101"
216
--      report "foute output";
217
--      --- 2de byte
218
        wait until tx ='0';
219
        wait for datatime ;
220
        wait for datatime;
221
        wait for 1 ns;
222
        for i in 0 to 7 loop
223
                        resievedata(i)<=TX;
224
                        wait for datatime;
225
        end loop;
226
        wait for 1 ns;
227
        assert resievedata=x"ee"
228
        report "foute output";
229
        ---3de byte
230
        wait until tx ='0';
231
        wait for datatime ;
232
        wait for datatime;
233
        wait for 1 ns;
234
        for i in 0 to 7 loop
235
                        resievedata(i)<=TX;
236
                        wait for datatime ;
237
        end loop;
238
        wait for 1 ns;
239
        assert resievedata=x"15"
240
        report "foute output";
241
 
242
        --4de byte
243
        wait until tx ='0';
244
        wait for datatime ;
245
        wait for datatime;
246
 
247
        wait for 1 ns;
248
        for i in 0 to 7 loop
249
                        resievedata(i)<=TX;
250
                        wait for datatime ;
251
        end loop;
252
        wait for 1 ns;
253
        assert resievedata=x"28"
254
        report "foute output";
255
        end process;
256
END;

powered by: WebSVN 2.1.0

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