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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [tags/] [rel_00_04_alpha/] [RTL/] [hostController/] [USBHostControlBI.v] - Blame information for rev 43

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

powered by: WebSVN 2.1.0

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