1 |
408 |
julius |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// usbHostControl.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 |
|
|
`include "timescale.v"
|
45 |
|
|
|
46 |
|
|
module usbHostControl_simlib(
|
47 |
|
|
busClk, rstSyncToBusClk,
|
48 |
|
|
usbClk, rstSyncToUsbClk,
|
49 |
|
|
//sendPacket
|
50 |
|
|
TxFifoRE, TxFifoData, TxFifoEmpty,
|
51 |
|
|
//getPacket
|
52 |
|
|
RxFifoWE, RxFifoData, RxFifoFull,
|
53 |
|
|
RxByteStatus, RxData, RxDataValid,
|
54 |
|
|
SIERxTimeOut, SIERxTimeOutEn,
|
55 |
|
|
//speedCtrlMux
|
56 |
|
|
fullSpeedRate, fullSpeedPol,
|
57 |
|
|
//HCTxPortArbiter
|
58 |
|
|
HCTxPortEn, HCTxPortRdy,
|
59 |
|
|
HCTxPortData, HCTxPortCtrl,
|
60 |
|
|
//rxStatusMonitor
|
61 |
|
|
connectStateIn,
|
62 |
|
|
resumeDetectedIn,
|
63 |
|
|
//USBHostControlBI
|
64 |
|
|
busAddress,
|
65 |
|
|
busDataIn,
|
66 |
|
|
busDataOut,
|
67 |
|
|
busWriteEn,
|
68 |
|
|
busStrobe_i,
|
69 |
|
|
SOFSentIntOut,
|
70 |
|
|
connEventIntOut,
|
71 |
|
|
resumeIntOut,
|
72 |
|
|
transDoneIntOut,
|
73 |
|
|
hostControlSelect
|
74 |
|
|
);
|
75 |
|
|
|
76 |
|
|
input busClk;
|
77 |
|
|
input rstSyncToBusClk;
|
78 |
|
|
input usbClk;
|
79 |
|
|
input rstSyncToUsbClk;
|
80 |
|
|
//sendPacket
|
81 |
|
|
output TxFifoRE;
|
82 |
|
|
input [7:0] TxFifoData;
|
83 |
|
|
input TxFifoEmpty;
|
84 |
|
|
//getPacket
|
85 |
|
|
output RxFifoWE;
|
86 |
|
|
output [7:0] RxFifoData;
|
87 |
|
|
input RxFifoFull;
|
88 |
|
|
input [7:0] RxByteStatus;
|
89 |
|
|
input [7:0] RxData;
|
90 |
|
|
input RxDataValid;
|
91 |
|
|
input SIERxTimeOut;
|
92 |
|
|
output SIERxTimeOutEn;
|
93 |
|
|
//speedCtrlMux
|
94 |
|
|
output fullSpeedRate;
|
95 |
|
|
output fullSpeedPol;
|
96 |
|
|
//HCTxPortArbiter
|
97 |
|
|
output HCTxPortEn;
|
98 |
|
|
input HCTxPortRdy;
|
99 |
|
|
output [7:0] HCTxPortData;
|
100 |
|
|
output [7:0] HCTxPortCtrl;
|
101 |
|
|
//rxStatusMonitor
|
102 |
|
|
input [1:0] connectStateIn;
|
103 |
|
|
input resumeDetectedIn;
|
104 |
|
|
//USBHostControlBI
|
105 |
|
|
input [3:0] busAddress;
|
106 |
|
|
input [7:0] busDataIn;
|
107 |
|
|
output [7:0] busDataOut;
|
108 |
|
|
input busWriteEn;
|
109 |
|
|
input busStrobe_i;
|
110 |
|
|
output SOFSentIntOut;
|
111 |
|
|
output connEventIntOut;
|
112 |
|
|
output resumeIntOut;
|
113 |
|
|
output transDoneIntOut;
|
114 |
|
|
input hostControlSelect;
|
115 |
|
|
|
116 |
|
|
wire busClk;
|
117 |
|
|
wire rstSyncToBusClk;
|
118 |
|
|
wire usbClk;
|
119 |
|
|
wire rstSyncToUsbClk;
|
120 |
|
|
wire [10:0] frameNum;
|
121 |
|
|
wire SOFSent;
|
122 |
|
|
wire TxFifoRE;
|
123 |
|
|
wire [7:0] TxFifoData;
|
124 |
|
|
wire TxFifoEmpty;
|
125 |
|
|
wire RxFifoWE;
|
126 |
|
|
wire [7:0] RxFifoData;
|
127 |
|
|
wire RxFifoFull;
|
128 |
|
|
wire [7:0] RxByteStatus;
|
129 |
|
|
wire [7:0] RxData;
|
130 |
|
|
wire RxDataValid;
|
131 |
|
|
wire SIERxTimeOut;
|
132 |
|
|
wire SIERxTimeOutEn;
|
133 |
|
|
wire fullSpeedRate;
|
134 |
|
|
wire fullSpeedPol;
|
135 |
|
|
wire HCTxPortEn;
|
136 |
|
|
wire HCTxPortRdy;
|
137 |
|
|
wire [7:0] HCTxPortData;
|
138 |
|
|
wire [7:0] HCTxPortCtrl;
|
139 |
|
|
wire [1:0] connectStateIn;
|
140 |
|
|
wire resumeDetectedIn;
|
141 |
|
|
wire [3:0] busAddress;
|
142 |
|
|
wire [7:0] busDataIn;
|
143 |
|
|
wire [7:0] busDataOut;
|
144 |
|
|
wire busWriteEn;
|
145 |
|
|
wire busStrobe_i;
|
146 |
|
|
wire SOFSentIntOut;
|
147 |
|
|
wire connEventIntOut;
|
148 |
|
|
wire resumeIntOut;
|
149 |
|
|
wire transDoneIntOut;
|
150 |
|
|
wire hostControlSelect;
|
151 |
|
|
|
152 |
|
|
//internal wiring
|
153 |
|
|
wire SOFTimerClr;
|
154 |
|
|
wire getPacketREn;
|
155 |
|
|
wire getPacketRdy;
|
156 |
|
|
wire HCTxGnt;
|
157 |
|
|
wire HCTxReq;
|
158 |
|
|
wire [3:0] HC_PID;
|
159 |
|
|
wire HC_SP_WEn;
|
160 |
|
|
wire SOFTxGnt;
|
161 |
|
|
wire SOFTxReq;
|
162 |
|
|
wire SOF_SP_WEn;
|
163 |
|
|
wire SOFEnable;
|
164 |
|
|
wire SOFSyncEn;
|
165 |
|
|
wire sendPacketCPReadyIn;
|
166 |
|
|
wire sendPacketCPReadyOut;
|
167 |
|
|
wire [3:0] sendPacketCPPIDIn;
|
168 |
|
|
wire [3:0] sendPacketCPPIDOut;
|
169 |
|
|
wire sendPacketCPWEnIn;
|
170 |
|
|
wire sendPacketCPWEnOut;
|
171 |
|
|
wire [7:0] SOFCntlCntl;
|
172 |
|
|
wire [7:0] SOFCntlData;
|
173 |
|
|
wire SOFCntlGnt;
|
174 |
|
|
wire SOFCntlReq;
|
175 |
|
|
wire SOFCntlWEn;
|
176 |
|
|
wire [7:0] directCntlCntl;
|
177 |
|
|
wire [7:0] directCntlData;
|
178 |
|
|
wire directCntlGnt;
|
179 |
|
|
wire directCntlReq;
|
180 |
|
|
wire directCntlWEn;
|
181 |
|
|
wire [7:0] sendPacketCntl;
|
182 |
|
|
wire [7:0] sendPacketData;
|
183 |
|
|
wire sendPacketGnt;
|
184 |
|
|
wire sendPacketReq;
|
185 |
|
|
wire sendPacketWEn;
|
186 |
|
|
wire [15:0] SOFTimer;
|
187 |
|
|
wire clrTxReq;
|
188 |
|
|
wire transDone;
|
189 |
|
|
wire transReq;
|
190 |
|
|
wire isoEn;
|
191 |
|
|
wire [1:0] transType;
|
192 |
|
|
wire preAmbleEnable;
|
193 |
|
|
wire [1:0] directLineState;
|
194 |
|
|
wire directLineCtrlEn;
|
195 |
|
|
wire [6:0] TxAddr;
|
196 |
|
|
wire [3:0] TxEndP;
|
197 |
|
|
wire [7:0] RxPktStatus;
|
198 |
|
|
wire [3:0] RxPID;
|
199 |
|
|
wire [1:0] connectStateOut;
|
200 |
|
|
wire resumeIntFromRxStatusMon;
|
201 |
|
|
wire connectionEventFromRxStatusMon;
|
202 |
|
|
|
203 |
|
|
USBHostControlBI_simlib u_USBHostControlBI
|
204 |
|
|
(.address(busAddress),
|
205 |
|
|
.dataIn(busDataIn),
|
206 |
|
|
.dataOut(busDataOut),
|
207 |
|
|
.writeEn(busWriteEn),
|
208 |
|
|
.strobe_i(busStrobe_i),
|
209 |
|
|
.busClk(busClk),
|
210 |
|
|
.rstSyncToBusClk(rstSyncToBusClk),
|
211 |
|
|
.usbClk(usbClk),
|
212 |
|
|
.rstSyncToUsbClk(rstSyncToUsbClk),
|
213 |
|
|
.SOFSentIntOut(SOFSentIntOut),
|
214 |
|
|
.connEventIntOut(connEventIntOut),
|
215 |
|
|
.resumeIntOut(resumeIntOut),
|
216 |
|
|
.transDoneIntOut(transDoneIntOut),
|
217 |
|
|
.TxTransTypeReg(transType),
|
218 |
|
|
.TxSOFEnableReg(SOFEnable),
|
219 |
|
|
.TxAddrReg(TxAddr),
|
220 |
|
|
.TxEndPReg(TxEndP),
|
221 |
|
|
.frameNumIn(frameNum),
|
222 |
|
|
.RxPktStatusIn(RxPktStatus),
|
223 |
|
|
.RxPIDIn(RxPID),
|
224 |
|
|
.connectStateIn(connectStateOut),
|
225 |
|
|
.SOFSentIn(SOFSent),
|
226 |
|
|
.connEventIn(connectionEventFromRxStatusMon),
|
227 |
|
|
.resumeIntIn(resumeIntFromRxStatusMon),
|
228 |
|
|
.transDoneIn(transDone),
|
229 |
|
|
.hostControlSelect(hostControlSelect),
|
230 |
|
|
.clrTransReq(clrTxReq),
|
231 |
|
|
.preambleEn(preAmbleEnable),
|
232 |
|
|
.SOFSync(SOFSyncEn),
|
233 |
|
|
.TxLineState(directLineState),
|
234 |
|
|
.LineDirectControlEn(directLineCtrlEn),
|
235 |
|
|
.fullSpeedPol(fullSpeedPol),
|
236 |
|
|
.fullSpeedRate(fullSpeedRate),
|
237 |
|
|
.transReq(transReq),
|
238 |
|
|
.isoEn(isoEn),
|
239 |
|
|
.SOFTimer(SOFTimer)
|
240 |
|
|
);
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
hostcontroller_simlib u_hostController
|
244 |
|
|
(.RXStatus(RxPktStatus),
|
245 |
|
|
.clearTXReq(clrTxReq),
|
246 |
|
|
.clk(usbClk),
|
247 |
|
|
.getPacketREn(getPacketREn),
|
248 |
|
|
.getPacketRdy(getPacketRdy),
|
249 |
|
|
.rst(rstSyncToUsbClk),
|
250 |
|
|
.sendPacketArbiterGnt(HCTxGnt),
|
251 |
|
|
.sendPacketArbiterReq(HCTxReq),
|
252 |
|
|
.sendPacketPID(HC_PID),
|
253 |
|
|
.sendPacketRdy(sendPacketCPReadyOut),
|
254 |
|
|
.sendPacketWEn(HC_SP_WEn),
|
255 |
|
|
.transDone(transDone),
|
256 |
|
|
.transReq(transReq),
|
257 |
|
|
.transType(transType),
|
258 |
|
|
.isoEn(isoEn) );
|
259 |
|
|
|
260 |
|
|
SOFController_simlib u_SOFController
|
261 |
|
|
(.HCTxPortCntl(SOFCntlCntl),
|
262 |
|
|
.HCTxPortData(SOFCntlData),
|
263 |
|
|
.HCTxPortGnt(SOFCntlGnt),
|
264 |
|
|
.HCTxPortRdy(HCTxPortRdy),
|
265 |
|
|
.HCTxPortReq(SOFCntlReq),
|
266 |
|
|
.HCTxPortWEn(SOFCntlWEn),
|
267 |
|
|
.SOFEnable(SOFEnable),
|
268 |
|
|
.SOFTimerClr(SOFTimerClr),
|
269 |
|
|
.SOFTimer(SOFTimer),
|
270 |
|
|
.clk(usbClk),
|
271 |
|
|
.rst(rstSyncToUsbClk) );
|
272 |
|
|
|
273 |
|
|
SOFTransmit_simlib u_SOFTransmit
|
274 |
|
|
(.SOFEnable(SOFEnable),
|
275 |
|
|
.SOFSent(SOFSent),
|
276 |
|
|
.SOFSyncEn(SOFSyncEn),
|
277 |
|
|
.SOFTimerClr(SOFTimerClr),
|
278 |
|
|
.SOFTimer(SOFTimer),
|
279 |
|
|
.clk(usbClk),
|
280 |
|
|
.rst(rstSyncToUsbClk),
|
281 |
|
|
.sendPacketArbiterGnt(SOFTxGnt),
|
282 |
|
|
.sendPacketArbiterReq(SOFTxReq),
|
283 |
|
|
.sendPacketRdy(sendPacketCPReadyOut),
|
284 |
|
|
.sendPacketWEn(SOF_SP_WEn) );
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
sendPacketArbiter_simlib u_sendPacketArbiter
|
288 |
|
|
(.HCTxGnt(HCTxGnt),
|
289 |
|
|
.HCTxReq(HCTxReq),
|
290 |
|
|
.HC_PID(HC_PID),
|
291 |
|
|
.HC_SP_WEn(HC_SP_WEn),
|
292 |
|
|
.SOFTxGnt(SOFTxGnt),
|
293 |
|
|
.SOFTxReq(SOFTxReq),
|
294 |
|
|
.SOF_SP_WEn(SOF_SP_WEn),
|
295 |
|
|
.clk(usbClk),
|
296 |
|
|
.rst(rstSyncToUsbClk),
|
297 |
|
|
.sendPacketPID(sendPacketCPPIDIn),
|
298 |
|
|
.sendPacketWEnable(sendPacketCPWEnIn) );
|
299 |
|
|
|
300 |
|
|
sendPacketCheckPreamble_simlib u_sendPacketCheckPreamble
|
301 |
|
|
(.sendPacketCPPID(sendPacketCPPIDIn),
|
302 |
|
|
.clk(usbClk),
|
303 |
|
|
.preAmbleEnable(preAmbleEnable),
|
304 |
|
|
.rst(rstSyncToUsbClk),
|
305 |
|
|
.sendPacketCPReady(sendPacketCPReadyOut),
|
306 |
|
|
.sendPacketCPWEn(sendPacketCPWEnIn),
|
307 |
|
|
.sendPacketPID(sendPacketCPPIDOut),
|
308 |
|
|
.sendPacketRdy(sendPacketCPReadyIn),
|
309 |
|
|
.sendPacketWEn(sendPacketCPWEnOut) );
|
310 |
|
|
|
311 |
|
|
sendPacket_simlib u_sendPacket
|
312 |
|
|
(.HCTxPortCntl(sendPacketCntl),
|
313 |
|
|
.HCTxPortData(sendPacketData),
|
314 |
|
|
.HCTxPortGnt(sendPacketGnt),
|
315 |
|
|
.HCTxPortRdy(HCTxPortRdy),
|
316 |
|
|
.HCTxPortReq(sendPacketReq),
|
317 |
|
|
.HCTxPortWEn(sendPacketWEn),
|
318 |
|
|
.PID(sendPacketCPPIDOut),
|
319 |
|
|
.TxAddr(TxAddr),
|
320 |
|
|
.TxEndP(TxEndP),
|
321 |
|
|
.clk(usbClk),
|
322 |
|
|
.fifoData(TxFifoData),
|
323 |
|
|
.fifoEmpty(TxFifoEmpty),
|
324 |
|
|
.fifoReadEn(TxFifoRE),
|
325 |
|
|
.frameNum(frameNum),
|
326 |
|
|
.rst(rstSyncToUsbClk),
|
327 |
|
|
.sendPacketRdy(sendPacketCPReadyIn),
|
328 |
|
|
.sendPacketWEn(sendPacketCPWEnOut),
|
329 |
|
|
.fullSpeedPolarity(fullSpeedPol) );
|
330 |
|
|
|
331 |
|
|
directControl_simlib u_directControl
|
332 |
|
|
(.HCTxPortCntl(directCntlCntl),
|
333 |
|
|
.HCTxPortData(directCntlData),
|
334 |
|
|
.HCTxPortGnt(directCntlGnt),
|
335 |
|
|
.HCTxPortRdy(HCTxPortRdy),
|
336 |
|
|
.HCTxPortReq(directCntlReq),
|
337 |
|
|
.HCTxPortWEn(directCntlWEn),
|
338 |
|
|
.clk(usbClk),
|
339 |
|
|
.directControlEn(directLineCtrlEn),
|
340 |
|
|
.directControlLineState(directLineState),
|
341 |
|
|
.rst(rstSyncToUsbClk) );
|
342 |
|
|
|
343 |
|
|
HCTxPortArbiter_simlib u_HCTxPortArbiter
|
344 |
|
|
(.HCTxPortCntl(HCTxPortCtrl),
|
345 |
|
|
.HCTxPortData(HCTxPortData),
|
346 |
|
|
.HCTxPortWEnable(HCTxPortEn),
|
347 |
|
|
.SOFCntlCntl(SOFCntlCntl),
|
348 |
|
|
.SOFCntlData(SOFCntlData),
|
349 |
|
|
.SOFCntlGnt(SOFCntlGnt),
|
350 |
|
|
.SOFCntlReq(SOFCntlReq),
|
351 |
|
|
.SOFCntlWEn(SOFCntlWEn),
|
352 |
|
|
.clk(usbClk),
|
353 |
|
|
.directCntlCntl(directCntlCntl),
|
354 |
|
|
.directCntlData(directCntlData),
|
355 |
|
|
.directCntlGnt(directCntlGnt),
|
356 |
|
|
.directCntlReq(directCntlReq),
|
357 |
|
|
.directCntlWEn(directCntlWEn),
|
358 |
|
|
.rst(rstSyncToUsbClk),
|
359 |
|
|
.sendPacketCntl(sendPacketCntl),
|
360 |
|
|
.sendPacketData(sendPacketData),
|
361 |
|
|
.sendPacketGnt(sendPacketGnt),
|
362 |
|
|
.sendPacketReq(sendPacketReq),
|
363 |
|
|
.sendPacketWEn(sendPacketWEn) );
|
364 |
|
|
|
365 |
|
|
getPacket_simlib u_getPacket
|
366 |
|
|
(.RXDataIn(RxData),
|
367 |
|
|
.RXDataValid(RxDataValid),
|
368 |
|
|
.RXFifoData(RxFifoData),
|
369 |
|
|
.RXFifoFull(RxFifoFull),
|
370 |
|
|
.RXFifoWEn(RxFifoWE),
|
371 |
|
|
.RXPacketRdy(getPacketRdy),
|
372 |
|
|
.RXPktStatus(RxPktStatus),
|
373 |
|
|
.RXStreamStatusIn(RxByteStatus),
|
374 |
|
|
.RxPID(RxPID),
|
375 |
|
|
.SIERxTimeOut(SIERxTimeOut),
|
376 |
|
|
.SIERxTimeOutEn(SIERxTimeOutEn),
|
377 |
|
|
.clk(usbClk),
|
378 |
|
|
.getPacketEn(getPacketREn),
|
379 |
|
|
.rst(rstSyncToUsbClk) );
|
380 |
|
|
|
381 |
|
|
rxStatusMonitor_simlib u_rxStatusMonitor
|
382 |
|
|
(.connectStateIn(connectStateIn),
|
383 |
|
|
.connectStateOut(connectStateOut),
|
384 |
|
|
.resumeDetectedIn(resumeDetectedIn),
|
385 |
|
|
.connectionEventOut(connectionEventFromRxStatusMon),
|
386 |
|
|
.resumeIntOut(resumeIntFromRxStatusMon),
|
387 |
|
|
.clk(usbClk),
|
388 |
|
|
.rst(rstSyncToUsbClk) );
|
389 |
|
|
|
390 |
|
|
endmodule
|
391 |
|
|
|
392 |
|
|
|
393 |
|
|
|
394 |
|
|
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
|