cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
7,044 Views
Registered: ‎06-12-2016

Zynq HLS <-> Vivado SDK transmission problem (s_axilite)

Jump to solution

Hello,

 

 

first of all I want to introduce myself. I'm an experienced software engineer, but I

don't have much practical knowledge in programming FPGAs (only a VHDL course

at university). To be able to play around with the Zybo Zynq I've read the Zynq-Book

and did the tutorials.

 

Now I want to do design a program (Xilinx SDK) that calculates the mean of two vectors.

On the one hand this is done in software using the ARM chip and on the other I build an

accelerator using Vivado HLS. Following the instructions from ug902 (http://www.xilinx.com/support/documentation/sw_manuals/xilinx2014_1/ug902-vivado-high-level-synthesis.pdf)

I'm using s_axilite interfaces for the ports. You can find the implementation and the Test-bench attached

(meanCalc.c,meanCalcTestbench.c).

Simulation, Synthesis, Co-Design & IP-Export seem to be working.

 

After that I used Vivado to create my design attached as MeanCalculation.pdf.

 

At the end, I've exported the bitfile to the SDK and implemented my program

(HW-SW.c).

Here I'm getting into trouble, because the accelerator delivers wrong results.

 

I'm looking forward for your help!

 

 

Best regards

Nils

 

 

0 Kudos
1 Solution

Accepted Solutions
Visitor
Visitor
13,519 Views
Registered: ‎06-12-2016

Re: Zynq HLS <-> Vivado SDK transmission problem (s_axilite)

Jump to solution

Thanks, I found my problem.

 

When I started, I used a loop and transmitte value after value.

That why, I used the offset variable i. After setting the offset to zero,

the code seems to be working!

 

For completeness here is the working piece of code:

int main() {
    init_platform();

    printf("Look Up the device configuration\n\r");
    meanHWConfig = XMeanaccelerator_LookupConfig(XPAR_XMEANACCELERATOR_0_DEVICE_ID);
    if (!meanHWConfig) {
		print("ERROR: Lookup of accelerator configuration failed.\n\r");
		return XST_FAILURE;
    }

    printf("Initialize the Device\n\r");
    int status = XMeanaccelerator_CfgInitialize(&meanHW, meanHWConfig);
    if (status != XST_SUCCESS) {
		print("ERROR: Could not initialize accelerator.\n\r");
		return XST_FAILURE;
    }

    printf("Create and fill test arrays\n\r");
	int vec1[vec_size];
	int vec2[vec_size];
	unsigned int i;
	for (i = 0; i < vec_size; i++) {
		vec1[i] = i;
		vec2[i] = i+10;
	}

	// Calculate mean in software
	int sum1 = 0;
	int sum2 = 0;
	unsigned int j;
	for (j = 0; j < vec_size; j++) {
		sum1 += vec1[j];
		sum2 += vec2[j];
	}
	int mean1 = sum1 / vec_size;
	int mean2 = sum2 / vec_size;

	printf("Send data to HW\n\r");
	printf("Vec1 wrote: %u\n", XMeanaccelerator_Write_vec1_Words(&meanHW, 0, vec1, vec_size));
	printf("Vec2 wrote: %u\n", XMeanaccelerator_Write_vec2_Words(&meanHW, 0, vec2, vec_size));

	printf("Start HW accelerator\n\r");
	XMeanaccelerator_Start(&meanHW);
	int mean1HW = -1, mean2HW = -1;
	do {
	} while (!XMeanaccelerator_IsDone(&meanHW));
	mean1HW = XMeanaccelerator_Get_rv_mean1(&meanHW);
	mean2HW = XMeanaccelerator_Get_rv_mean2(&meanHW);

	printf("Statistics\r\n");
	printf("sum1 = %d\n", sum1);
	printf("sum2 = %d\n", sum2);
	printf("mean1:   SW = %d, HW = %d\r\n", mean1, mean1HW);
	printf("mean2:   SW = %d, HW = %d\r\n", mean2, mean2HW);
	if (mean1 == mean1HW && mean2 == mean2HW) {
		printf("SUCCESS");
		return 0;
	} else {
		printf("FAIL");
		return 1;
	}

    cleanup_platform();
    return 0;
}

View solution in original post

0 Kudos
6 Replies
Highlighted
Teacher
Teacher
7,039 Views
Registered: ‎03-31-2012

Re: Zynq HLS <-> Vivado SDK transmission problem (s_axilite)

Jump to solution

in hw-sw.c move the get_rv_meanX calls after the check for _IsDone and see if that helps.

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Highlighted
Visitor
Visitor
6,889 Views
Registered: ‎06-12-2016

Re: Zynq HLS <-> Vivado SDK transmission problem (s_axilite)

Jump to solution

Hello,

 

 

thanks for your fast reply.

I changed the code to the listing below:

 

// Start HW block
XMeanaccelerator_Start(&meanHW);

// Wait until HW block finishes calculation
do {
} while (!XMeanaccelerator_IsDone(&meanHW));

// Create some additional delay before reading values
for (j = 0; j < 10000; j++) {
	printf(" ");
}

// Receive values from HW block
int mean1HW = XMeanaccelerator_Get_rv_mean1(&meanHW);
int mean2HW = XMeanaccelerator_Get_rv_mean2(&meanHW);

 

 

Unfortunately, the problem still exists. The output is as follows:

 

Look Up the device configuration

Initialize the Device

Create and fill test arrays

Send data to HW

Start HW accelerator

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Statistics
sum1 = 499500
sum2 = 509500
mean1:   SW = 499, HW = 0
mean2:   SW = 509, HW = 0

FAIL

 

 

Any ideas?

 

 

Best regards

Nils

 

0 Kudos
Highlighted
Teacher
Teacher
7,031 Views
Registered: ‎03-31-2012

Re: Zynq HLS <-> Vivado SDK transmission problem (s_axilite)

Jump to solution
verify that you are able to write the vectors correctly.
Also attach the implementation of XMeanaccelerator_Write_vec2_Words etc. in addition to your ..._hw.h file.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
Highlighted
Visitor
Visitor
7,029 Views
Registered: ‎06-12-2016

Re: Zynq HLS <-> Vivado SDK transmission problem (s_axilite)

Jump to solution

In my HLS implementation, I returned the two first vector entries instead of the mean values.

=> They are garbage, so the transmission of vectors seems to fail.

 

I attached the created ip drivers.

0 Kudos
Highlighted
Teacher
Teacher
7,017 Views
Registered: ‎03-31-2012

Re: Zynq HLS <-> Vivado SDK transmission problem (s_axilite)

Jump to solution
I think you are using the XMeanaccelerator_Write_vec1_Words etc. incorrectly. Look at their definition and see if your calls match what they do.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
Visitor
Visitor
13,520 Views
Registered: ‎06-12-2016

Re: Zynq HLS <-> Vivado SDK transmission problem (s_axilite)

Jump to solution

Thanks, I found my problem.

 

When I started, I used a loop and transmitte value after value.

That why, I used the offset variable i. After setting the offset to zero,

the code seems to be working!

 

For completeness here is the working piece of code:

int main() {
    init_platform();

    printf("Look Up the device configuration\n\r");
    meanHWConfig = XMeanaccelerator_LookupConfig(XPAR_XMEANACCELERATOR_0_DEVICE_ID);
    if (!meanHWConfig) {
		print("ERROR: Lookup of accelerator configuration failed.\n\r");
		return XST_FAILURE;
    }

    printf("Initialize the Device\n\r");
    int status = XMeanaccelerator_CfgInitialize(&meanHW, meanHWConfig);
    if (status != XST_SUCCESS) {
		print("ERROR: Could not initialize accelerator.\n\r");
		return XST_FAILURE;
    }

    printf("Create and fill test arrays\n\r");
	int vec1[vec_size];
	int vec2[vec_size];
	unsigned int i;
	for (i = 0; i < vec_size; i++) {
		vec1[i] = i;
		vec2[i] = i+10;
	}

	// Calculate mean in software
	int sum1 = 0;
	int sum2 = 0;
	unsigned int j;
	for (j = 0; j < vec_size; j++) {
		sum1 += vec1[j];
		sum2 += vec2[j];
	}
	int mean1 = sum1 / vec_size;
	int mean2 = sum2 / vec_size;

	printf("Send data to HW\n\r");
	printf("Vec1 wrote: %u\n", XMeanaccelerator_Write_vec1_Words(&meanHW, 0, vec1, vec_size));
	printf("Vec2 wrote: %u\n", XMeanaccelerator_Write_vec2_Words(&meanHW, 0, vec2, vec_size));

	printf("Start HW accelerator\n\r");
	XMeanaccelerator_Start(&meanHW);
	int mean1HW = -1, mean2HW = -1;
	do {
	} while (!XMeanaccelerator_IsDone(&meanHW));
	mean1HW = XMeanaccelerator_Get_rv_mean1(&meanHW);
	mean2HW = XMeanaccelerator_Get_rv_mean2(&meanHW);

	printf("Statistics\r\n");
	printf("sum1 = %d\n", sum1);
	printf("sum2 = %d\n", sum2);
	printf("mean1:   SW = %d, HW = %d\r\n", mean1, mean1HW);
	printf("mean2:   SW = %d, HW = %d\r\n", mean2, mean2HW);
	if (mean1 == mean1HW && mean2 == mean2HW) {
		printf("SUCCESS");
		return 0;
	} else {
		printf("FAIL");
		return 1;
	}

    cleanup_platform();
    return 0;
}

View solution in original post

0 Kudos