PC平台:WINDOWS 10 64位
Xilinx设计开发套件:Xilinx_vivado_sdk_2015.4
开发板:Zed Board
1、打开学习笔记四构建的vivado项目,打开block design,把学习笔记六导出的FAST corner IP添加进来
2、add ip,把hls_fast_corner添加到block design,再添加一个VDMA连接起来
3、导出Hardware,启动SDK
4、初始化hls_fast_corner
int status = XHls_fast_corner_Initialize(&fast_corner, XPAR_HLS_FAST_CORNER_DEVICE_ID);
if(0 != status)
{
printf("XHls_fast_corner_Initialize failed");
}
XHls_fast_corner_SetRows(&fast_corner, 1024);
XHls_fast_corner_SetCols(&fast_corner, 1280);
XHls_fast_corner_SetThrehold(&fast_corner, 100);
XHls_fast_corner_DisableAutoRestart(&fast_corner);
XHls_fast_corner_InterruptGlobalDisable(&fast_corner);
init_hls_fast_corner_dma(1280, 1024, VIDEO_BASEADDR, HLS_VDMA_MM2S_ADDR);
DDRVideoWr(HLS_VDMA_MM2S_ADDR, 1280, 1024);
XHls_fast_corner_Start(&fast_corner);
VDMA的初始化如下
void init_hls_fast_corner_dma(unsigned int width, unsigned int height,
unsigned int s2mm_addr, unsigned int mm2s_addr)
{
Xil_Out32(XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + 0x30, 0x4); //reset S2MM VDMA Control Register
Xil_Out32(XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + 0x30, 0x8); //genlock
Xil_Out32(XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + 0xAC, s2mm_addr);//S2MM Start Addresses
Xil_Out32(XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + 0xAC+4, s2mm_addr);
Xil_Out32(XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + 0xAC+8, s2mm_addr);
Xil_Out32(XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + 0xA4, width*4);//S2MM Horizontal Size
Xil_Out32(XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + 0xA8, width*4);//S2MM Frame Delay and Stride
Xil_Out32(XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + 0x30, 0x3);//S2MM VDMA Control Register
Xil_Out32(XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + 0xA0, height);//S2MM Vertical Size start an S2M
Xil_DCacheFlush();
Xil_Out32((XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + AXI_VDMA_REG_DMA_CTRL),0x00000003); // enable circular mode
Xil_Out32((XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + AXI_VDMA_REG_START_1),mm2s_addr); // start address
Xil_Out32((XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + AXI_VDMA_REG_START_2),mm2s_addr); // start address
Xil_Out32((XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + AXI_VDMA_REG_START_3),mm2s_addr); // start address
Xil_Out32((XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + AXI_VDMA_REG_FRMDLY_STRIDE),(width*4)); // h offset
Xil_Out32((XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + AXI_VDMA_REG_H_SIZE),(width*4)); // h size
Xil_Out32((XPAR_AXI_FAST_CORNER_VDMA_BASEADDR + AXI_VDMA_REG_V_SIZE),height); // v size
Xil_DCacheFlush();
}
if(XHls_fast_corner_IsDone(&fast_corner))
{
//memcpy(VIDEO_BASEADDR, HLS_VDMA_S2MM_ADDR, 1280*1024*4);
threhold--;
if(threhold == 0)
threhold = 300;
XHls_fast_corner_SetThrehold(&fast_corner, threhold);
XHls_fast_corner_Start(&fast_corner);
}
同理,sobel的测试步骤也一样,效果如下
代码