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

Subversion Repositories usbhostslave

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

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

Line No. Rev Author Line
1 37 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// usbDevice.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 for usbDevice
10
//// Instantiates a usbSlave, and controllers for EP0 and EP1
11
//// If you wish to implement another type of HID, then you will
12
//// need to modify usbROM.v, and EP1Mouse.v
13
////                                                              ////
14
//// To Do:                                                       ////
15
//// 
16
////                                                              ////
17
//// Author(s):                                                   ////
18
//// - Steve Fielding, sfielding@base2designs.com                 ////
19
////                                                              ////
20
//////////////////////////////////////////////////////////////////////
21
////                                                              ////
22
//// Copyright (C) 2008 Steve Fielding and OPENCORES.ORG          ////
23
////                                                              ////
24
//// This source file may be used and distributed without         ////
25
//// restriction provided that this copyright statement is not    ////
26
//// removed from the file and that any derivative work contains  ////
27
//// the original copyright notice and the associated disclaimer. ////
28
////                                                              ////
29
//// This source file is free software; you can redistribute it   ////
30
//// and/or modify it under the terms of the GNU Lesser General   ////
31
//// Public License as published by the Free Software Foundation; ////
32
//// either version 2.1 of the License, or (at your option) any   ////
33
//// later version.                                               ////
34
////                                                              ////
35
//// This source is distributed in the hope that it will be       ////
36
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
37
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
38
//// PURPOSE. See the GNU Lesser General Public License for more  ////
39
//// details.                                                     ////
40
////                                                              ////
41
//// You should have received a copy of the GNU Lesser General    ////
42
//// Public License along with this source; if not, download it   ////
43
//// from <http://www.opencores.org/lgpl.shtml>                   ////
44
////                                                              ////
45
//////////////////////////////////////////////////////////////////////
46
//
47
 
48
module usbDevice (
49
  clk,
50
  rst,
51
  usbSlaveVP_in,
52
  usbSlaveVM_in,
53
  usbSlaveVP_out,
54
  usbSlaveVM_out,
55
  usbSlaveOE_n,
56 39 sfielding
  USBFullSpeed,
57 37 sfielding
  usbDPlusPullup,
58 39 sfielding
  usbDMinusPullup,
59 37 sfielding
  vBusDetect
60
);
61
 
62
input clk;
63
input rst;
64
input usbSlaveVP_in;
65
input usbSlaveVM_in;
66
output usbSlaveVP_out;
67
output usbSlaveVM_out;
68
output usbSlaveOE_n;
69 39 sfielding
output USBFullSpeed;
70 37 sfielding
output usbDPlusPullup;
71 39 sfielding
output usbDMinusPullup;
72 37 sfielding
input vBusDetect;
73
 
74
//local wires and regs
75
wire [7:0] wb_addr0;
76
wire wb_stb0;
77
wire wb_we0;
78
wire wbBusReq0;
79
wire wbBusGnt0;
80
wire [7:0] wb_addr1;
81
wire [7:0] wb_data_o1;
82
wire wb_stb1;
83
wire wb_we1;
84
wire wbBusReq1;
85
wire wbBusGnt1;
86
wire [7:0] wb_addr2;
87
wire [7:0] wb_data_o2;
88
wire wb_stb2;
89
wire wb_we2;
90
wire wbBusReq2;
91
wire wbBusGnt2;
92
wire [7:0] wb_adr;
93
wire [7:0] wb_dat_to_usb;
94
wire [7:0] wb_dat_from_usb;
95
wire wb_we;
96
wire wb_stb;
97
wire wb_ack;
98
reg [1:0] resetReg;
99
wire initComplete;
100
wire usbRstDet;
101
wire [7:0] memAddr;
102
wire [7:0] memData;
103
wire USBWireCtrlOut;
104
wire [1:0] USBWireDataIn;
105
wire [1:0] USBWireDataOut;
106
 
107
 
