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

Subversion Repositories usb2uart

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dinesha
/**********************************************************************
2
*  Ported to USB2UART Project
3
*  Author:  Dinesh Annayya
4
*           Email:- dinesha@opencores.org
5
*
6
*     Date: 4th Feb 2013
7
*     Changes:
8
*     A. Warning Clean Up
9
*     B. USB1-phy is move to core level
10
*
11
**********************************************************************/
12
/////////////////////////////////////////////////////////////////////
13
////                                                             ////
14
////  USB 1.1 function IP core                                   ////
15
////                                                             ////
16
////                                                             ////
17
////  Author: Rudolf Usselmann                                   ////
18
////          rudi@asics.ws                                      ////
19
////                                                             ////
20
////                                                             ////
21
////  Downloaded from: http://www.opencores.org/cores/usb1_funct/////
22
////                                                             ////
23
/////////////////////////////////////////////////////////////////////
24
////                                                             ////
25
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
26
////                         www.asics.ws                        ////
27
////                         rudi@asics.ws                       ////
28
////                                                             ////
29
//// This source file may be used and distributed without        ////
30
//// restriction provided that this copyright statement is not   ////
31
//// removed from the file and that any derivative work contains ////
32
//// the original copyright notice and the associated disclaimer.////
33
////                                                             ////
34
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
35
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
36
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
37
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
38
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
39
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
40
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
41
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
42
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
43
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
44
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
45
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
46
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
47
////                                                             ////
48
/////////////////////////////////////////////////////////////////////
49
 
50
//  CVS Log
51
//
52
//  $Id: usb1_core.v,v 1.2 2002-10-11 05:48:20 rudi Exp $
53
//
54
//  $Date: 2002-10-11 05:48:20 $
55
//  $Revision: 1.2 $
56
//  $Author: rudi $
57
//  $Locker:  $
58
//  $State: Exp $
59
//
60
// Change History:
61
//               $Log: not supported by cvs2svn $
62
//               Revision 1.1  2002/09/25 06:06:49  rudi
63
//               - Added New Top Level
64
//               - Remove old top level and associated files
65
//               - Moved FIFOs to "Generic FIFOs" project
66
//
67
//
68
//
69
//
70
//
71
//
72
//
73
 
74
`include "usb1_defines.v"
75
 
76
/*
77
 
78
                // USB PHY Interface
79
                tx_dp, tx_dn, tx_oe,
80
                rx_d, rx_dp, rx_dn,
81
These pins are a semi-standard interface to USB 1.1 transceivers.
82
Just match up the signal names with the IOs of the transceiver.
83
 
84
                // USB Misc
85
                phy_tx_mode, usb_rst,
86
The PHY supports single ended and differential output to the
87
transceiver Depending on which device you are using, you have
88
to tie the phy_tx_mode high or low.
89
usb_rst is asserted whenever the host signals reset on the USB
90
bus. The USB core will internally reset itself automatically.
91
This output is provided for external logic that needs to be
92
reset when the USB bus is reset.
93
 
94
                // Interrupts
95
                dropped_frame, misaligned_frame,
96
                crc16_err,
97
dropped_frame, misaligned_frame are interrupt to indicate error
98
conditions in Block Frame mode.
99
crc16_err, indicates when a crc 16 error was detected on the
100
payload of a USB packet.
101
 
102
                // Vendor Features
103
                v_set_int, v_set_feature, wValue,
104
                wIndex, vendor_data,
105
This signals allow to control vendor specific registers and logic
106
that can be manipulated and monitored via the control endpoint
107
through vendor defined commands.
108
 
109
                // USB Status
110
                usb_busy, ep_sel,
111
usb_busy is asserted when the USB core is busy transferring
112
data ep_sel indicated the endpoint that is currently busy.
113
This information might be useful if one desires to reset/clear
114
the attached FIFOs and want to do this when the endpoint is idle.
115
 
116
                // Endpoint Interface
117
This implementation supports 8 endpoints. Endpoint 0 is the
118
control endpoint and used internally. Endpoints 1-7 are available
119
to the user. replace 'N' with the endpoint number.
120
 
121
                epN_cfg,
122
This is a constant input used to configure the endpoint by ORing
123
these defines together and adding the max packet size for this
124
endpoint:
125
`IN and `OUT select the transfer direction for this endpoint
126
`ISO, `BULK and `INT determine the endpoint type
127
 
