UVMArena

Direct Mapped Cache – Problem 4

In this problem we determine the cache memory size and the tag directory size for a direct mapped cache. As in previous problems, we assume a byte-addressable system, meaning every byte has a unique address.


Given

  • RAM Size: 32 GB
  • Frame Size: 213 bytes
  • Tag Size: 10 bits

First convert the RAM size into powers of two.

32 GB = 25 × 230 = 235 bytes

Since the system is byte-addressable, the physical address must contain 35 bits.


Step 1 – Address Structure

A direct mapped cache address is divided into three fields:

  • Tag
  • Line Index
  • Offset

From the problem statement:

  • Tag = 10 bits
  • Frame size = 213 bytes

Since each frame contains 213 bytes, the offset requires:

Offset = 13 bits

Now we compute the number of bits used for the line index:

Line Bits = Total Address Bits − Tag Bits − Offset Bits

35 − 10 − 13 = 12 bits

Address Format
Tag (10) | Line (12) | Offset (13)

Step 2 – Number of Cache Lines

If the line index field has 12 bits, then the number of cache lines is:

212 lines


Step 3 – Cache Memory Size

Each cache line stores one block. Since the frame size is 213 bytes, each cache line also stores 213 bytes.

Cache Size = Number of Lines × Line Size

212 × 213 = 225 bytes

Cache Size = 225 bytes (32 MB)

Step 4 – Tag Directory Size

Every cache line stores one tag. Therefore the total tag storage is:

Tag Directory Size = Number of Lines × Tag Bits

212 × 10 bits

To convert from bits to bytes we divide by 8:

(212 × 10) / 8

212 / 23 = 29

Tag Directory Size = 29 × 10 bytes = 5120 bytes

Alternative Method

Another way to solve the problem is by analyzing the mapping relationship between RAM frames and cache lines.

First compute the number of frames in RAM:

Number of Frames = RAM Size / Frame Size

235 / 213 = 222

The tag field has 10 bits, meaning:

210 frames map to a single cache line

Therefore the number of cache lines is:

222 / 210 = 212

Once we know the number of lines and the line size, the cache size is:

212 × 213 = 225 bytes

There are several ways to solve direct mapped cache problems. The key idea is understanding how tag bits determine how many memory frames map to each cache line.