Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: dmu_imu_gcs_csm.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_csm ( | |
36 | ||
37 | // Clock and Reset | |
38 | ||
39 | clk, | |
40 | rst_l, | |
41 | ||
42 | // ISS lookup request signals | |
43 | ||
44 | gcs2iss_tid_req, | |
45 | gcs2iss_tid_sel, | |
46 | gcs2iss_mdo_pending, | |
47 | ||
48 | // ISS lookup response signals | |
49 | ||
50 | iss2gcs_tid_ack, | |
51 | iss2gcs_tid, | |
52 | iss2gcs_mondo_mode, | |
53 | ||
54 | // Signal to Arbiter to arbitrate again | |
55 | ||
56 | next_arb, | |
57 | ||
58 | // Signals from arbiter | |
59 | ||
60 | gc_arb_valid, | |
61 | gc_arb_ino, | |
62 | gc_arb_id, | |
63 | ||
64 | // LRM Mondo Enqueue Interface | |
65 | ||
66 | im2rm_mdo_enq, | |
67 | im2rm_mdo, | |
68 | ||
69 | // Debug Interface | |
70 | ||
71 | fsm_dbg | |
72 | ||
73 | ); | |
74 | ||
75 | //############################################################################ | |
76 | // PORT DECLARATIONS | |
77 | //############################################################################ | |
78 | ||
79 | //------------------------------------------------------------------------ | |
80 | // Clock and Reset Signals | |
81 | //------------------------------------------------------------------------ | |
82 | ||
83 | input clk; | |
84 | input rst_l; | |
85 | ||
86 | //------------------------------------------------------------------------ | |
87 | // ISS lookup request signals | |
88 | //------------------------------------------------------------------------ | |
89 | output gcs2iss_tid_req; // Request ot ISS for TID for accepted mondo | |
90 | output [5:0] gcs2iss_tid_sel; // Select for the TID output mux | |
91 | output [63:0] gcs2iss_mdo_pending; // ID of mondo that was accecpted | |
92 | ||
93 | //------------------------------------------------------------------------ | |
94 | // ISS lookup response signals | |
95 | //------------------------------------------------------------------------ | |
96 | ||
97 | input iss2gcs_tid_ack; // Qualifier for tid of mondo | |
98 | input [5:0] iss2gcs_tid; // TID of mondo | |
99 | input iss2gcs_mondo_mode; // Mode of the modo | |
100 | ||
101 | //------------------------------------------------------------------------ | |
102 | // Signal to Arbiter to arbitrate again | |
103 | //------------------------------------------------------------------------ | |
104 | ||
105 | output next_arb; // Signal to GC arb to do next arb | |
106 | ||
107 | //------------------------------------------------------------------------ | |
108 | // Signals from arbiter | |
109 | //------------------------------------------------------------------------ | |
110 | ||
111 | input gc_arb_valid; // Valid signal saying that the arb winner is now valid are ready to be taken | |
112 | input [5:0] gc_arb_ino; // The ino of winner from arbitration; | |
113 | input [1:0] gc_arb_id; // ID of the group controller of the arb winner | |
114 | ||
115 | ||
116 | //----------------------------------------------------- | |
117 | // Interface for to LRM for Mondo Records | |
118 | //----------------------------------------------------- | |
119 | ||
120 | output im2rm_mdo_enq; //Enqueue signal for mondo record | |
121 | output [`FIRE_DLC_MQR_REC_WDTH-1:0] im2rm_mdo; // Mondo data | |
122 | ||
123 | //----------------------------------------------------- | |
124 | // Debug Interface | |
125 | //----------------------------------------------------- | |
126 | ||
127 | output [`FIRE_DEBUG_WDTH-1:0] fsm_dbg; | |
128 | ||
129 | ||
130 | ||
131 | //############################################################################ | |
132 | // PARAMETERS | |
133 | //############################################################################ | |
134 | parameter IDLE = 2'b00; | |
135 | parameter TID_REQ = 2'b01; | |
136 | parameter TID_ACK = 2'b10; | |
137 | parameter LRM_ENQ = 2'b11; | |
138 | ||
139 | ||
140 | //############################################################################ | |
141 | // SIGNAL DECLARATIONS | |
142 | //############################################################################ | |
143 | ||
144 | //------------------------ | |
145 | // Wires | |
146 | //------------------------ | |
147 | ||
148 | wire load_new_mondo; | |
149 | ||
150 | //------------------------- | |
151 | // Regs that are NOT flops | |
152 | //------------------------- | |
153 | reg [1:0] n_state; | |
154 | ||
155 | ||
156 | //------------------------ | |
157 | // Regs that are flops | |
158 | //------------------------ | |
159 | reg [1:0] state; | |
160 | reg [5:0] current_ino; | |
161 | reg [1:0] current_id; | |
162 | ||
163 | ||
164 | //############################################################################ | |
165 | // ZERO IN CHECKERS | |
166 | //############################################################################ | |
167 | ||
168 | //--------------------------------------------------------------------- | |
169 | // One Hot / Bits On Checkers | |
170 | //--------------------------------------------------------------------- | |
171 | ||
172 | //0in bits_on -var gcs2iss_mdo_pending -max 1 | |
173 | ||
174 | //--------------------------------------------------------------------- | |
175 | // REQ / ACK Interface Checkers | |
176 | //--------------------------------------------------------------------- | |
177 | ||
178 | //0in req_ack -req gcs2iss_tid_req -ack iss2gcs_tid_ack -req_until_ack -new_req_after_ack -max_ack 1 | |
179 | //0in req_ack -req gc_arb_valid -ack next_arb -req_until_ack -new_req_after_ack -max_ack 1 | |
180 | ||
181 | //--------------------------------------------------------------------- | |
182 | // Known and Constant Checkers | |
183 | //--------------------------------------------------------------------- | |
184 | //0in known_driven -var gcs2iss_mdo_pending -active gcs2iss_tid_req | |
185 | //0in constant -var gcs2iss_mdo_pending -active gcs2iss_tid_req | |
186 | ||
187 | //0in known_driven -var iss2gcs_tid -active iss2gcs_tid_ack | |
188 | //0in constant -var iss2gcs_tid -active iss2gcs_tid_ack | |
189 | ||
190 | //0in known_driven -var iss2gcs_mondo_mode -active iss2gcs_tid_ack | |
191 | //0in constant -var iss2gcs_mondo_mode -active iss2gcs_tid_ack | |
192 | ||
193 | //0in known_driven -var gc_arb_ino -active gc_arb_valid | |
194 | //0in constant -var gc_arb_ino -active gc_arb_valid | |
195 | ||
196 | //0in known_driven -var gc_arb_id -active gc_arb_valid | |
197 | //0in constant -var gc_arb_id -active gc_arb_valid | |
198 | ||
199 | //0in known_driven -var im2rm_mdo -active im2rm_mdo_enq | |
200 | //0in constant -var im2rm_mdo -active im2rm_mdo_enq | |
201 | ||
202 | ||
203 | //--------------------------------------------------------------------- | |
204 | // Assert Timers | |
205 | //--------------------------------------------------------------------- | |
206 | //0in assert_timer -var im2rm_mdo_enq -min 1 -max 1 | |
207 | ||
208 | ||
209 | //--------------------------------------------------------------------- | |
210 | // State Machine Checkers | |
211 | //--------------------------------------------------------------------- | |
212 | //0in state_transition -var state -val IDLE -next TID_REQ | |
213 | //0in state_transition -var state -val TID_REQ -next TID_ACK | |
214 | //0in state_transition -var state -val TID_ACK -next LRM_ENQ | |
215 | //0in state_transition -var state -val LRM_ENQ -next TID_REQ IDLE | |
216 | //0in sequence -var state -val TID_REQ TID_ACK LRM_ENQ | |
217 | ||
218 | ||
219 | //############################################################################ | |
220 | // FUNCTION DECLARATIONS | |
221 | //############################################################################ | |
222 | //---------------------------------------------------------------------- | |
223 | // This function takes as an input a 6 bit vector encodes it to | |
224 | // a 64 bit vector with one bit set. | |
225 | // | |
226 | // For Example on a 8 bit vector | |
227 | // | |
228 | // Input = 00011 | |
229 | // | |
230 | // Output = 000100 | |
231 | // | |
232 | //----------------------------------------------------------------------- | |
233 | ||
234 | function [63:0] decode; | |
235 | input [5:0] vec; | |
236 | ||
237 | reg [63:0] decode_vec; | |
238 | reg [6:0]i; | |
239 | ||
240 | begin | |
241 | ||
242 | decode_vec = 64'h0; | |
243 | ||
244 | for (i=7'd0; i<= 7'd63; i=i+7'd1) | |
245 | begin | |
246 | if (i[5:0] == vec) decode_vec[i] = 1'b1; | |
247 | else decode_vec[i] = 1'b0; | |
248 | end | |
249 | ||
250 | decode = decode_vec; | |
251 | ||
252 | //$display($time,": Ecoded value for vec = %0b is %0b\n",vec, enc_vec); | |
253 | end | |
254 | endfunction | |
255 | ||
256 | ||
257 | ||
258 | ||
259 | //############################################################################ | |
260 | // COMBINATIONAL LOGIC | |
261 | //############################################################################ | |
262 | ||
263 | //------------------------------------------------------------------- | |
264 | // Assign the outputs to the ISS | |
265 | // - req should be assrted in REQ state until gets and ACK back | |
266 | // - The ino should be the registered version encoded to 64 bits | |
267 | //------------------------------------------------------------------- | |
268 | assign gcs2iss_tid_req = (state == TID_REQ) | (state == TID_ACK); | |
269 | assign gcs2iss_mdo_pending = decode(current_ino); | |
270 | assign gcs2iss_tid_sel = current_ino; | |
271 | ||
272 | ||
273 | //------------------------------------------------------------------- | |
274 | // Assign the outputs to the LRM | |
275 | // - Enq should be pulsed every LRM_ENQ state | |
276 | // - Concat the proper registed flops togther. | |
277 | //------------------------------------------------------------------- | |
278 | ||
279 | assign im2rm_mdo_enq = (state == LRM_ENQ); | |
280 | assign im2rm_mdo = {iss2gcs_tid[5],iss2gcs_mondo_mode, current_ino, iss2gcs_tid[4:0], current_id}; | |
281 | ||
282 | //------------------------------------------------------------------- | |
283 | // Do the internal combination control signals | |
284 | // - Next arb should happen ever TID req to get the next arb ready and exposed | |
285 | // - Register the current id and ino before the new values are loaded in on the | |
286 | // next cycle. | |
287 | //------------------------------------------------------------------- | |
288 | assign next_arb = (state == TID_REQ); | |
289 | assign load_new_mondo = (n_state == TID_REQ); | |
290 | ||
291 | //------------------------------------------------------------------------- | |
292 | // Debug Ports | |
293 | //------------------------------------------------------------------------- | |
294 | ||
295 | assign fsm_dbg = {2'h0, state[1:0], gc_arb_valid, iss2gcs_tid_ack, gc_arb_id[1:0]}; | |
296 | ||
297 | //############################################################################ | |
298 | // SEQUENTIAL LOGIC | |
299 | //############################################################################ | |
300 | ||
301 | //----------------------------------------------------------------------- | |
302 | // Flop the arb winner's INO and ID | |
303 | // - Load the new valaue of the winner when appropriate | |
304 | // or hold the current value | |
305 | //----------------------------------------------------------------------- | |
306 | always @(posedge clk) | |
307 | begin | |
308 | if (~rst_l) | |
309 | begin | |
310 | current_ino <= 6'h0; | |
311 | current_id <= 2'b00; | |
312 | end | |
313 | else if (load_new_mondo) | |
314 | begin | |
315 | current_ino <= gc_arb_ino; | |
316 | current_id <= gc_arb_id; | |
317 | end | |
318 | else | |
319 | begin | |
320 | current_ino <= current_ino; | |
321 | current_id <= current_id ; | |
322 | end | |
323 | end | |
324 | ||
325 | ||
326 | //----------------------------------------------------------------------- | |
327 | // Next State Logic, Assign next state to current state | |
328 | //----------------------------------------------------------------------- | |
329 | always @(posedge clk) | |
330 | begin | |
331 | if (~rst_l) | |
332 | begin | |
333 | state <= IDLE; | |
334 | end | |
335 | else | |
336 | begin | |
337 | state <= n_state; | |
338 | end | |
339 | end | |
340 | ||
341 | ||
342 | //----------------------------------------------------------------------- | |
343 | // FSM Combination Logic | |
344 | //----------------------------------------------------------------------- | |
345 | ||
346 | always @(state or gc_arb_valid or iss2gcs_tid_ack) | |
347 | begin | |
348 | ||
349 | ||
350 | case (state) // synopsys parallel_case full_case | |
351 | ||
352 | //******************************************************** | |
353 | // | |
354 | // IDLE STATE | |
355 | // | |
356 | // - Wait here until the arbiter has a mondo which needs | |
357 | // to be sent . | |
358 | // | |
359 | //******************************************************** | |
360 | ||
361 | ||
362 | IDLE: | |
363 | begin | |
364 | if (gc_arb_valid) // If there is interrupt waiting arb | |
365 | begin | |
366 | n_state = TID_REQ; | |
367 | end | |
368 | else // If there are no interrupts that needs servicing | |
369 | begin | |
370 | n_state = IDLE; | |
371 | end | |
372 | end | |
373 | ||
374 | //******************************************************** | |
375 | // | |
376 | // TID_REQ STATE | |
377 | // | |
378 | // - This state is used to issue the request to the ISS | |
379 | // to obatin the TID for the mondo which the arbiter | |
380 | // selected as the winner. | |
381 | // | |
382 | // - This state is also used to trigger the loading of | |
383 | // the next winner for the arbiter and to latch in | |
384 | // the value of the current winners before they change | |
385 | // | |
386 | //******************************************************** | |
387 | ||
388 | TID_REQ: | |
389 | begin | |
390 | n_state = TID_ACK; // Stay here for one cycle | |
391 | end | |
392 | ||
393 | //******************************************************** | |
394 | // | |
395 | // TID_ACK STATE | |
396 | // | |
397 | // - Wait in this state until the ISS respons with an | |
398 | // ACK and the TID of the requested mondo | |
399 | // | |
400 | //******************************************************** | |
401 | ||
402 | TID_ACK: | |
403 | begin | |
404 | if (iss2gcs_tid_ack) // If get granted by the ISS | |
405 | begin | |
406 | n_state = LRM_ENQ; | |
407 | end | |
408 | else | |
409 | begin | |
410 | n_state = TID_ACK; // If still not granted wait here | |
411 | end | |
412 | end | |
413 | ||
414 | ||
415 | //******************************************************** | |
416 | // | |
417 | // LRM_ENQ STATE | |
418 | // | |
419 | // - This state is used to enqueue the request to the | |
420 | // LRM . | |
421 | // - If another requests is waiting go handle it | |
422 | // - If not go back to IDLE | |
423 | // | |
424 | //******************************************************** | |
425 | ||
426 | LRM_ENQ: | |
427 | begin | |
428 | if (gc_arb_valid) // If another request is waiting | |
429 | begin | |
430 | n_state = TID_REQ; | |
431 | end | |
432 | ||
433 | else // Another request is not waiting more waiting | |
434 | begin | |
435 | n_state = IDLE; | |
436 | end | |
437 | end | |
438 | ||
439 | endcase | |
440 | end | |
441 | ||
442 | ||
443 | ||
444 | endmodule | |
445 |