A two way set assocaiative cache memory uses blocks of four words.
The cache can accommodate a total of
2048 words from the main memory. The main memory size is 128 K*32. (i) Formulate all pertinent information
required to construct the cache memory. (ii) What is the size of the cache memory.
ChatGPT said:
Below is the complete solution, step-by-step.
Given:
2-way set associative cache
Block size = 4 words
Total cache capacity = 2048 words
Main memory size = 128 K × 32 bits
Assume:
“128 K × 32” = 128K words, each 32 bits.
(i) Pertinent Information Required Constructing the Cache
1. Cache Capacity
Total words in cache = 2048 words
2. Block Size
1 block = 4 words
3. Number of Blocks in Cache
Cache blocks=20484=512 blocks\text{Cache blocks} = \frac{2048}{4} = 512 \
text{ blocks}Cache blocks=42048=512 blocks
4. Degree of Associativity
2-way set associative → 2 blocks per set
5. Number of Sets in Cache
Number of sets=5122=256 sets\text{Number of sets} = \frac{512}{2} = 256 \text{ sets}Number of sets=2512
=256 sets
6. Main Memory Size
128K words
128K=131072 words=217 words128K = 131072 \text{ words} = 2^{17} \
text{ words}128K=131072 words=217 words
So memory address requires 17 bits (word addressing).
7. Address Format (Tag, Index, Block offset)
Block offset bits
Block size=4 words=22⇒Offset=2 bits\text{Block size} = 4 \text{ words} = 2^2 \Rightarrow \text{Offset} =
2 \text{ bits}Block size=4 words=22⇒Offset=2 bits
Index bits
Sets=256=28⇒Index=8 bits\text{Sets} = 256 = 2^8 \Rightarrow \text{Index} = 8 \
text{ bits}Sets=256=28⇒Index=8 bits
Tag bits
Tag=17−(8+2)=7 bits\text{Tag} = 17 - (8 + 2) = 7 \text{ bits}Tag=17−(8+2)=7 bits
8. Final Address Format
| Tag (7 bits) | Index (8 bits) | Block Offset (2 bits) |
(ii) Size of the Cache Memory
Data Storage Size (words × word size)
2048 words×32 bits=65536 bits2048 \text{ words} \times 32 \text{ bits} = 65536 \
text{ bits}2048 words×32 bits=65536 bits
= 64 Kbits = 8 KB data capacity
Tag Storage (overhead)
Each block has:
7-bit tag
1 valid bit (usually)
Per block = 8 bits
Total tag storage:
512 blocks×8 bits=4096 bits512 \text{ blocks} \times 8 \text{ bits} = 4096 \
text{ bits}512 blocks×8 bits=4096 bits
= 512 bytes
Total Cache Size (data + tags)
Data part = 8 KB
Tag + valid bits ≈ 512 bytes ≈ 0.5 KB
Total cache size≈8.5 KB\text{Total cache size} \approx 8.5 \text{ KB}Total cache size≈8.5 KB
If only data size is asked → 8 KB
Final Answers
(i) Pertinent information:
Block size: 4 words (2 offset bits)
Total blocks in cache: 512
Associativity: 2-way
Number of sets: 256 (8 index bits)
Main memory address size: 17 bits
Tag size: 7 bits
Address format: Tag (7) | Index (8) | Offset (2)
(ii) Cache memory size:
Data size = 8 KB
Including tag + valid bits ≈ 8.5 KB