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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [hostController/] [USBHostControlBI.v] - Blame information for rev 14

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

Line No. Rev Author Line
1 2 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// USBHostControlBI.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 9 sfielding
 
47 2 sfielding
`include "usbHostControl_h.v"
48
 
49
module USBHostControlBI (address, dataIn, dataOut, writeEn,
50
  strobe_i,
51
  clk, rst,
52 5 sfielding
  SOFSentIntOut, connEventIntOut, resumeIntOut, transDoneIntOut,
53
  TxTransTypeReg, TxSOFEnableReg,
54
  TxAddrReg, TxEndPReg, frameNumIn,
55
  RxPktStatusIn, RxPIDIn,
56
  connectStateIn,
57
  SOFSentIn, connEventIn, resumeIntIn, transDoneIn,
58 2 sfielding
  hostControlSelect,
59
  clrTransReq,
60
  preambleEn,
61
  SOFSync,
62
  TxLineState,
63
  LineDirectControlEn,
64
  fullSpeedPol,
65
  fullSpeedRate,
66 14 sfielding
  transReq,
67
  isoEn
68 2 sfielding
  );
69
input [3:0] address;
70
input [7:0] dataIn;
71
input writeEn;
72
input strobe_i;
73
input clk;
74
input rst;
75
output [7:0] dataOut;
76
output SOFSentIntOut;
77
output connEventIntOut;
78
output resumeIntOut;
79
output transDoneIntOut;
80
 
81
output [1:0] TxTransTypeReg;
82
output TxSOFEnableReg;
83
output [6:0] TxAddrReg;
84
output [3:0] TxEndPReg;
85
input [10:0] frameNumIn;
86
input [7:0] RxPktStatusIn;
87
input [3:0] RxPIDIn;
88
input [1:0] connectStateIn;
89
input SOFSentIn;
90
input connEventIn;
91
input resumeIntIn;
92
input transDoneIn;
93
input hostControlSelect;
94
input clrTransReq;
95
output preambleEn;
96
output SOFSync;
97
output [1:0] TxLineState;
98
output LineDirectControlEn;
99
output fullSpeedPol;
100
output fullSpeedRate;
101
output transReq;
102 14 sfielding
output isoEn;     //enable isochronous mode
103 2 sfielding
 
104
wire [3:0] address;
105
wire [7:0] dataIn;
106
wire writeEn;
107
wire strobe_i;
108
wire clk;
109
wire rst;
110
reg [7:0] dataOut;
111
 
112
reg SOFSentIntOut;
113
reg connEventIntOut;
114
reg resumeIntOut;
115
reg transDoneIntOut;
116
 
117
reg [1:0] TxTransTypeReg;
118
reg TxSOFEnableReg;
119
reg [6:0] TxAddrReg;
120
reg [3:0] TxEndPReg;
121
wire [10:0] frameNumIn;
122
wire [7:0] RxPktStatusIn;
123
wire [3:0] RxPIDIn;
124
wire [1:0] connectStateIn;
125
 
126
wire SOFSentIn;
127
wire connEventIn;
128
wire resumeIntIn;
129
wire transDoneIn;
130
wire hostControlSelect;
131
wire clrTransReq;
132
reg preambleEn;
133
reg SOFSync;
134
reg [1:0] TxLineState;
135
reg LineDirectControlEn;
136
reg fullSpeedPol;
137
reg fullSpeedRate;
138
reg transReq;
139 14 sfielding
reg isoEn;
140 2 sfielding
 
141
//internal wire and regs
142
reg [1:0] TxControlReg;
143
reg [4:0] TxLineControlReg;
144
reg clrSOFReq;
145
reg clrConnEvtReq;
146
reg clrResInReq;
147
reg clrTransDoneReq;
148
reg SOFSentInt;
149
reg connEventInt;
150
reg resumeInt;
151
reg transDoneInt;
152
reg [3:0] interruptMaskReg;
153
reg setTransReq;
154
 
155
//sync write demux
156
always @(posedge clk)
157
begin
158 14 sfielding
  if (rst == 1'b1) begin
159
    isoEn <= 1'b0;
160
    preambleEn <= 1'b0;
161
    SOFSync <= 1'b0;
162
    TxTransTypeReg <= 2'b00;
163
    TxLineControlReg <= 5'h00;
164
    TxSOFEnableReg <= 1'b0;
165
    TxAddrReg <= 7'h00;
166
    TxEndPReg <= 4'h0;
167
    interruptMaskReg <= 4'h0;
168 5 sfielding
  end
169 14 sfielding
  else begin
170
    clrSOFReq <= 1'b0;
171
    clrConnEvtReq <= 1'b0;
172
    clrResInReq <= 1'b0;
173
    clrTransDoneReq <= 1'b0;
174
    setTransReq <= 1'b0;
175
    if (writeEn == 1'b1 && strobe_i == 1'b1 && hostControlSelect == 1'b1)
176
    begin
177
      case (address)
178
        `TX_CONTROL_REG : begin
179
          isoEn <= dataIn[`ISO_ENABLE_BIT];
180
          preambleEn <= dataIn[`PREAMBLE_ENABLE_BIT];
181
          SOFSync <= dataIn[`SOF_SYNC_BIT];
182
          setTransReq <= dataIn[`TRANS_REQ_BIT];
183
        end
184
        `TX_TRANS_TYPE_REG : TxTransTypeReg <= dataIn[1:0];
185
        `TX_LINE_CONTROL_REG : TxLineControlReg <= dataIn[4:0];
186
        `TX_SOF_ENABLE_REG : TxSOFEnableReg <= dataIn[`SOF_EN_BIT];
187
        `TX_ADDR_REG : TxAddrReg <= dataIn[6:0];
188
        `TX_ENDP_REG : TxEndPReg <= dataIn[3:0];
