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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [slaveController/] [USBSlaveControlBI.v] - Blame information for rev 18

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

Line No. Rev Author Line
1 2 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// USBSlaveControlBI.v                                          ////
4
////                                                              ////
5
//// This file is part of the usbhostslave opencores effort.
6
//// <http://www.opencores.org/cores//>                           ////
7
////                                                              ////
8
//// Module Description:                                          ////
9 14 sfielding
////       
10 2 sfielding
////                                                              ////
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 9 sfielding
`timescale 1ns / 1ps
45 2 sfielding
 
46 9 sfielding
 
47 2 sfielding
`include "usbSlaveControl_h.v"
48
 
49
module USBSlaveControlBI (address, dataIn, dataOut, writeEn,
50
  strobe_i,
51 18 sfielding
  busClk,
52
  rstSyncToBusClk,
53
  usbClk,
54
  rstSyncToUsbClk,
55 5 sfielding
  SOFRxedIntOut, resetEventIntOut, resumeIntOut, transDoneIntOut, NAKSentIntOut,
56 2 sfielding
  endP0TransTypeReg, endP0NAKTransTypeReg,
57
  endP1TransTypeReg, endP1NAKTransTypeReg,
58
  endP2TransTypeReg, endP2NAKTransTypeReg,
59
  endP3TransTypeReg, endP3NAKTransTypeReg,
60
  endP0ControlReg,
61
  endP1ControlReg,
62
  endP2ControlReg,
63
  endP3ControlReg,
64
  EP0StatusReg,
65
  EP1StatusReg,
66
  EP2StatusReg,
67
  EP3StatusReg,
68
  SCAddrReg, frameNum,
69 5 sfielding
  connectStateIn,
70
  SOFRxedIn, resetEventIn, resumeIntIn, transDoneIn, NAKSentIn,
71 2 sfielding
  slaveControlSelect,
72
  clrEP0Ready, clrEP1Ready, clrEP2Ready, clrEP3Ready,
73
  TxLineState,
74
  LineDirectControlEn,
75
  fullSpeedPol,
76
  fullSpeedRate,
77
  SCGlobalEn
78
  );
79
input [4:0] address;
80
input [7:0] dataIn;
81
input writeEn;
82
input strobe_i;
83 18 sfielding
input busClk;
84
input rstSyncToBusClk;
85
input usbClk;
86
input rstSyncToUsbClk;
87 2 sfielding
output [7:0] dataOut;
88
output SOFRxedIntOut;
89
output resetEventIntOut;
90
output resumeIntOut;
91
output transDoneIntOut;
92
output NAKSentIntOut;
93
 
94
input [1:0] endP0TransTypeReg;
95
input [1:0] endP0NAKTransTypeReg;
96
input [1:0] endP1TransTypeReg;
97
input [1:0] endP1NAKTransTypeReg;
98
input [1:0] endP2TransTypeReg;
99
input [1:0] endP2NAKTransTypeReg;
100
input [1:0] endP3TransTypeReg;
101
input [1:0] endP3NAKTransTypeReg;
102 14 sfielding
output [4:0] endP0ControlReg;
103
output [4:0] endP1ControlReg;
104
output [4:0] endP2ControlReg;
105
output [4:0] endP3ControlReg;
106 2 sfielding
input [7:0] EP0StatusReg;
107
input [7:0] EP1StatusReg;
108
input [7:0] EP2StatusReg;
109
input [7:0] EP3StatusReg;
110
output [6:0] SCAddrReg;
111
input [10:0] frameNum;
112
input [1:0] connectStateIn;
113
input SOFRxedIn;
114
input resetEventIn;
115
input resumeIntIn;
116
input transDoneIn;
117
input NAKSentIn;
118
input slaveControlSelect;
119
input clrEP0Ready;
120
input clrEP1Ready;
121
input clrEP2Ready;
122
input clrEP3Ready;
123
output [1:0] TxLineState;
124
output LineDirectControlEn;
125
output fullSpeedPol;
126
output fullSpeedRate;
127
output SCGlobalEn;
128
 
