7.4k views
3 votes
The question: A computer has 8 GByte of memory with 64-bit addressable word sizes. Each block of memory stores 16 words. The computer has a direct-mapping cache of 128 blocks

1. Calculate the tag bits, Line number bits, and offset bit.


To solve the question, here is what I did.
8GB = 1GW (64 bit word = 8 bytes/word), which requires 30 bits (log 2 1G = 30). The memory address is divided into line number and word number. With 16 words per line, we need 4 bits for the block offset. Next, since block stores 16 words, there must be 16 lines in cache to store 128 blocks so line number bits 4 (log 2 16 = 4) and then or tag bits 30 - 4 - 4 = 22 bits for tag bits.

Please tell me if this is correct or not? If not, provide solution.

On an unrelated note, to get Tag bits is this formula valid? log 2 (main memory size / cache size).

User Guasi
by
8.4k points

1 Answer

7 votes

Answer:

Your solution is correct.

To calculate the number of tag bits, we use the formula: number of tag bits = total number of bits - number of offset bits - number of index bits.

In this case, the total number of bits is 64 (since we have 64-bit addressable word sizes). We have 8GB of memory, which requires 30 bits (since 2^30 = 1GB). We have 16 words per block, so we need 4 bits for the offset. We have 128 blocks in the cache, which requires 7 bits for the index (since log2(128) = 7).

Therefore, the number of tag bits is: 64 - 4 - 7 = 53.

So, the tag bits are 53 bits, the line number bits are 4 bits, and the offset bits are 4 bits.

Regarding your unrelated note, the formula log2(main memory size / cache size) is used to calculate the number of index bits for a set-associative cache. It is not used to calculate the number of tag bits.

User Riku
by
8.0k points