Accessing BRAM from HLS IP

Hello all,
I am working on the following example in Vitis HLS:

#include <stdio.h>
#include <string.h>

void example(volatile int a[50], int length, int value){
#pragma HLS INTERFACE mode=s_axilite port=a
#pragma HLS INTERFACE mode=s_axilite port=return
#pragma HLS INTERFACE mode=s_axilite port=length
#pragma HLS INTERFACE mode=s_axilite port=value

	int i;
  int buff[50];


  memcpy(buff,(const int*)a,length*sizeof(int));

  for(i=0; i < length; i++){
    buff[i] = buff[i] + value;
  }

  memcpy((int *)a,buff,length*sizeof(int));
}

After exporting RTL in vitis HLS, the address of each port is shown in the following picture:

I want to initialize array a from PS and then the HLS IP will write into it and then I want to read it from PS. I made the following system in Vivado IP integrator:

Now in Pynq, when I read from address 0x100(the base address of array a) it gives me 0:

Can anyone help me with why I got this result?

1 Like

By making the a[50] an axilite, means you need to write all the values of a to the IP via AXI lite.
I would suggest you do it like this:

Allow HLS to read and write from an external interface. In this example the AXI master is connected to PS DRAM.
You can initialize the PS DRAM from software, and pass the address to the HLS IP.

If you really want to do it as you described, you could connect the AXI Master of the HLS IP to one port of a dual port BRAM, and connect the other port of the BRAM to the PS. This would be slower than the first method in most cases, and limits the available memory the HLS IP can access.

Cathal

Thanks @cathalmccabe for your explanation.

If you really want to do it as you described, you could connect the AXI Master of the HLS IP to one port of a dual port BRAM, and connect the other port of the BRAM to the PS. This would be slower than the first method in most cases, and limits the available memory the HLS IP can access.

In this scenario the interface for array a in HLS should be m-axi, right?

1 Like

Yes, like the tutorial I shared.

Cathal

1 Like