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

Subversion Repositories usb_dongle_fpga

[/] [usb_dongle_fpga/] [trunk/] [beh/] [toplevel_usb_test.vhd] - Blame information for rev 53

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 nuubik
------------------------------------------------------------------
2
-- Universal dongle board source code
3
-- 
4
-- Copyright (C) 2006 Artec Design <jyrit@artecdesign.ee>
5
-- 
6
-- This source code is free hardware; you can redistribute it and/or
7
-- modify it under the terms of the GNU Lesser General Public
8
-- License as published by the Free Software Foundation; either
9
-- version 2.1 of the License, or (at your option) any later version.
10
-- 
11
-- This source code is distributed in the hope that it will be useful,
12
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
-- Lesser General Public License for more details.
15
-- 
16
-- You should have received a copy of the GNU Lesser General Public
17
-- License along with this library; if not, write to the Free Software
18
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
-- 
20
-- 
21
-- The complete text of the GNU Lesser General Public License can be found in 
22
-- the file 'lesser.txt'.
23
--------------------------------------------------------------------------------
24
-- Company: 
25
-- Engineer:
26
--
27
-- Create Date:   18:17:32 09/28/2006
28
-- Design Name:   design_top
29
-- Module Name:   C:/projects/USB_dongle/beh/toplevel_usb_test.vhd
30
-- Project Name:  simulation
31
-- Target Device:  
32
-- Tool versions:  
33
-- Description:   
34
-- 
35
-- VHDL Test Bench Created by ISE for module: design_top
36
--
37
-- Dependencies:
38
-- 
39
-- Revision:
40
-- Revision 0.01 - File Created
41
-- Additional Comments:
42
--
43
-- Notes: 
44
-- This testbench has been automatically generated using types std_logic and
45
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends 
46
-- that these types always be used for the top-level I/O of a design in order 
47
-- to guarantee that the testbench will bind correctly to the post-implementation 
48
-- simulation model.
49
--------------------------------------------------------------------------------
50
LIBRARY ieee;
51
USE ieee.std_logic_1164.ALL;
52
USE ieee.std_logic_unsigned.all;
53
USE ieee.numeric_std.ALL;
54
 
55
ENTITY toplevel_usb_test_vhd IS
56
END toplevel_usb_test_vhd;
57
 
58
ARCHITECTURE behavior OF toplevel_usb_test_vhd IS
59
 
60
        -- Component Declaration for the Unit Under Test (UUT)
61
        COMPONENT design_top
62
        PORT(
63
                sys_clk : IN std_logic;
64
                resetn : IN std_logic;
65
                hdr : OUT std_logic_vector(10 downto 0);
66
                alt_clk : IN std_logic;
67
                mode : IN std_logic_vector(1 downto 0);
68
                lreset_n : IN std_logic;
69
                lclk : IN std_logic;
70
                fl_sts : IN std_logic;
71
                usb_txe_n : IN std_logic;
72
                usb_rxf_n : IN std_logic;
73
                lad : INOUT std_logic_vector(3 downto 0);
74
                lframe_n : INOUT std_logic;
75
                fl_data : INOUT std_logic_vector(15 downto 0);
76
                usb_bd : INOUT std_logic_vector(7 downto 0);
77
                seg_out : OUT std_logic_vector(7 downto 0);
78
                scn_seg : OUT std_logic_vector(3 downto 0);
79
                led_green : OUT std_logic;
80
                led_red : OUT std_logic;
81
                fl_addr : OUT std_logic_vector(23 downto 0);
82
                fl_ce_n : OUT std_logic;
83
                fl_oe_n : OUT std_logic;
84
                fl_we_n : OUT std_logic;
85
                fl_rp_n : OUT std_logic;
86
                usb_rd_n : OUT std_logic;
87
                usb_wr : OUT std_logic
88
                );
89
        END COMPONENT;
90
 
91
        --Inputs
92
        SIGNAL sys_clk :  std_logic := '0';
93
        SIGNAL resetn :  std_logic := '0';
94
        SIGNAL alt_clk :  std_logic := '0';
95
        SIGNAL lreset_n :  std_logic := '0';
96
        SIGNAL lclk :  std_logic := '0';
97
        SIGNAL fl_sts :  std_logic := '0';
98
        SIGNAL usb_txe_n :  std_logic := '0';
99
        SIGNAL usb_rxf_n :  std_logic := '0';
100
        SIGNAL hdr :  std_logic_vector(10 downto 0);
101
        SIGNAL mode :  std_logic_vector(1 downto 0) := (others=>'0');
102
 
