うまくいったっぽいけど、このHLSが何をやっているか理解していなかった
https://forums.xilinx.com/t5/Vivado-High-Level-Synthesis-HLS/Problem-with-AXI-Stream-write-in-Vivado-HLS/td-p/712975
HLS
#include <string.h> void topFunc(volatile char *a){ #pragma HLS INTERFACE m_axi depth=2000 port=a offset=slave #pragma HLS INTERFACE s_axilite port=return bundle=AXILiteS int i; char buff[2000]; memcpy(buff,(const char*)a,2000); for (int i = 0; i < 2000; i++) { buff[i] = buff[i]+10; } memcpy((char *)a,buff,2000); }
#include <stdio.h> #include "platform.h" #include "xil_printf.h" #include "xtopfunc.h" #define SIZE 20480 u32 *test; u32 *test2; XTopfunc xTopfunc; int main() { //init platform and the axi lite driver that is generated by the synthesis xil_printf("\r\n----------PROGRAM ENDED.-------------------\r\n"); xil_printf("array size: %d\r\n",SIZE); Xil_DCacheEnable(); int Status; Status = XTopfunc_Initialize(&xTopfunc, XPAR_TOPFUNC_0_DEVICE_ID); if (Status != XST_SUCCESS){ return XST_FAILURE; } for(int i=0;i<SIZE;i++){ test[i] = 1; } XTopfunc_Set_a(&xTopfunc, test); //set the data to process Xil_DCacheFlush(); //wait if interrupt appears, so the processing is done //enable interrupts and call the delivered *_start function xil_printf("Receive via DMA.\r\n"); test2 = XTopfunc_Get_a(&xTopfunc); //get the results Xil_DCacheInvalidate(); for(int i=0;i<SIZE;i++){ if(test[i]!=test2[i]) xil_printf("DMA test failed\r\n"); } xil_printf("DMA test success.\r\n"); xil_printf("----------PROGRAM ENDED.-------------------\r\n"); cleanup_platform(); return 0; }
----------PROGRAM ENDED.------------------- array size: 32 Receive via DMA. DMA test success. ----------PROGRAM ENDED.------------------- ----------PROGRAM ENDED.------------------- array size: 256 Receive via DMA. DMA test success. ----------PROGRAM ENDED.------------------- ----------PROGRAM ENDED.------------------- array size: 4096 Receive via DMA. DMA test success. ----------PROGRAM ENDED.------------------- ----------PROGRAM ENDED.------------------- array size: 65536 ----------PROGRAM ENDED.------------------- array size: 4097 Receive via DMA. DMA test success. ----------PROGRAM ENDED.------------------- ----------PROGRAM ENDED.------------------- array size: 20480 Receive via DMA. DMA test success. ----------PROGRAM ENDED.-------------------