Please enable JavaScript to view this site.

Waijung 2 User Guide

Navigation: Zynq-7000 target > Tutorials > Basic tutorials

Tutorial 1: Blink an EMIO LED

Scroll Prev Top Next More

Introduction

This tutorial will guide you to create a simple blinking LED application project using EMIO interface. Using EMIO interface, we can control I/O pins which are connected to the PL(FPGA) using GPIO driver.

This will include,

1.Make the hardware design and export the hardware design file using Vivado

2.Create the application project using MATLAB Simulink and Waijung 2 for ZYNQ-7000

Make the hardware design using Vivado

1.Open the Vivado design suite

2.Create new project

zynq7000_basic_tutorial1_1

3.Click on Next

4.Provide a proper name and a location for the project. Click Next to continue.

zynq7000_basic_tutorial1_2

5.Select RTL Project and click Next.

zynq7000_basic_tutorial1_3

6.Click Next for Add Sources and Add Constraints

7.Then, select Zybo Z7-20 board under Boards and click Next

zynq7000_basic_tutorial1_4

8.At last, click on Finish.

zynq7000_basic_tutorial1_5

9.Once the project is loaded, go to Create Block Design

zynq7000_basic_tutorial1_6

10. Click OK to create the block design with the given name

zynq7000_basic_tutorial1_7

11. Once the blank diagram, click on zynq7000_getting_started_10 or use Ctrl + i to add Vivado IPs to the diagram. Only ZYNQ7 Processing System IP is required for this project. Add ZYNQ7 Processing System IP to the diagram.

zynq7000_basic_tutorial1_8

12. Then click on Run Block Automation to configure the IP automatically according to the hardware and click OK.

zynq7000_basic_tutorial1_9

13. Unnecessary ports and interfaces can be removed from the IP. In here, M_AXI_GP0 is not required for this project. To remove it, double click on the ZYNQ7 Processing System IP. Then go to PS-PL Configuration, expand AXI Non Secure Enablement, expand GP Master AXI Interface and disable M AXI GP0. Next click OK

zynq7000_basic_tutorial1_10
zynq7000_basic_tutorial1_11
zynq7000_basic_tutorial1_12

14. Since we are going to control pin in FPGA fabric, the pin should be connected to the ZYNQ7 Processing System IP externally. The Processing System(PS) doesn't have a direct connection to the FPGA I/O pins, those pins should be connected to the PS externally using EMIO interface. To do that, double click on the ZYNQ7 Processing System IP to open the IP configuration.

zynq7000_basic_tutorial1_13

15. Then go to MIO Configuration and scroll down until you find GPIO section. Next, expand the GPIO section, Enable EMIO GPIO and set the width as 1 since we are going to only one pin. Then click OK.

zynq7000_basic_tutorial1_14

16. Click OK to the pop-up windows if you get any warning messages. Once it is done, you will see a new port GPIO_0 in the ZYNQ7 Processing System IP. That is the port that we are going to connect the FPGA pin.

zynq7000_basic_tutorial1_15

17. To connect the external pin, right click on GPIO_0 port and click on Create Interface Port

zynq7000_basic_tutorial1_16

18. Then click OK the pop-up window

zynq7000_basic_tutorial1_17

19. Once it is done, you will see an external port connected to the GPIO_0 port

zynq7000_basic_tutorial1_18

20. Then save the project. Next step is to set the correct LED pin to the external port that we created above. There are two ways to define the FPGA pins to the external port. First way is, manually write a constraint file to define pins, second way is to use the Vivado system to generate the constraint file automatically. In this tutorial the constraint file will be generated using the Vivado system. To do that first we have to create HDL wrapper. Go to Design Sources under Sources. Then right click on design_1 and select Create HDL Wrapper. Select Let Vivado manage wrapper and auto-update from the selection and click OK.

zynq7000_basic_tutorial1_19
zynq7000_basic_tutorial1_20

21. Once that process is finished, click on Run Synthesis to synthesis the hardware design and wait until the process is finished. Once the process is finished click Cancel on the pop-up window.

zynq7000_basic_tutorial1_21
zynq7000_basic_tutorial1_22

22. Then expand the Open Synthesized Design and click on Schematic to set the pins

zynq7000_basic_tutorial1_23

23. In the Schematic tab, click on I/O Ports to get the list of the assigned pin list of the current hardware configuration

zynq7000_basic_tutorial1_24

24.Once you click on I/O Ports separate Find Results tab will be appeared in the bottom pane. In there you can the list of pins and their configurations

zynq7000_basic_tutorial1_25

25. Scroll down until you find the GPIO_0_tri_io[0] signal name. Since we are going to use LD0 LED (M14 pin) to blink set the Package Pin M14 for the GPIO_0_tri_io[0] and set the I/O Std as LVCMOS33 to use 3.3V.

zynq7000_basic_tutorial1_26