103
        --BiDirs
104
        SIGNAL lad :  std_logic_vector(3 downto 0);
105
        SIGNAL lframe_n :  std_logic;
106
        SIGNAL fl_data :  std_logic_vector(15 downto 0);
107
        SIGNAL usb_bd :  std_logic_vector(7 downto 0);
108
 
109
        --Outputs
110
        SIGNAL seg_out :  std_logic_vector(7 downto 0);
111
        SIGNAL scn_seg :  std_logic_vector(3 downto 0);
112
        SIGNAL led_green :  std_logic;
113
        SIGNAL led_red :  std_logic;
114
        SIGNAL fl_addr :  std_logic_vector(23 downto 0);
115
        SIGNAL fl_ce_n :  std_logic;
116
        SIGNAL fl_oe_n :  std_logic;
117
        SIGNAL fl_we_n :  std_logic;
118
        SIGNAL fl_rp_n :  std_logic;
119
        SIGNAL usb_rd_n :  std_logic;
120
        SIGNAL usb_wr :  std_logic;
121
 
122
BEGIN
123
 
124
        -- Instantiate the Unit Under Test (UUT)
125
        uut: design_top PORT MAP(
126
                sys_clk => sys_clk,
127
                resetn => resetn,
128
                hdr => hdr,
129
                alt_clk => alt_clk,
130
                mode => mode,
131
                lad => lad,
132
                lframe_n => lframe_n,
133
                lreset_n => lreset_n,
134
                lclk => lclk,
135
                seg_out => seg_out,
136
                scn_seg => scn_seg,
137
                led_green => led_green,
138
                led_red => led_red,
139
                fl_addr => fl_addr,
140
                fl_ce_n => fl_ce_n,
141
                fl_oe_n => fl_oe_n,
142
                fl_we_n => fl_we_n,
143
                fl_data => fl_data,
144
                fl_rp_n => fl_rp_n,
145
                fl_sts => fl_sts,
146
                usb_rd_n => usb_rd_n,
147
                usb_wr => usb_wr,
148
                usb_txe_n => usb_txe_n,
149
                usb_rxf_n => usb_rxf_n,
150
                usb_bd => usb_bd
151
        );
152
 
153
 clocker : process is
154
  begin
155
    wait for 17 ns;
156
    lclk <=not (lclk);
157
  end process clocker;
158
 
159
  clocker2 : process is
160
  begin
161
    wait for 20 ns;
162
    sys_clk <=not (sys_clk);
163
  end process clocker2;
164
 
165
 
166
        tb : PROCESS
167
        BEGIN
168
 
169
                -- Wait 100 ns for global reset to finish
170
                wait for 100 ns;
171
                resetn <='1';
172
                lreset_n <='1';
173
                -- Status check COMMAND
174
                usb_rxf_n <='0';
175
                usb_bd <=x"00";
176
                wait until usb_rd_n='0'; --wait to go low --first read
177
                wait until usb_rd_n='1'; --wait to go low
178
                wait for 20 ns;
179
                usb_bd <=x"C5";
180
                wait until usb_rd_n='0'; --wait to go low --second read
181
                wait until usb_rd_n='1'; --wait to go low
182
                usb_bd <=(others=>'Z');
183
                usb_rxf_n <='1';
184
                -- END A1 COMMAND 
185
                wait for 800 ns;
186
 
187
                -- A0 COMMAND
188
                usb_rxf_n <='0';
189
                usb_bd <=x"02";
190
                wait until usb_rd_n='0'; --wait to go low --first read
191
                wait until usb_rd_n='1'; --wait to go low
192
                wait for 20 ns;
193
                usb_bd <=x"A0";
194
                wait until usb_rd_n='0'; --wait to go low --second read
195
                wait until usb_rd_n='1'; --wait to go low
196
                usb_bd <=(others=>'Z');
197
                usb_rxf_n <='1';
198
                -- END A0 COMMAND 
199
                wait for 800 ns;
200
 
201
                -- A1 COMMAND
202
                usb_rxf_n <='0';
203
                usb_bd <=x"00";
204
                wait until usb_rd_n='0'; --wait to go low --first read
205
                wait until usb_rd_n='1'; --wait to go low
206
                wait for 20 ns;
207
                usb_bd <=x"A1";
208
                wait until usb_rd_n='0'; --wait to go low --second read
209
                wait until usb_rd_n='1'; --wait to go low
210
                usb_bd <=(others=>'Z');
211
                usb_rxf_n <='1';
212
                -- END A1 COMMAND 
213
                wait for 800 ns;
214
 
215
                -- A2 COMMAND
