1 |
37 |
sfielding |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// usbROM.v ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the usbHostSlave opencores effort.
|
6 |
|
|
//// <http://www.opencores.org/cores//> ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Module Description: ////
|
9 |
|
|
//// if you modify this file, be sure to modify usbDevice_define.v
|
10 |
|
|
//// Using RAM rather than logic resources might be a more efficient implememtation
|
11 |
|
|
//// but this has the advantage of working with FPGAs that do not provide a
|
12 |
|
|
//// mechanism for initialising RAM, eg Actel IGLOO
|
13 |
|
|
//// Quartus 7.2 will infer this code as BLOCK RAM, and provide initialisation - nice
|
14 |
|
|
//// ////
|
15 |
|
|
//// To Do: ////
|
16 |
|
|
////
|
17 |
|
|
//// ////
|
18 |
|
|
//// Author(s): ////
|
19 |
|
|
//// - Steve Fielding, sfielding@base2designs.com ////
|
20 |
|
|
//// ////
|
21 |
|
|
//////////////////////////////////////////////////////////////////////
|
22 |
|
|
//// ////
|
23 |
|
|
//// Copyright (C) 2008 Steve Fielding and OPENCORES.ORG ////
|
24 |
|
|
//// ////
|
25 |
|
|
//// This source file may be used and distributed without ////
|
26 |
|
|
//// restriction provided that this copyright statement is not ////
|
27 |
|
|
//// removed from the file and that any derivative work contains ////
|
28 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
29 |
|
|
//// ////
|
30 |
|
|
//// This source file is free software; you can redistribute it ////
|
31 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
32 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
33 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
34 |
|
|
//// later version. ////
|
35 |
|
|
//// ////
|
36 |
|
|
//// This source is distributed in the hope that it will be ////
|
37 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
38 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
39 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
40 |
|
|
//// details. ////
|
41 |
|
|
//// ////
|
42 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
43 |
|
|
//// Public License along with this source; if not, download it ////
|
44 |
|
|
//// from <http://www.opencores.org/lgpl.shtml> ////
|
45 |
|
|
//// ////
|
46 |
|
|
//////////////////////////////////////////////////////////////////////
|
47 |
|
|
//
|
48 |
|
|
`include "usbDevice_define.v"
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
module usbROM (
|
52 |
|
|
clk,
|
53 |
|
|
addr,
|
54 |
|
|
data
|
55 |
|
|
);
|
56 |
|
|
input clk;
|
57 |
|
|
input [7:0] addr;
|
58 |
|
|
output [7:0] data;
|
59 |
|
|
reg [7:0] data;
|
60 |
|
|
|
61 |
|
|
always @(posedge clk) begin
|
62 |
|
|
case (addr)
|
63 |
|
|
// ====================================
|
64 |
|
|
// ===== DEVICE Descriptor =====
|
65 |
|
|
// ====================================
|
66 |
|
|
|
67 |
|
|
8'h00: data <= 8'h12; //BYTE bLength
|
68 |
|
|
8'h01: data <= 8'h01; //BYTE bDescriptorType
|
69 |
|
|
8'h02: data <= 8'h10; //WORD (Lo) bcdUSB version supported
|
70 |
|
|
8'h03: data <= 8'h01; //WORD (Hi) bcdUSB version supported
|
71 |
|
|
8'h04: data <= 8'h00; //BYTE bDeviceClass
|
72 |
|
|
8'h05: data <= 8'h00; //BYTE bDeviceSubClass
|
73 |
|
|
8'h06: data <= 8'h00; //BYTE bDeviceProtocol
|
74 |
|
|
8'h07: data <= `MAX_RESP_SIZE; //BYTE bMaxPacketSize
|
75 |
|
|
8'h08: data <= 8'hC7; //WORD (Lo) idVendor
|
76 |
|
|
8'h09: data <= 8'h05; //WORD (Hi) idVendor
|
77 |
|
|
8'h0a: data <= 8'h13; //WORD (Lo) idProduct; For Philips Hub mouse
|
78 |
|
|
8'h0b: data <= 8'h01; //WORD (Hi) idProduct; For Philips Hub mouse
|
79 |
|
|
8'h0c: data <= 8'h01; //WORD (Lo) bcdDevice
|
80 |
|
|
8'h0d: data <= 8'h00; //WORD (Hi) bcdDevice
|
81 |
|
|
8'h0e: data <= 8'h01; //BYTE iManufacturer
|
82 |
|
|
8'h0f: data <= 8'h02; //BYTE iProduct
|
83 |
|
|
8'h10: data <= 8'h03; //BYTE iSerialNumber
|
84 |
|
|
8'h11: data <= 8'h01; //BYTE bNumConfigurations
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
// ====================================
|
88 |
|
|
// ===== Configuration Descriptor =====
|
89 |
|
|
// ====================================
|
90 |
|
|
8'h12: data <= 8'h09; //BYTE bLength (Configuration descriptor)
|
91 |
|
|
8'h13: data <= 8'h02; //BYTE bDescriptorType //Assigned by USB
|
92 |
|
|
8'h14: data <= 8'd34; //WORD (Lo) wTotalLength
|
93 |
|
|
8'h15: data <= 8'h00; //WORD (Hi) wTotalLength
|
94 |
|
|
8'h16: data <= 8'h01; //BYTE bNumInterfaces
|
95 |
|
|
8'h17: data <= 8'h01; //BYTE bConfigurationValue
|
96 |
|
|
8'h18: data <= 8'h00; //BYTE iConfiguration
|
97 |
|
|
8'h19: data <= 8'ha0; //BYTE bmAttributes, Bus powered and remote wakeup
|
98 |
|
|
8'h1a: data <= 8'h32; //BYTE MaxPower, 100mA
|
99 |
|
|
|
100 |
|
|
// ====================================
|
101 |
|
|
// ===== Interface Descriptor =====
|
102 |
|
|
// ====================================
|
103 |
|
|
8'h1b: data <= 8'h09; //BYTE bLength (Interface descriptor)
|
104 |
|
|
8'h1c: data <= 8'h04; //BYTE bDescriptionType; assigned by USB
|
105 |
|
|
8'h1d: data <= 8'h00; //BYTE bInterfaceNumber
|
106 |
|
|
8'h1e: data <= 8'h00; //BYTE bAlternateSetting
|
107 |
|
|
8'h1f: data <= 8'h01; //BYTE bNumEndpoints; uses 1 endpoints
|
108 |
|
|
8'h20: data <= 8'h03; //BYTE bInterfaceClass; HID Class - 0x03
|
109 |
|
|
8'h21: data <= 8'h01; //BYTE bInterfaceSubClass
|
110 |
|
|
8'h22: data <= 8'h02; //BYTE bInterfaceProtocol
|
111 |
|
|
8'h23: data <= 8'h00; //BYTE iInterface
|
112 |
|
|
|
113 |
|
|
// ====================================
|
114 |
|
|
// ===== HID Descriptor =====
|
115 |
|
|
// ====================================
|
116 |
|
|
8'h24: data <= 8'h09; //BYTE bLength (HID Descriptor)
|
117 |
|
|
8'h25: data <= 8'h21; //BYTE bDescriptorType
|
118 |
|
|
8'h26: data <= 8'h10; //WORD (Lo) bcdHID
|
119 |
|
|
8'h27: data <= 8'h01; //WORD (Hi) bcdHID
|
120 |
|
|
8'h28: data <= 8'h00; //BYTE bCountryCode
|
121 |
|
|
8'h29: data <= 8'h01; //BYTE bNumDescriptors
|
122 |
|
|
8'h2a: data <= 8'h22; //BYTE bReportDescriptorType
|
123 |
|
|
8'h2b: data <= 8'h32; //WORD (Lo) wItemLength
|
124 |
|
|
8'h2c: data <= 8'h00; //WORD (Hi) wItemLength
|
125 |
|
|
|
126 |
|
|
// ====================================
|
127 |
|
|
// ===== Endpoint 1 Descriptor =====
|
128 |
|
|
// ====================================
|
129 |
|
|
8'h2d: data <= 8'h07; //BYTE bLength (Endpoint Descriptor)
|
130 |
|
|
8'h2e: data <= 8'h05; //BYTE bDescriptorType; assigned by USB
|
131 |
|
|
8'h2f: data <= 8'h81; //BYTE bEndpointAddress; IN endpoint; endpoint 1
|
132 |
|
|
8'h30: data <= 8'h03; //BYTE bmAttributes; Interrupt endpoint
|
133 |
|
|
8'h31: data <= 8'h10; //WORD (Lo) wMaxPacketSize
|
134 |
|
|
8'h32: data <= 8'h00; //WORD (Hi) wMaxPacketSize
|
135 |
|
|
8'h33: data <= 8'hFF; //BYTE bInterval
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
// ====================================
|
139 |
|
|
// ===== Report Descriptor =====
|
140 |
|
|
// ====================================
|
141 |
|
|
|
142 |
|
|
8'h3a: data <= 8'h05; 8'h3b: data <= 8'h01; // USAGE_PAGE (Generic Desktop)
|
143 |
|
|
8'h3c: data <= 8'h09; 8'h3d: data <= 8'h02; // USAGE (Mouse)
|
144 |
|
|
8'h3e: data <= 8'ha1; 8'h3f: data <= 8'h01; // COLLECTION (Application)
|
145 |
|
|
8'h40: data <= 8'h09; 8'h41: data <= 8'h01; // USAGE (Pointer)
|
146 |
|
|
8'h42: data <= 8'ha1; 8'h43: data <= 8'h00; // COLLECTION (Physical)
|
147 |
|
|
8'h44: data <= 8'h05; 8'h45: data <= 8'h09; // USAGE_PAGE (Button)
|
148 |
|
|
8'h46: data <= 8'h19; 8'h47: data <= 8'h01; // USAGE_MINIMUM (Button 1)
|
149 |
|
|
8'h48: data <= 8'h29; 8'h49: data <= 8'h03; // USAGE_MAXIMUM (Button 3)
|
150 |
|
|
8'h4a: data <= 8'h15; 8'h4b: data <= 8'h00; // LOGICAL_MINIMUM (0)
|
151 |
|
|
8'h4c: data <= 8'h25; 8'h4d: data <= 8'h01; // LOGICAL_MAXIMUM (1)
|
152 |
|
|
8'h4e: data <= 8'h95; 8'h4f: data <= 8'h03; // REPORT_COUNT (3)
|
153 |
|
|
8'h50: data <= 8'h75; 8'h51: data <= 8'h01; // REPORT_SIZE (1)
|
154 |
|
|
8'h52: data <= 8'h81; 8'h53: data <= 8'h02; // INPUT (Data,Var,Abs)
|
155 |
|
|
8'h54: data <= 8'h95; 8'h55: data <= 8'h01; // REPORT_COUNT (1)
|
156 |
|
|
8'h56: data <= 8'h75; 8'h57: data <= 8'h05; // REPORT_SIZE (5)
|
157 |
|
|
8'h58: data <= 8'h81; 8'h59: data <= 8'h01; // INPUT (Cnst,Var,Rel)
|
158 |
|
|
8'h5a: data <= 8'h05; 8'h5b: data <= 8'h01; // USAGE_PAGE (Generic Desktop)
|
159 |
|
|
8'h5c: data <= 8'h09; 8'h5d: data <= 8'h30; // USAGE (X)
|
160 |
|
|
8'h5e: data <= 8'h09; 8'h5f: data <= 8'h31; // USAGE (Y)
|
161 |
|
|
8'h60: data <= 8'h15; 8'h61: data <= 8'h81; // LOGICAL_MINIMUM (-127)
|
162 |
|
|
8'h62: data <= 8'h25; 8'h63: data <= 8'h7f; // LOGICAL_MAXIMUM (127)
|
163 |
|
|
8'h64: data <= 8'h75; 8'h65: data <= 8'h08; // REPORT_SIZE (8)
|
164 |
|
|
8'h66: data <= 8'h95; 8'h67: data <= 8'h02; // REPORT_COUNT (2)
|
165 |
|
|
8'h68: data <= 8'h81; 8'h69: data <= 8'h06; // INPUT (Data,Var,Rel)
|
166 |
|
|
8'h6a: data <= 8'hc0; //END_COLLECTION
|
167 |
|
|
8'h6b: data <= 8'hc0; // END_COLLECTION
|
168 |
|
|
|
169 |
|
|
// ZERO_ZERO
|
170 |
|
|
8'h6c: data <= 8'h00;
|
171 |
|
|
8'h6d: data <= 8'h00;
|
172 |
|
|
// ONE_ZERO
|
173 |
|
|
8'h6e: data <= 8'h01;
|
174 |
|
|
8'h6f: data <= 8'h00;
|
175 |
|
|
// Vendor data
|
176 |
|
|
8'h70: data <= 8'h00;
|
177 |
|
|
8'h71: data <= 8'h00;
|
178 |
|
|
|
179 |
|
|
// =============================================
|
180 |
|
|
// ===== Language ID Descriptor(String0) =====
|
181 |
|
|
// =============================================
|
182 |
|
|
8'h80: data <= 8'h04; // bLength
|
183 |
|
|
8'h81: data <= 8'h03; // bDescriptorType = String Desc
|
184 |
|
|
8'h82: data <= 8'h09; // wLangID (Lo) (Lang ID for English = 0x0409)
|
185 |
|
|
8'h83: data <= 8'h04; // wLangID (Hi) (Lang ID for English = 0x0409)
|
186 |
|
|
|
187 |
|
|
// ====================================
|
188 |
|
|
// ===== string 1 Descriptor =====
|
189 |
|
|
// ====================================
|
190 |
|
|
8'h90: data <= 8'd26; // bLength
|
191 |
|
|
8'h91: data <= 8'h03; // bDescriptorType = String Desc
|
192 |
|
|
// Noting that text is always unicode, hence the 'padding'
|
193 |
|
|
8'h92: data <= "B"; 8'h93: data <= 8'h00;
|
194 |
|
|
8'h94: data <= "a"; 8'h95: data <= 8'h00;
|
195 |
|
|
8'h96: data <= "s"; 8'h97: data <= 8'h00;
|
196 |
|
|
8'h98: data <= "e"; 8'h99: data <= 8'h00;
|
197 |
|
|
8'h9a: data <= "2"; 8'h9b: data <= 8'h00;
|
198 |
|
|
8'h9c: data <= "D"; 8'h9d: data <= 8'h00;
|
199 |
|
|
8'h9e: data <= "e"; 8'h9f: data <= 8'h00;
|
200 |
|
|
8'ha0: data <= "s"; 8'ha1: data <= 8'h00;
|
201 |
|
|
8'ha2: data <= "i"; 8'ha3: data <= 8'h00;
|
202 |
|
|
8'ha4: data <= "g"; 8'ha5: data <= 8'h00;
|
203 |
|
|
8'ha6: data <= "n"; 8'ha7: data <= 8'h00;
|
204 |
|
|
8'ha8: data <= "s"; 8'ha9: data <= 8'h00;
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
// ====================================
|
209 |
|
|
// ===== string 2 Descriptor =====
|
210 |
|
|
// ====================================
|
211 |
|
|
8'hb0: data <= 8'd20; // bLength
|
212 |
|
|
8'hb1: data <= 8'h03; // bDescriptorType = String Desc
|
213 |
|
|
// Noting that text is always unicode, hence the 'padding'
|
214 |
|
|
8'hb2: data <= "B"; 8'hb3: data <= 8'h00;
|
215 |
|
|
8'hb4: data <= "2"; 8'hb5: data <= 8'h00;
|
216 |
|
|
8'hb6: data <= "D"; 8'hb7: data <= 8'h00;
|
217 |
|
|
8'hb8: data <= " "; 8'hb9: data <= 8'h00;
|
218 |
|
|
8'hba: data <= "M"; 8'hbb: data <= 8'h00;
|
219 |
|
|
8'hbc: data <= "o"; 8'hbd: data <= 8'h00;
|
220 |
|
|
8'hbe: data <= "u"; 8'hbf: data <= 8'h00;
|
221 |
|
|
8'hc0: data <= "s"; 8'hc1: data <= 8'h00;
|
222 |
|
|
8'hc2: data <= "e"; 8'hc3: data <= 8'h00;
|
223 |
|
|
|
224 |
|
|
// ====================================
|
225 |
|
|
// ===== string 3 Descriptor =====
|
226 |
|
|
// ====================================
|
227 |
|
|
8'hd0: data <= 8'd30; // bLength
|
228 |
|
|
8'hd1: data <= 8'h03; // bDescriptorType = String Desc
|
229 |
|
|
// Noting that text is always unicode, hence the 'padding'
|
230 |
|
|
8'hd2: data <= "L"; 8'hd3: data <= 8'h00;
|
231 |
|
|
8'hd4: data <= "i"; 8'hd5: data <= 8'h00;
|
232 |
|
|
8'hd6: data <= "m"; 8'hd7: data <= 8'h00;
|
233 |
|
|
8'hd8: data <= "i"; 8'hd9: data <= 8'h00;
|
234 |
|
|
8'hda: data <= "t"; 8'hdb: data <= 8'h00;
|
235 |
|
|
8'hdc: data <= "e"; 8'hdd: data <= 8'h00;
|
236 |
|
|
8'hde: data <= "d"; 8'hdf: data <= 8'h00;
|
237 |
|
|
8'he0: data <= "E"; 8'he1: data <= 8'h00;
|
238 |
|
|
8'he2: data <= "d"; 8'he3: data <= 8'h00;
|
239 |
|
|
8'he4: data <= "i"; 8'he5: data <= 8'h00;
|
240 |
|
|
8'he6: data <= "t"; 8'he7: data <= 8'h00;
|
241 |
|
|
8'he8: data <= "i"; 8'he9: data <= 8'h00;
|
242 |
|
|
8'hea: data <= "o"; 8'heb: data <= 8'h00;
|
243 |
|
|
8'hec: data <= "n"; 8'hed: data <= 8'h00;
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
default: data <= 8'h00;
|
248 |
|
|
endcase
|
249 |
|
|
end
|
250 |
|
|
|
251 |
|
|
endmodule
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
|