I have two questions:
An 8-kB (8192 bytes) direct-mapped cache has 16-byte lines.
The system has 64-bit addresses numbered from 0 on the right to 63 on the left.
Which bits are associated with the offset, index, and tag?
A 16-kB (16384 bytes) 4-way set associative cache has 8-byte lines.
The system has 64-bit addresses numbered from 0 on the right to 63 on the left.
Which bits are associated with the offset, index, and tag?
For offset, it's: tag bits = address bit length - exponent of index - exponent of offset, correct?
Then the Index for a direct mapped cache is the number of blocks in the cache, and the Tag bits are everything else, right?
How would I calculate these? Because I'm a little confused on an associative cache vs a direct-map cache.
-
$\begingroup$ Does this help cs.stackexchange.com/questions/13356/… $\endgroup$ss09– ss092019年12月17日 04:51:22 +00:00Commented Dec 17, 2019 at 4:51
-
$\begingroup$ I once summarized all this here cs.stackexchange.com/questions/33818/… $\endgroup$Ran G.– Ran G.2020年03月06日 20:07:55 +00:00Commented Mar 6, 2020 at 20:07
1 Answer 1
An 8-kB (8192 bytes) direct-mapped cache has 16-byte lines.
The system has 64-bit addresses numbered from 0 on the right to 63 on the left.
Which bits are associated with the offset, index, and tag?
Since a cache line is 16-byte long, it can be represented with $\log_2 16 = 4 \text{b}$, which is the number of bits required for the offset field. The number of lines in the cache are $\frac{8\text{kB}}{16\text{B}} = 512$. The index maps these entire lines; therefore, $\log_2 512 = 9\text{b}$ are required. The tag field gets the rest, that is, 64ドル-9-4=51\text{b}$.
A 16-kB (16384 bytes) 4-way set associative cache has 8-byte lines.
The system has 64-bit addresses numbered from 0 on the right to 63 on the left.
Which bits are associated with the offset, index, and tag?
As before, $\log_2 8 = 3\text{b}$ for the offset field. Since the cache is 4-way associative, the number of sets are $\frac{16\text{kB}}{4\cdot 8\text{B}}=512$, which, again, requires 9ドル\text{b}$ for the index field. Finally, the tag is 52ドル$ bits long.
-
$\begingroup$ @greybeard, why one set? you can select 2^9 sets. $\endgroup$Gilsho– Gilsho2020年02月06日 10:53:24 +00:00Commented Feb 6, 2020 at 10:53
Explore related questions
See similar questions with these tags.