128
Example: "`BULK | `IN  | 14'd064" defines a BULK IN endpoint with
129
max packet size of 64 bytes
130
 
131
                epN_din,  epN_we, epN_full,
132
This is the OUT FIFO interface. If this is a IN endpoint, ground
133
all unused inputs and leave outputs unconnected.
134
 
135
                epN_dout, epN_re, epN_empty,
136
this is the IN FIFO interface. If this is a OUT endpoint ground
137
all unused inputs and leave outputs unconnected.
138
 
139
                epN_bf_en, epN_bf_size,
140
These two constant configure the Block Frame feature.
141
 
142
*/
143
 
144
 
145
module usb1_core(clk_i, rst_i,
146
 
147
                // UTMI Interface
148
                DataOut, TxValid, TxReady, RxValid,
149
                RxActive, RxError, DataIn, LineState,
150
                // USB Misc
151
                phy_tx_mode, usb_rst,
152
 
153
                // Interrupts
154
                dropped_frame, misaligned_frame,
155
                crc16_err,
156
 
157
                // Vendor Features
158
                v_set_int, v_set_feature, wValue,
159
                wIndex, vendor_data,
160
 
161
                // USB Status
162
                usb_busy, ep_sel,
163
 
164
                // Endpoint Interface
165
                ep1_cfg,
166
                ep1_din,  ep1_we, ep1_full,
167
                ep1_dout, ep1_re, ep1_empty,
168
                ep1_bf_en, ep1_bf_size,
169
 
170
                ep2_cfg,
171
                ep2_din,  ep2_we, ep2_full,
172
                ep2_dout, ep2_re, ep2_empty,
173
                ep2_bf_en, ep2_bf_size,
174
 
175
                ep3_cfg,
176
                ep3_din,  ep3_we, ep3_full,
177
                ep3_dout, ep3_re, ep3_empty,
178
                ep3_bf_en, ep3_bf_size,
179
 
180
                ep4_cfg,
181
                ep4_din,  ep4_we, ep4_full,
182
                ep4_dout, ep4_re, ep4_empty,
183
                ep4_bf_en, ep4_bf_size,
184
 
185
                ep5_cfg,
186
                ep5_din,  ep5_we, ep5_full,
187
                ep5_dout, ep5_re, ep5_empty,
188
                ep5_bf_en, ep5_bf_size,
189
 
190
                ep6_cfg,
191
                ep6_din,  ep6_we, ep6_full,
192
                ep6_dout, ep6_re, ep6_empty,
193
                ep6_bf_en, ep6_bf_size,
194
 
195
                ep7_cfg,
196
                ep7_din,  ep7_we, ep7_full,
197
                ep7_dout, ep7_re, ep7_empty,
198
                ep7_bf_en, ep7_bf_size,
199
 
200
                // Register Interface
201
                reg_addr,
202
                reg_rdwrn,
203
                reg_req,
204
                reg_wdata,
205
                reg_rdata,
206
                reg_ack
207
 
208
                );
209
 
210
input           clk_i;
211
input           rst_i;
212
//------------------------------------
213
// UTMI Interface
214
// -----------------------------------
215
output  [7:0]    DataOut;
216
output          TxValid;
217
input           TxReady;
218
input   [7:0]    DataIn;
219
input           RxValid;
220
input           RxActive;
221
input           RxError;
222
input   [1:0]    LineState;
223
 
224
input           phy_tx_mode;
225
input           usb_rst;
226
output          dropped_frame, misaligned_frame;
227
output          crc16_err;
228
 
229
output          v_set_int;
230
output          v_set_feature;
231
output  [15:0]   wValue;
232
output  [15:0]   wIndex;
233
input   [15:0]   vendor_data;
234
 
235
output          usb_busy;
236
output  [3:0]    ep_sel;
237
 
