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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [verilog/] [usbhostslave/] [usbhost_simlib.v] - Blame information for rev 449

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

Line No. Rev Author Line
1 408 julius
//////////////////////////////////////////////////////////////////////
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_simlib( // Uncapitalised name
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
assign USBFullSpeed = fullSpeedBitRateToSIE;
151
 
152
 
153
usbHostControl_simlib u_usbHostControl(
154
  .busClk(clk_i),
155
  .rstSyncToBusClk(rstSyncToBusClk),
156
  .usbClk(usbClk),
157
  .rstSyncToUsbClk(rstSyncToUsbClk),
158
  .TxFifoRE(hostTxFifoRE),
159
  .TxFifoData(hostTxFifoData),
160
  .TxFifoEmpty(hostTxFifoEmpty),
161
  .RxFifoWE(hostRxFifoWE),
162
  .RxFifoData(hostRxFifoData),
163
  .RxFifoFull(hostRxFifoFull),
164
  .RxByteStatus(RxCtrlOut),
165
  .RxData(RxDataFromSIE),
166
  .RxDataValid(RxDataOutWEn),
167
  .SIERxTimeOut(noActivityTimeOut),
168
  .SIERxTimeOutEn(noActivityTimeOutEnableFromHost),
169
  .fullSpeedRate(fullSpeedBitRateFromHost),
170
  .fullSpeedPol(fullSpeedPolarityFromHost),
171
  .HCTxPortEn(SIEPortWEnFromHost),
172
  .HCTxPortRdy(SIEPortTxRdy),
173
  .HCTxPortData(SIEPortDataInFromHost),
174
  .HCTxPortCtrl(SIEPortCtrlInFromHost),
175
  .connectStateIn(connectState),
176
  .resumeDetectedIn(resumeDetected),
177
  .busAddress(address_i[3:0]),
178
  .busDataIn(data_i),
179
  .busDataOut(dataFromHostControl),
180
  .busWriteEn(we_i),
181
  .busStrobe_i(strobe_i),
182
  .SOFSentIntOut(hostSOFSentIntOut),
183
  .connEventIntOut(hostConnEventIntOut),
184
  .resumeIntOut(hostResumeIntOut),
185
  .transDoneIntOut(hostTransDoneIntOut),
186
  .hostControlSelect(hostControlSel) );
187
 
188
 
189
wishBoneBI_simlib u_wishBoneBI (
190
  .address(address_i),
191
  .dataIn(data_i),
192
  .dataOut(data_o),
193
  .writeEn(we_i),
194
  .strobe_i(strobe_i),
195
  .ack_o(ack_o),
196
  .clk(clk_i),
197
  .rst(rstSyncToBusClk),
198
  .hostControlSel(hostControlSel),
199
  .hostRxFifoSel(hostRxFifoSel),
200
  .hostTxFifoSel(hostTxFifoSel),
201
  .slaveControlSel(),
202
  .slaveEP0RxFifoSel(),
203
  .slaveEP1RxFifoSel(),
204
  .slaveEP2RxFifoSel(),
205
  .slaveEP3RxFifoSel(),
206
  .slaveEP0TxFifoSel(),
207
  .slaveEP1TxFifoSel(),
208
  .slaveEP2TxFifoSel(),
209
  .slaveEP3TxFifoSel(),
210
  .hostSlaveMuxSel(hostSlaveMuxSel),
211
  .dataFromHostControl(dataFromHostControl),
212
  .dataFromHostRxFifo(dataFromHostRxFifo),
213
  .dataFromHostTxFifo(dataFromHostTxFifo),
214
  .dataFromSlaveControl(8'h00),
215
  .dataFromEP0RxFifo(8'h00),
216
  .dataFromEP1RxFifo(8'h00),
217
  .dataFromEP2RxFifo(8'h00),
218
  .dataFromEP3RxFifo(8'h00),
219
  .dataFromEP0TxFifo(8'h00),
220
  .dataFromEP1TxFifo(8'h00),
221
  .dataFromEP2TxFifo(8'h00),
222
  .dataFromEP3TxFifo(8'h00),
223
  .dataFromHostSlaveMux(dataFromHostSlaveMux)
224
   );
225
 
226
 
227
assign SIEPortCtrlInToSIE = SIEPortCtrlInFromHost;
228
assign SIEPortDataInToSIE = SIEPortDataInFromHost;
229
assign SIEPortWEnToSIE = SIEPortWEnFromHost;
230
assign fullSpeedPolarityToSIE = fullSpeedPolarityFromHost;
231
assign fullSpeedBitRateToSIE = fullSpeedBitRateFromHost;
232
assign noActivityTimeOutEnableToSIE = noActivityTimeOutEnableFromHost;
233
 
234
hostSlaveMuxBI_simlib u_hostSlaveMuxBI (
235
  .dataIn(data_i),
236
  .dataOut(dataFromHostSlaveMux),
237
  .address(address_i[0]),
238
  .writeEn(we_i),
239
  .strobe_i(strobe_i),
240
  .usbClk(usbClk),
241
  .busClk(clk_i),
242
  .hostMode(hostMode),
243
  .hostSlaveMuxSel(hostSlaveMuxSel),
244
  .rstFromWire(rst_i),
245
  .rstSyncToBusClkOut(rstSyncToBusClk),
246
  .rstSyncToUsbClkOut(rstSyncToUsbClk)
247
);
248
 
249
usbSerialInterfaceEngine_simlib u_usbSerialInterfaceEngine(
250
  .clk(usbClk),
251
  .rst(rstSyncToUsbClk),
252
  .USBWireDataIn(USBWireDataIn),
253
  .USBWireDataOut(USBWireDataOut),
254
  .USBWireDataInTick(USBWireDataInTick),
255
  .USBWireDataOutTick(USBWireDataOutTick),
256
  .USBWireCtrlOut(USBWireCtrlOut),
257
  .connectState(connectState),
258
  .resumeDetected(resumeDetected),
259
  .RxCtrlOut(RxCtrlOut),
260
  .RxDataOutWEn(RxDataOutWEn),
261
  .RxDataOut(RxDataFromSIE),
262
  .SIEPortCtrlIn(SIEPortCtrlInToSIE),
263
  .SIEPortDataIn(SIEPortDataInToSIE),
264
  .SIEPortTxRdy(SIEPortTxRdy),
265
  .SIEPortWEn(SIEPortWEnToSIE),
266
  .fullSpeedPolarity(fullSpeedPolarityToSIE),
267
  .fullSpeedBitRate(fullSpeedBitRateToSIE),
268
  .noActivityTimeOut(noActivityTimeOut),
269
  .noActivityTimeOutEnable(noActivityTimeOutEnableToSIE)
270
);
271
 
272
 
273
 
274
//---Host fifos
275
TxFifo_simlib #(HOST_FIFO_DEPTH, HOST_FIFO_ADDR_WIDTH) HostTxFifo (
276
  .usbClk(usbClk),
277
  .busClk(clk_i),
278
  .rstSyncToBusClk(rstSyncToBusClk),
279
  .rstSyncToUsbClk(rstSyncToUsbClk),
280
  .fifoREn(hostTxFifoRE),
281
  .fifoEmpty(hostTxFifoEmpty),
282
  .busAddress(address_i[2:0]),
283
  .busWriteEn(we_i),
284
  .busStrobe_i(strobe_i),
285
  .busFifoSelect(hostTxFifoSel),
286
  .busDataIn(data_i),
287
  .busDataOut(dataFromHostTxFifo),
288
  .fifoDataOut(hostTxFifoData) );
289
 
290
 
291
RxFifo_simlib #(HOST_FIFO_DEPTH, HOST_FIFO_ADDR_WIDTH) HostRxFifo(
292
  .usbClk(usbClk),
293
  .busClk(clk_i),
294
  .rstSyncToBusClk(rstSyncToBusClk),
295
  .rstSyncToUsbClk(rstSyncToUsbClk),
296
  .fifoWEn(hostRxFifoWE),
297
  .fifoFull(hostRxFifoFull),
298
  .busAddress(address_i[2:0]),
299
  .busWriteEn(we_i),
300
  .busStrobe_i(strobe_i),
301
  .busFifoSelect(hostRxFifoSel),
302
  .busDataIn(data_i),
303
  .busDataOut(dataFromHostRxFifo),
304
  .fifoDataIn(hostRxFifoData)  );
305
 
306
 
307
endmodule
308
 
309
 
310
 
311
 
312
 
313
 
314
 

powered by: WebSVN 2.1.0

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