Xilinx/Vitis-HLS-Introductory-Examples

the role of static int j in Dataflow/Bypassing/input_bypass/dut_sol.cpp ?

3togo opened this issue · 2 comments

3togo commented

What is the objective of adding
static int j;
in functions add_kernel, Double_pass and pass?

Intuitively, it might be used as a global counter. If so, how to use it? Also, why not declare it as a global variable outside these functions.
What have I missed?

void add_kernel(int tmp1[128], int tmp2[128], int tmp3[128])
{
	static int j;

	int buff[127];
	for(int i=0;i<128;i++)
	{
		j++;
		tmp3[i] = tmp1[i] +tmp2[i];
	}

}


void Double_pass(int tmp2[128], int tmp1[128], int tmp4[128], int tmp5[128])
{
	static int j;

	int buff[127];
	for(int i=0;i<128;i++)
	{
		j++;
		tmp4[i] = tmp1[i];
		tmp5[i] = tmp2[i];
	}

}

void pass(int a[128], int b[128],int tmp1[128], int tmp2[128])
{
	static int j;
	for(int i=0;i<128;i++)
	{
		j++;
		tmp1[i]= a[i];
		tmp2[i] = b[i];
	}

}

void dut(int a[128], int b[128], int tmp3[128])
{
#pragma HLS DATAFLOW

int tmp1[128],tmp2[128], tmp4[128];
int tmp5[128];
	pass(a,b,tmp1,tmp2);
	Double_pass(tmp2,tmp1, tmp4, tmp5);
	add_kernel(tmp4,tmp5,tmp3);
}

Yes, as you suspected there was no reason for the static int j variable. It has been removed. Thanks for reporting it.

Closing this issue.