Set Associative Mapping
Set Associative Mapping
Problem-01:
Consider a 2-way set associative mapped cache of size 16 KB with block size 256
bytes. The size of main memory is 128 KB. Find-
1. Number of bits in tag
2. Tag directory size
Solution-
Given-
Set size = 2
Cache memory size = 16 KB
Block size = Frame size = Line size = 256 bytes
Main memory size = 128 KB
We consider that the memory is byte addressable.
Problem-02:
Consider a 8-way set associative mapped cache of size 512 KB with block size 1 KB.
There are 7 bits in the tag. Find-
1. Size of main memory
2. Tag directory size
Solution-
Given-
Set size = 8
Cache memory size = 512 KB
Block size = Frame size = Line size = 1 KB
Number of bits in tag = 7 bits
We consider that the memory is byte addressable.
Problem-03:
Consider a 4-way set associative mapped cache with block size 4 KB. The size of main
memory is 16 GB and there are 10 bits in the tag. Find-
1. Size of cache memory
2. Tag directory size
Solution-
Given-
Set size = 4
Block size = Frame size = Line size = 4 KB
Main memory size = 16 GB
Number of bits in tag = 10 bits
We consider that the memory is byte addressable.
Problem-04:
Consider a 8-way set associative mapped cache. The size of cache memory is 512 KB
and there are 10 bits in the tag. Find the size of main memory.
Solution-
Given-
Setsize = 8
Cache memory size = 512 KB
Number of bits in tag = 10 bits
We consider that the memory is byte addressable.
Let-
Number of bits in set number field = x bits
Number of bits in block offset field = y bits
Sum of Number Of Bits Of Set Number Field And Block Offset Field-
We have,
Cache memory size = Number of sets in cache x Number of lines in one set x Line size
Now, substituting the values, we get-
512 KB = 2x x 8 x 2y bytes
219 bytes = 23+x+y bytes
19 = 3 +x + y
x + y = 19 – 3
x + y = 16
Problem-05:
Consider a 4-way set associative mapped cache. The size of main memory is 64 MB
and there are 10 bits in the tag. Find the size of cache memory.
Solution-
Given-
Setsize = 4
Main memory size = 64 MB
Number of bits in tag = 10 bits
We consider that the memory is byte addressable.
Sum Of Number Of Bits Of Set Number Field And Block Offset Field-
Let-
Number of bits in set number field = x bits
Number of bits in block offset field = y bits
Then, Number of bits in physical address
= Number of bits in tag + Number of bits in set number + Number of bits in block offset
So, we have-
26 bits = 10 bits + x bits + y bits
26 = 10 + (x + y)
x + y = 26 – 10
x + y = 16
Thus, Sum of number of bits of set number field and block offset field = 16 bits
Size of Cache Memory-
Cache memory size
= Number of sets in cache x Number of lines in one set x Line size
= 2x x 4 x 2y bytes
= 22+x+y bytes
= 22+16 bytes
= 218 bytes
= 256 KB
Thus, size of cache memory = 256 KB