in CO and Architecture retagged by
490 views
3 votes
3 votes
Suppose we have a four-way set associative physically addressed cache of size $256 \mathrm{KB}$ and $\text{16B}$ blocks, on a machine that uses $32$-bit physical addresses. How many bits will be used for the index?
in CO and Architecture retagged by
490 views

2 Answers

3 votes
3 votes
$256 KB$ cache size.

$16B$ block size ($4 bits$ for offset)

$=\dfrac{256 * 1024}{16} blocks = \dfrac{2^{18}}{2^4}blocks = 2^{14}$ blocks

Each set has $4$ blocks ($4$ way set associative) so,

$=\dfrac{2^{14}}{4}$ sets in total

$=2^{12}$ sets.

We need $log_2(2^{12})$ = $12$ bits to index the sets.
0 votes
0 votes
In a set-associative cache, the index is used to determine which set in the cache a particular memory block is mapped to. The number of sets in a cache can be calculated using the formula:

Number of Sets=Cache Size(Number of Ways×Block Size)

Number of Sets=(Number of Ways×Block Size)Cache Size​

In this case, you have a four-way set-associative cache with a size of 256KB (kilobytes) and block size of 16B (bytes). Let's calculate the number of sets:

Number of Sets=256KB(4×16B)=256×102464=4×1024=4096Number of Sets=(4×16B)256KB​=64256×1024​=4×1024=4096

Now, to find the number of bits needed for the index, you can use the formula:

Number of Index Bits=log⁡2(Number of Sets)Number of Index Bits=log2​(Number of Sets)

Number of Index Bits=log⁡2(4096)Number of Index Bits=log2​(4096)

Using a calculator, you'll find that log⁡2(4096)=12log2​(4096)=12.

Therefore, 12 bits will be used for the index in the four-way set-associative cache with the given specifications.
Answer:

Related questions