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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [slaveController/] [usbSlaveControl.v] - Blame information for rev 14

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

Line No. Rev Author Line
1 2 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// usbSlaveControl.v                                            ////
4
////                                                              ////
5
//// This file is part of the usbhostslave opencores effort.
6
//// <http://www.opencores.org/cores//>                           ////
7
////                                                              ////
8
//// Module Description:                                          ////
9
//// 
10
////                                                              ////
11
//// To Do:                                                       ////
12
//// 
13
////                                                              ////
14
//// Author(s):                                                   ////
15
//// - Steve Fielding, sfielding@base2designs.com                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG          ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE. See the GNU Lesser General Public License for more  ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from <http://www.opencores.org/lgpl.shtml>                   ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44 9 sfielding
`timescale 1ns / 1ps
45 2 sfielding
 
46
module usbSlaveControl(
47 5 sfielding
  clk, rst,
48
  //getPacket
49
  RxByteStatus, RxData, RxDataValid,
50
  SIERxTimeOut, RxFifoData,
51
  //speedCtrlMux
52
  fullSpeedRate, fullSpeedPol,
53
  //SCTxPortArbiter
54
  SCTxPortEn, SCTxPortRdy,
55
  SCTxPortData, SCTxPortCtrl,
56
  //rxStatusMonitor
57
  connectStateIn,
58
  resumeDetectedIn,
59 2 sfielding
  //USBHostControlBI 
60
  busAddress,
61
  busDataIn,
62
  busDataOut,
63
  busWriteEn,
64
  busStrobe_i,
65 5 sfielding
  SOFRxedIntOut,
66 2 sfielding
  resetEventIntOut,
67
  resumeIntOut,
68
  transDoneIntOut,
69
  NAKSentIntOut,
70
  slaveControlSelect,
71
  //fifoMux
72
  TxFifoEP0REn,
73
  TxFifoEP1REn,
74
  TxFifoEP2REn,
75
  TxFifoEP3REn,
76
  TxFifoEP0Data,
77
  TxFifoEP1Data,
78
  TxFifoEP2Data,
79
  TxFifoEP3Data,
80
  TxFifoEP0Empty,
81
  TxFifoEP1Empty,
82
  TxFifoEP2Empty,
83
  TxFifoEP3Empty,
84
  RxFifoEP0WEn,
85
  RxFifoEP1WEn,
86
  RxFifoEP2WEn,
87
  RxFifoEP3WEn,
88
  RxFifoEP0Full,
89
  RxFifoEP1Full,
90
  RxFifoEP2Full,
91
  RxFifoEP3Full
92 5 sfielding
    );
93 2 sfielding
 
94
input clk, rst;
95
//getPacket
96
input [7:0] RxByteStatus;
97
input [7:0] RxData;
98
input RxDataValid;
99
input SIERxTimeOut;
100
output [7:0] RxFifoData;
101
//speedCtrlMux
102
output fullSpeedRate;
103
output fullSpeedPol;
104
//HCTxPortArbiter
105
output SCTxPortEn;
106
input SCTxPortRdy;
107
output [7:0] SCTxPortData;
108
output [7:0] SCTxPortCtrl;
109
//rxStatusMonitor
110
input [1:0] connectStateIn;
111
input resumeDetectedIn;
112
//USBHostControlBI 
113
input [4:0] busAddress;
114
input [7:0] busDataIn;
115
output [7:0] busDataOut;
116
input busWriteEn;
117
input busStrobe_i;
118
output SOFRxedIntOut;
119
output resetEventIntOut;
120
output resumeIntOut;
121
output transDoneIntOut;
122
output NAKSentIntOut;
123
input slaveControlSelect;
124
//fifoMux
125
output TxFifoEP0REn;
126
output TxFifoEP1REn;
127
output TxFifoEP2REn;
128
output TxFifoEP3REn;
129
input [7:0] TxFifoEP0Data;
130
input [7:0] TxFifoEP1Data;
131
input [7:0] TxFifoEP2Data;
132
input [7:0] TxFifoEP3Data;
133
input TxFifoEP0Empty;
134
input TxFifoEP1Empty;
135
input TxFifoEP2Empty;
136
input TxFifoEP3Empty;
137
output RxFifoEP0WEn;
138
output RxFifoEP1WEn;
139
output RxFifoEP2WEn;
140
output RxFifoEP3WEn;
141
input RxFifoEP0Full;
142
input RxFifoEP1Full;
143
input RxFifoEP2Full;
144
input RxFifoEP3Full;
145
 
146
wire clk;
147
wire rst;
148
wire [7:0] RxByteStatus;
149
wire [7:0] RxData;
150
wire RxDataValid;
151
wire SIERxTimeOut;
152
wire [7:0] RxFifoData;
153
wire fullSpeedRate;
154
wire fullSpeedPol;
155
wire [7:0] SCTxPortData;
156
wire [7:0] SCTxPortCtrl;
157
wire [1:0] connectStateIn;
158
wire resumeDetectedIn;
159
wire [4:0] busAddress;
160
wire [7:0] busDataIn;
161
wire [7:0] busDataOut;
162
wire busWriteEn;
163
wire busStrobe_i;
164
wire SOFRxedIntOut;
165
wire resetEventIntOut;
166
wire resumeIntOut;
167
wire transDoneIntOut;
168
wire NAKSentIntOut;
169
wire slaveControlSelect;
170
wire TxFifoEP0REn;
171
wire TxFifoEP1REn;
172
wire TxFifoEP2REn;
173
wire TxFifoEP3REn;
174
wire [7:0] TxFifoEP0Data;
175
wire [7:0] TxFifoEP1Data;
176
wire [7:0] TxFifoEP2Data;
177
wire [7:0] TxFifoEP3Data;
178
wire TxFifoEP0Empty;
179
wire TxFifoEP1Empty;
180
wire TxFifoEP2Empty;
181
wire TxFifoEP3Empty;
182
wire RxFifoEP0WEn;
183
wire RxFifoEP1WEn;
184
wire RxFifoEP2WEn;
185
wire RxFifoEP3WEn;
186
wire RxFifoEP0Full;
187
wire RxFifoEP1Full;
188
wire RxFifoEP2Full;
189
wire RxFifoEP3Full;
190
 
191
//internal wiring
192
wire [7:0] directCntlCntl;
193
wire [7:0] directCntlData;
194
wire directCntlGnt;
195
wire directCntlReq;
196
wire directCntlWEn;
197
wire [7:0] sendPacketCntl;
198
wire [7:0] sendPacketData;
199
wire sendPacketGnt;
200
wire sendPacketReq;
201 5 sfielding
wire sendPacketWEn;
202 2 sfielding
wire SCTxPortArbRdyOut;
203
wire transDone;
204
wire [1:0] directLineState;
205
wire directLineCtrlEn;
206
wire [3:0] RxPID;
207
wire [1:0] connectStateOut;
208
wire resumeIntFromRxStatusMon;
209
wire [1:0] endP0TransTypeReg;
210
wire [1:0] endP1TransTypeReg;
211
wire [1:0] endP2TransTypeReg;
212
wire [1:0] endP3TransTypeReg;
213
wire [1:0] endP0NAKTransTypeReg;
214
wire [1:0] endP1NAKTransTypeReg;
215
wire [1:0] endP2NAKTransTypeReg;
216
wire [1:0] endP3NAKTransTypeReg;
217 14 sfielding
wire [4:0] endP0ControlReg;
218
wire [4:0] endP1ControlReg;
219
wire [4:0] endP2ControlReg;
220
wire [4:0] endP3ControlReg;
221 2 sfielding
wire [7:0] endP0StatusReg;
222
wire [7:0] endP1StatusReg;
223
wire [7:0] endP2StatusReg;
224
wire [7:0] endP3StatusReg;
225
wire [6:0] USBTgtAddress;
226
wire [10:0] frameNum;
227
wire clrEP0Rdy;
228
wire clrEP1Rdy;
229
wire clrEP2Rdy;
230
wire clrEP3Rdy;
231
wire SCGlobalEn;
232
wire ACKRxed;
233
wire CRCError;
234
wire RXOverflow;
235
wire RXTimeOut;
236
wire bitStuffError;
237
wire dataSequence;
238
wire stallSent;
239
wire NAKSent;
240
wire SOFRxed;
241 14 sfielding
wire [4:0] endPControlReg;
242 2 sfielding
wire [1:0] transTypeNAK;
243
wire [1:0] transType;
244
wire [3:0] currEndP;
245
wire getPacketREn;
246
wire getPacketRdy;
247
wire [3:0] slaveControllerPIDOut;
248
wire slaveControllerReadyIn;
249
wire slaveControllerWEnOut;
250
wire TxFifoRE;
251
wire [7:0] TxFifoData;
252
wire TxFifoEmpty;
253
wire RxFifoWE;
254
wire RxFifoFull;
255
wire resetEventFromRxStatusMon;
256
wire clrEPRdy;
257
wire endPMuxErrorsWEn;
258
 
259
USBSlaveControlBI u_USBSlaveControlBI
260
  (.address(busAddress),
261
  .dataIn(busDataIn),
262
  .dataOut(busDataOut),
263
  .writeEn(busWriteEn),
264
  .strobe_i(busStrobe_i),
265
  .clk(clk),
266
  .rst(rst),
267 5 sfielding
  .SOFRxedIntOut(SOFRxedIntOut),
268 2 sfielding
  .resetEventIntOut(resetEventIntOut),
269
  .resumeIntOut(resumeIntOut),
270
  .transDoneIntOut(transDoneIntOut),
271 5 sfielding
  .NAKSentIntOut(NAKSentIntOut),
272 2 sfielding
  .endP0TransTypeReg(endP0TransTypeReg),
273
  .endP0NAKTransTypeReg(endP0NAKTransTypeReg),
274
  .endP1TransTypeReg(endP1TransTypeReg),
275
  .endP1NAKTransTypeReg(endP1NAKTransTypeReg),
276
  .endP2TransTypeReg(endP2TransTypeReg),
277
  .endP2NAKTransTypeReg(endP2NAKTransTypeReg),
278
  .endP3TransTypeReg(endP3TransTypeReg),
279
  .endP3NAKTransTypeReg(endP3NAKTransTypeReg),
280
  .endP0ControlReg(endP0ControlReg),
281
  .endP1ControlReg(endP1ControlReg),
282
  .endP2ControlReg(endP2ControlReg),
283
  .endP3ControlReg(endP3ControlReg),
284
  .EP0StatusReg(endP0StatusReg),
285
  .EP1StatusReg(endP1StatusReg),
286
  .EP2StatusReg(endP2StatusReg),
287
  .EP3StatusReg(endP3StatusReg),
288
  .SCAddrReg(USBTgtAddress),
289
  .frameNum(frameNum),
290
  .connectStateIn(connectStateOut),
291 5 sfielding
  .SOFRxedIn(SOFRxed),
292 2 sfielding
  .resetEventIn(resetEventFromRxStatusMon),
293
  .resumeIntIn(resumeIntFromRxStatusMon),
294
  .transDoneIn(transDone),
295
  .NAKSentIn(NAKSent),
296
  .slaveControlSelect(slaveControlSelect),
297
  .clrEP0Ready(clrEP0Rdy),
298
  .clrEP1Ready(clrEP1Rdy),
299
  .clrEP2Ready(clrEP2Rdy),
300
  .clrEP3Ready(clrEP3Rdy),
301
  .TxLineState(directLineState),
302
  .LineDirectControlEn(directLineCtrlEn),
303
  .fullSpeedPol(fullSpeedPol),
304
  .fullSpeedRate(fullSpeedRate),
305
  .SCGlobalEn(SCGlobalEn)
306
  );
307
 
308
slavecontroller u_slavecontroller
309
  (.CRCError(CRCError),
310
  .NAKSent(NAKSent),
311
  .RxByte(RxData),
312
  .RxDataWEn(RxDataValid),
313
  .RxOverflow(RXOverflow),
314
  .RxStatus(RxByteStatus),
315
  .RxTimeOut(RXTimeOut),
316
  .SCGlobalEn(SCGlobalEn),
317
  .SOFRxed(SOFRxed),
318
  .USBEndPControlReg(endPControlReg),
319
  .USBEndPNakTransTypeReg(transTypeNAK),
320
  .USBEndPTransTypeReg(transType),
321
  .USBEndP(currEndP),
322
  .USBTgtAddress(USBTgtAddress),
323
  .bitStuffError(bitStuffError),
324
  .clk(clk),
325
  .clrEPRdy(clrEPRdy),
326
  .endPMuxErrorsWEn(endPMuxErrorsWEn),
327
  .frameNum(frameNum),
328
  .getPacketREn(getPacketREn),
329
  .getPacketRdy(getPacketRdy),
330
  .rst(rst),
331
  .sendPacketPID(slaveControllerPIDOut),
332
  .sendPacketRdy(slaveControllerReadyIn),
333
  .sendPacketWEn(slaveControllerWEnOut),
334
  .stallSent(stallSent),
335
  .transDone(transDone)
336
    );
337
 
338
 
339
endpMux u_endpMux (
340
  .clk(clk),
341
  .rst(rst),
342
  .currEndP(currEndP),
343
  .NAKSent(NAKSent),
344
  .stallSent(stallSent),
345
  .CRCError(CRCError),
346
  .bitStuffError(bitStuffError),
347
  .RxOverflow(RXOverflow),
348
  .RxTimeOut(RXTimeOut),
349
  .dataSequence(dataSequence),
350
  .ACKRxed(ACKRxed),
351
  .transType(transType),
352
  .transTypeNAK(transTypeNAK),
353
  .endPControlReg(endPControlReg),
354
  .clrEPRdy(clrEPRdy),
355
  .endPMuxErrorsWEn(endPMuxErrorsWEn),
356
  .endP0ControlReg(endP0ControlReg),
357
  .endP1ControlReg(endP1ControlReg),
358
  .endP2ControlReg(endP2ControlReg),
359
  .endP3ControlReg(endP3ControlReg),
360
  .endP0StatusReg(endP0StatusReg),
361
  .endP1StatusReg(endP1StatusReg),
362
  .endP2StatusReg(endP2StatusReg),
363
  .endP3StatusReg(endP3StatusReg),
364
  .endP0TransTypeReg(endP0TransTypeReg),
365
  .endP1TransTypeReg(endP1TransTypeReg),
366
  .endP2TransTypeReg(endP2TransTypeReg),
367
  .endP3TransTypeReg(endP3TransTypeReg),
368
  .endP0NAKTransTypeReg(endP0NAKTransTypeReg),
369
  .endP1NAKTransTypeReg(endP1NAKTransTypeReg),
370
  .endP2NAKTransTypeReg(endP2NAKTransTypeReg),
371
  .endP3NAKTransTypeReg(endP3NAKTransTypeReg),
372
  .clrEP0Rdy(clrEP0Rdy),
373
  .clrEP1Rdy(clrEP1Rdy),
374
  .clrEP2Rdy(clrEP2Rdy),
375
  .clrEP3Rdy(clrEP3Rdy)
376
    );
377
 
378
slaveSendPacket u_slaveSendPacket
379
  (.PID(slaveControllerPIDOut),
380 5 sfielding
  .SCTxPortCntl(sendPacketCntl),
381
  .SCTxPortData(sendPacketData),
382
  .SCTxPortGnt(sendPacketGnt),
383
  .SCTxPortRdy(SCTxPortArbRdyOut),
384
  .SCTxPortReq(sendPacketReq),
385
  .SCTxPortWEn(sendPacketWEn),
386
  .clk(clk),
387
  .fifoData(TxFifoData),
388
  .fifoEmpty(TxFifoEmpty),
389
  .fifoReadEn(TxFifoRE),
390
  .rst(rst),
391
  .sendPacketRdy(slaveControllerReadyIn),
392
  .sendPacketWEn(slaveControllerWEnOut) );
393 2 sfielding
 
394
slaveDirectControl u_slaveDirectControl
395 5 sfielding
  (.SCTxPortCntl(directCntlCntl),
396
  .SCTxPortData(directCntlData),
397
  .SCTxPortGnt(directCntlGnt),
398
  .SCTxPortRdy(SCTxPortArbRdyOut),
399
  .SCTxPortReq(directCntlReq),
400
  .SCTxPortWEn(directCntlWEn),
401
  .clk(clk),
402
  .directControlEn(directLineCtrlEn),
403
  .directControlLineState(directLineState),
404
  .rst(rst) );
405 2 sfielding
 
406
SCTxPortArbiter u_SCTxPortArbiter
407 5 sfielding
  (.SCTxPortCntl(SCTxPortCtrl),
408
  .SCTxPortData(SCTxPortData),
409
  .SCTxPortRdyIn(SCTxPortRdy),
410
  .SCTxPortRdyOut(SCTxPortArbRdyOut),
411
  .SCTxPortWEnable(SCTxPortEn),
412
  .clk(clk),
413
  .directCntlCntl(directCntlCntl),
414
  .directCntlData(directCntlData),
415
  .directCntlGnt(directCntlGnt),
416
  .directCntlReq(directCntlReq),
417
  .directCntlWEn(directCntlWEn),
418
  .rst(rst),
419
  .sendPacketCntl(sendPacketCntl),
420
  .sendPacketData(sendPacketData),
421
  .sendPacketGnt(sendPacketGnt),
422
  .sendPacketReq(sendPacketReq),
423
  .sendPacketWEn(sendPacketWEn) );
424 2 sfielding
 
425
 
426
slaveGetPacket u_slaveGetPacket
427
  (.ACKRxed(ACKRxed),
428
  .CRCError(CRCError),
429 5 sfielding
  .RXDataIn(RxData),
430
  .RXDataValid(RxDataValid),
431
  .RXFifoData(RxFifoData),
432
  .RXFifoFull(RxFifoFull),
433
  .RXFifoWEn(RxFifoWE),
434
  .RXPacketRdy(getPacketRdy),
435
  .RXStreamStatusIn(RxByteStatus),
436
  .RxPID(RxPID),
437
  .SIERxTimeOut(SIERxTimeOut),
438
  .clk(clk),
439 2 sfielding
  .RXOverflow(RXOverflow),
440
  .RXTimeOut(RXTimeOut),
441
  .bitStuffError(bitStuffError),
442
  .dataSequence(dataSequence),
443 5 sfielding
  .getPacketEn(getPacketREn),
444
  .rst(rst) );
445 2 sfielding
 
446 5 sfielding
slaveRxStatusMonitor  u_slaveRxStatusMonitor
447
  (.connectStateIn(connectStateIn),
448
  .connectStateOut(connectStateOut),
449
  .resumeDetectedIn(resumeDetectedIn),
450
  .resetEventOut(resetEventFromRxStatusMon),
451
  .resumeIntOut(resumeIntFromRxStatusMon),
452
  .clk(clk),
453
  .rst(rst)  );
454 2 sfielding
 
455
fifoMux u_fifoMux (
456
  .currEndP(currEndP),
457
  //TxFifo
458
  .TxFifoREn(TxFifoRE),
459
  .TxFifoEP0REn(TxFifoEP0REn),
460
  .TxFifoEP1REn(TxFifoEP1REn),
461
  .TxFifoEP2REn(TxFifoEP2REn),
462
  .TxFifoEP3REn(TxFifoEP3REn),
463
  .TxFifoData(TxFifoData),
464
  .TxFifoEP0Data(TxFifoEP0Data),
465
  .TxFifoEP1Data(TxFifoEP1Data),
466
  .TxFifoEP2Data(TxFifoEP2Data),
467
  .TxFifoEP3Data(TxFifoEP3Data),
468
  .TxFifoEmpty(TxFifoEmpty),
469
  .TxFifoEP0Empty(TxFifoEP0Empty),
470
  .TxFifoEP1Empty(TxFifoEP1Empty),
471
  .TxFifoEP2Empty(TxFifoEP2Empty),
472
  .TxFifoEP3Empty(TxFifoEP3Empty),
473
  //RxFifo
474
  .RxFifoWEn(RxFifoWE),
475
  .RxFifoEP0WEn(RxFifoEP0WEn),
476
  .RxFifoEP1WEn(RxFifoEP1WEn),
477
  .RxFifoEP2WEn(RxFifoEP2WEn),
478
  .RxFifoEP3WEn(RxFifoEP3WEn),
479
  .RxFifoFull(RxFifoFull),
480
  .RxFifoEP0Full(RxFifoEP0Full),
481
  .RxFifoEP1Full(RxFifoEP1Full),
482
  .RxFifoEP2Full(RxFifoEP2Full),
483
  .RxFifoEP3Full(RxFifoEP3Full)
484
    );
485
 
486
endmodule
487
 
488 5 sfielding
 
489
 
490 2 sfielding
 
491
 
492
 
493
 

powered by: WebSVN 2.1.0

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