Intel® High Level Synthesis Compiler Pro Edition: Reference Manual
A newer version of this document is available. Customers should click here to go to the newest version.
Visible to Intel only — GUID: usx1551295204803
Ixiasoft
Visible to Intel only — GUID: usx1551295204803
Ixiasoft
3.3.1. Templated Functions
Templated Functions as an HLS Component
When you create a template function, you must declare the instantiation of the function to synthesize into hardware.
template <typename T, int MULT> T multadd (T a, T b) { return MULT * (a + b); }
template component int multadd<int, 5>(int a, int b);
This declaration combined with the earlier template definition marks the int variant with MULT=5 of the multiadd function to be generated into a component. This component can now be invoked from the testbench.
Templated Functions as an HLS Task
If you want to use the function as a task in a system of tasks, use the ihc::launch and ihc::collect calls as shown in the following example:
component void foo () { int a, b; ihc::launch<multadd<int, 5>> (a, b); int res = ihc::collect<multadd<int, 5>>(); }