Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / ccx / rtl / ccx_srq_ctl.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: ccx_srq_ctl.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`ifndef FPGA
36module ccx_srq_ctl (
37 qfull_a,
38 qfullbar_a,
39 qsel0_a,
40 qsel1_a,
41 shift_a,
42 q0_holdbar_a,
43 atom_x,
44 req_a,
45 atom_a,
46 grant_a,
47 l1clk,
48 scan_in,
49 ccx_aclk,
50 ccx_bclk,
51 scan_out);
52wire siclk;
53wire soclk;
54wire dff_grant_x_scanin;
55wire dff_grant_x_scanout;
56wire grant_x;
57wire atom_rq_a;
58wire atom_rq_x;
59wire dff_atom_rq_x_scanin;
60wire dff_atom_rq_x_scanout;
61wire dff_qfull_a_scanin;
62wire dff_qfull_a_scanout;
63wire qfull;
64wire req_new;
65wire v0_in;
66wire v0;
67wire v1;
68wire v1_in;
69wire qfullbar;
70wire dff_v0_scanin;
71wire dff_v0_scanout;
72wire dff_v1_scanin;
73wire dff_v1_scanout;
74wire dff_qfullbar_a_scanin;
75wire dff_qfullbar_a_scanout;
76wire av0_in;
77wire av0;
78wire av1;
79wire av1_in;
80wire aqsel0_a;
81wire aqsel1_a;
82wire ashift_a;
83wire dff_av0_scanin;
84wire dff_av0_scanout;
85wire dff_av1_scanin;
86wire dff_av1_scanout;
87wire atom1_in;
88wire atom1;
89wire dff_atom1_scanin;
90wire dff_atom1_scanout;
91wire atom0_in;
92wire atom0;
93wire dff_atom0_scanin;
94wire dff_atom0_scanout;
95
96
97output qfull_a;
98output qfullbar_a;
99output qsel0_a;
100output qsel1_a;
101output shift_a;
102output q0_holdbar_a;
103output atom_x;
104
105input req_a;
106input atom_a;
107input grant_a;
108
109//Globals
110input l1clk;
111input scan_in;
112input ccx_aclk;
113input ccx_bclk;
114output scan_out;
115
116// scan renames
117assign siclk = ccx_aclk;
118assign soclk = ccx_bclk;
119// end scan
120
121
122// latch the grant
123// grant is generated in the same cycle as req_a.
124// The data corresponding to the grant is consumed from the queues
125// in next cycle. grant_x is used to update the FIFO.
126ccx_srq_ctl_msff_ctl_macro dff_grant_x
127 (
128 .scan_in(dff_grant_x_scanin),
129 .scan_out(dff_grant_x_scanout),
130 .din (grant_a),
131 .dout (grant_x),
132 .l1clk (l1clk),
133 .siclk(siclk),
134 .soclk(soclk)
135 );
136
137
138// set up state to detect an atomic request and hold it until queue stays
139// full. The atomic requests are guaranteed to be back-to-back.
140// On PCX, an atomic req will not be made unless queue is empty.
141// On CPX, L2 can make the req when queue is not full (it need not be empty).
142// In this case atom_rq_a will get set after the first packet is accepted. It will
143// stay set until the queue remains full. When the queue goes not full, the
144// next packet (second part of the atomic req) will get accepted and a req
145// will be generated for it. At the same time atom_rq_a will be cleared.
146//
147// ideally the setting should be qualified with !qfull, but it is not needed
148// since design guarantees that LSU and L2 will not make an atomic request
149// unless the queue is not full.
150
151//assign atom_rq_a = atom_a & req_a | atom_rq_x & qfull_a;
152assign atom_rq_a = atom_a & req_a & ~qfull_a | atom_rq_x & qfull_a;
153
154ccx_srq_ctl_msff_ctl_macro dff_atom_rq_x
155 (
156 .scan_in(dff_atom_rq_x_scanin),
157 .scan_out(dff_atom_rq_x_scanout),
158 .din (atom_rq_a),
159 .dout (atom_rq_x),
160 .l1clk (l1clk),
161 .siclk(siclk),
162 .soclk(soclk)
163);
164
165ccx_srq_ctl_msff_ctl_macro dff_qfull_a
166 (
167 .scan_in(dff_qfull_a_scanin),
168 .scan_out(dff_qfull_a_scanout),
169 .din (qfull),
170 .dout (qfull_a),
171 .l1clk (l1clk),
172 .siclk(siclk),
173 .soclk(soclk)
174);
175
176// req_new indicates that a valid request is presented with FIFO not full.
177assign req_new = (atom_rq_x | req_a) & ~qfull_a;
178
179// v0 and v1 are the valids for queue entries q0 and q1
180//
181// v1_in does not include the term (v1 & v0 & req_new & grant_x)
182// because with v1 set, the queue would be full.
183// No new requests can be accepted if v1 is set. This is because the source
184// continues to drive the request until the cycle after grant_x. Accepting
185// a request in the cycle of grant_x will result in same request being
186// latched twice in the FIFO.
187
188assign v0_in = ((~v0 & req_new) | (v0 & req_new & grant_x) | (v1 & grant_x) | (v0 & ~grant_x));
189assign v1_in = ((v0 & req_new & ~grant_x) | (v1 & ~grant_x));
190
191
192
193// qsel0 is the mux select which loads incoming new data into q0
194// shift_a is the mux select whicl loads q1 data into q0
195// qsel1 is the enable for q1
196// speed these up by using earlier versions of the signals
197//assign qsel0 = (~v0 & req_new) | (v0 & req_new & grant_x)
198// = req_new & (~v0 | v0 & grant_x)
199// = req_new & (~v0 | grant_x);
200assign qsel0_a = req_new & (~v0 | grant_x);
201assign shift_a = v1 & grant_x;
202assign q0_holdbar_a = ~(~qsel0_a & ~shift_a);
203
204assign qsel1_a = v0 & req_new & ~grant_x;
205assign qfull = v1_in;
206assign qfullbar = ~v1_in;
207
208ccx_srq_ctl_msff_ctl_macro dff_v0
209 (
210 .scan_in(dff_v0_scanin),
211 .scan_out(dff_v0_scanout),
212 .din (v0_in),
213 .dout (v0),
214 .l1clk (l1clk),
215 .siclk(siclk),
216 .soclk(soclk)
217);
218ccx_srq_ctl_msff_ctl_macro dff_v1
219 (
220 .scan_in(dff_v1_scanin),
221 .scan_out(dff_v1_scanout),
222 .din (v1_in),
223 .dout (v1),
224 .l1clk (l1clk),
225 .siclk(siclk),
226 .soclk(soclk)
227);
228
229ccx_srq_ctl_msff_ctl_macro dff_qfullbar_a
230 (
231 .scan_in(dff_qfullbar_a_scanin),
232 .scan_out(dff_qfullbar_a_scanout),
233 .din (qfullbar),
234 .dout (qfullbar_a),
235 .l1clk (l1clk),
236 .siclk(siclk),
237 .soclk(soclk)
238);
239
240// Atomic flag tracking
241// Should place this in the dp FIFO.
242
243// This queue has different timing then the data queue
244// The atomic request indicator comes one cycle earlier than data, along with the request.
245// Also, on a "grant", the queue shifts very next cycle.
246
247// ideally this should be:
248// the term (~av0 & req_new & ~grant_a) allows for the fact that if a grant_a comes with ~av0 & req_new, then the
249// request does not get latched in the FIFO. Basically in this case, the arbiter processes the request directly out
250// of the input register.
251assign av0_in = ((~av0 & req_new & ~grant_a) | (av0 & ~av1 & req_new & grant_a) | (av1 & grant_a) | (av0 & ~grant_a));
252assign av1_in = ((av0 & req_new & ~grant_a) | (av1 & ~grant_a));
253
254assign aqsel0_a = (req_new & ~av0 ) | (req_new & av0 & ~av1 & grant_a);
255assign aqsel1_a = (req_new & av0 & ~grant_a);
256
257assign ashift_a = av1 & grant_a;
258
259ccx_srq_ctl_msff_ctl_macro dff_av0
260 (
261 .scan_in(dff_av0_scanin),
262 .scan_out(dff_av0_scanout),
263 .din (av0_in),
264 .dout (av0),
265 .l1clk (l1clk),
266 .siclk(siclk),
267 .soclk(soclk)
268);
269ccx_srq_ctl_msff_ctl_macro dff_av1
270 (
271 .scan_in(dff_av1_scanin),
272 .scan_out(dff_av1_scanout),
273 .din (av1_in),
274 .dout (av1),
275 .l1clk (l1clk),
276 .siclk(siclk),
277 .soclk(soclk)
278);
279
280assign atom1_in = (aqsel1_a & atom_a) | (~aqsel1_a & atom1);
281
282ccx_srq_ctl_msff_ctl_macro dff_atom1 (
283 .scan_in(dff_atom1_scanin),
284 .scan_out(dff_atom1_scanout),
285 .din (atom1_in),
286 .dout (atom1),
287 .l1clk (l1clk),
288 .siclk(siclk),
289 .soclk(soclk)
290);
291
292
293assign atom0_in = (aqsel0_a & atom_a) | (ashift_a & atom1) | (~aqsel0_a & ~ ashift_a & atom0);
294
295ccx_srq_ctl_msff_ctl_macro dff_atom0 (
296 .scan_in(dff_atom0_scanin),
297 .scan_out(dff_atom0_scanout),
298 .din (atom0_in),
299 .dout (atom0),
300 .l1clk (l1clk),
301 .siclk(siclk),
302 .soclk(soclk)
303);
304
305
306assign atom_x = atom0;
307
308// fixscan start:
309assign dff_grant_x_scanin = scan_in ;
310assign dff_atom_rq_x_scanin = dff_grant_x_scanout ;
311assign dff_qfull_a_scanin = dff_atom_rq_x_scanout ;
312assign dff_v0_scanin = dff_qfull_a_scanout ;
313assign dff_v1_scanin = dff_v0_scanout ;
314assign dff_qfullbar_a_scanin = dff_v1_scanout ;
315assign dff_av0_scanin = dff_qfullbar_a_scanout ;
316assign dff_av1_scanin = dff_av0_scanout ;
317assign dff_atom1_scanin = dff_av1_scanout ;
318assign dff_atom0_scanin = dff_atom1_scanout ;
319assign scan_out = dff_atom0_scanout ;
320// fixscan end:
321endmodule
322
323
324
325
326
327
328
329// any PARAMS parms go into naming of macro
330
331module ccx_srq_ctl_msff_ctl_macro (
332 din,
333 l1clk,
334 scan_in,
335 siclk,
336 soclk,
337 dout,
338 scan_out);
339wire [0:0] fdin;
340
341 input [0:0] din;
342 input l1clk;
343 input scan_in;
344
345
346 input siclk;
347 input soclk;
348
349 output [0:0] dout;
350 output scan_out;
351assign fdin[0:0] = din[0:0];
352
353
354
355
356
357
358dff #(1) d0_0 (
359.l1clk(l1clk),
360.siclk(siclk),
361.soclk(soclk),
362.d(fdin[0:0]),
363.si(scan_in),
364.so(scan_out),
365.q(dout[0:0])
366);
367
368
369
370
371
372
373
374
375
376
377
378
379endmodule
380
381
382
383
384
385
386
387`endif // `ifndef FPGA
388
389`ifdef FPGA
390// No timescale specified
391module ccx_srq_ctl(qfull_a, qfullbar_a, qsel0_a, qsel1_a, shift_a, q0_holdbar_a,
392 atom_x, req_a, atom_a, grant_a, l1clk, scan_in, ccx_aclk, ccx_bclk,
393 scan_out);
394
395 output qfull_a;
396 output qfullbar_a;
397 output qsel0_a;
398 output qsel1_a;
399 output shift_a;
400 output q0_holdbar_a;
401 output atom_x;
402 input req_a;
403 input atom_a;
404 input grant_a;
405 input l1clk;
406 input scan_in;
407 input ccx_aclk;
408 input ccx_bclk;
409 output scan_out;
410
411 wire siclk;
412 wire soclk;
413 wire dff_grant_x_scanin;
414 wire dff_grant_x_scanout;
415 wire grant_x;
416 wire atom_rq_a;
417 wire atom_rq_x;
418 wire dff_atom_rq_x_scanin;
419 wire dff_atom_rq_x_scanout;
420 wire dff_qfull_a_scanin;
421 wire dff_qfull_a_scanout;
422 wire qfull;
423 wire req_new;
424 wire v0_in;
425 wire v0;
426 wire v1;
427 wire v1_in;
428 wire qfullbar;
429 wire dff_v0_scanin;
430 wire dff_v0_scanout;
431 wire dff_v1_scanin;
432 wire dff_v1_scanout;
433 wire dff_qfullbar_a_scanin;
434 wire dff_qfullbar_a_scanout;
435 wire av0_in;
436 wire av0;
437 wire av1;
438 wire av1_in;
439 wire aqsel0_a;
440 wire aqsel1_a;
441 wire ashift_a;
442 wire dff_av0_scanin;
443 wire dff_av0_scanout;
444 wire dff_av1_scanin;
445 wire dff_av1_scanout;
446 wire atom1_in;
447 wire atom1;
448 wire dff_atom1_scanin;
449 wire dff_atom1_scanout;
450 wire atom0_in;
451 wire atom0;
452 wire dff_atom0_scanin;
453 wire dff_atom0_scanout;
454
455 assign siclk = ccx_aclk;
456 assign soclk = ccx_bclk;
457 assign atom_rq_a = (((atom_a & req_a) & (~qfull_a)) | (atom_rq_x &
458 qfull_a));
459 assign req_new = ((atom_rq_x | req_a) & (~qfull_a));
460 assign v0_in = (((((~v0) & req_new) | ((v0 & req_new) & grant_x)) | (v1
461 & grant_x)) | (v0 & (~grant_x)));
462 assign v1_in = (((v0 & req_new) & (~grant_x)) | (v1 & (~grant_x)));
463 assign qsel0_a = (req_new & ((~v0) | grant_x));
464 assign shift_a = (v1 & grant_x);
465 assign q0_holdbar_a = (~((~qsel0_a) & (~shift_a)));
466 assign qsel1_a = ((v0 & req_new) & (~grant_x));
467 assign qfull = v1_in;
468 assign qfullbar = (~v1_in);
469 assign av0_in = ((((((~av0) & req_new) & (~grant_a)) | (((av0 & (~av1))
470 & req_new) & grant_a)) | (av1 & grant_a)) | (av0 & (~grant_a)));
471 assign av1_in = (((av0 & req_new) & (~grant_a)) | (av1 & (~grant_a)));
472 assign aqsel0_a = ((req_new & (~av0)) | (((req_new & av0) & (~av1)) &
473 grant_a));
474 assign aqsel1_a = ((req_new & av0) & (~grant_a));
475 assign ashift_a = (av1 & grant_a);
476 assign atom1_in = ((aqsel1_a & atom_a) | ((~aqsel1_a) & atom1));
477 assign atom0_in = (((aqsel0_a & atom_a) | (ashift_a & atom1)) | (((~
478 aqsel0_a) & (~ashift_a)) & atom0));
479 assign atom_x = atom0;
480 assign dff_grant_x_scanin = scan_in;
481 assign dff_atom_rq_x_scanin = dff_grant_x_scanout;
482 assign dff_qfull_a_scanin = dff_atom_rq_x_scanout;
483 assign dff_v0_scanin = dff_qfull_a_scanout;
484 assign dff_v1_scanin = dff_v0_scanout;
485 assign dff_qfullbar_a_scanin = dff_v1_scanout;
486 assign dff_av0_scanin = dff_qfullbar_a_scanout;
487 assign dff_av1_scanin = dff_av0_scanout;
488 assign dff_atom1_scanin = dff_av1_scanout;
489 assign dff_atom0_scanin = dff_atom1_scanout;
490 assign scan_out = dff_atom0_scanout;
491
492 msff_ctl_macro dff_grant_x(
493 .scan_in (dff_grant_x_scanin),
494 .scan_out (dff_grant_x_scanout),
495 .din (grant_a),
496 .dout (grant_x),
497 .l1clk (l1clk),
498 .siclk (siclk),
499 .soclk (soclk));
500 msff_ctl_macro dff_atom_rq_x(
501 .scan_in (dff_atom_rq_x_scanin),
502 .scan_out (dff_atom_rq_x_scanout),
503 .din (atom_rq_a),
504 .dout (atom_rq_x),
505 .l1clk (l1clk),
506 .siclk (siclk),
507 .soclk (soclk));
508 msff_ctl_macro dff_qfull_a(
509 .scan_in (dff_qfull_a_scanin),
510 .scan_out (dff_qfull_a_scanout),
511 .din (qfull),
512 .dout (qfull_a),
513 .l1clk (l1clk),
514 .siclk (siclk),
515 .soclk (soclk));
516 msff_ctl_macro dff_v0(
517 .scan_in (dff_v0_scanin),
518 .scan_out (dff_v0_scanout),
519 .din (v0_in),
520 .dout (v0),
521 .l1clk (l1clk),
522 .siclk (siclk),
523 .soclk (soclk));
524 msff_ctl_macro dff_v1(
525 .scan_in (dff_v1_scanin),
526 .scan_out (dff_v1_scanout),
527 .din (v1_in),
528 .dout (v1),
529 .l1clk (l1clk),
530 .siclk (siclk),
531 .soclk (soclk));
532 msff_ctl_macro dff_qfullbar_a(
533 .scan_in (dff_qfullbar_a_scanin),
534 .scan_out (dff_qfullbar_a_scanout),
535 .din (qfullbar),
536 .dout (qfullbar_a),
537 .l1clk (l1clk),
538 .siclk (siclk),
539 .soclk (soclk));
540 msff_ctl_macro dff_av0(
541 .scan_in (dff_av0_scanin),
542 .scan_out (dff_av0_scanout),
543 .din (av0_in),
544 .dout (av0),
545 .l1clk (l1clk),
546 .siclk (siclk),
547 .soclk (soclk));
548 msff_ctl_macro dff_av1(
549 .scan_in (dff_av1_scanin),
550 .scan_out (dff_av1_scanout),
551 .din (av1_in),
552 .dout (av1),
553 .l1clk (l1clk),
554 .siclk (siclk),
555 .soclk (soclk));
556 msff_ctl_macro dff_atom1(
557 .scan_in (dff_atom1_scanin),
558 .scan_out (dff_atom1_scanout),
559 .din (atom1_in),
560 .dout (atom1),
561 .l1clk (l1clk),
562 .siclk (siclk),
563 .soclk (soclk));
564 msff_ctl_macro dff_atom0(
565 .scan_in (dff_atom0_scanin),
566 .scan_out (dff_atom0_scanout),
567 .din (atom0_in),
568 .dout (atom0),
569 .l1clk (l1clk),
570 .siclk (siclk),
571 .soclk (soclk));
572endmodule
573
574`endif // `ifdef FPGA
575