238
//-----------------------------------
239
// Register Interface
240
// ----------------------------------
241
output [31:0]   reg_addr;   // Register Address
242
output          reg_rdwrn;  // 0 -> write, 1-> read
243
output          reg_req;    //  Register Req
244
output [31:0]   reg_wdata;  // Register write data
245
input  [31:0]   reg_rdata;  // Register Read Data
246
input           reg_ack;    // Register Ack
247
 
248
// Endpoint Interfaces
249
input   [13:0]   ep1_cfg;
250
input   [7:0]    ep1_din;
251
output  [7:0]    ep1_dout;
252
output          ep1_we, ep1_re;
253
input           ep1_empty, ep1_full;
254
input           ep1_bf_en;
255
input   [6:0]    ep1_bf_size;
256
 
257
input   [13:0]   ep2_cfg;
258
input   [7:0]    ep2_din;
259
output  [7:0]    ep2_dout;
260
output          ep2_we, ep2_re;
261
input           ep2_empty, ep2_full;
262
input           ep2_bf_en;
263
input   [6:0]    ep2_bf_size;
264
 
265
input   [13:0]   ep3_cfg;
266
input   [7:0]    ep3_din;
267
output  [7:0]    ep3_dout;
268
output          ep3_we, ep3_re;
269
input           ep3_empty, ep3_full;
270
input           ep3_bf_en;
271
input   [6:0]    ep3_bf_size;
272
 
273
input   [13:0]   ep4_cfg;
274
input   [7:0]    ep4_din;
275
output  [7:0]    ep4_dout;
276
output          ep4_we, ep4_re;
277
input           ep4_empty, ep4_full;
278
input           ep4_bf_en;
279
input   [6:0]    ep4_bf_size;
280
 
281
input   [13:0]   ep5_cfg;
282
input   [7:0]    ep5_din;
283
output  [7:0]    ep5_dout;
284
output          ep5_we, ep5_re;
285
input           ep5_empty, ep5_full;
286
input           ep5_bf_en;
287
input   [6:0]    ep5_bf_size;
288
 
289
input   [13:0]   ep6_cfg;
290
input   [7:0]    ep6_din;
291
output  [7:0]    ep6_dout;
292
output          ep6_we, ep6_re;
293
input           ep6_empty, ep6_full;
294
input           ep6_bf_en;
295
input   [6:0]    ep6_bf_size;
296
 
297
input   [13:0]   ep7_cfg;
298
input   [7:0]    ep7_din;
299
output  [7:0]    ep7_dout;
300
output          ep7_we, ep7_re;
301
input           ep7_empty, ep7_full;
302
input           ep7_bf_en;
303
input   [6:0]    ep7_bf_size;
304
 
305
///////////////////////////////////////////////////////////////////
306
//
307
// Local Wires and Registers
308
//
309
 
310
wire    [7:0]    rx_data;
311
wire            rx_valid, rx_active, rx_err;
312
wire    [7:0]    tx_data;
313
wire            tx_valid;
314
wire            tx_ready;
315
wire            tx_first;
316
wire            tx_valid_last;
317
 
318
// Internal Register File Interface
319
wire    [6:0]    funct_adr;      // This functions address (set by controller)
320
wire    [3:0]    ep_sel;         // Endpoint Number Input
321
wire            crc16_err;      // Set CRC16 error interrupt
322
wire            int_to_set;     // Set time out interrupt
323
wire            int_seqerr_set; // Set PID sequence error interrupt
324
wire    [31:0]   frm_nat;        // Frame Number and Time Register
325
wire            nse_err;        // No Such Endpoint Error
326
wire            pid_cs_err;     // PID CS error
327
wire            crc5_err;       // CRC5 Error
328
 
329
reg     [7:0]    tx_data_st;
330
wire    [7:0]    rx_ctrl_data;
331
wire    [7:0]    rx_ctrl_data_d;
332
reg     [13:0]   cfg;
333
reg             ep_empty;
334
reg             ep_full;
335
wire    [7:0]    rx_size;
336
wire            rx_done;
337
 
338
wire    [7:0]    ep0_din;
339
wire    [7:0]    ep0_dout;
340
wire            ep0_re, ep0_we;
341
wire    [13:0]   ep0_cfg;
342
wire    [7:0]    ep0_size;
343
wire    [7:0]    ep0_ctrl_dout, ep0_ctrl_din;
344
wire            ep0_ctrl_re, ep0_ctrl_we;
345
wire    [3:0]    ep0_ctrl_stat;
346
 
