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

Subversion Repositories usbhostslave

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

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