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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [slaveController/] [endpMux.v] - Blame information for rev 5

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

Line No. Rev Author Line
1 2 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// endpMux.v                                                    ////
4
////                                                              ////
5
//// This file is part of the usbhostslave opencores effort.
6
//// <http://www.opencores.org/cores//>                           ////
7
////                                                              ////
8
//// Module Description:                                          ////
9
//// 
10
////                                                              ////
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 5 sfielding
// $Id: endpMux.v,v 1.2 2004-12-18 14:36:18 sfielding Exp $
45 2 sfielding
//
46
// CVS Revision History
47
//
48
// $Log: not supported by cvs2svn $
49 5 sfielding
// Revision 1.1.1.1  2004/10/11 04:01:05  sfielding
50
// Created
51 2 sfielding
//
52 5 sfielding
//
53 2 sfielding
 
54
`include "usbSlaveControl_h.v"
55
 
56
module endpMux (
57
  clk,
58
  rst,
59
  currEndP,
60
  NAKSent,
61
  stallSent,
62
  CRCError,
63
  bitStuffError,
64
  RxOverflow,
65
  RxTimeOut,
66
  dataSequence,
67
  ACKRxed,
68
  transType,
69
  transTypeNAK,
70
  endPControlReg,
71
  clrEPRdy,
72
  endPMuxErrorsWEn,
73
  endP0ControlReg,
74
  endP1ControlReg,
75
  endP2ControlReg,
76
  endP3ControlReg,
77
  endP0StatusReg,
78
  endP1StatusReg,
79
  endP2StatusReg,
80
  endP3StatusReg,
81
  endP0TransTypeReg,
82
  endP1TransTypeReg,
83
  endP2TransTypeReg,
84
  endP3TransTypeReg,
85
  endP0NAKTransTypeReg,
86
  endP1NAKTransTypeReg,
87
  endP2NAKTransTypeReg,
88
  endP3NAKTransTypeReg,
89
  clrEP0Rdy,
90
  clrEP1Rdy,
91
  clrEP2Rdy,
92
  clrEP3Rdy);
93
 
94
 
95
input clk;
96
input rst;
97
input [3:0] currEndP;
98
input NAKSent;
99
input stallSent;
100
input CRCError;
101
input bitStuffError;
102
input RxOverflow;
103
input RxTimeOut;
104
input dataSequence;
105
input ACKRxed;
106
input [1:0] transType;
107
input [1:0] transTypeNAK;
108
output [3:0] endPControlReg;
109
input clrEPRdy;
110
input endPMuxErrorsWEn;
111
input [3:0] endP0ControlReg;
112
input [3:0] endP1ControlReg;
113
input [3:0] endP2ControlReg;
114
input [3:0] endP3ControlReg;
115
output [7:0] endP0StatusReg;
116
output [7:0] endP1StatusReg;
117
output [7:0] endP2StatusReg;
118
output [7:0] endP3StatusReg;
119
output [1:0] endP0TransTypeReg;
120
output [1:0] endP1TransTypeReg;
121
output [1:0] endP2TransTypeReg;
122
output [1:0] endP3TransTypeReg;
123
output [1:0] endP0NAKTransTypeReg;
124
output [1:0] endP1NAKTransTypeReg;
125
output [1:0] endP2NAKTransTypeReg;
126
output [1:0] endP3NAKTransTypeReg;
127
output clrEP0Rdy;
128
output clrEP1Rdy;
129
output clrEP2Rdy;
130
output clrEP3Rdy;
131
 
132
wire clk;
133
wire rst;
134
wire [3:0] currEndP;
135
wire NAKSent;
136
wire stallSent;
137
wire CRCError;
138
wire bitStuffError;
139
wire RxOverflow;
140
wire RxTimeOut;
141
wire dataSequence;
142
wire ACKRxed;
143
wire [1:0] transType;
144
wire [1:0] transTypeNAK;
145
reg [3:0] endPControlReg;
146
wire clrEPRdy;
147
wire endPMuxErrorsWEn;
148
wire [3:0] endP0ControlReg;
149
wire [3:0] endP1ControlReg;
150
wire [3:0] endP2ControlReg;
151
wire [3:0] endP3ControlReg;
152
reg [7:0] endP0StatusReg;
153
reg [7:0] endP1StatusReg;
154
reg [7:0] endP2StatusReg;
155
reg [7:0] endP3StatusReg;
156
reg [1:0] endP0TransTypeReg;
157
reg [1:0] endP1TransTypeReg;
158
reg [1:0] endP2TransTypeReg;
159
reg [1:0] endP3TransTypeReg;
160
reg [1:0] endP0NAKTransTypeReg;
161
reg [1:0] endP1NAKTransTypeReg;
162
reg [1:0] endP2NAKTransTypeReg;
163
reg [1:0] endP3NAKTransTypeReg;
164
reg clrEP0Rdy;
165
reg clrEP1Rdy;
166
reg clrEP2Rdy;
167
reg clrEP3Rdy;
168
 
169
//internal wires and regs
170
reg [7:0] endPStatusCombine;
171
 
172
//mux endPControlReg and clrEPRdy
173
always @(posedge clk)
174
begin
175
  case (currEndP[1:0])
176
    2'b00: begin
177
      endPControlReg <= endP0ControlReg;
178
      clrEP0Rdy <= clrEPRdy;
179
    end
180
    2'b01: begin
181
      endPControlReg <= endP1ControlReg;
182
      clrEP1Rdy <= clrEPRdy;
183
    end
184
    2'b10: begin
185
      endPControlReg <= endP2ControlReg;
186
      clrEP2Rdy <= clrEPRdy;
187
    end
188
    2'b11: begin
189
      endPControlReg <= endP3ControlReg;
190
      clrEP3Rdy <= clrEPRdy;
191
    end
192
  endcase
193
end
194
 
195
//mux endPNAKTransType, endPTransType, endPStatusReg
196
//If there was a NAK sent then set the NAKSent bit, and leave the other status reg bits untouched.
197
//else update the entire status reg
198
always @(posedge clk)
199
begin
200
  if (rst) begin
201
    endP0NAKTransTypeReg <= 2'b00;
202
    endP1NAKTransTypeReg <= 2'b00;
203
    endP2NAKTransTypeReg <= 2'b00;
204
    endP3NAKTransTypeReg <= 2'b00;
205
    endP0TransTypeReg <= 2'b00;
206
    endP1TransTypeReg <= 2'b00;
207
    endP2TransTypeReg <= 2'b00;
208
    endP3TransTypeReg <= 2'b00;
209
    endP0StatusReg <= 4'h0;
210
    endP1StatusReg <= 4'h0;
211
    endP2StatusReg <= 4'h0;
212
    endP3StatusReg <= 4'h0;
213
  end
214
  else begin
215
    if (endPMuxErrorsWEn == 1'b1) begin
216
      if (NAKSent == 1'b1) begin
217
        case (currEndP[1:0])
218
          2'b00: begin
219
            endP0NAKTransTypeReg <= transTypeNAK;
220
            endP0StatusReg <= endP0StatusReg | `NAK_SET_MASK;
