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: 10:19:29 09/28/2006
|
28 |
|
|
-- Design Name: usb2mem
|
29 |
|
|
-- Module Name: C:/projects/USB_dongle/beh/usb_mem_test.vhd
|
30 |
|
|
-- Project Name: simulation
|
31 |
|
|
-- Target Device:
|
32 |
|
|
-- Tool versions:
|
33 |
|
|
-- Description:
|
34 |
|
|
--
|
35 |
|
|
-- VHDL Test Bench Created by ISE for module: usb2mem
|
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 usb_mem_test_vhd IS
|
56 |
|
|
END usb_mem_test_vhd;
|
57 |
|
|
|
58 |
|
|
ARCHITECTURE behavior OF usb_mem_test_vhd IS
|
59 |
|
|
|
60 |
|
|
-- Component Declaration for the Unit Under Test (UUT)
|
61 |
|
|
COMPONENT usb2mem
|
62 |
|
|
PORT(
|
63 |
|
|
clk25 : IN std_logic;
|
64 |
|
|
reset_n : IN std_logic;
|
65 |
|
|
mem_di : IN std_logic_vector(15 downto 0);
|
66 |
|
|
mem_ack : IN std_logic;
|
67 |
|
|
usb_txe_n : IN std_logic;
|
68 |
|
|
usb_rxf_n : IN std_logic;
|
69 |
|
|
usb_bd : INOUT std_logic_vector(7 downto 0);
|
70 |
|
|
mem_addr : OUT std_logic_vector(23 downto 0);
|
71 |
|
|
mem_do : OUT std_logic_vector(15 downto 0);
|
72 |
|
|
mem_wr : OUT std_logic;
|
73 |
|
|
mem_val : OUT std_logic;
|
74 |
|
|
mem_cmd : OUT std_logic;
|
75 |
|
|
usb_rd_n : OUT std_logic;
|
76 |
|
|
usb_wr : OUT std_logic
|
77 |
|
|
);
|
78 |
|
|
END COMPONENT;
|
79 |
|
|
|
80 |
|
|
--Inputs
|
81 |
|
|
SIGNAL clk25 : std_logic := '0';
|
82 |
|
|
SIGNAL reset_n : std_logic := '0';
|
83 |
|
|
SIGNAL mem_ack : std_logic := '0';
|
84 |
|
|
SIGNAL usb_txe_n : std_logic := '0';
|
85 |
|
|
SIGNAL usb_rxf_n : std_logic := '1';
|
86 |
|
|
SIGNAL mem_di : std_logic_vector(15 downto 0) := x"3210";
|
87 |
|
|
|
88 |
|
|
--BiDirs
|
89 |
|
|
SIGNAL usb_bd : std_logic_vector(7 downto 0);
|
90 |
|
|
|
91 |
|
|
--Outputs
|
92 |
|
|
SIGNAL mem_addr : std_logic_vector(23 downto 0);
|
93 |
|
|
SIGNAL mem_do : std_logic_vector(15 downto 0);
|
94 |
|
|
SIGNAL mem_wr : std_logic;
|
95 |
|
|
SIGNAL mem_val : std_logic;
|
96 |
|
|
SIGNAL mem_cmd : std_logic;
|
97 |
|
|
SIGNAL usb_rd_n : std_logic;
|
98 |
|
|
SIGNAL usb_wr : std_logic;
|
99 |
|
|
|
100 |
|
|
BEGIN
|
101 |
|
|
|
102 |
|
|
-- Instantiate the Unit Under Test (UUT)
|
103 |
|
|
uut: usb2mem PORT MAP(
|
104 |
|
|
clk25 => clk25,
|
105 |
|
|
reset_n => reset_n,
|
106 |
|
|
mem_addr => mem_addr,
|
107 |
|
|
mem_do => mem_do,
|
108 |
|
|
mem_di => mem_di,
|
109 |
|
|
mem_wr => mem_wr,
|
110 |
|
|
mem_val => mem_val,
|
111 |
|
|
mem_ack => mem_ack,
|
112 |
|
|
mem_cmd => mem_cmd,
|
113 |
|
|
usb_rd_n => usb_rd_n,
|
114 |
|
|
usb_wr => usb_wr,
|
115 |
|
|
usb_txe_n => usb_txe_n,
|
116 |
|
|
usb_rxf_n => usb_rxf_n,
|
117 |
|
|
usb_bd => usb_bd
|
118 |
|
|
);
|
119 |
|
|
|
120 |
|
|
clocker : process is
|
121 |
|
|
begin
|
122 |
|
|
wait for 20 ns;
|
123 |
|
|
clk25 <=not (clk25);
|
124 |
|
|
end process clocker;
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
VCI_ACK : process is
|
128 |
|
|
begin
|
129 |
|
|
wait until mem_val='1';
|
130 |
|
|
wait for 100 ns;
|
131 |
|
|
mem_ack <='1';
|
132 |
|
|
wait until mem_val='0';
|
133 |
|
|
mem_ack <='0';
|
134 |
|
|
end process VCI_ACK;
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
tb : PROCESS
|
138 |
|
|
BEGIN
|
139 |
|
|
|
140 |
|
|
-- Wait 100 ns for global reset to finish
|
141 |
|
|
wait for 100 ns;
|
142 |
|
|
reset_n <='1';
|
143 |
|
|
|
144 |
|
|
-- STATUS CHECK COMMAND
|
145 |
|
|
usb_rxf_n <='0';
|
146 |
|
|
usb_bd <=x"C5";
|
147 |
|
|
wait until usb_rd_n='0'; --wait to go low --first read
|
148 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
149 |
|
|
wait until usb_rd_n='0'; --wait to go low --second read
|
150 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
151 |
|
|
usb_bd <=(others=>'Z');
|
152 |
|
|
usb_rxf_n <='1';
|
153 |
|
|
-- END STATUS CHECK COMMAND
|
154 |
|
|
wait for 800 ns;
|
155 |
|
|
|
156 |
|
|
-- A0 COMMAND
|
157 |
|
|
usb_rxf_n <='0';
|
158 |
|
|
usb_bd <=x"02";
|
159 |
|
|
wait until usb_rd_n='0'; --wait to go low --first read
|
160 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
161 |
|
|
wait for 20 ns;
|
162 |
|
|
usb_bd <=x"A0";
|
163 |
|
|
wait until usb_rd_n='0'; --wait to go low --second read
|
164 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
165 |
|
|
usb_bd <=(others=>'Z');
|
166 |
|
|
usb_rxf_n <='1';
|
167 |
|
|
-- END A0 COMMAND
|
168 |
|
|
wait for 800 ns;
|
169 |
|
|
|
170 |
|
|
-- A1 COMMAND
|
171 |
|
|
usb_rxf_n <='0';
|
172 |
|
|
usb_bd <=x"00";
|
173 |
|
|
wait until usb_rd_n='0'; --wait to go low --first read
|
174 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
175 |
|
|
wait for 20 ns;
|
176 |
|
|
usb_bd <=x"A1";
|
177 |
|
|
wait until usb_rd_n='0'; --wait to go low --second read
|
178 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
179 |
|
|
usb_bd <=(others=>'Z');
|
180 |
|
|
usb_rxf_n <='1';
|
181 |
|
|
-- END A1 COMMAND
|
182 |
|
|
wait for 800 ns;
|
183 |
|
|
|
184 |
|
|
-- A2 COMMAND
|
185 |
|
|
usb_rxf_n <='0';
|
186 |
|
|
usb_bd <=x"00";
|
187 |
|
|
wait until usb_rd_n='0'; --wait to go low --first read
|
188 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
189 |
|
|
wait for 20 ns;
|
190 |
|
|
usb_bd <=x"A2";
|
191 |
|
|
wait until usb_rd_n='0'; --wait to go low --second read
|
192 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
193 |
|
|
usb_bd <=(others=>'Z');
|
194 |
|
|
usb_rxf_n <='1';
|
195 |
|
|
-- END A2 COMMAND
|
196 |
|
|
wait for 800 ns;
|
197 |
|
|
|
198 |
|
|
-- CD COMMAND
|
199 |
|
|
usb_rxf_n <='0';
|
200 |
|
|
usb_bd <=x"01";
|
201 |
|
|
wait until usb_rd_n='0'; --wait to go low --first read
|
202 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
203 |
|
|
wait for 20 ns;
|
204 |
|
|
usb_bd <=x"CD";
|
205 |
|
|
wait until usb_rd_n='0'; --wait to go low --second read
|
206 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
207 |
|
|
usb_bd <=(others=>'Z');
|
208 |
|
|
usb_rxf_n <='1';
|
209 |
|
|
-- END CD COMMAND
|
210 |
|
|
wait for 800 ns;
|
211 |
|
|
|
212 |
|
|
-- E8 COMMAND
|
213 |
|
|
usb_rxf_n <='0';
|
214 |
|
|
usb_bd <=x"01"; --this should mean 2 word to write
|
215 |
|
|
wait until usb_rd_n='0'; --wait to go low --first read
|
216 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
217 |
|
|
wait for 20 ns;
|
218 |
|
|
usb_bd <=x"E8";
|
219 |
|
|
wait until usb_rd_n='0'; --wait to go low --second read
|
220 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
221 |
|
|
usb_bd <=(others=>'Z');
|
222 |
|
|
usb_rxf_n <='1';
|
223 |
|
|
-- END E8 COMMAND
|
224 |
|
|
wait for 2000 ns;
|
225 |
|
|
|
226 |
|
|
-- SEND Data count to flash COMMAND
|
227 |
|
|
usb_rxf_n <='0';
|
228 |
|
|
usb_bd <=x"01"; --this should mean 2 word to write
|
229 |
|
|
wait until usb_rd_n='0'; --wait to go low --first read
|
230 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
231 |
|
|
wait for 20 ns;
|
232 |
|
|
usb_bd <=x"00"; --count 00 means 1 word
|
233 |
|
|
wait until usb_rd_n='0'; --wait to go low --second read
|
234 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
235 |
|
|
usb_bd <=(others=>'Z');
|
236 |
|
|
usb_rxf_n <='1';
|
237 |
|
|
-- END COMMAND
|
238 |
|
|
wait for 800 ns;
|
239 |
|
|
|
240 |
|
|
-- SEND raw Data
|
241 |
|
|
usb_rxf_n <='0';
|
242 |
|
|
usb_bd <=x"CA"; --this should mean 1 word to write
|
243 |
|
|
wait until usb_rd_n='0'; --wait to go low --first read
|
244 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
245 |
|
|
wait for 20 ns;
|
246 |
|
|
usb_bd <=x"FE"; --count 00 means 1 word
|
247 |
|
|
wait until usb_rd_n='0'; --wait to go low --second read
|
248 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
249 |
|
|
usb_bd <=(others=>'Z');
|
250 |
|
|
usb_rxf_n <='1';
|
251 |
|
|
-- END send data
|
252 |
|
|
wait for 800 ns;
|
253 |
|
|
|
254 |
|
|
-- SEND raw Data
|
255 |
|
|
usb_rxf_n <='0';
|
256 |
|
|
usb_bd <=x"BE"; --this should mean 1 word to write
|
257 |
|
|
wait until usb_rd_n='0'; --wait to go low --first read
|
258 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
259 |
|
|
wait for 20 ns;
|
260 |
|
|
usb_bd <=x"CD"; --count 00 means 1 word
|
261 |
|
|
wait until usb_rd_n='0'; --wait to go low --second read
|
262 |
|
|
wait until usb_rd_n='1'; --wait to go low
|
263 |
|
|
usb_bd <=(others=>'Z');
|
264 |
|
|
usb_rxf_n <='1';
|
265 |
|
|
-- END send data
|
266 |
|
|
wait for 800 ns;
|
267 |
|
|
|
268 |
|
|
wait; -- will wait forever
|
269 |
|
|
END PROCESS;
|
270 |
|
|
|
271 |
|
|
END;
|