129
wire [4:0] address;
130
wire [7:0] dataIn;
131
wire writeEn;
132
wire strobe_i;
133 18 sfielding
wire busClk;
134
wire rstSyncToBusClk;
135
wire usbClk;
136
wire rstSyncToUsbClk;
137 2 sfielding
reg [7:0] dataOut;
138
 
139
reg SOFRxedIntOut;
140
reg resetEventIntOut;
141
reg resumeIntOut;
142
reg transDoneIntOut;
143
reg NAKSentIntOut;
144
 
145
wire [1:0] endP0TransTypeReg;
146
wire [1:0] endP0NAKTransTypeReg;
147
wire [1:0] endP1TransTypeReg;
148
wire [1:0] endP1NAKTransTypeReg;
149
wire [1:0] endP2TransTypeReg;
150
wire [1:0] endP2NAKTransTypeReg;
151
wire [1:0] endP3TransTypeReg;
152
wire [1:0] endP3NAKTransTypeReg;
153 14 sfielding
reg [4:0] endP0ControlReg;
154
reg [4:0] endP1ControlReg;
155
reg [4:0] endP2ControlReg;
156
reg [4:0] endP3ControlReg;
157 2 sfielding
wire [7:0] EP0StatusReg;
158
wire [7:0] EP1StatusReg;
159
wire [7:0] EP2StatusReg;
160
wire [7:0] EP3StatusReg;
161
reg [6:0] SCAddrReg;
162
reg [3:0] TxEndPReg;
163
wire [10:0] frameNum;
164
wire [1:0] connectStateIn;
165
 
166
wire SOFRxedIn;
167
wire resetEventIn;
168
wire resumeIntIn;
169
wire transDoneIn;
170
wire NAKSentIn;
171
wire slaveControlSelect;
172
wire clrEP0Ready;
173
wire clrEP1Ready;
174
wire clrEP2Ready;
175
wire clrEP3Ready;
176
reg [1:0] TxLineState;
177
reg LineDirectControlEn;
178
reg fullSpeedPol;
179
reg fullSpeedRate;
180
reg SCGlobalEn;
181
 
182
//internal wire and regs
183
reg [5:0] SCControlReg;
184
reg clrNAKReq;
185
reg clrSOFReq;
186
reg clrResetReq;
187
reg clrResInReq;
188
reg clrTransDoneReq;
189
reg SOFRxedInt;
190
reg resetEventInt;
191
reg resumeInt;
192
reg transDoneInt;
193
reg NAKSentInt;
194
reg [4:0] interruptMaskReg;
195
reg EP0SetReady;
196
reg EP1SetReady;
197
reg EP2SetReady;
198
reg EP3SetReady;
199
reg EP0SendStall;
200
reg EP1SendStall;
201
reg EP2SendStall;
202
reg EP3SendStall;
203 14 sfielding
reg EP0IsoEn;
204
reg EP1IsoEn;
205
reg EP2IsoEn;
206
reg EP3IsoEn;
207 2 sfielding
reg EP0DataSequence;
208
reg EP1DataSequence;
209
reg EP2DataSequence;
210
reg EP3DataSequence;
211
reg EP0Enable;
212
reg EP1Enable;
213
reg EP2Enable;
214
reg EP3Enable;
215
reg EP0Ready;
216
reg EP1Ready;
217
reg EP2Ready;
218
reg EP3Ready;
219
 
