• edited by
7,982 views
22 22 votes

Consider a memory system with $1 \mathrm{M}$ bytes of main memory and $16 \mathrm{~K}$ bytes of cache memory. Assume that the processor generates $20$-bit memory address, and the cache block size is $16$ bytes. If the cache uses direct mapping, how many bits will be required to store all the $\operatorname{tag}$ values? [Assume memory is byte addressable, $1 \mathrm{~K}=2^{10}$, $1 \mathrm{M}=2^{20}$.]

  1. $6 \times 2^{10}$
  2. $8 \times 2^{10}$
  3. $2^{12}$
  4. $2^{14}$

4 Answers

2 2 votes

We are given a memory system with the following parameters:

  • Main memory size: $1~\text{M bytes} = 2^{20}$ bytes  
  • Cache size: $16~\text{K bytes} = 2^{14}$ bytes  
  • Cache block size: $16$ bytes = $2^4$ bytes  
  • Address width: $20$ bits (byte-addressable)  
  • Cache organization: Direct-mapped

In a direct-mapped cache, each memory block maps to exactly one cache line based on its index.

  • Number of cache lines (blocks) = $\frac{\text{Cache size}}{\text{Block size}} = \frac{2^{14}}{2^4} = 2^{10}$

So, there are $2^{10}$ cache lines.A 20-bit address is partitioned into:

$$
\begin{array}{|c|c|c|}
\hline
\text{Tag} & \text{Index} & \text{Offset} \\
\hline
\end{array}
$$

  • Offset: determines byte within a block → $\log_2(\text{block size}) = \log_2(16) = 4$ bits  
  • Index: selects which cache line → $\log_2(\text{number of lines}) = \log_2(2^{10}) = 10$ bits  
  • Tag: remaining bits → $20 - 10 - 4 = 6$ bits

Thus, each cache line stores a 6 bit tag. Since there are $2^{10}$ cache lines, and each requires 6 bits for its tag:

$$
\text{Total tag storage} = 6 \times 2^{10} \text{ bits}
$$

 

$$
\color{lime} \boxed{\text{A. } 6 \times 2^{10}}
$$

0 0 votes

In Direct mapping Tag bits can be find out using Log(mms/cms)= 6 bits and Block offset bits its Log(Block size) = 4 bits and line number bits = 20-(TAG+BO) = 10 bits now calculate the tag directory size 

Answer:
Position:
Show:

Related questions

23 23 votes
7 7 answers
10.3k
10.3k views
Arjun asked Feb 27, 2025
10,296 views
​​​​For a direct-mapped cache, $4$ bits are used for the tag field and $12$ bits are used to index into a cache block. The size of each cache block is one byte. Assume th...
10 10 votes
7 7 answers
2.8k
2.8k views
gatecse asked Feb 23
2,803 views
Consider a system with a processor and a $4$ KB direct mapped cache with block size of $16$ bytes. The system has a $16$ MB physical memory. Four words $\mathrm{P}, \math...
19 19 votes
6 6 answers
3.2k
3.2k views
gatecse asked Feb 23
3,175 views
Consider a system with $1$ MB physical memory and a word length of $1$ byte. The system uses a direct mapped cache, with block numbers starting from $0$. The word with ph...
32 32 votes
8 8 answers
19.2k
19.2k views
Arjun asked Feb 27, 2025
19,185 views
A computer has a memory hierarchy consisting of two-level cache $\text{(L1}$ and $\text{L2)}$ and a main memory. If the processor needs to access data from memory, it fir...