Undefined reference to function with Vitis HLS 2020.2

Hello,

I am trying to create an accelerator for a specific algorithm using Vitis HLS. I wrote the code and I wanted to run a C_simulation. But, I always got “undefined reference” to the function that I am calling in the Testbench. Please See the code attached and the console log below.

Starting C simulation ...
D:/Xilinx/Vitis_HLS/2020.2/bin/vitis_hls.bat C:/Users/anoir/Desktop/CG_accelerator/CG/solution1/csim.tcl
INFO: [HLS 200-10] Running 'D:/Xilinx/Vitis_HLS/2020.2/bin/unwrapped/win64.o/vitis_hls.exe'
INFO: [HLS 200-10] For user 'anoir' on host 'desktop-9nntrgt' (Windows NT_amd64 version 6.2) on Mon Jul 05 15:12:25 +0200 2021
INFO: [HLS 200-10] In directory 'C:/Users/anoir/Desktop/CG_accelerator'
Sourcing Tcl script 'C:/Users/anoir/Desktop/CG_accelerator/CG/solution1/csim.tcl'
INFO: [HLS 200-1510] Running: open_project CG
INFO: [HLS 200-10] Opening project 'C:/Users/anoir/Desktop/CG_accelerator/CG'.
INFO: [HLS 200-1510] Running: set_top kernel_cg
INFO: [HLS 200-1510] Running: add_files CG/cg.cpp
INFO: [HLS 200-10] Adding design file 'CG/cg.cpp' to the project
INFO: [HLS 200-1510] Running: add_files CG/cg.h
INFO: [HLS 200-10] Adding design file 'CG/cg.h' to the project
INFO: [HLS 200-1510] Running: add_files -tb CG/cg_tb.cpp -cflags -Wno-unknown-pragmas -csimflags -Wno-unknown-pragmas
INFO: [HLS 200-10] Adding test bench file 'CG/cg_tb.cpp' to the project
INFO: [HLS 200-1510] Running: open_solution solution1 -flow_target vivado
INFO: [HLS 200-10] Opening solution 'C:/Users/anoir/Desktop/CG_accelerator/CG/solution1'.
INFO: [SYN 201-201] Setting up clock 'default' with a period of 10ns.
INFO: [SYN 201-201] Setting up clock 'default' with an uncertainty of 0.5ns.
INFO: [HLS 200-10] Setting target device to 'xczu7ev-ffvc1156-2-e'
INFO: [HLS 200-1505] Using flow_target 'vivado'
Resolution: For help on HLS 200-1505 see www.xilinx.com/cgi-bin/docs/rdoc?v=2020.2;t=hls+guidance;d=200-1505.html
INFO: [HLS 200-1510] Running: set_part xczu7ev-ffvc1156-2-e
INFO: [HLS 200-1510] Running: create_clock -period 10 -name default
INFO: [HLS 200-1510] Running: set_clock_uncertainty 0.5
INFO: [HLS 200-1510] Running: csim_design -setup -clean -quiet
INFO: [SIM 211-2] *************** CSIM start ***************
INFO: [SIM 211-4] CSIM will launch GCC as the compiler.
Compiling ../../../cg_tb.cpp in debug mode
Compiling ../../../cg.cpp in debug mode
Generating csim.exe
Makefile.rules:392: recipe for target 'csim.exe' failed
obj/cg_tb.o: In function `main':
C:\Users\anoir\Desktop\CG_accelerator\CG\solution1\csim\build/../../../cg_tb.cpp:14: undefined reference to `void kernel_cg<float>(float (*) [2], float*, float, int, float*)'
collect2.exe: error: ld returned 1 exit status
make: *** [csim.exe] Error 1
ERROR: [SIM 211-100] CSim file generation failed: compilation error(s).

Did I miss something somehow?

Thank you in advance.
cg.cpp (1.6 KB)
cg.h (139 Bytes)
cg_tb.cpp (307 Bytes)

1 Like

Hi @anoir_nechi,

This is not a PYNQ specific question. It may be better if you seek support in the Xilinx forums
https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/bd-p/hls

Mario

I already posted the issue there. However, no one is answering.
My apologies

No need to apologise. In that case, can you provide the link to the question?

I see that you define the templated kernel, but do not provide any instance of the kernel with the right type. For instance,

kernel_cg<int>(A_, b_, tolerance, max_iteration, X_)

Thank you so much Mario for the assistance.
Please find attached the link for the Topic:
https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/Undefined-reference-to-function-with-Vitis-HLS-2020-2/m-p/1260618