Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: dmu_common_ccc_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_common_ccc_arb | |
36 | ( | |
37 | clk, | |
38 | rst_l, | |
39 | ||
40 | csr_host_0_req, | |
41 | csr_host_1_req, | |
42 | csr_host_2_req, | |
43 | csr_host_3_req, | |
44 | ||
45 | fsm2arb_done, | |
46 | ||
47 | csr_host_0_done, | |
48 | csr_host_1_done, | |
49 | csr_host_2_done, | |
50 | csr_host_3_done, | |
51 | ||
52 | arb2cdp_sel, | |
53 | arb2fsm_valid | |
54 | ); | |
55 | ||
56 | // ---------------------------------------------------------------------------- | |
57 | // Parameters | |
58 | // ---------------------------------------------------------------------------- | |
59 | parameter IDLE = 2'b00, // state machine states | |
60 | BUSY = 2'b01, | |
61 | DONE = 2'b11; | |
62 | ||
63 | // ---------------------------------------------------------------------------- | |
64 | // Ports | |
65 | // ---------------------------------------------------------------------------- | |
66 | input clk; | |
67 | input rst_l; | |
68 | ||
69 | input csr_host_0_req; | |
70 | input csr_host_1_req; | |
71 | input csr_host_2_req; | |
72 | input csr_host_3_req; | |
73 | ||
74 | input fsm2arb_done; | |
75 | ||
76 | output csr_host_0_done; | |
77 | output csr_host_1_done; | |
78 | output csr_host_2_done; | |
79 | output csr_host_3_done; | |
80 | ||
81 | output [`FIRE_CSR_SRCB_BITS] arb2cdp_sel; | |
82 | output arb2fsm_valid; | |
83 | ||
84 | // ---------------------------------------------------------------------------- | |
85 | // Variables | |
86 | // ---------------------------------------------------------------------------- | |
87 | wire [3:0] req; | |
88 | ||
89 | reg [3:0] done, nxt_done; | |
90 | reg [1:0] grant, new_grant, nxt_grant; | |
91 | reg [1:0] state, nxt_state; | |
92 | reg valid, nxt_valid; | |
93 | ||
94 | // ---------------------------------------------------------------------------- | |
95 | // Combinational | |
96 | // ---------------------------------------------------------------------------- | |
97 | // csr host dones | |
98 | wire csr_host_0_done = done[0]; | |
99 | wire csr_host_1_done = done[1]; | |
100 | wire csr_host_2_done = done[2]; | |
101 | wire csr_host_3_done = done[3]; | |
102 | ||
103 | // cdp select and fsm valid | |
104 | assign arb2cdp_sel = grant; | |
105 | wire arb2fsm_valid = valid; | |
106 | ||
107 | // csr host requests | |
108 | assign req[0] = csr_host_0_req; | |
109 | assign req[1] = csr_host_1_req; | |
110 | assign req[2] = csr_host_2_req; | |
111 | assign req[3] = csr_host_3_req; | |
112 | ||
113 | wire any_req = |req; | |
114 | ||
115 | // round-robin new grant | |
116 | always @ (req or grant) begin | |
117 | casez ({grant, req}) // synopsys parallel_case | |
118 | 6'b00_zz1z : new_grant = 2'b01; | |
119 | 6'b00_z10z : new_grant = 2'b10; | |
120 | 6'b00_100z : new_grant = 2'b11; | |
121 | 6'b00_000z : new_grant = 2'b00; | |
122 | ||
123 | 6'b01_z1zz : new_grant = 2'b10; | |
124 | 6'b01_10zz : new_grant = 2'b11; | |
125 | 6'b01_00z1 : new_grant = 2'b00; | |
126 | 6'b01_00z0 : new_grant = 2'b01; | |
127 | ||
128 | 6'b10_1zzz : new_grant = 2'b00; | |
129 | 6'b10_0zz1 : new_grant = 2'b00; | |
130 | 6'b10_0z10 : new_grant = 2'b00; | |
131 | 6'b10_0z00 : new_grant = 2'b00; | |
132 | ||
133 | 6'b11_zzz1 : new_grant = 2'b00; | |
134 | 6'b11_zz10 : new_grant = 2'b00; | |
135 | 6'b11_z100 : new_grant = 2'b00; | |
136 | 6'b11_z000 : new_grant = 2'b00; | |
137 | endcase | |
138 | end | |
139 | ||
140 | always @ (state or any_req or fsm2arb_done) begin | |
141 | case (state) // synopsys parallel_case | |
142 | IDLE : begin | |
143 | if (any_req) nxt_state = BUSY; | |
144 | else nxt_state = IDLE; | |
145 | end | |
146 | BUSY : begin | |
147 | if (fsm2arb_done) nxt_state = DONE; | |
148 | else nxt_state = BUSY; | |
149 | end | |
150 | DONE : nxt_state = IDLE; | |
151 | default : nxt_state = IDLE; | |
152 | endcase | |
153 | end | |
154 | ||
155 | always @ (state or nxt_state or new_grant or grant) begin | |
156 | nxt_done = 0; | |
157 | nxt_grant = grant; | |
158 | nxt_valid = 0; | |
159 | case (state) // synopsys parallel_case | |
160 | IDLE : begin | |
161 | case (nxt_state) // synopsys parallel_case | |
162 | BUSY : begin | |
163 | nxt_valid = 1'b1; | |
164 | nxt_grant = new_grant; | |
165 | end | |
166 | default : begin | |
167 | nxt_valid = 0; | |
168 | end | |
169 | endcase | |
170 | end | |
171 | BUSY : begin | |
172 | case (nxt_state) // synopsys parallel_case | |
173 | DONE : begin | |
174 | nxt_done[grant] = 1'b1; | |
175 | end | |
176 | default : begin | |
177 | nxt_done = 0; | |
178 | end | |
179 | endcase | |
180 | end | |
181 | default : begin | |
182 | nxt_done = 0; | |
183 | nxt_valid = 0; | |
184 | end | |
185 | endcase | |
186 | end | |
187 | ||
188 | // ---------------------------------------------------------------------------- | |
189 | // Sequential | |
190 | // ---------------------------------------------------------------------------- | |
191 | always @(posedge clk) begin | |
192 | if (!rst_l) begin | |
193 | done <= 0; | |
194 | grant <= 0; | |
195 | state <= IDLE; | |
196 | valid <= 0; | |
197 | end | |
198 | else begin | |
199 | done <= nxt_done; | |
200 | grant <= nxt_grant; | |
201 | state <= nxt_state; | |
202 | valid <= nxt_valid; | |
203 | end | |
204 | end | |
205 | ||
206 | endmodule // dmu_common_ccc_arb |