AR# 54135

Vivado HLS 2012: Why the top-level function cannot be a template, by example

Description

Why can the top-level function not be a template?

Solution

With the current release of the VHLS tools, everything needs to be static at compile time.

 

Taking as an example, a templated FIR filter:

template<TAPS_number, type> fir (type new_input) {core}

 

This cannot be a top level function.

However, the following would be a valid top level:

 

int top_type1(int x) {

   return fir<2,int>(x);

}

 

double top_type2(double x) {

   return fir<10000,double>(x);

}

 

It should be clear that top_type1 and top_type2 would be very different in size and performance.


As shown in this example, the tool cannot be expected to generate both top_type1 and top_type2 or any other combination on demand.

 

AR# 54135
Date 03/25/2015
Status Active
Type General Article
Tools