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: 
282 Views
Registered: ‎07-30-2018

Vivado HLS

 

How to create a test bench for a cpp programme in vivado HLS.Please help me with this.

0 Kudos
6 Replies
Scholar u4223374
Scholar
260 Views
Registered: ‎04-26-2015

Re: Vivado HLS

In the "Explorer" pane on the left-hand side, right-click on "Test Bench" and then select "New File...". Name the file, create a main function that does what you want, and you're finished.

0 Kudos
243 Views
Registered: ‎07-30-2018

Re: Vivado HLS

Thanks for the response sir.

But I need to know how to use the function in the testbench.If there is any syntax for that,please help me with the solution.

 

0 Kudos
Scholar u4223374
Scholar
229 Views
Registered: ‎04-26-2015

Re: Vivado HLS

The syntax is very simple:

int main() {
// your code goes here.
return 0;
}

In the "your code goes here" section, you need to generate or read some test data suitable for your application, turn that into a form suitable for the module you're testing, run that module with the data, collect results, and compare the results to known-good data. Until you actually post the code that you're trying to test, it's going to be pretty difficult to give more information.

0 Kudos
Scholar dpaul24
Scholar
227 Views
Registered: ‎08-07-2014

Re: Vivado HLS

krishnendu@123,

you should read the tutorials first.A very basic one - https://www.so-logic.net/documents/upload/Basic_HLS_Tutorial.pdf

There are many others, from Xilinx as well as other Youtube vdos.

--------------------------------------------------------------------------------------------------------
FPGA enthusiast!
All PMs will be ignored
--------------------------------------------------------------------------------------------------------
191 Views
Registered: ‎07-30-2018

Re: Vivado HLS

Thanks for the reply sir,i will send you the code

 

 

#include <stdio.h>
#include <ctime>
#include <stdlib.h>
#include "haar.h"
#include "image.h"

using namespace std;

int main ( int argc, char *argv[] )
{

int flag;
int in_flag , in_width , in_height , in_maxgrey;
int ret_val=1;

printf ("-- entering main function --\r\n");
printf ("-- loading image --\r\n");

// 320 X 240 Input image in hex format
#include INPUT_IMAGE

double duration;

// Arguments to be passed to DUT
MyRect result[RESULT_SIZE];
int result_x[RESULT_SIZE];
int result_y[RESULT_SIZE];
int result_w[RESULT_SIZE];
int result_h[RESULT_SIZE];

int res_size=0;
int *result_size = &res_size;
int i;

// As the SDSoC generated data motion network does not support sending 320 X 240 images at once
// We needed to send all the 240 rows using 240 iterations. The last invokation of detectFaces() does the actual face detection

for ( i = 0; i < IMAGE_HEIGHT-1; i+=1 ){
detectFaces ( Data[i], result_x, result_y, result_w, result_h, result_size);
}

printf ("-- detecting faces --\r\n");

std::clock_t start = std::clock();
detectFaces ( Data[IMAGE_HEIGHT-1], result_x, result_y, result_w, result_h, result_size);
duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;

printf("\nresult_size = %d", *result_size);

for (int j = 0; j < RESULT_SIZE; j++){
result[j].x = result_x[j];
result[j].y = result_y[j];
result[j].width = result_w[j];
result[j].height = result_h[j];
}

for( int i=0 ; i < *result_size ; i++ )
printf("\n [Test Bench (main) ] detected rects: %d %d %d %d",result[i].x,result[i].y,result[i].width,result[i].height);

if ( *result_size > 0 ) ret_val = 0;

printf("\n-- saving output image [Start] --\r\n");

// Draw the rectangles onto the images and save the outputs.
for(i = 0; i < *result_size ; i++ )
{
MyRect r = result[i];
drawRectangle(Data, r);
}

flag = writePgm((char *)(OUTPUT_FILENAME),Data);
printf("\n-- saving output image [Done] --\r\n");
printf("DURATION: %2f", duration);

return ret_val;

}

0 Kudos
190 Views
Registered: ‎07-30-2018

Re: Vivado HLS

Thanks for the reply sir.

0 Kudos