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
Visitor allenlin
Visitor
80 Views
Registered: ‎07-22-2019

debug:same data but different result,how it happend?

Jump to solution
void mmult_accel_stream1(hls::stream<blockvector1> &A,hls::stream<blockvector1> &B,hls::stream<blockvector1> &C){
//#pragma HLS DATAFLOW
	DTYPE1 tmpa[TEST_HEIGHT],tmpb[TEST_HEIGHT];//tmp;
#pragma HLS ARRAY_PARTITION variable=tmpa complete dim=1
#pragma HLS ARRAY_PARTITION variable=tmpb complete dim=1
	static DTYPE1 c[TEST_HEIGHT][TEST_HEIGHT];


	period:for(int peri=0;peri<TEST_WIDTH;peri++){
#pragma HLS PIPELINE
blockvector1 va=A.read();
blockvector1 vb=B.read();
		readdataa:for(int ele=0;ele<TEST_HEIGHT;ele++)

//#pragma HLS UNROLL
			//a[ele]=A[ele][peri];
			tmpa[ele]=va.a[ele];
		readdatab:for(int ele=0;ele<TEST_HEIGHT;ele++)
//#pragma HLS UNROLL
			tmpb[ele]=vb.a[ele];
		//static DTYPE c[TEST_HEIGHT][TEST_HEIGHT];
#pragma HLS ARRAY_PARTITION variable=c complete dim=0
#pragma HLS dependence variable=c  inter false
		pe_row:for(int i=0;i<TEST_HEIGHT;i++){
			pe_col:for(int j=0;j<TEST_HEIGHT;j++){
//#pragma HLS PIPELINE
				DTYPE1 tmp;
				tmp=tmpa[i]*tmpb[j];
				c[i][j]+=tmp;
				//c[i][j]+=tmpa[i]*tmpb[j];
				//c[i][j]+=va.a[i]*vb.a[j];
			}
		}



	}

	Writedata:for(int i=0;i<TEST_HEIGHT;i++){
#pragma HLS PIPELINE
		blockvector1 vc;
				for(int j=0;j<TEST_HEIGHT;j++){
//#pragma HLS PIPELINE
					//C[i][j]=c[i][j];

					vc.a[j]=c[j][i];
					//vc.a[j]=c[i][j];
				}
				C.write(vc);
			}


}
void mmult_accel1_stream1(hls::stream<blockvector1> &A,hls::stream<din_t1> &B,hls::stream<DTYPE1> &C){
//#pragma HLS ARRAY_PARTITION variable=B complete dim=2

//#pragma HLS ARRAY_PARTITION variable=A complete dim=1
//#pragma HLS DATAFLOW
	DTYPE1 tmpa[TEST_HEIGHT];//tmp;
	din_t1 b;
#pragma HLS ARRAY_PARTITION variable=tmpa complete dim=1
	static DTYPE1 c[TEST_HEIGHT];

	// DTYPE1 c[TEST_HEIGHT];
	period:for(int peri=0;peri<TEST_WIDTH;peri++){
#pragma HLS PIPELINE
blockvector1 va=A.read();
		readdataa:for(int ele=0;ele<TEST_HEIGHT;ele++)

//#pragma HLS UNROLL
			tmpa[ele]=va.a[ele];
		//readdatab:for(int ele=0;ele<TEST_HEIGHT;ele++)
//#pragma HLS UNROLL
			//b[ele]=B[peri][ele];
			//b=B[peri];
			b=B.read();
		//static DTYPE c[TEST_HEIGHT][TEST_HEIGHT];
#pragma HLS ARRAY_PARTITION variable=c complete dim=0
#pragma HLS dependence variable=c  inter false
		pe_row:for(int i=0;i<TEST_HEIGHT;i++){
			//pe_col:for(int j=0;j<TEST_HEIGHT;j++){
			DTYPE1 tmp;
			tmp=tmpa[i]*b;
			c[i]+=tmp;
				//c[i]+=tmpa[i]*b;
			//}
		}



	}

	Writedata:for(int i=0;i<TEST_HEIGHT;i++){
				//for(int j=0;j<TEST_HEIGHT;j++){
#pragma HLS UNROLL
					C.write(c[i]);
				//}
			}




}
void mmult_accel2_stream1(hls::stream<blockvector1> &A,hls::stream<DTYPE1> &B,hls::stream<dout_type> &C){
//#pragma HLS ARRAY_PARTITION variable=B complete dim=2

//#pragma HLS ARRAY_PARTITION variable=A complete dim=1
//#pragma HLS DATAFLOW
	DTYPE1 tmpa[TEST_HEIGHT], b;//tmp;
	static dout_type c[TEST_HEIGHT];
	 //DTYPE1 c[TEST_HEIGHT];

	period:for(int peri=0;peri<TEST_HEIGHT;peri++){
#pragma HLS PIPELINE
blockvector1 va=A.read();
		readdataa:for(int ele=0;ele<TEST_HEIGHT;ele++)

//#pragma HLS UNROLL
			tmpa[ele]=va.a[ele];
		//readdatab:for(int ele=0;ele<TEST_HEIGHT;ele++)
//#pragma HLS UNROLL
			//b[ele]=B[peri][ele];
			//b=B[peri];
			b=B.read();
		//static DTYPE c[TEST_HEIGHT][TEST_HEIGHT];
#pragma HLS ARRAY_PARTITION variable=c complete dim=0
#pragma HLS dependence variable=c  inter false
		pe_row:for(int i=0;i<TEST_HEIGHT;i++){
			//pe_col:for(int j=0;j<TEST_HEIGHT;j++){
			dout_type tmp;
			tmp=tmpa[i]*b;
			c[i]+=tmp;
				//c[i]+=tmpa[i]*b;
			//}
		}



	}

	Writedata:for(int i=0;i<TEST_HEIGHT;i++){
				//for(int j=0;j<TEST_HEIGHT;j++){
//#pragma HLS UNROLL
#pragma HLS UNROLL
					C.write(c[i]);
				//}
			}




}
void module_conv21(
		hls::stream<din_t1> &a,
		//const int direction,
		const ap_fixed<4,1,AP_RND,AP_SAT> coeff[4],
		//const ap_int<2>coeff[4],
		hls::stream<dout_t1> &c

){
#pragma HLS DATAFLOW
//#pragma HLS INLINE off

//行缓冲
din_t1 linebuff[PATCH_COLS+1]={0};
//窗口寄存器
 din_t1 win[2][2];
 ConvH:for(int row=0;row<=PATCH_ROWS;row++){
	ConvW:for(int col=0;col<=PATCH_COLS;col++){

#pragma HLS PIPELINE

		din_t1 in_val;
		if(row<PATCH_ROWS&&col<PATCH_COLS)
		in_val=a.read();
		else
		in_val=0;
		dout_t1 tmp=0;
		/*
		//窗口2*2
#pragma HLS ARRAY_PARTITION variable=win complete
		win[0][0]=win[0][1];win[0][1]=linebuff[0];
		win[1][0]=win[1][1];win[1][1]=in_val;
		tmp=win[0][0]*coeff[0]+win[0][1]*coeff[1]+win[1][0]*coeff[2]+win[1][1]*coeff[3];
		//行缓存
#pragma HLS ARRAY_PARTITION variable=linebuff complete
		linebuff_loop:for(int i=0;i<=PATCH_COLS;i++){
#pragma HLS UNROLL
			linebuff[i]=i<PATCH_COLS?linebuff[i+1]:in_val;
		}
		//tmp=win[0][0]*coeff[0]+win[0][1]*coeff[1]+win[1][0]*coeff[2]+win[1][1]*coeff[3];
		if(row>=1&&col>=1)
		c<<tmp;
*/

#pragma HLS ARRAY_PARTITION variable=win complete dim=0
#pragma HLS ARRAY_PARTITION variable=coeff complete dim=0
		winbuff:for(int i=0;i<2;i++){
#pragma HLS UNROLL
		win[i][0]=win[i][1];
		}
		win[0][1]=linebuff[0];
		win[1][1]=in_val;
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				tmp+=win[i][j]*coeff[i*2+j];
		//tmp+=win[i][j]*coeff[i*2+j];
		//tmp=win[0][0]*coeff[0]+win[0][1]*coeff[1]+win[1][0]*coeff[2]+win[1][1]*coeff[3];
		if(row>=1&&col>=1){

				c<<tmp;

				}
		//行缓存
		linebuff:for(int i=0;i<=PATCH_COLS;i++){
#pragma HLS UNROLL
			linebuff[i]=i<PATCH_COLS?linebuff[i+1]:in_val;
		}

	}
 }

}
void module_conv21(
		hls::stream<din_t1> &a,
		//const int direction,
		const ap_fixed<4,1,AP_RND,AP_SAT> coeff[4],
		//const ap_int<2>coeff[4],
		hls::stream<dout_t1> &c

){
#pragma HLS DATAFLOW
//#pragma HLS INLINE off

//行缓冲
din_t1 linebuff[PATCH_COLS+1]={0};
//窗口寄存器
 din_t1 win[2][2];
 ConvH:for(int row=0;row<=PATCH_ROWS;row++){
	ConvW:for(int col=0;col<=PATCH_COLS;col++){

#pragma HLS PIPELINE

		din_t1 in_val;
		if(row<PATCH_ROWS&&col<PATCH_COLS)
		in_val=a.read();
		else
		in_val=0;
		dout_t1 tmp=0;
		/*
		//窗口2*2
#pragma HLS ARRAY_PARTITION variable=win complete
		win[0][0]=win[0][1];win[0][1]=linebuff[0];
		win[1][0]=win[1][1];win[1][1]=in_val;
		tmp=win[0][0]*coeff[0]+win[0][1]*coeff[1]+win[1][0]*coeff[2]+win[1][1]*coeff[3];
		//行缓存
#pragma HLS ARRAY_PARTITION variable=linebuff complete
		linebuff_loop:for(int i=0;i<=PATCH_COLS;i++){
#pragma HLS UNROLL
			linebuff[i]=i<PATCH_COLS?linebuff[i+1]:in_val;
		}
		//tmp=win[0][0]*coeff[0]+win[0][1]*coeff[1]+win[1][0]*coeff[2]+win[1][1]*coeff[3];
		if(row>=1&&col>=1)
		c<<tmp;
*/

#pragma HLS ARRAY_PARTITION variable=win complete dim=0
#pragma HLS ARRAY_PARTITION variable=coeff complete dim=0
		winbuff:for(int i=0;i<2;i++){
#pragma HLS UNROLL
		win[i][0]=win[i][1];
		}
		win[0][1]=linebuff[0];
		win[1][1]=in_val;
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				tmp+=win[i][j]*coeff[i*2+j];
		//tmp+=win[i][j]*coeff[i*2+j];
		//tmp=win[0][0]*coeff[0]+win[0][1]*coeff[1]+win[1][0]*coeff[2]+win[1][1]*coeff[3];
		if(row>=1&&col>=1){

				c<<tmp;

				}
		//行缓存
		linebuff:for(int i=0;i<=PATCH_COLS;i++){
#pragma HLS UNROLL
			linebuff[i]=i<PATCH_COLS?linebuff[i+1]:in_val;
		}

	}
 }

}

