0% found this document useful (0 votes)
3 views

Set Associative mapping

The document presents two problems related to set associative mapping in cache memory. The first problem involves a 2-way set associative cache with a size of 16 KB and a block size of 256 bytes, resulting in a tag size of 4 bits and a tag directory size of 32 bytes. The second problem discusses an 8-way set associative cache of 512 KB with a block size of 1 KB, leading to a main memory size of 8 MB and a tag directory size of 448 bytes.

Uploaded by

Dr. BRINDHA 2369
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Set Associative mapping

The document presents two problems related to set associative mapping in cache memory. The first problem involves a 2-way set associative cache with a size of 16 KB and a block size of 256 bytes, resulting in a tag size of 4 bits and a tag directory size of 32 bytes. The second problem discusses an 8-way set associative cache of 512 KB with a block size of 1 KB, leading to a main memory size of 8 MB and a tag directory size of 448 bytes.

Uploaded by

Dr. BRINDHA 2369
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Set

Associative
Mapping
Problems
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
Number of Bits in Physical Address-

We have,
Size of main memory
= 128 KB
= 217 bytes
Thus, Number of bits in physical address = 17 bits
Number of Bits in Block Offset-

Block size
= 256 bytes
= 28 bytes
Thus, Number of bits in block offset = 8 bits
Number of Lines in Cache-

Total number of lines in cache


= Cache size / Line size
= 16 KB / 256 bytes
= 214 bytes / 28 bytes
= 64 lines
Thus, Number of lines in cache = 64 lines
Number of Sets in Cache-

Total number of sets in cache


= Total number of lines in cache / Set size
= 64 / 2
= 32 sets
= 25 sets
Thus, Number of bits in set number = 5 bits
Number of Bits in Tag-
Number of bits in tag
= Number of bits in physical address – (Number of bits in set
number +Number of bits in block offset)
= 17 bits – (5 bits + 8 bits)
= 17 bits – 13 bits
= 4 bits
Thus, Number of bits in tag = 4 bits
Tag Directory Size-

Tag directory size


= Number of tags x Tag size
= Number of lines in cache x Number of bits in tag
= 64 x 4 bits
= 256 bits
= 32 bytes
Thus, size of tag directory = 32 bytes
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
Number of Bits in Block Offset-

Block size
= 1 KB
= 210 bytes
• Thus, Number of bits in block offset = 10 bits
Number of Lines in Cache-

Total number of lines in cache


= Cache size / Line size
= 512 KB / 1 KB
= 512 lines
Thus, Number of lines in cache = 512 lines
Number of Sets in Cache-

Total number of sets in cache


= Total number of lines in cache / Set size
= 512 / 8
= 64 sets
= 26 sets
Thus, Number of bits in set number = 6 bits
Number of Bits in Physical
Address-
Number of bits in physical address
= Number of bits in tag + Number of bits in set number + Number
of bits in block offset
= 7 bits + 6 bits + 10 bits
= 23 bits
Thus, Number of bits in physical address = 23 bits
Size of Main Memory-

Number of bits in physical address = 23 bits


Thus, Size of main memory
= 223 bytes
= 8 MB
Tag Directory Size-

Tag directory size


= Number of tags x Tag size
= Number of lines in cache x Number of bits in tag
= 512 x 7 bits
= 3584 bits
= 448 bytes
Thus, size of tag directory = 448 bytes

You might also like