347
wire            ctrl_setup, ctrl_in, ctrl_out;
348
wire            send_stall;
349
wire            token_valid;
350
reg             rst_local;              // internal reset
351
wire            dropped_frame;
352
wire            misaligned_frame;
353
wire            v_set_int;
354
wire            v_set_feature;
355
wire    [15:0]   wValue;
356
wire    [15:0]   wIndex;
357
 
358
reg             ep_bf_en;
359
reg     [6:0]    ep_bf_size;
360
wire    [6:0]    rom_adr;
361
wire    [7:0]    rom_data;
362
 
363
///////////////////////////////////////////////////////////////////
364
//
365
// Misc Logic
366
//
367
 
368
// Endpoint type and Max transfer size
369
assign ep0_cfg = `CTRL | ep0_size;
370
 
371
always @(posedge clk_i)
372
        rst_local <= #1 rst_i & ~usb_rst;
373
 
374
///////////////////////////////////////////////////////////////////
375
//
376
// Module Instantiations
377
//
378
/******* Move to phy logic is move to core level
379
usb_phy phy(
380
                .clk(                   clk_i                   ),
381
                .rst(                   rst_i                   ),      // ONLY external reset
382
                .phy_tx_mode(           phy_tx_mode             ),
383
                .usb_rst(               usb_rst                 ),
384
 
385
                // Transceiver Interface
386
                .rxd(                   rx_d                    ),
387
                .rxdp(                  rx_dp                   ),
388
                .rxdn(                  rx_dn                   ),
389
                .txdp(                  tx_dp                   ),
390
                .txdn(                  tx_dn                   ),
391
                .txoe(                  tx_oe                   ),
392
 
393
                // UTMI Interface
394
                .DataIn_o(              DataIn                  ),
395
                .RxValid_o(             RxValid                 ),
396
                .RxActive_o(            RxActive                ),
397
                .RxError_o(             RxError                 ),
398
                .DataOut_i(             DataOut                 ),
399
                .TxValid_i(             TxValid                 ),
400
                .TxReady_o(             TxReady                 ),
401
                .LineState_o(           LineState               )
402
                );
403
*******************************/
404
// UTMI Interface
405
usb1_utmi_if    u0(
406
                .phy_clk(               clk_i                   ),
407
                .rst(                   rst_local               ),
408
                // Interface towards Phy-Tx
409
                .DataOut(               DataOut                 ),
410
                .TxValid(               TxValid                 ),
411
                .TxReady(               TxReady                 ),
412
 
413
                // Interface towards Phy-rx
414
                .RxValid(               RxValid                 ),
415
                .RxActive(              RxActive                ),
416
                .RxError(               RxError                 ),
417
                .DataIn(                DataIn                  ),
418
 
419
                // Interfcae towards protocol layer-rx
420
                .rx_data(               rx_data                 ),
421
                .rx_valid(              rx_valid                ),
422
                .rx_active(             rx_active               ),
423
                .rx_err(                rx_err                  ),
424
 
425
                // Interfcae towards protocol layer-tx
426
                .tx_data(               tx_data                 ),
427
                .tx_valid(              tx_valid                ),
428
                .tx_valid_last(         tx_valid_last           ),
429
                .tx_ready(              tx_ready                ),
430
                .tx_first(              tx_first                )
431
                );
432
 
433
// Protocol Layer
434
usb1_pl  u1(    .clk(                   clk_i                   ),
435
                .rst(                   rst_local               ),
436
                // Interface towards utmi-rx
437
                .rx_data(               rx_data                 ),
438
                .rx_valid(              rx_valid                ),
439
                .rx_active(             rx_active               ),
440
                .rx_err(                rx_err                  ),
441
 
442
                // Interface towards utmi-tx
443
                .tx_data(               tx_data                 ),
444
                .tx_valid(              tx_valid                ),
445
                .tx_valid_last(         tx_valid_last           ),
446
                .tx_ready(              tx_ready                ),
447
                .tx_first(              tx_first                ),
448
 
449
                // Interface towards usb-phy-tx
450
                .tx_valid_out(          TxValid                 ),
451
 
452
                // unused outputs
453
                .token_valid(           token_valid             ),
454
                .int_to_set(            int_to_set              ),
455
                .int_seqerr_set(        int_seqerr_set          ),
456
                .pid_cs_err(            pid_cs_err              ),
457
                .nse_err(               nse_err                 ),
458
                .crc5_err(              crc5_err                ),
459
                .rx_size(               rx_size                 ),
460
                .rx_done(               rx_done                 ),
461
 
462
                // Interface towards usb-ctrl
463
                .fa(                    funct_adr               ),
464
                .frm_nat(               frm_nat                 ),
465
                .ctrl_setup(            ctrl_setup              ),
466
                .ctrl_in(               ctrl_in                 ),
467
                .ctrl_out(              ctrl_out                ),
468
                .send_stall(            send_stall              ),
469
 
470
                // usb-status 
471
                .ep_sel(                ep_sel                  ),
472
                .x_busy(                usb_busy                ),
473
                .int_crc16_set(         crc16_err               ),
474
                .dropped_frame(         dropped_frame           ),
475
                .misaligned_frame(      misaligned_frame        ),
476
 
477
                .ep_bf_en(              ep_bf_en                ),
478
                .ep_bf_size(            ep_bf_size              ),
479
                .csr(                   cfg                     ),
480
                .tx_data_st(            tx_data_st              ),
481
 
482
                .rx_ctrl_data          (rx_ctrl_data            ),
483
                .rx_ctrl_data_d        (rx_ctrl_data_d          ),
484
                .rx_ctrl_dvalid        (rx_ctrl_dvalid          ),
485
                .rx_ctrl_ddone         (rx_ctrl_ddone           ),
486
 
487
                .idma_re(               idma_re                 ),
488
                .idma_we(               idma_we                 ),
489
                .ep_empty(              ep_empty                ),
490
                .ep_full(               ep_full                 )
491
                );
492
 
493
usb1_ctrl  u4(  .clk(                   clk_i                   ),
494
                .rst(                   rst_local               ),
495
 
496
                .rom_adr(               rom_adr                 ),
497
                .rom_data(              rom_data                ),
498
 
499
                .ctrl_setup(            ctrl_setup              ),
500
                .ctrl_in(               ctrl_in                 ),
501
                .ctrl_out(              ctrl_out                ),
502
 
503
                .rx_ctrl_data          (rx_ctrl_data            ),
504
                .rx_ctrl_dvalid        (rx_ctrl_dvalid          ),
505
                .rx_ctrl_ddone         (rx_ctrl_ddone           ),
506
 
507
 
508
                .ep0_din(               ep0_ctrl_dout           ),
509
                .ep0_dout(              ep0_ctrl_din            ),
510
                .ep0_re(                ep0_ctrl_re             ),
511
                .ep0_we(                ep0_ctrl_we             ),
512
                .ep0_stat(              ep0_ctrl_stat           ),
513
                .ep0_size(              ep0_size                ),
514
 
515
                .send_stall(            send_stall              ),
516
                .frame_no(              frm_nat[26:16]          ),
517
                .funct_adr(             funct_adr               ),
518
                .configured(                                    ),
519
                .halt(                                          ),
520
 
521
                .v_set_int(             v_set_int               ),
522
                .v_set_feature(         v_set_feature           ),
523
                .wValue(                wValue                  ),
524
                .wIndex(                wIndex                  ),
525
                .vendor_data(           vendor_data             ),
526
 
527
                  // Register Interface
528
                   .reg_addr    (reg_addr),
529
                   .reg_rdwrn   (reg_rdwrn),
530
                   .reg_req     (reg_req),
531
                   .reg_wdata   (reg_wdata),
532
                   .reg_rdata   (reg_rdata),
533
                   .reg_ack     (reg_ack)
534
 
535
                );
536
 
537
 
538
usb1_rom1 rom1( .clk(           clk_i           ),
539
                .adr(           rom_adr         ),
540
                .dout(          rom_data        )
541
                );
542
 
543
// CTRL Endpoint FIFO
544
/*************
545
generic_fifo_sc_a #(8,6,0) u10(
546
                .clk(                   clk_i                   ),
547
                .rst(                   rst_i                   ),
548
                .clr(                   usb_rst                 ),
549
                .din(                   rx_ctrl_data_d          ),
550
                .we(                    ep0_we                  ),
551
                .dout(                  ep0_ctrl_dout           ),
552
                .re(                    ep0_ctrl_re             ),
553
                .full_r(                                        ),
554
                .empty_r(                                       ),
555
                .full(                  ep0_full                ),
556
                .empty(                 ep0_ctrl_stat[1]        ),
557
                .full_n(                                        ),
558
                .empty_n(                                       ),
559
                .full_n_r(                                      ),
560
                .empty_n_r(                                     ),
561
                .level(                                         )
562
                );
563
 
564
*************/
565
// CTRL Endpoint FIFO
566
sync_fifo  #(8,8) u10(
567
                  .clk          (clk_i),
568
                  .reset_n      (rst_i),
569
                  .clr          (usb_rst),
570
                  .wr_en        (ep0_we),
571
                  .wr_data      (rx_ctrl_data_d),
572
                  .full         (ep0_full),
573
                  .empty        (ep0_ctrl_stat[1]),
574
                  .rd_en        (ep0_ctrl_re),
575
                  .rd_data      (ep0_ctrl_dout)
576
          );
577
generic_fifo_sc_a #(8,6,0) u11(
578
                .clk(                   clk_i                   ),
579
                .rst(                   rst_i                   ),
580
                .clr(                   usb_rst                 ),
581
                .din(                   ep0_ctrl_din            ),
582
                .we(                    ep0_ctrl_we             ),
583
                .dout(                  ep0_dout                ),
584
                .re(                    ep0_re                  ),
585
                .full_r(                                        ),
586
                .empty_r(                                       ),
587
                .full(                  ep0_ctrl_stat[2]        ),
588
                .empty(                 ep0_empty               ),
589
                .full_n(                                        ),
590
                .empty_n(                                       ),
591
                .full_n_r(                                      ),
592
                .empty_n_r(                                     ),
593
                .level(                                         )
594
                );
595
 
596
 
597
///////////////////////////////////////////////////////////////////
598
//
599
// Endpoint FIFO Interfaces
600
//
601
 
602
always @(ep_sel or ep0_cfg or ep1_cfg or ep2_cfg or ep3_cfg or
603
                ep4_cfg or ep5_cfg or ep6_cfg or ep7_cfg)
604
        case(ep_sel)    // synopsys full_case parallel_case
605
           4'h0:        cfg = ep0_cfg;
606
           4'h1:        cfg = ep1_cfg;
607
           4'h2:        cfg = ep2_cfg;
608
           4'h3:        cfg = ep3_cfg;
609
           4'h4:        cfg = ep4_cfg;
610
           4'h5:        cfg = ep5_cfg;
611
           4'h6:        cfg = ep6_cfg;
612
           4'h7:        cfg = ep7_cfg;
613
        endcase
614
 
615
// In endpoints only
616
always @(posedge clk_i)
617
        case(ep_sel)    // synopsys full_case parallel_case
618
           4'h0:        tx_data_st <= #1 ep0_dout;
619
           4'h1:        tx_data_st <= #1 ep1_din;
620
           4'h2:        tx_data_st <= #1 ep2_din;
621
           4'h3:        tx_data_st <= #1 ep3_din;
622
           4'h4:        tx_data_st <= #1 ep4_din;
623
           4'h5:        tx_data_st <= #1 ep5_din;
624
           4'h6:        tx_data_st <= #1 ep6_din;
625
           4'h7:        tx_data_st <= #1 ep7_din;
626
        endcase
627
 
628
// In endpoints only
629
always @(posedge clk_i)
630
        case(ep_sel)    // synopsys full_case parallel_case
631
           4'h0:        ep_empty <= #1 ep0_empty;
632
           4'h1:        ep_empty <= #1 ep1_empty;
633
           4'h2:        ep_empty <= #1 ep2_empty;
634
           4'h3:        ep_empty <= #1 ep3_empty;
635
           4'h4:        ep_empty <= #1 ep4_empty;
636
           4'h5:        ep_empty <= #1 ep5_empty;
637
           4'h6:        ep_empty <= #1 ep6_empty;
638
           4'h7:        ep_empty <= #1 ep7_empty;
639
        endcase
640
 
641
// OUT endpoints only
642
always @(ep_sel or ep0_full or ep1_full or ep2_full or ep3_full or
643
                ep4_full or ep5_full or ep6_full or ep7_full)
644
        case(ep_sel)    // synopsys full_case parallel_case
645
           4'h0:        ep_full = ep0_full;
646
           4'h1:        ep_full = ep1_full;
647
           4'h2:        ep_full = ep2_full;
648
           4'h3:        ep_full = ep3_full;
649
           4'h4:        ep_full = ep4_full;
650
           4'h5:        ep_full = ep5_full;
651
           4'h6:        ep_full = ep6_full;
652
           4'h7:        ep_full = ep7_full;
653
        endcase
654
 
655
always @(posedge clk_i)
656
        case(ep_sel)    // synopsys full_case parallel_case
657
           4'h0:        ep_bf_en = 1'b0;
658
           4'h1:        ep_bf_en = ep1_bf_en;
659
           4'h2:        ep_bf_en = ep2_bf_en;
660
           4'h3:        ep_bf_en = ep3_bf_en;
661
           4'h4:        ep_bf_en = ep4_bf_en;
662
           4'h5:        ep_bf_en = ep5_bf_en;
663
           4'h6:        ep_bf_en = ep6_bf_en;
664
           4'h7:        ep_bf_en = ep7_bf_en;
665
        endcase
666
 
667
always @(posedge clk_i)
668
        case(ep_sel)    // synopsys full_case parallel_case
669
           4'h1:        ep_bf_size = ep1_bf_size;
670
           4'h2:        ep_bf_size = ep2_bf_size;
671
           4'h3:        ep_bf_size = ep3_bf_size;
672
           4'h4:        ep_bf_size = ep4_bf_size;
673
           4'h5:        ep_bf_size = ep5_bf_size;
674
           4'h6:        ep_bf_size = ep6_bf_size;
675
           4'h7:        ep_bf_size = ep7_bf_size;
676
        endcase
677
 
678
assign ep1_dout = rx_ctrl_data_d;
679
assign ep2_dout = rx_ctrl_data_d;
680
assign ep3_dout = rx_ctrl_data_d;
681
assign ep4_dout = rx_ctrl_data_d;
682
assign ep5_dout = rx_ctrl_data_d;
683
assign ep6_dout = rx_ctrl_data_d;
684
assign ep7_dout = rx_ctrl_data_d;
685
 
686
assign ep0_re = idma_re & (ep_sel == 4'h0);
687
assign ep1_re = idma_re & (ep_sel == 4'h1) & !ep1_empty;
688
assign ep2_re = idma_re & (ep_sel == 4'h2) & !ep2_empty;
689
assign ep3_re = idma_re & (ep_sel == 4'h3) & !ep3_empty;
690
assign ep4_re = idma_re & (ep_sel == 4'h4) & !ep4_empty;
691
assign ep5_re = idma_re & (ep_sel == 4'h5) & !ep5_empty;
692
assign ep6_re = idma_re & (ep_sel == 4'h6) & !ep6_empty;
693
assign ep7_re = idma_re & (ep_sel == 4'h7) & !ep7_empty;
694
 
695
assign ep0_we = idma_we & (ep_sel == 4'h0);
696
assign ep1_we = idma_we & (ep_sel == 4'h1) & !ep1_full;
697
assign ep2_we = idma_we & (ep_sel == 4'h2) & !ep2_full;
698
assign ep3_we = idma_we & (ep_sel == 4'h3) & !ep3_full;
699
assign ep4_we = idma_we & (ep_sel == 4'h4) & !ep4_full;
700
assign ep5_we = idma_we & (ep_sel == 4'h5) & !ep5_full;
701
assign ep6_we = idma_we & (ep_sel == 4'h6) & !ep6_full;
702
assign ep7_we = idma_we & (ep_sel == 4'h7) & !ep7_full;
703
 
704
endmodule

powered by: WebSVN 2.1.0

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