16 bytes CACHE
TAG
CACHE
ADDRESS
MAIN MEMORY
0000000
BLOK 0
BLOK 0
0000100
BLOK 1
BLOK 1
0001000
BLOK 2
BLOK 2
0001100
BLOK 3
BLOK 3
0010000
BLOK 4
BLOK 5
.
.
.
.
.
.
.
.
.
.
.
Block Word
2 bit
2 bit
1111100
BLOK 31
Example:
Main memory size of 1 MB (20 address bit) addressable to individual byte.
Cache size of 8 kB lines, each block consists 8 bytes.
Where is the byte stored at main memory location $ ABCDE stored?
Answer:
WORD = 3 bits
BLOCK = 10 bits
TAG = 7 bits
$ABCDE = 1010 1011 1100 1101 1110
$ABCDE = 1010101 1110011011 110
HEX:
Byte store at:
55
39B
Block 39B
Word 6
Tag
55
ASSOCIATIVE MAP
16 bytes CACHE
TAG
ADDRESS
0000000
BLOK 0
MAIN MEMORY
BLOK 0
0000100
BLOK 1
BLOK 1
0001000
BLOK 2
BLOK 2
0001100
BLOK 3
BLOK 3
0010000
BLOK 4
Blok
pada
main
memory
dapat
.
.
.
.
.
.
.
1111100
WORD
BLOK 31
SET 0
SET 1
SET 2
ADDRESS
MAIN MEMORY
BLOK 0
BLOK 1
BLOK 1
BLOK 2
BLOK 2
BLOK 3
BLOK 3
BLOK 4
BLOK 4
BLOK 5
BLOK 5
BLOK 6
BLOK 6
BLOK 7
BLOK 7
SET 3
BLOK 8
BLOK 9
BLOK 10
sama.
1 Blok misalnya dapat menyimpan 2 byte, maka
.
.
.
.
.
.
.
BLOK 63
untuk TAG.
7 1 2 = 4 bit.
TAG
4
SET
2
WORD
REPLACEMENT ALGORITHM
Pada DIRECT MAPPED CACHE posisi dari setiap blok sudah
ditentukan terlebih dahulu, oleh karenanya tidak diperlukan strategi
penggantian.
Pada ASSOCIATIVE dan SET ASSOCIATIVE, jika suatu blok yang
baru akan dibawa ke CACHE yang sudah penuh maka CACHE
controller akan memutuskan blok lama yang mana akan diganti.
Strategi yang dipakai menggunakan LRU, FIFO, LFU, dan Random.