硬件:Zedboard
软件:Vivado2018.2 + Win10
本文参考了http://blog.chinaaet.com/cuter521/p/35978的设计
1 设计
功能:PS + PL流水灯
语言:C
流程:创建工程->IP Integrator->综合、实现、生成Bitstream->SDK
2 流程
2.1 创建工程
参考ZedBoard+Vivado(一)
2.2 IP Integrator
IP Integrator是一个图形化、模块化的IP核开发工具,利用该工具可以很方便的开发基于现有芯片或开发板的复杂系统。
首先,在IP INTEGRATOR下选择Create Block Design
在弹出的窗口可以修改Design name,不修改直接OK就行
这样就进入BLOCK DESIGN界面,点击Diagram工具栏或中间的“+”号添加IP核
输入ZYNQ7 Processing System,双击
这样在Diagram里就出现了ZYNQ7 Processing System,继续添加AXI GPIO
在出现了AXI GPIO之后点击Run Block Automation,
这里可以使用预设或用户定制的ZYNQ7 Processing System配置,勾选Apply Board Preset即表示使用预设配置,否则由用户定制。这里采用预设配置,点OK
使用预设配置后,ZYNQ7 Processing System模块会出自动连接DDR和FIXED_IO,并且出现TTC的端口,这些暂时不用去理会,接下来双击AXI_GPIO模块,注意不要双击端口
在IP Configuration里按如下配置修改,点OK
接下来点击Run Connection Automation
这里先将所有端口勾选,然后选定GPIO
在GPIO下选择leds_8bits(LED),点OK
vivado自动为我们完成了连线
接下来,为该设计添加一个wrapper,在Sources->design sources下右键该设计模块,选择Create HDL Wrapper
选择Let Vivado manage wrapper and auto-update
2.3 综合、实现、生成Bitsteam
这里直接点Generate Bitstream,然后等待。等待的时长与电脑的配置有关
运行成功后,右上角会显示write_bitstream Complete,中间弹出的框选择Cancel
接下来把硬件配置导入SDK,首先依次点击File->Export->Export Hardware
勾选Include bitstream,点OK
接下来,依次点击File->Launch SDK
点OK
2.4 SDK
正常情况下,Project Explorer里会出现我们刚才导入的硬件配置,接下来依次点击左上角File->New->Application Project
按如下配置输入,点击Next
选择Hello World,然后点Finish
这样Project Explorer里出现led和led_bsp,我们双击led->src下的helloworld.c
将文件内容替换为如下内容然后保存
#include <stdio.h>
#include "platform.h"
#include "xparameters.h"
#include "xgpio.h"
#include "sleep.h"
/************************** Constant Definitions *****************************/
/*
* The following constant maps to the name of the hardware instances that
* were created in the EDK XPS system.
*/
#define XPAR_LEDS_ID XPAR_AXI_GPIO_0_BASEADDR
/*
* The following constant is used to determine which channel of the GPIO is
* used for the LED if there are 2 channels supported.
*/
#define LED_CHANNEL 1
/************************** Variable Definitions *****************************/
/*
* The following are declared globally so they are zeroed and so they are
* easily accessible from a debugger
*/
XGpio Gpio; /* The Instance of the GPIO Driver */
int main()
{
init_platform();
u8 i=0;
int Status;
/*
\ Initialize the GPIO driver
*/
Status = XGpio_Initialize(&Gpio, XPAR_LEDS_ID);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
/*
\ Set the direction for all signals to be outputs
*/
XGpio_SetDataDirection(&Gpio, LED_CHANNEL, 0x00);
/*
\ Loop forever run the LED
*/
while(1)
{
for(i=0;i<8;i++)
{
XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, (1<<i));
sleep(1);
}
}
return 0;
}
,
接下来给板子上电,正确连接JTAG线,然后点击Xilinx->Program FPGA
点击Program,完成后可以看见板子上蓝色LED点亮,表示PL配置成功
接下来,右键led,点击Run As->Launch on Hardware(GDB),成功后就可以在板子上看见流水灯现象