To transfer a double precision matrix by PYNQ

  • PYNQ version & Board name & Tool Version
  • Full details of the error message you see, or a detailed description of the problem you experience.
  • Steps to reproduce the problem, and if needed: source code and bitstream or any relevant files
  • Debug steps that you have taken to resolve the problem →
    Hi to whom it may concern,

I am using a xc7z020clg400-1 to accomplish my project as a matrix calculation.
But for now, it is facing a transport problems as my following code.
This code model was original modified to transfer a float matrix, and i rewrite them to make it more accuracy.
I have tried my main calculator was able to print out the results as float type.
And here are the codes below:
test.cpp:

extern "C" {
void calculator(hls::stream<axis_t> &in, hls::stream<axis_t> &out) {
#pragma HLS INTERFACE s_axilite port = return bundle = control
#pragma HLS INTERFACE axis port = in
#pragma HLS INTERFACE axis port = out

	DataType l_A[N2];
	DataType l_C[N2];

#pragma HLS ARRAY_PARTITION variable = l_A dim = 1
#pragma HLS ARRAY_PARTITION variable = l_C dim = 1

	int j_limit = 1024 / DataTypeSize;
	int i_limit = 3;
	converter_t converter;

load_A:
	for (int i = 0; i <= i_limit; i++) {
		axis_t temp = in.read();
		for (int j = 0; j < j_limit; j++) {
			int high = j * DataTypeSize + DataTypeSize - 1;
			int low = j * DataTypeSize;
			int index = i * 16 + j;

			//converter.i = temp.data.range(high, low);
			//l_A[index] = converter.d;
			l_A[index] = temp.data.range(high, low);
		}
	}


	main<DataType>(l_A, l_C); 

writeC:
	for (int i = 0; i <= i_limit; i++) {
		axis_t temp;
		for (int j = 0; j < j_limit; j++) {
			int high = j * DataTypeSize + DataTypeSize - 1;
			int low = j * DataTypeSize;
			converter.d = l_C[ i * 16 + j ];
			temp.data.range(high, low) = converter.i;
		}
		ap_uint<1> last = 0;
		if (i == i_limit) {
			last = 1;
		}
		temp.last = last;
		temp.keep = -1; // enabling all bytes
		out.write(temp);
	}
}

}

here is the .h file:

#ifndef _MMULT_
#define _MMULT_

#include "ap_axi_sdata.h"
#include "ap_int.h"
#include <inttypes.h>

#define N 8
#define N2 64 // N*N

#define	S4  6     //Column of A in Controller
#define	S5  12    //Column of A in Controller *2
#define	S6  2     //Line of B in Controller

#define DWIDTH 1024
typedef ap_axiu<DWIDTH, 0, 0, 0> axis_t;

typedef ap_uint<1024> uint1024_t;
typedef double DataType;

const int DataTypeSize = sizeof(DataType) * 8;

typedef ap_uint<DataTypeSize> DataTypeInt;

typedef union {
  double d;
  uint64_t i;
} converter_t;

converter_t converter;

template <typename T>
void main(T a[N2], T b[N2]);

#endif

And last here is my testbench:

#include "matmult.h"
//#include "test.cpp"


int main(void)
{

  DataType matOp1[N2]={0};
  DataType matMult_hw[N2]={1};

 main <double>(matOp1, matMult_hw);

  return 0;
}

If there is any possible error, please feel free to comment here.
Thank you for click in my topic!

1 Like

Are you using PYNQ for this project?
If not, you may be better posting on the Xilinx forums

Cathal