26. Once it is done, save the project. Then click OK to the pop-up window. After that there will be another pop-up window to save above configurations to a constraint file(.xdc). Give a proper file name to that and click OK to save it

zynq7000_basic_tutorial1_27

27. Then click on Open Block Design. If you need to see the generated constraint file for this design, you can go to Source tab in the left pane and expand the Constraints. You can see the constraint file that the system generated for us. Just double click on that file.

zynq7000_basic_tutorial1_28
zynq7000_basic_tutorial1_29

28.Next we need to generate the bit-stream for this hardware design. For that click on Generate Bitstream in the bottom of the left pane. Then click Yes to the pop-up window

zynq7000_basic_tutorial1_30
zynq7000_basic_tutorial1_31

29. Wait until the process is finished. Once it is finished, there will be a pop-up window. Click Cancel to that.

30. Last step is to export the hardware design file. For that, go to File → Export → Export Hardware.

zynq7000_basic_tutorial1_32

31.Click Next on the wizard. Next, select Include Bitstream from the selection and click Next. Then give a proper name for the hardware design file(XSA). Click Next and at last click Finish 

zynq7000_basic_tutorial1_33
zynq7000_basic_tutorial1_34
zynq7000_basic_tutorial1_35

32. You can find the XSA file in the project folder. This will be needed for the Waijung 2 blockset

zynq7000_basic_tutorial1_36

 

Create the application project using MATLAB Simulink and Waijung 2 ZYNQ-7000 blockset

1.Open MATLAB and change the current folder of MATLAB to a path where it doesn't contain any spaces.

zynq7000_basic_tutorial1_37

2.Add following blocks to the current Simulink model. To add the blocks, click on a empty white space on the Simulink model and type the block name.

a.Waijung 2 Target Setup

zynq7000_basic_tutorial1_39

b.Pulse Generator

zynq7000_basic_tutorial1_40

c.Data Type Conversion

zynq7000_basic_tutorial1_41

d.Digital Output

zynq7000_basic_tutorial1_42

3.Then, configure the added blocks as follows

a.Waijung 2 Target Setup

i.Set the Xilinx Tool Path in Waijung 2 tab. This is the path to the folder that you have installed Vivado and Vitis

zynq7000_basic_tutorial1_43
zynq7000_basic_tutorial1_44

ii.Browse the XSA (hardware design file) in ZYNQ7000 tab that we exported from the Vivado and wait until the process is finished.

zynq7000_basic_tutorial1_45
zynq7000_basic_tutorial1_46

b.Pulse generator

i.Set the Period to 1 and Pulse width to 50 to generate the 1Hz square wave

zynq7000_basic_tutorial1_47

a.Digital output

i.Deselect the default selected Pin 7

ii.Set GPIO Type to EMIO

iii.To select EMIO pin(s), please consider the following steps

1.First consider the EMIO width that you configured in Vivado

2.You have to check the signal name(s) for the EMIO interface. In the schematic in synthesis signal name for each EMIO ports will be GPIO_0_tri_io[0] to GPIO_0_tri_io[n]. So GPIO_0_tri_io[0] always be pin 54 in EMIO pin list in Digital output block. Consider the following examples.

a.If EMIO pin width is 2 in Vivado

i.GPIO_0_tri_io[0]  will be pin 54 and GPIO_0_tri_io[1]  will be pin 55

b.If EMIO pin width is 5 in Vivado

i.GPIO_0_tri_io[0]  will be pin 54, GPIO_0_tri_io[1]  will be pin 55, GPIO_0_tri_io[2]  will be pin 56, GPIO_0_tri_io[3]  will be pin 57 and GPIO_0_tri_io[4]  will be pin 58.

i.Since we are going use only one EMIO pin select pin 54

zynq7000_basic_tutorial1_48

4.Connect the following blocks in the Simulink model

a.Connect the Pulse generator to the Data type conversion block

b.Connect the Data type conversion block to the Digital output block

zynq7000_basic_tutorial1_49

5.Now the Simulink model is complete. Save the model first. Next we need to download the application to the hardware. To do that,

a.Go to the APPS tab in the Simulink model

zynq7000_basic_tutorial1_50

b.Then select Embedded Coder

zynq7000_basic_tutorial1_52

c.Then C CODE tab will appear

zynq7000_basic_tutorial1_51

d.After that connect the Zybo Z7 board to the computer using the USB cable, connect the Programming port to the USB cable and turn ON the board.

e.Click the Build button in the C CODE tab. Then it will start to build the model, compile and download to the hardware

zynq7000_basic_tutorial1_53

f.Wait until the process is finished. Once it is finished, the LD0(M14) LED will start to blink in 1Hz frequency

zynq7000_basic_tutorial1_54

6.The output results

zynq7000_basic_tutorial1_55

 

Resources

Simulink model: tutorial_1.slx

XSA file: tutorial1_wrapper.xsa

Vivado project: basic_tutorial1.zip

 

Copyright 2024 Aimagin Co.,Ltd. Rev.1670