Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: dmu_common_scoreboard_controller.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_common_scoreboard_controller | |
36 | ( | |
37 | // Control Signals | |
38 | clk, | |
39 | rst_l, | |
40 | ||
41 | // External Interface | |
42 | ||
43 | // input | |
44 | req_in, | |
45 | cmd_type_in, | |
46 | trn_in, | |
47 | wr_data_in, | |
48 | ||
49 | // output | |
50 | full_out, | |
51 | n_trn_out, | |
52 | rd_data_out, | |
53 | grant_out, | |
54 | ||
55 | // Internal Interface | |
56 | ||
57 | // input | |
58 | rd_data_in, | |
59 | ||
60 | // output | |
61 | wr1_out, | |
62 | wr2_out, | |
63 | trn1_out, | |
64 | type_out, | |
65 | wr_data_out, | |
66 | req_out, | |
67 | ||
68 | // input | |
69 | full_in, | |
70 | n_trn_in, | |
71 | ||
72 | // output | |
73 | deq_out, | |
74 | trn2_out, | |
75 | enq_out, | |
76 | ||
77 | // debug ports | |
78 | dbg_a, | |
79 | dbg_b, | |
80 | dbg_sel_a, | |
81 | dbg_sel_b | |
82 | ); | |
83 | ||
84 | ////////////////////////////////////////////////////////////////////// | |
85 | //************************* Parameters ************************* | |
86 | ////////////////////////////////////////////////////////////////////// | |
87 | ||
88 | // PARAMETERS PASSED IN ON INDIVIDUAL INSTANTIATIONS | |
89 | parameter CMD_TYPE_WIDTH = 4; | |
90 | parameter TAG_WIDTH = 5; | |
91 | parameter WR_DATA_WIDTH = 48; | |
92 | parameter RD_DATA_WIDTH = 48; | |
93 | ||
94 | // for command type definitions in case statement | |
95 | parameter IDLE = 4'b0000; | |
96 | ||
97 | parameter DMA_RD = 4'b0001; | |
98 | parameter DMA_CLR = 4'b0010; | |
99 | parameter DMA_RD_CLR = 4'b0011; | |
100 | parameter DMA_WR = 4'b0100; | |
101 | parameter DMA_TRN_REQ = 4'b0101; | |
102 | ||
103 | parameter PIO_RD = 4'b1001; | |
104 | parameter PIO_CLR = 4'b1010; | |
105 | parameter PIO_RD_CLR = 4'b1011; | |
106 | parameter PIO_WR = 4'b1100; | |
107 | parameter PIO_TRN_REQ = 4'b1101; | |
108 | ||
109 | ||
110 | ////////////////////////////////////////////////////////////////////// | |
111 | //************************* Port Declarations ******************* | |
112 | ////////////////////////////////////////////////////////////////////// | |
113 | ||
114 | // Control Signals | |
115 | input clk; // input clock | |
116 | input rst_l; // input reset | |
117 | ||
118 | // Controller external interface inputs | |
119 | ||
120 | input req_in; // service request signal | |
121 | input [CMD_TYPE_WIDTH-1:0] cmd_type_in; // command to be serviced from agent | |
122 | input [TAG_WIDTH-1:0] trn_in; // transaction number unique ID from agent | |
123 | input [WR_DATA_WIDTH-1:0] wr_data_in; // write data bus from agent | |
124 | ||
125 | // Controller external interface outputs | |
126 | ||
127 | output full_out; // full signals to agent | |
128 | output [TAG_WIDTH-1:0] n_trn_out; // next trn available for issue to agent | |
129 | output [RD_DATA_WIDTH-1:0] rd_data_out; // read data bus to agent | |
130 | output grant_out; // service granted signal to agent | |
131 | ||
132 | // Controller internal interface inputs | |
133 | ||
134 | input [RD_DATA_WIDTH-1:0] rd_data_in; // read data bus from scoreboard | |
135 | ||
136 | output wr1_out; // write enable to scoreboard | |
137 | output wr2_out; // write enable to scoreboard | |
138 | output [TAG_WIDTH-1:0] trn1_out; // transaction number unique ID to scoreboard | |
139 | output type_out; // command to be serviced from agent | |
140 | ||
141 | output [WR_DATA_WIDTH-1:0] wr_data_out; // write data bus to scoreboard | |
142 | output req_out; // req out to scoreboard | |
143 | ||
144 | input full_in; // full signals from ttg | |
145 | input [TAG_WIDTH-1:0] n_trn_in; // next trn available from ttg | |
146 | ||
147 | // Controller internal interface outputs | |
148 | ||
149 | output deq_out; // dequeue signal to ttg to get next trn | |
150 | output [TAG_WIDTH-1:0] trn2_out; // transaction number unique ID to scoreboard | |
151 | output enq_out; // enqueue signal to ttg to retire trn | |
152 | ||
153 | // debug ports | |
154 | output [7:0] dbg_a; // Controller debug output a | |
155 | output [7:0] dbg_b; // Controller debug output b | |
156 | input [2:0] dbg_sel_a; // Controller debug select a | |
157 | input [2:0] dbg_sel_b; // Controller debug select b | |
158 | ||
159 | ////////////////////////////////////////////////////////////////////// | |
160 | //*********************** Wires and Regs ************************ | |
161 | ////////////////////////////////////////////////////////////////////// | |
162 | ||
163 | // registers that are flops | |
164 | reg [TAG_WIDTH-1:0] n_trn_out; | |
165 | reg [RD_DATA_WIDTH-1:0] rd_data_out; | |
166 | reg grant_out; | |
167 | reg [3:0] state,next_state; | |
168 | ||
169 | // registers that are not flops | |
170 | ||
171 | ||
172 | reg next_grant; | |
173 | reg wr1_out; | |
174 | reg wr2_out; | |
175 | reg deq_out; | |
176 | reg enq_out; | |
177 | reg [TAG_WIDTH-1:0] trn1_out; | |
178 | wire type_out; | |
179 | reg full_out; | |
180 | // Wires | |
181 | ||
182 | wire req_in; | |
183 | wire req_out; | |
184 | wire [CMD_TYPE_WIDTH-1:0] cmd_type_in; | |
185 | wire [TAG_WIDTH-1:0] trn_in; | |
186 | wire [WR_DATA_WIDTH-1:0] wr_data_in; | |
187 | wire [TAG_WIDTH-1:0] trn2_out; | |
188 | ||
189 | ||
190 | wire [RD_DATA_WIDTH-1:0] rd_data_in; | |
191 | ||
192 | ||
193 | wire [WR_DATA_WIDTH-1:0] wr_data_out; | |
194 | wire full_in; | |
195 | wire [TAG_WIDTH-1:0] n_trn_in; | |
196 | ||
197 | // Idle | |
198 | reg scbd_idle; | |
199 | ||
200 | //debug | |
201 | reg [2:0] dbg_sel [0:1]; | |
202 | reg [7:0] dbg_bus [0:1]; | |
203 | reg [7:0] nxt_dbg_bus [0:1]; | |
204 | ||
205 | // debug ports | |
206 | wire [7:0] dbg_a; // Controller debug output a | |
207 | wire [7:0] dbg_b; // Controller debug output b | |
208 | wire [2:0] dbg_sel_a; // Controller debug select a | |
209 | wire [2:0] dbg_sel_b; // Controller debug select b | |
210 | ||
211 | integer i; | |
212 | ||
213 | ////////////////////////////////////////////////////////////////////// | |
214 | // ********************* Combinational Logic *********************** | |
215 | ////////////////////////////////////////////////////////////////////// | |
216 | ||
217 | // debug | |
218 | ||
219 | always @ (dbg_sel_a or dbg_sel_b) | |
220 | begin | |
221 | dbg_sel[0] = dbg_sel_a; | |
222 | dbg_sel[1] = dbg_sel_b; | |
223 | end | |
224 | ||
225 | always @ (dbg_sel[0] or dbg_sel[1] or state or next_state or trn_in or n_trn_in | |
226 | or trn1_out or n_trn_out or grant_out or full_out or req_in or cmd_type_in | |
227 | or wr1_out or wr2_out or deq_out or enq_out or scbd_idle) | |
228 | begin | |
229 | for (i = 0; i < 2; i = i + 1) | |
230 | begin | |
231 | case (dbg_sel[i]) // synopsys parallel_case infer_mux | |
232 | 3'b000: nxt_dbg_bus[i] = {next_state, state}; | |
233 | 3'b001: nxt_dbg_bus[i] = {3'b0, trn_in}; | |
234 | 3'b010: nxt_dbg_bus[i] = {3'b0, n_trn_in}; | |
235 | 3'b011: nxt_dbg_bus[i] = {3'b0, trn1_out}; | |
236 | 3'b100: nxt_dbg_bus[i] = {3'b0, n_trn_out}; | |
237 | 3'b101: nxt_dbg_bus[i] = {1'b0, grant_out, full_out, req_in, cmd_type_in}; | |
238 | 3'b110: nxt_dbg_bus[i] = {4'b0, wr1_out, wr2_out, deq_out, enq_out}; | |
239 | 3'b111: nxt_dbg_bus[i] = {7'b0, scbd_idle}; | |
240 | endcase | |
241 | end | |
242 | end | |
243 | ||
244 | assign dbg_a = dbg_bus[0]; | |
245 | assign dbg_b = dbg_bus[1]; | |
246 | ||
247 | // end debug | |
248 | ||
249 | assign wr_data_out = wr_data_in; // pass through the write data | |
250 | assign trn2_out = trn1_out; // connect up inside module | |
251 | assign type_out = req_in & cmd_type_in[3]; // pass bit out off controller | |
252 | assign req_out = req_in; // pass through the req | |
253 | ||
254 | ||
255 | // Decode the command type | |
256 | ||
257 | always @(state or req_in or full_in or cmd_type_in or full_out) | |
258 | begin | |
259 | next_state = IDLE; | |
260 | next_grant = 1'b0; | |
261 | deq_out = 1'b0; | |
262 | enq_out = 1'b0; | |
263 | wr1_out = 1'b0; | |
264 | wr2_out = 1'b0; | |
265 | ||
266 | case(state) | |
267 | IDLE : | |
268 | if(req_in) | |
269 | begin | |
270 | next_state = cmd_type_in; | |
271 | if((cmd_type_in == DMA_TRN_REQ || cmd_type_in == PIO_TRN_REQ) && full_in) | |
272 | next_grant = 1'b0; | |
273 | else | |
274 | next_grant = 1'b1; | |
275 | end | |
276 | else | |
277 | begin | |
278 | next_grant = 1'b0; | |
279 | next_state = IDLE; | |
280 | deq_out = 1'b0; | |
281 | enq_out = 1'b0; | |
282 | wr1_out = 1'b0; | |
283 | wr2_out = 1'b0; | |
284 | end | |
285 | DMA_RD : // Read (DMA) | |
286 | begin | |
287 | next_grant = 1'b0; | |
288 | next_state = IDLE; | |
289 | end | |
290 | DMA_CLR : // Clear (DMA) | |
291 | begin | |
292 | enq_out = 1'b1; | |
293 | next_grant = 1'b0; | |
294 | next_state = IDLE; | |
295 | end | |
296 | ||
297 | DMA_RD_CLR : // Read w/ Clear (DMA) | |
298 | begin | |
299 | enq_out = 1'b1; | |
300 | next_grant = 1'b0; | |
301 | next_state = IDLE; | |
302 | end | |
303 | ||
304 | DMA_WR : // Write (DMA) | |
305 | begin | |
306 | wr1_out = 1'b1; | |
307 | next_grant = 1'b0; | |
308 | next_state = IDLE; | |
309 | end | |
310 | ||
311 | DMA_TRN_REQ : // TRN Request w/ Write (DMA) | |
312 | begin | |
313 | if(!full_out) | |
314 | begin | |
315 | deq_out = 1'b1; | |
316 | wr1_out = 1'b1; | |
317 | next_grant = 1'b0; | |
318 | next_state = IDLE; | |
319 | end | |
320 | else | |
321 | begin | |
322 | next_state = IDLE; | |
323 | end | |
324 | end | |
325 | PIO_RD: // Read (PIO) | |
326 | begin | |
327 | next_grant = 1'b0; | |
328 | next_state = IDLE; | |
329 | end | |
330 | ||
331 | PIO_CLR : // Clear(PIO) | |
332 | begin | |
333 | next_grant = 1'b0; | |
334 | enq_out = 1'b1; | |
335 | next_state = IDLE; | |
336 | end | |
337 | ||
338 | PIO_RD_CLR : // Read w/ Clear(PIO) | |
339 | begin | |
340 | ||
341 | next_grant = 1'b0; | |
342 | enq_out = 1'b1; | |
343 | next_state = IDLE; | |
344 | end | |
345 | ||
346 | PIO_WR : // Write(PIO) | |
347 | begin | |
348 | wr2_out = 1'b1; | |
349 | next_grant = 1'b0; | |
350 | next_state = IDLE; | |
351 | end | |
352 | ||
353 | PIO_TRN_REQ : // TRN Request w/ Write(PIO) | |
354 | begin | |
355 | if(!full_out) | |
356 | begin | |
357 | deq_out = 1'b1; | |
358 | wr2_out = 1'b1; | |
359 | next_grant = 1'b0; | |
360 | next_state = IDLE; | |
361 | end | |
362 | else | |
363 | begin | |
364 | next_state = IDLE; | |
365 | end | |
366 | end // case: PIO_TRN_REQ | |
367 | default : // 0in < fire -message " Error - controller default state entered " | |
368 | begin | |
369 | next_grant = 1'b0; | |
370 | next_state = IDLE; | |
371 | end | |
372 | endcase // case(cmd_type_in) | |
373 | end | |
374 | ||
375 | // assign trn out to next trn on a TRN request | |
376 | always @ (trn_in or cmd_type_in or n_trn_in) | |
377 | begin | |
378 | if (cmd_type_in == DMA_TRN_REQ || cmd_type_in == PIO_TRN_REQ) | |
379 | trn1_out = n_trn_in; | |
380 | else | |
381 | trn1_out = trn_in; | |
382 | end | |
383 | ||
384 | ////////////////////////////////////////////////////////////////////// | |
385 | // ********************* Sequential Logic *********************** | |
386 | ////////////////////////////////////////////////////////////////////// | |
387 | always@(posedge clk) | |
388 | if (!rst_l) | |
389 | state <= IDLE; | |
390 | else | |
391 | state <= next_state; | |
392 | ||
393 | // Give grant for request | |
394 | always @(posedge clk) | |
395 | if (!rst_l) | |
396 | grant_out <= 1'b0; | |
397 | else | |
398 | grant_out <= next_grant; | |
399 | ||
400 | // for Read and Read w/ Clear | |
401 | always @(posedge clk) | |
402 | if (!rst_l) | |
403 | rd_data_out <= {RD_DATA_WIDTH{1'b0}}; | |
404 | else | |
405 | rd_data_out <= rd_data_in; | |
406 | ||
407 | // for TRN Request w/write | |
408 | always @(posedge clk) | |
409 | if (!rst_l) | |
410 | n_trn_out <= {TAG_WIDTH{1'b0}}; | |
411 | else | |
412 | n_trn_out <= n_trn_in; | |
413 | ||
414 | // Assert full after last trn request is made | |
415 | always @(posedge clk) | |
416 | if (!rst_l) | |
417 | full_out <= 1'b0; | |
418 | else | |
419 | full_out <= full_in; | |
420 | ||
421 | always@(posedge clk) | |
422 | if(~rst_l) | |
423 | scbd_idle <=1'b1; | |
424 | else if (req_in == 1'b0) | |
425 | scbd_idle <=1'b1; | |
426 | else | |
427 | scbd_idle <=1'b0; | |
428 | // Debug port outputs | |
429 | always @ (posedge clk) | |
430 | begin | |
431 | if(~rst_l) | |
432 | for (i = 0; i < 2; i = i + 1) | |
433 | dbg_bus[i] <= 8'h00; | |
434 | else | |
435 | for (i = 0; i < 2; i = i + 1) | |
436 | dbg_bus[i] <= nxt_dbg_bus[i]; | |
437 | end // always @ (posedge clk) | |
438 | ||
439 | ||
440 | endmodule // dmu_common_scoreboard_controller | |
441 |