216
                usb_rxf_n <='0';
217
                usb_bd <=x"00";
218
                wait until usb_rd_n='0'; --wait to go low --first read
219
                wait until usb_rd_n='1'; --wait to go low
220
                wait for 20 ns;
221
                usb_bd <=x"A2";
222
                wait until usb_rd_n='0'; --wait to go low --second read
223
                wait until usb_rd_n='1'; --wait to go low
224
                usb_bd <=(others=>'Z');
225
                usb_rxf_n <='1';
226
                -- END A2 COMMAND 
227
                wait for 800 ns;
228
 
229
                -- 98 COMMAND
230
                usb_rxf_n <='0';
231
                usb_bd <=x"00";
232
                wait until usb_rd_n='0'; --wait to go low --first read
233
                wait until usb_rd_n='1'; --wait to go low
234
                wait for 20 ns;
235
                usb_bd <=x"98";
236
                wait until usb_rd_n='0'; --wait to go low --second read
237
                wait until usb_rd_n='1'; --wait to go low
238
                usb_bd <=(others=>'Z');
239
                usb_rxf_n <='1';
240
                -- END A2 COMMAND 
241
                wait for 800 ns;
242
 
243
                -- CD COMMAND
244
                usb_rxf_n <='0';
245
                usb_bd <=x"01";
246
                wait until usb_rd_n='0'; --wait to go low --first read
247
                wait until usb_rd_n='1'; --wait to go low
248
                wait for 20 ns;
249
                usb_bd <=x"CD";
250
                wait until usb_rd_n='0'; --wait to go low --second read
251
                wait until usb_rd_n='1'; --wait to go low
252
                usb_bd <=(others=>'Z');
253
                usb_rxf_n <='1';
254
                -- END CD COMMAND 
255
                wait for 800 ns;
256
 
257
                -- E8 COMMAND
258
                usb_rxf_n <='0';
259
                usb_bd <=x"01";  --this should mean 2 word to write
260
                wait until usb_rd_n='0'; --wait to go low --first read
261
                wait until usb_rd_n='1'; --wait to go low
262
                wait for 20 ns;
263
                usb_bd <=x"E8";
264
                wait until usb_rd_n='0'; --wait to go low --second read
265
                wait until usb_rd_n='1'; --wait to go low
266
                usb_bd <=(others=>'Z');
267
                usb_rxf_n <='1';
268
                -- END E8 COMMAND 
269
                wait for 2000 ns;
270
 
271
                -- SEND Data count to flash COMMAND
272
                usb_rxf_n <='0';
273
                usb_bd <=x"01";  --this should mean 2 word to write
274
                wait until usb_rd_n='0'; --wait to go low --first read
275
                wait until usb_rd_n='1'; --wait to go low
276
                wait for 20 ns;
277
                usb_bd <=x"00";  --count 00 means 1 word
278
                wait until usb_rd_n='0'; --wait to go low --second read
279
                wait until usb_rd_n='1'; --wait to go low
280
                usb_bd <=(others=>'Z');
281
                usb_rxf_n <='1';
282
                -- END COMMAND 
283
                wait for 800 ns;
284
 
285
                -- SEND raw Data
286
                usb_rxf_n <='0';
287
                usb_bd <=x"CA";  --this should mean 1 word to write
288
                wait until usb_rd_n='0'; --wait to go low --first read
289
                wait until usb_rd_n='1'; --wait to go low
290
                wait for 20 ns;
291
                usb_bd <=x"FE";  --count 00 means 1 word
292
                wait until usb_rd_n='0'; --wait to go low --second read
293
                wait until usb_rd_n='1'; --wait to go low
294
                usb_bd <=(others=>'Z');
295
                usb_rxf_n <='1';
296
                -- END send data
297
                wait for 800 ns;
298
 
299
                -- SEND raw Data
300
                usb_rxf_n <='0';
301
                usb_bd <=x"BE";  --this should mean 1 word to write
302
                wait until usb_rd_n='0'; --wait to go low --first read
303
                wait until usb_rd_n='1'; --wait to go low
304
                wait for 20 ns;
305
                usb_bd <=x"CD";  --count 00 means 1 word
306
                wait until usb_rd_n='0'; --wait to go low --second read
307
                wait until usb_rd_n='1'; --wait to go low
308
                usb_bd <=(others=>'Z');
309
                usb_rxf_n <='1';
310
                -- END send data
311
                wait for 800 ns;
312
 
313
                wait; -- will wait forever
314
        END PROCESS;
315
 
316
END;

powered by: WebSVN 2.1.0

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