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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [wrapper/] [usbHost.v] - Blame information for rev 43

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 43 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// usbHost.v                                                    ////
4
////                                                              ////
5
//// This file is part of the usbhostslave opencores effort.
6
//// <http://www.opencores.org/cores//>                           ////
7
////                                                              ////
8
//// Module Description:                                          ////
9
////   Top level module
10
////                                                              ////
11
//// To Do:                                                       ////
12
//// 
13
////                                                              ////
14
//// Author(s):                                                   ////
15
//// - Steve Fielding, sfielding@base2designs.com                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2008 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
`include "timescale.v"
45
 
46
module usbHost(
47
  clk_i,
48
  rst_i,
49
  address_i,
50
  data_i,
51
  data_o,
52
  we_i,
53
  strobe_i,
54
  ack_o,
55
  usbClk,
56
  hostSOFSentIntOut,
57
  hostConnEventIntOut,
58
  hostResumeIntOut,
59
  hostTransDoneIntOut,
60
  USBWireDataIn,
61
  USBWireDataInTick,
62
  USBWireDataOut,
63
  USBWireDataOutTick,
64
  USBWireCtrlOut,
65
  USBFullSpeed
66
   );
67
  parameter HOST_FIFO_DEPTH = 64; //HOST_FIFO_DEPTH = 2^HOST_ADDR_WIDTH
68
  parameter HOST_FIFO_ADDR_WIDTH = 6;
69
 
70
 
71
input clk_i;               //Wishbone bus clock. Maximum 5*usbClk=240MHz
72
input rst_i;               //Wishbone bus sync reset. Synchronous to 'clk_i'. Resets all logic
73
input [7:0] address_i;     //Wishbone bus address in
74
input [7:0] data_i;        //Wishbone bus data in
75
output [7:0] data_o;       //Wishbone bus data out
76
input we_i;                //Wishbone bus write enable in
77
input strobe_i;            //Wishbone bus strobe in
78
output ack_o;              //Wishbone bus acknowledge out
79
input usbClk;              //usb clock. 48Mhz +/-0.25%
80
output hostSOFSentIntOut;
81
output hostConnEventIntOut;
82
output hostResumeIntOut;
83
output hostTransDoneIntOut;
84
input [1:0] USBWireDataIn;
85
output [1:0] USBWireDataOut;
86
output USBWireDataOutTick;
87
output USBWireDataInTick;
88
output USBWireCtrlOut;
89
output USBFullSpeed;
90
 
91
wire clk_i;
92
wire rst_i;
93
wire [7:0] address_i;
94
wire [7:0] data_i;
95
wire [7:0] data_o;
96
wire we_i;
97
wire strobe_i;
98
wire ack_o;
99
wire usbClk;
100
wire hostSOFSentIntOut;
101
wire hostConnEventIntOut;
102
wire hostResumeIntOut;
103
wire hostTransDoneIntOut;
104
wire [1:0] USBWireDataIn;
105
wire [1:0] USBWireDataOut;
106
wire USBWireDataOutTick;
107
wire USBWireDataInTick;
108
wire USBWireCtrlOut;
109
wire USBFullSpeed;
110
 
111
//internal wiring
112
wire hostControlSel;
113
wire slaveControlSel;
114
wire hostRxFifoSel;
115
wire hostTxFifoSel;
116
wire hostSlaveMuxSel;
117
wire [7:0] dataFromHostControl;
118
wire [7:0] dataFromSlaveControl;
119
wire [7:0] dataFromHostRxFifo;
120
wire [7:0] dataFromHostTxFifo;
121
wire [7:0] dataFromHostSlaveMux;
122
wire hostTxFifoRE;
123
wire [7:0] hostTxFifoData;
124
wire hostTxFifoEmpty;
125
wire hostRxFifoWE;
126
wire [7:0] hostRxFifoData;
127
wire hostRxFifoFull;
128
wire [7:0] RxCtrlOut;
129
wire [7:0] RxDataFromSIE;
130
wire RxDataOutWEn;
131
wire fullSpeedBitRateFromHost;
132
wire fullSpeedPolarityFromHost;
133
wire SIEPortWEnFromHost;
134
wire SIEPortTxRdy;
135
wire [7:0] SIEPortDataInFromHost;
136
wire [7:0] SIEPortCtrlInFromHost;
137
wire [1:0] connectState;
138
wire resumeDetected;
139
wire [7:0] SIEPortDataInToSIE;
140
wire SIEPortWEnToSIE;
141
wire [7:0] SIEPortCtrlInToSIE;
142
wire fullSpeedPolarityToSIE;
143
wire fullSpeedBitRateToSIE;
144
wire noActivityTimeOut;
145
wire rstSyncToBusClk;
146
wire rstSyncToUsbClk;
147
wire noActivityTimeOutEnableToSIE;
148
wire noActivityTimeOutEnableFromHost;
149
 
150
// This is not a bug.
151
// USBFullSpeed controls the PHY edge speed.
152
// The only time that the PHY needs to operate with low speed edge rate is
153
// when the host is directly connected to a low speed device. And when this is true, fullSpeedPolarity
154
// will be low. When the host is connected to a low speed device via a hub, then speed can be full or low
155
// but according to spec edge speed must be full rate edge speed. 
156
assign USBFullSpeed = fullSpeedPolarityToSIE;
157
//assign USBFullSpeed = fullSpeedBitRateToSIE;
158
 
159
usbHostControl u_usbHostControl(
160
  .busClk(clk_i),
161
  .rstSyncToBusClk(rstSyncToBusClk),
162
  .usbClk(usbClk),
163
  .rstSyncToUsbClk(rstSyncToUsbClk),
164
  .TxFifoRE(hostTxFifoRE),
165
  .TxFifoData(hostTxFifoData),
166
  .TxFifoEmpty(hostTxFifoEmpty),
167
  .RxFifoWE(hostRxFifoWE),
168
  .RxFifoData(hostRxFifoData),
169
  .RxFifoFull(hostRxFifoFull),
170
  .RxByteStatus(RxCtrlOut),
171
  .RxData(RxDataFromSIE),
172
  .RxDataValid(RxDataOutWEn),
173
  .SIERxTimeOut(noActivityTimeOut),
174
  .SIERxTimeOutEn(noActivityTimeOutEnableFromHost),
175
  .fullSpeedRate(fullSpeedBitRateFromHost),
176
  .fullSpeedPol(fullSpeedPolarityFromHost),
177
  .HCTxPortEn(SIEPortWEnFromHost),
178
  .HCTxPortRdy(SIEPortTxRdy),
179
  .HCTxPortData(SIEPortDataInFromHost),
180
  .HCTxPortCtrl(SIEPortCtrlInFromHost),
181
  .connectStateIn(connectState),
182
  .resumeDetectedIn(resumeDetected),
183
  .busAddress(address_i[3:0]),
184
  .busDataIn(data_i),
185
  .busDataOut(dataFromHostControl),
186
  .busWriteEn(we_i),
187
  .busStrobe_i(strobe_i),
188
  .SOFSentIntOut(hostSOFSentIntOut),
189
  .connEventIntOut(hostConnEventIntOut),
190
  .resumeIntOut(hostResumeIntOut),
191
  .transDoneIntOut(hostTransDoneIntOut),
192
  .hostControlSelect(hostControlSel) );
193
 
194
 
195
wishBoneBI u_wishBoneBI (
196
  .address(address_i),
197
  .dataIn(data_i),
198
  .dataOut(data_o),
199
  .writeEn(we_i),
200
  .strobe_i(strobe_i),
201
  .ack_o(ack_o),
202
  .clk(clk_i),
203
  .rst(rstSyncToBusClk),
204
  .hostControlSel(hostControlSel),
205
  .hostRxFifoSel(hostRxFifoSel),
206
  .hostTxFifoSel(hostTxFifoSel),
207
  .slaveControlSel(),
208
  .slaveEP0RxFifoSel(),
209
  .slaveEP1RxFifoSel(),
210
  .slaveEP2RxFifoSel(),
211
  .slaveEP3RxFifoSel(),
212
  .slaveEP0TxFifoSel(),
213
  .slaveEP1TxFifoSel(),
214
  .slaveEP2TxFifoSel(),
215
  .slaveEP3TxFifoSel(),
216
  .hostSlaveMuxSel(hostSlaveMuxSel),
217
  .dataFromHostControl(dataFromHostControl),
218
  .dataFromHostRxFifo(dataFromHostRxFifo),
219
  .dataFromHostTxFifo(dataFromHostTxFifo),
220
  .dataFromSlaveControl(8'h00),
221
  .dataFromEP0RxFifo(8'h00),
222
  .dataFromEP1RxFifo(8'h00),
223
  .dataFromEP2RxFifo(8'h00),
224
  .dataFromEP3RxFifo(8'h00),
225
  .dataFromEP0TxFifo(8'h00),
226
  .dataFromEP1TxFifo(8'h00),
227
  .dataFromEP2TxFifo(8'h00),
228
  .dataFromEP3TxFifo(8'h00),
229
  .dataFromHostSlaveMux(dataFromHostSlaveMux)
230
   );
231
 
232
 
233
assign SIEPortCtrlInToSIE = SIEPortCtrlInFromHost;
234
assign SIEPortDataInToSIE = SIEPortDataInFromHost;
235
assign SIEPortWEnToSIE = SIEPortWEnFromHost;
236
assign fullSpeedPolarityToSIE = fullSpeedPolarityFromHost;
237
assign fullSpeedBitRateToSIE = fullSpeedBitRateFromHost;
238
assign noActivityTimeOutEnableToSIE = noActivityTimeOutEnableFromHost;
239
 
240
hostSlaveMuxBI u_hostSlaveMuxBI (
241
  .dataIn(data_i),
242
  .dataOut(dataFromHostSlaveMux),
243
  .address(address_i[0]),
244
  .writeEn(we_i),
245
  .strobe_i(strobe_i),
246
  .usbClk(usbClk),
247
  .busClk(clk_i),
248
  .hostMode(hostMode),
249
  .hostSlaveMuxSel(hostSlaveMuxSel),
250
  .rstFromWire(rst_i),
251
  .rstSyncToBusClkOut(rstSyncToBusClk),
252
  .rstSyncToUsbClkOut(rstSyncToUsbClk)
253
);
254
 
255
usbSerialInterfaceEngine u_usbSerialInterfaceEngine(
256
  .clk(usbClk),
257
  .rst(rstSyncToUsbClk),
258
  .USBWireDataIn(USBWireDataIn),
259
  .USBWireDataOut(USBWireDataOut),
260
  .USBWireDataInTick(USBWireDataInTick),
261
  .USBWireDataOutTick(USBWireDataOutTick),
262
  .USBWireCtrlOut(USBWireCtrlOut),
263
  .connectState(connectState),
264
  .resumeDetected(resumeDetected),
265
  .RxCtrlOut(RxCtrlOut),
266
  .RxDataOutWEn(RxDataOutWEn),
267
  .RxDataOut(RxDataFromSIE),
268
  .SIEPortCtrlIn(SIEPortCtrlInToSIE),
269
  .SIEPortDataIn(SIEPortDataInToSIE),
270
  .SIEPortTxRdy(SIEPortTxRdy),
271
  .SIEPortWEn(SIEPortWEnToSIE),
272
  .fullSpeedPolarity(fullSpeedPolarityToSIE),
273
  .fullSpeedBitRate(fullSpeedBitRateToSIE),
274
  .noActivityTimeOut(noActivityTimeOut),
275
  .noActivityTimeOutEnable(noActivityTimeOutEnableToSIE)
276
);
277
 
278
 
279
 
280
//---Host fifos
281
TxFifo #(HOST_FIFO_DEPTH, HOST_FIFO_ADDR_WIDTH) HostTxFifo (
282
  .usbClk(usbClk),
283
  .busClk(clk_i),
284
  .rstSyncToBusClk(rstSyncToBusClk),
285
  .rstSyncToUsbClk(rstSyncToUsbClk),
286
  .fifoREn(hostTxFifoRE),
287
  .fifoEmpty(hostTxFifoEmpty),
288
  .busAddress(address_i[2:0]),
289
  .busWriteEn(we_i),
290
  .busStrobe_i(strobe_i),
291
  .busFifoSelect(hostTxFifoSel),
292
  .busDataIn(data_i),
293
  .busDataOut(dataFromHostTxFifo),
294
  .fifoDataOut(hostTxFifoData) );
295
 
296
 
297
RxFifo #(HOST_FIFO_DEPTH, HOST_FIFO_ADDR_WIDTH) HostRxFifo(
298
  .usbClk(usbClk),
299
  .busClk(clk_i),
300
  .rstSyncToBusClk(rstSyncToBusClk),
301
  .rstSyncToUsbClk(rstSyncToUsbClk),
302
  .fifoWEn(hostRxFifoWE),
303
  .fifoFull(hostRxFifoFull),
304
  .busAddress(address_i[2:0]),
305
  .busWriteEn(we_i),
306
  .busStrobe_i(strobe_i),
307
  .busFifoSelect(hostRxFifoSel),
308
  .busDataIn(data_i),
309
  .busDataOut(dataFromHostRxFifo),
310
  .fifoDataIn(hostRxFifoData)  );
311
 
312
 
313
endmodule
314
 
315
 
316
 
317
 
318
 
319
 
320
 

powered by: WebSVN 2.1.0

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