Send multiple arrays as input argument

I am trying to create a custom IP using Vivado HLS so as to explore the PYNQ Z2 Board provided by TUL. In this IP, I am trying to send two arrays of the same size, A[N] and B[N], as input to the IP, and then the IP would return an output array, C[N] where,

C[i] = A[i] + B[i]

Is it possible to send two input arrays to the board? How can I do it?

Things I have tried:

  1. I tried to use the AXI Stream Interface and it works with one input array but I do not how to proceed with two input arrays. Should I use two DMAs? One for each input array? How should the HLS code be altered in that case?

  2. Pynq custom overlay of multidimensional array calculation using vivado hls – Using the AXILITE Interface as suggested works but it is tedious, is there any better method?

1 Like

you can intercalate the 2 arrays and send it via 1 axi-stream. Or even easier: encode both arrays in one [2]x[n] (or [n]x[2) ]array. In HLS, you then read the stream twice before you work your mathemagics. Another, possibly faster, solution would be to encode the 2 arrays in a double bitwidth array eg.: A and B being arrays of 32b integers or floats or whatever. you encode A in bits 63~32 and B in bits 31~0. AXI HP ports allow for 64b wide transfers. Depending on where you want to do most of the processing, or if a little bit higher latency is a problem you may want to use one or the other solution.

below is an exerpt (probably horribly inefficient) of a convert to grayscale HLS core. On the PS, you just open an image, put it in a [n]x[m]x[3] array and stream it to PL.


#include “cvt2gray.h”

void cvtgray(int xres, int yres,axi_stream& img_in, axi_stream& img_out){

#pragma HLS PIPELINE II=2
#pragma HLS INTERFACE s_axilite port=yres
#pragma HLS INTERFACE s_axilite port=xres
#pragma HLS INTERFACE axis port=img_in
#pragma HLS INTERFACE axis port=img_out
#pragma HLS interface s_axilite port=return

axi_pixel pix_in1_r,pix_in1_g,pix_in1_b;
axi_pixel pix_out_r,pix_out_g,pix_out_b;
uint8_t r1,g1,b1,gray1;

for(int i=0;i<yres;i++){
#pragma HLS LOOP_TRIPCOUNT min=1 max=4000

for (int j=0;j<xres;j++){

#pragma HLS LOOP_TRIPCOUNT min=1 max=4000
pix_in1_r=img_in.read();
pix_in1_g=img_in.read();
pix_in1_b=img_in.read();

//insert mathemagic here…
r1=pix_in1_r.data0.11;
g1=pix_in1_g.data
0.59;
b1=pix_in1_b.data*0.30;


the .h file:

#include <stdio.h>
#include <stdint.h>
#include “hls_stream.h”
#include “hls_video.h”
#include “ap_utils.h”
#include “ap_fixed.h”
#include “ap_int.h”

#define max_width 1920
#define max_height 1200
typedef ap_axiu<8,2,5,6> axi_pixel;
typedef hls::stream<axi_pixel> axi_stream;
void cvtgray(int xres, int yres,axi_stream& img_in, axi_stream& img_out);