• 24 bit address
• 2 bit word identifier (4 word per block)
• 22 bit block identifier
– 8 bit tag (=22-14)
– 14 bit slot or line
• Check contents of cache by finding LINE and
checking TAG
DIRECT MAPPING – Asal Pembagian Bit
s
Tag s-r Line or Slot r Word w
8 14 2
CACHE
Line Tag Data Block pengiriman RAM
0000
0001 Jumlah
0010 Jumlah word
0011 baris
. cache
.
.
DIRECT MAPPING – Organisasi Cache
DIRECT MAPPING – Contoh
• 24 bit address
• 2 bit word identifier (4 word per block)
• 22 bit tag identifier
• Check contents of cache by finding TAG
ASSOCIATIVE MAPPING – Organisasi Cache
ASSOCIATIVE MAPPING – Contoh
• Lebih banyak bit
yang disimpan sebagai
penanda
• Lebih boros resource
karena harus mencari
dari line paling atas
dengan mencocokkan
tiap-tiap tag
ASSOCIATIVE MAPPING FACTS
• Panjang alamat = (s + w) bits
• Jumlah unit yang dapat dialamati = 2s+w
words or bytes
• Besar blok = Besar baris = 2w words or
bytes
• Jumlah blok di main memory = 2s+ w/2w = 2s
• Jumlah baris di cache = bebas
• Ukuran tag = s bits
SET ASSOCIATIVE MAPPING
• Satu word data dari main memory akan di-
mapping ke slot mana saja di cache dalam
baris set yang sama
Alamat main memory akan dibagi menjadi:
• w bit LSB mewakili nomor word dalam 1
block
• s bit MSB mewakili block
• MSB kemudian diambil r bit sebagai
penanda baris set cache, sisanya (s-r)
sebagai tag (penanda)
SET ASSOCIATIVE MAPPING – Struktur
Alamat
Word
Tag 9 bit Set 13 bit 2 bit
• 24 bit address
• 2 bit word identifier (4 word per block)
• 22 bit block identifier
– 9 bit tag (=22-13)
– 13 set number, each having 2 slots
• Check contents of cache by finding SET and
checking TAG
SET ASSOCIATIVE MAPPING – Asal Pembagian Bit
Word
Tag 9 bit Set 13 bit 2 bit
CACHE
Tag Data Set Tag Data
0000
0001 Jumlah
0010 word
Jumlah
0011 baris
. (set)
cache Block pengiriman
. RAM
.
ways
TWO-WAY SET ASSOCIATIVE – Contoh
TWO-WAY SET ASSOCIATIVE – Contoh
• Menggabungkan
kelebihan direct
mapping dan
associative
mapping
SET ASSOCIATIVE MAPPING FACTS
• Panjang Alamat = (s + w) bits
• Jumlah unit yang bisa dialamatkan = 2s+w
words or bytes
• Besar blok = besar baris = 2w words or bytes
• Jumlah blok di main memory = 2d
• Jumlah baris dalam sebuah set = k
• Jumlah set = v = 2d
• Jumlah baris dalam satu cache = kv = k * 2d
• Ukuran tag = (s – d) bits
ALGORITMA REPLACEMENT
– Direct Mapping
• Tidak ada pilihan
• Tiap word dari sebuah blok hanya dapat
terpetakan pada satu baris tertentu
• Jika ada data baru yang akan disimpan
dalam cache, replace baris tersebut
ALGORITMA REPLACEMENT
– Associative & Set Associative
• Implementasi algoritma bisa langsung secara
hardware (cepat)
• Least Recently Used (LRU)
Misal pada 2 way set associative
– Mana dari kedua slot yang is LRU?
• First In First Out (FIFO)
– Replace slot yang paling lama berada di cache
• Least Frequently Used (LFU)
– Replace slot yang memiliki hit paling rendah
• Random
WRITE POLICY
• Mengapa butuh write policy? Karena bisa
saja data yang tadi diload ke cache,
terupdate oleh proses di CPU
• Demi keamanan data, jangan overwrite isi
cache kecuali jika main memory sudah di-
update
• Agar tidak berebut, multiple CPU (satu
komputer dengan > 1 CPU, yang dapat
berupa CPU terpisah maupun multi-core)
bisa memiliki cache masing-masing
WRITE POLICY: WRITE THROUGH
• Write terhadap update data dilakukan baik
ke main memory maupun cache
• CPU bisa memonitor traffic main memory
untuk menjaga agar cache selalu up to date
• Kekurangan:
– Traffic data
– Memperlambat proses write
WRITE POLICY: WRITE BACK
• Write terhadap update data, awalnya hanya
dilakukan pada data di cache (update bit
pada baris cache di-set ketika terjadi
update)
• Jika slot data tersebut akan terkena replace,
baru tuliskan update ke main memory
• Sisi negatif:
– Cache terlambat tersinkronisasi
– I/O harus mengakses main memory melewati
cache
– 15% pembacaan memory adalah write
CONTOH: PENTIUM 4 CACHE
• 80386 – no on chip cache
• 80486 – 8k using 16 byte lines and four way set
associative organization
• Pentium (all versions)
– two on-chip L1 caches for Data & instructions
• Pentium 4 – L1 caches
– 8k bytes
– 64 byte lines
– four way set associative
• L2 cache
– Feeding both L1 caches - 256k
– 128 byte lines
– 8 way set associative
UKURAN CACHE
ARSITEKTUR PENTIUM 4
INTEL CORE i3
INTEL CORE i5
INTEL CORE i7
ARSITEKTUR INTEL CORE i3