13-Cache Memory Mapping Concepts-14-03-2024
13-Cache Memory Mapping Concepts-14-03-2024
Problem-01:
Consider a direct mapped cache of size 16 KB with block size 256 bytes. The size of main memory is 128 KB.
Find-
Solution-
Given-
Cache memory size = 16 KB, Block size = Frame size = Line size = 256 bytes
Main memory size = 128 KB
We have,
We have,
= Cache size / Line size= 16 KB / 256 bytes= 214 bytes / 28 bytes = 26 lines
= Number of bits in physical address – (Number of bits in line number + Number of bits in block offset)
= 26 x 3 bits
= 192 bits
= 24 bytes
Consider a direct mapped cache of size 512 KB with block size 1 KB. There are 7 bits in the tag. Find-
Given- Cache memory size = 512 KB , Block size = Frame size = Line size = 1 KB, Number of bits in tag = 7 bits
We have,
= Number of bits in tag + Number of bits in line number + Number of bits in block offset
We have,
= 226 bytes = 64 MB
= 29 x 7 bits = 3584 bits = 448 bytes Thus, size of tag directory = 448 bytes
Problem-03:
Consider a direct mapped cache with block size 4 KB. The size of main memory is 16 GB and there are 10 bits in
the tag. Find-
Solution-
Given-
We have,
= 16 GB
= 234 bytes
We have,
Block size
= 4 KB
= 212 bytes
= 34 bits – 22 bits
= 12 bits
We have-
= 212 x 4 KB
= 214 KB
= 16 MB
= 40960 bits
= 5120 bytes
Problem-04:
Consider a direct mapped cache of size 32 KB with block size 32 bytes. The CPU generates 32 bit addresses. The
number of bits needed for cache indexing and the number of tag bits are respectively- choose the correct answer
1. 10, 17
2. 10, 22
3. 15, 17
4. 5, 17
Solution-
Given-
We have,
Block size
= 32 bytes
= 25 bytes
= 32 KB / 32 bytes
= 210 lines
= 10 bits
= Number of bits in physical address – (Number of bits in line number + Number of bits in block offset)
= 17 bits
Problem-05:
Consider a machine with a byte addressable main memory of 232 bytes divided into blocks of size 32 bytes. Assume
that a direct mapped cache having 512 cache lines is used with this machine. The size of the tag field in bits is
______.
Solution-
Given-
We have,
= 232 bytes
We have,
Block size
= 32 bytes
= 25 bytes
= 512 lines
= 29 lines
= Number of bits in physical address – (Number of bits in line number + Number of bits in block offset)
= 32 bits – 14 bits
= 18 bits
Problem-06:
An 8 KB direct-mapped write back cache is organized as multiple blocks, each of size 32 bytes. The processor
generates 32 bit addresses. The cache controller maintains the tag information for each cache block comprising of
the following-
1 valid bit
1 modified bit
As many bits as the minimum needed to identify the memory block mapped in the cache
What is the total size of memory needed at the cache controller to store meta data (tags) for the cache?
1. 4864 bits
2. 6144 bits
3. 6656 bits
4. 5376 bits
Solution-
Given-
We have,
Block size
= 32 bytes
= 25 bytes
= 8 KB / 32 bytes
= 28 lines
= Number of bits in physical address – (Number of bits in line number + Number of bits in block offset)
= 32 bits – 13 bits
= 19 bits
= Number of lines in cache x (1 valid bit + 1 modified bit + 19 bits to identify block)
= 28 x 21 bits
= 5376 bits
Get more notes and other study material of Computer Organization and Architecture.
Summary
Article Name
Direct Mapping | Cache | Practice Problems
Description
Practice Problems based on Direct Mapping. Direct Mapping is a cache mapping technique that allows to map a
particular block of main memory to one particular cache line only.