Creating combined hardware projects for the ARM and FPGA

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

2160

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 SDK

Export Hardware

To design ARM software that can communicate with your custom IPcore, you need to export the hardware design for use in SDK. This configures SDK with knowledge of the ARM’s address space your custom peripheral is mapped to.

To do this, open File Menu, select Export Hardware item under Export.

Figure 1. Export Hardware
Figure 1. Export Hardware

Select Include bitstream, and then click OK. This will save the configuration for SDK.

Figure 2. Include Bitstream When Exporting Hardware
Figure 2. Include Bitstream When Exporting Hardware

Launch SDK

Launch Xilinx Software Design Kit (SDK) by selecting Launch SDK in the File menu. Click OK in the pop-up window.

Figure 3. Launch SDK from Vivado
Figure 3. Launch SDK from Vivado

SDK Internal Error

If SDK failed to launch with an internal error complaining about some .../.metadata directory is read-only, you probably have a white space in the path leading to your project folder. Move the project folder to somewhere whose path string has no white space, the problem will go away. Please see this Xilinx Forum Thread for more details.

Create Application Project

After SDK launches, it will automatically import the Hardware Design you exported in previous steps. Use the New button and select Application Project to create a C-based software project.

Figure 4. Create Application Project
Figure 4. Create Application Project

The New Project dialog will pop up. Pick a name for your project as shown in Figure 5, and then click Next.

Figure 5. Create Project
Figure 5. Create Project

Select Empty Application and click Finish to create an empty project.

Figure 6. Create an Empty Project
Figure 6. Create an Empty Project

Create C Source File

Your newly created project is automatically added to the Project Explorer panel on the top left of SDK. Expand the project and right clik on the src folder. Navigate to the New menu, then select Source File.

Figure 7. New Source File for Your Project
Figure 7. New Source File for Your Project

The New Source File dialog will pop up. Put main.c as the source file name, then click Finish.

Figure 8. Add main.c to Application Source Folder
Figure 8. Add main.c to Application Source Folder

Edit main.c

Open up main.c file and copy the following code into the file.

#include "xil_types.h"

// Macro to access the base address of your LED controller
#define my_LED *((uint32_t *)0x4BB00000)

int main() 
{
    int i = 0;

    // Turn off all LEDs
    my_LED = 0x00;

    // Infinite loop
    while (1) {

        // invert the LED value
	my_LED= ~my_LED;

        // Delay
        for (i = 0; i < 10000000; i++);
    }
    return 1;
}

Step 6: Program FPGA and Launch on Hardware

Go to TUTORIAL: Programming FPGA and Lanching Software on Hardware and follow a short step by step tutorial on how you can test your first embedded software project.