189
        `INTERRUPT_STATUS_REG :  begin
190
          clrSOFReq <= dataIn[`SOF_SENT_BIT];
191
          clrConnEvtReq <= dataIn[`CONNECTION_EVENT_BIT];
192
          clrResInReq <= dataIn[`RESUME_INT_BIT];
193
          clrTransDoneReq <= dataIn[`TRANS_DONE_BIT];
194
        end
195
        `INTERRUPT_MASK_REG  : interruptMaskReg <= dataIn[3:0];
196
      endcase
197
    end
198
  end
199 2 sfielding
end
200
 
201
//interrupt control
202
always @(posedge clk)
203
begin
204 14 sfielding
  if (rst == 1'b1) begin
205 5 sfielding
    SOFSentInt <= 1'b0;
206
    connEventInt <= 1'b0;
207 14 sfielding
    resumeInt <= 1'b0;
208
    transDoneInt <= 1'b0;
209
  end
210
  else begin
211
    if (SOFSentIn == 1'b1)
212
      SOFSentInt <= 1'b1;
213
    else if (clrSOFReq == 1'b1)
214
      SOFSentInt <= 1'b0;
215 5 sfielding
 
216 14 sfielding
    if (connEventIn == 1'b1)
217
      connEventInt <= 1'b1;
218
    else if (clrConnEvtReq == 1'b1)
219
      connEventInt <= 1'b0;
220
 
221
    if (resumeIntIn == 1'b1)
222
      resumeInt <= 1'b1;
223
    else if (clrResInReq == 1'b1)
224
      resumeInt <= 1'b0;
225 2 sfielding
 
226 14 sfielding
    if (transDoneIn == 1'b1)
227
      transDoneInt <= 1'b1;
228
    else if (clrTransDoneReq == 1'b1)
229
      transDoneInt <= 1'b0;
230
  end
231 2 sfielding
end
232
 
233
//mask interrupts
234
always @(interruptMaskReg or transDoneInt or resumeInt or connEventInt or SOFSentInt) begin
235
  transDoneIntOut <= transDoneInt & interruptMaskReg[`TRANS_DONE_BIT];
236
  resumeIntOut <= resumeInt & interruptMaskReg[`RESUME_INT_BIT];
237
  connEventIntOut <= connEventInt & interruptMaskReg[`CONNECTION_EVENT_BIT];
238
  SOFSentIntOut <= SOFSentInt & interruptMaskReg[`SOF_SENT_BIT];
239
end
240
 
241
//transaction request set/clear
242
always @(posedge clk)
243
begin
244 14 sfielding
  if (rst == 1'b1) begin
245 5 sfielding
    transReq <= 1'b0;
246 14 sfielding
  end
247
  else begin
248
    if (setTransReq == 1'b1)
249
      transReq <= 1'b1;
250
    else if (clrTransReq == 1'b1)
251
      transReq <= 1'b0;
252
  end
253 2 sfielding
end
254
 
255
//break out control signals
256
always @(TxControlReg or TxLineControlReg) begin
257
  TxLineState <= TxLineControlReg[`TX_LINE_STATE_MSBIT:`TX_LINE_STATE_LSBIT];
258
  LineDirectControlEn <= TxLineControlReg[`DIRECT_CONTROL_BIT];
259
  fullSpeedPol <= TxLineControlReg[`FULL_SPEED_LINE_POLARITY_BIT];
260
  fullSpeedRate <= TxLineControlReg[`FULL_SPEED_LINE_RATE_BIT];
261
end
262
 
263
// async read mux
264
always @(address or
265 5 sfielding
  TxControlReg or TxTransTypeReg or TxLineControlReg or TxSOFEnableReg or
266
  TxAddrReg or TxEndPReg or frameNumIn or
267
  SOFSentInt or connEventInt or resumeInt or transDoneInt or
268
  interruptMaskReg or RxPktStatusIn or RxPIDIn or connectStateIn or
269 14 sfielding
  preambleEn or SOFSync or transReq or isoEn)
270 2 sfielding
begin
271 5 sfielding
  case (address)
272 14 sfielding
      `TX_CONTROL_REG : dataOut <= {4'b0000, isoEn, preambleEn, SOFSync, transReq} ;
273 5 sfielding
      `TX_TRANS_TYPE_REG : dataOut <= {6'b000000, TxTransTypeReg};
274
      `TX_LINE_CONTROL_REG : dataOut <= {3'b000, TxLineControlReg};
275
      `TX_SOF_ENABLE_REG : dataOut <= {7'b0000000, TxSOFEnableReg};
276
      `TX_ADDR_REG : dataOut <= {1'b0, TxAddrReg};
277
      `TX_ENDP_REG : dataOut <= {4'h0, TxEndPReg};
278 12 sfielding
      `FRAME_NUM_MSB_REG : dataOut <= {5'b00000, frameNumIn[10:8]};
279
      `FRAME_NUM_LSB_REG : dataOut <= frameNumIn[7:0];
280 5 sfielding
      `INTERRUPT_STATUS_REG :  dataOut <= {4'h0, SOFSentInt, connEventInt, resumeInt, transDoneInt};
281
      `INTERRUPT_MASK_REG  : dataOut <= {4'h0, interruptMaskReg};
282
      `RX_STATUS_REG  : dataOut <= RxPktStatusIn;
283
      `RX_PID_REG  : dataOut <= {4'b0000, RxPIDIn};
284
      `RX_CONNECT_STATE_REG : dataOut <= {6'b000000, connectStateIn};
285 2 sfielding
      default: dataOut <= 8'h00;
286 5 sfielding
  endcase
287 2 sfielding
end
288
 
289
 
290
endmodule

powered by: WebSVN 2.1.0

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