Getting Started with Zynq
Overview
This guide will provide a step by step walk-through of creating a hardware design using the Vivado IP Integrator for the Zedboard.
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.
Prerequisites
Hardware
-
Digilent's Zedboard Development Board and a Micro USB cable for UART communication and JTAG programming
Software
-
Xilinx Vivado 2015.X with the SDK package.
Board Support Files
-
Zedboard Support Files
-
These files will describeGPIOinterfaces on your board and make it easier to select your board in the initial design setup and addGPIOIP blocks in the block design
-
Follow this Wiki guideVivado Board Files for Digilent 7-Series FPGA Boardson how to install Board Support Files for Vivado 2015.X
-
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
-
Validate and save block design
-
Create HDL system wrapper
-
设计合成和及其运行mentation
-
Generate Bit File
-
硬件设计包括出口generated bit stream file to SDK tool
-
Launch SDK
Now the Hardware design is exported to the SDK tool. The Vivado to SDK hand-off is done internally through Vivado. We will use SDK to create a Software application that will use the customized board interface data and FPGA hardware configuration by importing the hardware design information from Vivado.
II. SDK
-
Create new application project and select default Hello World template
-
Program FPGA and run application
1. Creating a New Project
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) Click onCreate New Project.
1.2) You will be presented with the project creation wizard. ClickNext.
1.3) Enter a project name and location the clickNext.
1.4) SelectRTL Projectand clickNext.
1.5) This demo does not use any existing sources, existing IP or constraints. Click through the next three screens.
Make sure to select the board file made by Digilent.
2. Creating a New Block Design
3. Add the Zynq IP & GPIO Blocks
—–
4. Run the Connection Automation Tool
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 byAll Automation. SelectGPIOunderaxi_gpio_0and selectbtns_5bitsin the Board Part Interface drop-down box.
4.3) SelectGPIO2underaxi_gpio_0and selectswts_8bitsin the drop-down box.
4.4) SelectGPIOunderaxi_gpio_1and selectleds_8bitsin the drop-down box and hitOK.
—–
5. Generate HDL Wrapper and Validate Design
5.1) Select Validate Design. This will check for design and connection errors.
This will create a top module in VHDL and will allow you to generate a bitstream.
6. Generate the Bitstream
7. Export hardware files for SDK
8. Launch SDK
9. Create a new Hello World Application Project
9.1) Go toFile→New→Application Project.
9.2) Enter the project details:* Project name: "zedboard_getting_started_with_zynq" * Hardware Platform: design_1_wrapper_hw_platform_0 * Processor: ps7_cortexas9_0 * Languate: C * OS Platform: standalone * Board Support Package: Create New (leave default name)
9.3) The Hello World demo is a good starting point for this demo. ClickNext, selectHello Worldand clickFinish. This process will add two directories to the project explorer.
10.1) Copy and paste the code below into the helloworld.c file.
/***************************************************** Getting Started Guide for Zedboard This demo displays the status of the switches on the LEDs and prints a message to the serial communication when a button is pressed. Terminal Settings: -Baud: 115200 -Data bits: 8 -Parity: no -Stop bits: 1 7/25/16: Created by JonP ****************************************************/#include#include "platform.h"#include #include "xparameters.h"#include "sleep.h"intmain(){XGpio输入,output;intbutton_data=0;intswitch_data=0;XGpio_Initialize(&input,XPAR_AXI_GPIO_0_DEVICE_ID);//initialize input XGpio variableXGpio_Initialize(&output,XPAR_AXI_GPIO_1_DEVICE_ID);//initialize output XGpio variableXGpio_SetDataDirection(&input,1,0xF);//set first channel tristate buffer to inputXGpio_SetDataDirection(&input,2,0xF);//set second channel tristate buffer to inputXGpio_SetDataDirection(&output,1,0x0);//set first channel tristate buffer to outputinit_platform();while(1){switch_data=XGpio_DiscreteRead(&input,2);//get switch dataXGpio_DiscreteWrite(&output,1,switch_data);//write switch data to the LEDsbutton_data=XGpio_DiscreteRead(&input,1);//get button data//print message dependent on whether one or more buttons are pressedif(button_data==0b00000){}//do nothingelseif(button_data==0b00001)xil_printf("button 0 pressed\n\r");elseif(button_data==0b00010)xil_printf("button 1 pressed\n\r");elseif(button_data==0b00100)xil_printf("button 2 pressed\n\r");elseif(button_data==0b01000)xil_printf("button 3 pressed\n\r");elseif(button_data==0b10000)xil_printf("button 4 pressed\n\r");elsexil_printf("multiple buttons pressed\n\r");usleep(200000);//delay}cleanup_platform();return0;}
11. Run the Project
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) Save the project. The project will automatically build.
11.3) Right click thezedboard_getting_started_with_zynqdirectory and select run as → Launch on Hardware(System Debugger).
11.4) The demo will be running on the Zedboard. Try playing around with the 4 switches (labeled SW0-SW3). Doing so should light its respectiveLED. 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: