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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [usbhostslave/] [endpMux.v] - Blame information for rev 584

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

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

powered by: WebSVN 2.1.0

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