Professional Documents
Culture Documents
Word
Assume main memory contains the following: 000 00 00 14 0
000 01 00 26 1
000 10 00 102 2
000 11 00 54 3
001 00 00 63 4
001 01 00 18 5
001 10 00 53 6
001 11 00 265 7
010 00 00 31 8
a) How many bits are needed for the index? cache size = 4, log2 4 = 2 (22 = 4)
b) How many bits are needed for the tag? Assume 32-bit addresses, even though
only the last seven bits are shown. 32 - 2 bits index - 2 bits byte offset = 28
d) Were there any hits? Is there competition? One hit: second reference to word 2.
Three addresses are competing for cache location 0.
Chapter 7 Exercise 2 - SOLUTION
Draw the layout, including valid, tag and data fields, for:
a) 4-word cache, direct-mapped with one-word blocks
b) 4-word cache, direct-mapped with two-word blocks.
Indicate how many index and tag bit for each organization
Now show hits, misses, and final cache contents for the following address references:
0,1,3,5,4,8,5,9
Note: Leave the addresses in decimalyou don't need to show bit patterns.
What is CPI?
.02 * 30 cycles = .6
.05 * .3 * 30 cycles = .45
.6 + .45 + 2 = 3.05 CPI
Assume cache of 16K words, 8-word block size, 32-bit address. Determine the byte
offset/index/tag bits and total cache size (can leave as formula) for:
8-word block size = 3 bit block offset (23 = 8), 2 bit byte offset = 5 bits
OR can think of as
8-word block size * 4 bytes/block = 32 byte block size = 5 bits (25 = 32)