Zynq入门
概述
本指南将提供使用ZEDBOARD的Vivado IP集成器创建硬件设计的逐步演练。
At the end of this tutorial you will have:
-
Created a simple hardware design incorporating the on board LEDs and switches.
-
Created a .C project in XIlinx Vivado SDK tieing the on board LEDs and switches together using the hardware design shown in the previous step.
先决条件
硬件
-
Digilent的Zedboard开发板和用于UART通信和JTAG编程的微型USB电缆
Software
-
Xilinx Vivado 2015.X with the SDK package.
Board Support Files
-
zedboard支持文件
-
These files will describeGPIOinterfaces on your board and make it easier to select your board in the initial design setup and addGPIO块设计中的IP块
-
遵循此Wiki指南General Design Flow
I. Vivado
-
Open Vivado and select Zedboard
-
Create an new Vivado Project
-
Create empty block design workspace inside the new project
-
Add required IP blocks using the IP integrator tool and build Hardware Design
-
验证并保存块设计
-
创建HDL系统包装器
-
设计合成和及其运行mentation
-
Generate Bit File
-
导出硬件设计,包括生成的位流文件到SDK工具
-
启动SDK
现在,硬件设计导出到SDK工具。Vivado到SDK交接是通过Vivado内部完成的。我们将使用SDK创建一个软件应用程序,该应用程序将通过从Vivado导入硬件设计信息来使用自定义的板接口数据和FPGA硬件配置。
ii。SDK
-
创建新的应用程序项目并选择默认Hello World模板
-
Program FPGA and run application
- -
1.创建一个新项目
When you first run Vivado this will be the main start window where you can create a new project or open a recent one.
Make sure to select the board file made by Digilent.
2.创建一个新的块设计
3. Add the Zynq IP & GPIO Blocks
- -
4.运行连接自动化工具
4.1) The connection automation tool will add the required logic blocks for the demo. SelectRun Connection Automationhighlighted in blue.
4.2) Check the box by所有自动化。SelectGPIO在下面axi_gpio_0并选择btns_5bitsin the Board Part Interface drop-down box.
4.3)选择GPIO2在下面axi_gpio_0并选择swts_8bits在下拉框中。
4.4)选择GPIO在下面axi_gpio_1并选择LEDS_8BITin the drop-down box and hitOK。
- -
5.生成HDL包装器并验证设计
5.1) Select 验证设计。这将检查设计和连接错误。这将在VHDL中创建一个顶部模块,并允许您生成一个Bitstream。
6. Generate the Bitstream
7. SDK导出硬件文件
8. Launch SDK
9.创建一个新的Hello World应用程序项目
9.3)Hello World演示是该演示的好起点。点击Next, 选择你好世界然后单击Finish。此过程将向项目资源管理器添加两个目录。
10。1)Copy and paste the code below into the helloworld.c file./************************************************************************************************************** Zedboard的入门指南此演示显示LED上的开关状态,并在按下按钮时向串行通信打印消息。终端设置:-BAUD:115200 -DATA BITS:8- PARITY:NO -Stop Bits:1 7/25/16:由JONP ******************创建********************************/#include
#include "platform.h"#include #include“ xparameters.h”#include“ sleep.h”intmain((){XGPIO输入,,,,输出;intbutton_data=0;intswitch_data=0;xgpio_initialize((和输入,,,,xpar_axi_gpio_0_device_id);//初始化输入XGPIO变量xgpio_initialize((和输出,,,,XPAR_AXI_GPIO_1_DEVICE_ID);//initialize output XGpio variableXGpio_SetDataDirection((和输入,,,,1,,,,0xf);//将第一个通道Tristate Buffer设置为输入XGpio_SetDataDirection((和输入,,,,2,,,,0xf);//将第二个通道Tristate缓冲区设置为输入XGpio_SetDataDirection((和输出,,,,1,,,,0x0);//set first channel tristate buffer to outputinit_platform(();while((1){switch_data=XGPIO_DISCRETEREAD((和输入,,,,2);//获取开关数据XGpio_DiscreteWrite((和输出,,,,1,,,,switch_data);//write switch data to the LEDsbutton_data=XGPIO_DISCRETEREAD((和输入,,,,1);//get button data//打印消息取决于按下一个或多个按钮如果((button_data==0b00000){}//没做什么别的如果((button_data==0b00001)xil_printf((“button 0 pressed\n\r“);别的如果((button_data==0b00010)xil_printf((“按钮1按\n\r“);别的如果((button_data==0b00100)xil_printf((“button 2 pressed\n\r“);别的如果((button_data==0B01000)xil_printf((“按钮3按下\n\r“);别的如果((button_data==0b10000)xil_printf((“按钮4按\n\r“);别的xil_printf((“multiple buttons pressed\n\r“);usleep((200000);//delay}cleanup_platform(();return0;} 11.运行项目
11。1)Make sure that the Zedboard is connected to the host PC via theUARTUSB Port and that JP5 is set to JTAG. To program the FPGA, on the top toolbar, click the Program FPGAbutton.11.2)保存项目。该项目将自动构建。11.3)右键单击zedboard_getting_started_with_zynq目录并选择运行为→在硬件(系统调试器)上启动。11.4)演示将在Zedboard上运行。尝试使用4个开关(标记为SW0-SW3)。这样做应该照亮其各自的LED。Also over the serial port, pressing each button (labeled BTN0-BTN3) will produce the message “button x pressed”.11。5) Tera Term or any serial terminal will work as a Console for displaying the output of the BTN's.Set up the terminal as:
-
-