当前位置:   article > 正文

HLS笔记——复数complex类型数据在2018.2版本无法赋值,error:passing 'const _Tp {aka const ap_int<16>}' as 'this' argumen___gmp_libgmp_dll" redefined

__gmp_libgmp_dll" redefined

1、问题描述

在HLS中使用c++编写程序,使用到了复数complex类型,综合没问题,在C仿真时对复数赋值的地方报错。
(1)top.h

#ifndef __TOP_H
#define __TOP_H

#include <iostream>
#include <complex>
#include <ap_int.h>
#include <ap_fixed.h>

using namespace std;

typedef ap_int<16> int16;
typedef ap_fixed<16,1> fixed16;

typedef std::complex<int16> cint16;
typedef std::complex<fixed16> cfixed16;

void test(cint16 *a,cint16 b);

#endif
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

(2)top.cpp

#include "top.h"

void test(cint16 *a,cint16 b)
{
	a->real() = 1;
	a->imag() = 0;

	b.real() = 2;
	b.imag() = 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

(3)top_test.cpp

#include "top.h"

int main()
{
	cint16 *a,b;

	test(a,b);

	cout<<a->real()<<endl;
	cout<<a->imag()<<endl;

	cout<<b.real()<<endl;
	cout<<b.imag()<<endl;

	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

报警信息:
warning: “__GMP_LIBGMP_DLL” redefined
#define __GMP_LIBGMP_DLL 0
warning: “__GMP_LIBGMP_DLL” redefined
#define __GMP_LIBGMP_DLL 1

错误信息:
error:passing ‘const _Tp {aka const ap_int<16>}’ as ‘this’ argument discards qualifiers [-fpermissive]

2、错误排查
(1)多处警告
网上答案一般说是版本问题,暂时不影响,没找到解决方法,排除了遇到的错误指挥发现也没这些警告了,所以继续往下看错误。
(2)C++的this问题
在这里插入图片描述
在这里插入图片描述
大概的意思是说C++里面现在的复数对象是const,不能修改(大概这样理解,具体我不太熟悉C++),此时对比了一下Vivado HLS 2016.2和2018.2的不同。

complex类型在Vivado HLS 2016.2中默认索引到头文件(记为complex_1,右键到定义会打开),而在2018.2中是索引到<ap_int_special.h>和<ap_fixed_special.h>,而这两个文件里面又引用了文件(记为complex_2)。
在2016.2中,如图,对复数complex类型的操作会直接索引到文件,该文件中的操作符“=”函数后面直接是函数体(大括号“{}”包含的),而对比2018.2:
在这里插入图片描述
在2018.2中,对复数complex的操作会索引到<ap_int_special.h>文件中,这里的对于复数的操作后面加了const修饰,猜测是这部分的const修饰导致无法改变数据,发生C++报有关“this”的错误。
在这里插入图片描述
typedef ap_int<16> int16;
typedef ap_fixed<16,1> fixed16;

typedef std::complex cint16;
typedef std::complex cfixed16;

上述,对cint16将会索引到<ap_int_special.h>,对cfixed16会索引到<ap_fixed_special.h>文件,将这两个头文件中的const全部删除之后,对复数的赋值和其他运算不会报错了。

注意,经过试验,在计算机 A 上的工程 X1 上修改后:
(1)在计算机A上的X2工程无需修改,新建工程时也会默认索引到修改后的头文件;
(2)当将X1拷贝到计算机B上时,若B没改过头文件,则仍会出现错误,需要再次修改B;

以上仅供参考,修改后成功运行C仿真、C-RTL联合仿真并打包IP,测试后发现数据正确,目前没有发现哪里出了问题,但是感觉这样直接改库不太安全,如果有其他方法的希望能告知,感谢!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/425747
推荐阅读
相关标签
  

闽ICP备14008679号