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: 
Highlighted
Observer prateek33
Observer
434 Views
Registered: ‎05-21-2018

Get an Array as input from memory in HLS

I wish to have a complete array as an input from memory. I tried to declare the port as ap_memory but I still get an error "Hls::stream 'hls::stream<float>.1' is read while empty, which may result in RTL simulation hanging." which makes me believe that it is still being initialized as a Stream by HLS. How do I stop this from happening? I am trying to simulate the function by giving an input as a complete array but I am greeted with the above error.

 

Here are my source code and testbench in case it's required.

 

#include "hls_video.h"

#define N 100
#define PX 256

using namespace hls;

void gauss2im(float* gauss, Mat<PX,PX,HLS_32FC1>& im){

#pragma HLS INTERFACE ap_memory port=gauss

	int i,j;
	unsigned char temp;
	Scalar<1, float> pixel;

	for(i = 0; i < N; ++i){
		for(j = 0; j < N; ++j){
			temp = (unsigned char)(hls::floorf(N*hls::sqrt((i*i + j*j)/(2.0*PX*PX))));
			pixel = gauss[temp];
			im.write(pixel);
		}
	}
}

Testbench:

#include <iostream>
#include <hls_video.h>
#include "hls_opencv.h"

#define N 100
#define PX 256

using namespace hls;

extern void gauss2im(float* gauss, Mat<PX,PX,HLS_32FC1>& im);

int main(){
	float gauss[N] = {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000001,0.000004,0.000010,0.000025,0.000063,0.000148,0.000335,0.000732,0.001534,0.003089,0.005976,0.011109,0.019841,0.034047,0.056135,0.088922,0.135335,0.197899,0.278037,0.375311,0.486752,0.606531,0.726149,0.835270,0.923116,0.980199,1.000000,0.980199,0.923116,0.835270,0.726149,0.606531,0.486752,0.375311,0.278037,0.197899,0.135335,0.088922,0.056135,0.034047,0.019841,0.011109,0.005976,0.003089,0.001534,0.000732,0.000335,0.000148,0.000063,0.000025,0.000010,0.000004,0.000001,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000};
	Mat<PX,PX,HLS_32FC1> im;

	gauss2im(gauss,im);
	cv::Mat im_cv(PX,PX,CV_32FC1);
	hlsMat2cvMat(im,im_cv);

	cv::namedWindow("Final",cv::WINDOW_NORMAL);
	cv::imshow("Final",im_cv);

	return 0;
}
0 Kudos
1 Reply
Scholar u4223374
Scholar
422 Views
Registered: ‎04-26-2015

Re: Get an Array as input from memory in HLS

Have you tried setting the size of "gauss" in the function definition?

 

ap_memory is designed to connect to an external RAM. In order to build this interface, HLS needs to know how large that RAM is (so it can select an appropriate number of address bits). Without that, it may just be defaulting to the only way HLS can deal with an infinite-size array - as a stream.

0 Kudos