Skip to content

oddek/CS4110-HLS-Tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

Using HLS with Zybo Zynq-7000 development board

Table of Contents

  1. High Level Synthesis in Vitis HLS
    1. Create New Project
    2. Create Source Files
    3. Get Source Code from Github
    4. Simulation and Synthesis
    5. Export RTL as IP
  2. Hardware Setup in Vivado
    1. Create New Project
    2. Create Block Design
    3. Create HDL Wrapper and Generate Bitstream
    4. Export Hardware Platform
  3. Application Setup in Vitis
    1. Create Platform Project
    2. Create Application Project
    3. Get Source Code from Github
    4. Build and Run Project
  4. Further Reading

Introduction

This is a complete guide for utilising a Vitis HLS design with the Zybo Zynq-7000 development board. We will use a simple FIR (Finite Impulse Response) moving average filter as an example.

The guide has been made for the USN course CS4110 by Kent Odde and Stian Onarheim upon request of Professor Jose Ferreira.

Prerequisites

  • Vitis 2021.X
  • Viviado 2021.X
  • Vitis HLS 2021.X
  • Zybo Zynq-7000 development board

1. High Level Synthesis in Vitis HLS

1.1 Create New Project

Open up Vitis HLS and choose Create Project.

Image

Give the project a suitable name and location.

Image

For now, skip adding design and testbench files. We will do this at a later stage. Click Next.

Image

Click the "Three horizontal dots" button under Part Selection.

Image

In the Device Selection Dialog, press Boards and search for Zybo. To install board files, look at Jose and Manuels guide here.

If the board does not show up, try clicking Boards again after searching and the board should appear.

If on Linux, also follow the instructions in the last post here.

Image

Give the solution a suitable name and press Finish.

Image

1.2 Create Source Files

On the left side in the Explorer window, right-click Sources and click New file. Add the files fir.c and fir.h.

Right-click on Test Bench, click New file and add the file tb.c.

Image

The file tree should now look like this:

Image

1.3 Get Source Code from Github

The source code can be found here:

The files should now look like this:

fir.h

Image

fir.c

Image

tb.c

Image

Go to Project --> Project Settings --> Syntesis. Select fir.c and click Browse to select the top level function for synthesis. In our case this is fir.

Image

1.4 Simulation and Synthesis

In the Flow navigator window as seen below:

Image

Run the C simulation and ensure that the output looks something like this:

utput:  Abbbbbbbbbbbbbbbbbb
INFO: [SIM 211-1] CSim done with 0 errors.
INFO: [SIM 211-3] *************** CSIM finish ***************
INFO: [HLS 200-111] Finished Command csim_design CPU user time: 23.45 seconds. CPU system time: 1.31 seconds. Elapsed time: 24.48 seconds; current allocated memory: 251.756 MB.
Finished C simulation.

Run the C Synthesis and ensure that the output looks something like this:

Image

The code is not optimised and has timing violations. Since this is only an example, this is fine.

[Optional] Improve the latency

Swap out the content of fir.c with fir_improved.c and run C Synthesis again.

Image

1.5 Export RTL as IP

In the Flow navigator window, press the Export RTL button and save the ZIP file in a suitable location. When prompted by the Run Cosimulation window, keep it set to Verilog, and set dump trace to all in order to later see the waveform. (See image below).

Image

Image

[Optional] View the waveform

Run Cosimulation and press the Waveform button in the top menu and wait for the Vivado program to open.

Image

It should look something like this:

Image

2. Hardware Setup in Vivado

2.1 Create New Project

As we assume some familiarity with the Vivado Design Suite, we will not go over how to create a new project. Create a new Vivado project and do not create any files.

Remember to select the correct board file. You can find it by searching for Zybo. (You might have to click the 'Refresh' button). Ensure that the Board Rev is B.3.

Image

2.2 Create Block Design

In the Flow Navigator window, under IP INTEGRATOR click Create Block Design.

Image

In the Diagram window, press the + button or right-click and press Add IP.

Search for Zynq in the pop-up window and double-click ZYNQ7 Processing System.

Image

Locate the ZIP file that we exported in step 1.5, and unzip the file.

Image

Go back to the Flow Navigator window in Vivado and click IP Catalog under PROJECT MANAGER.

Right-click anywhere in the IP Catalog tab and click Add Repository and select the folder that we unzipped.

Image

Expand the User Repository folder and double-click Fir.

Image

Click the Add IP to Block Design button.

Image

Return to the Diagram window. It should now look something like this:

Image

Click Run Block Automation. The presets should look like the image below. Click the OK button.

Image

Click Run Connection Automation. The presets should look like the image below. Click the OK button.

Image

Click the Regenerate Layout button located in the Diagram window's toolbar.

Image

If everything is done correctly, the diagram should now look like this:

Image

Click the Validate Design button located in the Diagram window's toolbar.

Image

Ignore the four critical warning messages. Click the OK button.

Image

2.3 Create HDL Wrapper and Generate Bitstream

Right-click the design file under Sources and click Create HDL Wrapper.

Image

Select the Let Vivado manage wrapper and auto-update option and click the OK button.

Image

In the Flow Navigator window, click the Generate Bitstream button located under PROGRAM AND DEBUG.

Image

Click the OK button.

Image

This will take some time. Eventually you will be met with a window like this:

Image

2.4 Export Hardware Platform

Click File --> Export --> Export Hardware.

Image

Choose the Include bitstream option and click the Next button.

Image

Choose a suitable XSA file name and location. In the final window, click the Finish button.

Image

3. Application Setup in Vitis

3.1 Create Platform Project

Start Vitis IDE and choose a suitable location for your workspace.

Image

When met by the welcome screen, choose Create Platform Project.

Image

Choose a suitable platform project name and click Next.

Image

Under Hardware Spesification click Browse and select the XSA file that we created in step 2.4.

Ensure that the Software Specification section matches the image below, and click Finish.

Image

After the project has been generated, you will be met with this window.

Image

In the Explorer window on the left, right-click the platform project, and click Build Project.

Image

3.2 Create Application Project

Create the Application Project. Click File --> New --> Application Project.

Image

Select the platform you created previously and click Next.

Image

Give the Application Project a suitable name and click Next.

Image

Click Next.

Image

Select the Hello World template and click Finish.

Image

You will now be met by the generated Application Project. It should look something like this:

Image

3.3 Get Source Code from Github

The source code can be found here:

Swap the file content of helloworld.c with src/main.c from the Git repository.

3.4 Build and Run Project

In the Explorer window, right-click your application and choose Build Project.

Image

Remember to set the boot mode jumper (21 in the Figure) to JTAG mode (to the far right).

Image

Then right-click your application again and choose Run As --> Launch Hardware.

Image

Use a serial communication tool (screen, PuTTY) to interact with your application running on the Zybo.

Image

It should look something like this:

At all times it should print out the moving average of the three last entered characters.

For instance, entering the sequence a b c repeatedly, should result in only b's as output as this will be the current moving average.

Image

Further Reading

See section 4 in the Vitis High-Level Synthesis User Guide for more information about the AXI4-Lite slave C drivers.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages