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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [usbhostslave/] [wishBoneBI.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
//// wishBoneBI.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_wishbonebus_h.v"
46
 
47
 
48
module wishBoneBI (
49
  address, dataIn, dataOut, writeEn,
50
  strobe_i,
51
  ack_o,
52
  clk, rst,
53
  hostControlSel,
54
  hostRxFifoSel, hostTxFifoSel,
55
  slaveControlSel,
56
  slaveEP0RxFifoSel, slaveEP1RxFifoSel, slaveEP2RxFifoSel, slaveEP3RxFifoSel,
57
  slaveEP0TxFifoSel, slaveEP1TxFifoSel, slaveEP2TxFifoSel, slaveEP3TxFifoSel,
58
  hostSlaveMuxSel,
59
  dataFromHostControl,
60
  dataFromHostRxFifo,
61
  dataFromHostTxFifo,
62
  dataFromSlaveControl,
63
  dataFromEP0RxFifo, dataFromEP1RxFifo, dataFromEP2RxFifo, dataFromEP3RxFifo,
64
  dataFromEP0TxFifo, dataFromEP1TxFifo, dataFromEP2TxFifo, dataFromEP3TxFifo,
65
  dataFromHostSlaveMux
66
   );
67
input clk;
68
input rst;
69
input [7:0] address;
70
input [7:0] dataIn;
71
output [7:0] dataOut;
72
input strobe_i;
73
output ack_o;
74
input writeEn;
75
output hostControlSel;
76
output hostRxFifoSel;
77
output hostTxFifoSel;
78
output slaveControlSel;
79
output slaveEP0RxFifoSel, slaveEP1RxFifoSel, slaveEP2RxFifoSel, slaveEP3RxFifoSel;
80
output slaveEP0TxFifoSel, slaveEP1TxFifoSel, slaveEP2TxFifoSel, slaveEP3TxFifoSel;
81
output hostSlaveMuxSel;
82
input [7:0] dataFromHostControl;
83
input [7:0] dataFromHostRxFifo;
84
input [7:0] dataFromHostTxFifo;
85
input [7:0] dataFromSlaveControl;
86
input [7:0] dataFromEP0RxFifo, dataFromEP1RxFifo, dataFromEP2RxFifo, dataFromEP3RxFifo;
87
input [7:0] dataFromEP0TxFifo, dataFromEP1TxFifo, dataFromEP2TxFifo, dataFromEP3TxFifo;
88
input [7:0] dataFromHostSlaveMux;
89
 
90
 
91
wire clk;
92
wire rst;
93
wire [7:0] address;
94
wire [7:0] dataIn;
95
reg [7:0] dataOut;
96
wire writeEn;
97
wire strobe_i;
98
reg ack_o;
99
reg hostControlSel;
100
reg hostRxFifoSel;
101
reg hostTxFifoSel;
102
reg slaveControlSel;
103
reg slaveEP0RxFifoSel, slaveEP1RxFifoSel, slaveEP2RxFifoSel, slaveEP3RxFifoSel;
104
reg slaveEP0TxFifoSel, slaveEP1TxFifoSel, slaveEP2TxFifoSel, slaveEP3TxFifoSel;
105
reg hostSlaveMuxSel;
106
wire [7:0] dataFromHostControl;
107
wire [7:0] dataFromHostRxFifo;
108
wire [7:0] dataFromHostTxFifo;
109
wire [7:0] dataFromSlaveControl;
110
wire [7:0] dataFromEP0RxFifo, dataFromEP1RxFifo, dataFromEP2RxFifo, dataFromEP3RxFifo;
111
wire [7:0] dataFromEP0TxFifo, dataFromEP1TxFifo, dataFromEP2TxFifo, dataFromEP3TxFifo;
112
wire [7:0] dataFromHostSlaveMux;
113
 
114
//internal wires and regs
115
reg ack_delayed;
116
reg ack_immediate;
117
 
118
//address decode and data mux
119
always @(address or
120
  dataFromHostControl or
121
  dataFromHostRxFifo or
122
  dataFromHostTxFifo or
123
  dataFromSlaveControl or
124
  dataFromEP0RxFifo or
125
  dataFromEP1RxFifo or
126
  dataFromEP2RxFifo or
127
  dataFromEP3RxFifo or
128
  dataFromHostSlaveMux or
129
  dataFromEP0TxFifo or
130
  dataFromEP1TxFifo or
131
  dataFromEP2TxFifo or
132
  dataFromEP3TxFifo)
133
begin
134
  hostControlSel <= 1'b0;
135
  hostRxFifoSel <= 1'b0;
136
  hostTxFifoSel <= 1'b0;
137
  slaveControlSel <= 1'b0;
138
  slaveEP0RxFifoSel <= 1'b0;
139
  slaveEP0TxFifoSel <= 1'b0;
140
  slaveEP1RxFifoSel <= 1'b0;
141
  slaveEP1TxFifoSel <= 1'b0;
142
  slaveEP2RxFifoSel <= 1'b0;
143
  slaveEP2TxFifoSel <= 1'b0;
144
  slaveEP3RxFifoSel <= 1'b0;
145
  slaveEP3TxFifoSel <= 1'b0;
146
  hostSlaveMuxSel <= 1'b0;
147
  case (address & `ADDRESS_DECODE_MASK)
148
    `HCREG_BASE : begin
149
      hostControlSel <= 1'b1;
150
      dataOut <= dataFromHostControl;
151
    end
152
    `HCREG_BASE_PLUS_0X10 : begin
153
      hostControlSel <= 1'b1;
154
      dataOut <= dataFromHostControl;
155
    end
156
    `HOST_RX_FIFO_BASE : begin
157
      hostRxFifoSel <= 1'b1;
158
      dataOut <= dataFromHostRxFifo;
159
    end
160
    `HOST_TX_FIFO_BASE : begin
161
      hostTxFifoSel <= 1'b1;
162
      dataOut <= dataFromHostTxFifo;
163
    end
164
    `SCREG_BASE : begin
165
      slaveControlSel <= 1'b1;
166
      dataOut <= dataFromSlaveControl;
167
    end
168
    `SCREG_BASE_PLUS_0X10 : begin
169
      slaveControlSel <= 1'b1;
170
      dataOut <= dataFromSlaveControl;
171
    end
172
    `EP0_RX_FIFO_BASE : begin
173
      slaveEP0RxFifoSel <= 1'b1;
174
      dataOut <= dataFromEP0RxFifo;
175
    end
176
    `EP0_TX_FIFO_BASE : begin
177
      slaveEP0TxFifoSel <= 1'b1;
178
      dataOut <= dataFromEP0TxFifo;
179
    end
180
    `EP1_RX_FIFO_BASE : begin
181
      slaveEP1RxFifoSel <= 1'b1;
182
      dataOut <= dataFromEP1RxFifo;
183
    end
184
    `EP1_TX_FIFO_BASE : begin
185
      slaveEP1TxFifoSel <= 1'b1;
186
      dataOut <= dataFromEP1TxFifo;
187
    end
188
    `EP2_RX_FIFO_BASE : begin
189
      slaveEP2RxFifoSel <= 1'b1;
190
      dataOut <= dataFromEP2RxFifo;
191
    end
192
    `EP2_TX_FIFO_BASE : begin
193
      slaveEP2TxFifoSel <= 1'b1;
194
      dataOut <= dataFromEP2TxFifo;
195
    end
196
    `EP3_RX_FIFO_BASE : begin
197
      slaveEP3RxFifoSel <= 1'b1;
198
      dataOut <= dataFromEP3RxFifo;
199
    end
200
    `EP3_TX_FIFO_BASE : begin
201
      slaveEP3TxFifoSel <= 1'b1;
202
      dataOut <= dataFromEP3TxFifo;
203
    end
204
    `HOST_SLAVE_CONTROL_BASE : begin
205
      hostSlaveMuxSel <= 1'b1;
206
      dataOut <= dataFromHostSlaveMux;
207
    end
208
    default:
209
      dataOut <= 8'h00;
210
  endcase
211
end
212
 
213
//delayed ack
214
always @(posedge clk) begin
215
  ack_delayed <= strobe_i;
216
end
217
 
218
//immediate ack
219
always @(strobe_i) begin
220
  ack_immediate <= strobe_i;
221
end
222
 
223
//select between immediate and delayed ack
224
always @(writeEn or address or ack_delayed or ack_immediate) begin
225
  if (writeEn == 1'b0 &&
226
      (address == `HOST_RX_FIFO_BASE + `FIFO_DATA_REG ||
227
       address == `HOST_TX_FIFO_BASE + `FIFO_DATA_REG ||
228
       address == `EP0_RX_FIFO_BASE + `FIFO_DATA_REG ||
229
       address == `EP0_TX_FIFO_BASE + `FIFO_DATA_REG ||
230
       address == `EP1_RX_FIFO_BASE + `FIFO_DATA_REG ||
231
       address == `EP1_TX_FIFO_BASE + `FIFO_DATA_REG ||
232
       address == `EP2_RX_FIFO_BASE + `FIFO_DATA_REG ||
233
       address == `EP2_TX_FIFO_BASE + `FIFO_DATA_REG ||
234
       address == `EP3_RX_FIFO_BASE + `FIFO_DATA_REG ||
235
       address == `EP3_TX_FIFO_BASE + `FIFO_DATA_REG) )
236
  begin
237
    ack_o <= ack_delayed & ack_immediate;
238
  end
239
  else
240
  begin
241
    ack_o <= ack_immediate;
242
  end
243
end
244
 
245
endmodule

powered by: WebSVN 2.1.0

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