150 likes | 307 Vues
CDA 3101 Discussion Section 10. Memory Hierarchy. Question 1. Assume the word address is 8-bits, calculate the length of tag index and block offset of the following cache: C1: block size = 1 word, 4 blocks, direct-mapped; C2: block size = 1 word, 8 blocks, direct-mapped;
E N D
CDA 3101 Discussion Section 10 Memory Hierarchy
Question 1 • Assume the word address is 8-bits, calculate the length of tag index and block offset of the following cache: • C1: block size = 1 word, 4 blocks, direct-mapped; • C2: block size = 1 word, 8 blocks, direct-mapped; • C3: block size = 1 word, 8 blocks, 2-way set associative; • C4: block size = 2 words, 4 blocks, direct-mapped; • C5: block size = 2 words, 4 blocks, fully associative;
Question 1 (cont) • (Block size) = 2(# of offset bits) • (Number of sets) = 2(# of index bits) • (# of tag bits) = (# of memory address bits) (# of index bits) (# of offset bits) • Block size =1 => No offset bits • Sets =1 (fully associative) => No index bits
Question 1 (cont) • C1: block size = 1 word, 4 blocks, direct-mapped; • Block size =1 ->Offset bits :0; • 4 blocks direct-mapped -> 4 sets -> index bits =2; • Tag bits = 8-2-0 =6.
Question 1 (cont) • C2: block size = 1 word, 8 blocks, direct-mapped; • Block size =1 ->Offset bits :0; • 8 blocks direct-mapped -> 8 sets -> index bits =3; • Tag bits = 8-3-0 =5.
Question 1 (cont) • C3: block size = 1 word, 8 blocks, 2-way set associative; • Block size =1 ->Offset bits :0; • 8 blocks 2-way set associative -> 4 sets -> index bits =2; • Tag bits = 8-2-0 =6.
Question 1 (cont) • C4: block size = 2 words, 4 blocks, direct-mapped; • Block size =2 ->Offset bits :1; • 4 blocks direct-mapped -> 4 sets -> index bits =2; • Tag bits = 8-2-1 =5.
Question 1 (cont) • C5: block size = 2 words, 4 blocks, fully associative; • Block size =2 ->Offset bits :1; • fully associative -> 1 set -> index bits =0; • Tag bits = 8-0-1 =7.
Question 2 • Mapping the following word addresses to the corresponding cache block: • Address: 2 3 6 7 11 15 26 43: • C1: block size = 1 word, 4 blocks, direct-mapped; • C2: block size = 1 word, 8 blocks, direct-mapped; • C3: block size = 1 word, 8 blocks, 2-way set associative; • C4: block size = 2 words, 4 blocks, direct-mapped; • C5: block size = 2 word, 4 blocks, fully associative;
Question 2 (cont) • 2 = 0000 0010 • 3 = 0000 0011 • 6 = 0000 0110 • 7 = 0000 0111 • 11 = 0000 1011 • 15 = 0000 1111 • 26 = 0001 1010 • 43 = 0010 1011
Question 2 (cont) • C1: block size = 1 word, 4 blocks, direct-mapped; • 2 = 0000 0010 block 2 • 3 = 0000 0011 block 3 • 6 = 0000 0110 block 2 • 7 = 0000 0111 block 3 • 11 = 0000 1011 block 3 • 15 = 0000 1111 block 3 • 26 = 0001 1010 block 2 • 43 = 0010 1011 block 3
Question 2 (cont) • C2: block size = 1 word, 8 blocks, direct mapped; • 2 = 0000 0010 block 2 • 3 = 0000 0011 block 3 • 6 = 0000 0110 block 6 • 7 = 0000 0111 block 7 • 11 = 0000 1011 block 3 • 15 = 0000 1111 block 7 • 26 = 0001 1010 block 2 • 43 = 0010 1011 block 3
Question 2 (cont) • C3: block size = 1 word, 8 blocks, 2-way set associative; ->4 sets • 2 = 0000 0010 set 2: block 4 5 • 3 = 0000 0011 set 3 : block 6 7 • 6 = 0000 0110 set 2 : block 4 5 • 7 = 0000 0111 set 3 : block 6 7 • 11 = 0000 1011 set 3 : block 6 7 • 15 = 0000 1111 set 3 : block 6 7 • 26 = 0001 1010 set 2 : block 4 5 • 43 = 0010 1011 set 3 : block 6 7
Question 2 (cont) • C4: block size = 2 words, 4 blocks, direct-mapped; • 2 = 0000 0010block 1 1st word • 3 = 0000 0011block 1 2nd word • 6 = 0000 0110block 3 1st word • 7 = 0000 0111block 3 2nd word • 11 = 0000 1011block 1 2nd word • 15 = 0000 1111block 3 2nd word • 26 = 0001 1010block 1 1st word • 43 = 0010 1011block 1 2nd word
Question 2 (cont) • C5: block size = 2 word, 4 blocks, fully associative; • 2 = 0000 0010any block 1st word • 3 = 0000 0011any block 2nd word • 6 = 0000 0110any block 1st word • 7 = 0000 0111any block 2nd word • 11 = 0000 1011any block 2nd word • 15 = 0000 1111any block 2nd word • 26 = 0001 1010any block 1st word • 43 = 0010 1011any block 2nd word