blob: 96e9edd23e234235587a882dabd5325fe7439918 [file] [log] [blame]
njn4f9c9342002-04-29 16:03:24 +00001/* I1 cache simulator, generated by vg_cachegen.
2 * total size = 65536 bytes
3 * line size = 64 bytes
4 * associativity = 2-way associative
5 *
6 * This file should be #include-d into vg_cachesim.c
7 */
8
9static char I1_desc_line[] =
10 "desc: I1 cache: 65536 B, 64 B, 2-way associative\n";
11
12static UInt I1_tags[512][2];
13
14static void cachesim_I1_initcache(void)
15{
16 UInt set, way;
17 for (set = 0; set < 512; set++)
18 for (way = 0; way < 2; way++)
19 I1_tags[set][way] = 0;
20}
21
22static __inline__
23void cachesim_I1_doref(Addr a, UChar size, ULong* m1, ULong *m2)
24{
njn9aae6742002-04-30 13:44:01 +000025 register UInt set1 = ( a >> 6) & (512-1);
26 register UInt set2 = ((a + size - 1) >> 6) & (512-1);
njn4f9c9342002-04-29 16:03:24 +000027 register UInt tag = a >> (6 + 9);
28
29 if (set1 == set2) {
30
31 if (tag == I1_tags[set1][0]) {
32 return;
33 }
34 else if (tag == I1_tags[set1][1]) {
35 I1_tags[set1][1] = I1_tags[set1][0];
36 I1_tags[set1][0] = tag;
37 return;
38 }
39 else {
40 /* A miss */
41 I1_tags[set1][1] = I1_tags[set1][0];
42 I1_tags[set1][0] = tag;
43
44 (*m1)++;
45 cachesim_L2_doref(a, size, m2);
46 }
47
48 } else if ((set1 + 1) % 512 == set2) {
49
50 Bool is_I1_miss = False;
51
52 /* Block one */
53 if (tag == I1_tags[set1][0]) {
54 }
55 else if (tag == I1_tags[set1][1]) {
56 I1_tags[set1][1] = I1_tags[set1][0];
57 I1_tags[set1][0] = tag;
58 }
59 else {
60 /* A miss */
61 I1_tags[set1][1] = I1_tags[set1][0];
62 I1_tags[set1][0] = tag;
63
64 is_I1_miss = True;
65 }
66
67 /* Block two */
68 if (tag == I1_tags[set2][0]) {
69 }
70 else if (tag == I1_tags[set2][1]) {
71 I1_tags[set2][1] = I1_tags[set2][0];
72 I1_tags[set2][0] = tag;
73 }
74 else {
75 /* A miss */
76 I1_tags[set2][1] = I1_tags[set2][0];
77 I1_tags[set2][0] = tag;
78
79 is_I1_miss = True;
80 }
81
82 /* Miss treatment */
83 if (is_I1_miss) {
84 (*m1)++;
85 cachesim_L2_doref(a, size, m2);
86 }
87
88 } else {
89 VG_(printf)("\nERROR: Data item 0x%x of size %u bytes is in two non-adjacent\n", a, size);
90 VG_(printf)("sets %d and %d.\n", set1, set2);
91 VG_(panic)("I1 cache set mismatch");
92 }
93}