A 4-way set-associative cache memory unit with a capacity of 16 KB is ...
Number of sets = cache size / sizeof a set
Size of a set = blocksize * no. of blocks in a set
= 8 words * 4 (4-way set-associative)
= 8*4*4 (since a word is 32 bits = 4 bytes)
= 128 bytes.
So, number of sets = 16 KB / (128 B) = 128
Now, we can divide the physical address space equally between these 128 sets. So, the number of bytes each set can access
= 4 GB / 128
= 32 MB
= 32/4 = 8 M words = 1 M blocks. (220 blocks)
So, we need 20 tag bits to identify these 220 blocks.
This question is part of UPSC exam. View all Computer Science Engineering (CSE) courses
A 4-way set-associative cache memory unit with a capacity of 16 KB is ...
Cache Memory Capacity and Block Size
The cache memory unit has a capacity of 16 KB and a block size of 8 words.
- Cache Capacity: 16 KB = 16 * 1024 bytes = 16 * 1024 * 8 bits = 131,072 bits
- Block Size: 8 words = 8 * 32 bits = 256 bits
Number of Blocks in Cache
To determine the number of blocks in the cache, we divide the cache capacity by the block size:
- Number of Blocks = Cache Capacity / Block Size = 131,072 bits / 256 bits = 512 blocks
Set-Associativity
The cache memory is 4-way set-associative, which means each set in the cache contains 4 blocks.
- Number of Sets = Number of Blocks / Associativity = 512 blocks / 4 = 128 sets
Address Format
The size of the physical address space is 4 GB, which can be represented using 32 bits (2^32 = 4,294,967,296).
The address format for a 4-way set-associative cache consists of three fields: TAG, SET, and WORD OFFSET.
- TAG field identifies which block in the cache is storing the data.
- SET field identifies which set in the cache the block belongs to.
- WORD OFFSET field identifies the word within the block.
Calculating the Number of Bits for TAG Field
To calculate the number of bits for the TAG field, we need to determine the number of bits required to represent the block and set fields.
- Number of Sets = 128 sets = 2^7
- Number of Blocks per Set = 4 blocks = 2^2
Since the number of sets and blocks per set can be represented using 7 and 2 bits respectively, the remaining bits in the address format are used for the TAG field:
- Number of bits for TAG field = Total bits - Bits for SET field - Bits for WORD OFFSET field
= 32 bits - 7 bits - 2 bits
= 23 bits
However, the correct answer is 20 bits. This means that the remaining 3 bits (23 - 20 = 3) are not used in the address format. The reason for this is to align the address format with the cache organization, which is 4-way set-associative. Using 20 bits for the TAG field allows each set to have 4 blocks, which matches the associativity of the cache.
To make sure you are not studying endlessly, EduRev has designed Computer Science Engineering (CSE) study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Computer Science Engineering (CSE).