Using the Pmod Connectors

In this guide I will go through the steps involved in connecting 4 LEDs to the Pmod terminals on the Zybo board, and control the LEDs from a terminal on the PC.

Setting up the hardware part in Vivado

Firstly we will will start by creating a project in Vivado. You should give a name like e.g “UART_External_LEDs”. You decide, as long as you do not create while spaces in the file-name and the path leading to the file. Create an “RTL-Project” and click next until you get to “Default part” selection. I assume that you have the Zybo board loaded in Vivado at this point so that you under “Default part” can select “Board” and under “Vendor” can select “digilentinc.com”, and thereafter “Zybo” in the list below. Press finish and wait.

When the project has opened, press “Create Block Design”, and give it a name. Then press the “Add IP” icon in the menu in the “Diagram view” and search for “Zynq” and select the first the list.AddIPWhen added, press “Run Block Automation”. A windows will open. The settings are fine, so you will just press “OK”. Then you once again press the “Add IP” icon, and this search for “GPIO”. This will most likely give one result which you insert. You run “Run Connection Automation”. In the window (see below) check all fields, and make sure that it in options under GPIO reads “Custom”. Press OK and wait.

gpio

You should now have Block design that looks similar to the one shown below

block

Then double click on the box “axi_gpio_0” and wait for the Re-costomize IP windows to appear.

recosip

Select the “IP configuration” tab and make sure it writes “4” under “GPIO Width” under GPIO. When so, pres OK and wait. Now select the “Sources” in the Sources view (See figure below). Right click on the file under “Design sources” (in my case UART_External_Leds_Test) and from the drop-down menu select “Create HDL wrapper…”. Let Vivado manage wrapper and auto-update, press OK, and wait for it to finish.

source

Now press “Open Elaborated Design” under “RTL Analysis” in the menu all to the left, and select OK in the window that shows and wait for it to finish. After it have opened in the top menu, select “I/O planning” in the dropdown  box (That normaly says “Default lauout”.

selectview

In the bottom part windows called “I/O ports” you should the unfold “GPIO_10713” and then “gpio_rtl_tri_io” so it looks like the figure bellow.

ioport1

The window allows you to select the physical pins onto which the 4 GPIO pins should be connected. In this guide we would like to connect to the Pmod JE on the Zybo board, which means the pins should be assigned under “Site” as shown in the figure below. You also need to set the “I/O std” for the pins. It should in this case be selected to be “LVCMOS33”.

ioport2

When your I/O Ports look similar as shown above, press “Save Constrains” in the File-menu. Write a filename such as “project_constrains” and press save. To fine all the pins for the peripheral connectors on the Zybo board, please consult the “Zybo reference manual” that can be found online here.

You are now ready to press “Generate Bitstream” under “Program and Debug” in the left most menu. Say YES in the window that shows and wait for it to finish. Depending on your PC, this process can take several minutes. When it have finished a “Bitstream Generation Completed” window will show. You can say OK to “Open Implemented Design” and say Yes to close the current design view.

We will now move over to Xilinx SDK in order to generate the software for the Zynq processor, but before doing so, you should connect 4 LEDs with current limiting resistors connected in series with each LED. Should look similar to the following setup. The LEDs should comment to the top-row of the Pmod connector.

20160218_225254

The last thing you need to do in Vivado is to “Export Hardware” under “Files->Export”. Make sure you select “Include bitstream” in the windows that pops up. Hereafter “Launch SDK”, also under “Files” and select OK in the windows that shows up.

Get the software running in Xilinx SDK

When Xilinx SDK have opened, select “Files -> New -> Application Project”. Give it a project name and select Next. In the next windows make sure to select “Empty Application” and press Finish.

Now you have created you empty software project, and you how now import some c-files to make things work. Please download the following files before continuing: Files  –  Unzip the files, and right-click on your newly created project and select “Import” (See below). In the windows select “General” and then “File System” and press Next. In the “From directory” select the directory of your newly un-ziped files and press OK. Finally, select the 4 files you just downloaded in the view, and press Finish.

sdk-import

The c-program you just imported creates a serial interface to the computer so, that you in a terminal will be able to control which LED turns on with the use of the keys 1, 2, 3 and 4. To get the menu working you should now start up a terminal client like e.g. “Putty”, and connect to the serial port on which your Zybo board sits. You should use baud-rate 112500.

Then you need firstly to program the Zynq chip with its hardware configuration. This is done in the SDK through the menu “Xilinx Tools” -> “Program FPGA”. In the windows that show, just select “Program”.

To get the software running, once again right-click on the project top folder and select “Run as” -> “Launch on Hardware (GDB)” as shown below.

sdk-run

If everything goes as planed, your how now in your terminal see the following:

terminal

By pressing the keys 1,2,3 and 4 you should now be able to switch between which LED is active.