Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: dmu_imu_gcs_arb.v | |
4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | // | |
7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | // | |
9 | // This program is free software; you can redistribute it and/or modify | |
10 | // it under the terms of the GNU General Public License as published by | |
11 | // the Free Software Foundation; version 2 of the License. | |
12 | // | |
13 | // This program is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License | |
19 | // along with this program; if not, write to the Free Software | |
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | // | |
22 | // For the avoidance of doubt, and except that if any non-GPL license | |
23 | // choice is available it will apply instead, Sun elects to use only | |
24 | // the General Public License version 2 (GPLv2) at this time for any | |
25 | // software where a choice of GPL license versions is made | |
26 | // available with the language indicating that GPLv2 or any later version | |
27 | // may be used, or where a choice of which version of the GPL is applied is | |
28 | // otherwise unspecified. | |
29 | // | |
30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | // CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | // have any questions. | |
33 | // | |
34 | // ========== Copyright Header End ============================================ | |
35 | module dmu_imu_gcs_arb ( | |
36 | ||
37 | // Clock and Reset | |
38 | ||
39 | clk, | |
40 | rst_l, | |
41 | ||
42 | // Group 0 Req/Gnt Interface | |
43 | ||
44 | gc_0_req, | |
45 | gc_0_ino, | |
46 | gc_0_gnt, | |
47 | ||
48 | // Group 1 Req/Gnt Interface | |
49 | ||
50 | gc_1_req, | |
51 | gc_1_ino, | |
52 | gc_1_gnt, | |
53 | ||
54 | // Group 2 Req/Gnt Interface | |
55 | ||
56 | gc_2_req, | |
57 | gc_2_ino, | |
58 | gc_2_gnt, | |
59 | ||
60 | // Group 3 Req/Gnt Interface | |
61 | ||
62 | gc_3_req, | |
63 | gc_3_ino, | |
64 | gc_3_gnt, | |
65 | ||
66 | // Next Arbitration Interface | |
67 | ||
68 | next_arb, | |
69 | ||
70 | // CSM Interface | |
71 | ||
72 | gc_arb_valid, | |
73 | gc_arb_ino, | |
74 | gc_arb_id | |
75 | ||
76 | ); | |
77 | ||
78 | ||
79 | ||
80 | ||
81 | //############################################################################ | |
82 | // PORT DECLARATIONS | |
83 | //############################################################################ | |
84 | ||
85 | //------------------------------------------------------------------------ | |
86 | // Clock and Reset Signals | |
87 | //------------------------------------------------------------------------ | |
88 | ||
89 | input clk; | |
90 | input rst_l; | |
91 | ||
92 | //------------------------------------------------------------------------ | |
93 | // Requests and ack interface to/from the group controllers | |
94 | //------------------------------------------------------------------------ | |
95 | ||
96 | input gc_0_req; // Request Signal from the group controller | |
97 | input [5:0] gc_0_ino; // INO for the corresponding request from the group controller | |
98 | output gc_0_gnt; // grant signal for req for the group controller | |
99 | ||
100 | input gc_1_req; // Request Signal from the group controller | |
101 | input [5:0] gc_1_ino; // INO for the corresponding request from the group controller | |
102 | output gc_1_gnt; // grant signal for req for the group controller | |
103 | ||
104 | input gc_2_req; // Request Signal from the group controller | |
105 | input [5:0] gc_2_ino; // INO for the corresponding request from the group controller | |
106 | output gc_2_gnt; // grant signal for req for the group controller | |
107 | ||
108 | input gc_3_req; // Request Signal from the group controller | |
109 | input [5:0] gc_3_ino; // INO for the corresponding request from the group controller | |
110 | output gc_3_gnt; // grant signal for req for the group controller | |
111 | ||
112 | //------------------------------------------------------------------------ | |
113 | // Signal to do the next arbitration | |
114 | //------------------------------------------------------------------------ | |
115 | ||
116 | input next_arb; // Signal from Central GC FSM to do next arb | |
117 | ||
118 | //------------------------------------------------------------------------ | |
119 | // Interface to the csm with the arbitration winner | |
120 | //------------------------------------------------------------------------ | |
121 | ||
122 | output gc_arb_valid; // Valid signal saying that the arb winner is now valid are ready to be taken | |
123 | output [5:0] gc_arb_ino; // The ino of winner from arbitration; | |
124 | output [1:0] gc_arb_id; // ID of the group controller of the arb winner | |
125 | ||
126 | ||
127 | //############################################################################ | |
128 | // PARAMETERS | |
129 | //############################################################################ | |
130 | parameter IDLE = 2'b00; | |
131 | parameter ARB_GNT = 2'b01; | |
132 | parameter W_4_CSM = 2'b10; | |
133 | ||
134 | ||
135 | ||
136 | //############################################################################ | |
137 | // SIGNAL DECLARATIONS | |
138 | //############################################################################ | |
139 | ||
140 | //------------------------ | |
141 | // Wires | |
142 | //------------------------ | |
143 | wire arb_needed; | |
144 | ||
145 | //------------------------- | |
146 | // Regs that are NOT flops | |
147 | //------------------------- | |
148 | reg [1:0] arb_winner; | |
149 | reg [1:0] n_state; | |
150 | reg [1:0] n_arb_winner; | |
151 | reg [5:0] gc_arb_ino; | |
152 | ||
153 | //------------------------ | |
154 | // Regs that are flops | |
155 | //------------------------ | |
156 | reg [1:0] last_arb_winner; | |
157 | reg [1:0] state; | |
158 | ||
159 | //############################################################################ | |
160 | // ZERO IN CHECKERS | |
161 | //############################################################################ | |
162 | ||
163 | //--------------------------------------------------------------------- | |
164 | // Arbiter Checker | |
165 | //--------------------------------------------------------------------- | |
166 | /* 0in arbiter -req gc_0_req gc_1_req gc_2_req gc_3_req | |
167 | -gnt gc_0_gnt gc_1_gnt gc_2_gnt gc_3_gnt | |
168 | -fair | |
169 | -round_robin | |
170 | -known_grant | |
171 | -req_until_gnt | |
172 | -max_grant 1 | |
173 | -deassert 0 | |
174 | -no_simultaneous_req_gnt | |
175 | ||
176 | */ | |
177 | ||
178 | //--------------------------------------------------------------------- | |
179 | // State Machine Checkers | |
180 | //--------------------------------------------------------------------- | |
181 | //0in state_transition -var state -val IDLE -next ARB_GNT | |
182 | //0in state_transition -var state -val ARB_GNT -next W_4_CSM | |
183 | //0in state_transition -var state -val W_4_CSM -next ARB_GNT IDLE | |
184 | ||
185 | ||
186 | //############################################################################ | |
187 | // COMBINATIONAL LOGIC | |
188 | //############################################################################ | |
189 | ||
190 | ||
191 | //------------------------------------------------------------------- | |
192 | // Signal to tell gc central FSM if there is a request pending | |
193 | // and if arbitration is then needed | |
194 | // | |
195 | // It is an OR of all 4 of the request Signals | |
196 | //------------------------------------------------------------------- | |
197 | assign arb_needed = (gc_0_req | gc_1_req | gc_2_req |gc_3_req); | |
198 | ||
199 | ||
200 | //------------------------------------------------------------------- | |
201 | // Logic to figure out the who the next arbitration winner is | |
202 | // it is based on the last person who one and what the current | |
203 | // req's are. Look first at the last winner then the current reqs | |
204 | // | |
205 | // For example for a last winner of 01 the proper order would then be | |
206 | // 10 2 | |
207 | // 11 3 | |
208 | // 00 0 | |
209 | // 01 1 (parked) | |
210 | // | |
211 | // For the first term, is only set when 2 or 3 is requesting | |
212 | // For the secoond term if 2 is not requesting and 3 or 0 is | |
213 | //------------------------------------------------------------------- | |
214 | ||
215 | always @ (gc_0_req or gc_1_req or gc_2_req or gc_3_req or last_arb_winner) | |
216 | case (last_arb_winner) // synopsys parallel_case full_case infer_mux | |
217 | 2'b00 : arb_winner = {(~gc_1_req&(gc_2_req|gc_3_req)) ,(gc_1_req|(~gc_2_req&gc_3_req))}; | |
218 | 2'b01 : arb_winner = {(gc_2_req|gc_3_req) ,(~gc_2_req&(gc_3_req|~gc_0_req))}; | |
219 | 2'b10 : arb_winner = {(gc_3_req|~(gc_0_req|gc_1_req)) ,(gc_3_req|(~gc_0_req&gc_1_req))}; | |
220 | 2'b11 : arb_winner = {~(gc_0_req|gc_1_req) ,~(gc_0_req|(~gc_1_req&gc_2_req))}; | |
221 | endcase | |
222 | ||
223 | //------------------------------------------------------------------- | |
224 | // Logic to figure out which grant needs to be asserted | |
225 | // - Only assert the GNT when in ARB_GRT state | |
226 | //------------------------------------------------------------------- | |
227 | ||
228 | assign gc_0_gnt = (state == ARB_GNT) & (last_arb_winner == 2'b00); | |
229 | assign gc_1_gnt = (state == ARB_GNT) & (last_arb_winner == 2'b01); | |
230 | assign gc_2_gnt = (state == ARB_GNT) & (last_arb_winner == 2'b10); | |
231 | assign gc_3_gnt = (state == ARB_GNT) & (last_arb_winner == 2'b11); | |
232 | ||
233 | //------------------------------------------------------------------- | |
234 | // Logic for output to CSM | |
235 | // - Only assert valid in W_4_CSM state | |
236 | // - Mux the correct ino from the granted gc to the CSM | |
237 | // - Assign the id to the grated gc | |
238 | //------------------------------------------------------------------- | |
239 | assign gc_arb_valid = (state == W_4_CSM); | |
240 | ||
241 | ||
242 | always @ (gc_0_ino or gc_1_ino or gc_2_ino or gc_3_ino or last_arb_winner) | |
243 | case (last_arb_winner) // synopsys parallel_case full_case infer_mux | |
244 | 2'b00 : gc_arb_ino = gc_0_ino; | |
245 | 2'b01 : gc_arb_ino = gc_1_ino; | |
246 | 2'b10 : gc_arb_ino = gc_2_ino; | |
247 | 2'b11 : gc_arb_ino = gc_3_ino; | |
248 | endcase | |
249 | ||
250 | ||
251 | assign gc_arb_id = last_arb_winner; | |
252 | ||
253 | ||
254 | //############################################################################ | |
255 | // SEQUENTIAL LOGIC | |
256 | //############################################################################ | |
257 | ||
258 | //----------------------------------------------------------------------- | |
259 | // Next State Logic, Assign next state to current state | |
260 | //----------------------------------------------------------------------- | |
261 | always @(posedge clk) | |
262 | begin | |
263 | if (~rst_l) | |
264 | begin | |
265 | state <= IDLE; | |
266 | end | |
267 | else | |
268 | begin | |
269 | state <= n_state; | |
270 | end | |
271 | end | |
272 | ||
273 | //----------------------------------------------------------------------- | |
274 | // Next arbitration winner logic | |
275 | //----------------------------------------------------------------------- | |
276 | ||
277 | always @(posedge clk) | |
278 | begin | |
279 | if (~rst_l) | |
280 | last_arb_winner <= 2'b11; // Reset to 11 so that the next arb winner will be zero if not it will be 1 | |
281 | else | |
282 | last_arb_winner <= n_arb_winner; | |
283 | end | |
284 | ||
285 | //----------------------------------------------------------------------- | |
286 | // FSM Combination Logic | |
287 | //----------------------------------------------------------------------- | |
288 | ||
289 | always @(state or arb_winner or arb_needed or last_arb_winner or next_arb) | |
290 | begin | |
291 | ||
292 | case (state) // synopsys parallel_case | |
293 | ||
294 | //******************************************************** | |
295 | // | |
296 | // IDLE STATE | |
297 | // | |
298 | // - Wait here until the arbiter has a request | |
299 | // - Do not update the last winner | |
300 | // | |
301 | // -If it has a request which needs servicing use the arb | |
302 | // winner as the one to req for | |
303 | // - Update the next winner | |
304 | // - By doing this we register the winner and | |
305 | // use that value for the rest of the | |
306 | // calculations (last_arb_winner) | |
307 | // | |
308 | // | |
309 | //******************************************************** | |
310 | IDLE: | |
311 | begin | |
312 | if (arb_needed) // If there is at least group controller thats needs servicing | |
313 | begin | |
314 | n_state = ARB_GNT; | |
315 | n_arb_winner = arb_winner; | |
316 | end | |
317 | else // If there no group controllers that need servicing | |
318 | begin | |
319 | n_state = IDLE; | |
320 | n_arb_winner = last_arb_winner; | |
321 | end | |
322 | end | |
323 | ||
324 | ||
325 | //******************************************************** | |
326 | // | |
327 | // ARB_GNT STATE | |
328 | // | |
329 | // - This state is used to grant the winner of the | |
330 | // arbitaration | |
331 | // | |
332 | // - Do not update the last winner | |
333 | ||
334 | // | |
335 | //******************************************************** | |
336 | ||
337 | ARB_GNT: | |
338 | begin | |
339 | n_state = W_4_CSM; // Grant the bus winner | |
340 | n_arb_winner = last_arb_winner; | |
341 | end | |
342 | ||
343 | ||
344 | //******************************************************** | |
345 | // | |
346 | // W_4_CSM STATE | |
347 | // | |
348 | // - This state is used to wait, until the CSM is done | |
349 | // and is ready to handle the next request | |
350 | // | |
351 | // - When the CSM replys, need to check if we have more | |
352 | // requests that need processing. | |
353 | // - If yes | |
354 | // - see if we have any more reqs waiting | |
355 | // - if yes ARB again and update last winner | |
356 | // - if no go to IDLE, no update | |
357 | // | |
358 | //******************************************************** | |
359 | ||
360 | ||
361 | W_4_CSM: | |
362 | begin | |
363 | if (next_arb) // Get signal from CSM to go and do next arb | |
364 | begin | |
365 | ||
366 | if (arb_needed) // more requests waiting | |
367 | begin | |
368 | n_state = ARB_GNT; | |
369 | n_arb_winner = arb_winner; | |
370 | end | |
371 | ||
372 | else // No more requests waiting | |
373 | begin | |
374 | n_state = IDLE; | |
375 | n_arb_winner = last_arb_winner; | |
376 | end | |
377 | end | |
378 | ||
379 | else // NO reply yet, the CSM is Busy | |
380 | begin | |
381 | n_state = W_4_CSM ; | |
382 | n_arb_winner = last_arb_winner; | |
383 | end | |
384 | end | |
385 | //******************************************************** | |
386 | // | |
387 | // DEFAULT STATE | |
388 | // | |
389 | // - Go to IDLE | |
390 | //******************************************************** | |
391 | ||
392 | default: | |
393 | ||
394 | begin | |
395 | n_state = IDLE; //0in < fire -message "Illegal State Reached in module fire_dlc_imu_gcs_arb.v" | |
396 | n_arb_winner = last_arb_winner; | |
397 | end | |
398 | ||
399 | endcase | |
400 | end | |
401 | ||
402 | endmodule |