In: Computer Science
11. (12 pts) Consider a system with 32-bit addresses and a 16KB 8-way set-associative cache. Each cache line contains 64 bytes.
(a) How many bits of an address are used for the offset in this cache?
(b) How many bits of an address are used for the index in this cache?
(c) How many bits of an address are used in the tag for this cache?
(d) What is the value of the tag for 0x000d6ae2?
(e) What is the value of the index for 0x000d6ae2?
(f) What is the value of the offset for 0x000d6ae2?
Solution:
(11)
Given,
=>Address size = 32 bits
=>Cache size = 16 KB
=>8-way set associative cache
=>Line size = 64 B
(a)
Explanation:
Set associative cache:
Tag | Set index | Block offset |
Calculating number of bits for block offset:
=>Number of bits required for block offset = log2(line size in bytes)
=>Number of bits required for block offset = log2(64)
=>Number of bits required for block offset = 6 bits
(b)
Explanation:
Calculating number of bits for set index:
=>Number of lines in the cache = cache size/line size
=>Number of lines in the cache = 16 KB/64 B
=>Number of lines in the cache = 2^4*2^10 B/2^6 B as 1 KB = 2^10 B
=>Number of lines in the cache = 2^14 B/2^6 B
=>Number of lines in the cache = 2^8 lines
=>Number of lines in the cache = 256 lines
=>Number of sets in the cache = number of lines/N-way
=>Number of sets in the cache = 256/8
=>Number of sets in the cache = 32 sets
=>Number of bits required for set index = log2(number of sets)
=>Number of bits required for set index = log2(32)
=>Number of bits required for set index = 5 bits
(c)
Explanation:
Calculating number of bits for tag:
=>Number of bits for tag = total address bits - set index bits - block offset bits
=>Number of bits for tag = 32 bits - 5 bits - 6 bits
=>Number of bits for tag = 21 bits
(d)
Given,
=>Address = 0x000d6ae2
Explanation:
Calculating value of tag:
=>Address = 0x000d6ae2 in hexadecimal
=>Address = 0000 0000 0000 1101 0110 1010 1110 0010 in binary
=>Tag bits = 0 0000 0000 0001 1010 1101
=>Tag bits = 0000 0000 0000 0001 1010 1101
=>Tag value in hexadecimal = 0x0001ad
(e)
Explanation:
Calcualting value of index:
=>Address = 0000 0000 0000 1101 0110 1010 1110 0010 in binary
=>Index bits = 01011
=>Index bits = 0000 1011
=>Index value in hexadecimal = 0x0b
(f)
Explanation:
Calculating value of offset:
=>Address = 0000 0000 0000 1101 0110 1010 1110 0010 in binary
=>Offset bits = 10 0010
=>Offset bits = 0010 0010
=>Offset value in hexadecimal = 0x22
I have explained each and every part with the help fo statements attached to it.