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

Subversion Repositories usb11

[/] [usb11/] [trunk/] [bench/] [verilog/] [test_bench_8051_top.v] - Blame information for rev 15

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfoltran
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  USB 1.1 Top Level Test Bench - 8051 Interface              ////
4
////                                                             ////
5
////                                                             ////
6
////  Author: Rudolf Usselmann                                   ////
7
////          rudi@asics.ws                                      ////
8
////                                                             ////
9
////  Modifications: Alfredo Luiz Foltran Fialho                 ////
10
////                 alfoltran@opencores.org                     ////
11
////                                                             ////
12
////  Downloaded from: http://www.opencores.org/cores/usb1_funct/////
13
////                                                             ////
14
/////////////////////////////////////////////////////////////////////
15
////                                                             ////
16
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
17
////                         www.asics.ws                        ////
18
////                         rudi@asics.ws                       ////
19
////                                                             ////
20
//// This source file may be used and distributed without        ////
21
//// restriction provided that this copyright statement is not   ////
22
//// removed from the file and that any derivative work contains ////
23
//// the original copyright notice and the associated disclaimer.////
24
////                                                             ////
25
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
26
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
27
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
28
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
29
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
30
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
31
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
32
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
33
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
34
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
35
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
36
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
37
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
38
////                                                             ////
39
/////////////////////////////////////////////////////////////////////
40
 
41
`include "timescale.v"
42
`include "usb_defines.v"
43
`include "usb_top.v"
44
 
45
module test;
46
 
47
///////////////////////////////////////////////////////////////////
48
//
49
// Local IOs and Vars
50
//
51
 
52
reg             clk;
53
reg             clk2;
54
reg             rst;
55
 
56
integer         error_cnt;
57
reg     [7:0]    txmem[0:2048];
58
reg     [7:0]    buffer1[0:16384];
59
reg     [7:0]    buffer0[0:16384];
60
integer         buffer1_last;
61
reg     [31:0]   wd_cnt;
62
reg             setup_pid;
63
integer         pack_sz, pack_sz_max;
64
wire            tx_dp, tx_dn, tx_oe;
65
wire            rx_d, rx_dp, rx_dn;
66
reg             tb_tx_valid;
67
wire            tb_tx_ready;
68
reg     [7:0]    tb_txdata;
69
wire            tb_rx_valid, tb_rx_active, tb_rx_error;
70
wire    [7:0]    tb_rxdata;
71
 
72
reg     [7:0]    ep_f_din;
73
wire    [7:0]    ep_f_dout;
74
reg             ep_f_re;
75
reg             ep_f_we;
76
wire            ep_f_empty;
77
wire            ep_f_full;
78
 
79
reg     [7:0]    ep_f_addr;
80
reg             cs;
81
 
82
reg     [7:0]    ep0_max_size;
83
reg     [7:0]    ep1_max_size;
84
reg     [7:0]    ep2_max_size;
85
reg     [7:0]    ep3_max_size;
86
reg     [7:0]    ep4_max_size;
87
reg     [7:0]    ep5_max_size;
88
reg     [7:0]    ep6_max_size;
89
reg     [7:0]    ep7_max_size;
90
 
91
wire            rx_dp1;
92
wire            rx_dn1;
93
wire            tx_dp1;
94
wire            tx_dn1;
95
wire            rx_dp2;
96
wire            rx_dn2;
97
wire            tx_dp2;
98
wire            tx_dn2;
99
 
100
reg             usb_reset;
101
integer         n;
102
reg     [31:0]   data;
103
 
104
///////////////////////////////////////////////////////////////////
105
//
106
// Test Definitions
107
//
108
 
109
///////////////////////////////////////////////////////////////////
110
//
111
// Initial Startup and Simulation Begin
112
//
113
 
114
 
115
initial
116
   begin
117
        usb_reset = 0;
118
        $timeformat (-9, 1, " ns", 12);
119
 
120
`ifdef WAVES
121
        $shm_open("waves");
122
        $shm_probe("AS",test,"AS");
123
        $display("INFO: Signal dump enabled ...\n\n");
