Electronic – How are LUTs in a FPGA filled

digital-logicfpgatruth-table

I know there have been a lot of questions about lookup tables and their design, but even after reading them and scouring the web, I still don't quite understand how the LUTs are filled with corresponding boolean function's outputs from SRAM.

What is an LUT in FPGA?

The top answer to that question mentions something about using LUT masks. Are LUT masks the key to filling LUTs based on the boolean function from SRAM? Could someone elaborate on LUT masks please?

Also, say we have a 4 input LUT. That means we have 16 outputs, and 65535 possible combinations of outputs (0000000000000000 to 11111111111111). Does that mean all 65535 combinations will be stored in SRAM? And if we had 6 input the number would jump by a lot, and it doesn't seem like all that could be stored in RAM?

I think I may be misunderstanding something fundamental about FPGAs/LUTs horrifically. Any insight would be helpful!

Best Answer

There are indeed 64k possible combinations for the bits in the LUT but since there are only 4 bits to address the LUT (assuming it is organized for 4 input 1 output) you only need to store 16 1 bit values. Which particular ones are stored depend upon the particular expression you have defined in your HDL.

A common usage of a LUT would be used to define a 4 input 1 output expression.

If for example the LUT is defined to output the AND function of the 4 input bits the first 15 locations would be set to zero with the 16th set to 1. The LUT would only output a 1 if all 4 input bits are a '1'.