220 18 sfielding
//clock domain crossing sync registers
221
//STB = Sync To Busclk
222
reg [4:0] endP0ControlRegSTB;
223
reg [4:0] endP1ControlRegSTB;
224
reg [4:0] endP2ControlRegSTB;
225
reg [4:0] endP3ControlRegSTB;
226
reg NAKSentInSTB;
227
reg SOFRxedInSTB;
228
reg resetEventInSTB;
229
reg resumeIntInSTB;
230
reg transDoneInSTB;
231
reg clrEP0ReadySTB;
232
reg clrEP1ReadySTB;
233
reg clrEP2ReadySTB;
234
reg clrEP3ReadySTB;
235
reg SCGlobalEnSTB;
236
reg [1:0] TxLineStateSTB;
237
reg LineDirectControlEnSTB;
238
reg fullSpeedPolSTB;
239
reg fullSpeedRateSTB;
240
reg [7:0] EP0StatusRegSTB;
241
reg [7:0] EP1StatusRegSTB;
242
reg [7:0] EP2StatusRegSTB;
243
reg [7:0] EP3StatusRegSTB;
244
reg [1:0] endP0TransTypeRegSTB;
245
reg [1:0] endP0NAKTransTypeRegSTB;
246
reg [1:0] endP1TransTypeRegSTB;
247
reg [1:0] endP1NAKTransTypeRegSTB;
248
reg [1:0] endP2TransTypeRegSTB;
249
reg [1:0] endP2NAKTransTypeRegSTB;
250
reg [1:0] endP3TransTypeRegSTB;
251
reg [1:0] endP3NAKTransTypeRegSTB;
252
reg [10:0] frameNumSTB;
253 2 sfielding
 
254 18 sfielding
 
255 2 sfielding
//sync write demux
256 18 sfielding
always @(posedge busClk)
257 14 sfielding
begin
258 18 sfielding
  if (rstSyncToBusClk == 1'b1) begin
259 14 sfielding
    EP0IsoEn <= 1'b0;
260
    EP0SendStall <= 1'b0;
261
    EP0DataSequence <= 1'b0;
262
    EP0Enable <= 1'b0;
263
    EP1IsoEn <= 1'b0;
264
    EP1SendStall <= 1'b0;
265
    EP1DataSequence <= 1'b0;
266
    EP1Enable <= 1'b0;
267
    EP2IsoEn <= 1'b0;
268
    EP2SendStall <= 1'b0;
269
    EP2DataSequence <= 1'b0;
270
    EP2Enable <= 1'b0;
271
    EP3IsoEn <= 1'b0;
272
    EP3SendStall <= 1'b0;
273
    EP3DataSequence <= 1'b0;
274
    EP3Enable <= 1'b0;
275
    SCControlReg <= 6'h00;
276
    SCAddrReg <= 7'h00;
277
    interruptMaskReg <= 5'h00;
278 5 sfielding
  end
279 14 sfielding
  else begin
280
    clrNAKReq <= 1'b0;
281
    clrSOFReq <= 1'b0;
282
    clrResetReq <= 1'b0;
283
    clrResInReq <= 1'b0;
284
    clrTransDoneReq <= 1'b0;
285
    EP0SetReady <= 1'b0;
286
    EP1SetReady <= 1'b0;
287
    EP2SetReady <= 1'b0;
288
    EP3SetReady <= 1'b0;
289
    if (writeEn == 1'b1 && strobe_i == 1'b1 && slaveControlSelect == 1'b1)
290
    begin
291
      case (address)
292
        `EP0_CTRL_REG : begin
293
          EP0IsoEn <= dataIn[`ENDPOINT_ISO_ENABLE_BIT];
294
          EP0SendStall <= dataIn[`ENDPOINT_SEND_STALL_BIT];
295
          EP0DataSequence <= dataIn[`ENDPOINT_OUTDATA_SEQUENCE_BIT];
296
          EP0SetReady <= dataIn[`ENDPOINT_READY_BIT];
297
          EP0Enable <= dataIn[`ENDPOINT_ENABLE_BIT];
298
        end
299
        `EP1_CTRL_REG : begin
300
          EP1IsoEn <= dataIn[`ENDPOINT_ISO_ENABLE_BIT];
