ZedBoard+Vivado(二)——PS + PL實現流水燈
阿新 • • 發佈:2018-12-20
硬體:Zedboard 軟體:Vivado2018.2 + Win10
本文參考了http://blog.chinaaet.com/cuter521/p/35978的設計
1 設計
功能:PS + PL流水燈 語言:C 流程:建立工程->IP Integrator->綜合、實現、生成Bitstream->SDK
2 流程
2.1 建立工程
跟上一篇步驟完全相同,這裡不用新增原始檔
2.2 IP Integrator
IP Integrator是一個圖形化、模組化的IP核開發工具,利用該工具可以很方便的開發基於現有晶片或板子的複雜系統。 首先,在IP INTEGRATOR下選擇Create Block Design
2.3 綜合、實現、生成Bitsteam
這裡直接點Generate Bitstream,然後等待。等待的時長與電腦的配置有關
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),成功後就可以在板子上看見流水燈現象