

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


In the following diagram, each blank box in the CPU Cache represents 8 bits (1 byte) of data. Our
memory is byte-addressed, meaning that there is one address for each byte. Compare this to word-
addressed, which means that there is one address for each word.
Index bits=log 2
(Number of index rows) Offset bits=log 2
(Number of offsets columns)
Tag bits Index bits Offset bits Total
What type of cache is this? fully associative
Tag bits Index bits Offset bits Total
What type of cache is this? 2 - way set associative
Tag bits Index bits Offset bits Total
What type of cache is this? direct mapped
diagram.
of 0xFEEDF00D?
Tag: 111111101 (0x1FD) Index: 1101101111100000 (0xDBE0) Offset: 0001101 (0x0D)
row includes only the cache data, the tag, and the valid bit.
Address size
(bits) Cache size Block size Tag bits Index bits Offset bits Bits per row
Cache
Offset
Cache
Index
Number
Offset
Cache
Index
Number
Offset
Cache
Index
Number
Offset
16 4KiB 4B 4 10 2 3 2+4+
32 32KiB 16B
17 11 4 128+17+
64 KiB 16B 16 12 4 128+16+
64 2048KiB 128B 43 14 7 1068
Assume we have the following cache. Of the 32 bits in each address, which bits do we use to find the
row of the cache to use? We use the 4
th
and 5
th
least significant bit since the offset is 3 bits
Classify each of the following byte memory accesses as a cache hit (H), cache miss (M), or cache miss
with replacement (R).
0x0000000 4 Index 0, Tag 0: M
0x0000000 5 Index 0, Tag 0: H
0x000000 68 Index 1, Tag 3: M
4.0x000000C8 Index 1, Tag 6: R
5 .0x000000 68 Index 1, Tag 3: R
0x000000DD Index 3, Tag 6: M
0x000000 45 Index 0, Tag 2: R
0x0000000 4 Index 0, Tag 0: R
0x000000C8 Index 1, Tag 6: R
#define NUM_INTS 8192
int A[NUM_INTS]; /* A lives at 0x10000 0 */
int i, total = 0;
for (i = 0; i < NUM_INTS; i += 128) { A[i] = i; } /* Line 1 */
for (i = 0; i < NUM_INTS; i += 128) { total += A[i]; } /* Line 2 */
Let’s say you have a byte-addressed computer with a total memory of 1MiB. It features a 16KiB CPU
cache with 1KiB blocks.
The integer accesses are 4*128=512 bytes apart, which means there are 2 accesses per block.
The first accesses in each block is a cache miss, but the second is a hit because A[i] and
A[i+128] are in the same cache block.
The size of A is 8192*4 = 2
15
bytes. This is exactly twice the size of our cache. At the end of
line 1, we have the second half of A inside the cache, while in line 2 we start accesses from
C h
Ind x
Numb
ffs t