Introduction
Cache Basics Direct Mapped Cache Direct Mapped Example 1 Direct Mapped Example 2 Direct Mapped Problem 1 Direct Mapped Problem 2 Direct Mapped Problem 3 Direct Mapped Problem 4 Direct Mapped Comparators Direct Mapped Disadvantages Direct Mapped Locality Direct Mapped UVM Example Associative Mapped Cache Associative Mapped Problem 1 Associative Mapped Problem 2 Associative Mapped Problem 3 Associative Mapped Problem 4 Set Associative Mapped Cache Set Associative Mapped Comparators Set Associative Mapped Problem 1 Set Associative Mapped Problem 2 Set Associative Mapped Problem 3 Set Associative Mapped Problem 4 Set Associative Mapped Problem 5 Other Mapping Problem - Example 1 Cache Replacement Algorithms LRU Cache Replacement Algorithm FIFO Cache Replacement Algorithm MRU Cache Replacement Algorithm PLRU Cache Replacement Algorithm Round Robin Cache Replacement AlgorithmUVMArena
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:
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
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
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
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