Cache Memory · Computer Organization and Architecture
68 questions · asked in 25 of 27 years (2000–2026)
MCQ 44 · MSQ 4 · NAT 201-mark 30 · 2-mark 38
Questions 51–55 of 68
Which of the following lines of the data cache will be replaced by new blocks in accessing the array for the second time?
Answer: (A)
The starting address .
First, find the block where the array starts: exactly, so the array begins at the start of block 68.
Array size , and . The array starts at a block boundary, so it needs 40 blocks: .
The first block maps to cache block , and after that the blocks are accessed in sequence.
The table below shows that line number to is replaced by the array in the second access.
Blocks 96 to 107 wrap around to lines 0 to 11. In the first pass, lines 4 to 11 first hold blocks 68 to 75 and are then overwritten by blocks 100 to 107.
In the second pass, lines 0 to 3 and 12 to 31 still hold the blocks that are needed (hits). Lines 4 to 11 hold 100 to 107 but now need 68 to 75, so these lines are replaced.
Answer: (A)
How many data cache misses will occur in total?
Answer: (C)
Number of bits in an address =
Each cache line bytes, so the offset needs
The cache has lines in total, so the line number needs
So, the tag bits
We have a and each of its elements has a size of
Total size of this array
So, the number of lines the array needs in the cache is
The start address is , a multiple of 64. So the array begins at a block boundary and needs the full 40 lines.
Starting address of the array
The group of bits in the middle gives the cache line number the array starts from cache line number .
We need cache lines to hold all the array elements, but we have only cache lines.
Split the array elements into those array lines. We call the first array line , and it has of its elements.
This line (a group of elements) of the array maps to cache line number , as found from the starting address of the array above.
This means that among those array lines, some array lines map to the same cache line, because there are just cache lines but array lines.
The mapping is like this:
The array is read in order, so each block is fully used before the next one is fetched.
First pass: each of the 40 blocks misses once, giving 40 compulsory misses. Lines 4 to 11 first get and are then overwritten by .
Second pass: miss again (8 misses), hit, and miss again (8 misses). That is 16 misses.
Total misses .
Answer: (C)
Answer: (D)
Find the number of sets first:
So the number of index (LINE) bits . The number of WORD bits , because the cache block (line) size is
So the number of TAG bits
Answer is choice (D)
The length of the physical address of a word in the main memory is 30 bits. The capacity of the tag memory in the I-cache, D-cache and L2-cache is, respectively,
Answer: (A)
1. I-cache
- Blocks in the cache:
- Bits needed for the block number:
- Words in one block:
- Bits needed for the word offset:
- Tag bits:
- Every block has its own tag bits, so the total tag memory is:
2. D-cache
- Blocks in the cache:
- Sets in the cache:
- Bits needed for the set number:
- Words in one block:
- Bits needed for the word offset:
- Tag bits:
- Every block has its own tag bits, so the total tag memory is:
3. L2 cache
- Blocks in the cache:
- Sets in the cache:
- Bits needed for the set number:
- Words in one block:
- Bits needed for the word offset:
- Tag bits:
- Every block has its own tag bits, so the total tag memory is:
Option (A).
Answer: (C)
Transfer time for 64 bytes .
The memory latency is 32 ns.
Time to fetch the cache line .
Answer: (C)
Keep practising