UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer ssong94
Observer
1,563 Views
Registered: ‎03-19-2018

Vivado HLS: Failed checking during preprocessing

Jump to solution

Hi, I'm having this error during synthesis in HLS. This is my cpp code:

#include "core.h"

void imgreading(hls::stream<datau32> &Imgin_stream, datau32 Imgin[imagesize])
{
	for(int i=0;i<imagesize;i++)
	{
		Imgin[i]=(datau32)Imgin_stream.read();
	}
}

void resize_half(hls::stream<datau32> &inStream, hls::stream<datau32> &outStream)
{
#pragma HLS INTERFACE axis port=inStream
#pragma HLS INTERFACE axis port=outStream
#pragma HLS INTERFACE s_axilite port=return bundle=CRTL_BUS
	datau32 Imgin[imagesize];
	imgreading (inStream,Imgin);
	datau32 imgOut;
	int coord;


#pragma HLS DATAFLOW
	for (int a=0; a<240; a++) {
		for(int b=0; b<320; b++){
#pragma HLS PIPELINE II=1
			coord=6*(a*640+b);
		    imgOut=  (0.2126*Imgin[coord] + 0.7152*Imgin[coord+1] + 0.0722*Imgin[coord+2]) ;
			datau32 dataOutSideChannel;
			dataOutSideChannel.data = imgOut;
			outStream.write (dataOutSideChannel);
		}

	}

}

and this is the header file:

#include <hls_stream.h>
#include <ap_axi_sdata.h>

typedef ap_axiu<32,2,5,6> datau32;
#define imagesize 921600
void resize_half(hls::stream<datau32> &inStream, hls::stream<datau32> &outStream);

This is the complete error message:

error: invalid operands to binary expression ('double' and 'datau32' (aka 'ap_axiu<32, 2, 5, 6>'))
imgOut= (0.2126*Imgin[coord] + 0.7152*Imgin[coord+1] + 0.0722*Imgin[coord+2]) ;

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Voyager
Voyager
1,948 Views
Registered: ‎03-28-2016

Re: Vivado HLS: Failed checking during preprocessing

Jump to solution

I suspect the issue is with the use of the "ap_axiu<32,2,5,6> " structure.  Try something along the lines of:

 

imgOut.data =  (0.2126*Imgin[coord].data + 0.7152*Imgin[coord+1].data + 0.0722*Imgin[coord+2].data) ;

 

Also keep in mind that you are mixing data types (double and int).  I would recommend converting the doubles to fixed-point integers.  That would allow the use of integer arithmetic instead of floating-point arithmetic.  Integer arithmetic is typically faster and uses less resources.

 

Ted Booth - Tech. Lead FPGA Design Engineer
www.designlinxhs.com
5 Replies
Voyager
Voyager
1,949 Views
Registered: ‎03-28-2016

Re: Vivado HLS: Failed checking during preprocessing

Jump to solution

I suspect the issue is with the use of the "ap_axiu<32,2,5,6> " structure.  Try something along the lines of:

 

imgOut.data =  (0.2126*Imgin[coord].data + 0.7152*Imgin[coord+1].data + 0.0722*Imgin[coord+2].data) ;

 

Also keep in mind that you are mixing data types (double and int).  I would recommend converting the doubles to fixed-point integers.  That would allow the use of integer arithmetic instead of floating-point arithmetic.  Integer arithmetic is typically faster and uses less resources.

 

Ted Booth - Tech. Lead FPGA Design Engineer
www.designlinxhs.com
Highlighted
Observer ssong94
Observer
1,530 Views
Registered: ‎03-19-2018

Re: Vivado HLS: Failed checking during preprocessing

Jump to solution

@tedbooth Hi, thanks for the help. now it works but it uses a lot of BRAM resources.

 

Can you suggest me on how to convert the doubles to fixed point integers as the value 0.2126, 0.7152, 0.0722 is data type of double.

0 Kudos
Voyager
Voyager
1,523 Views
Registered: ‎03-28-2016

Re: Vivado HLS: Failed checking during preprocessing

Jump to solution

It's using lots of BRAMs because HLS implements arrays (datau32 Imgin[imagesize]) as RAMs.  Also keep in mind that you are accessing that RAM three times in the main processing loop.  RAMs can only have two ports which will limit the access to the array and will require multiple clock cycles to access the require data.  This will slow down the processing and limit the "II" that can be achieved as it is currently implemented.

 

As for fixed-point, take a look at :

https://en.wikipedia.org/wiki/Fixed-point_arithmetic

 

Also in UG902 do a search on "ap_fixed".

Ted Booth - Tech. Lead FPGA Design Engineer
www.designlinxhs.com
Observer ssong94
Observer
1,518 Views
Registered: ‎03-19-2018

Re: Vivado HLS: Failed checking during preprocessing

Jump to solution

@tedbooth Thanks for the explanation, one more question, in the C testbench, since the input pixel of the image is in unsigned char form, how can i convert it into the stream input so that i can pass into my function for processing?

 

I did try with this code but it causes unknown error: 

#include <stdio.h>
#include "core.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <hls_opencv.h>

#define input_image_path "D:\\HLS\\2017.4\\Face_detection\\inputimage1.jpg"
#define output_image_path "D:\\HLS\\2017.4\\Face_detection\\output.jpg"

char outImage[320][240];

int main()
{

	int  *imgIn;
	imgIn=(int*)malloc(sizeof(int)*640*480*3);
	hls::stream<datau32> inputStream;
	hls::stream<datau32> outputStream;
	cv::Mat imgSrc;

	imgsrc=cv::imread(input_image_path);
	imgIn = (int*)imgSrc.data;
	for (int y=0;y<640*480*3;y++){
		datau32 valIn;
		valIn.data = imgIn[y];
		inputStream << valIn;
	}
	resize_half(inputStream, outputStream);
	for (int i=0;i<320;i++)
	{
		for (int j=0;j<240;j++)
		{

			datau8 valOut;
			outputStream.read(valOut);
			outImage[i][j]=valOut.data;
		}
	}
	cv::Mat output(cv::Size(320,240),0,outImage,cv::Mat::AUTO_STEP);
	imwrite (output_image_path,output);

	return 0;
}

Error message: INFO: [SIM 2] *************** CSIM start ***************
INFO: [SIM 4] CSIM will launch GCC as the compiler.
Compiling ../../../test_core.cpp in debug mode
Compiling ../../../core.cpp in debug mode
Generating csim.exe
CRITICAL WARNING: [SIM 100] CSim failed with errors.
INFO: [SIM 3] *************** CSIM finish ***************

0 Kudos
Voyager
Voyager
1,508 Views
Registered: ‎03-28-2016

Re: Vivado HLS: Failed checking during preprocessing

Jump to solution

Since you are using the OpenCV functions, do a search in UG902 for "cvMat2AXIvideo".  That function will convert a cv::Mat to an hls stream.

Ted Booth - Tech. Lead FPGA Design Engineer
www.designlinxhs.com