top of page
FOLLOW ME
  • Black Facebook Icon

Tutorial 2 Part1 : Using ZedBoard Switches & LEDs


Introduction

In this tutorial we are going to control the 8 LEDs available on the ZedBoard using Switches, both switches and LEDs are connected to the PL side of the ZYNQ SOC, therefore we can perform this function using two approaches, the first approach is reading the switch values from the switches connected to then PL and sending its value to the ZYNQ PS, then ZYNQ PS sends back the value to the LEDs connected to the PL.

The second approach would be using the PL only and bypass the signals from the switches to the LEDS using a VHDL code.

This tutorial will be divided into two parts, the first part will be for the first approach while the second part for the second approach

Part1


Step1: Create new project using Vivado IDE

These are the same steps for creating all projects


1- Launch Vivado IDE and select create new project.

2- Enter Zedboard_tutorial2_p1 in the project name field and choose a project directory location.


3- Select RTL Project option in the Project Type form, and click Next.

4- Select VHDL as the Target language and Simulator language in the Add Sources form.

5- We are not going to add files, IPs or constraints so click next.

6- In the Default Part form, using the Boards option choose Zedboard Zynq Evaluation and development Kit and click Next then Finish.

Step2: Create Block design

In this project we will need to ass 2 GPIO IP’s the first one is for the input switches and the second one would be for the output LEDs these IPs will be connected to the ZYNQ processing system

1- In the Flow Navigator click expand the IP Integrator and click create block design, create Design window will pop up, keep the same name design_1 and click ok.

2- After the Diagram page opens, click on the Add IP icon from the left panel of the Diagram page to add IP blocks. Also you can right click on any empty space in the Diagram page and choose Add IP style="margin-left:.25in;"

3- In the search bar type Zynq , and choose the first option, this will add a ZYNQ processing system IP( the ARM cortex A9 processor).

4- Click on the run block automation option. style="margin-left:.25in;"

5- Again click on the Add IP icon and this time write in the search bar GPIO, and add two AXI GPIO, both AXI GPIO IPs should appear in the Diagram.

6- Double click on the first AXI GPIO IP, under the choose leds 8 bit and click ok style="margin-left:.25in;"

7- Double click on the second AXI GPIO IP, under the choose sws 8 bit and click ok, this will configure the AXI GPIO to work as 8 bit input

8- Click on Running Connection Automation, and choose All Automation then click ok.

9- Click on the Regenerate Layout icon to rearrange the blocks in a good organization.

10- In the sources window, right click on the design_1 block design under Design Source folder and choose create HDL wrapper, this options creates a top level VHDL file for the block design which can be used to generate the bitstream file.

11- Choose let Vivado manage wrapper and auto update and click ok

Note: Click on the address editor panel and expand Data, you shall find the processing system connected to the axi_gpio_0 which is the output led controller and axi_gpio_1 which is the input switch controller both of them are given an offset address which will be used by the software running on the ZYNQ PS to communicate with these peripherals


12- In the flow navigator, click on generate bitstream or click on flow->generate bitstream. During this step the tool creates a bit file for programming the PL of the ZYNQ.

12- Bit Generation Complete window should pop up, close it then go to File-> Export -> Export Hardware. Check the Include bitstream and click ok. This exports the hardware files generated to the SDK (software development kit). style="margin-left:.25in;"

Step3: writing the software application

During this step we should export the hardware files to the software development kit to create then create a C project for continuesly reading the value of the switches and writing these values to the LEDs

1- In Vivado go to File-> Launch SDK, the SDK will open and in the Project Explorer window you can see the exported hardware files. In the SDK go to Files-> New-> board support package then click finish, this create a board support package with all necessary functions for driving the hardware you designed in Vivado.

2- Create application project by going to File-> Application Project, in the project name type Project1 and in the board support package choose use existing then click Next and choose Hello World from the available templates then click finish




3- Expand the src folder under the Project1 folder and double click on Helloworld.c and replace it with the following code:


#include <stdio.h>

#include "platform.h"

#include "xil_io.h"


int main()

{

int sw;

init_platform();


while(1)

{

// read the switches value in variable sw (AXI GPIO at address 0x41210000)

sw = Xil_In32(0x41210000);

// write the value to LEDs (AXI GPIO at address 0x41200000)

Xil_Out32(0x41200000, sw);

}


cleanup_platform();

return 0;

}


Step4: Programming the Zedboard and running the C Application

1- In the SDK click on the program FPGA icon then click program to program the ZYNQ PL with the bitstream




2- Write click on Project1 in the project explorer then go to Run AS-> 4 Launch on Hardware(GBD). The application should run on the board and the LEDs will read the value of the swithces




![endif]--

Subscribe to get upcoming FPGA projects by email

SEARCH BY TAGS
No tags yet.
FEATURED POSTS
bottom of page