0
\$\begingroup\$

I have a direct mapped cache of size S with the line size L. The cache is physically indexed and tagged. The physical address is 50 bits, numbered from 0 to 49 (with 0 being the least significant bit). The machine has a word size of 4 bits and the memory is byte-addressable. Which bits of the 50 bits are used to select a word from the line? Is it as many bits as it takes to point of a word in the line size L e.g. if line size is 8 byte then 2 bits are needed? Is it some logarithm again that must be used?

\$\endgroup\$
2
\$\begingroup\$

Assuming you meant to say "The machine has a word size of 4 bytes" (instead of "bits"), then yes you are correct - the log2 of the number of words in a line. Since there are 4 bytes per word, the bottom 2 address bits (addr[1 : 0]) are used to select which byte of a word, and then next bits after that (addr[log2(L)-1 : 2]) are to select which word in the line. This assumes line size is L bytes, not L bits (if L is in bits, then first divide L by 8).

\$\endgroup\$
1
\$\begingroup\$

Is this supposed to be a trick question? You can't directly select 4-bit words from the cache, since the memory system is "byte addressable", which presumably means 8-bit bytes.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.