5.4.4 · D1 · HinglishMemory Hierarchy & Caches

FoundationsCache line size and tags

1,776 words8 min read↑ Read in English

5.4.4 · D1 · Hardware › Memory Hierarchy & Caches › Cache line size and tags

Is page mein assume kiya gaya hai ki aap kuch nahi jaante. Hum har word, symbol, aur picture ko build karte hain jo parent note 5.4.4 use karta hai, is tarah ke har idea uske pehle wale idea par tika ho.


0. Bit kya hota hai? (neeche ki har cheez ka atom)

Ek row of light switches ki picture socho. Har switch ek bit hai. Agar mere paas 3 switches hain, toh woh kitne alag patterns dikha sakti hain? Har switch ko independently on ya off karo:

Figure — Cache line size and tags

Daayein taraf red count dekho: 3 switches se patterns milte hain. Generally:

Is topic ko yeh kyun chahiye. Memory address ek row of bits hi hoti hai. Cache ka poora game yeh hai: "main har kaam par kitne bits kharchoon?" — aur "yeh bits kitne patterns naam de sakte hain?" ka answer exactly hai.


1. Powers of two aur (switches ginne ka tarika)

Humne abhi dekha . Exponent notation ka matlab hai "2 ko baar khud se multiply karo".

Ab ulta sawaal. Maan lo mere paas 64 patterns hain aur main poochhta hoon: kitne switches chahiye the? Jawab 6 hai, kyunki . Woh tool jo poochhe "konsa exponent yeh number deta hai?" — woh hai .


2. Byte, aur KiB units (switches ko group karna)

Memory sizes badi ho jaati hain, isliye hum bytes ko group karte hain:


3. Hexadecimal (lambi bit rows ka shorthand)

32-bit address ko 32 zeros aur ones ki tarah likhna bahut takleef deh hai. Hex 4 bits ko ek symbol mein pack karta hai, kyunki 4 bits patterns dete hain aur hex mein exactly 16 digits hain: 0 1 2 3 4 5 6 7 8 9 A B C D E F.

Figure — Cache line size and tags

0x prefix sirf flag karta hai "yeh hex hai". Toh 0x2 ka matlab value 2 hai; 0xA9 ka matlab hai.

Is topic ko yeh kyun chahiye. Addresses parent mein har jagah hex mein dikhaye jaate hain (tag 0x2, index 0xA9). Hex sirf bit row ki rewrting hai — koi naya information nahi, bas kam characters.


4. Memory address (badi book mein ek numbered slot)

ke liye: billion addressable bytes.

Is topic ko yeh kyun chahiye. Parent page poori tarah ek address ko teen fields mein kaatne ke baare mein hai. Agar aap nahi jaante ki address sirf bits ki ek row hai, toh kaatne ka koi matlab nahi.


5. Cache line / block (woh chunk jo hum copy karte hain)

Figure — Cache line size and tags

Red bracket ek line dikhata hai: CPU ne arrow wale byte ke liye request ki, lekin cache ne poora bracketed run le liya. Woh bet laga raha hai ki aapko agli baar neighbors chahiye honge — woh bet hai spatial locality.

Is topic ko yeh kyun chahiye. Line woh unit hai jiske against sab kuch measure hota hai: offset bits = "line ke andar kaunsa byte", aur line count se index bits aate hain.


6. Teen address fields (sab kuch jodna)

Ab har prerequisite haath mein hai, parent ki central picture poori tarah samajh aati hai. address bits ko upar (high bits) se neeche split karo:

Figure — Cache line size and tags

Prerequisite map

Bit: a 0 or 1 switch

n bits give 2 to the n patterns

log base 2 counts the bits

Byte is 8 bits and KiB is 1024 bytes

Hex packs 4 bits per digit

Memory address is N bits

Offset bits equal log2 of line size

Index bits equal log2 of line count

Cache line is L neighbour bytes

Split address into Tag Index Offset

Cache line size and tags 5.4.4


Equipment checklist

Aap parent note ke liye ready hain jab aap bina dekhe inn mein se har ek ka jawab de sako:

6 bits kitne patterns represent kar sakte hain?
kya hoga, aur kyun?
, kyunki
KiB mein kitne bytes hain?
bytes, jo ki hai
Hex exactly 4 bits per digit kyun pack karta hai?
Kyunki aur hex mein 16 digits hain (, )
Cache line kya hoti hai, ek sentence mein?
neighboring bytes ka ek fixed run jo memory se ek unit ki tarah saath copy hota hai
Address ke lowest bits kaun sa field hota hai, aur woh kya pick karta hai?
Offset; woh line ke andar byte pick karta hai
Line size diya ho toh offset bits kitne?
Cache size aur line size diye hon (direct-mapped), toh index bits kitne?
-bit address diya ho toh tag bits kitne?

Connections

  • 5.4.01-Cache-fundamentals — hum cache kyun karte hain
  • 5.4.02-Direct-mapped-caches — pehla cache jo in teeno fields ko directly use karta hai
  • 3.1.04-Spatial-locality — wajah ki ek line mein bahut saare bytes hote hain
  • 6.2.01-Virtual-memory-pages — wahi "address ko split karo" trick, pages par apply ki
  • Yeh foundation Hinglish mein →