Xilinx / finn-hlslib

Vitis HLS Library for FINN

Home Page:https://xilinx.github.io/finn/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vivado_hls version for testbench

tunghoang290780 opened this issue · comments

Hi,

What vivado_hls version is used for testing the code?

/T

Hi,

currently we use vivado_hls 2020.1, but it has been tested also with previous versions.

@giuliogamba I used vivado_hls 2020.1 and tried to run a simple test "vivado_hls -f test_add.tcl". However, I got a lot of compilation error as below (I have succeeded with examples shipped with vivado hls installation)
Do you have any idea for these errors?

ERROR: [SYNCHK 200-11] Global Variable 'std::cout' has an unsynthesizable struct type '%"class.std::basic_ostream.13.51.75" = type { i32 (...)**, %...' (a member pointer to struct itself).
ERROR: [SYNCHK 200-11] add_top.cpp:12: Argument 'in1' of function 'Testbench_add' (add_top.cpp:12) has an unsynthesizable type (possible cause(s): structure variable cannot be decomposed due to (1) unsupported type conversion; (2) memory copy operation; (3) function pointer used in struct; (4) unsupported pointer comparison).
ERROR: [SYNCHK 200-11] /xilinx/Vivado/2020.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_deque.h:248: Argument 'this' has an unsynthesizable type '%"class.hls::stream.25.61.85" = type { i32 (...)**, %"class....' (possible cause(s): pointer to pointer or global pointer).
ERROR: [SYNCHK 200-42] /xilinx/Vivado/2020.1/lnx64/tools/gcc/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_deque.h:248: pointer comparison is not supported.
ERROR: [SYNCHK 200-71] /xilinx_dnn/finn-hlslib/streamtools.h:677: function 'std::basic_ostream<char, FORWARD_REFERENCE>& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, FORWARD_REFERENCE>&, char const*)' has no function body.

Which OS are you using? Is the test_add.tcl the only one failing, or all the tests fail?

Hi @giuliogamba

I used Ubuntu 16.04.4 LTS, and all the tests fail with similar errors.

There must be a problem with your installation, I'm not able to replicate this on my machine (everything works here). Can you try re-installing Vivado HLS? Please also upload the complete vivado_hls.log file here for further investigation.

Hi @giuliogamba

Perhaps, I should start from the root cause. When I run "original" test_add.tcl, I had compilation error with mfpr.h header file. I guess gcc search that file in the /usr/include/mpfr.h instead of using one provided by Vivado
original_add_vivado_hls.log

Then I modified test_add.tcl to search Vivado's header files as below. Then I ended up with errors shown in add_vivado_hls.log

# New code
set VIVADO_HLS_INC  "/home/hoangt/TOOLS/xilinx/Vitis/2020.1/include"
add_files add_top.cpp -cflags "-std=c++0x -I$VIVADO_HLS_INC -I$::env(FINN_HLS_ROOT) -I$::env(FINN_HLS_ROOT)/tb" 
add_files -tb add_tb.cpp -cflags "-std=c++0x -I$VIVADO_HLS_INC -I$::env(FINN_HLS_ROOT) -I$::env(FINN_HLS_ROOT)/tb" 

# Old code
#add_files add_top.cpp -cflags "-std=c++0x -I$::env(FINN_HLS_ROOT) -I$::env(FINN_HLS_ROOT)/tb"
#add_files -tb add_tb.cpp -cflags "-std=c++0x -I$::env(FINN_HLS_ROOT) -I$::env(FINN_HLS_ROOT)/tb"

add_vivado_hls.log
2dconv_vivado_hls.log

I attache two log files. One is for test_add (failed) and the other one for 2dconv (passed). 2dconv is a reference example that we can find in Vivado installation folder (i.e. /xilinx/Vivado/2020.1/examples/design/2D_convolution_with_linebuffer)

Hi,

can you try the workaround suggested here instead?
As you can see with the original code, synthesis actually worked, while cosim failed. The mfpr.h as reported in the forum is affecting only the cosimulation.

@giuliogamba thanks for the reference. I have fixed the issue and want to document here if someone would face this later

Below is what I changed in the mpfr.h header file of Vivado to take its own gmp.h (surprisingly when looking into your link, this bug has existed in many Vivado versions )

/* Check if GMP is included, and try to include it (Works with local GMP) */
#ifndef __GMP_H__
  #include <gmp.h>
#else
  #include "/home/hoangt/TOOLS/xilinx/Vivado/2020.1/include/gmp.h"
  #ifndef __gmp_const
    #define __gmp_const const
  #endif
#endif

Thanks @tunghoang290780 for providing a solution!