Professional Documents
Culture Documents
Final Review
Branch Prediction
Branch Pattern: T, T, T, NT, NT
Branch Prediction
Branch Pattern: T, T, T, NT, NT
Branch Prediction
Branch Pattern: T, T, T, NT, NT
Branch Prediction
Branch Pattern: T, T, T, NT, NT
Tag
000
0000
001
010
011
100
101
110
111
Tag
Index
Offset
H/M
0000
000
Tag
Index
Offset
H/M
0000
000
Index
Tag
1000
011
000
0000
1101
010
001
010
1101
011
1000
100
101
110
111
Tag
Index
Offset
H/M
0000
000
Index
Tag
1000
011
000
0000
1101
010
0000
000
001
010
1101
011
1000
100
101
110
111
Tag
Index
Offset
H/M
0000
000
Index
Tag
1000
011
000
0000
1101
010
0000
000
001
010
1101
1000
011
011
1000
1101
010
100
101
110
111
Tag
Index
Offset
H/M
0000
000
Index
Tag
1000
011
000
0000 1010
1101
010
001
1010
0000
000
010
1101
1000
011
011
1000
1101
010
100
1010
001
101
1010
000
110
111
Tag
Index
Offset
H/M
0000
000
Index
Tag
1000
011
000
1010
1101
010
001
1010 0000
0000
000
010
1101
1000
011
011
1000
1101
010
100
1010
001
101
1010
000
110
0000
001
111
Tag
Index
Offset
H/M
0000
000
Index
Tag
1000
011
000
1010
1101
010
001
0000
0000
000
010
1101
1000
011
011
1000
1101
010
100
0010
1010
001
1010
000
0000
001
0010
110
0010
100
1101
110
101
110
111
0010 1101
Set-Associative Caching
Memory Access Pattern: 1, 134, 212, 1, 135, 213, 162, 161, 2, 44, 41, 221
Filling up Cache
Index
Tag[0]
00
00000
01
10
11010
11
10000
Tag[1]
Tag[2]
Tag
Index
Offset
H/M
00000
00
10000
11
11010
10
Set-Associative Caching
Memory Access Pattern: 1, 134, 212, 1, 135, 213, 162, 161, 2, 44, 41, 221
Bunch of hits!
Index
Tag[0]
00
00000
01
Tag[1]
Tag[2]
Tag
Index
Offset
H/M
00000
00
10000
11
11010
10
00000
00
10
11010
10000
11
11
10000
11010
10
Set-Associative Caching
Memory Access Pattern: 1, 134, 212, 1, 135, 213, 162, 161, 2, 44, 41, 221
Filling up more Cache
Tag
Index
Offset
H/M
00000
00
Index
Tag[0]
Tag[1]
Tag[2]
10000
11
00
00000
10100
00101
11010
10
01
10100
00000
00000
00
10
11010
00101
10000
11
11
10000
11010
10
10100
01
10100
00
00000
01
00101
10
00101
00
11011
10
11011
Set-Associative Caching
Memory Access Pattern: 1, 134, 212, 1, 135, 213, 162, 161, 2, 44, 41, 221
Example of LRU Step 1
Tag
Index
Offset
H/M
00000
00
Index
Tag[0]
Tag[1]
Tag[2]
10000
11
00
00000
00001
10100
00101
11010
10
00000
00
01
10100
00000
10000
11
10
11010
00101
11010
10
11
10000
10100
01
10100
00
00000
01
11011
Index
Offset
H/M
00101
10
00001
00
00101
00
10100
00
11011
10
Set-Associative Caching
Memory Access Pattern: 1, 134, 212, 1, 135, 213, 162, 161, 2, 44, 41, 221
Example of LRU Step 2
Tag
Index
Offset
H/M
00000
00
Index
Tag[0]
Tag[1]
Tag[2]
10000
11
00
00001
10100
00101
00000
11010
10
00000
00
10000
11
11010
10
10100
01
10100
00
00000
01
01
10100
00000
10
11010
00101
11
10000
11011
Index
Offset
H/M
00101
10
00001
00
00101
00
10100
00
11011
10
00000
00
TLB
Think of it as a cache for virtual memory
Operates in pretty much the same way as a
cache does
They tend to be fully associative
Will have some form of LRU (since true LRU is
difficult to implement in hardware)
TLB
Memory Access Pattern: 9452, 30964, 19136, 46502, 38110, 16653, 48480
Valid
Valid
Tag
Page Num
Disk
11
12
Disk
11
Disk
Disk
Disk
12
TLB
Memory Access Pattern: 9452, 30964, 19136, 46502, 38110, 16653, 48480
Address: 9452, TLB Miss AND Page Fault!
(Tag is 2)
Valid
Tag
Page Num
Valid
Disk
11
12
13
13
11
Disk
Disk
Disk
12
TLB
Memory Access Pattern: 9452, 30964, 19136, 46502, 38110, 16653, 48480
Address: 30964, TLB Hit (Tag is 7)
Valid
Valid
Tag
Page Num
Disk
11
12
13
13
11
Disk
Disk
Disk
12
TLB
Memory Access Pattern: 9452, 30964, 19136, 46502, 38110, 16653, 48480
Address: 19136, TLB Miss (Tag is 4 Replace 11)
Valid
Valid
Tag
Page Num
Disk
13
13
11
Disk
Disk
Disk
12
TLB
Memory Access Pattern: 9452, 30964, 19136, 46502, 38110, 16653, 48480
Address: 46502, TLB Miss (Tag is 11 Replace 3)
Valid
Valid
Tag
Page Num
Disk
13
11
12
13
11
Disk
Disk
Disk
12
TLB
Memory Access Pattern: 9452, 30964, 19136, 46502, 38110, 16653, 48480
Address: 38110, Page Fault! (Tag is 9 Replace 2)
Valid
Valid
Tag
Page Num
Disk
13
11
12
14
11
Disk
Disk
14
12
TLB
Memory Access Pattern: 9452, 30964, 19136, 46502, 38110, 16653, 48480
Address: 16553 (Tag = 4) Hit
Address: 48480 (Tag = 11) Hit
Valid
Tag
Page Num
Valid
Disk
13
11
12
14
11
Disk
Disk
14
12