<s>
Content-addressable	B-Data_Structure
memory	I-Data_Structure
(	O
CAM	B-Data_Structure
)	O
is	O
a	O
special	O
type	O
of	O
computer	B-General_Concept
memory	I-General_Concept
used	O
in	O
certain	O
very-high-speed	O
searching	O
applications	O
.	O
</s>
<s>
It	O
is	O
also	O
known	O
as	O
associative	O
memory	O
or	O
associative	B-Data_Structure
storage	I-Data_Structure
and	O
compares	O
input	O
search	O
data	O
against	O
a	O
table	O
of	O
stored	O
data	O
,	O
and	O
returns	O
the	O
address	O
of	O
matching	O
data	O
.	O
</s>
<s>
CAM	B-Data_Structure
is	O
frequently	O
used	O
in	O
networking	B-Device
devices	I-Device
where	O
it	O
speeds	O
up	O
forwarding	B-Protocol
information	I-Protocol
base	I-Protocol
and	O
routing	B-Protocol
table	I-Protocol
operations	O
.	O
</s>
<s>
Dudley	O
Allen	O
Buck	O
invented	O
the	O
concept	O
of	O
content-addressable	B-Data_Structure
memory	I-Data_Structure
in	O
1955	O
.	O
</s>
<s>
Unlike	O
standard	O
computer	B-General_Concept
memory	I-General_Concept
,	O
random-access	B-Architecture
memory	I-Architecture
(	O
RAM	B-Architecture
)	O
,	O
in	O
which	O
the	O
user	O
supplies	O
a	O
memory	O
address	O
and	O
the	O
RAM	B-Architecture
returns	O
the	O
data	O
word	O
stored	O
at	O
that	O
address	O
,	O
a	O
CAM	B-Data_Structure
is	O
designed	O
such	O
that	O
the	O
user	O
supplies	O
a	O
data	O
word	O
and	O
the	O
CAM	B-Data_Structure
searches	O
its	O
entire	O
memory	O
to	O
see	O
if	O
that	O
data	O
word	O
is	O
stored	O
anywhere	O
in	O
it	O
.	O
</s>
<s>
If	O
the	O
data	O
word	O
is	O
found	O
,	O
the	O
CAM	B-Data_Structure
returns	O
a	O
list	O
of	O
one	O
or	O
more	O
storage	O
addresses	O
where	O
the	O
word	O
was	O
found	O
.	O
</s>
<s>
Thus	O
,	O
a	O
CAM	B-Data_Structure
is	O
the	O
hardware	O
embodiment	O
of	O
what	O
in	O
software	O
terms	O
would	O
be	O
called	O
an	O
associative	B-Application
array	I-Application
.	O
</s>
<s>
A	O
major	O
interface	O
definition	O
for	O
CAMs	B-Data_Structure
and	O
other	O
network	B-Device
search	I-Device
engines	I-Device
was	O
specified	O
in	O
an	O
interoperability	O
agreement	O
called	O
the	O
Look-Aside	B-Device
Interface	I-Device
(	O
LA-1	O
and	O
LA-1B	O
)	O
developed	O
by	O
the	O
Network	B-General_Concept
Processing	I-General_Concept
Forum	O
.	O
</s>
<s>
CAM	B-Data_Structure
is	O
much	O
faster	O
than	O
RAM	B-Architecture
in	O
data	O
search	O
applications	O
.	O
</s>
<s>
There	O
are	O
cost	O
disadvantages	O
to	O
CAM	B-Data_Structure
however	O
.	O
</s>
<s>
Unlike	O
a	O
RAM	B-Architecture
chip	I-Architecture
,	O
which	O
has	O
simple	O
storage	O
cells	O
,	O
each	O
individual	O
memory	O
bit	O
in	O
a	O
fully	O
parallel	O
CAM	B-Data_Structure
must	O
have	O
its	O
own	O
associated	O
comparison	O
circuit	O
to	O
detect	O
a	O
match	O
between	O
the	O
stored	O
bit	O
and	O
the	O
input	O
bit	O
.	O
</s>
<s>
The	O
additional	O
circuitry	O
increases	O
the	O
physical	O
size	O
and	O
manufacturing	O
cost	O
of	O
the	O
CAM	B-Data_Structure
chip	O
.	O
</s>
<s>
Consequently	O
,	O
CAM	B-Data_Structure
is	O
used	O
only	O
in	O
specialized	O
applications	O
where	O
searching	O
speed	O
cannot	O
be	O
accomplished	O
using	O
a	O
less	O
costly	O
method	O
.	O
</s>
<s>
In	O
the	O
early	O
2000s	O
several	O
semiconductor	O
companies	O
including	O
Cypress	O
,	O
IDT	O
,	O
Netlogic	O
,	O
Sibercore	O
,	O
and	O
MOSAID	O
introduced	O
CAM	B-Data_Structure
products	O
targeting	O
networking	O
applications	O
.	O
</s>
<s>
These	O
products	O
were	O
labelled	O
Network	B-Device
Search	I-Device
Engines	I-Device
(	O
NSE	O
)	O
,	O
Network	O
Search	O
Accelerators	O
(	O
NSA	O
)	O
,	O
and	O
Knowledge-based	O
Processors	O
(	O
KBP	O
)	O
but	O
were	O
essentially	O
CAM	B-Data_Structure
with	O
specialized	O
interfaces	O
and	O
features	O
optimized	O
for	O
networking	O
.	O
</s>
<s>
To	O
achieve	O
a	O
different	O
balance	O
between	O
speed	O
,	O
memory	O
size	O
and	O
cost	O
,	O
some	O
implementations	O
emulate	O
the	O
function	O
of	O
CAM	B-Data_Structure
by	O
using	O
standard	O
tree	O
search	O
or	O
hashing	O
designs	O
in	O
hardware	O
,	O
using	O
hardware	O
tricks	O
like	O
replication	O
or	O
pipelining	O
to	O
speed	O
up	O
effective	O
performance	O
.	O
</s>
<s>
These	O
designs	O
are	O
often	O
used	O
in	O
routers	B-Protocol
.	O
</s>
<s>
The	O
Lulea	B-Protocol
algorithm	I-Protocol
is	O
an	O
efficient	O
implementation	O
for	O
longest	B-Protocol
prefix	I-Protocol
match	I-Protocol
searches	O
as	O
required	O
in	O
internet	O
routing	B-Protocol
tables	I-Protocol
.	O
</s>
<s>
Binary	O
CAM	B-Data_Structure
is	O
the	O
simplest	O
type	O
of	O
CAM	B-Data_Structure
and	O
uses	O
data	O
search	O
words	O
consisting	O
entirely	O
of	O
1s	O
and	O
0s	O
.	O
</s>
<s>
Ternary	O
CAM	B-Data_Structure
(	O
TCAM	O
)	O
allows	O
a	O
third	B-Language
matching	I-Language
state	I-Language
of	O
X	O
or	O
do	O
n't	O
care	O
for	O
one	O
or	O
more	O
bits	O
in	O
the	O
stored	O
word	O
,	O
thus	O
adding	O
flexibility	O
to	O
the	O
search	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
stored	O
word	O
of	O
"	O
10XX0	O
"	O
in	O
a	O
ternary	O
CAM	B-Data_Structure
will	O
match	O
any	O
of	O
the	O
four	O
search	O
words	O
"	O
10000	O
"	O
,	O
"	O
10010	O
"	O
,	O
"	O
10100	O
"	O
,	O
or	O
"	O
10110	O
"	O
.	O
</s>
<s>
The	O
added	O
search	O
flexibility	O
comes	O
at	O
an	O
additional	O
cost	O
over	O
binary	O
CAM	B-Data_Structure
as	O
the	O
internal	O
memory	O
cell	O
must	O
now	O
encode	O
three	O
possible	O
states	O
instead	O
of	O
the	O
two	O
for	O
the	O
binary	O
CAM	B-Data_Structure
.	O
</s>
<s>
Content-addressable	B-Data_Structure
memory	I-Data_Structure
is	O
often	O
used	O
in	O
computer	B-Device
networking	I-Device
devices	I-Device
.	O
</s>
<s>
For	O
example	O
,	O
when	O
a	O
network	B-Protocol
switch	I-Protocol
receives	O
a	O
data	B-Protocol
frame	I-Protocol
from	O
one	O
of	O
its	O
ports	O
,	O
it	O
updates	O
an	O
internal	O
table	O
with	O
the	O
frame	O
's	O
source	O
MAC	O
address	O
and	O
the	O
port	O
it	O
was	O
received	O
on	O
.	O
</s>
<s>
The	O
MAC	O
address	O
table	O
is	O
usually	O
implemented	O
with	O
a	O
binary	O
CAM	B-Data_Structure
so	O
the	O
destination	O
port	O
can	O
be	O
found	O
very	O
quickly	O
,	O
reducing	O
the	O
switch	O
's	O
latency	O
.	O
</s>
<s>
Ternary	O
CAMs	B-Data_Structure
are	O
often	O
used	O
in	O
network	B-Protocol
routers	I-Protocol
,	O
where	O
each	O
address	O
has	O
two	O
parts	O
:	O
the	O
network	O
prefix	O
,	O
which	O
can	O
vary	O
in	O
size	O
depending	O
on	O
the	O
subnet	B-Protocol
configuration	O
,	O
and	O
the	O
host	O
address	O
,	O
which	O
occupies	O
the	O
remaining	O
bits	O
.	O
</s>
<s>
Each	O
subnet	B-Protocol
has	O
a	O
network	O
mask	O
that	O
specifies	O
which	O
bits	O
of	O
the	O
address	O
are	O
the	O
network	O
prefix	O
and	O
which	O
bits	O
are	O
the	O
host	O
address	O
.	O
</s>
<s>
Routing	B-Protocol
is	O
done	O
by	O
consulting	O
a	O
routing	B-Protocol
table	I-Protocol
maintained	O
by	O
the	O
router	B-Protocol
which	O
contains	O
each	O
known	O
destination	O
network	O
prefix	O
,	O
the	O
associated	O
network	O
mask	O
,	O
and	O
the	O
information	O
needed	O
to	O
route	O
packets	O
to	O
that	O
destination	O
.	O
</s>
<s>
In	O
a	O
simple	O
software	O
implementation	O
,	O
the	O
router	B-Protocol
compares	O
the	O
destination	O
address	O
of	O
the	O
packet	O
to	O
be	O
routed	B-Protocol
with	O
each	O
entry	O
in	O
the	O
routing	B-Protocol
table	I-Protocol
,	O
performing	O
a	O
bitwise	O
AND	O
with	O
the	O
network	O
mask	O
and	O
comparing	O
it	O
with	O
the	O
network	O
prefix	O
.	O
</s>
<s>
If	O
they	O
are	O
equal	O
,	O
the	O
corresponding	O
routing	B-Protocol
information	I-Protocol
is	O
used	O
to	O
forward	O
the	O
packet	O
.	O
</s>
<s>
Using	O
a	O
ternary	O
CAM	B-Data_Structure
for	O
the	O
routing	B-Protocol
table	I-Protocol
makes	O
the	O
lookup	O
process	O
very	O
efficient	O
.	O
</s>
<s>
The	O
addresses	O
are	O
stored	O
using	O
do	O
n't	O
care	O
for	O
the	O
host	O
part	O
of	O
the	O
address	O
,	O
so	O
looking	O
up	O
the	O
destination	O
address	O
in	O
the	O
CAM	B-Data_Structure
immediately	O
retrieves	O
the	O
correct	O
routing	B-Protocol
entry	O
;	O
both	O
the	O
masking	O
and	O
comparison	O
are	O
done	O
by	O
the	O
CAM	B-Data_Structure
hardware	O
.	O
</s>
<s>
This	O
works	O
if	O
(	O
a	O
)	O
the	O
entries	O
are	O
stored	O
in	O
order	O
of	O
decreasing	O
network	O
mask	O
length	O
,	O
and	O
(	O
b	O
)	O
the	O
hardware	O
returns	O
only	O
the	O
first	O
matching	O
entry	O
;	O
thus	O
,	O
the	O
match	O
with	O
the	O
longest	O
network	O
mask	O
(	O
longest	B-Protocol
prefix	I-Protocol
match	I-Protocol
)	O
is	O
used	O
.	O
</s>
<s>
Other	O
CAM	B-Data_Structure
applications	O
include	O
:	O
</s>
<s>
Several	O
custom	O
computers	O
,	O
like	O
the	O
Goodyear	O
STARAN	B-Device
,	O
were	O
built	O
to	O
implement	O
CAM	B-Data_Structure
.	O
</s>
