Creating a new Vitis project

3050

Tools Installation

Download and install the Vitis tool from the Xilinx website. You will need to create and account and register with Xilinx to download Vitis. The installation image is quite large, so you’ll want a good internet connection.


Configuring the ZYNQ system for use

Immediately after power-on, the ZYNQ system (both the ARM processing system and the FPGA) must be configured to function in a particular setting on a particular circuit board before any software can be run. This “first stage boot loader” process configures ZYNQ by loading setup data into various system registers, and by programming the FPGA. A “Xilinx Support Archive” (.xsa) file contains all required setup data, and the contents of this file must be applied to the ARM system before any programs can be executed. The Vitis tool requires you to select and include an .xsa file before you can start writing software. Then, when Vitis downloads software to the ZYNQ device for execution, it will automatically transfer .xsa file contents to setup the ARM system for you.

The .xsa file defines many parameters, including clocking and memory system configurations, peripheral circuit interfaces and optional features, ZYNQ physical pin definitions, and FPGA programming data. In a later project, we’ll look more closely at the .xsa file contents. For now, if you are curious, you can use Vitis to look at the .xsa file contents by expanding the “blackboard” tab in the explorer window and opening the .xsa file and the “ps7_init” html file.

Figure 1. Vitis hardware definition settings

For this class, Real Digital has produced a single .xsa file that can be used to configure the ZYNQ system for all design projects. This .xsa file defines the ARM systems clock frequencies, the size, speed, and type of external memory used, and the peripheral circuits that are connected to external pins. It also configures the FPGA with circuits to allow the ARM processor to access Blackboard’s FPGA-connected I/O devices, including pushbuttons, slide switches, and LEDs. Note that this .xsa file must be applied to the Blackboard each time you start a new project.

blackboard.xsa

Create an empty VITIS Project

There are many ways to organize Vitis workspaces on your computer, but in general, creating a new directory for each major project (like each of the project assignments in this class) will help keep you organized. Before opening the Vitis tool, create a new project directory (something like “C:\ee234\proj1” or similar). Then, download the blackboard.xsa file into your new directory.

Start the Vitis tool. The first time you start the tool you will be asked to select a directory as your workspace – browse to the directory you created and click Launch. This will open the Vitis IDE, with the Welcome screen showing – you can close the Welcome screen.

Figure 2. Vitis Welcome Screen

After closing the welcome screen, you will see an empty Vitis IDE screen. The first step in creating a new project is to define the target hardware system, so that Vitis knows what hardware resources are available.

Define the Target hardware system

Click File -> New -> Application project as shown below.

In the “Create a New Application Project” dialog box that opens, click Next to bring up the New Application Project dialog box.

In the “New Application Project” box, select the” Create a new platform from hardware (XSA)” tab, browse to the blackboard.xsa file you downloaded, and click Next.

Figure 3. Screenshots showing the Create New Project process

In the Application Project Details box, enter a suitable name for your project (I chose EE234Proj1), and click Next. In the Domain dialog box that opens, click next to create a new domain. Finally, in the Templates dialog box, choose “Empty Application( C )” and click finish.

Now, all the configurations specified in the .xsa file are a part of your project, and this information will be downloaded to the Blackboard when you download whatever programs you write.

Figure 4. Screenshots showing application project detials

After the project workspace is defined, and the Vitis tool places you in the Workspace view. From here, you can see all the files associated with the project, including the hardware definitions that you just loaded and applied. Feel free to click around the workspace, and get a feel for what’s there. You can close the Application Project Settings window and the System Project Settings window if you would like – they are displayed by default in case you want to verify the settings.

Figure 4. The Vitis workspace view

Write software

Now you can add new source code files to your project. Right click on the “src” file icon located underneath your project name in the Explorer window, and click New -> File to bring up the New File box.

Figure 5. Add (software) source files

Enter a name for your source file, and be sure to use the “.S” suffix to tell the tools you are creating and assembly language source file (if you don’t use the .s suffix, it won’t work properly).

Figure 6. Be sure to use the “.S” suffix for assembly language sources

A blank editor window will appear. Now, you can add assembly code to the editor window.

Figure 7. Empty editor view

Copy the following Assembly source code into the Assembly file you just defined. Your editor window should look like the picture below. To execute the program, you must first build the software project, and then choose a Run Configuration. To build the software project, make sure the src folder is selected in the explorer window, and then click Project -> Build Project. Since you already built the hardware part of the project, this should go fairly quickly.

.text
.global main

@define constants, these can be used as symbols in your code
.equ LED_CTL, 0x41210000
.set SW_DATA, 0x41220000

@the set and equ directives are equivalent and can be used interchangeably

main:
	ldr r1,=SW_DATA	@load switch address from constant
	ldr r2,=LED_CTL	@load LED address from constant
loop:
	ldr r0,[r1]	@load switch value *r1 ->r0
	str r0,[r2]	@store value to led register *r2 <-r0
	b loop		@go back to "loop"

.end

Figure 8. Build the software

To choose a Run Configuration, open the pull-down menu next to the run icon (the white arrow in the green circle), and choose Run Configurations. In the window that opens, double-click the Single Application Debug (GDB) option.

Figure 9. Choose a Run Configuration

That will bring up the GDB Run Configuration settings screen. For now, you can leave all the defaults as they are, and click Run in the lower right corner. That will transfer your program to the Blackboard and start it running.

Figure 10. Run your project

After a Run Configuration has been selected, you can just click the arrow icon for future runs. Note that the Run Configuration programs the FPGA by default. If you don’t power-cycle your board, you can make the Run process faster by turning off FPGA programming for each new run. To turn off automatic FPGA programming, select the “Target Setup” tab in the Run Configuration, and uncheck “Reset entire system” and “Program FPGA”.

Figure 11. Run Configuration settings

After you have successfully programmed your Blackboard, you should be able to control the individual LEDs with the slide switches. That’s it for this tutorial! Before moving on, you are highly encouraged to spend a few moments looking around the tool space, and building more familiarity with the environment.