Any ideas on how to implement CAM and TCAM using SystemVerilog?
I understand CAM can be implemented using associative arrays, and data can be used as an index to find the address location.
Any ideas on how to implement CAM and TCAM using SystemVerilog?
I understand CAM can be implemented using associative arrays, and data can be used as an index to find the address location.
In reply to n347:
You can use the find_index() method. See section 7.12.1 Array locator methods in the IEEE 1800-2017 SystemVerilog LRM. For a TCAM, see 11.4.6 Wildcard equality operators to implement the ternary search.
In reply to n347:
module top;
bit [7:0] array[] = {'hF7,'hE6,'hE5,'hF4,'h03,'hE2,'hF1,'hE0};
int found[$];
initial begin
found = array.find_index() with (item ==? 'hE?);
foreach (found[index]) $display("array[%0d] = %h",found[index],array[found[index]]);
end
endmodul
e