You are on page 1of 3
& testbook.com De teria) PSE Tam ee CMe lel eli) FA) Daily Live Practice eens ato MasterClasses Cres ea ig Download App Question View this Question Online > A computer system with a word length of 32 bits has a 16 MB byte-addressable main memory and a 64 KB, 4-way set associative cache memory with a block size of 256 bytes. Consider the following four physical addresses represented in hexadecimal notation. Al = 0x42C8A4, A2 = 0x546888, A3 = 0x6A289C, A4 = 0x5E4880 Which one of the following is TRUE? This question was previously asked in iaoen i % Get CI aeOM GATE CS 2020 Official Paper View all GATE CS Papers > 1. A1 and Ad are mapped to different cache sets. 2. A2 and A3 are mapped to the same cache set. 3, A3 and Ad are mapped to the same cache set. 4, A and A3 are mapped to the same cache set. Answer (Detailed Solution Below) Option 2: A2 and A3 are mapped to the same cache set. Detailed Solution Size of main memory: 16 MB Size of cache memory: 64 KB Block/line size: 256 B The cache memory has been designed as 4- way set associative Calculation: The memory is Byte- addressable. Main memory size = 16 MB = 24 represented 8. That means physical address generated by CPU would be using 24 bits Cache memory size = 64 KB = 2" B Block size = 256 B = 2° B. i.e. word would be represented by 8 bits Therefore, Number of cache lines + blocks = 2'6 + 28 = 28 Since, the cache memory is 4-way set associative. Hence, number of sets = 2° = 2? = 2°. ie. 6 bits would be required for set/index. Therefore, Number of bits for tag = 24 - (6 +8) = 10 bits Hence, the 24 bit address generated by CPU would have following components: Tag (10 bits) Set/Index (6 | Word (8 bits) bits) Physical Address A1 = 0x 42C8A4. Converting it into binary gives: 0100 0010 11 | 00 1000 1010 0100 Physical Address A2 = Ox 546888. Converting it into binary gives: 0101010001 | 10 1000 1000 1000 Physical Address A3 = 0x 6A289C. Converting it into binary gives: 0110 101000 | 10 1000 1001 1100 Physical Address A4 =0x 5E4880. Converting it into binary gives: 0101111001 | 00 1000 1000 0000 Thus it can be observed that A2 and A3 map to same set. Also, address A1 and A4 map to same set. Tips and Tricks: The following approach should be adopted to quickly solve this question and save a lot of time:- The number of bits for tag in a K- way set associative memory can be calculated directly as: (logs (Main memory size in Bytes) — logs (Cache memory size in Bytes)) + logo K Another thing is that the question is concerned only about the set number of the given addresses. So, we need not convert first two Hex digits of the given address into binary format, because they would be part of tag bits. Similarly, the last two Hex digits need not be converted into binary as they are part of Word/Offset. Only the middle two Hex digit needs to be converted into binary. And then the 6 LSBs can be compared to check if they represent the same set or not.

You might also like