Creating combined hardware projects for the ARM and FPGA

How to instantiate ZYNQ's ARM processor and add custom IP

11875

Step 1: Tools installation

If you haven’t already installed the Xilinx Vivado and SDK tools, you can follow this tutorial.

Step 2: Create a Vivado Project

Create an empty project in using the latest version of Vivado. Make sure that you select the correct FPGA part for the Blackboard’s Zynq chip. If you need some guidance, you can follow this tutorial.

Step 3: Prepare the Hardware Design

You are now ready to create a block design for your system. This involves creating, adding, and editing a Zynq Processing System as well a custom AXI4 IPcore. Follow this tutorial to prepare the hardware design (make sure to follow all the steps!).

Step 4: Synthesize, Implementation, and Generate Bitstream

After the hardware system is defined, it can be synthesized and implemented. Follow the steps in this tutorial to generate bitstream for your Vivado Project.

Step 5: Design Software using Xilinx Vitis

Export Hardware

To design ARM software that can communicate with your custom AXI IP, you need to export the hardware design for use in Vitis. The hardware design can be imported into Vitis as a .xsa file which tells the IDE about the memory address space of the processor, specifically how axi-bus slaves are mapped into the address space.

To export a hardware description file, open File Menu, select Export Hardware item under Export.

Figure 1. Export Hardware
Figure 1. Export Hardware

You will be asked to select a platform type. Select ‘Fixed’ here and click next.

Figure 2a. Select Platform Type
Figure 2a. Select Platform Type

Next, you will be asked which kind of output to create. Select the option to include the bitstream in the exported platform. Continue on to the next dialogue.

Figure 2b. Select Output Type
Figure 2b. Select Output Type

Now you can enter the output file name and export location. By default the export location is within the Vivado project directory. You can leave the default path or place it somewhere else. Make sure you remember where you saved the file as you will need it when importing the platform into Vitis

Figure 2c. Confirm output file name and path
Figure 2c. Confirm output file name and path

The final dialogue lets you review the settings and path you selected. Finishing the wizard will write the output xsa to the displayed location.

Figure 2d. Confirm export Hardware
Figure 2d. Confirm export Hardware

Launch Vitis and Import Hardware Platform

To write a c program for controlling your new LED axi IP, open the Vitis software IDE. This can be done through your system or in Vivado under the ‘tools’ menu tab.

Figure 3. Launch Vitis from Vivado
Figure 3. Launch Vitis from Vivado

If this is your first time launching Vitis, you will be prompted to open a workspace. Even if you have previously created a workspace, it is recommended you create a new workspace for each hardware platform you develop.

Figure 4. Select a workspace
Figure 4. Select a workspace

Create a Platform Project The Exported Hardware Platform

The first time you open vitis, you will see the ‘welcome’ screen. Here you can select “Create Platform Project” to import your custom hardware platform.

Figure 5a. Create Platform Project from Vitis Welcome Screen
Figure 5a. Create Platform Project from Vitis Welcome Screen

If Vitis doesn’t open to the welcome screen, you can create a platform project from the ‘file’ menu, under the ‘new’ submenu.

Figure 6b. Create Platform Project from File Menu
Figure 6b. Create Platform Project from File Menu

Now the new platform project dialog will appear. Enter a name for the project, then select next.

Figure 6a. Name Entry for Platform Project
Figure 6a. Name Entry for Platform Project

The next screen will ask you the source of the platform description. Select “Create from hardware specification (XSA)” and continue.

Figure 6b. Create from XSA
Figure 6b. Create from XSA

Vitis will now ask you for the location of the exported hardware platform file. Select the file you exported from Vivado and click finish to create the platform project.

Figure 6c. Select XSA Hardware Platform File
Figure 6c. Select XSA Hardware Platform File

Vitis should now display your imported platform in the main editor window. Additionally, in the project explorer you will see the platform project you just created. There may be a small exclamation point icon above your platform project. If you hover over the icon, Vitis may indicate that the platform is ‘out-of-date’.

