3.5.2.3 Function Pipelining
(Ask a Question)Similar to loop pipelining, when a function is specified to be pipelined, SmartHLS™ will automatically in-line all of its descendant functions, and unroll all loops (in the specified function as well as in all of its descendant functions). This is done to create a high-performance pipelined hardware. A function can be specified to be pipelined using the pragma #pragma HLS function pipeline
(see Pipeline Function ). Consider the following call graph:
where function c
contains a loop. If function a
is specified as the top-level function and to be function pipelined, functions c
and d
, which are descendant functions of a
will be automatically inlined (c
will not be inlined into b
).
When SmartHLS runs, it will print out the following:
Info: Adding no_inline attribute to the user-specified function: a
Info: Inlining function 'c' into its parent function 'a' for pipelining.
Info: Inlining function 'd' into its parent function 'a' for pipelining.
Info: Unrolling the entire loop nest on line 22 of function_pipeline.c.
This loop nest is inside function 'a', which is specified to be pipelined.
Info: Pipelining function 'a' on line 15 of function_pipeline.c.
It shows that SmartHLS first adds the no_inline
attribute to function a
to prevent it from being inlined. Then it inlines its descendant functions and unrolls their loops.
Care must be taken though, if the function designated to be pipelined has many descendant functions, which also has many loops, the hardware area can increase significantly (as was described above for Loop Pipelining). For instance, in the call graph shown above, if main
is specified to be pipelined, functions a
, b
, c
, and d
will be automatically inlined. There will be two copies of c
, as the function is called from two different places. As there is also a loop in c
that will be completely unrolled (in each copy of c
), this can increase the area significantly. Hence for function pipelining, one should examine the program before pipelining a function that has many descendant functions or loops.