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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [tags/] [rel_00_06_alpha/] [RTL/] [slaveController/] [endpMux.v] - Blame information for rev 2

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

powered by: WebSVN 2.1.0

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