開發板環境:vivado 2017.4 ,開發板型號xc7z020clg400-1,這個工程主要功能是自定義一個axi_lite IP然後
在SDK中控制LED閃爍
工程鏈接:https://pan.baidu.com/s/1W2p50NZP6hKMQEdFbTcLDA 提取碼:r5kn
step1 新建一個vivado工程和自定義一個axi_lite IP核
然後在這個工程路徑下新建一個IP文件夾用於存放自定義IP所產生的文件
點擊Tools-->Create Interface Definition New IP
點擊Next
選擇這個AXI4,然後點擊Next
這裏的顯示名稱可以隨便取名
這裏IP存放路徑,選擇我們剛剛新建IP文件夾的路徑,然後點Next
這裏都選擇默認,點擊Next
選擇Edit IP,點擊Finish
在彈出的對話框中選擇axi_led_test_v1_0 ,然添加一個led輸出端口
將led端口例化進來
在axi_led_test_v1_0_S00_AXI_inst中添加led端口如下圖所示
axi_lite一共32數據位寬,有四個32位寄存器,下面就是對四個寄存器進行寫,每一個寄存器32位,
我這裏只對slv_reg0進行操作
這裏讀取四個寄存器的值
我們這個自定義IP做爲一個輸出口,一般只會用到寫功能,也就是對相應位寫值來控制電平,
所以這裏的讀其實可以屏蔽,這裏我就不屏蔽,因爲後面的SDK程序我只會進行寫不會進行讀
下面這個截圖是將第一個32位寄存器slv_reg0的最低位的電平給led,只要在SDK裏對第一個寄存器
進行操作就可以控制led閃爍
點擊Merge changes from File Groups Wizard
點擊Merge changes from File Groups Wizard
點擊Re-Package IP 生成自定義axi_lite IP
點擊Yes
生成的自定義IP如下圖所示
step2 添加自定義IP
點擊Settings
我這裏直接自動添加進來了,如果你自己生成的IP這裏沒有,可以點擊+將自己新建的IP添加進來
step3 添加zynq核將自定義IP掛接到zynq上
點擊Create Block Design
點擊OK
添加ZYNQ核並配置參數,不同的開發板設置不同,只要根據自己的開發板進行設置就可以了
雙擊axi_led_test添加自定義的IP
點擊Run Block Automation
點擊OK
點擊Run Connection Automation
點擊OK
自動連線完成如下圖所示
右擊--> Make Extemal 引出led管腳
引出的led管腳如下圖所示
這個0x43C00000 就是這個自定義IP的地址,我們在SDK中給這個地址寫值就可以控制led
step4 綜合、生成頂層文件,生成bit文件
綜合
生成頂層文件
添加管腳約束,這裏的自定義led管腳接的fpga上的led
生成bit文件
step5 導出硬件配置,打開SDK,新建fsbl
導出硬件配置
點擊OK
打開SDK
點擊OK
點擊File--> Application Project新建工程
新建一個fsbl,點Next
選擇Zynq FSBL,點Finish
step6 新建axi_led_test工程
新axi_led_test工程,選擇fsbl_bsp,然後點擊Next
選擇hello_world工程模板,點擊Finish
主程序
/******************************************************************************
*
* 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 <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "sleep.h"
int main()
{
while(1)
{
Xil_Out32(0x43C00000 ,0x00000000);
sleep(1);
Xil_Out32(0x43C00000 ,0x00000001);
sleep(1);
}
}
我這裏分配的是三色燈中的一個,手機拍出來的看起來不太明顯,我這裏可以看到led不停閃爍說明這個工程沒有問題
axi_lite IP的整體控制流程(這個圖如果看懂了,這個axi_lite自定義IP也就理解差不多了)