Written by Sherneyko Plata Rangel

 

Pynq-z2: Hello world

 

In this tutorial we will implement a simple test of the inputs/outputs available on our board, in order to familiarize with it and test that we can program it without any issues.

 

  1. First we will start a project from scratch, on Vivado, in this case we will use Vivado 2019.1, some options may vary depending on the version you are using:


  2. Then we will name our project, and its path.


  3. We will create an empty RTL project. We will specify sources later.


  4. Select the FPGA part to work with. For pynq-z2, the part name is XC7z020clk400-1.


  5. Finally, press finish. An empty project for the selected part will be created in the path we specified before. Vivado automatically creates a directory hierarchy for our project. Since we dont need to explore it yet, we will extract Download this file (zynq_mybase_src.zip)zynq_mybase_src.zip into the projects directory


  6. For sake of simplicity, we will use ./v and ./xdc folders for our verilog sources and constraint files, respectively. Then, on vivado, we will add our sources to the project(Download this file (zynq_mybase_src.zip)zynq_mybase_src.zip).


  7. Select add or create constraints, click next, then click on the “+” , and navigate to the xdc folder we extracted before. Select “io.xdc” and click ok



  8. Now, lets add our verilog sources. Select add or create design sources, click next, then click on the “+” , and navigate to the v folder we extracted before. Select “top.v” and click ok
    https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png

    https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png

  9. Our project has now a top module, and a constraint file. We will now review these files
    https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png


     https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png

    Top.v

     

    Module and inputs/outputs declaration

     

    Port names on our top module must match names in our io.xdc

     

     

     

     

     

    Internal wires for connecting test modules to some of our IOs

     

    Clocking wizard. Will take an onboard clk of 125MHz (sysclk), and generate our design clk. This is a xilinx IP core, so we will have to create an instance of it first.

     

    Virtuail IO. Will allow us to capture and generate signals from vivado. This is a xilinx IP core, so we will have to create an instance of it as well

     

    Assignment of onboard buttons, switches to VIO inputs

     

    Assignment of VIO outputs to onboard LEDs


     https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png

    io.xdc

     

     

    PACKAGE_PIN <pin>
    specifies a pin on the FPGA

     

    IOSTANDARD <iostandard> specifies the voltage level of the pin

     

    get_ports <name>

    specifies a port from the top level (top.v) to connect to

     

    Basically each line maps a port to a FPGA pin, and specifies its IO type.

     

    Note that port arrays need to be mapped one by one

  10. Lets create our Clocking wizard, VIO instances. Open the IP Catalog, and search for clocking wizard
    https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png

  11. Set the input clock to 125M
    https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png

  12. And the output clock to 100M
    https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png

  13. Then click OK to generate it. You can choose to generate the output product now, or skip it (will be done anyways when compiling the top module)

  14. Now lets repeat the process for our VIO, We will use 1 input probe and 1 output probe, both of 16 bits.
    https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png
    https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png

  15. Now that our project seems to have no missing sources, we can try to compile it.
    https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png
    https://fpgalover.com/images/manuals/Pynq-z2/Vivado/intro/pynqz2_hworld_files/image013.png

  16. After compilation is finished, its possible to download the design to the pynq-z2.
    1. With the board connected to our PC via USB, and powered on, click on Prorgram and debug > Open hardware manager > Open target


    2. Then click program device, and select xc7020_1.



  17. On the program device pop-up, you can select the bitsream and debug probes file. Most times it will automatically load the last compiled bitfile, with its matching debug probes file. Probes file needs to match the debugging logic in the bitfile being downloaded, otherwise it wont be able to connect. If any part of the debugging logic has a design error (missing connections, unmet timing), the debug probes file might not be generated, and it would not be possible to access debugging logic this way.


  18. Go to the hw_vio_1 and add all ports.


  19. Set all output ports bits o be controlled as toggle buttons


  20. Finally, test pressing some buttons/switches onboard, and see how the input probes change Also toggle some buttons on the VIO to control the onboard leds.

 

Enjoy!