伙计们,我需要有关如何在 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);
干杯!