HLS4ML/vivado HLS 报错解决方案

用HLS4ML到 hls_model.build()的时候报错
报错内容

/opt/Xilinx/Vivado/2019.1/include/mpfr.h:724:28: error: ‘mpfr_srcptr’ was not declared in this scope
 __MPFR_DECLSPEC int    mpfr_custom_get_kind   _MPFR_PROTO ((mpfr_srcptr));
                            ^~~~~~~~~~~
make: *** [obj/myproject.cpp_pre.cpp.tb.o] Error 1
ERROR: [COSIM 212-317] C++ compile error.
ERROR: [COSIM 212-321] EXE file generate failed.
ERROR: [COSIM 212-321] EXE file generate failed.
ERROR: [COSIM 212-331] Aborting co-simulation: C simulation failed, compilation errors.
ERROR: [COSIM 212-5] *** C/RTL co-simulation file generation failed. ***
ERROR: [COSIM 212-4] *** C/RTL co-simulation finished: FAIL ***
command 'ap_source' returned error code
    while executing
"source build_prj.tcl"
    ("uplevel" body line 1)
    invoked from within
"uplevel \#0 [list source $arg] "

INFO: [HLS 200-112] Total elapsed time: 578.3 seconds; peak allocated memory: 1.226 GB.
INFO: [Common 17-206] Exiting vivado_hls at Tue Dec 14 15:45:32 2021...
child process exited 

原因是因为GCC文件冲突,这里用的是vivado2019.2
解决方案:

  1. /tools/Xilinx/Vivado/2019.2/include/mpfr.h 中系统导入头文件<gmp.h> 改为当前文件夹导入”gmp.h“
#ifndef __GMP_H__
#include "gmp.h"
#endif
  1. 在每个源文件(main.cpp和test.cpp,主文件路径在my-hls-test/fireware/myproject.cpp,test文件在my-hls-test/fmyproject_test.cpp)头顶添加下面语句,这句话添加的位置靠前点儿
#include "/tools/Xilinx/Vivado/2019.2/include/gmp.h"
#define __gmp_const const

这个bug需要在每次生成my-hls-test文件夹之后手动修改cpp文件,因此不能在python文件中直接用hls_model.build(),需要命令行输入
hls4ml build -p my-hls-test -a

参考:

  1. https://chhzh123.github.io/blogs/2020-03-11-vivado-hls/
  2. https://support.xilinx.com/s/question/0D52E00006iHkfpSAC/vivado-20153-hls-bug-gmph?language=en_US
  3. https://github.com/fastmachinelearning/hls4ml/issues/473
  4. https://fastmachinelearning.org/hls4ml/command.html
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值