Consider a machine with a byte addressable main memory of bytes. Assum...
Cache Organization:
Staring Address=1100H = 163+162+0+0 =4352B is the starting address.
We need to find Starting block = 4352B/64B = 68th block in main memory from where array start storing elements.
50*50B =array size = 50*50B/64B =39.0625 blocks needed =approx = 40 blocks
68,69,70....107 block we need = 40 blocks starting block is 68 mod 32 = 4th cache block and after that in sequence they will be accessed.
as shown in below table line no 4 to 11 has been replaced by array in second time
This question is part of UPSC exam. View all Computer Science Engineering (CSE) courses
Consider a machine with a byte addressable main memory of bytes. Assum...
Byte Addressable Main Memory and Direct Mapped Data Cache
• The byte addressable main memory has a capacity of bytes.
• The direct mapped data cache consists of 32 lines of 64 bytes each.
• A 50 x 50 two-dimensional array of bytes is stored in the main memory starting from memory location 1100H.
• The data cache is initially empty.
• The complete array is accessed twice.
• The contents of the data cache do not change in between the two accesses.
Determination of the Replaced Lines in Data Cache
• To determine the lines of the data cache that will be replaced by new blocks in accessing the array for the second time, we need to calculate the line numbers that correspond to the memory locations of the array.
• The array occupies a total of 50 x 50 = 2500 bytes in the main memory, starting from memory location 1100H.
• The memory locations of the array range from 1100H to 1373H.
• To find the line number of a memory location in the data cache, we use the formula:
line number = (memory location mod cache size) / block size
• Here, cache size = 32 lines x 64 bytes/line = 2048 bytes
• Block size = 1 byte (since the array consists of bytes)
• Using the above formula, we can calculate the line numbers for the memory locations of the array.
• For example, the line number for memory location 1100H is (1100 mod 2048)/1 = 108.
• Similarly, we can calculate the line numbers for all the memory locations of the array.
• Since the array is accessed twice and the contents of the data cache do not change in between the two accesses, the same lines of the data cache will be used for both accesses.
• Therefore, the lines of the data cache that will be replaced by new blocks in accessing the array for the second time are the lines that correspond to the memory locations of the array and are not already present in the data cache.
• These lines are line 4 to line 11, which correspond to the memory locations 1140H to 11F3H.
To make sure you are not studying endlessly, EduRev has designed Computer Science Engineering (CSE) study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Computer Science Engineering (CSE).