124
`endif
125
        tb_tx_valid = 0;
126
        error_cnt = 0;
127
        wd_cnt = 0;
128
        clk = 0;
129
        clk2 = 0;
130
        rst = 0;
131
        ep_f_we=0;
132
        ep_f_re=0;
133
        cs=1;
134
        ep_f_addr=8'h00;
135
 
136
        repeat(10)      @(posedge clk);
137
        rst = 1;
138
        repeat(50)      @(posedge clk);
139
        usb_reset = 1;
140
        repeat(300)     @(posedge clk);
141
        usb_reset = 0;
142
        repeat(10)      @(posedge clk);
143
 
144
        if(1)
145
           begin
146
                setup0;
147
                in1;
148
                out2;
149
                in3;
150
                out4;
151
                in5;
152
                out6;
153
           end
154
        else
155
        if(1)
156
           begin
157
                setup0;
158
           end
159
 
160
        repeat(500)     @(posedge clk);
161
        $finish;
162
   end
163
 
164
///////////////////////////////////////////////////////////////////
165
//
166
// Watchdog Timer
167
//
168
always @(posedge clk)
169
        if(tx_dp1 | tx_dp2)             wd_cnt <= #1 0;
170
        else                            wd_cnt <= #1 wd_cnt + 1;
171
 
172
always @(wd_cnt)
173
        if(wd_cnt>5000)
174
           begin
175
                $display("\n\n*************************************\n");
176
                $display("ERROR: Watch Dog Counter Expired\n");
177
                $display("*************************************\n\n\n");
178
                $finish;
179
           end
180
 
181
///////////////////////////////////////////////////////////////////
182
//
183
// Clock generation
184
//
185
 
186
always #10.42 clk = ~clk;
187
always #10.42 clk2 = ~clk2;
188
 
189
///////////////////////////////////////////////////////////////////
190
//
191
// Module Instantiations
192
//
193
 
194
usb_phy tb_phy(.clk(                    clk                     ),
195
                .rst(                   rst                     ),
196
 
197
                .phy_tx_mode(           1'b1                    ),
198
                .usb_rst(                                       ),
199
 
200
                .rxd(                   rx_dp1                  ),
201
                .rxdp(                  rx_dp1                  ),
202
                .rxdn(                  rx_dn1                  ),
203
 
204
                .txdp(                  tx_dp1                  ),
205
                .txdn(                  tx_dn1                  ),
206
                .txoe(                                          ),
207
 
208
                .DataIn_o(              tb_rxdata               ),
209
                .RxValid_o(             tb_rx_valid             ),
210
                .RxActive_o(            tb_rx_active            ),
211
                .RxError_o(             tb_rx_error             ),
212
 
213
                .DataOut_i(             tb_txdata               ),
214
                .TxValid_i(             tb_tx_valid             ),
215
                .TxReady_o(             tb_tx_ready             ),
216
                .LineState_o(                                   )
217
                );
218
 
219
parameter       LD = 40;
220
 
221
assign #(LD) rx_dp1 = !usb_reset & tx_dp2;
222
assign #(LD) rx_dn1 = !usb_reset & tx_dn2;
223
 
224
assign #(LD) rx_dp2 = !usb_reset & tx_dp1;
225
assign #(LD) rx_dn2 = !usb_reset & tx_dn1;
226
 
227
usb_top u0(     .clk_i(                 clk2                    ),
228
                .rst_i(                 rst                     ),
229
 
230
                // USB Misc
231
                .usb_rst(                                       ),
232
 
233
                // USB Status
234
                .usb_busy(                                      ),
235
                .ep_sel(                                        ),
236
 
237
                // Interrupts
238
                .crc16_err(                                     ),
239
 
240
                // Vendor Features
241
                .v_set_int(                                     ),
242
                .v_set_feature(                                 ),
243
 
244
                // USB PHY Interface
245
                .tx_dp(                 tx_dp2                  ),
246
                .tx_dn(                 tx_dn2                  ),
247
                .tx_oe(                                         ),
248
                .rx_d(                  rx_dp2                  ),
249
                .rx_dp(                 rx_dp2                  ),
250
                .rx_dn(                 rx_dn2                  ),
251
 
252
                // ENDPOINTS Interface
253
                .din(                   ep_f_din                ),
254
                .dout(                  ep_f_dout               ),
255
                .re(                    ep_f_re                 ),
256
                .we(                    ep_f_we                 ),
257
                .empty(                 ep_f_empty              ),
258
                .full(                  ep_f_full               ),
259
 
260
                // 8051 Interface
261
                .adr(                   ep_f_addr               ),
262
                .cs(                    cs                      )
263
                );
264
 
265
///////////////////////////////////////////////////////////////////
266
//
267
// Test and test lib Includes
268
//
269
`include "tests_lib.v"
270
`include "tests.v"
271
 
272
endmodule
273
 

powered by: WebSVN 2.1.0

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