<s>
A	O
CPU	B-General_Concept
cache	I-General_Concept
is	O
a	O
memory	O
which	O
holds	O
the	O
recently	O
utilized	O
data	O
by	O
the	O
processor	O
.	O
</s>
<s>
If	O
the	O
tag	O
matches	O
,	O
then	O
there	O
is	O
a	O
cache	O
hit	O
and	O
the	O
cache	B-General_Concept
block	I-General_Concept
is	O
returned	O
to	O
the	O
processor	O
.	O
</s>
<s>
Since	O
each	O
cache	B-General_Concept
block	I-General_Concept
is	O
of	O
size	O
4	O
bytes	O
,	O
the	O
total	O
number	O
of	O
sets	O
in	O
the	O
cache	O
is	O
256/4	O
,	O
which	O
equals	O
64	O
sets	O
.	O
</s>
<s>
In	O
a	O
fully	O
associative	B-General_Concept
cache	I-General_Concept
,	O
the	O
cache	O
is	O
organized	O
into	O
a	O
single	O
cache	O
set	O
with	O
multiple	O
cache	O
lines	O
.	O
</s>
<s>
Fully	O
associative	B-General_Concept
cache	I-General_Concept
structure	O
provides	O
us	O
the	O
flexibility	O
of	O
placing	O
memory	O
block	O
in	O
any	O
of	O
the	O
cache	O
lines	O
and	O
hence	O
full	O
utilization	O
of	O
the	O
cache	O
.	O
</s>
<s>
Consider	O
a	O
main	O
memory	O
of	O
16	O
kilobytes	O
,	O
which	O
is	O
organized	O
as	O
4-byte	O
blocks	O
,	O
and	O
a	O
fully	O
associative	B-General_Concept
cache	I-General_Concept
of	O
256	O
bytes	O
and	O
a	O
block	O
size	O
of	O
4	O
bytes	O
.	O
</s>
<s>
The	O
total	O
number	O
of	O
sets	O
in	O
the	O
cache	O
is	O
1	O
,	O
and	O
the	O
set	O
contains	O
256/4	O
=	O
64	O
cache	O
lines	O
,	O
as	O
the	O
cache	B-General_Concept
block	I-General_Concept
is	O
of	O
size	O
4	O
bytes	O
.	O
</s>
<s>
Set-associative	O
cache	O
is	O
a	O
trade-off	O
between	O
direct-mapped	O
cache	O
and	O
fully	O
associative	B-General_Concept
cache	I-General_Concept
.	O
</s>
<s>
(	O
A	O
direct-mapped	O
cache	O
is	O
one-way	O
set-associative	O
and	O
a	O
fully	O
associative	B-General_Concept
cache	I-General_Concept
with	O
m	O
cache	O
lines	O
is	O
m-way	O
set-associative	O
.	O
)	O
</s>
<s>
Many	O
processor	B-General_Concept
caches	I-General_Concept
in	O
today	O
's	O
designs	O
are	O
either	O
direct-mapped	O
,	O
two-way	O
set-associative	O
,	O
or	O
four-way	O
set-associative	O
.	O
</s>
<s>
The	O
placement	O
policy	O
is	O
a	O
trade-off	O
between	O
direct-mapped	O
and	O
fully	O
associative	B-General_Concept
cache	I-General_Concept
.	O
</s>
<s>
Since	O
each	O
cache	B-General_Concept
block	I-General_Concept
is	O
of	O
size	O
4	O
bytes	O
and	O
is	O
2-way	O
set-associative	O
,	O
the	O
total	O
number	O
of	O
sets	O
in	O
the	O
cache	O
is	O
256/	O
( 4	O
*	O
2	O
)	O
,	O
which	O
equals	O
32	O
sets	O
.	O
</s>
<s>
Other	O
schemes	O
have	O
been	O
suggested	O
,	O
such	O
as	O
the	O
skewed	O
cache	O
,	O
where	O
the	O
index	O
for	O
way	O
0	O
is	O
direct	O
,	O
as	O
above	O
,	O
but	O
the	O
index	O
for	O
way	O
1	O
is	O
formed	O
with	O
a	O
hash	B-Error_Name
function	I-Error_Name
.	O
</s>
<s>
A	O
good	O
hash	B-Error_Name
function	I-Error_Name
has	O
the	O
property	O
that	O
addresses	O
which	O
conflict	O
with	O
the	O
direct	O
mapping	O
tend	O
not	O
to	O
conflict	O
when	O
mapped	O
with	O
the	O
hash	B-Error_Name
function	I-Error_Name
,	O
and	O
so	O
it	O
is	O
less	O
likely	O
that	O
a	O
program	O
will	O
suffer	O
from	O
an	O
unexpectedly	O
large	O
number	O
of	O
conflict	O
misses	O
due	O
to	O
a	O
pathological	O
access	O
pattern	O
.	O
</s>
<s>
The	O
downside	O
is	O
extra	O
latency	O
from	O
computing	O
the	O
hash	B-Error_Name
function	I-Error_Name
.	O
</s>
<s>
Additionally	O
,	O
when	O
it	O
comes	O
time	O
to	O
load	O
a	O
new	O
line	O
and	O
evict	O
an	O
old	O
line	O
,	O
it	O
may	O
be	O
difficult	O
to	O
determine	O
which	O
existing	O
line	O
was	O
least	O
recently	O
used	O
,	O
because	O
the	O
new	O
line	O
conflicts	O
with	O
data	O
at	O
different	O
indexes	O
in	O
each	O
way	O
;	O
LRU	B-General_Concept
tracking	O
for	O
non-skewed	O
caches	O
is	O
usually	O
done	O
on	O
a	O
per-set	O
basis	O
.	O
</s>
<s>
A	O
true	O
set-associative	O
cache	O
tests	O
all	O
the	O
possible	O
ways	O
simultaneously	O
,	O
using	O
something	O
like	O
a	O
content-addressable	B-Data_Structure
memory	I-Data_Structure
.	O
</s>
<s>
A	O
hash-rehash	O
cache	O
and	O
a	O
column-associative	O
cache	O
are	O
examples	O
of	O
a	O
pseudo-associative	O
cache	O
.	O
</s>
<s>
In	O
the	O
common	O
case	O
of	O
finding	O
a	O
hit	O
in	O
the	O
first	O
way	O
tested	O
,	O
a	O
pseudo-associative	O
cache	O
is	O
as	O
fast	O
as	O
a	O
direct-mapped	O
cache	O
,	O
but	O
it	O
has	O
a	O
much	O
lower	O
conflict	O
miss	O
rate	O
than	O
a	O
direct-mapped	O
cache	O
,	O
closer	O
to	O
the	O
miss	O
rate	O
of	O
a	O
fully	O
associative	B-General_Concept
cache	I-General_Concept
.	O
</s>
