0
$\begingroup$

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.

asked Dec 16, 2019 at 23:37
$\endgroup$
2

1 Answer 1

0
$\begingroup$
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.

xskxzr
7,6235 gold badges24 silver badges48 bronze badges
answered Feb 4, 2020 at 22:39
$\endgroup$
1
  • $\begingroup$ @greybeard, why one set? you can select 2^9 sets. $\endgroup$ Commented Feb 6, 2020 at 10:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.