UVMArena

Direct Mapped Cache – Problem 3

In this problem we analyze a Direct Mapped Cache configuration and determine the RAM size and the tag directory size. Throughout the analysis we assume the system is byte-addressable, meaning every byte in memory has its own address.


Given

  • Cache Size: 256 KB
  • Block Size: 1 KB
  • Tag Size: 8 bits

First convert the values to powers of two:

  • Cache Size = 256 KB = 218 bytes
  • Block Size = 1 KB = 210 bytes

Step 1 – Determine the Offset Bits

Since the block size is 210 bytes, we need 10 bits to address each byte inside the block.

Offset = 10 bits

Step 2 – Determine Line Bits

The number of cache lines is calculated using:

Number of Lines = Cache Size / Block Size

218 / 210 = 28

Therefore the cache contains:

Number of Lines = 28 = 256 lines

To index 256 lines we need:

Line Index = 8 bits

Step 3 – Address Structure

The physical address in a direct mapped cache consists of:

  • Tag
  • Line Index
  • Offset

From the problem statement:

  • Tag = 8 bits
  • Line Index = 8 bits
  • Offset = 10 bits
Physical Address = Tag + Line + Offset =
8 + 8 + 10 = 26 bits

Step 4 – Calculate RAM Size

With a 26-bit physical address, the number of possible addresses is:

226 addresses

Because the system is byte-addressable, the RAM size is:

RAM Size = 226 bytes = 64 MB

Step 5 – Tag Directory Size

Every cache line stores a tag. Therefore the total tag storage (tag directory) is:

Tag Directory Size = Number of Lines × Tag Bits

= 28 × 8 bits

Convert bits to bytes by dividing by 8:

(28 × 8) / 8 = 28

Tag Directory Size = 256 bytes

Shortcut Method

Another quick way to solve the problem is:

  1. Compute number of lines:
    218 / 210 = 28
  2. Line bits = 8
  3. Offset bits = 10 (from block size)
  4. Tag bits = 8 (given)
  5. Total physical address bits = 8 + 8 + 10 = 26
  6. RAM size = 226 bytes = 64 MB
Multiple approaches can be used to solve cache mapping problems. The key is understanding how tag, index, and offset fields relate to cache size, block size, and main memory size.