Direct and Associate Cache - Offset, Index, and Tag
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.