Assuming that a computer system has 64MBytes of main memory, 16Bytes of cache line and 64KBytes of cache size. A main memory address contains “A1E3”data in a particular memory cell. Transfer this data to the cache in direct mapping, associative mapping and 16-way set-associative mapping algorithms.
Cache Line = 16B => Block Offset = log 16 = 4 bits.
Total # of block inside cache => 64KB /16 = 4K
Main memory = 64MB => 26 bits.
For Direct Mapping,
Index offset = log(#of blocks) = log 4k = 12 bits
Tag = 26 - 12 - 4 = 10 bits
Tag(10 bits) | Index Offset (12 bits) | Cache Offset (4 bits) |
A1E3 => 000A1E3 => 0000000000 101000011110 0100
So Index offset => 101000011110 => 2590.
So A1E3 would be transferred to block # 2590 of cache.
Association Mapping: Here there is no restriction on the main memory block. It can be placed anywhere inside the cache.
Thus A1E3 can be placed in any one of 4k blocks.
16 way set associative:
Total # of set inside cache => 4K/16 = 256
So index offset = log 256 = 8
So tag bits = 26 - 8 - 4 = 14
Tag(14 bits) | Index Offset (8) | Block Offset (4) |
A1E3 => 1010 0001 1110 0011
Here index bits = 00011110 => 30
So the memory block A1E3 belongs to set # 30 of cache.
If you have any questions comment down. Please don't simply downvote and leave. If you are satisfied with answer, please? upvote thanks....
Get Answers For Free
Most questions answered within 1 hours.