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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [usbDevice/] [RTL/] [wishboneArb.v] - Blame information for rev 43

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

Line No. Rev Author Line
1 37 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// wishboneArb.v                                                 ////
4
////                                                              ////
5
//// This file is part of the usbHostSlave opencores effort.
6
//// <http://www.opencores.org/cores//>                           ////
7
////                                                              ////
8
//// Module Description:                                          ////
9
//// Arbitrate between 3 wishbone bus controllers
10
//// Uses Round Robin access controller
11
//// 
12
////
13
////                                                              ////
14
//// To Do:                                                       ////
15
//// 
16
////                                                              ////
17
//// Author(s):                                                   ////
18
//// - Steve Fielding, sfielding@base2designs.com                 ////
19
////                                                              ////
20
//////////////////////////////////////////////////////////////////////
21
////                                                              ////
22
//// Copyright (C) 2008 Steve Fielding and OPENCORES.ORG          ////
23
////                                                              ////
24
//// This source file may be used and distributed without         ////
25
//// restriction provided that this copyright statement is not    ////
26
//// removed from the file and that any derivative work contains  ////
27
//// the original copyright notice and the associated disclaimer. ////
28
////                                                              ////
29
//// This source file is free software; you can redistribute it   ////
30
//// and/or modify it under the terms of the GNU Lesser General   ////
31
//// Public License as published by the Free Software Foundation; ////
32
//// either version 2.1 of the License, or (at your option) any   ////
33
//// later version.                                               ////
34
////                                                              ////
35
//// This source is distributed in the hope that it will be       ////
36
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
37
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
38
//// PURPOSE. See the GNU Lesser General Public License for more  ////
39
//// details.                                                     ////
40
////                                                              ////
41
//// You should have received a copy of the GNU Lesser General    ////
42
//// Public License along with this source; if not, download it   ////
43
//// from <http://www.opencores.org/lgpl.shtml>                   ////
44
////                                                              ////
45
//////////////////////////////////////////////////////////////////////
46
//
47
module wishboneArb (
48
  clk,
49
  rst,
50
 
51
  addr0_i,
52
  data0_i,
53
  stb0_i,
54
  we0_i,
55
  req0,
56
  gnt0,
57
 
58
  addr1_i,
59
  data1_i,
60
  stb1_i,
61
  we1_i,
62
  req1,
63
  gnt1,
64
 
65
  addr2_i,
66
  data2_i,
67
  stb2_i,
68
  we2_i,
69
  req2,
70
  gnt2,
71
 
72
 
73
  addr_o,
74
  data_o,
75
  stb_o,
76
  we_o
77
);
78
 
79
input clk;
80
input rst;
81
 
82
input [7:0] addr0_i;
83
input [7:0] data0_i;
84
input stb0_i;
85
input we0_i;
86
input req0;
87
output gnt0;
88
reg gnt0;
89
 
90
input [7:0] addr1_i;
91
input [7:0] data1_i;
92
input stb1_i;
93
input we1_i;
94
input req1;
95
output gnt1;
96
reg gnt1;
97
 
98
input [7:0] addr2_i;
99
input [7:0] data2_i;
100
input stb2_i;
101
input we2_i;
102
input req2;
103
output gnt2;
104
reg gnt2;
105
 
106
 
107
output [7:0] addr_o;
108
reg [7:0] addr_o;
109
output [7:0] data_o;
110
reg [7:0] data_o;
111
output stb_o;
112
reg stb_o;
113
output we_o;
114
reg we_o;
115
 
116
//local wires and regs
117
reg [1:0] muxSel;
118
reg [2:0] arbSt;
119
 
120
`define REQ_0 3'b000
121
`define REQ_1 3'b001
122
`define REQ_2 3'b010
123
`define GNT_0 3'b011
124
`define GNT_1 3'b100
125
`define GNT_2 3'b101
126
 
127
 
128
//arb
129
always @(posedge clk) begin
130
  if (rst == 1'b1) begin
131
    gnt0 <= 1'b0;
132
    gnt1 <= 1'b0;
133
    gnt2 <= 1'b0;
134
    muxSel <= 2'b00;
135
    arbSt <= `REQ_0;
136
  end
137
  else begin
138
    case (arbSt)
139
      `REQ_0: begin
140
        if (req0 == 1'b1)
141
          arbSt <= `GNT_0;
142
        else
143
          arbSt <= `REQ_1;
144
      end
145
      `REQ_1: begin
146
        if (req1 == 1'b1)
147
          arbSt <= `GNT_1;
148
        else
149
          arbSt <= `REQ_2;
150
      end
151
      `REQ_2: begin
152
        if (req2 == 1'b1)
153
          arbSt <= `GNT_2;
154
        else
155
          arbSt <= `REQ_0;
156
      end
157
      `GNT_0: begin
158
        gnt0 <= 1'b1;
159
        muxSel <= 2'b00;
160
        if (req0 == 1'b0) begin
161
          arbSt <= `REQ_1;
162
          gnt0 <= 1'b0;
163
        end
164
      end
165
      `GNT_1: begin
166
        gnt1 <= 1'b1;
167
        muxSel <= 2'b01;
168
        if (req1 == 1'b0) begin
169
          arbSt <= `REQ_2;
170
          gnt1 <= 1'b0;
171
        end
172
      end
173
      `GNT_2: begin
174
        gnt2 <= 1'b1;
175
        muxSel <= 2'b10;
176
        if (req2 == 1'b0) begin
177
          arbSt <= `REQ_0;
178
          gnt2 <= 1'b0;
179
        end
180
      end
181
    endcase
182
  end
183
end
184
 
185
 
186
//mux
187
always @(*) begin
188
  case (muxSel)
189
    2'b00: begin
190
      addr_o <= addr0_i;
191
      data_o <= data0_i;
192
      stb_o <= stb0_i;
193
      we_o <= we0_i;
194
    end
195
    2'b01: begin
196
      addr_o <= addr1_i;
197
      data_o <= data1_i;
198
      stb_o <= stb1_i;
199
      we_o <= we1_i;
200
    end
201
    2'b10: begin
202
      addr_o <= addr2_i;
203
      data_o <= data2_i;
204
      stb_o <= stb2_i;
205
      we_o <= we2_i;
206
    end
207
    default: begin
208
      addr_o <= addr0_i;
209
      data_o <= data0_i;
210
      stb_o <= stb0_i;
211
      we_o <= we0_i;
212
    end
213
  endcase
214
end
215
 
216
 
217
endmodule
218
 

powered by: WebSVN 2.1.0

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