Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: ccx_tag_class.vr | |
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 | #include <vera_defines.vrh> | |
36 | ||
37 | #include <globals.vri> | |
38 | #include <ccx.vri> | |
39 | #include <defines.vri> | |
40 | #include <std_display_defines.vri> | |
41 | ||
42 | #include <std_display_class.vrh> | |
43 | ||
44 | //---------------------------------------------------------- | |
45 | //---------------------------------------------------------- | |
46 | class TAG_MEM { | |
47 | ||
48 | local integer instance; | |
49 | string name; | |
50 | reg type; // I$ or D$ | |
51 | reg [2:0] max_tag; // 7 or 3 | |
52 | reg [6:0] max_line; // 63 or 127 | |
53 | ||
54 | reg [239:0] tag_mem [128]; | |
55 | ||
56 | //---------------------------------------------------------- | |
57 | task new (reg new_type, | |
58 | reg [6:0] new_max_line, | |
59 | reg [2:0] new_max_tag, | |
60 | integer inst=0) { | |
61 | ||
62 | integer i,j; | |
63 | ||
64 | type = new_type; | |
65 | max_tag = new_max_tag; | |
66 | max_line = new_max_line; | |
67 | if (type==DATA_TAG) { | |
68 | name = "dtag"; | |
69 | } else { | |
70 | name = "itag"; | |
71 | } | |
72 | ||
73 | instance = inst; | |
74 | ||
75 | // Initialize memory - all entries are invalid | |
76 | for (i=0; i<=max_line; i=i+1) { | |
77 | tag_mem[i] = 0; | |
78 | } | |
79 | ||
80 | PR_DEBUG(name, MON_DEBUG, psprintf("C%0d type = %b max_line = %d max_tag = %d ",instance,type,max_line,max_tag)); | |
81 | } | |
82 | ||
83 | //---------------------------------------------------------- | |
84 | // Print all valid entries in the table | |
85 | task dump_mem (integer msglevel) { | |
86 | ||
87 | integer i,j; | |
88 | ||
89 | if (msglevel>=MON_NORMAL) { | |
90 | if (type==DATA_TAG) { | |
91 | PR_NORMAL(name, MON_NORMAL, | |
92 | psprintf("--- C%0d D$ TAG MEMORY (valid entries only) --- ",instance)); | |
93 | } else { | |
94 | PR_NORMAL(name, MON_NORMAL, | |
95 | psprintf("--- C%0d I$ TAG MEMORY (valid entries only) --- ",instance)); | |
96 | } | |
97 | } else { | |
98 | if (type==DATA_TAG) { | |
99 | PR_INFO(name, MON_INFO, | |
100 | psprintf("--- C%0d D$ TAG MEMORY (valid entries only) --- ",instance)); | |
101 | } else { | |
102 | PR_INFO(name, MON_INFO, | |
103 | psprintf("--- C%0d I$ TAG MEMORY (valid entries only) --- ",instance)); | |
104 | } | |
105 | } | |
106 | ||
107 | for (i=0; i<=max_line; i=i+1) { | |
108 | if (tag_mem[i] !== 0) dump_line ("Dump",i,msglevel); | |
109 | } | |
110 | } | |
111 | ||
112 | //---------------------------------------------------------- | |
113 | // Print the line | |
114 | task dump_line (string why, reg [6:0] index,integer msglevel) { | |
115 | ||
116 | reg [28:0] tag0,tag1,tag2,tag3,tag4,tag5,tag6,tag7; | |
117 | reg valid0,valid1,valid2,valid3,valid4,valid5,valid6,valid7; | |
118 | ||
119 | error_check(0,index); | |
120 | ||
121 | read_line (index, | |
122 | tag0,tag1,tag2,tag3, | |
123 | tag4,tag5,tag6,tag7, | |
124 | valid0,valid1,valid2,valid3, | |
125 | valid4,valid5,valid6,valid7); | |
126 | ||
127 | ||
128 | if (msglevel>=MON_NORMAL) { | |
129 | PR_NORMAL(name, MON_NORMAL, | |
130 | psprintf({"C%0d tag_mem[%2h] ", | |
131 | "w3-w0 V:T %b:%h %b:%h %b:%h %b:%h [dump_line]%s"}, | |
132 | instance,index, | |
133 | valid3,tag3,valid2,tag2,valid1,tag1,valid0,tag0,why)); | |
134 | if (type!=DATA_TAG) { | |
135 | PR_NORMAL(name, MON_NORMAL, | |
136 | psprintf({"C%0d tag_mem[%2h] ", | |
137 | "w7-w4 V:T %b:%h %b:%h %b:%h %b:%h [dump_line]%s"}, | |
138 | instance,index, | |
139 | valid7,tag7,valid6,tag6,valid5,tag5,valid4,tag4,why)); | |
140 | } | |
141 | } else { | |
142 | PR_INFO(name, MON_INFO, | |
143 | psprintf({"C%0d tag_mem[%2h] ", | |
144 | "w3-w0 V:T %b:%h %b:%h %b:%h %b:%h [dump_line]%s"}, | |
145 | instance,index, | |
146 | valid3,tag3,valid2,tag2,valid1,tag1,valid0,tag0,why)); | |
147 | if (type!=DATA_TAG) { | |
148 | PR_INFO(name, MON_INFO, | |
149 | psprintf({"C%0d tag_mem[%2h] ", | |
150 | "w7-w4 V:T %b:%h %b:%h %b:%h %b:%h [dump_line]%s"}, | |
151 | instance,index, | |
152 | valid7,tag7,valid6,tag6,valid5,tag5,valid4,tag4,why)); | |
153 | } | |
154 | } | |
155 | ||
156 | #ifdef TAG_DEBUG | |
157 | PR_INFO(name, MON_INFO, | |
158 | psprintf({"C%0d tag_mem[%2h] ", | |
159 | "w3-w0 V:T %b:%h %b:%h %b:%h %b:%h (adr) [dump_line]%s"}, | |
160 | instance,index, | |
161 | valid3,tag3>>1,valid2,tag2>>1,valid1,tag1>>1,valid0,tag0>>1,why)); | |
162 | if (type!=DATA_TAG) { | |
163 | PR_INFO(name, MON_INFO, | |
164 | psprintf({"C%0d tag_mem[%2h] ", | |
165 | "w7-w4 V:T %b:%h %b:%h %b:%h %b:%h (adr) [dump_line]%s"}, | |
166 | instance,index, | |
167 | valid7,tag7>>1,valid6,tag6>>1,valid5,tag5>>1,valid4,tag4>>1,why)); | |
168 | } | |
169 | #endif | |
170 | ||
171 | } | |
172 | ||
173 | //---------------------------------------------------------- | |
174 | // Print lines in a group (cache line). | |
175 | // Itag - 2 lines | |
176 | // Dtag - 4 lines | |
177 | // index must be normalized between 0..31 | |
178 | task dump_group (string why, reg [5:0] index) { | |
179 | ||
180 | if (type==DATA_TAG) { | |
181 | dump_line(why, (index*4+0), MON_INFO); | |
182 | dump_line(why, (index*4+1), MON_INFO); | |
183 | dump_line(why, (index*4+2), MON_INFO); | |
184 | dump_line(why, (index*4+3), MON_INFO); | |
185 | } else { | |
186 | dump_line(why, (index*2+0), MON_INFO); | |
187 | dump_line(why, (index*2+1), MON_INFO); | |
188 | } | |
189 | ||
190 | } | |
191 | ||
192 | //---------------------------------------------------------- | |
193 | task write_tag (reg [2:0] way, | |
194 | reg [6:0] index, | |
195 | reg [28:0] tag, | |
196 | reg valid, | |
197 | reg hitCheck=0) { | |
198 | ||
199 | reg [239:0] old_line; | |
200 | reg [239:0] new_line; | |
201 | integer i,count; | |
202 | reg [39:0] pa; | |
203 | ||
204 | error_check(way,index); | |
205 | ||
206 | // Read/Modify/Write | |
207 | old_line = tag_mem[index]; | |
208 | new_line = old_line; | |
209 | ||
210 | ||
211 | #ifdef TAG_DEBUG | |
212 | if (valid) { | |
213 | #endif | |
214 | case (way) { | |
215 | 0: new_line [ 29: 0] = {valid,tag}; | |
216 | 1: new_line [ 59: 30] = {valid,tag}; | |
217 | 2: new_line [ 89: 60] = {valid,tag}; | |
218 | 3: new_line [119: 90] = {valid,tag}; | |
219 | 4: new_line [149:120] = {valid,tag}; | |
220 | 5: new_line [179:150] = {valid,tag}; | |
221 | 6: new_line [209:180] = {valid,tag}; | |
222 | 7: new_line [239:210] = {valid,tag}; | |
223 | } | |
224 | #ifdef TAG_DEBUG | |
225 | } else { | |
226 | case (way) { | |
227 | 0: new_line [ 29] = valid; | |
228 | 1: new_line [ 59] = valid; | |
229 | 2: new_line [ 89] = valid; | |
230 | 3: new_line [119] = valid; | |
231 | 4: new_line [149] = valid; | |
232 | 5: new_line [179] = valid; | |
233 | 6: new_line [209] = valid; | |
234 | 7: new_line [239] = valid; | |
235 | } | |
236 | } | |
237 | #endif | |
238 | ||
239 | pa = get_pa(tag,index); | |
240 | ||
241 | // is the L1 allocating when it doesn't need to? L1 should have hit! | |
242 | if (old_line == new_line && hitCheck) { | |
243 | printf("\n"); | |
244 | dump_line ("write: Old ",index,MON_NORMAL); | |
245 | PR_ERROR(name, MON_ERR, | |
246 | psprintf ("C%0d L1 should have hit! index=%h tag=%h PA[39:0]=%h",instance,index,tag,pa)); | |
247 | printf("\n"); | |
248 | } | |
249 | ||
250 | if (gDbg.info) dump_line ("write_tag: Old ",index,MON_INFO); | |
251 | tag_mem[index] = new_line; | |
252 | if (gDbg.info) dump_line ("write_tag: New ",index,MON_INFO); | |
253 | ||
254 | // check if Multiple hits in tag line that was just written | |
255 | count = 0; | |
256 | for (i=0;i<8;i++) if (new_line[30*i+29:30*i] == {1'b1,tag}) count++; | |
257 | if (count > 1) { | |
258 | printf("\n"); | |
259 | dump_line ("Multiple hits in line",index,MON_NORMAL); | |
260 | PR_ERROR(name, MON_ERR, | |
261 | psprintf ("C%0d Multiple hits in tag table for a single line! PA[39:0]=%h", | |
262 | instance,pa)); | |
263 | printf("\n"); | |
264 | dump_mem(MON_NORMAL); | |
265 | } | |
266 | ||
267 | ||
268 | PR_INFO(name, MON_INFO, | |
269 | psprintf({"C%0d tag_mem[%0h] tag=0x%h way=0x%h PA[39:0]=0x%h [write_tag]"}, | |
270 | instance,index,tag,way,pa)); | |
271 | ||
272 | #ifdef TAG_DEBUG | |
273 | dump_mem(MON_INFO); | |
274 | #endif | |
275 | ||
276 | } | |
277 | ||
278 | //---------------------------------------------------------- | |
279 | // Read tag line and return way if tag hit | |
280 | // way[3:0] is in the format required for the inval.vector in Vack field of CPX pkt | |
281 | function reg [3:0] get_way ( string why, | |
282 | reg [6:0] index, | |
283 | reg [28:0] tag ) { | |
284 | ||
285 | reg [239:0] line; | |
286 | reg [28:0] tag0,tag1,tag2,tag3,tag4,tag5,tag6,tag7; | |
287 | reg valid0,valid1,valid2,valid3,valid4,valid5,valid6,valid7; | |
288 | reg hit0,hit1,hit2,hit3,hit4,hit5,hit6,hit7; | |
289 | reg hit; | |
290 | reg [39:0] pa; | |
291 | ||
292 | if ((type==INSTR_TAG)&&(index>63)) { | |
293 | PR_ERROR(name, MON_ERR, | |
294 | psprintf ("C%0d index=%0d. It cannot be >63 for I_tag table.",instance,index)); | |
295 | } | |
296 | ||
297 | pa = get_pa(tag,index); | |
298 | ||
299 | read_line (index, | |
300 | tag0,tag1,tag2,tag3, | |
301 | tag4,tag5,tag6,tag7, | |
302 | valid0,valid1,valid2,valid3, | |
303 | valid4,valid5,valid6,valid7); | |
304 | ||
305 | hit0 = {tag,1'b1}=={tag0,valid0}; | |
306 | hit1 = {tag,1'b1}=={tag1,valid1}; | |
307 | hit2 = {tag,1'b1}=={tag2,valid2}; | |
308 | hit3 = {tag,1'b1}=={tag3,valid3}; | |
309 | hit4 = {tag,1'b1}=={tag4,valid4}; | |
310 | hit5 = {tag,1'b1}=={tag5,valid5}; | |
311 | hit6 = {tag,1'b1}=={tag6,valid6}; | |
312 | hit7 = {tag,1'b1}=={tag7,valid7}; | |
313 | ||
314 | hit = (hit0 | hit1 | hit2 | hit3 | hit4 | hit5 | hit6 | hit7); | |
315 | ||
316 | if (type==DATA_TAG) { | |
317 | case ({hit7,hit6,hit5,hit4,hit3,hit2,hit1,hit0}) { | |
318 | 8'b00000000: get_way = 4'b0000; // n/a, bittom 2 always 10 if hit | |
319 | 8'b00000001: get_way = 4'b0010; // 0 | |
320 | 8'b00000010: get_way = 4'b0110; // 1 | |
321 | 8'b00000100: get_way = 4'b1010; // 2 | |
322 | 8'b00001000: get_way = 4'b1110; // 3 | |
323 | 8'b00010000, | |
324 | 8'b00100000, | |
325 | 8'b01000000, | |
326 | 8'b10000000: {printf("\n"); | |
327 | dump_line (why,index,MON_NORMAL); | |
328 | PR_NORMAL(name, MON_NORMAL, | |
329 | psprintf({"C%0d hit[7:0] = %b index = %h tag = %h "}, | |
330 | instance,{hit7,hit6,hit5,hit4,hit3,hit2,hit1,hit0},index,tag)); | |
331 | ||
332 | PR_ERROR(name, MON_ERR, | |
333 | psprintf ("C%0d Out of range hit in D$ tag table. One of the bits (7:4) is 1 and shouldn't be. ",instance)); | |
334 | ||
335 | } | |
336 | default : {printf("\n"); | |
337 | dump_line ("Multiple hits in line",index,MON_NORMAL); | |
338 | PR_NORMAL(name, MON_NORMAL, | |
339 | psprintf({"C%0d hit[7:0] = %b index = %h tag = %h "}, | |
340 | instance,{hit7,hit6,hit5,hit4,hit3,hit2,hit1,hit0},index,tag)); | |
341 | ||
342 | PR_ERROR(name, MON_ERR, | |
343 | psprintf ("C%0d Multiple hits in tag table for a single line! PA[39:0]=%h", | |
344 | instance, pa)); | |
345 | printf("\n"); | |
346 | dump_mem(MON_NORMAL); | |
347 | } | |
348 | } | |
349 | } else { | |
350 | case ({hit7,hit6,hit5,hit4,hit3,hit2,hit1,hit0}) { | |
351 | 8'b00000000: get_way = 4'b0000; // N/A, bottom bit always 1 is hit | |
352 | 8'b00000001: get_way = 4'b0001; // 0 | |
353 | 8'b00000010: get_way = 4'b0011; // 1 | |
354 | 8'b00000100: get_way = 4'b0101; | |
355 | 8'b00001000: get_way = 4'b0111; | |
356 | 8'b00010000: get_way = 4'b1001; | |
357 | 8'b00100000: get_way = 4'b1011; | |
358 | 8'b01000000: get_way = 4'b1101; | |
359 | 8'b10000000: get_way = 4'b1111; // 7 | |
360 | default : {printf("\n"); | |
361 | dump_line ("Multiple hits in line",index,MON_NORMAL); | |
362 | PR_NORMAL(name, MON_NORMAL, | |
363 | psprintf({"C%0d hit[7:0] = %b index = %h tag = %h "}, | |
364 | instance,{hit7,hit6,hit5,hit4,hit3,hit2,hit1,hit0},index,tag)); | |
365 | ||
366 | PR_ERROR(name, MON_ERR, | |
367 | psprintf ("C%0d Multiple hits in tag table for a single line! PA[39:0]=%h", | |
368 | instance, pa)); | |
369 | printf("\n"); | |
370 | dump_mem(MON_NORMAL); | |
371 | } | |
372 | } | |
373 | } | |
374 | ||
375 | if (gDbg.info) dump_line (why,index,MON_INFO); | |
376 | PR_INFO(name, MON_INFO, | |
377 | psprintf({"C%0d way[3:0]=%b hit[7:0]=%b index=%0h tag=%h pa=%h [get_way]%s"}, | |
378 | instance,get_way,{hit7,hit6,hit5,hit4,hit3,hit2,hit1,hit0},index,tag,pa,why)); | |
379 | } | |
380 | ||
381 | //---------------------------------------------------------- | |
382 | // Return index that points to the line with a valid entry | |
383 | task search_tagmem (var reg valid, var reg [6:0] index) { | |
384 | ||
385 | integer cnt; | |
386 | ||
387 | cnt = 0; | |
388 | index = random() % (max_line+1); | |
389 | valid = 0; | |
390 | ||
391 | while ((cnt<=max_line)&&!valid) { | |
392 | if (index==max_line) { | |
393 | index = 0; | |
394 | } else { | |
395 | index = index + 1; | |
396 | } | |
397 | valid = line_valid (index); | |
398 | PR_DEBUG (name, MON_DEBUG, | |
399 | psprintf("C%0d count = %0h index = %0h valid = %0b ",instance,cnt,index,valid)); | |
400 | cnt = cnt + 1; | |
401 | } | |
402 | ||
403 | if (!valid) { | |
404 | PR_INFO (name, MON_INFO, | |
405 | psprintf("C%0d No valid entry found in tag table. [search_tagmem]",instance)); | |
406 | } else { | |
407 | PR_INFO (name, MON_INFO, | |
408 | psprintf("C%0d Valid entry found in tag table at index = %0h valid = %b [search_tagmem]",instance,index,valid)); | |
409 | } | |
410 | ||
411 | } | |
412 | ||
413 | //---------------------------------------------------------- | |
414 | // Search line and return tag on any valid entry | |
415 | // Return 0's if no valid entry found | |
416 | task get_tag (reg [6:0] index, var reg valid, var reg [28:0] tag) { | |
417 | ||
418 | reg [28:0] tag0,tag1,tag2,tag3,tag4,tag5,tag6,tag7; | |
419 | reg valid0,valid1,valid2,valid3,valid4,valid5,valid6,valid7; | |
420 | ||
421 | valid = 1'b0; | |
422 | ||
423 | read_line (index, | |
424 | tag0,tag1,tag2,tag3, | |
425 | tag4,tag5,tag6,tag7, | |
426 | valid0,valid1,valid2,valid3, | |
427 | valid4,valid5,valid6,valid7); | |
428 | ||
429 | casex ({valid7,valid6,valid5,valid4,valid3,valid2,valid1,valid0}) { | |
430 | 8'bxxxxxxx1: { tag = tag0; valid = 1'b1;} | |
431 | 8'bxxxxxx10: { tag = tag1; valid = 1'b1;} | |
432 | 8'bxxxxx100: { tag = tag2; valid = 1'b1;} | |
433 | 8'bxxxx1000: { tag = tag3; valid = 1'b1;} | |
434 | 8'bxxx10000: { tag = tag4; valid = 1'b1;} | |
435 | 8'bxx100000: { tag = tag5; valid = 1'b1;} | |
436 | 8'bx1000000: { tag = tag6; valid = 1'b1;} | |
437 | 8'b10000000: { tag = tag7; valid = 1'b1;} | |
438 | 8'b00000000: { tag = 29'b0; valid = 1'b0;} | |
439 | default: PR_ERROR(name, MON_ERR, | |
440 | psprintf ("C%0d BENCH Problem: get_tag should not hit case default.",instance)); | |
441 | ||
442 | } | |
443 | } | |
444 | ||
445 | //---------------------------------------------------------- | |
446 | // Read line and return individual fields in the line | |
447 | task read_line (reg [6:0] index, | |
448 | var reg [28:0] tag0, | |
449 | var reg [28:0] tag1, | |
450 | var reg [28:0] tag2, | |
451 | var reg [28:0] tag3, | |
452 | var reg [28:0] tag4, | |
453 | var reg [28:0] tag5, | |
454 | var reg [28:0] tag6, | |
455 | var reg [28:0] tag7, | |
456 | var reg valid0, | |
457 | var reg valid1, | |
458 | var reg valid2, | |
459 | var reg valid3, | |
460 | var reg valid4, | |
461 | var reg valid5, | |
462 | var reg valid6, | |
463 | var reg valid7 | |
464 | ) { | |
465 | ||
466 | reg [239:0] line; | |
467 | ||
468 | line = tag_mem [index]; | |
469 | tag0 = line [ 28: 0]; | |
470 | tag1 = line [ 58: 30]; | |
471 | tag2 = line [ 88: 60]; | |
472 | tag3 = line [118: 90]; | |
473 | tag4 = line [148:120]; | |
474 | tag5 = line [178:150]; | |
475 | tag6 = line [208:180]; | |
476 | tag7 = line [238:210]; | |
477 | valid0 = line [ 29]; | |
478 | valid1 = line [ 59]; | |
479 | valid2 = line [ 89]; | |
480 | valid3 = line [119]; | |
481 | valid4 = line [149]; | |
482 | valid5 = line [179]; | |
483 | valid6 = line [209]; | |
484 | valid7 = line [239]; | |
485 | ||
486 | } | |
487 | ||
488 | //---------------------------------------------------------- | |
489 | // Use this function to calculate the pa from the tag & index | |
490 | function reg [39:0] get_pa (reg [28:0] tag, reg [6:0] index) { | |
491 | if (type==DATA_TAG) { | |
492 | get_pa = {tag,index[6:0],4'h0}; | |
493 | } else { | |
494 | get_pa = {tag,index[5:0],5'h0}; | |
495 | } | |
496 | } | |
497 | //---------------------------------------------------------- | |
498 | function reg line_valid (reg [6:0] index) { | |
499 | ||
500 | reg [28:0] tag0,tag1,tag2,tag3,tag4,tag5,tag6,tag7; | |
501 | reg valid0,valid1,valid2,valid3,valid4,valid5,valid6,valid7; | |
502 | ||
503 | read_line (index, | |
504 | tag0,tag1,tag2,tag3, | |
505 | tag4,tag5,tag6,tag7, | |
506 | valid0,valid1,valid2,valid3, | |
507 | valid4,valid5,valid6,valid7); | |
508 | ||
509 | line_valid = valid0 | valid1 | valid2 | valid3 | | |
510 | valid4 | valid5 | valid6 | valid7; | |
511 | ||
512 | } | |
513 | ||
514 | //---------------------------------------------------------- | |
515 | task error_check (reg [2:0] way, | |
516 | reg [6:0] index) { | |
517 | if ((type==DATA_TAG)&&(way>3)) { | |
518 | PR_ERROR(name, MON_ERR, | |
519 | psprintf ("C%0d way=%0d. It cannot be >3 for D_tag table.",instance,way)); | |
520 | } | |
521 | if ((type==INSTR_TAG)&&(index>63)) { | |
522 | PR_ERROR(name, MON_ERR, | |
523 | psprintf ("C%0d index=%0d. It cannot be >63 for I_tag table.",instance,index)); | |
524 | } | |
525 | } | |
526 | ||
527 | //---------------------------------------------------------- | |
528 | // Create 32 or 24 bit invalidation vector to be used in response data field | |
529 | // Can be used for Vack or Vinv in CPX packets | |
530 | task create_vector (reg format, | |
531 | reg [3:0] way, | |
532 | var reg [31:0] vect) { | |
533 | ||
534 | vect = 32'b0; | |
535 | if (format==WAY_3BIT) { | |
536 | case (instance) { | |
537 | 0: vect[ 2: 0] = way[3:1]; | |
538 | 1: vect[ 5: 3] = way[3:1]; | |
539 | 2: vect[ 8: 6] = way[3:1]; | |
540 | 3: vect[11: 9] = way[3:1]; | |
541 | 4: vect[14:12] = way[3:1]; | |
542 | 5: vect[17:15] = way[3:1]; | |
543 | 6: vect[20:18] = way[3:1]; | |
544 | 7: vect[23:21] = way[3:1]; | |
545 | } | |
546 | } else { | |
547 | case (instance) { | |
548 | 0: vect[ 3: 0] = way; | |
549 | 1: vect[ 7: 4] = way; | |
550 | 2: vect[11: 8] = way; | |
551 | 3: vect[15:12] = way; | |
552 | 4: vect[19:16] = way; | |
553 | 5: vect[23:20] = way; | |
554 | 6: vect[27:24] = way; | |
555 | 7: vect[31:28] = way; | |
556 | } | |
557 | } | |
558 | } | |
559 | ||
560 | //---------------------------------------------------------- | |
561 | // Index is normalized to be 0..31 (pointer to L2 cache line - top of group) | |
562 | task evict_group (reg [28:0] evict_tag, | |
563 | reg [4:0] evict_index, | |
564 | var reg [111:0] inv_vect) { | |
565 | ||
566 | reg [6:0] index [4]; | |
567 | reg [3:0] way [4]; | |
568 | reg [3:0] tmp_way; | |
569 | reg [31:0] vect0,vect1,vect2,vect3; | |
570 | integer i; | |
571 | ||
572 | dump_group("Before Evict",evict_index); | |
573 | ||
574 | //-------------------- | |
575 | // Default values | |
576 | vect0 = 32'b0; | |
577 | vect1 = 32'b0; | |
578 | vect2 = 32'b0; | |
579 | vect3 = 32'b0; | |
580 | inv_vect = 112'b0; | |
581 | for (i=0; i<=3; i=i+1) { | |
582 | index[i] = 5'b0; | |
583 | way[i] = 4'b0; | |
584 | } | |
585 | ||
586 | //-------------------- | |
587 | // dtag | |
588 | if (type==DATA_TAG) { | |
589 | ||
590 | //-------------------- | |
591 | // Setup Indexes for the group of lines that we are going to evict | |
592 | index[0] = (evict_index * 4); | |
593 | index[1] = (evict_index * 4) + 1; | |
594 | index[2] = (evict_index * 4) + 2; | |
595 | index[3] = (evict_index * 4) + 3; | |
596 | ||
597 | //-------------------- | |
598 | // Repeat get_way for all lines in the L2 cache line | |
599 | // Get the way for the tag (even if no valid entry) | |
600 | // since it is returned in inval vector | |
601 | ||
602 | for (i=0; i<=3; i=i+1) { | |
603 | way[i] = get_way ("Get_evict",index[i],evict_tag); | |
604 | } | |
605 | ||
606 | //-------------------- | |
607 | // Invalidate the entries in the eviction group | |
608 | // (for the lines that had a valid entry) | |
609 | for (i=0; i<=3; i=i+1) { | |
610 | tmp_way = way[i]; | |
611 | if (tmp_way!=4'b0) { | |
612 | tmp_way = {2'b0,tmp_way[3:2]}; | |
613 | write_tag (tmp_way[2:0],index[i],29'b0,TAG_INVAL); | |
614 | } | |
615 | } | |
616 | create_vector (WAY_4BIT, way[0], vect0); | |
617 | create_vector (WAY_3BIT, way[1], vect1); | |
618 | create_vector (WAY_4BIT, way[2], vect2); | |
619 | create_vector (WAY_3BIT, way[3], vect3); | |
620 | ||
621 | //-------------------- | |
622 | // itag | |
623 | } else { | |
624 | ||
625 | //-------------------- | |
626 | // Setup Indexes for the group of lines that we are going to evict | |
627 | index[0] = (evict_index * 2); | |
628 | index[1] = (evict_index * 2) + 1; | |
629 | ||
630 | //-------------------- | |
631 | // Repeat get_way for all lines in the L2 cache line | |
632 | // Get the way for the tag (even if no valid entry) | |
633 | // since it is returned in inval vector | |
634 | ||
635 | for (i=0; i<=1; i=i+1) { | |
636 | way[i] = get_way ("Get_evict",index[i],evict_tag); | |
637 | } | |
638 | ||
639 | // Invalidate the entries in the eviction group | |
640 | // (for the lines that had a valid entry) | |
641 | for (i=0; i<=1; i=i+1) { | |
642 | tmp_way = way[i]; | |
643 | if (tmp_way!=4'b0) { | |
644 | tmp_way = {1'b0,tmp_way[3:1]}; | |
645 | write_tag (tmp_way[2:0],index[i],29'b0,TAG_INVAL); | |
646 | } | |
647 | } | |
648 | create_vector (WAY_4BIT, way[0], vect0); | |
649 | vect1 = 32'b0; | |
650 | create_vector (WAY_4BIT, way[1], vect2); | |
651 | vect3 = 32'b0; | |
652 | ||
653 | } | |
654 | ||
655 | inv_vect = {vect3[23:0],vect2,vect1[23:0],vect0}; | |
656 | ||
657 | dump_group("After Evict",evict_index); | |
658 | } | |
659 | ||
660 | //---------------------------------------------------------- | |
661 | ||
662 | } // end class CCX_REQ | |
663 | ||
664 | //---------------------------------------------------------- | |
665 | // END OF FILE | |
666 | //---------------------------------------------------------- |