Set Associative cache

Seungyun Lee·2026년 9월 19일

Computer Arch (Memory)

목록 보기
5/16

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?\boxed{Index=which room? }

Tag=is it the right person/block?\boxed{ \text{Tag}=\text{is it the right person/block?} }

Offset=where inside the room/block?\boxed{ \text{Offset}=\text{where inside the room/block?} }

profile
Design Verification engineer

0개의 댓글