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

Subversion Repositories usbhostslave

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

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

powered by: WebSVN 2.1.0

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