Understanding the INIT attribute for LUTs
Every Look-Up Table (LUT) implements a Boolean logic equation which is defined by the INIT attribute attached to it. When we wish to implement LUTs directly rather than allowing the synthesis tool to infer them, we must have an understanding of how the INIT attribute and the implemented logic function are related.
Figure 1: LUT configurations for the UltraScale family
Truth-table to INIT
If we express the logic function as a truth-table, it is easy to then extract the INIT attribute. Suppose that the function we want to
implement in a LUT4 is as follows:
O = I3.I1 + I2.I0 + I1.I0
We can write this as a truth-table and then by grouping the output bits
into hex characters we can obtain the INIT attribute:
I3 | I2 | I1 | I0 | O | INIT |
0 | 0 | 0 | 0 | 0 | 8 |
0 | 0 | 0 | 1 | 0 | |
0 | 0 | 1 | 0 | 0 | |
0 | 0 | 1 | 1 | 1 | |
0 | 1 | 0 | 0 | 0 | A |
0 | 1 | 0 | 1 | 1 | |
0 | 1 | 1 | 0 | 0 | |
0 | 1 | 1 | 1 | 1 | |
1 | 0 | 0 | 0 | 0 | C |
1 | 0 | 0 | 1 | 0 | |
1 | 0 | 1 | 0 | 1 | |
1 | 0 | 1 | 1 | 1 | |
1 | 1 | 0 | 0 | 0 | E |
1 | 1 | 0 | 1 | 1 | |
1 | 1 | 1 | 0 | 1 | |
1 | 1 | 1 | 1 | 1 |
To obtain the INIT attribute, we read the output states in groups of 4 from the bottom up and convert them into hex characters. The first four bits (marked in blue in the table) are 1110, so the first hex character of the INIT attribute is "E". We can see that the next four bits (marked in red) are 1100, so the next character in the INIT attribute is "C". The complete INIT attribute is ECA8.
Applying INIT in VHDL source files
The easiest way to set the INIT attribute is by applying a generic to the instantiated LUT:
- i_lut : lut4
-   generic map(
-    init => x"eca8")
-   port map(
-    i0 => i0,
-    i1 => i1,
-    i2 => i2,
-    i3 => i3,
-    o  => o );
Checking LUT contents with Vivado
The Vivado development environment can display the contents of a LUT a hexadecimal INIT string, truth-table and boolean logic equation. Just click on a LUT in any one of the Vivado windows such as schematic or netlist, then open the properties window:
Figure 2: LUT contents displayed in Vivado as INIT string, truth-table and equation
The LUT contents can also be modified using the Edit LUT Equation button or by a tcl command in the XDC file, for example:
- set_property INIT 16'hECA8 [get_cells i_LUT]