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

Subversion Repositories usb2uart

[/] [usb2uart/] [trunk/] [rtl/] [core/] [core.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  USB2UART core level  Module                                 ////
4
////                                                              ////
5
////  This file is part of the usb2uart cores project             ////
6
////  http://www.opencores.org/cores/usb2uart/                    ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  USB2UART core level integration.                            ////
10
////     Following modules are integrated                         ////
11
////         1. usb1_phy                                          ////
12
////         2. usb1_core                                         ////
13
////         3. uart_core                                         ////
14
////   Ver 0.1 : 01.Mar.2013                                      ////
15
////                                                              ////
16
////  To Do:                                                      ////
17
////    nothing                                                   ////
18
////                                                              ////
19
////  Author(s):                                                  ////
20
////      - Dinesh Annayya, dinesha@opencores.org                 ////
21
////                                                              ////
22
//////////////////////////////////////////////////////////////////////
23
////                                                              ////
24
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
25
////                                                              ////
26
//// This source file may be used and distributed without         ////
27
//// restriction provided that this copyright statement is not    ////
28
//// removed from the file and that any derivative work contains  ////
29
//// the original copyright notice and the associated disclaimer. ////
30
////                                                              ////
31
//// This source file is free software; you can redistribute it   ////
32
//// and/or modify it under the terms of the GNU Lesser General   ////
33
//// Public License as published by the Free Software Foundation; ////
34
//// either version 2.1 of the License, or (at your option) any   ////
35
//// later version.                                               ////
36
////                                                              ////
37
//// This source is distributed in the hope that it will be       ////
38
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
39
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
40
//// PURPOSE.  See the GNU Lesser General Public License for more ////
41
//// details.                                                     ////
42
////                                                              ////
43
//// You should have received a copy of the GNU Lesser General    ////
44
//// Public License along with this source; if not, download it   ////
45
//// from http://www.opencores.org/lgpl.shtml                     ////
46
////                                                              ////
47
//////////////////////////////////////////////////////////////////////
48
 
49
 
50
module core(
51
        clk_i,
52
        rst_i,
53
 
54
        // Transciever Interface
55
        usb_txdp,
56
        usb_txdn,
57
        usb_txoe,
58
        usb_rxd,
59
        usb_rxdp,
60
        usb_rxdn,
61
 
62
        // USB Misc
63
        phy_tx_mode ,
64
        usb_rst,
65
 
66
        // Interrupts
67
        dropped_frame,
68
        misaligned_frame,
69
        crc16_err,
70
 
71
        // Vendor Features
72
        v_set_int,
73
        v_set_feature,
74
        wValue,
75
        wIndex,
76
        vendor_data,
77
 
78
        // USB Status
79
        usb_busy,
80
        ep_sel,
81
 
82
        // Endpoint Interface
83
        ep1_cfg,
84
        ep1_din,
85
        ep1_we,
86
        ep1_full,
87
        ep1_dout,
88
        ep1_re,
89
        ep1_empty,
90
        ep1_bf_en,
91
        ep1_bf_size,
92
 
93
        ep2_cfg,
94
        ep2_din,
95
        ep2_we,
96
        ep2_full,
97
        ep2_dout,
98
        ep2_re,
99
        ep2_empty,
100
        ep2_bf_en,
101
        ep2_bf_size,
102
 
103
        ep3_cfg,
104
        ep3_din,
105
        ep3_we,
106
        ep3_full,
107
        ep3_dout,
108
        ep3_re,
109
        ep3_empty,
110
        ep3_bf_en,
111
        ep3_bf_size,
112
 
113
        ep4_cfg,
114
        ep4_din,
115
        ep4_we,
116
        ep4_full,
117
        ep4_dout,
118
        ep4_re,
119
        ep4_empty,
120
        ep4_bf_en,
121
        ep4_bf_size,
122
 
123
        ep5_cfg,
124
        ep5_din,
125
        ep5_we,
126
        ep5_full,
127
        ep5_dout,
128
        ep5_re,
129
        ep5_empty,
130
        ep5_bf_en,
131
        ep5_bf_size,
132
 
133
        ep6_cfg,
134
        ep6_din,
135
        ep6_we, ep6_full,
136
        ep6_dout, ep6_re, ep6_empty,
137
        ep6_bf_en, ep6_bf_size,
138
 
139
        ep7_cfg,
140
        ep7_din,  ep7_we, ep7_full,
141
        ep7_dout, ep7_re, ep7_empty,
142
        ep7_bf_en, ep7_bf_size,
143
        // Uart Line Interface
144
        uart_txd, uart_rxd
145
 
146
        );
147
 
148
input       clk_i;
149
input       rst_i;
150
 
151
// USB Traceiver interface
152
output      usb_txdp; // USB TX + 
153
output      usb_txdn; // USB TX -
154
output      usb_txoe; // USB TX OEN, Output driven at txoe=0
155
input       usb_rxd;
156
input       usb_rxdp;  // USB RX+
157
input       usb_rxdn;  // USB RX-
158
 
159
input       phy_tx_mode;
160
output      usb_rst;
161
output          dropped_frame, misaligned_frame;
162
output          crc16_err;
163
 
164
output          v_set_int;
165
output          v_set_feature;
166
output  [15:0]  wValue;
167
output  [15:0]  wIndex;
168
input   [15:0]  vendor_data;
169
 
170
output      usb_busy;
171
output  [3:0]   ep_sel;
172
 
173
// Endpoint Interfaces
174
input   [13:0]  ep1_cfg;
175
input   [7:0]   ep1_din;
176
output  [7:0]   ep1_dout;
177
output      ep1_we, ep1_re;
178
input       ep1_empty, ep1_full;
179
input       ep1_bf_en;
180
input   [6:0]   ep1_bf_size;
181
 
182
input   [13:0]  ep2_cfg;
183
input   [7:0]   ep2_din;
184
output  [7:0]   ep2_dout;
185
output      ep2_we, ep2_re;
186
input       ep2_empty, ep2_full;
187
input       ep2_bf_en;
188
input   [6:0]   ep2_bf_size;
189
 
190
input   [13:0]  ep3_cfg;
191
input   [7:0]   ep3_din;
192
output  [7:0]   ep3_dout;
193
output      ep3_we, ep3_re;
194
input       ep3_empty, ep3_full;
195
input       ep3_bf_en;
196
input   [6:0]   ep3_bf_size;
197
 
198
input   [13:0]  ep4_cfg;
199
input   [7:0]   ep4_din;
200
output  [7:0]   ep4_dout;
201
output      ep4_we, ep4_re;
202
input       ep4_empty, ep4_full;
203
input       ep4_bf_en;
204
input   [6:0]   ep4_bf_size;
205
 
206
input   [13:0]  ep5_cfg;
207
input   [7:0]   ep5_din;
208
output  [7:0]   ep5_dout;
209
output      ep5_we, ep5_re;
210
input       ep5_empty, ep5_full;
211
input       ep5_bf_en;
212
input   [6:0]   ep5_bf_size;
213
 
214
input   [13:0]  ep6_cfg;
215
input   [7:0]   ep6_din;
216
output  [7:0]   ep6_dout;
217
output      ep6_we, ep6_re;
218
input       ep6_empty, ep6_full;
219
input       ep6_bf_en;
220
input   [6:0]   ep6_bf_size;
221
 
222
input   [13:0]  ep7_cfg;
223
input   [7:0]   ep7_din;
224
output  [7:0]   ep7_dout;
225
output      ep7_we, ep7_re;
226
input       ep7_empty, ep7_full;
227
input       ep7_bf_en;
228
input   [6:0]   ep7_bf_size;
229
 
230
//----------------------
231
// Uart I/F
232
//-----------------------
233
 
234
input           uart_rxd;
235
output          uart_txd;
236
 
237
//-----------------------------------
238
// Register Interface
239
// ----------------------------------
240
wire [31:0]   reg_addr;   // Register Address
241
wire      reg_rdwrn;  // 0 -> write, 1-> read
242
wire      reg_req;    //  Register Req
243
wire [31:0]   reg_wdata;  // Register write data
244
wire  [31:0]   reg_rdata;  // Register Read Data
245
wire       reg_ack;    // Register Ack
246
///////////////////////////////////////////////////////////////////
247
// Local Wires and Registers
248
///////////////////////////////////////////////////////////////////
249
//------------------------------------
250
// UTMI Interface
251
// -----------------------------------
252
wire    [7:0]   DataOut;
253
wire        TxValid;
254
wire        TxReady;
255
wire    [7:0]   DataIn;
256
wire        RxValid;
257
wire        RxActive;
258
wire        RxError;
259
wire    [1:0]   LineState;
260
wire        clk;
261
wire        rst;
262
wire        phy_tx_mode;
263
wire        usb_rst;
264
 
265
usb_phy u_usb_phy(
266
                    .clk                ( clk_i             ),
267
                    .rst                ( rst_i             ),
268
                    .phy_tx_mode        ( phy_tx_mode       ),
269
                    .usb_rst            ( usb_rst           ),
270
 
271
        // Transceiver Interface
272
                    .rxd                ( usb_rxd           ),
273
                    .rxdp               ( usb_rxdp          ),
274
                    .rxdn               ( usb_rxdn          ),
275
                    .txdp               ( usb_txdp          ),
276
                    .txdn               ( usb_txdn          ),
277
                    .txoe               ( usb_txoe          ),
278
 
279
        // UTMI Interface
280
                    .DataIn_o           ( DataIn            ),
281
                    .RxValid_o          ( RxValid           ),
282
                    .RxActive_o         ( RxActive          ),
283
                    .RxError_o          ( RxError           ),
284
                    .DataOut_i          ( DataOut           ),
285
                    .TxValid_i          ( TxValid           ),
286
                    .TxReady_o          ( TxReady           ),
287
                    .LineState_o        ( LineState         )
288
        );
289
 
290
 
291
usb1_core  u_usb_core(
292
                    .clk_i              ( clk_i             ),
293
                    .rst_i              ( rst_i             ),
294
 
295
 
296
                 // USB Misc
297
                    .phy_tx_mode        ( phy_tx_mode       ),
298
                    .usb_rst            ( usb_rst           ),
299
 
300
                                        // UTMI Interface
301
                    .DataIn             ( DataIn            ),
302
                    .RxValid            ( RxValid           ),
303
                    .RxActive           ( RxActive          ),
304
                    .RxError            ( RxError           ),
305
                    .DataOut            ( DataOut           ),
306
                    .TxValid            ( TxValid           ),
307
                    .TxReady            ( TxReady           ),
308
                    .LineState          ( LineState         ),
309
 
310
                 // Interrupts
311
                    .dropped_frame      ( dropped_frame     ),
312
                    .misaligned_frame   ( misaligned_frame  ),
313
                    .crc16_err          ( crc16_err         ),
314
 
315
                  // Vendor Features
316
                    .v_set_int          ( v_set_int         ),
317
                    .v_set_feature      ( v_set_feature     ),
318
                    .wValue             ( wValue            ),
319
                    .wIndex             ( wIndex            ),
320
                    .vendor_data        ( vendor_data       ),
321
 
322
        // USB Status
323
                    .usb_busy           ( usb_busy          ),
324
                    .ep_sel             ( ep_sel            ),
325
 
326
        // Endpoint Interface
327
                    .ep1_cfg            ( ep1_cfg           ),
328
                    .ep1_din            ( ep1_din           ),
329
                    .ep1_we             ( ep1_we            ),
330
                    .ep1_full           ( ep1_full          ),
331
                    .ep1_dout           ( ep1_dout          ),
332
                    .ep1_re             ( ep1_re            ),
333
                    .ep1_empty          ( ep1_empty         ),
334
                    .ep1_bf_en          ( ep1_bf_en         ),
335
                    .ep1_bf_size        ( ep1_bf_size       ),
336
 
337
                    .ep2_cfg            ( ep2_cfg           ),
338
                    .ep2_din            ( ep2_din           ),
339
                    .ep2_we             ( ep2_we            ),
340
                    .ep2_full           ( ep2_full          ),
341
                    .ep2_dout           ( ep2_dout          ),
342
                    .ep2_re             ( ep2_re            ),
343
                    .ep2_empty          ( ep2_empty         ),
344
                    .ep2_bf_en          ( ep2_bf_en         ),
345
                    .ep2_bf_size        ( ep2_bf_size       ),
346
 
347
                    .ep3_cfg            ( ep3_cfg           ),
348
                    .ep3_din            ( ep3_din           ),
349
                    .ep3_we             ( ep3_we            ),
350
                    .ep3_full           ( ep3_full          ),
351
                    .ep3_dout           ( ep3_dout          ),
352
                    .ep3_re             ( ep3_re            ),
353
                    .ep3_empty          ( ep3_empty         ),
354
                    .ep3_bf_en          ( ep3_bf_en         ),
355
                    .ep3_bf_size        ( ep3_bf_size       ),
356
 
357
                    .ep4_cfg            ( ep4_cfg           ),
358
                    .ep4_din            ( ep4_din           ),
359
                    .ep4_we             ( ep4_we            ),
360
                    .ep4_full           ( ep4_full          ),
361
                    .ep4_dout           ( ep4_dout          ),
362
                    .ep4_re             ( ep4_re            ),
363
                    .ep4_empty          ( ep4_empty         ),
364
                    .ep4_bf_en          ( ep4_bf_en         ),
365
                    .ep4_bf_size        ( ep4_bf_size       ),
366
 
367
                    .ep5_cfg            ( ep5_cfg           ),
368
                    .ep5_din            ( ep5_din           ),
369
                    .ep5_we             ( ep5_we            ),
370
                    .ep5_full           ( ep5_full          ),
371
                    .ep5_dout           ( ep5_dout          ),
372
                    .ep5_re             ( ep5_re            ),
373
                    .ep5_empty          ( ep5_empty         ),
374
                    .ep5_bf_en          ( ep5_bf_en         ),
375
                    .ep5_bf_size        ( ep5_bf_size       ),
376
 
377
                    .ep6_cfg            ( ep6_cfg           ),
378
                    .ep6_din            ( ep6_din           ),
379
                    .ep6_we             ( ep6_we            ),
380
                    .ep6_full           ( ep6_full          ),
381
                    .ep6_dout           ( ep6_dout          ),
382
                    .ep6_re             ( ep6_re            ),
383
                    .ep6_empty          ( ep6_empty         ),
384
                    .ep6_bf_en          ( ep6_bf_en         ),
385
                    .ep6_bf_size        ( ep6_bf_size       ),
386
 
387
                    .ep7_cfg            ( ep7_cfg           ),
388
                    .ep7_din            ( ep7_din           ),
389
                    .ep7_we             ( ep7_we            ),
390
                    .ep7_full           ( ep7_full          ),
391
                    .ep7_dout           ( ep7_dout          ),
392
                    .ep7_re             ( ep7_re            ),
393
                    .ep7_empty          ( ep7_empty         ),
394
                    .ep7_bf_en          ( ep7_bf_en         ),
395
                    .ep7_bf_size        ( ep7_bf_size       ),
396
 
397
                // Register Interface
398
                    .reg_addr           ( reg_addr          ),
399
                    .reg_rdwrn          ( reg_rdwrn         ),
400
                    .reg_req            ( reg_req           ),
401
                    .reg_wdata          ( reg_wdata         ),
402
                    .reg_rdata          ( reg_rdata         ),
403
                    .reg_ack            ( reg_ack           )
404
 
405
 
406
        );
407
 
408
uart_core  u_uart_core
409
 
410
     (
411
        .app_reset_n (rst_i),
412
        .app_clk     (clk_i),
413
 
414
        // Reg Bus Interface Signal
415
        .reg_cs     (reg_req),
416
        .reg_wr     (!reg_rdwrn),
417
        .reg_addr   (reg_addr[5:2]),
418
        .reg_wdata  (reg_wdata),
419
        .reg_be     (4'hF),
420
 
421
        // Outputs
422
        .reg_rdata   (reg_rdata),
423
        .reg_ack     (reg_ack),
424
 
425
       // Line Interface
426
        .si          (uart_rxd),
427
        .so          (uart_txd)
428
 
429
     );
430
 
431
 
432
endmodule

powered by: WebSVN 2.1.0

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