Lab 6: Programmable Microelectronic System on Zynq

This text is based on teaching materials from Xilinx (www.xilinx.com).

Contents

Contents. 2

Introduction. 2

Setup. 2

Step 1: Creating microprocessor system with Zynq processing platform.. 3

Step 2: Creating Block diagram of the microprocessor system.. 10

Step 3: Synthesis and implementation of the hardware. 14

Step 4: Creating new software project in SDK. 16

Step 5: Write the software. 20

Step 6: Compare the performance of Zynq microprocessor system with the MicroBlaze processor system   21

Conclusions. 22

Results required to complete the exercise. 22

Change history. 22

Introduction

This lab guides you through the process of creating the processor system o Xilinx’s Zynq platform. As with Nexys and Microblaze in the previous labs, you also will use the same tools: Vivado and Xilinx SDK. You run simple software on Zynq-based system and you will compare it with the MicroBlaze-based system.

Setup

For this lab, you will need a Xilinx Zybo Z7 FPGA Board and a USB cable:

You will also need Nexys A7 board and another USB cable:

Connect the USB cable to the PC and the Zybo board to connector PROG/UART. Connect another USB cable to the PC and the Nexys A7 board to connector PROG/UART. With those cables, the programming of the FPGAs will be done, as well as serial communication between the boards and PC.

Step 1: Creating microprocessor system with Zynq processing platform

1.      Run Vivado  from desktop or menu: All Apps/Xilinx Design Tools Vivado 2018.3.

2.      In Vivado create new project (File/Project/New): 

New window will open with New Project wizard:

3.      Enter the name of your project. The Project location should contain the directory where you are allowed to write (for example C:\Designs) and make sure that Create project subdirectory checkbox is selected, because software will create the directory of the same name as your design name and all the design files will be placed in this folder.

In Project Type window, select RTL Project:

4.      In Add Sources you can select your preferred HDL language (Target language). You will not add any files here, so click Next:

5.      In the next window you will also do not add any constraints, so click Next. The constraints can be added later, if needed.

6.      In Default Part, first switch from Parts view to Boards view, then select the line with Zybo Z7-20. Do not click directly on blue text “Zybo Z7-20” because it is a link which will open in a browser, but click anywhere to the right on this line (green rectangle on the picture). Finally click Next.

 

7.      The last screen of this wizard presents the summary. Just click Finish.

Step 2: Creating Block diagram of the microprocessor system

1.      Having created the empty project, now you will add the microprocessor system using block diagram design entry method. This will be done with IP INTEGRATOR flow by creating Block Design. Click Create Block Design:

2.      In the next window you can set the name of the block design, do not change anything else. Press OK and wait for creating new block diagram.

 

3.      Now add the following new blocks using +

 and searching for the appropriate block names:

·      ZYNQ7 Processing System

·      AXI GPIO

4.      When finished, click  to regenerate the diagram, then click Run Block Automation Wizard, with default settings which will help you to configure the Zynq subsystem.

5.      When Block Automation finishes, start the Connection Automation Wizard. For GPIO, select leds_4bits:

 

 

6.       Your diagram should look like this:

You can validate your block diagram using button Validate Design (F6):

The block design should have no errors:

 

Step 3: Synthesis and implementation of the hardware

1.      Your block design is now a part of the design sources, you can see it in the Sources tab. To use such a block diagram in the implementation flow, you need to wrap it in HDL block. This can be done with the Create HDL Wrapper command:

Let Vivado manage the updates of the HDL file and click OK:

2.      Now in the Sources tab you will see another level of the hierarchy in your project: the block design in instantiated inside HDL file:

3.      The hardware is ready and you can synthesize and implement it. It is enough to click Generate Bitstream.

4.      After several minutes your hardware will be synthesized and implemented, the bitstream file containing the FPGA hardware configuration will be created. The current status of Vivado is presented in top-right corner of the screen:

You can also look at Deign Runs window at the bottom.

When you see write_bitstream Complete message, your hardware is now ready, but you need to create software. This will be done in Xilinx SDK.

Step 4: Creating new software project in SDK

Having your hardware ready, you need to create software.

1.      Export your hardware from Vivado to Xilinx SDK. In Vivado you will export your design and launch Xilinx SDK with the following commands:

Do not forget to select the include the bitstream in the exported platform:

2.      Finally you launch Xilinx SDK to start creating the software from menu File/Launch SDK. Xilinx SDK opens with already created hardware platform imported from Vivado.

3.      Create new application project from menu File/New/Application project: or right-click in Project Explorer:

Enter the name of your application. You should also let the software to create new Board Support Package (BSP) for this platform.

Then you ask for creation of template project containing tests for the peripheral devices available in the system and click Finish:

Step 5: Write the software

Write the software that blinks the LEDs on Zybo board. LEDs are connected to GPIO, so you should use the drivers  of GPIO to control the state of the outputs. Present the code and it results.

As you have two prototype boards connected to your PC, when programming FPGA and running the software, you should follow the procedure given here: Working with multiple FPGAs connected to the PC. If you have problems with programming and you cannot manually reset the board (remote lab), check this document: Remote reset by JTAG.

Step 6: Compare the performance of Zynq microprocessor system with the MicroBlaze processor system

Run the software listed below on the following platform:

·      Zynq processor system created in this lab

·      MicroBlaze processor system created in lab4

and measure the time using the stop-watch. Compare, analyze and present the results.

The software below calculates the sum of the series [ 1-X^2/2!+X^4/4!- .........], you can adjust n to change the calculation time. This software runs on both Zynq and MicroBlaze.

#include <stdio.h>
#include "xil_printf.h"
#include "xparameters.h"
// *****************************************************************
void printFloat(float fval) {
   int intergerPart, fractionalPart;
   intergerPart = fval;
   fractionalPart = (fval - intergerPart) * 1000;
    xil_printf("%d.%3d", intergerPart, fractionalPart);
}
// *****************************************************************
int main()
{
   double x, sum, t, d;
   int i,n;
   x=0.5;
   n=1000000;
 
#ifdef PLATFORM_MB
   xil_printf("\n\rCalculations on MicroBlaze:\n\r");
#endif // PLATFORM_ZYNQ
 
#ifdef PLATFORM_ZYNQ
   xil_printf("\n\rCalculations on Zynq:\n\r");
#endif // PLATFORM_ZYNQ
 
   xil_printf("Value of x=");
   printFloat(x);
   xil_printf(", number of terms=%d\n\r", n);
   xil_printf("Calculation...");
   sum = 1; t = 1;
   for (i=1;i<n;i++)
   {
     d = (2*i)*(2*i-1);
     t = -t*x*x/d;
     sum =sum+ t;
   }
   xil_printf(" finished.\n\r");
   xil_printf("The sum="); printFloat(sum); xil_printf("\n\r");
}
// *****************************************************************

Conclusions

You built two programmable microelectronic systems: with a Microblaze soft processor on Nexys board and with an Arm hard processor on the Zynq platform and compared the execution time of the same algorithm written in C.

Results required to complete the exercise

·      Answer the questions in the test: https://docs.google.com/forms/d/e/1FAIpQLSfgSg8J9Fm5fUz9LoRpSG8tynBdAgtq61-4xrak6Uy3Hus8CQ/viewform?usp=sf_link

·      Present the operation of your software on Zybo with bliknking LEDs.

·      Present the operation of “sum of series” software on Nexys and Zybo boards.

Change history

Adaptation to version Vivado 2018.3: M. Wójcikowski (08/2020).