void model_A1(

		hls::stream<din_t1> &Fx,
		hls::stream<din_t1> &Fy,
		//din_t Fx_buff[COEFF_ROWS*COEFF_COLS],
		//din_t Fy_buff[COEFF_ROWS*COEFF_COLS],
		//hls::stream<din_t> &Ft,
	    //hls::stream<dout_t> &A,
		hls::stream<blockvector1> &A
		//hls::stream<dout_t> &Ft_buff


)
{
#pragma HLS DATAFLOW
		 ap_int<7> hwy=38;
		 ap_int<4> hwx=7;
		  static  ap_int<4> H[ COEFF_ROWS][COEFF_COLS];
		  static ap_int<7> W[COEFF_ROWS][COEFF_COLS];


		H_row_loop:for(int i=0;i<COEFF_ROWS;i++)
			H_col_loop:for(int j=0;j<COEFF_COLS;j++){
#pragma HLS PIPELINE

				H[i][j]=-hwx+1+j;

		}
		W_row_loop:for(int i=0;i<COEFF_COLS;i++)
			W_col_loop:for(int j=0;j<COEFF_ROWS;j++){
#pragma HLS PIPELINE

					W[j][i]=-hwy+1+j;
			}
/*
		din_t Fx_buff[COEFF_ROWS*COEFF_COLS];
		din_t Fy_buff[COEFF_ROWS*COEFF_COLS];


//#pragma HLS dependence variable=Fx_buff inter false
//#pragma HLS dependence variable=Fy_buff inter false
		Fx_buff_row_loop:for(int m=0;m<COEFF_ROWS;m++){
			Fx_buff_col_loop:for(int n=0;n<COEFF_COLS;n++){
#pragma HLS PIPELINE

				Fx_buff[m*COEFF_COLS+n]=Fx.read();

			    Fy_buff[m*COEFF_COLS+n]=Fy.read();


			}

		}
*/

//dout_t A_[A_ROWS][A_COLS];
hls::stream<dout_t1> Fx1("Fx1");
#pragma HLS STREAM variable=Fx1 depth=975 dim=1
hls::stream<dout_t1> Fx2("Fx2");
#pragma HLS STREAM variable=Fx2 depth=975 dim=1
hls::stream<dout_t1> Fx3("Fx3");
#pragma HLS STREAM variable=Fx3 depth=975 dim=1

hls::stream<dout_t1> Fy1("Fy1");
#pragma HLS STREAM variable=Fy1 depth=975 dim=1

hls::stream<dout_t1> Fy2("Fy2");
#pragma HLS STREAM variable=Fy2 depth=975 dim=1

hls::stream<dout_t1> Fy3("Fy3");
#pragma HLS STREAM variable=Fy3 depth=975 dim=1
split_flow1(Fx,Fy,Fx1,Fy1,Fx2,Fy2,Fx3,Fy3,COEFF_ROWS,COEFF_COLS);

//#pragma HLS ARRAY_PARTITION variable=A_ cyclic factor=6 dim=2
//#pragma HLS ARRAY_PARTITION variable=A_ complete dim=2//solution9
		Fxh_row_loop:for(int m=0;m<COEFF_ROWS;m++){
			Fxh_col_loop:for(int n=0;n<COEFF_COLS;n++){
din_type tmp[6];
blockvector1 tmpa;
#pragma HLS ARRAY_PARTITION variable=tmp complete dim=1//solution9
#pragma HLS PIPELINE
//#pragma HLS UNROLL  factor=13//solution9
				/*
											A_[m*COEFF_COLS+n][0]=Fx1.read();
										    A_[m*COEFF_COLS+n][1]=Fx2.read()*H[m][n];
											A_[m*COEFF_COLS+n][2]=Fx3.read()*W[m][n];
											A_[m*COEFF_COLS+n][3]=Fy1.read();
											A_[m*COEFF_COLS+n][4]=Fy2.read()*H[m][n];
											A_[m*COEFF_COLS+n][5]=Fy3.read()*W[m][n];
											*/
															tmp[0]=Fx1.read();
														    tmp[1]=Fx2.read()*H[m][n];
														    tmp[2]=Fx3.read()*W[m][n];
														    tmp[3]=Fy1.read();
														    tmp[4]=Fy2.read()*H[m][n];
														    tmp[5]=Fy3.read()*W[m][n];
														    //A<<tmp[0]<<tmp[1]<<tmp[2]<<tmp[3]<<tmp[4]<<tmp[5];
														    for(int k=0;k<A_COLS;k++){
														    //#pragma HLS PIPELINE

														    	//A_[m*COEFF_COLS+n][k]=tmp[k];
														    	tmpa.a[k]=tmp[k];
														    		}
														    A.write(tmpa);
					}
				}
}