Figure 7. Imported XSA into Platfom Project in Vitis IDE
Figure 7. Imported XSA into Platfom Project in Vitis IDE

By right clicking on the project in the explorer, you can select ‘Build Project’ in the drop-down menu. Vitis will now compile the platform project. Once the build succeeds, the out-of-date warning should disappear.

Figure 8. Build “out-of-date” Platform Project
Figure 8. Build “out-of-date” Platform Project

Creating an Application Project

Now you can add a project for your program. In the ‘file’ menu, under the ‘new’ sub-menu, select “Application Project”.

Figure 9. New Application Project
Figure 9. New Application Project

The new project wizard will ask for a hardware platform to use. Select the platform project you created earlier and continue.

Figure 10a. Select Hardware Platform
Figure 10a. Select Hardware Platform

In the next dialogue, enter the name for your project. There is also a place to select a ‘system project’. For your first project you must create a system project, but other projects sharing the same hardware platform can also share the same system project.

Figure 10b. Enter Project Name and Select System Project
Figure 10b. Enter Project Name and Select System Project

The wizard will now ask for a ‘domain’. Select the only option availible and continue

Figure 10c. Select Project Domain
Figure 10c. Select Project Domain

Finally, the wizard will have you select an application template. Choose “Empty Application” and click ‘Finish’ to create the project.

Figure 10d. Select Application Template
Figure 10d. Select Application Template

Now your empty Application project will appear in the project explorer

Figure 11. Empty Project Added
Figure 11. Empty Project Added

Add a Source File, Write Code, and Compile

In your newly created project, right click on the ‘src’ directory. In the dropdown menu select ‘new’->‘file’. In the following dialogue enter the name for the source file you want to create. For this tutorial you can create ‘main.c’.

Figure 12. Add Source File
Figure 12. Add Source File

You can now open the source file to edit your program. To test your custom IP core, you can paste the following sample program into your ‘main.c’ file.

#include "xil_types.h"

//Macro for accessing memory address for read/write
//(permanently dereferenced constant pointer)
#define LED_CTL *((uint32_t *) 0x4BB00000)

//test custom LED IP by blinking the lights using software delay
int main()
{

	int i=0;

	//turn off all LEDs
	LED_CTL =0;

	while(1)
	{

		//invert content of register using bitwise invert
		LED_CTL = ~LED_CTL;


		//do nothing for a delay
		for(i=0; i<10000000; i++)
			;
	}

	return 1;
}

Once you have entered your program, you can compile it. Make sure either the application project or a source file within is selected, then click on the ‘Hammer’ icon in the toolbar. You can also right click on a project and build it from the drop-down menu.

Figure 13. Build Application Project
Figure 13. Build Application Project

When the application compiles successfully, the binary ‘.elf’ file will appear under your project.

Figure 14. Compiled ‘.elf’ Binary
Figure 14. Compiled ‘.elf’ Binary

Run Program

Once you have generated an executable binary, you can run your program on the Blackboard. Right click on your project in the explorer and select ‘Run As’->‘Launch on Hardware’. By default Vitis will attempt to program the FPGA with the bitstream included in the hardware platform. If not follow the steps in the section below to do so manually.

Figure 15. Launch Program on Hardware
Figure 15. Launch Program on Hardware

Program FPGA Manually

To program the FPGA Manually from Vitis, Select “Program FPGA” from the ‘Xilinx’ Menu.

Figure 16. Select Program FPGA in Xilinx Menu
Figure 16. Select Program FPGA in Xilinx Menu

In the Program FPGA dialogue, you can choose a bitstream to program. If the bitstream from the hardware platform you imported is not already selected, add it here. Once a bitstream is selected click ‘Program’ to upload the bitstream and configure the FPGA.

Figure 17. Bitstream Selection and Program Dialogue
Figure 17. Bitstream Selection and Program Dialogue

Once you have programmed the FPGA you can run your program on the board, using the steps above.

If you are successful, the provided program will make the LED’s on the board toggle on and off.