Consider a computer with a 4-way set-associative cache with these characteristics: Main memory size = 1 MB Word size = 1 byte Block size = 128 words Cache size = 8 KB For memory address 0C795H, find the TAG field value. Find the number of bits in TAG, SET, and WORD fields. Enter the TAG value in hexadecimal without trailing H.
Consider a computer with a 4-way set-associative cache with these characteristics:
- Main memory size = 1 MB
- Word size = 1 byte
- Block size = 128 words
- Cache size = 8 KB
- For memory address
0C795H, find the TAG field value. - Find the number of bits in TAG, SET, and WORD fields.
Enter the TAG value in hexadecimal without trailing H.
Answer
20
Theory
For an n-way set-associative cache:
| TAG | SET Offset | Word Offset |
|---|---|---|
| \(LA - (S.O + W.O)\) | \(\log_2(\text{Number of Sets})\) | \(\log_2(\text{Block Size})\) |
- \(\text{Number of Cache Lines} = \frac{\text{Cache Size}}{\text{Block Size}}\)
- \(\text{Number of Sets} = \frac{\text{Number of Cache Lines}}{n\text{-way}}\)
- \(\text{Set Offset} = \log_2(\text{Number of Sets})\)
Solution
Step 1: Find field sizes
| Field | Computation | Bits |
|---|---|---|
| WORD offset | \(\log_2(128)\) | 7 |
| SET index | \(\frac{64}{4} = 16 \text{ sets}, \log_2(16)\) | 4 |
| TAG | \(20 - (7 + 4)\) | 9 |
Step 2: Convert address
\(0C795_H = 0000\ 1100\ 0111\ 1001\ 0101_2\)
Step 3: Split as TAG | SET | WORD = 9 | 4 | 7 bits
| TAG 9 bits | SET 4 bits | WORD 7 bits |
|---|---|---|
000011000 | 1111 | 0010101 |
\(TAG = 000011000_2 = 018_H\)
Therefore, required TAG value = 18.
Also, bit counts are TAG = 9, SET = 4, WORD = 7.