Back to the 2023 paper

Module 4: Memory Organization

20237m

A 4-way set associative cache memory unit with a capacity of 16 KB is built using a block size of 8 words. The word length is 32 bits. The size of the physical address space is 4 GB. Find the number of bits for TAG, SET, and WORD fields in the address generated by CPU.

Worked SolutionAI Assisted

Given

  • Cache size C=16C =16 KB =16384=16384 B =214=2^{14} B
  • Associativity k=4k=4 (4-way set associative)
  • Block size = 88 words, Word = 3232 bits =4=4 B
    ⇒\Rightarrow Block = 8×4=328\times4=32 B =25=2^{5} B
  • Physical address space 44 GB =232=2^{32} B ⇒\Rightarrow Physical address 3232 bits

Calculations

1. Number of blocks in cache:
Nblocks=C/Block=16384/32=512N_{blocks}= C / Block =16384/32=512 blocks =29=2^{9}

2. Number of sets:
Nsets=Nblocks/k=512/4=128N_{sets}= N_{blocks}/k =512/4=128 sets =27=2^{7}
⇒\Rightarrow SET field s=log⁡2Nsets=7s = \log_2 N_{sets}=7 bits

3. WORD / Offset field:
Block = 3232 B. Byte offset within block = log⁡232=5\log_2 32 =5 bits.
This 55 bits comprises:

  • Word offset within block: log⁡28=3\log_2 8 =3 bits (select 1 of 8 words)
  • Byte offset within word: log⁡24=2\log_2 4 =2 bits (select 1 of 4 bytes)

If address is word-addressable, WORD field = 33 bits.
If byte-addressable (standard), combined offset = 55 bits.

Common naming in question: WORD field = 55 bits (or split 3+23+2).

4. TAG field:
TAG=Physical_bits−SET−OFFSETTAG = Physical\_bits - SET - OFFSET

  • Byte-addressable: TAG=32−7−5=20TAG =32 -7 -5 =20 bits
  • Word-addressable with byte split: TAG=32−7−3−2=20TAG =32 -7 -3 -2 =20 bits same.

Answer

Physical Address (32 bits)
+-----------+---------+---------------+
| TAG 20b   | SET 7b  | WORD/OFFSET 5b|
|           |         | (3b word+2b byte)|
+-----------+---------+---------------+
  • TAG = 20 bits
  • SET = 7 bits
  • WORD/Offset = 5 bits (3 bits word + 2 bits byte)

If counting WORD only (word index): WORD=3 bits, BYTE=2 bits, TAG=20, SET=7.

Check: 20+7+5=3220+7+5=32.

Alternative: If cache size given as 1616 KB words (unlikely), then C=16K×4=64KBC=16K\times4=64KB ⇒\Rightarrow sets =512=512 ⇒\Rightarrow SET=9, TAG=18. But standard is bytes → answer above.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.