CAM the hard way or how to compare against thousands of bits?
Guys,
I don't have a lot of experience with FPGAs and so I turn to you my friends for an advice. The circuit I am aiming to create is relative simple, but I am not sure about what is the right way to do it.
The module should get data off of the Avalon-MM FIFO, 32-bit wide. Let's think in software terms and call those 32-bits an unsigned integer. That integer must be compared against a pre-configured list of numbers, approx. 5000 of them (5K * 32 bits = 19.53125 kilobytes). The output should be two things:
1) A signal that is positive if there was a match, or negative otherwise.
2) If the output is positive, the offset of the matching register (i.e. register address) should be stored in [31:0] register value.
(of course there will also be a simple reset logic)
I am thinking to use on-chip memory as 19KByte doesn't seem like a big deal, and create a module where a number of 32-bit registers will be a parameter. Those registers will be exported to a on-chip CPU, where software would write some data into it (HAL + uCOS).
Does this sound as a good idea thus far? Now, I can think about two ways to go from here to compare that number against value in registers:
Way #1, something like:
[code]
for (i = 0; i < MAX_REGS_PARAMETER; ++i)
begin
if (input_data[31:0] == reg[31 + (i * ...)i * ...)])
output_signal <= 1'b1;
end
[code]
...
Way #2, generated combinatorial:
[code]
assign output_signal = (input_data[31:0] == reg1[31:0]) || (input_data[31:0] == reg2[31:00]) ....
[code]
I am not sure about how that code will synthesize and how big of a delay this comparison will introduce. Will that comparison take long and does it make sense to pipeline or no?
Which way do you think is better and why? Or is there any other way to do a thing like that? How would you do it? Your help is very much appreciated.
Thank you very much,
V.