Consider a set-associative cache of size 2KB (1KB=2^10 bytes) with cache block…

2021

Consider a set-associative cache of size 2KB (1KB=2^10 bytes) with cache block size of 64 bytes. Assume that the cache is byte-addressable and a 32 -bit address is used for accessing the cache. If the width of the tag field is 22 bits, the associativity of the cache is _________ .

Attempted by 217 students.

Show answer & explanation

Correct answer: 2

Key facts: Cache size = 2 KB = 2048 bytes; block size = 64 bytes; 32-bit addresses; tag field = 22 bits.

  • Block offset bits = log2(64) = 6 bits.

  • Number of cache lines = 2048 / 64 = 32 = 2^5 lines.

  • If associativity = A, number of sets = 32 / A, so index bits = log2(32/A) = 5 - log2(A).

  • Tag bits = 32 - index bits - offset bits = 32 - (5 - log2(A)) - 6 = 21 + log2(A).

  • Set 21 + log2(A) = 22 (given). Therefore log2(A) = 1, so A = 2.

Final answer: The cache is 2-way set-associative.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir