A CAM system is provided for determining which data word in a CAM array
exhibits the longest continuous, unmasked match with an input data value.
The input data value is divided into non-overlapping subfields, thereby
creating a series of keys, the first key of the series including either
the least significant bit (LSB) or most significant bit (MSB) of the
input data value. The CAM array is divided along columns into a similar
series of non-overlapping sub-arrays corresponding to the subfields
defined by the series of keys. A first CAM sub-array compares the first
key with its stored rows of data bit values to generate a first match
signal. The first match signal disables each row of the second CAM
sub-array for which the corresponding row of the first CAM sub-array did
not show a match. A second CAM sub-array then compares the second key
with its enabled rows to generate a second match signal. The second match
signal disables each row of the third CAM sub-array for which the
corresponding row of either the first or second CAM sub-array did not
show a match. This comparison process continues in sequence with the
remaining keys and CAM sub-arrays. The row of the CAM array that shows a
match over the most consecutive comparison operations contains the
longest match for the input data value. If multiple rows match over the
same number of comparison operations, a priority encoder determines which
location has the highest priority.