如何在SDK中将数组/指针传递给HLS IP

时间:2017-12-22 18:01:59

标签: sdk xilinx vivado vivado-hls

民间, 我需要有关如何在SDK中将数组/指针传递给HLS IP的帮助。我知道如果它是标量值,我可以使用<> _get / set(* Instance)函数,但是当你想要将内存区域作为数组/指针传递时,该怎么做。我厌倦了以下但没有成功。

#define DRAM_ADDR 0x00100000
u32 val;
u32* DRAM = (u32*)DRAM_ADDR;
XSimple_ddr simple_ddr;
int* res_hw;
memcpy(DRAM, data, 100*sizeof(int)); //data is an array with 100 elements

for(int i=0; i<100; i++)
{
   xil_printf("\nRead Memory: %d, %d, %d\n", res_hw[i], DRAM[i], DRAM[i+100]);
}
XSimple_ddr_Set_DRAM(&simple_ddr, DRAM);
XSimple_ddr_Set_num(&simple_ddr, 100);
if (XSimple_ddr_IsReady(&simple_ddr))
   print("HLS peripheral is ready. Starting... ");
else {
   print("!!! HLS peripheral is not ready! Exiting...\n\r");
   exit(-1);
}
XSimple_ddr_Start(&simple_ddr);
print("Detected HLS peripheral complete. Result received.\n\r");
do {
   res_hw = (int*)XSimple_ddr_Get_DRAM(&simple_ddr);
} while (!XSimple_ddr_IsReady(&simple_ddr));
xil_printf("------------------Read after IP------------------------\n");
for(int i=0; i<100; i++)
{
   xil_printf("\nRead Memory: %d, %d, %d", (res_hw[i]), DRAM[i], DRAM[i+100]);

}

IP是:

void simple_ddr(int* DRAM, int num)
{
#pragma HLS INTERFACE m_axi port=DRAM depth=400 offset=slave bundle=DRAMBUS register
#pragma HLS INTERFACE s_axilite port=num bundle=CONFIGBUS register
#pragma HLS INTERFACE s_axilite port=return bundle=CONFIGBUS register

int BRAM[100];
int j;
memcpy(BRAM, DRAM, num*sizeof(int));
int val=0;
for(j=0; j<num; j++)
{
    BRAM[j]=7 + val;
    val++;
}
memcpy(DRAM+num, BRAM, num*sizeof(int));

}

所以我观察到的是以下行返回DDR的基地址,而从(基地址+ num)开始的内存区域没有来自HLS IP的修改数据。

res_hw = (int*)XSimple_ddr_Get_DRAM(&simple_ddr);

干杯!

0 个答案:

没有答案