A method and apparatus for operating a content addressable memory (CAM)
and a ternary CAM (TCAM) are described including an encoding circuit for
encoding an incoming CAM or TCAM word to produce an encoded CAM or TCAM
word such that a one-bit mismatch between a comparand and the incoming
CAM or TCAM word results in at least a M-bit mismatch between said
encoded CAM or TCAM word and a similarly encoded comparand, a circuit for
precharging a match line to a predetermined state before a comparison
between the encoded CAM or TCAM word and said similarly encoded comparand
and a memory storage location for storing the encoded CAM or TCAM word.