您当前的位置: 首页 > 

FPGA硅农

暂无认证

  • 0浏览

    0关注

    282博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Zynq开发-通过寄存器读写调用HLS IP核

FPGA硅农 发布时间:2020-12-20 20:09:33 ,浏览量:0

一般情况下,在使用Vivado HLS工具将设计导出为RTL IP时,会附带一个在Xilinx SDK中调用HLS IP核的驱动程序,我们可以直接使用已经写好的驱动程序来使用PL端的ip来为我们做一些计算,本文则旨在直接通过读写寄存器来进行HLS IP的调用。 HLS IP的设计流程以及Vivado中的Block Deisgn在这里略去,主要讲如何使用寄存器来控制我们的IP。 首先我们在system.hdf中查看HLS IP核的寄存器地址: 在这里插入图片描述 因为不使用中断,我们主要关心以下三个寄存器地址 在这里插入图片描述 在HLS提供的驱动文件中,我们能看到更详细的信息 在这里插入图片描述 可以看到,控制信号中,低4位分别是ap_ready、ap_idle、ap_done和ap_start信号,第8位(也就是bit7)是自动重启的信号。因此,我们可以编写如下代码调用HLS IP:

/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc.  All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/

/*
 * helloworld.c: simple test application
 *
 * This application configures UART 16550 to baud rate 9600.
 * PS7 UART (Zynq) is not initialized by this application, since
 * bootrom/bsp configures it to baud rate 115200
 *
 * ------------------------------------------------
 * | UART TYPE   BAUD RATE                        |
 * ------------------------------------------------
 *   uartns550   9600
 *   uartlite    Configurable only in HW design
 *   ps7_uart    115200 (configured by bootrom/bsp)
 */

#include 
#include "platform.h"
#include "xil_printf.h"
#include "xparameters.h"
#include "xmy_cnn.h"
#include"xil_cache.h"
#include "xil_io.h"

u32 myip_isdone(int addr){
	u32 Data;
	Data=Xil_In32(addr);
	return (Data >> 1) & 0x1;
}


int main()
{
    //u32 a=0x10000000;
    //u32 b=0x10001000;
	int* a=(int*)malloc(sizeof(int)*20);
	int* b=(int*)malloc(sizeof(int)*20);
	//int a[30];
	//int b[30];
    int i;
	init_platform();
    for(i=0;i> 1) & 0x1)
    		break;
    }
    Xil_DCacheInvalidateRange((u32)b,20*sizeof(int));
    for(i=0;i> 1) & 0x1;
}


int main()
{
    //u32 a=0x10000000;
    //u32 b=0x10001000;
	//int* a=(int*)malloc(sizeof(int)*20);
	//int* b=(int*)malloc(sizeof(int)*20);
	int a[20];
	int b[20];
    int i;
	init_platform();
    for(i=0;i> 1) & 0x1)
    		break;
    }
    Xil_DCacheInvalidateRange((u32)b,20*sizeof(int));
    for(i=0;i> 1) & 0x1;
}


int main()
{
    //u32 a=0x10000000;
    //u32 b=0x10001000;
	int* a=(int*)malloc(sizeof(int)*20);
	int* b=(int*)malloc(sizeof(int)*20);
	//int a[20];
	//int b[20];
    int i;
	init_platform();
    for(i=0;i> 2) & 0x1)
    		break;
    }
    Xil_Out32(0x43c00010,(u32)a);
    Xil_Out32(0x43c00018,(u32)b);
    Xil_Out32(0x43c00000,(u32)0x01);
    while(1){
    	u32 Data;
    	Data=Xil_In32(0x43c00000);
    	if((Data >> 1) & 0x1)
    		break;
    }
    Xil_DCacheInvalidateRange((u32)b,20*sizeof(int));
    for(i=0;i> 1) & 0x1;
}


int main()
{
    //u32 a=0x10000000;
    //u32 b=0x10001000;
	//int* a=(int*)malloc(sizeof(int)*20);
	//int* b=(int*)malloc(sizeof(int)*20);
	int a[20];
	int b[20];
    int i;
	init_platform();
    for(i=0;i> 2) & 0x1)
    		break;
    }
    Xil_Out32(0x43c00010,(u32)a);
    Xil_Out32(0x43c00018,(u32)b);
    Xil_Out32(0x43c00000,(u32)0x01);
    while(1){
    	//volatile u32 Data
    	u32 Data2;
    	Data2=Xil_In32(0x43c00000);
    	if((Data2 >> 1) & 0x1)
    		break;
    }
    Xil_DCacheInvalidateRange((u32)b,20*sizeof(int));
    Xil_DCacheInvalidateRange((u32)a,20*sizeof(int));
    for(i=0;i            
关注
打赏
1658642721
查看更多评论
0.0437s