void cholesky_inverse1(hls::stream<blockvector1>&a,hls::stream<blockvector1>&inv_a){
	//DTYPE1 p_i [A_COLS][A_COLS];
	//dout_t p_i2 [A_COLS][A_COLS];
	//DTYPE1 inverse_p_i[ROWS_COLS_A][ROWS_COLS_A];
	float p_i [A_COLS][A_COLS];
		//dout_t p_i2 [A_COLS][A_COLS];
	float inverse_p_i[ROWS_COLS_A][ROWS_COLS_A];
//#pragma HLS DATAFLOW
	//hls::stream<blockvector>inv_p_i_stream("inv_p_i_stream");
	 int inverse_OK=0;
	 blockvector1 pv;
#pragma HLS ARRAY_PARTITION variable=pv.a complete dim=1
//#pragma HLS RESOURCE variable=pv.a core=RAM_2P_BRAM
#pragma HLS ARRAY_PARTITION variable=p_i complete dim=1
//#pragma HLS ARRAY_PARTITION variable=p_i complete dim=2

	    choledatain:for(int i=0;i<A_COLS;i++){
//#pragma HLS PIPELINE
		    	 //blockvector1 pv=a.read();
		    	 for(int j=0;j<A_COLS;j++){
#pragma HLS PIPELINE
		    		 if(j==0)
		    			 pv=a.read();
		    		 p_i[j][i]=pv.a[j];
		    		// p_i[i][j]=pv.a[j];
		    	 }
		     }

		     //hls::cholesky_inverse_top<ROWS_COLS_A,CHOL_INV_CONFIG_FAST,MATRIX_IN_T, MATRIX_OUT_T>(p_i, inverse_p_i, inverse_OK);

		     //mmult_accel1_stream(a3,Ft, q_i_stream);

			  //hls::matrix_multiply_top<hls::NoTranspose,hls::NoTranspose, A_COLS, A_ROWS, A_ROWS, 2, A_COLS, 2,MULTIPLIER_CONFIG2, din_t, dout_t> (at_i2,Ft_1, q_i);
			//  hls::cholesky_inverse_top<ROWS_COLS_A,CHOL_INV_CONFIG_FAST,MATRIX_IN_T1, MATRIX_OUT_T1>(p_i, inverse_p_i, inverse_OK);
	    hls::cholesky_inverse_top<ROWS_COLS_A,CHOL_INV_CONFIG_FAST,float, float>(p_i, inverse_p_i, inverse_OK);
			  //task11
			  //output :A'*A
		      // Call multiplier caculate A'*Ft
#pragma HLS ARRAY_PARTITION variable=inverse_p_i complete dim=1
//#pragma HLS ARRAY_PARTITION variable=inverse_p_i complete dim=2
blockvector1 inv_pv;
#pragma HLS ARRAY_PARTITION variable=inv_pv.a  complete dim=1
			 choledataout:for(int i=0;i<A_COLS;i++){
//#pragma HLS PIPELINE
			 	    	    	 //blockvector1 inv_pv;
			 	    	    	 for(int j=0;j<A_COLS;j++){
#pragma HLS PIPELINE
			 	    	    		inv_pv.a[j]=MATRIX_OUT_T1(inverse_p_i[j][i]);
			 	    	    		//inv_pv.a[j]=round(16<<double(inverse_p_i[j][i]))>>16;
			 	    	    		//inv_pv.a[j]=inverse_p_i[i][j];
			 	    	    	 }
			 	    	    	 inv_a.write(inv_pv);
			 	    	     }
}

