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.

      1.1)单击创建新项目



      1.2)将向您提供项目创建向导。点击Next



      1。3) Enter a project name and location the clickNext



      1。4) SelectRTL Project然后单击Next



      1。5) This demo does not use any existing sources, existing IP or constraints. Click through the next three screens.

      1.6)选择董事会并选择theZedboard板文件。点击Next接着Finish

      Make sure to select the board file made by Digilent.


      2.创建一个新的块设计

      2.1)该过程完成后,单击创建块设计在流导航器中。



      2。2)点击OK



      2。3) A blank Block Design will open up.


      3. Add the Zynq IP & GPIO Blocks

      3.1)单击 Add IP按钮并搜索Zynq。双击ZYNQ7处理系统放置裸露的Zynq块。



      3.2) Click the运行块自动化link



      您的Zynq块现在看起来像下面的图片。


      3.3) Click the Add IP图标再次,这次搜索“ gpio”并添加AxiGPIOcore.


      3.4)双击新的axi_gpio_0core that was just added to bring up the customizing window. Under theIP配置选项卡检查Enable Dual Channelbox. ClickOK



      3.5) Add anotherGPIO通过重复步骤3.4,但不要启用双通道。


      - -

      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


      4.5) This process will add:
      * The AXI interconnect * Processor System Reset * The board parts for the buttons, switches and LEDs.

      >

      4.6)接下来,让我们清理我们的块设计。点击再生布局button to rearrange your block design.


      - -

      5.生成HDL包装器并验证设计

      5.1) Select 验证设计。这将检查设计和连接错误。
      5.2)在设计验证步骤之后,我们将继续创建HDL系统包装器。在块设计窗口中设计来源tab, right-click on the block diagram file. We labeled it “design_1.bd” and selectCreate HDL Wrapper

      这将在VHDL中创建一个顶部模块,并允许您生成一个Bitstream。


      6. Generate the Bitstream

      6.1) Click onGenerate Bitstream在流导航器的底部。等待该过程完成并单击确定。


      7. SDK导出硬件文件

      7.1) Go to file→Export→Export Hardware… Make sure to check the box for包括Bitstreamthen clickOK


      8. Launch SDK

      8.1) Go toFile→Launch SDK然后单击OK


      9.创建一个新的Hello World应用程序项目

      9.1)去文件→新→申请项目



      9.2) Enter the project details:
      *项目名称:“ zedboard_getting_started_with_zynq” *硬件平台:design_wwrapper_hw_platform_0 *处理器:ps7_cortexas9_0 * languate:languate:c * os Platform:os平台:独立平台:standalone * board Support package:board support package:create new new(留下默认名称)

      9.3)Hello World演示是该演示的好起点。点击Next, 选择你好世界然后单击Finish。此过程将向项目资源管理器添加两个目录。
      9.4) Expandzedboard_getting_started_with_zynq然后打开srcand double click on “helloworld.c”. This is the default Hello World C code.



      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==0b00001xil_printf((“button 0 pressed\n\r;别的如果((button_data==0b00010xil_printf((“按钮1按\n\r;别的如果((button_data==0b00100xil_printf((“button 2 pressed\n\r;别的如果((button_data==0B01000xil_printf((“按钮3按下\n\r;别的如果((button_data==0b10000xil_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:

      ,,,,可编程逻辑,,,,教程,,,,zedboard