i am implementing a simple image transformation filter in vivado hls. I have attached the files below:
//headerfile- ct_h.hpp
#include <assert.h>
#include <stdint.h>
#include <hls_stream.h>
#include <windows.h>
#include <windef.h>
#define MAX_IMG_ROWS 1080
#define MAX_IMG_COLS 1920
#define MAX_IMG_CHANNELS 3
#define min_pix (float)0.0
#define max_pix (float)255.0
#define TEST_IMG_ROWS 256
#define TEST_IMG_COLS 512
#define TEST_IMG_CHANNELS 512
typedef unsigned char data_t;
void ct_filter(
int w, int h,
data_t input_image, data_t output_image,float TsTw_tran[3][3]);
synthasizable part:
//Mainfile - ct_core.cpp
//core
#include "ct_h.hpp"
#include <hls_math.h>
void ct_filter(int width, int height,
data_t src[256][512][3], data_t dst[256][512][3],float TsTw_tran[3][3])
{
float red_ar, green_ar, blue_ar;
float red_new_ar, green_new_ar, blue_new_ar;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
red_ar = (((float)src[i][j][0]) / 256.0);
green_ar = (((float)src[i][j][1]) / 256.0);
blue_ar = (((float)src[i][j][2]) / 256.0);
red_new_ar = red_ar * TsTw_tran[0][0] + green_ar * TsTw_tran[1][0] + blue_ar * TsTw_tran[2][0];
green_new_ar = red_ar * TsTw_tran[0][1] + green_ar * TsTw_tran[1][1] + blue_ar * TsTw_tran[2][1];
blue_new_ar = red_ar * TsTw_tran[0][2] + green_ar * TsTw_tran[1][2] + blue_ar * TsTw_tran[2][2];
red_new_ar = red_new_ar*255.0;
green_new_ar = green_new_ar*255.0;
blue_new_ar = blue_new_ar*255.0;
red_new_ar = fmin(fmax(red_new_ar, min_pix), max_pix);
green_new_ar = fmin(fmax(green_new_ar, min_pix), max_pix);
blue_new_ar = fmin(fmax(blue_new_ar, min_pix), max_pix);
dst[i][j][0] = (data_t)red_new_ar;
dst[i][j][1] = (data_t)green_new_ar;
dst[i][j][2] = (data_t)blue_new_ar;
}
}
}
Testbenchpart:
//ct_testbench.cpp
#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include "math.h"
#include <chrono>
#include "ct_h.hpp"
#include <hls_opencv.h>
using namespace cv;
using namespace std;
int main()
{
float TsTw_tran[3][3];
for (int i = 0; i < TsTw_trans.size(); i++) {
for (int j = 0; j < TsTw_trans[i].size(); j++) {
TsTw_tran[i][j] = TsTw_trans[i][j];
}
}//caluclated this from previous functions, code is not posted here
//data_t * const input_img = new data_t[TEST_IMG_ROWS][TEST_IMG_COLS][TEST_IMG_CHANNELS];
//data_t * const output_img = new data_t[TEST_IMG_ROWS][TEST_IMG_COLS][TEST_IMG_CHANNELS];
data_t input_img[256][512][3];
data_t output_img[256][512][3];
Mat img_rev = imread("C:/Users/20181217/Desktop/images/imgs/output_rev.png");
Mat final_img(img_rev.rows,img_rev.cols,CV_8UC3);
Mat ideal = imread("C:/Users/20181217/Desktop/images/imgs/output_fwd_v4.png");
for (int i = 0; i < TEST_IMG_ROWS; i++)
{
for (int j = 0; j < TEST_IMG_COLS; j++)
{
input_img[i][j][0] = img_rev.at<Vec3b>(i, j)[2];//R - B
input_img[i][j][1] = img_rev.at<Vec3b>(i, j)[1];//G - G
input_img[i][j][2] = img_rev.at<Vec3b>(i, j)[0];//B - R
}
}
ct_filter(TEST_IMG_COLS, TEST_IMG_ROWS, input_img, output_img, TsTw_tran);
for (int i = 0; i < img_rev.rows; i++)
{
for (int j = 0; j < img_rev.cols; j++)
{
final_img.at<Vec3b>(i, j)[0] = output_img[i][j][0];//R
final_img.at<Vec3b>(i, j)[1] = output_img[i][j][1];//G
final_img.at<Vec3b>(i, j)[2] = output_img[i][j][2];//B
}
}
imwrite("C:/Users/20181217/Desktop/images/imgs/hls_gen_stage3.png",final_img);
return 0
}
The simulation part is giving me an correct result but when I try to synthesize this, I am getting these errors
ERROR: [HLS 214-124] use of undeclared identifier '__builtin_ia32_storeups':
C:\Xilinx\Vivado\2019.2\win64\tools\clang\lib\clang\3.1\include\xmmintrin.h:630
ERROR: [HLS 214-124] use of undeclared identifier '__builtin_ia32_movntps'; did you mean '__builtin_ia32_movntss'?: C:\Xilinx\Vivado\2019.2\win64\tools\clang\lib\clang\3.1\include\xmmintrin.h:678
ERROR: [HLS 214-124] use of undeclared identifier '__builtin_ia32_cvtps2pd': C:\Xilinx\Vivado\2019.2\win64\tools\clang\lib\clang\3.1\include\emmintrin.h:380
ERROR: [HLS 214-124] use of undeclared identifier '__builtin_ia32_cvtdq2pd'; did you mean '__builtin_ia32_cvtdq2ps'?: C:\Xilinx\Vivado\2019.2\win64\tools\clang\lib\clang\3.1\include\emmintrin.h:386
ERROR: [HLS 214-124] use of undeclared identifier '__builtin_ia32_storeupd': C:\Xilinx\Vivado\2019.2\win64\tools\clang\lib\clang\3.1\include\emmintrin.h:586
ERROR: [HLS 214-124] use of undeclared identifier '__builtin_ia32_pavgb128': C:\Xilinx\Vivado\2019.2\win64\tools\clang\lib\clang\3.1\include\emmintrin.h:671
ERROR: [HLS 214-124] use of undeclared identifier '__builtin_ia32_pavgw128': C:\Xilinx\Vivado\2019.2\win64\tools\clang\lib\clang\3.1\include\emmintrin.h:677
ERROR: [HLS 214-124] use of undeclared identifier '__builtin_ia32_storedqu': C:\Xilinx\Vivado\2019.2\win64\tools\clang\lib\clang\3.1\include\emmintrin.h:1177
ERROR: [HLS 214-124] use of undeclared identifier '__builtin_ia32_storelv4si'; did you mean '__builtin_ia32_storelps'?: C:\Xilinx\Vivado\2019.2\win64\tools\clang\lib\clang\3.1\include\emmintrin.h:1189
ERROR: [HLS 214-124] use of undeclared identifier '__builtin_ia32_movntpd'; did you mean '__builtin_ia32_movntsd'?: C:\Xilinx\Vivado\2019.2\win64\tools\clang\lib\clang\3.1\include\emmintrin.h:1195
ERROR: [HLS 214-124] use of undeclared identifier '__builtin_ia32_movntdq'; did you mean '__builtin_ia32_movntq'?: C:\Xilinx\Vivado\2019.2\win64\tools\clang\lib\clang\3.1\include\emmintrin.h:1201
Wrong pragma usage.
PS: I know that using streams is a better way to the data transfer rather than using arrays, my objective is to implement a naive implementation using arrays and then optimize it using different pragmas like streams.
Thanks in advance
by removing the below mentioned libraries
the conflict was resolved