TCAM (ternary content addressable memory) is used to make a pattern match between the search key and a masked key within a table. The per-entry mask represents a wildcard pattern of bits used when performing the comparison. The entries of the table are ordered by priority. The stored associated value for the matched entry with highest priority is returned as well as an indication of a match. This CAM uses internal URAM or BRAM to store data. There are limits for the number of URAMs and BRAMs that can be used at higher frequencies. See Ternary CAM Search LogiCORE IP Product Guide (PG318), Tables 2 and 7 for parameter limits, and NUM_ENTRIES in Chapter 5, Design Flow Steps for more information on these limits.
- Key width: up to 992 bits
- Although the key width can be up to 992 bits, there are further restrictions on the ternary match kind fields. The use of the ternary match kind greatly increases the 'Complexity' calculation and thus degrades the software performance (see Ternary CAM Search LogiCORE IP Product Guide (PG318) for more information). It is therefore recommended to only use the ternary match kind where necessary. A STCAM can often be used instead.
- Response width: up to 1024 bits
- Hit/miss flag: Yes
- Size: up to 32k
Here is an example of how to instantiate a TCAM in a P4 file:
table forwardIPv4 {
key = { hdr.ipv4.flags : ternary;
hdr.ipv4.version : ternary;
hdr.ipv4.offset : ternary;
hdr.ipv4.hdr_len : ternary;
hdr.ipv4.src : exact; }
actions = { forwardPacket;
dropPacket; }
size = 1024;
default_action = dropPacket;
}
For more details on how the compiler selects a TCAM, see the Compiler Table Selection section of this chapter. See Ternary CAM Search LogiCORE IP Product Guide (PG318) for more information on TCAMs.