Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / dmu / rtl / dmu_clu_crm_arb.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: dmu_clu_crm_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 ============================================
35module dmu_clu_crm_arb
36 (
37 // clock/reset
38 clk,
39 rst_l,
40
41 // ctl port
42 grant,
43 req,
44 grnt_lck
45 );
46
47 // synopsys sync_set_reset "rst_l"
48
49 // >>>>>>>>>>>>>>>>>>>>>>>>> Parameter Declarations <<<<<<<<<<<<<<<<<<<<<<<<<
50
51 parameter N = 3;
52
53 // >>>>>>>>>>>>>>>>>>>>>>>>> Port Declarations <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
54
55 // --------------------------------------------------------
56 // Clock/Reset Signals
57 // --------------------------------------------------------
58
59 input clk;
60 input rst_l;
61
62 // --------------------------------------------------------
63 // Arbiter Control Port
64 // --------------------------------------------------------
65
66 output [(N-1):0] grant;
67 input [(N-1):0] req;
68 input grnt_lck;
69
70 // >>>>>>>>>>>>>>>>>>>>>>>>> Data Type Declarations <<<<<<<<<<<<<<<<<<<<<<<<<
71
72 // ~~~~~~~~~~~~~~~~~~~~~~~~~ REGISTERS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73
74 // ********** Flops **********
75
76 reg [(N-1):0] pointer_reg;
77
78 // ~~~~~~~~~~~~~~~~~~~~~~~~~ NETS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79
80 wire [(N-1):0] req_masked;
81 wire [(N-1):0] mask_higher_pri_reqs;
82 wire [(N-1):0] grant_masked;
83 wire [(N-1):0] unmask_higher_pri_reqs;
84 wire [(N-1):0] grant_unmasked;
85 wire no_req_masked;
86 wire mask_ptr_sel;
87 wire unmask_ptr_sel;
88
89 // >>>>>>>>>>>>>>>>>>>>>>>>> 0-in Checkers <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
90
91 /* 0in arb
92 -req req[0] req[1] req[2]
93 -gnt (grant[0] & ~grnt_lck) (grant[1] & ~grnt_lck) (grant[2] & ~grnt_lck)
94 -round_robin
95 -known_grant
96 */
97
98 // >>>>>>>>>>>>>>>>>>>>>>>>> RTL Model <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
99
100 // --------------------------------------------------------
101 // Mask_Expand Round-Robin Arbiter
102 // --------------------------------------------------------
103
104 // Simple priority arbitration for masked portion
105 assign req_masked = req & pointer_reg;
106 assign mask_higher_pri_reqs[N-1:1] = (mask_higher_pri_reqs[N-2: 0] |
107 req_masked[N-2:0]);
108 assign mask_higher_pri_reqs[0] = 1'b0;
109 assign grant_masked[N-1:0] = (req_masked[N-1:0] &
110 ~mask_higher_pri_reqs[N-1:0]);
111
112 // Simple priority arbitration for unmasked portion
113 assign unmask_higher_pri_reqs[N-1:1] = (unmask_higher_pri_reqs[N-2:0] |
114 req[N-2:0]);
115 assign unmask_higher_pri_reqs[0] = 1'b0;
116 assign grant_unmasked[N-1:0] = req[N-1:0] & ~unmask_higher_pri_reqs[N-1:0];
117
118 // Use grant_masked if there is any there, otherwise use grant_unmasked
119 assign no_req_masked = ~(|req_masked);
120 assign grant = ({N{no_req_masked}} & grant_unmasked) | grant_masked;
121
122 // Generate arbiter pointer update
123 assign mask_ptr_sel = |req_masked & ~grnt_lck;
124 assign unmask_ptr_sel = |req & ~grnt_lck;
125
126 // Pointer update : only update if there's a req
127 always @ (posedge clk)
128 if (~rst_l)
129 pointer_reg <= {N{1'b1}};
130 else if (mask_ptr_sel) // select if masked arbiter used
131 pointer_reg <= mask_higher_pri_reqs;
132 else if (unmask_ptr_sel) // select if unmasked arbiter used
133 pointer_reg <= unmask_higher_pri_reqs;
134
135endmodule // dmu_clu_crm_arb