301
          EP1SendStall <= dataIn[`ENDPOINT_SEND_STALL_BIT];
302
          EP1DataSequence <= dataIn[`ENDPOINT_OUTDATA_SEQUENCE_BIT];
303
          EP1SetReady <= dataIn[`ENDPOINT_READY_BIT];
304
          EP1Enable <= dataIn[`ENDPOINT_ENABLE_BIT];
305
        end
306
        `EP2_CTRL_REG : begin
307
          EP2IsoEn <= dataIn[`ENDPOINT_ISO_ENABLE_BIT];
308
          EP2SendStall <= dataIn[`ENDPOINT_SEND_STALL_BIT];
309
          EP2DataSequence <= dataIn[`ENDPOINT_OUTDATA_SEQUENCE_BIT];
310
          EP2SetReady <= dataIn[`ENDPOINT_READY_BIT];
311
          EP2Enable <= dataIn[`ENDPOINT_ENABLE_BIT];
312
        end
313
        `EP3_CTRL_REG : begin
314
          EP3IsoEn <= dataIn[`ENDPOINT_ISO_ENABLE_BIT];
315
          EP3SendStall <= dataIn[`ENDPOINT_SEND_STALL_BIT];
316
          EP3DataSequence <= dataIn[`ENDPOINT_OUTDATA_SEQUENCE_BIT];
317
          EP3SetReady <= dataIn[`ENDPOINT_READY_BIT];
318
          EP3Enable <= dataIn[`ENDPOINT_ENABLE_BIT];
319
        end
320
        `SC_CONTROL_REG : SCControlReg <= dataIn[5:0];
321
        `SC_ADDRESS : SCAddrReg <= dataIn[6:0];
322
        `SC_INTERRUPT_STATUS_REG : begin
323
          clrNAKReq <= dataIn[`NAK_SENT_INT_BIT];
324
          clrSOFReq <= dataIn[`SOF_RECEIVED_BIT];
325
          clrResetReq <= dataIn[`RESET_EVENT_BIT];
326
          clrResInReq <= dataIn[`RESUME_INT_BIT];
327
          clrTransDoneReq <= dataIn[`TRANS_DONE_BIT];
328
        end
329
        `SC_INTERRUPT_MASK_REG  : interruptMaskReg <= dataIn[4:0];
330
      endcase
331
    end
332
  end
333 2 sfielding
end
334
 
335
//interrupt control 
336 18 sfielding
always @(posedge busClk)
337 2 sfielding
begin
338 18 sfielding
  if (rstSyncToBusClk == 1'b1) begin
339 14 sfielding
    NAKSentInt <= 1'b0;
340 5 sfielding
    SOFRxedInt <= 1'b0;
341
    resetEventInt <= 1'b0;
342 14 sfielding
    resumeInt <= 1'b0;
343
    transDoneInt <= 1'b0;
344
  end
345
  else begin
346 18 sfielding
    if (NAKSentInSTB == 1'b1)
347 14 sfielding
      NAKSentInt <= 1'b1;
348
    else if (clrNAKReq == 1'b1)
349
      NAKSentInt <= 1'b0;
350 5 sfielding
 
351 18 sfielding
    if (SOFRxedInSTB == 1'b1)
352 14 sfielding
      SOFRxedInt <= 1'b1;
353
    else if (clrSOFReq == 1'b1)
354
      SOFRxedInt <= 1'b0;
355
 
356 18 sfielding
    if (resetEventInSTB == 1'b1)
357 14 sfielding
      resetEventInt <= 1'b1;
358
    else if (clrResetReq == 1'b1)
359
      resetEventInt <= 1'b0;
360
 
361 18 sfielding
    if (resumeIntInSTB == 1'b1)
362 14 sfielding
      resumeInt <= 1'b1;
363
    else if (clrResInReq == 1'b1)
364
      resumeInt <= 1'b0;
365 2 sfielding
 
366 18 sfielding
    if (transDoneInSTB == 1'b1)
367 14 sfielding
      transDoneInt <= 1'b1;
368
    else if (clrTransDoneReq == 1'b1)
369
      transDoneInt <= 1'b0;
370
  end
371 2 sfielding
end
372
 
373
//mask interrupts
374
always @(interruptMaskReg or transDoneInt or resumeInt or resetEventInt or SOFRxedInt or NAKSentInt) begin
375
  transDoneIntOut <= transDoneInt & interruptMaskReg[`TRANS_DONE_BIT];
