HLS kernel block supports importing a templatized function as a block into Vitis Model Composer. Consider the HLS kernel with function template as depicted in the following code.
template <typename T, int C>
void my_add_temp(hls::stream<T> & in1, hls::stream<T> & in2, hls::stream<T> & out)
{
T a, b, c;
a = in1.read();
b = in2.read();
c = a + b * C;
out.write(c);
}
After configuring the port directionalities and clicking Build as explained in the previous section, the following dialog box opens for setting the template values.
Figure 1. Block Parameters Dialog Box
You can enter the template values in the Function Template Parameters section, click Apply then click OK. This generates the HLS Kernel block with all the ports in the interface.