Memory Hierarchy

15
1 Memory Hierarchy Memory Hierarchy CDA 3101 Discussion Section 10 CDA 3101 Discussion Section 10

description

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; - PowerPoint PPT Presentation

Transcript of Memory Hierarchy

Page 1: Memory Hierarchy

1

Memory HierarchyMemory Hierarchy

CDA 3101 Discussion Section 10CDA 3101 Discussion Section 10

Page 2: Memory Hierarchy

Question 1Question 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;

2

Page 3: Memory Hierarchy

Question 1 (cont)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

3

Page 4: Memory Hierarchy

Question 1 (cont)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.

4

Page 5: Memory Hierarchy

Question 1 (cont)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.

5

Page 6: Memory Hierarchy

Question 1 (cont)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.

6

Page 7: Memory Hierarchy

Question 1 (cont)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.

7

Page 8: Memory Hierarchy

Question 1 (cont)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.

8

Page 9: Memory Hierarchy

Question 2Question 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;

9

Page 10: Memory Hierarchy

Question 2 (cont)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

10

Page 11: Memory Hierarchy

Question 2 (cont)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

11

Page 12: Memory Hierarchy

Question 2 (cont)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

12

Page 13: Memory Hierarchy

Question 2 (cont)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

13

Page 14: Memory Hierarchy

Question 2 (cont)Question 2 (cont)• C4: block size = 2 words, 4 blocks, direct-

mapped;– 2 = 0000 0010 block 1 1st word– 3 = 0000 0011 block 1 2nd word– 6 = 0000 0110 block 3 1st word– 7 = 0000 0111 block 3 2nd word– 11 = 0000 1011 block 1 2nd word– 15 = 0000 1111 block 3 2nd word– 26 = 0001 1010 block 1 1st word– 43 = 0010 1011 block 1 2nd word

14

Page 15: Memory Hierarchy

Question 2 (cont)Question 2 (cont)• C5: block size = 2 word, 4 blocks, fully

associative;– 2 = 0000 0010 any block 1st word– 3 = 0000 0011 any block 2nd word– 6 = 0000 0110 any block 1st word– 7 = 0000 0111 any block 2nd word– 11 = 0000 1011 any block 2nd word– 15 = 0000 1111 any block 2nd word– 26 = 0001 1010 any block 1st word– 43 = 0010 1011 any block 2nd word

15