221
          end
222
          2'b01: begin
223
            endP1NAKTransTypeReg <= transTypeNAK;
224
            endP1StatusReg <= endP1StatusReg | `NAK_SET_MASK;
225
          end
226
          2'b10: begin
227
            endP2NAKTransTypeReg <= transTypeNAK;
228
            endP2StatusReg <= endP2StatusReg | `NAK_SET_MASK;
229
          end
230
          2'b11: begin
231
            endP3NAKTransTypeReg <= transTypeNAK;
232
            endP3StatusReg <= endP3StatusReg | `NAK_SET_MASK;
233
          end
234
        endcase
235
      end
236
      else begin
237
        case (currEndP[1:0])
238
          2'b00: begin
239
            endP0TransTypeReg <= transType;
240
            endP0StatusReg <= endPStatusCombine;
241
          end
242
          2'b01: begin
243
            endP1TransTypeReg <= transType;
244
            endP1StatusReg <= endPStatusCombine;
245
          end
246
          2'b10: begin
247
            endP2TransTypeReg <= transType;
248
            endP2StatusReg <= endPStatusCombine;
249
          end
250
          2'b11: begin
251
            endP3TransTypeReg <= transType;
252
            endP3StatusReg <= endPStatusCombine;
253
          end
254
        endcase
255
      end
256
    end
257
  end
258
end
259
 
260
 
261
//combine status bits into a single word
262
always @(dataSequence or ACKRxed or stallSent or RxTimeOut or RxOverflow or bitStuffError or CRCError)
263
begin
264
  endPStatusCombine <= {dataSequence, ACKRxed, stallSent, 1'b0, RxTimeOut, RxOverflow, bitStuffError, CRCError};
265
end
266
 
267
 
268
endmodule

powered by: WebSVN 2.1.0

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