Answer 1
Main Memory Size = 64 K bytes = 216 Bytes so main memory address = 16 bits
Block Size = 8 Bytes = 23
Cache Size = 4 K bytes = 212 Bytes
4-way set associative cache which means Number of sets = 4
Main Memory Address = Tag bits Set Offset Byte Offset
Number of sets = Number of blocks / associativity
= (Cache Size/block size) / associativity
= (212 / 23) / 4
= 27 = 128 sets
So, Main Memory Address = Tag(6 bits) Set Offset (7 bits) Byte Offset(3 bits)
Answer 2
Direct-mapped cache
Number of blocks in cache = 8 = 23.
Number of blocks in Main memory = 4K = 212
Block size = 8 bytes = 23.
Cache access time = 22 ns
Page fault time = 300 ns.
a)
Main memory size = 212 * 23 = 215 so address = 15 bits
Byte offset = 3 bits (required to access each byte in the block)
Block offset = 3 bits (required to access each block in cache)
Tag = 15-3-3= 9 bits
Main Memory Address = Tag(9 bits) Block Offset (3 bits) Byte Offset(3 bits)
b)
Loop runs from 0x0 to 0x43 (67 in decimal)
Each block of memory contains 8 bytes. So first time miss will happen for starting address of block but subsequent 7 addresses will be hit. Please note that number of cache blocks are 8.
Pass 1 of Loop
Main Memory Block |
Addresses | Cache Block | Number of Misses | Number of Hits |
0 | 0x0 - 0x7 | 0 | 1 | 7 |
1 | 0x8 - 0xF | 1 | 1 | 7 |
2 | 0x10 - 0x17 | 2 | 1 | 7 |
3 | 0x18 - 0x1F | 3 | 1 | 7 |
4 | 0x20 - 0x27 | 4 | 1 | 7 |
5 | 0x28 - 0x2F | 5 | 1 | 7 |
6 | 0x30 - 0x37 | 6 | 1 | 7 |
7 | 0x38 - 0x3F | 7 | 1 | 7 |
8 | 0x40 - 0x43 | 0 | 1 | 3 |
Pass 2 of Loop
Main Memory Block |
Addresses | Cache Block | Number of Misses | Number of Hits |
0 | 0x0 - 0x7 | 0 | 1 | 7 |
1 | 0x8 - 0xF | 1 | 0 | 8 |
2 | 0x10 - 0x17 | 2 | 0 | 8 |
3 | 0x18 - 0x1F | 3 | 0 | 8 |
4 | 0x20 - 0x27 | 4 | 0 | 8 |
5 | 0x28 - 0x2F | 5 | 0 | 8 |
6 | 0x30 - 0x37 | 6 | 0 | 8 |
7 | 0x38 - 0x3F | 7 | 0 | 8 |
8 | 0x40 - 0x43 | 0 | 1 | 3 |
Pass 3 and pass 4 of Loop will also be similar to pass 2.
So Hit ratio = Number of hits / total access (hit+miss)
= 257/272
= 0.94485 = 94.48%
c)
Effective access time = Hit rate * cache access time + miss rate * page fault time
= (257/272) * 22 + (15/272)*300
= 37.33 ns
Get Answers For Free
Most questions answered within 1 hours.