Questions for Cache Hierarchy
Q1: Where can a block be placed in the upper level?
- (Block placement)
Q2: How is a block found if it is in the upper level?
- (Block identification)
Q3: Which block should be replaced on a miss?
- (Block replacement)
Q4: What happens on a write?
- (Write strategy)
Q1: Where can a block be placed in the upper level?

Set = # of cacheline / way
2 - way set associative = 2 cache line (way) per set
Cache Block = chunk of memory data
Cache line = actual stroage location
Way = position name of that line

Way 0 Way 1
↓ ↓
Set 0 [ Cache Line ] [ Cache Line ]
Set 1 [ Cache Line ] [ Cache Line ]
Set 2 [ Cache Line ] [ Cache Line ]
Set 3 [ Cache Line ] [ Cache Line ]
As you can see here,
- Number of ways = 2 (position name)
- Number of cache lines = 8 (actual stroage location)
1. Fully associative
Anywhere in the cache
2. Direct mapped
At a fixed place in the cache
Index=Block_Address mod Cache_Size
3. Set associative
Anywhere within a restricted set of places
Set_Index=Block_Address mod Number_Of_Sets

2 way means you have two cache line,
and 12 mod 4 = 0 so, you can put data at set 0
Q2: How is a block found if it is in the upper level?
Data address in main memory is divided into following fields:
- Block offset – where within a block do we start accessing the data we need
- Block Address

Each cache record stores
- Tag
- Valid bit – whether this record contains valid information
- Data – the actual block is stored here
Index=whichroom?
Tag=is it the right person/block?
Offset=where inside the room/block?