3.6.3.35 SHLS-82
(Ask a Question)Message
Error: (SHLS-82) The top-level function '{function}' can only be called from software testbench.
/***************************************************************** * This example is expected to result in * - Code : SHLS-82 * - Type : Error * - Cause : As a top-level function, DUT_1() is invoked from * hardware code within DUT_2(). *****************************************************************/ int DUT_1(int a, int b) { #pragma HLS function top return a * b; } int DUT_2(int a, int b, int c) { #pragma HLS function top /* a * a + b * c */ return DUT_1(a, a) + DUT_1(b, c); } int main() { int r1 = DUT_1(1, 2); int r2 = DUT_2(3, 4, 5); return (r1 != 1*2) || (r2 != 3*3 + 4*5); }
In an input design, a top-level function cannot be invoked by hardware design code within the same design. To comply with this rule while maintaining code reusability, users are advised to extract the shared core functionality into a separate function. This new function can then be accessed by both the hardware code and the top-level function from which it was derived. For example, the code above can be refactored as follows:
int DUT_1_core(int a, int b) { return a * b; } int DUT_1(int a, int b) { #pragma HLS function top return DUT_1_core(a, b); } int DUT_2(int a, int b, int c) { #pragma HLS function top /* a * a + b * c */ return DUT_1_core(a, a) + DUT_1_core(b, c); } int main() { int r1 = DUT_1(1, 2); int r2 = DUT_2(3, 4, 5); return (r1 != 1*2) || (r2 != 3*3 + 4*5); }
