To map the main memory address to the cache address under different cache mapping schemes, let's consider each scenario:
### Given Information:
- Main Memory Size: 64 K words
- Word Size: 16 bits
- Cache Size: 32 blocks
- Block Size: 32 bits (2 memory words)
### (i) Direct Cache Mapping:
1. Calculate Block Size
- Block Size = Cache Line Size = 32 bits
2. Calculate Block Offset:
- Block Offset = log2(Block Size) = log2(32) = 5 bits
3. Calculate Index Bits:
- Index Bits = log2(Number of Blocks) = log2(32) = 5 bits
4. Calculate Tag Bits:
- Tag Bits = Total Address Bits - (Index Bits + Block Offset) = 16 - (5 + 5) = 6 bits
5. Convert the Main Memory Address (1AFC)h to Binary:
- Tag: \(000110\) - \(0001 \, 1010 \, 1111 \, 1100\) (in 16 bits)
6. Extract Tag, Index, and Offset:
- Index: \(10111\)
- Offset: \(11100\)
7. Cache Address:
- Concatenate Index and Offset: \(1011111100\) (binary)
(ii) Associative Cache Mapping (Fully Associative):
Since it's fully associative, there's no need to calculate indexes. The entire main memory address is used as the tag.
1. Convert the Main Memory Address (1AFC)h to Binary:
- \(0001 \, 1010 \, 1111 \, 1100\) (in 16 bits)
2. Cache Address:
- Entire Address is the Tag: \(0001101011111100\) (binary)
(iii) Two-Way Set Associative Cache Mapping:
1. Calculate Sets:
- Number of Sets = Number of Blocks / Associativity = 32 / 2 = 16 sets
2. Calculate Index Bits:
- Index Bits = log2(Number of Sets) = log2(16) = 4 bits
3. Calculate Block Offset:
- Block Offset = log2(Block Size) = log2(32) = 5 bits
4. Calculate Tag Bits:
- Tag Bits = Total Address Bits - (Index Bits + Block Offset) = 16 - (4 + 5) = 7 bits
5. Convert the Main Memory Address (1AFC)h to Binary:
- \(0001 \, 1010 \, 1111 \, 1100\) (in 16 bits)
6. Extract Tag, Index, and Offset:
- Tag: \(0001101\)
- Index: \(0111\)
- Offset: \(11100\)
7. Cache Address:
- Concatenate Index and Offset: \(011111100\) (binary)
In summary:
- (i) Direct Cache Mapping: \(1011111100\) (binary)
- (ii) Associative Cache Mapping: \(0001101011111100\) (binary)
- (iii) Two-Way Set Associative Cache Mapping: \(011111100\) (binary)
0 टिप्पणियाँ:
Post a Comment