void  system1 (
				hls::stream<din_t1> &patch1,
				hls::stream<din_t1> &patch2,
				//din_t patch1_i[PATCH_ROWS*PATCH_COLS],
				//din_t patch2_i[PATCH_ROWS*PATCH_COLS],
				hls::stream<dout_type> &u

				//dout_type u[A_COLS]
)
{
//Interface Behavior
//#pragma HLS INTERFACE axis port=patch1_i
//#pragma HLS INTERFACE axis port=patch2_i
#pragma HLS INTERFACE axis port=patch1
#pragma HLS INTERFACE axis port=patch2
#pragma HLS INTERFACE axis port=u

//Interface Mapping
//#pragma HLS RESOURCE variable=patch1  core=AXIS bundle= INPUT_STREAM
//#pragma HLS RESOURCE variable=patch2   core=AXIS bundle= OUTPUT_STREAM
#pragma HLS INTERFACE s_axilite port=return bundle=CONTROL_BUS
#pragma HLS DATAFLOW
//#pragma HLS INLINE region

	hls::stream<dout_t1> Fx("Fx");
#pragma HLS STREAM variable=Fx depth=975 dim=1
	hls::stream<dout_t1> Fy("Fy");
#pragma HLS STREAM variable=Fy depth=975 dim=1
	hls::stream<dout_t1> Ft("Ft");
#pragma HLS STREAM variable=Ft depth=975 dim=1
	//hls::stream<dout_t> Ft_1("Ft_1");
	//hls::stream<dout_t> Ft_2("Ft_2");
	hls::stream<blockvector1> A("A");
#pragma HLS STREAM variable=A depth=975 dim=1
	//hls::stream<dout_t> A_1("A_1");
	//hls::stream<dout_t> A_2("A_2");
	//hls::stream<dout_t> AT("AT");
//#pragma HLS STREAM variable=Fx depth=2587 dim=1
//#pragma HLS STREAM variable=Fy depth=2587 dim=1
//#pragma HLS STREAM variable=Ft depth=2587 dim=1
//#pragma HLS STREAM variable=Ft_1 depth=2587 dim=1
//#pragma HLS STREAM variable=A depth=15522 dim=1
//#pragma HLS STREAM variable=A_1 depth=15522 dim=1
//#pragma HLS STREAM variable=AT depth=15522 dim=1
	//dout_t Ft_buff[A_ROWS];



	//gradient1(patch1,patch2,Fx,Fy,Ft);

	hls::stream<dout_t1> x1("x1");
	 #pragma HLS STREAM variable=x1 depth=1155 dim=1
	 hls::stream<dout_t1> x2("x2");
	 #pragma HLS STREAM variable=x2 depth=1155 dim=1
	 hls::stream<dout_t1> y1("y1");
	 #pragma HLS STREAM variable=y1 depth=1155 dim=1
	 hls::stream<dout_t1> y2("y2");
	 #pragma HLS STREAM variable=y2 depth=1155 dim=1
	 hls::stream<dout_t1> t1("t1");
	 #pragma HLS STREAM variable=t1 depth=1155 dim=1
	 hls::stream<dout_t1> t2("t2");
	 #pragma HLS STREAM variable=t2 depth=1155 dim=1
	 hls::stream<dout_t1> fx1("fx1");
	 #pragma HLS STREAM variable=fx1 depth=1155 dim=1
	 hls::stream<dout_t1> fx2("fx2");
	 #pragma HLS STREAM variable=fx2 depth=1155 dim=1
	 hls::stream<dout_t1> fy1("fy1");
	 #pragma HLS STREAM variable=fy1 depth=1155 dim=1
	 hls::stream<dout_t1>fy2("fy2");
	 #pragma HLS STREAM variable=fy2 depth=1155 dim=1
	 hls::stream<dout_t1>ft1("ft1");
	 #pragma HLS STREAM variable=ft1 depth=1155 dim=1
	 hls::stream<dout_t1> ft2("ft2");
	 #pragma HLS STREAM variable=ft2 depth=1155 dim=1
	// hls::stream<din_t1> &patch1_i=patch1;
	// hls::stream<din_t1> &patch2_i=patch2;
	 split_flow1(patch1,patch2,x1,x2,y1,y2,t1,t2,PATCH_ROWS,PATCH_COLS);


	 const  ap_fixed<4,1,AP_RND,AP_SAT> coeffx[4]={0.25,-0.25,0.25,-0.25};
	 const  ap_fixed<4,1,AP_RND,AP_SAT> coeffy[4]={0.25,0.25,-0.25,-0.25};
	 const  ap_fixed<4,1,AP_RND,AP_SAT> coefft[4]={0.25,0.25,0.25,0.25};
	 //const  ap_int<2> coeffx[4]={1,-1,1,-1};
	 //const  ap_int<2> coeffy[4]={1,1,-1,-1};
	 //const  ap_int<2> coefft[4]={1,1,1,1};
	 proc_conv:{
	 	module_conv21(t1,coefft,ft1);
	 	module_conv21(t2,coefft,ft2);

	 	module_conv21(y1,coeffy,fy1);
	 	module_conv21(y2,coeffy,fy2);

	 	module_conv21(x1,coeffx,fx1);
	 	module_conv21(x2,coeffx,fx2);
	 }

	 gradient_row_loop:for(int i=0;i<PATCH_ROWS;i++){
	 	gradient_col_loop:for(int j=0;j<PATCH_COLS;j++){
	 #pragma HLS PIPELINE

	 					dout_t1 tmp1,tmp2,tmp3;
	 					tmp1=fx1.read()+fx2.read();
	 					tmp2=fy1.read()+fy2.read();
	 					tmp3=ft2.read()-ft1.read();
	 					if(i>0&&i<=COEFF_ROWS&&j>0&&j<=COEFF_COLS)
	 					{
	 						Fx<<tmp1;
	 						Fy<<tmp2;
	 						Ft<<tmp3;
	 		             }
	 			 }
	 }

	model_A1(Fx,Fy,A);

	//middle1(A,Ft,u);

    int inverse_OK=0;
	     hls::stream<blockvector1>a1("a1");
#pragma HLS STREAM variable=a1 depth=975 dim=1
	     hls::stream<blockvector1>a2("a2");
#pragma HLS STREAM variable=a2 depth=975 dim=1
	     hls::stream<blockvector1>a3("a3");
#pragma HLS STREAM variable=a3 depth=975 dim=1
	     hls::stream<blockvector1>p_i_stream("p_i_stream");
#pragma HLS STREAM variable=p_i_stream depth=6 dim=1
	     hls::stream<blockvector1>inv_p_i_stream("inv_p_i_stream");
#pragma HLS STREAM variable=inv_p_i_stream depth=6 dim=1
	     hls::stream<DTYPE1>q_i_stream("q_i_stream");
#pragma HLS STREAM variable=q_i_stream depth=6 dim=1
	     //hls::stream<dout_type>u_i_stream("u_i_stream");
	     for(int i=0;i<A_ROWS;i++){
#pragma HLS PIPELINE
	    	 blockvector1 av=A.read();
	    	 a1.write(av);
	    	 a2.write(av);
	    	 a3.write(av);
	     }




	     mmult_accel_stream1(a1,a2,p_i_stream);




	     mmult_accel1_stream1(a3,Ft, q_i_stream);


	     cholesky_inverse1(p_i_stream,inv_p_i_stream);

		 mmult_accel2_stream1(inv_p_i_stream, q_i_stream, u);

//for(int i=0;i<A_COLS;i++)
	//u[i]=u_i_stream.read();

}
#include "block_proc.h"
#include<iostream>
#include<iomanip>
#include<fstream>
//#include "hls/linear_algebra/utils/x_hls_matrix_utils.h"
//#include "hls/linear_algebra/utils/x_hls_matrix_tb_utils.h"
using namespace std;
int main()
{

	hls::stream<din_t1> src1("src1");
	hls::stream<din_t1> src2("src2");
	hls::stream<din_t1> src3("src3");
    hls::stream<din_t1> src4("src4");
    //hls::stream<din_t1> src5("src5");
    //hls::stream<din_t1> src6("src6");

	hls::stream<dout_type> dst1("dst1");
	hls::stream<dout_type> dst2("dst2");
	//hls::stream<dout_type> dst3("dst3");

		 din_t1 d_i1[ PATCH_ROWS*PATCH_COLS];
		 din_t1 d_i2[ PATCH_ROWS*PATCH_COLS];
		  din_t1 d_i3[ PATCH_ROWS*PATCH_COLS];
		  din_t1 d_i4[ PATCH_ROWS*PATCH_COLS];
		  dout_type u[ A_COLS];

		  ifstream file1;
		  				  file1.open("tb_data/1st_patch1.dat");
		  				 for (int i = 0;i < PATCH_ROWS; i++) {
		  				 	 for (int j = 0;j < PATCH_COLS; j++) {
		  				 		 file1>>d_i1[i*PATCH_COLS+j];
		  				 	 }
		  				  }
		  				  file1.close();
		  				//for (int i = 0;i < 10; i++)
		  				//  cout<<d_i1[76*15+i]<<"                   ";


		  				 // delete []d_i1;
		  				  for (int i = 0;i < PATCH_ROWS; i++) {
		  				 		 	 for (int j = 0;j < PATCH_COLS; j++) {
		  				 		 		// src1<<d_i1[i*PATCH_COLS+j];
		  				 		 		 src1<<d_i1[i*PATCH_COLS+j];
		  				 		 		src3<<d_i1[i*PATCH_COLS+j];
		  				 		 	 }
		  				 		  }
		  				//for (int i = 0;i < 10; i++)
		  				//		  				  cout<<src1.read()<<"                   ";
		  				//cout<<endl;
		  				 //delete []d_i1;
		  				  ifstream file2;
		  				 		  file2.open("tb_data/1st_patch2.dat");
		  				 		  //din_t data_input[ PATCH_ROWS][PATCH_COLS];
		  				 		  //dout_t data_output[A_ROWS][A_COLS];
		  				 		 //dout_t data_output_expected[ PATCH_ROWS][PATCH_COLS];

		  				 		 for (int i = 0;i < PATCH_ROWS; i++) {
		  				 		 	 for (int j = 0;j < PATCH_COLS; j++) {
		  				 		 		 file2>>d_i2[i*PATCH_COLS+j];
		  				 		 	 }
		  				 		  }
		  				 file2.close();
		  				 for (int i = 0;i < PATCH_ROWS; i++) {
		  						 		 	 for (int j = 0;j < PATCH_COLS; j++) {
		  						 		 		 src4<<d_i2[i*PATCH_COLS+j];
		  						 		 		src2<<d_i2[i*PATCH_COLS+j];
		  						 		 	//src6<<d_i2[i*PATCH_COLS+j];
		  						 		 	 }
		  						 		  }
		  				system2(src1,src2,dst1);

		  				system2(src3,src4,dst2);
		  					dout_type data_output1[6];
		  					dout_type data_output2[6];
		  					//dout_type data_output3[6];
		  				    dout_type data_output_expected[6];

		  					//dout_t data_output[6];
		  					//dout_t data_output_expected[6];
		  					//cout<<precision(5);


		  					cout<<endl;
		  					 for (int i = 0;i <6; i++){
		  									data_output2[i]=dst2.read();
		  					 data_output1[i]=dst1.read();
		  					// data_output3[i]=dst3.read();
		  					 }
		  					 for (int i = 0;i <A_COLS; i++) {
		  					 		 		 cout<<fixed<<setprecision(12)<<data_output1[i]<<"                  ";

		  					 		 		  				  }

		  					 cout<<endl;
		  					 for (int i = 0;i <A_COLS; i++) {
		  					 		 cout<<fixed<<setprecision(12)<<data_output2[i]<<"                  ";

		  					 		  				  }



0 Kudos
1 Solution

Accepted Solutions
Visitor allenlin
Visitor
45 Views
Registered: ‎07-22-2019

Re: debug:same data but different result,how it happend?

Jump to solution

The problem was from the qualifier static in the mult,where the veriable must be clear to 0 in the end .

0 Kudos
1 Reply
Visitor allenlin
Visitor
46 Views
Registered: ‎07-22-2019

Re: debug:same data but different result,how it happend?

Jump to solution

The problem was from the qualifier static in the mult,where the veriable must be clear to 0 in the end .

0 Kudos