108
//Parameters declaration: 
109
defparam usbSlaveInst.EP0_FIFO_DEPTH = 64;
110
defparam usbSlaveInst.EP0_FIFO_ADDR_WIDTH = 6;
111
defparam usbSlaveInst.EP1_FIFO_DEPTH = 64;
112
defparam usbSlaveInst.EP1_FIFO_ADDR_WIDTH = 6;
113
defparam usbSlaveInst.EP2_FIFO_DEPTH = 64;
114
defparam usbSlaveInst.EP2_FIFO_ADDR_WIDTH = 6;
115
defparam usbSlaveInst.EP3_FIFO_DEPTH = 64;
116
defparam usbSlaveInst.EP3_FIFO_ADDR_WIDTH = 6;
117
usbSlave usbSlaveInst (
118
  .clk_i(clk),
119
  .rst_i(rst),
120
  .address_i(wb_adr),
121
  .data_i(wb_dat_to_usb),
122
  .data_o(wb_dat_from_usb),
123
  .we_i(wb_we),
124
  .strobe_i(wb_stb),
125
  .ack_o(wb_ack),
126
  .usbClk(clk),
127
  .slaveSOFRxedIntOut(),
128
  .slaveResetEventIntOut(),
129
  .slaveResumeIntOut(),
130
  .slaveTransDoneIntOut(),
131
  .slaveNAKSentIntOut(),
132
  .slaveVBusDetIntOut(),
133
  .USBWireDataIn(USBWireDataIn),
134
  .USBWireDataInTick(),
135
  .USBWireDataOut(USBWireDataOut),
136
  .USBWireDataOutTick(),
137
  .USBWireCtrlOut(USBWireCtrlOut),
138 39 sfielding
  .USBFullSpeed(USBFullSpeed),
139 37 sfielding
  .USBDPlusPullup(usbDPlusPullup),
140 39 sfielding
  .USBDMinusPullup(usbDMinusPullup),
141 37 sfielding
  .vBusDetect(vBusDetect)
142
);
143
 
144
assign USBWireDataIn = {usbSlaveVP_in, usbSlaveVM_in};
145
assign {usbSlaveVP_out, usbSlaveVM_out} = USBWireDataOut;
146
assign usbSlaveOE_n = ~USBWireCtrlOut;
147
 
148
checkLineState u_checkLineState (
149
  .clk(clk),
150
  .rst(rst),
151
  .initComplete(initComplete),
152
  .usbRstDet(usbRstDet),
153
  .wb_ack(wb_ack),
154
  .wb_addr(wb_addr0),
155
  .wb_data_i(wb_dat_from_usb),
156
  .wb_stb(wb_stb0),
157
  .wb_we(wb_we0),
158
  .wbBusGnt(wbBusGnt0),
159
  .wbBusReq(wbBusReq0)
160
);
161
 
162
 
163
EP0 u_EP0 (
164
  .clk(clk),
165
  .rst(rst | usbRstDet),
166
  .initComplete(initComplete),
167
  .wb_ack(wb_ack),
168
  .wb_addr(wb_addr1),
169
  .wb_data_i(wb_dat_from_usb),
170
  .wb_data_o(wb_data_o1),
171
  .wb_stb(wb_stb1),
172
  .wb_we(wb_we1),
173
  .wbBusGnt(wbBusGnt1),
174
  .wbBusReq(wbBusReq1),
175
  .memAddr(memAddr),
176
  .memData(memData),
177
  .memRdEn()
178
);
179
 
180
usbROM u_usbROM (
181
  .clk(clk),
182
  .addr(memAddr),
183
  .data(memData)
184
);
185
 
186
 
187
EP1Mouse u_EP1Mouse (
188
  .clk(clk),
189
  .rst(rst | usbRstDet),
190
  .initComplete(initComplete),
191
  .wb_ack(wb_ack),
192
  .wb_addr(wb_addr2),
193
  .wb_data_i(wb_dat_from_usb),
194
  .wb_data_o(wb_data_o2),
195
  .wb_stb(wb_stb2),
196
  .wb_we(wb_we2),
197
  .wbBusGnt(wbBusGnt2),
198
  .wbBusReq(wbBusReq2)
199
);
200
 
201
wishboneArb u_wishboneArb (
202
  .clk(clk),
203
  .rst(rst),
204
 
205
  .addr0_i(wb_addr0),
206
  .data0_i(8'h00),
207
  .stb0_i(wb_stb0),
208
  .we0_i(wb_we0),
209
  .req0(wbBusReq0),
210
  .gnt0(wbBusGnt0),
211
 
212
  .addr1_i(wb_addr1),
213
  .data1_i(wb_data_o1),
214
  .stb1_i(wb_stb1),
215
  .we1_i(wb_we1),
216
  .req1(wbBusReq1),
217
  .gnt1(wbBusGnt1),
218
 
219
  .addr2_i(wb_addr2),
220
  .data2_i(wb_data_o2),
221
  .stb2_i(wb_stb2),
222
  .we2_i(wb_we2),
223
  .req2(wbBusReq2),
224
  .gnt2(wbBusGnt2),
225
 
226
 
227
  .addr_o(wb_adr),
228
  .data_o(wb_dat_to_usb),
229
  .stb_o(wb_stb),
230
  .we_o(wb_we)
231
);
232
 
233
 
234
endmodule
235
 

powered by: WebSVN 2.1.0

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