376
  resumeIntOut <= resumeInt & interruptMaskReg[`RESUME_INT_BIT];
377
  resetEventIntOut <= resetEventInt & interruptMaskReg[`RESET_EVENT_BIT];
378
  SOFRxedIntOut <= SOFRxedInt & interruptMaskReg[`SOF_RECEIVED_BIT];
379
  NAKSentIntOut <= NAKSentInt & interruptMaskReg[`NAK_SENT_INT_BIT];
380
end
381
 
382
//end point ready, set/clear
383 18 sfielding
//Since 'busClk' can be a higher freq than 'usbClk',
384
//'EP0SetReady' etc must be delayed with respect to other control signals, thus
385
//ensuring that control signals have been clocked through to 'usbClk' clock
386
//domain before the ready is asserted.
387
//Not sure this is required because there is at least two 'usbClk' ticks between
388
//detection of 'EP0Ready' and sampling of related control signals.always @(posedge busClk)
389
always @(posedge busClk)
390 2 sfielding
begin
391 18 sfielding
  if (rstSyncToBusClk == 1'b1) begin
392 5 sfielding
    EP0Ready <= 1'b0;
393
    EP1Ready <= 1'b0;
394
    EP2Ready <= 1'b0;
395 14 sfielding
    EP3Ready <= 1'b0;
396
  end
397
  else begin
398
    if (EP0SetReady == 1'b1)
399
      EP0Ready <= 1'b1;
400 18 sfielding
    else if (clrEP0ReadySTB == 1'b1)
401 14 sfielding
      EP0Ready <= 1'b0;
402 2 sfielding
 
403 14 sfielding
    if (EP1SetReady == 1'b1)
404
      EP1Ready <= 1'b1;
405 18 sfielding
    else if (clrEP1ReadySTB == 1'b1)
406 14 sfielding
      EP1Ready <= 1'b0;
407
 
408
    if (EP2SetReady == 1'b1)
409
      EP2Ready <= 1'b1;
410 18 sfielding
    else if (clrEP2ReadySTB == 1'b1)
411 14 sfielding
      EP2Ready <= 1'b0;
412
 
413
    if (EP3SetReady == 1'b1)
414
      EP3Ready <= 1'b1;
415 18 sfielding
    else if (clrEP3ReadySTB == 1'b1)
416 14 sfielding
      EP3Ready <= 1'b0;
417
  end
418 2 sfielding
end
419
 
420
//break out control signals
421
always @(SCControlReg) begin
422 18 sfielding
  SCGlobalEnSTB <= SCControlReg[`SC_GLOBAL_ENABLE_BIT];
423
  TxLineStateSTB <= SCControlReg[`SC_TX_LINE_STATE_MSBIT:`SC_TX_LINE_STATE_LSBIT];
424
  LineDirectControlEnSTB <= SCControlReg[`SC_DIRECT_CONTROL_BIT];
425
  fullSpeedPolSTB <= SCControlReg[`SC_FULL_SPEED_LINE_POLARITY_BIT];
426
  fullSpeedRateSTB <= SCControlReg[`SC_FULL_SPEED_LINE_RATE_BIT];
427 2 sfielding
end
428
 
429
//combine endpoint control signals 
430 14 sfielding
always @(EP0IsoEn or EP0SendStall or EP0Ready or EP0DataSequence or EP0Enable or
431
  EP1IsoEn or EP1SendStall or EP1Ready or EP1DataSequence or EP1Enable or
432
  EP2IsoEn or EP2SendStall or EP2Ready or EP2DataSequence or EP2Enable or
433
  EP3IsoEn or EP3SendStall or EP3Ready or EP3DataSequence or EP3Enable)
434 2 sfielding
begin
435 18 sfielding
  endP0ControlRegSTB <= {EP0IsoEn, EP0SendStall, EP0DataSequence, EP0Ready, EP0Enable};
436
  endP1ControlRegSTB <= {EP1IsoEn, EP1SendStall, EP1DataSequence, EP1Ready, EP1Enable};
437
  endP2ControlRegSTB <= {EP2IsoEn, EP2SendStall, EP2DataSequence, EP2Ready, EP2Enable};
438
  endP3ControlRegSTB <= {EP3IsoEn, EP3SendStall, EP3DataSequence, EP3Ready, EP3Enable};
439 2 sfielding
end
440
 
441
 
442 18 sfielding
// async read mux
443
// FIX ME
444
// Not sure why 'EP0SendStall' etc are in sensitivity list. May be related to
445
// some translation bug
446 2 sfielding
always @(address or
447
  EP0SendStall or EP0Ready or EP0DataSequence or EP0Enable or
448
  EP1SendStall or EP1Ready or EP1DataSequence or EP1Enable or
449
  EP2SendStall or EP2Ready or EP2DataSequence or EP2Enable or
450
  EP3SendStall or EP3Ready or EP3DataSequence or EP3Enable or
451 18 sfielding
  EP0StatusRegSTB or EP1StatusRegSTB or EP2StatusRegSTB or EP3StatusRegSTB or
452
  endP0ControlRegSTB or endP1ControlRegSTB or endP2ControlRegSTB or endP3ControlRegSTB or
453
  endP0NAKTransTypeRegSTB or endP1NAKTransTypeRegSTB or endP2NAKTransTypeRegSTB or endP3NAKTransTypeRegSTB or
454
  endP0TransTypeRegSTB or endP1TransTypeRegSTB or endP2TransTypeRegSTB or endP3TransTypeRegSTB or
455 2 sfielding
  SCControlReg or connectStateIn or
456
  NAKSentInt or SOFRxedInt or resetEventInt or resumeInt or transDoneInt or
457 18 sfielding
  interruptMaskReg or SCAddrReg or frameNumSTB)
458 2 sfielding
begin
459 5 sfielding
  case (address)
460 18 sfielding
      `EP0_CTRL_REG : dataOut <= endP0ControlRegSTB;
461
      `EP0_STS_REG : dataOut <= EP0StatusRegSTB;
462
      `EP0_TRAN_TYPE_STS_REG : dataOut <= endP0TransTypeRegSTB;
463
      `EP0_NAK_TRAN_TYPE_STS_REG : dataOut <= endP0NAKTransTypeRegSTB;
464
      `EP1_CTRL_REG : dataOut <= endP1ControlRegSTB;
465
      `EP1_STS_REG :  dataOut <= EP1StatusRegSTB;
466
      `EP1_TRAN_TYPE_STS_REG : dataOut <= endP1TransTypeRegSTB;
467
      `EP1_NAK_TRAN_TYPE_STS_REG : dataOut <= endP1NAKTransTypeRegSTB;
468
      `EP2_CTRL_REG : dataOut <= endP2ControlRegSTB;
469
      `EP2_STS_REG :  dataOut <= EP2StatusRegSTB;
470
      `EP2_TRAN_TYPE_STS_REG : dataOut <= endP2TransTypeRegSTB;
471
      `EP2_NAK_TRAN_TYPE_STS_REG : dataOut <= endP2NAKTransTypeRegSTB;
472
      `EP3_CTRL_REG : dataOut <= endP3ControlRegSTB;
473
      `EP3_STS_REG :  dataOut <= EP3StatusRegSTB;
474
      `EP3_TRAN_TYPE_STS_REG : dataOut <= endP3TransTypeRegSTB;
475
      `EP3_NAK_TRAN_TYPE_STS_REG : dataOut <= endP3NAKTransTypeRegSTB;
476 5 sfielding
      `SC_CONTROL_REG : dataOut <= SCControlReg;
477
      `SC_LINE_STATUS_REG : dataOut <= {6'b000000, connectStateIn};
478
      `SC_INTERRUPT_STATUS_REG :  dataOut <= {3'b000, NAKSentInt, SOFRxedInt, resetEventInt, resumeInt, transDoneInt};
479
      `SC_INTERRUPT_MASK_REG  : dataOut <= {3'b000, interruptMaskReg};
480
      `SC_ADDRESS : dataOut <= {1'b0, SCAddrReg};
481 18 sfielding
      `SC_FRAME_NUM_MSP : dataOut <= {5'b00000, frameNumSTB[10:8]};
482
      `SC_FRAME_NUM_LSP : dataOut <= frameNumSTB[7:0];
483 2 sfielding
      default: dataOut <= 8'h00;
484 5 sfielding
  endcase
485 2 sfielding
end
486
 
487 18 sfielding
//re-sync from busClk to usbClk. 
488
always @(posedge usbClk) begin
489
  endP0ControlReg <= endP0ControlRegSTB;
490
  endP1ControlReg <= endP1ControlRegSTB;
491
  endP2ControlReg <= endP2ControlRegSTB;
492
  endP3ControlReg <= endP3ControlRegSTB;
493
  SCGlobalEn <= SCGlobalEnSTB;
494
  TxLineState <= TxLineStateSTB;
495
  LineDirectControlEn <= LineDirectControlEnSTB;
496
  fullSpeedPol <= fullSpeedPolSTB;
497
  fullSpeedRate <= fullSpeedRateSTB;
498
end
499 2 sfielding
 
500 18 sfielding
//re-sync from usbClk to busClk. Since 'NAKSentIn', 'SOFRxedIn' etc are only asserted 
501
//for one 'usbClk' tick, busClk freq must be greater than or equal to usbClk freq
502
always @(posedge busClk) begin
503
  NAKSentInSTB <= NAKSentIn;
504
  SOFRxedInSTB <= SOFRxedIn;
505
  resetEventInSTB <= resetEventIn;
506
  resumeIntInSTB <= resumeIntIn;
507
  transDoneInSTB <= transDoneIn;
508
  clrEP0ReadySTB <= clrEP0Ready;
509
  clrEP1ReadySTB <= clrEP1Ready;
510
  clrEP2ReadySTB <= clrEP2Ready;
511
  clrEP3ReadySTB <= clrEP3Ready;
512
  EP0StatusRegSTB <= EP0StatusReg;
513
  EP1StatusRegSTB <= EP1StatusReg;
514
  EP2StatusRegSTB <= EP2StatusReg;
515
  EP3StatusRegSTB <= EP3StatusReg;
516
  endP0TransTypeRegSTB <= endP0TransTypeReg;
517
  endP1TransTypeRegSTB <= endP1TransTypeReg;
518
  endP2TransTypeRegSTB <= endP2TransTypeReg;
519
  endP3TransTypeRegSTB <= endP3TransTypeReg;
520
  endP0NAKTransTypeRegSTB <= endP0NAKTransTypeReg;
521
  endP1NAKTransTypeRegSTB <= endP1NAKTransTypeReg;
522
  endP2NAKTransTypeRegSTB <= endP2NAKTransTypeReg;
523
  endP3NAKTransTypeRegSTB <= endP3NAKTransTypeReg;
524
  frameNumSTB <= frameNum;
525
end
526
 
527
endmodule

powered by: WebSVN 2.1.0

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