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

Subversion Repositories usbhostslave

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

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
  usbDPlusPullup,
57
  vBusDetect
58
);
59
 
60
input clk;
61
input rst;
62
input usbSlaveVP_in;
63
input usbSlaveVM_in;
64
output usbSlaveVP_out;
65
output usbSlaveVM_out;
66
output usbSlaveOE_n;
67
output usbDPlusPullup;
68
input vBusDetect;
69
 
70
//local wires and regs
71
wire [7:0] wb_addr0;
72
wire wb_stb0;
73
wire wb_we0;
74
wire wbBusReq0;
75
wire wbBusGnt0;
76
wire [7:0] wb_addr1;
77
wire [7:0] wb_data_o1;
78
wire wb_stb1;
79
wire wb_we1;
80
wire wbBusReq1;
81
wire wbBusGnt1;
82
wire [7:0] wb_addr2;
83
wire [7:0] wb_data_o2;
84
wire wb_stb2;
85
wire wb_we2;
86
wire wbBusReq2;
87
wire wbBusGnt2;
88
wire [7:0] wb_adr;
89
wire [7:0] wb_dat_to_usb;
90
wire [7:0] wb_dat_from_usb;
91
wire wb_we;
92
wire wb_stb;
93
wire wb_ack;
94
reg [1:0] resetReg;
95
wire initComplete;
96
wire usbRstDet;
97
wire [7:0] memAddr;
98
wire [7:0] memData;
99
wire USBWireCtrlOut;
100
wire [1:0] USBWireDataIn;
101
wire [1:0] USBWireDataOut;
102
 
103
 
104
//Parameters declaration: 
105
defparam usbSlaveInst.EP0_FIFO_DEPTH = 64;
106
defparam usbSlaveInst.EP0_FIFO_ADDR_WIDTH = 6;
107
defparam usbSlaveInst.EP1_FIFO_DEPTH = 64;
108
defparam usbSlaveInst.EP1_FIFO_ADDR_WIDTH = 6;
109
defparam usbSlaveInst.EP2_FIFO_DEPTH = 64;
110
defparam usbSlaveInst.EP2_FIFO_ADDR_WIDTH = 6;
111
defparam usbSlaveInst.EP3_FIFO_DEPTH = 64;
112
defparam usbSlaveInst.EP3_FIFO_ADDR_WIDTH = 6;
113
usbSlave usbSlaveInst (
114
  .clk_i(clk),
115
  .rst_i(rst),
116
  .address_i(wb_adr),
117
  .data_i(wb_dat_to_usb),
118
  .data_o(wb_dat_from_usb),
119
  .we_i(wb_we),
120
  .strobe_i(wb_stb),
121
  .ack_o(wb_ack),
122
  .usbClk(clk),
123
  .slaveSOFRxedIntOut(),
124
  .slaveResetEventIntOut(),
125
  .slaveResumeIntOut(),
126
  .slaveTransDoneIntOut(),
127
  .slaveNAKSentIntOut(),
128
  .slaveVBusDetIntOut(),
129
  .USBWireDataIn(USBWireDataIn),
130
  .USBWireDataInTick(),
131
  .USBWireDataOut(USBWireDataOut),
132
  .USBWireDataOutTick(),
133
  .USBWireCtrlOut(USBWireCtrlOut),
134
  .USBFullSpeed(),
135
  .USBDPlusPullup(usbDPlusPullup),
136
  .USBDMinusPullup(),
137
  .vBusDetect(vBusDetect)
138
);
139
 
140
assign USBWireDataIn = {usbSlaveVP_in, usbSlaveVM_in};
141
assign {usbSlaveVP_out, usbSlaveVM_out} = USBWireDataOut;
142
assign usbSlaveOE_n = ~USBWireCtrlOut;
143
 
144
checkLineState u_checkLineState (
145
  .clk(clk),
146
  .rst(rst),
147
  .initComplete(initComplete),
148
  .usbRstDet(usbRstDet),
149
  .wb_ack(wb_ack),
150
  .wb_addr(wb_addr0),
151
  .wb_data_i(wb_dat_from_usb),
152
  .wb_stb(wb_stb0),
153
  .wb_we(wb_we0),
154
  .wbBusGnt(wbBusGnt0),
155
  .wbBusReq(wbBusReq0)
156
);
157
 
158
 
159
EP0 u_EP0 (
160
  .clk(clk),
161
  .rst(rst | usbRstDet),
162
  .initComplete(initComplete),
163
  .wb_ack(wb_ack),
164
  .wb_addr(wb_addr1),
165
  .wb_data_i(wb_dat_from_usb),
166
  .wb_data_o(wb_data_o1),
167
  .wb_stb(wb_stb1),
168
  .wb_we(wb_we1),
169
  .wbBusGnt(wbBusGnt1),
170
  .wbBusReq(wbBusReq1),
171
  .memAddr(memAddr),
172
  .memData(memData),
173
  .memRdEn()
174
);
175
 
176
usbROM u_usbROM (
177
  .clk(clk),
178
  .addr(memAddr),
179
  .data(memData)
180
);
181
 
182
 
183
EP1Mouse u_EP1Mouse (
184
  .clk(clk),
185
  .rst(rst | usbRstDet),
186
  .initComplete(initComplete),
187
  .wb_ack(wb_ack),
188
  .wb_addr(wb_addr2),
189
  .wb_data_i(wb_dat_from_usb),
190
  .wb_data_o(wb_data_o2),
191
  .wb_stb(wb_stb2),
192
  .wb_we(wb_we2),
193
  .wbBusGnt(wbBusGnt2),
194
  .wbBusReq(wbBusReq2)
195
);
196
 
197
wishboneArb u_wishboneArb (
198
  .clk(clk),
199
  .rst(rst),
200
 
201
  .addr0_i(wb_addr0),
202
  .data0_i(8'h00),
203
  .stb0_i(wb_stb0),
204
  .we0_i(wb_we0),
205
  .req0(wbBusReq0),
206
  .gnt0(wbBusGnt0),
207
 
208
  .addr1_i(wb_addr1),
209
  .data1_i(wb_data_o1),
210
  .stb1_i(wb_stb1),
211
  .we1_i(wb_we1),
212
  .req1(wbBusReq1),
213
  .gnt1(wbBusGnt1),
214
 
215
  .addr2_i(wb_addr2),
216
  .data2_i(wb_data_o2),
217
  .stb2_i(wb_stb2),
218
  .we2_i(wb_we2),
219
  .req2(wbBusReq2),
220
  .gnt2(wbBusGnt2),
221
 
222
 
223
  .addr_o(wb_adr),
224
  .data_o(wb_dat_to_usb),
225
  .stb_o(wb_stb),
226
  .we_o(wb_we)
227
);
228
 
229
 
230
endmodule
231
 

powered by: WebSVN 2.1.0

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