After completing this lab, you will be able to:
- Create an embedded system design using Vivado and SDK flow
- Configure the Processing System (PS)
- Add Xilinx standard IP in the Programmable Logic (PL) section
- Use SDK to build a software project and verify the design functionality in hardware.
Launch Vivado and create an empty project targeting the PYNQ-Z1 or PYNQ-Z2 board, selecting Verilog as a target language
- Open Vivado by selecting Start > All Programs > Xilinx Design Tools > Vivado 2018.2 > Vivado 2018.2
- Click Create Project to start the wizard. You will see the Create A New Vivado Project wizard page. Click Next.
- Click the Browse button of the Project Location field of the New Project form, browse to {labs} , and click Select.
- Enter lab1 in the Project Name field. Make sure that the Create Project Subdirectory box is checked. Click Next.
Project Name Entry
- Select the RTL Project option in the Project Type form, and click Next.
- Select Verilog as the Target Language and Simulation Language in the Add Sources form, and click Next.
- Click Next to skip adding constraints.
- In the Default Part form, click Boards filter.
- Select www.digilentinc.com for the PYNQ-Z1 board, tul.com.tw for the PYNQ-Z2 board in the Vendor field, select PYNQ-Z1__or pynq-z2, and click Next.
Board Selection (pynq-z2)
- Click Finish to create an empty Vivado project.
-
Create a block design in the Vivado project using IP Integrator to generate the ARM Cortex-A9 processor based hardware system.
-
In the Flow Navigator, click Create Block Design under IP Integrator.
-
Name the block system and click OK.
-
Click on the button.
-
Once the IP Catalog is open, type zy into the Search bar, and double click on the ZYNQ7 Processing System entry to add it to the design.
-
Click on Run Block Automation and click OK to automatically configure the board presets.
Zynq Block Automation View (pynq-z2)
-
Double click on the Zynq block to open the Customization window for the Zynq processing system.
A block diagram of the Zynq PS should now be open, showing various configurable blocks of the Processing System.
-
At this stage, designer can click on various configurable blocks (highlighted in green) and change the system configuration.
Zynq Processing System Configuration View (pynq-z2)
-
Click on the MIO Configuration panel to open its configuration form.
-
Expand the I/O Peripherals (and GPIO).
-
Deselect all the peripherals except UART 0 (Deselect ENET 0, USB 0, SD 0, and GPIO).
Selecting only UART 0 Peripheral of PS
-
Click OK.
The configuration form will close and the block diagram will be updated as shown below.
ZYNQ7 Processing System configured block
Add one instance of GPIO, name it buttons, and configure for the board. Connect the block to the Zynq.
-
Double-click the AXI GPIO to add an instance of the core to the design.
-
Click on the AXI GPIO block to select it, and in the Block properties tab, change the name to buttons.
-
Double click on the AXI GPIO block to open the customization window. Under Board Interface, for GPIO, click on Custom to view the drop down menu options, and select btns 4Bits for the PYNQ-Z2 or the PYNQ-Z1 board.
As the board was selected during the project creation, and a board support package is available for these boards, Vivado has knowledge of available resources on the board.
-
Click the IP Configuration tab. Notice the GPIO Width is set to 4 (PYNQ-Z1 and PYNQ-Z2) and is greyed out. If a board support package was not available, the width of the IP could be configured here.
-
Click OK to finish configuring the GPIO and to close the Re-Customize IP window.
-
Click on Run Connection Automation , and select buttons (which will include GPIO and S_AXI)
Click on GPIO and S_AXI to check the default connections for these interfaces.
Connection Automation for the GPIO (PYNQ-Z2)
-
Click OK to automatically connect the S_AXI interface to the Zynq GP0 port (through the AXI interconnect block), and the GPIO port to an external interface.
Notice that after block automation has been run, two additional blocks that are required to connect the blocks, Processor System Reset, and AXI Interconnect have automatically been added to the design.
-
Add another instance of GPIO, name the instance leds, configure it and connect it to the Zynq.
-
Add another instance of the GPIO peripheral .
-
Change the name of the block to leds.
-
Double click on the leds block, and select leds 4bits (PYNQ-Z1 and PYNQ-Z2) for the GPIO interface and click OK.
-
Click on Run Connection Automation
-
Click leds , and check the connections for GPIO and S_AXI as before
-
Click OK to automatically connect the interfaces as before.
Notice that the AXI Interconnect block has the second master AXI (M01_AXI) port added and connected to the S_AXI of the leds.
-
Add another instance of GPIO, name the instance switches, configure it and connect it to the Zynq.
-
Add another instance of the GPIO peripheral .
-
Change the name of the block to switches.
-
Double click on the switches block, and select sws 2bits (PYNQ-Z1 and PYNQ-Z2) for the GPIO interface and click OK.
-
Click on Run Connection Automation
-
Click switches , and check the connections for GPIO and S_AXI as before
-
Click OK to automatically connect the interfaces as before.
Notice that the AXI Interconnect block has the third master AXI (M02_AXI) port added and connected to the S_AXI of the leds.
At this stage the design should look like as shown below.
Completed design
-
Verify that the addresses are assigned to the two GPIO instances and validate the design for no errors.
-
Select the Address Editor tab and see that the addresses are assigned to the three GPIO instances. They should look like as follows.
Assigned addresses
The addresses should be in the 0x40000000 to 0xbfffffff range as the instances are connected to M\_AXI\_GP0 port of the processing system instance. -
Select the Diagram tab, and click on the (Validate Design) button to make sure that there are no errors.
Ignore warnings.
-
Select File > Save Block Design to save the design.
-
Since all IO pins are board-aware no additional user constraints are need.
-
Create the top-level HDL of the embedded system. Add the provided constraints file and generate the bitstream.
-
In Vivado, select the Sources tab, expand the Design Sources, right-click the system.bd and select Create HDL Wrapper…
Selecting the system design to create the wrapper file
-
Click OK when prompted to allow Vivado to automatically manage this file.
The wrapper file, system_wrapper.v, is generated and added to the hierarchy. The wrapper file will be displayed in the Auxiliary pane.
Design Hierarchy View
-
Click on the Generate Bitstream in the Flow Navigator pane to synthesize and implement the design, and generate the bitstream. Click Save and Yes if prompted. Click OK to launch the runs.
-
When the bitstream generation is complete, click Cancel.
-
Export the hardware configuration by clicking File > Export > Export Hardware … Tick the box to include the bitstream and click OK.
Exporting the hardware
-
Launch SDK by clicking File > Launch SDK and click OK
(Launching SDK from Vivado will automatically load the SDK workspace associated with the current project. If launching SDK standalone, the workspace will need to be selected.)
SDK should open and automatically create a hardware platform project based on the configuration exported from Vivado. A board support package and software application will be created and associated with this hardware platform.
-
Select File > New > Board Support Package
Create BSP
-
Click Finish with the default settings selected (using the Standalone operating system).
This will open the Software Platform Settings form showing the OS and libraries selections.
-
Click OK to accept the default settings as we want to create a standalone_bsp_0 software platform project without any additional libraries.
-
The library generator will run in the background and will create the xparameters.h file in the lab1.sdk\standalone_bsp_0\ps7_cortexa9_0\include directory.
-
Create an empty application project, named lab1, and import the provided lab1.c file.
-
Select File > New > Application Project.
-
In the Project Name field, enter lab1 as the project name.
-
Select the Use existing option in the Board Support Package field and then click Next.
Create a Blank Application Project
-
Select the Empty Application template and click Finish.
The lab1 project will be created in the Project Explorer window of SDK.
-
Select lab1 > src directoryin the project view, right-click, and select Import.
-
Expand the General category and double-click on File System.
-
Browse to the {sources}\lab1 folder.
-
Select the lab1.c source file and click Finish.
A snippet of the source code is shown in the following figure. Note the greyed out code will be used in Lab5. The code reads from the switches, and writes to the LEDs. The BTN is read, and written to the LED.
Snippet of Source Code
Connect and power up the board. Establish serial communications using the SDK's Terminal tab. Verify the design functionality.
- Connect and power up the board.
- Select the tab. If it is not visible then select Window > Show view > Other > Terminal > Terminal.
- Click on and select appropriate COM port (depending on your computer), and configure the terminal with the parameters as shown below.
SDK Terminal Settings
- Select Xilinx > Program FPGA and then click the Program button.
- Make sure that the SW0-1 are not set to "11".
- Select the lab1 project in the Project Explorer, right-click and select Run As > Launch on Hardware(System Debugger) to download the application, execute ps7_init, and execute lab1.elf.
- You should see the following output on the Terminal console.
SDK Terminal Output
- Press BTN0-BTN3 (PYNQ-Z1, PYNQ-Z2) and see the corresponding LED light up.
- Set the two slide switches on PYNQ-Z1 or PYNQ-Z2 to the ON position to exit the program.
- Close SDK and Vivado programs by selecting File > Exit in each program.
- Turn OFF the power to the board.
In this lab, you created an ARM Cortex-A9 processor based embedded system using the Zynq device for the PYNQ-Z1/PYNQ-Z2 board. You instantiated the Xilinx standard GPIO IP to provide input and output functionality.
You created the project in Vivado, created the hardware system using IPI, implemented the design in Vivado, exported the generated bitstream to the SDK, created a software application in the SDK, and verified the functionality in hardware after programming the PL section and running the application from the DDR memory.