在vivado hls 2018.3中使用xfopencv时出现错误:INFO:
E:/vivado_hls/xfopencv/xfopencv/include/common/xf_axi_sdata.h:43:10: error: previous definition of ‘struct ap_axis<D, U, TI, TD>’
struct ap_axis{
E:/vivado_hls/xfopencv/xfopencv/include/common/xf_axi_sdata.h:54:10: error: previous definition of ‘struct ap_axiu<D, U, TI, TD>’
struct ap_axiu{
前言
在vivado hls 2018.3中使用xfopencv
一、错误的原因
咨询了大佬,大佬说是因为头文件重复引用,但是我检查所有的头文件并没有重复引用。然后在网上找相关的解决方法,终于找到一篇类似的传送门,
在HLS中查看头文件,发现有这个文件:ap_axi_sdata.h
其中的内容为:
/*****************************************************************************
*
* Author: Xilinx, Inc.
*
* This text contains proprietary, confidential information of
* Xilinx, Inc. , is distributed by under license from Xilinx,
* Inc., and may be used, copied and/or disclosed only pursuant to
* the terms of a valid license agreement with Xilinx, Inc.
*
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
* AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
* SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
* OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
* APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
* THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
* AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
* FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
* WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
* IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
* REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
* INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* Xilinx products are not intended for use in life support appliances,
* devices, or systems. Use in such applications is expressly prohibited.
*
#- (c) Copyright 2011-2018 Xilinx, Inc. All rights reserved.
#-
#- This file contains confidential and proprietary information
#- of Xilinx, Inc. and is protected under U.S. and
#- international copyright and other intellectual property
#- laws.
#-
#- DISCLAIMER
#- This disclaimer is not a license and does not grant any
#- rights to the materials distributed herewith. Except as
#- otherwise provided in a valid license issued to you by
#- Xilinx, and to the maximum extent permitted by applicable
#- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
#- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
#- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
#- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
#- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
#- (2) Xilinx shall not be liable (whether in contract or tort,
#- including negligence, or under any other theory of
#- liability) for any loss or damage of any kind or nature
#- related to, arising under or in connection with these
#- materials, including for any direct, or any indirect,
#- special, incidental, or consequential loss or damage
#- (including loss of data, profits, goodwill, or any type of
#- loss or damage suffered as a result of any action brought
#- by a third party) even if such damage or loss was
#- reasonably foreseeable or Xilinx had been advised of the
#- possibility of the same.
#-
#- CRITICAL APPLICATIONS
#- Xilinx products are not designed or intended to be fail-
#- safe, or for use in any application requiring fail-safe
#- performance, such as life-support or safety devices or
#- systems, Class III medical devices, nuclear facilities,
#- applications related to the deployment of airbags, or any
#- other applications that could lead to death, personal
#- injury, or severe property or environmental damage
#- (individually and collectively, "Critical
#- Applications"). Customer assumes the sole risk and
#- liability of any use of Xilinx products in Critical
#- Applications, subject only to applicable laws and
#- regulations governing limitations on product liability.
#-
#- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
#- PART OF THIS FILE AT ALL TIMES.
#- ************************************************************************
*
*****************************************************************************/
/*
* This file contains the definition of the data types for AXI streaming.
* ap_axi_s is a signed interpretation of the AXI stream
* ap_axi_u is an unsigned interpretation of the AXI stream
*/
#ifndef __AP__AXI_SDATA__
#define __AP__AXI_SDATA__
#include "ap_int.h"
template<int D,int U,int TI,int TD>
struct ap_axis{
ap_int<D> data;
ap_uint<(D+7)/8> keep;
ap_uint<(D+7)/8> strb;
ap_uint<U> user;
ap_uint<1> last;
ap_uint<TI> id;
ap_uint<TD> dest;
};
template<int D>
struct ap_axis <D, 0, 0, 0>{
ap_int<D> data;
ap_uint<(D+7)/8> keep;
ap_uint<(D+7)/8> strb;
ap_uint<1> last;
};
template<int D,int U,int TI,int TD>
struct ap_axiu{
ap_uint<D> data;
ap_uint<(D+7)/8> keep;
ap_uint<(D+7)/8> strb;
ap_uint<U> user;
ap_uint<1> last;
ap_uint<TI> id;
ap_uint<TD> dest;
};
template<int D>
struct ap_axiu <D, 0, 0, 0>{
ap_uint<D> data;
ap_uint<(D+7)/8> keep;
ap_uint<(D+7)/8> strb;
ap_uint<1> last;
};
template<int D,int U,int TI,int TD> struct qdma_axis;
template<int D>
struct qdma_axis <D, 0, 0, 0>{
// private:
ap_uint<D> data;
ap_uint<(D+7)/8> keep;
ap_uint<1> last;
// public:
ap_uint<D> get_data() const { return data; }
ap_uint<(D+7)/8> get_keep() const { return keep; }
ap_uint<1> get_last() const { return last; }
void set_data(const ap_uint<D> &d) { data = d; }
void set_keep(const ap_uint<(D+7)/8> &k) { keep = k; }
void set_last(const ap_uint<1> &l) { last = l; }
void keep_all() {
ap_uint<(D+7)/8> k = 0;
keep = ~k;
}
qdma_axis(ap_uint<D> d = ap_uint<D>(), ap_uint<(D+7)/8> k = ap_uint<(D+7)/8>(), ap_uint<1> l = ap_uint<1>()) : data(d), keep(k), last(l) {}
qdma_axis(const qdma_axis<D, 0, 0, 0> &d) : data(d.data), keep(d.keep), last(d.last) {}
};
//typedef ap_axis<int D, int U, int TI, int TD> ap_axis_unsigned<int D, int U, int TI, int TD>;
#endif
其中就有报错显示的两个类型:
struct ap_axis
struct ap_axiu
报这个错的原因,可能是因为hls_opencv和xfopencv之间不兼容,不支持综合。
二、解决方法
修改源码,即ap_axi_sdata.h文件。
1. 在该文件中加入引用头:
#include "hls_video.h"
2.将关于struct ap_axis和struct ap_axiu部分注释掉
#ifndef __AP__AXI_SDATA__
#define __AP__AXI_SDATA__
#include "ap_int.h"
#include "hls_video.h"
/*
template<int D,int U,int TI,int TD>
struct ap_axis{
ap_int<D> data;
ap_uint<(D+7)/8> keep;
ap_uint<(D+7)/8> strb;
ap_uint<U> user;
ap_uint<1> last;
ap_uint<TI> id;
ap_uint<TD> dest;
};
template<int D>
struct ap_axis <D, 0, 0, 0>{
ap_int<D> data;
ap_uint<(D+7)/8> keep;
ap_uint<(D+7)/8> strb;
ap_uint<1> last;
};
template<int D,int U,int TI,int TD>
struct ap_axiu{
ap_uint<D> data;
ap_uint<(D+7)/8> keep;
ap_uint<(D+7)/8> strb;
ap_uint<U> user;
ap_uint<1> last;
ap_uint<TI> id;
ap_uint<TD> dest;
};
template<int D>
struct ap_axiu <D, 0, 0, 0>{
ap_uint<D> data;
ap_uint<(D+7)/8> keep;
ap_uint<(D+7)/8> strb;
ap_uint<1> last;
};
*/
template<int D,int U,int TI,int TD> struct qdma_axis;
template<int D>
struct qdma_axis <D, 0, 0, 0>{
// private:
ap_uint<D> data;
ap_uint<(D+7)/8> keep;
ap_uint<1> last;
// public:
ap_uint<D> get_data() const { return data; }
ap_uint<(D+7)/8> get_keep() const { return keep; }
ap_uint<1> get_last() const { return last; }
void set_data(const ap_uint<D> &d) { data = d; }
void set_keep(const ap_uint<(D+7)/8> &k) { keep = k; }
void set_last(const ap_uint<1> &l) { last = l; }
void keep_all() {
ap_uint<(D+7)/8> k = 0;
keep = ~k;
}
qdma_axis(ap_uint<D> d = ap_uint<D>(), ap_uint<(D+7)/8> k = ap_uint<(D+7)/8>(), ap_uint<1> l = ap_uint<1>()) : data(d), keep(k), last(l) {}
qdma_axis(const qdma_axis<D, 0, 0, 0> &d) : data(d.data), keep(d.keep), last(d.last) {}
};
//typedef ap_axis<int D, int U, int TI, int TD> ap_axis_unsigned<int D, int U, int TI, int TD>;
#endif
修改后再次点击仿真按钮,会提示是否保存修改的系统文件并执行,点击“yes”,静静等待即可。
注意:此方法存在一定的缺陷,因为在系统的头文件中注释掉了这两个数据类型,如果下一个工程中使用到opencv这个库中的两个数据类型,那么需要把注释取消,否则会报错,大概意思就是没有定义这两个数据类型,一定要注意。
Symbol 'ap_axiu' could not be resolved
翻译:无法解析符号“ap_axiu”
原因和解决方法:因为被注释掉了,把注释取消即可
——晓凡 于桂林2022年3月3日书