Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: dmu_psb_ptg.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_psb_ptg | |
36 | ( | |
37 | // Control Signals | |
38 | clk, | |
39 | rst_l, | |
40 | ||
41 | // PIC-PTG INTERFACE | |
42 | // PIC-PTG Interface (Internal Input from PIC to PTG) | |
43 | tag_deq, | |
44 | ||
45 | // PTG-PIC Interface (Internal Output to PIC) | |
46 | no_tag_avail, | |
47 | tag_issue, | |
48 | ||
49 | // PCE-PTG INTERFACE | |
50 | // PCE-PTG Interface (Internal Input from PCE to PTG) | |
51 | tag_enq, | |
52 | tag_retire, | |
53 | ||
54 | // Debug ports | |
55 | ptg2dbg_dbg_a, | |
56 | ptg2dbg_dbg_b, | |
57 | dbg2ptg_dbg_sel_a, | |
58 | dbg2ptg_dbg_sel_b | |
59 | ); | |
60 | ||
61 | // synopsys sync_set_reset "rst_l" | |
62 | ||
63 | /////////////////////////////////////////////////////////////////////// | |
64 | // ************************* Parameters ************************* | |
65 | /////////////////////////////////////////////////////////////////////// | |
66 | ||
67 | parameter TAG_NUM = 32; // 32; number of tags | |
68 | parameter TAG_WDTH = 5; // 5; number of bits to encode tag: log2(TAG_NUM) | |
69 | ||
70 | ////////////////////////////////////////////////////////////////////// | |
71 | //************************* Port Declarations ******************* | |
72 | ////////////////////////////////////////////////////////////////////// | |
73 | ||
74 | // Control Signals | |
75 | input clk; | |
76 | input rst_l; | |
77 | ||
78 | // generator external interface inputs | |
79 | ||
80 | input tag_deq; // request from PRM for pktag | |
81 | input tag_enq; // request from CRM to retire pktag | |
82 | input [(TAG_WDTH-1):0] tag_retire; // pktag from CRM | |
83 | ||
84 | // generator external interface outputs | |
85 | output no_tag_avail; // all pktags are in use | |
86 | output [(TAG_WDTH-1):0] tag_issue; // pktag to be issued to PRM per request | |
87 | ||
88 | // Debug Wires | |
89 | output [`FIRE_DBG_DATA_BITS] ptg2dbg_dbg_a; | |
90 | output [`FIRE_DBG_DATA_BITS] ptg2dbg_dbg_b; | |
91 | ||
92 | input [2:0] dbg2ptg_dbg_sel_a; | |
93 | input [2:0] dbg2ptg_dbg_sel_b; | |
94 | ||
95 | ////////////////////////////////////////////////////////////////////// | |
96 | //*********************** Wires and Regs ************************ | |
97 | ////////////////////////////////////////////////////////////////////// | |
98 | ||
99 | wire tag_deq; | |
100 | reg [TAG_WDTH-1:0] next_tag_issue; | |
101 | wire n_no_tag_avail; | |
102 | ||
103 | wire tag_enq; | |
104 | wire [TAG_WDTH-1:0] tag_retire; | |
105 | ||
106 | ||
107 | wire [TAG_NUM-1:0] tag_issue_vctr; | |
108 | wire [TAG_NUM-1:0] next_tag; | |
109 | wire [TAG_NUM-1:0] higher_priority_tag; | |
110 | ||
111 | // non flops | |
112 | wire [TAG_NUM-1:0] nxt_tag_pool; | |
113 | reg [TAG_NUM-1:0] tag_dec_vctr; | |
114 | reg [TAG_NUM-1:0] dcd_vec; | |
115 | ||
116 | // flops | |
117 | reg [TAG_NUM-1:0] tag_pool; | |
118 | reg [TAG_WDTH-1:0] tag_issue; | |
119 | reg no_tag_avail; | |
120 | ||
121 | reg [5:0] count; | |
122 | reg ptg_idle; | |
123 | ||
124 | // debug | |
125 | reg [2:0] dbg_sel [0:1]; | |
126 | reg [`FIRE_DBG_DATA_BITS] dbg_bus [0:1]; | |
127 | reg [`FIRE_DBG_DATA_BITS] nxt_dbg_bus [0:1]; | |
128 | ||
129 | // debug ports | |
130 | wire [`FIRE_DBG_DATA_BITS] ptg2dbg_dbg_a; // PTG debug output a | |
131 | wire [`FIRE_DBG_DATA_BITS] ptg2dbg_dbg_b; // PTG debug output b | |
132 | wire [2:0] dbg2ptg_dbg_sel_a; // PTG debug select a | |
133 | wire [2:0] dbg2ptg_dbg_sel_b; // PTG debug select b | |
134 | ||
135 | integer i; | |
136 | ||
137 | ////////////////////////////////////////////////////////////////////// | |
138 | // ******** Zero-in checkers************************************ | |
139 | ////////////////////////////////////////////////////////////////////// | |
140 | ||
141 | // 0in bus_id -req tag_deq -req_id tag_issue -ret tag_enq -ret_id tag_retire -max_ids 32 | |
142 | // 0in encoder -in next_tag -out next_tag_issue -zero off | |
143 | // 0in decoder -in tag_retire -out dcd_vec | |
144 | ||
145 | ////////////////////////////////////////////////////////////////////// | |
146 | // ********************* Combinational Logic *********************** | |
147 | ////////////////////////////////////////////////////////////////////// | |
148 | ||
149 | // debug | |
150 | ||
151 | always @ (dbg2ptg_dbg_sel_a or dbg2ptg_dbg_sel_b) | |
152 | begin | |
153 | dbg_sel[0] = dbg2ptg_dbg_sel_a; | |
154 | dbg_sel[1] = dbg2ptg_dbg_sel_b; | |
155 | end | |
156 | ||
157 | always @ (dbg_sel[0] or dbg_sel[1] or tag_enq or tag_deq or tag_issue or tag_retire | |
158 | or no_tag_avail or ptg_idle) | |
159 | begin | |
160 | for (i = 0; i < 2; i = i + 1) | |
161 | begin | |
162 | case (dbg_sel[i]) // synopsys parallel_case infer_mux | |
163 | 3'b000: nxt_dbg_bus[i] = {2'b0, tag_enq, tag_retire}; | |
164 | 3'b001: nxt_dbg_bus[i] = {1'b0, no_tag_avail, tag_deq, tag_issue}; | |
165 | 3'b010: nxt_dbg_bus[i] = 8'b0; | |
166 | 3'b011: nxt_dbg_bus[i] = 8'b0; | |
167 | 3'b100: nxt_dbg_bus[i] = 8'b0; | |
168 | 3'b101: nxt_dbg_bus[i] = 8'b0; | |
169 | 3'b110: nxt_dbg_bus[i] = 8'b0; | |
170 | 3'b111: nxt_dbg_bus[i] = {7'b0,ptg_idle}; | |
171 | endcase | |
172 | end | |
173 | end | |
174 | ||
175 | assign ptg2dbg_dbg_a = dbg_bus[0]; | |
176 | assign ptg2dbg_dbg_b = dbg_bus[1]; | |
177 | ||
178 | // end debug | |
179 | ||
180 | //************************************ | |
181 | // CLEAR (RETIRE) TAG | |
182 | //************************************ | |
183 | // if tag pool is empty the retired tag becomes the next tag to issue | |
184 | always @ (tag_retire or tag_enq or no_tag_avail) | |
185 | begin | |
186 | if(no_tag_avail & tag_enq) | |
187 | begin | |
188 | dcd_vec = {TAG_NUM{1'b0}}; | |
189 | dcd_vec[tag_retire] = 1'b1; | |
190 | tag_dec_vctr = dcd_vec & {TAG_NUM{1'b0}}; | |
191 | end | |
192 | else | |
193 | begin | |
194 | dcd_vec = {TAG_NUM{1'b0}}; | |
195 | dcd_vec[tag_retire] = 1'b1; | |
196 | tag_dec_vctr = dcd_vec & {TAG_NUM{tag_enq}}; | |
197 | end | |
198 | end // always @ (tag_retire or tag_enq) | |
199 | ||
200 | //************************************ | |
201 | // ISSUE TAG | |
202 | //************************************ | |
203 | ||
204 | assign tag_issue_vctr = (next_tag & {TAG_NUM{tag_deq}}); | |
205 | ||
206 | // generate "next tag pool" storage vector | |
207 | assign nxt_tag_pool = (tag_dec_vctr | tag_pool) & ~tag_issue_vctr; | |
208 | ||
209 | // generate full signal | |
210 | assign n_no_tag_avail = ~(|tag_pool); | |
211 | ||
212 | // Idle counter | |
213 | ||
214 | always @(posedge clk) | |
215 | if (~rst_l) | |
216 | count <= 6'b00_0000; | |
217 | else if(tag_enq | tag_deq) | |
218 | begin | |
219 | if (tag_deq & tag_enq) | |
220 | count <= count; | |
221 | else if (tag_deq) | |
222 | count <= count + 1'b1; | |
223 | else | |
224 | count <= count - 1'b1; | |
225 | end | |
226 | ||
227 | always @(count) | |
228 | if (count == 6'b00_0000) | |
229 | ptg_idle = 1'b1; | |
230 | else | |
231 | ptg_idle = 1'b0; | |
232 | ||
233 | ||
234 | always @(posedge clk) | |
235 | if (~rst_l) | |
236 | no_tag_avail <= 1'b0; | |
237 | else if (tag_deq) | |
238 | no_tag_avail <= n_no_tag_avail; | |
239 | else if (tag_enq) | |
240 | no_tag_avail <= 1'b0; | |
241 | ||
242 | // "tag pool" storage vector: 1 = avail, 0 = used | |
243 | always @(posedge clk) | |
244 | if (~rst_l) | |
245 | tag_pool <= 32'hffff_fffe; // all tags available on reset | |
246 | else | |
247 | tag_pool <= nxt_tag_pool; // retire/issue tags | |
248 | ||
249 | //*********************************** | |
250 | // priority select | |
251 | //*********************************** | |
252 | ||
253 | assign higher_priority_tag[TAG_NUM-1:1] = higher_priority_tag[TAG_NUM-2:0] | tag_pool[TAG_NUM-2:0]; | |
254 | assign higher_priority_tag[0] = 1'b0; | |
255 | assign next_tag[TAG_NUM-1:0] = tag_pool[TAG_NUM-1:0] & ~higher_priority_tag[TAG_NUM-1:0]; | |
256 | ||
257 | //*********************************** | |
258 | // encode tag | |
259 | //*********************************** | |
260 | ||
261 | ||
262 | always @(next_tag) | |
263 | begin | |
264 | ||
265 | next_tag_issue[0] = (next_tag[1] | next_tag[3] | next_tag[5] | | |
266 | next_tag[7] | next_tag[9] | next_tag[11] | | |
267 | next_tag[13] | next_tag[15] | | |
268 | next_tag[17] | next_tag[19] | next_tag[21] | | |
269 | next_tag[23] | next_tag[25] | next_tag[27] | | |
270 | next_tag[29] | next_tag[31]); | |
271 | ||
272 | next_tag_issue[1] = (next_tag[2] | next_tag[3] | next_tag[6] | | |
273 | next_tag[7] | next_tag[10] | next_tag[11] | | |
274 | next_tag[14] | next_tag[15] | | |
275 | next_tag[18] | next_tag[19] | next_tag[22] | | |
276 | next_tag[23] | next_tag[26] | next_tag[27] | | |
277 | next_tag[30] | next_tag[31]); | |
278 | ||
279 | next_tag_issue[2] = (next_tag[4] | next_tag[5] | next_tag[6] | | |
280 | next_tag[7] | next_tag[12] | next_tag[13] | | |
281 | next_tag[14] | next_tag[15] | | |
282 | next_tag[20] | next_tag[21] | next_tag[22] | | |
283 | next_tag[23] | next_tag[28] | next_tag[29] | | |
284 | next_tag[30] | next_tag[31]); | |
285 | ||
286 | next_tag_issue[3] = (next_tag[8] | next_tag[9] | next_tag[10] | | |
287 | next_tag[11] | next_tag[12] | next_tag[13] | | |
288 | next_tag[14] | next_tag[15] | | |
289 | next_tag[24] | next_tag[25] | next_tag[26] | | |
290 | next_tag[27] | next_tag[28] | next_tag[29] | | |
291 | next_tag[30] | next_tag[31]); | |
292 | ||
293 | next_tag_issue[4] = (next_tag[16] | next_tag[17] | next_tag[18] | | |
294 | next_tag[19] | next_tag[20] | next_tag[21] | | |
295 | next_tag[22] | next_tag[23] | | |
296 | next_tag[24] | next_tag[25] | next_tag[26] | | |
297 | next_tag[27] | next_tag[28] | next_tag[29] | | |
298 | next_tag[30] | next_tag[31]); | |
299 | end // always @ (next_tag) | |
300 | ||
301 | always @(posedge clk) | |
302 | if (~rst_l) | |
303 | tag_issue <= {TAG_WDTH{1'b0}}; | |
304 | else if (tag_enq & no_tag_avail) | |
305 | tag_issue <= tag_retire; | |
306 | ||
307 | else if (tag_deq) | |
308 | tag_issue <= next_tag_issue; | |
309 | ||
310 | // Debug port outputs | |
311 | always @ (posedge clk) | |
312 | begin | |
313 | if(~rst_l) | |
314 | for (i = 0; i < 2; i = i + 1) | |
315 | dbg_bus[i] <= 8'h00; | |
316 | else | |
317 | for (i = 0; i < 2; i = i + 1) | |
318 | dbg_bus[i] <= nxt_dbg_bus[i]; | |
319 | end // always @ (posedge clk) | |
320 | ||
321 | endmodule // dmu_psb_ptg |