Home

SetAssociative

Set-associative is a cache organization used in computer memory systems. In a set-associative cache, the cache is divided into multiple sets. Each memory address maps to exactly one set, but within that set the data can be stored in any one of several cache lines. The number of lines per set is called the associativity; common configurations include 2-way, 4-way, and 8-way sets. The total number of cache lines equals the number of sets times the associativity, and each line holds a block of memory and a tag.

Addressing in a set-associative cache typically divides the memory address into a tag, an index (which selects

Performance-wise, increasing associativity reduces conflict misses compared with direct-mapped caches and generally improves hit rates, but

the
set),
and
an
offset
(which
selects
data
within
the
block).
The
index
identifies
the
candidate
set
for
a
given
address,
while
the
tag
is
used
to
verify
whether
a
line
in
that
set
contains
the
requested
data.
On
a
hit,
data
is
retrieved
from
the
corresponding
line;
on
a
miss,
a
new
block
is
loaded
into
the
set,
potentially
replacing
an
existing
line
according
to
a
replacement
policy
such
as
LRU
(least
recently
used),
pseudo-LRU,
or
random.
it
raises
hardware
complexity,
access
time,
and
energy
consumption.
Fully
associative
caches
offer
maximum
flexibility
but
are
often
impractical
for
large
caches
due
to
high
complexity.
Set-associative
caches
strike
a
balance
and
are
widely
used
in
modern
CPUs,
including
L1
and
L2
data
caches.
They
can
support
different
write
policies
(e.g.,
write-back
or
write-through)
and
are
compatible
with
various
coherence
and
consistency
mechanisms
in
multi-core
systems.