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

Subversion Repositories usb2uart

[/] [usb2uart/] [trunk/] [verify/] [tb/] [tb.v] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////                                                              ////
4
////  This file is part of the USB2UART  project                  ////
5
////  http://www.opencores.org/cores/usb2uart/                    ////
6
////                                                              ////
7
////  Description                                                 ////
8
////                                                              ////
9
////  To Do:                                                      ////
10
////    nothing                                                   ////
11
////                                                              ////
12
//   Version  :0.1 -                                              ////
13
////  Author(s):                                                  ////
14
////      - Dinesh Annayya, dinesha@opencores.org                 ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
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 source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
 
43
 
44
`timescale 1ns/10ps
45
 
46
`include "usb1_defines.v"
47
module tb;
48
 
49
wire  usb_txoe,usb_txdp,usb_txdn;
50
 
51
wire dpls = (usb_txoe == 1'b0) ? usb_txdp : 1'bz;
52
wire dmns = (usb_txoe == 1'b0) ? usb_txdn : 1'bz;
53
 
54
pullup(dpls); // Full Speed Device Indication
55
//pulldown(dmns);
56
 
57
parameter  SYS_BP_PER = 2.5;
58
parameter  USB_BP_PER = 10.4167;
59
reg sys_clk,resetn;
60
reg usb_48mhz_clk;
61
 
62
//-----------------------------------
63
// Register Interface
64
// ----------------------------------
65
wire [31:0]   reg_addr;   // Register Address
66
wire          reg_rdwrn;  // 0 -> write, 1-> read
67
wire          reg_req;    //  Register Req
68
wire [31:0]   reg_wdata;  // Register write data
69
reg   [31:0]  reg_rdata;  // Register Read Data
70
reg           reg_ack;    // Register Ack
71
 
72
always begin
73
     #SYS_BP_PER     sys_clk <= 1'b0;
74
     #SYS_BP_PER     sys_clk <= 1'b1;
75
end
76
 
77
always begin
78
     #USB_BP_PER     usb_48mhz_clk <= 1'b0;
79
     #USB_BP_PER     usb_48mhz_clk <= 1'b1;
80
end
81
 
82
wire usb_rxd = ((dpls == 1) && (dmns == 0)) ? 1'b1:
83
               ((dpls == 0) && (dmns == 1)) ? 1'b0: 1'b0;
84
 
85
core dut(
86
        .clk_i      (usb_48mhz_clk),
87
        .rst_i      (resetn),
88
 
89
                // USB PHY Interface
90
        .usb_txdp   (usb_txdp),
91
        .usb_txdn   (usb_txdn),
92
        .usb_txoe   (usb_txoe),
93
        .usb_rxd    (usb_rxd),
94
        .usb_rxdp   (dpls),
95
        .usb_rxdn   (dmns),
96
 
97
        // USB Misc
98
        .phy_tx_mode(1'b1),
99 8 dinesha
        .usb_rst(),
100 3 dinesha
 
101
        // Interrupts
102
        .dropped_frame(),
103
        .misaligned_frame(),
104
        .crc16_err(),
105
 
106
        // Vendor Features
107
        .v_set_int(),
108
        .v_set_feature(),
109
        .wValue(),
110
        .wIndex(),
111
        .vendor_data(),
112
 
113
        // USB Status
114
        .usb_busy(),
115
        .ep_sel(),
116
 
117
        // End point 1 configuration
118
        .ep1_cfg(       `ISO  | `IN  | 14'd0256         ),
119
        // End point 1 'OUT' FIFO i/f
120
        .ep1_dout(                                      ),
121
        .ep1_we(                                        ),
122
        .ep1_full(              1'b0                    ),
123
        // End point 1 'IN' FIFO i/f
124 8 dinesha
        .ep1_din(               8'h0                    ),
125
        .ep1_re(                                        ),
126
        .ep1_empty(             1'b0                    ),
127 3 dinesha
        .ep1_bf_en(             1'b0                    ),
128
        .ep1_bf_size(           7'h0                    ),
129
 
130
        // End point 2 configuration
131
        .ep2_cfg(       `ISO  | `OUT | 14'd0256         ),
132
        // End point 2 'OUT' FIFO i/f
133 8 dinesha
        .ep2_dout(                                      ),
134
        .ep2_we(                                        ),
135
        .ep2_full(              1'b0                    ),
136 3 dinesha
        // End point 2 'IN' FIFO i/f
137
        .ep2_din(               8'h0                    ),
138
        .ep2_re(                                        ),
139
        .ep2_empty(             1'b0                    ),
140
        .ep2_bf_en(             1'b0                    ),
141
        .ep2_bf_size(           7'h0                    ),
142
 
143
        // End point 3 configuration
144
        .ep3_cfg(       `BULK | `IN  | 14'd064          ),
145
        // End point 3 'OUT' FIFO i/f
146
        .ep3_dout(                                      ),
147
        .ep3_we(                                        ),
148
        .ep3_full(              1'b0                    ),
149
        // End point 3 'IN' FIFO i/f
150 8 dinesha
        .ep3_din(               8'h0                    ),
151
        .ep3_re(                                        ),
152
        .ep3_empty(             1'b0                    ),
153 3 dinesha
        .ep3_bf_en(             1'b0                    ),
154
        .ep3_bf_size(           7'h0                    ),
155
 
156
        // End point 4 configuration
157
        .ep4_cfg(       `BULK | `OUT | 14'd064          ),
158
        // End point 4 'OUT' FIFO i/f
159 8 dinesha
        .ep4_dout(                                      ),
160
        .ep4_we(                                        ),
161
        .ep4_full(              1'b0                    ),
162 3 dinesha
        // End point 4 'IN' FIFO i/f
163
        .ep4_din(               8'h0                    ),
164
        .ep4_re(                                        ),
165
        .ep4_empty(             1'b0                    ),
166
        .ep4_bf_en(             1'b0                    ),
167
        .ep4_bf_size(           7'h0                    ),
168
 
169
        // End point 5 configuration
170
        .ep5_cfg(       `INT  | `IN  | 14'd064          ),
171
        // End point 5 'OUT' FIFO i/f
172
        .ep5_dout(                                      ),
173
        .ep5_we(                                        ),
174
        .ep5_full(              1'b0                    ),
175
        // End point 5 'IN' FIFO i/f
176 8 dinesha
        .ep5_din(               8'h0                    ),
177
        .ep5_re(                                        ),
178
        .ep5_empty(             1'b0                    ),
179 3 dinesha
        .ep5_bf_en(             1'b0                    ),
180
        .ep5_bf_size(           7'h0                    ),
181
 
182
        // End point 6 configuration
183
        .ep6_cfg(               14'h00                  ),
184
        // End point 6 'OUT' FIFO i/f
185
        .ep6_dout(                                      ),
186
        .ep6_we(                                        ),
187
        .ep6_full(              1'b0                    ),
188
        // End point 6 'IN' FIFO i/f
189
        .ep6_din(               8'h0                    ),
190
        .ep6_re(                                        ),
191
        .ep6_empty(             1'b0                    ),
192
        .ep6_bf_en(             1'b0                    ),
193
        .ep6_bf_size(           7'h0                    ),
194
 
195
        // End point 7 configuration
196
        .ep7_cfg(               14'h00                  ),
197
        // End point 7 'OUT' FIFO i/f
198
        .ep7_dout(                                      ),
199
        .ep7_we(                                        ),
200
        .ep7_full(              1'b0                    ),
201
        // End point 7 'IN' FIFO i/f
202
        .ep7_din(               8'h0                    ),
203
        .ep7_re(                                        ),
204
        .ep7_empty(             1'b0                    ),
205
        .ep7_bf_en(             1'b0                    ),
206
        .ep7_bf_size(           7'h0                    ),
207
 
208
        // Uart Line Interface
209
        .uart_txd     (uart_txd),
210
        .uart_rxd    (uart_rxd)
211
 
212
        );
213
 
214
 
215
 
216
usb_agent u_usb_agent(
217
        .dpls       (dpls),
218
        .dmns       (dmns)
219
       );
220
 
221
uart_agent u_uart_agent(
222
        .test_clk (usb_48mhz_clk),
223
        .sin     (uart_rxd),
224
        .sout    (uart_txd)
225
     );
226
test_control test_control();
227
 
228
always @(posedge usb_48mhz_clk)
229
        reg_ack <= reg_req;
230
 
231
always @(posedge usb_48mhz_clk)
232
        if(reg_req)
233
            reg_rdata <= reg_wdata;
234
 
235
 
236
 
237
initial
238
begin
239
        resetn = 1;
240
        #100 resetn = 0;
241
        #100 resetn = 1;
242
        #1000
243
        //usb_test1;
244
        //usb_test2;
245
        usb_test3;
246
 
247
        $finish;
248
end
249
 
250
`include "usb_test1.v"
251
`include "usb_test2.v"
252
`include "usb_test3.v"
253
endmodule

powered by: WebSVN 2.1.0

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