Cache Specifications: The cache size (to store data or instructions) is 256 byte
ID: 2084710 • Letter: C
Question
Cache Specifications:
The cache size (to store data or instructions) is 256 bytes.
The block size is 32 bytes.
The cache is initially empty.
The following is a list of 16-bit memory addresses issued by the processor. Assume that the memory is byte-addressable.
0x0004, 0x000C, 0x0014, 0x0048, 0x0044,0x0105, 0x0050, 0x0018, 0x0210, 0x0020, 0x0024, 0x0106, 0x001C
(a) How many blocks are in the direct-mapped cache?
(b) How many bits are needed for the tag, index and block-offset fields of the 16-bit address?
(c) Determine the tag, index and block-offset for each address.
(d) Identify each address as either a cache hit or a cache miss.
(e) Show the final contents of the direct-mapped cache.
(f) Calculate the total size (in bits) of the direct-mapped cache.
Explanation / Answer
Cache size for storing data information is 256 bytes, block size is 32 bytes. Each 16-bit memory address is issued by the processor assuming the memory is byte-addressable.
0x0004, 0x000C, 0x0014, 0x0048, 0x0044,0x0105, 0x0050, 0x0018, 0x0210, 0x0020, 0x0024, 0x0106, 0x001C.
a)
Tag - 31-10
Index – 9-5
Offset – 4-0
Therefore the no of blocks for direct mapped cache will be 2index = 25 = 32 bytes.
b)
Offset size: log2(cache line size) = log2(24)=4 bits
Index size: log2(# of lines) = log2(28)=8 bits
Where # of lines can be calculated as the ratio of the cache size by the ratio of cache line size and # of lines.
# of lines = cache size/(cache line size/# of lines) = 213/(24/2) = 28.
Tag size: 32-4-8 = 20 bits.
c)
For this answer please follow the table below;
Address
index
tag
offset
0x0004
0x00
0001
00
0x000C
0x00
0011
00
0x0014
0x00
0101
00
0x0048
0x01
0010
00
0x0044
0x01
0001
00
0x0105
0x10
0001
01
0x0050
0x01
0100
00
0x0018
0x00
0110
00
0x0210
0x04
0100
00
0x0020
0x00
1000
00
0x0024
0x00
1001
00
0x0106
0x04
0001
10
0x001C
0x00
0111
00
d) Hit/Miss table vs Address
Address
Access Type
0x0004
Hit
0x000C
Miss
0x0014
Hit
0x0048
Miss
0x0044
Hit
0x0105
Miss
0x0050
Miss
0x0018
Miss
0x0210
Miss
0x0020
Miss
0x0024
Hit
0x0106
Miss
0x001C
Miss
Address
index
tag
offset
0x0004
0x00
0001
00
0x000C
0x00
0011
00
0x0014
0x00
0101
00
0x0048
0x01
0010
00
0x0044
0x01
0001
00
0x0105
0x10
0001
01
0x0050
0x01
0100
00
0x0018
0x00
0110
00
0x0210
0x04
0100
00
0x0020
0x00
1000
00
0x0024
0x00
1001
00
0x0106
0x04
0001
10
0x001C
0x00
0111
00