Consider two cache organizations: The first one is 32KB 2-way set-associative…
2025
Consider two cache organizations: The first one is 32KB 2-way set-associative with 32B block size. The second one is of the same size but direct mapped. The size of an address is 32 bits in both cases. A 2×1 multiplexer has latency of 0.6 ns while a k-bit comparator has a latency of k/10 ns. Find out the hit latency of the set-associative and direct-mapped memory organizations.
Consider another setting of the 2-way set-associative cache having 128 lines, each with 16 words. Suppose the main memory has a 16-bit address. Both cache and memory are word addressable. Now suppose we want to read and write a word at memory address 357A. Under this, another set associative mapping technique, what will be the "tag" value in decimal?
Attempted by 22 students.
Show answer & explanation
To find the hit latency and the tag value, we break down the cache architecture into its addressing components.
Hit Latency Calculation
Hit latency is the time the CPU takes to find and retrieve data from the cache.
1. 2-way Set-Associative Cache
Total Cache Size: 32KB
Block Size: 32B
Number of blocks = 32KB / 32B = 1024 blocks.
Number of sets = 1024 / 2 = 512 sets.
Offset bits = log2(32) = 5 bits.
Index bits = log2(512) = 9 bits.
Tag bits = 32 - (9 + 5) = 18 bits.
Comparator Latency (k=18) = 18 / 10 = 1.8 ns.
MUX Latency = 0.6 ns.
Total Hit Latency = 1.8 + 0.6 = 2.4 ns.
2. Direct-Mapped Cache
Number of blocks = 1024 blocks.
Index bits = log2(1024) = 10 bits.
Tag bits = 32 - (10 + 5) = 17 bits.
Comparator Latency (k=17) = 17 / 10 = 1.7 ns.
A direct-mapped cache does not use a MUX for way selection.
Total Hit Latency = 1.7 ns.
Tag Value Calculation (Address 357A)
In this scenario, we use a 16-bit word-addressable memory system.
1. Address Partitioning
Total Address: 16 bits.
Block Size: 16 words.
Word Offset = log2(16) = 4 bits.
Sets = 128 lines / 2 = 64 sets.
Index bits = log2(64) = 6 bits.
Tag bits = 16 - (6 + 4) = 6 bits.
2. Converting Hex Address 357A to Binary
3 = 0011
5 = 0101
7 = 0111
A = 1010
Full Binary Address: 0011 0101 0111 1010
3. Extracting the Tag
The tag is the first 6 bits: 001101.
Binary 001101 = (1 2^3) + (1 2^2) + (0 2^1) + (1 2^0).
Calculation: 8 + 4 + 0 + 1 = 13.
The decimal tag value is 13.
Summary of Results
Set-Associative Latency: 2.4 ns
Direct-Mapped Latency: 1.7 ns
Tag Value (Decimal): 13