1.函数定义
函数接口定义了进入library的入口点,里面有一个函数或多个函数,用户可以在应用程序中调用这些函数进入RTL创建的IP。函数定义包含的是空的函数体,因为sdsoc编译器可以用API调用替换他们去执行与IP之间的数据传输。除了空函数体,函数定义还必须包括#include stdlib.h和stdio.h,在替换和编译函数体时要用到他们。下面是xilinx例程里面函数定义的源码:
#include <stdio.h>
#include <stdlib.h>
#include "arraycopy.h"
// Copy M values from array a to array b, or N (max array size)
// values if M < 0 or M > N.
//
// Array arguments are mapped onto axis interfaces amenable to axi_dma_sg,
// axi_dma_simple and axi_fifo datamovers, or direct connections.
//
// The transfer size M is passed to the hardware function with the
// axi_lite datamover.
//
// @return max transferred value
//
// See arraycopy.fcnmap.xml for the software/hardware interface mapping.
//
// SDSoC will use this function definition to create a stub function to
// control the IP and transfer data between CPU and hardware function, and
// rewrite any calling code to invoke the generated stub in lieu of this
// function.
//
// For more information on importing HDL IP, refer to
// UG1027 - Introduction to SDSoC, Chapter 16
// UG1146 - SDSoC Platforms and Libraries, Chapter 2
//
int arraycopy_axis(int A[N], int B[N], int M)
{
// This function body can be non-empty if you want to provide a software
// implemenation, but currently SDSoC does not support both hardware
// and software implementations of the same function within the same
// application.
}