PowerPoint Presentation - HLS - Workshop - Final1
PowerPoint Presentation - HLS - Workshop - Final1
Copyright 2022 Adiuvo Engineering & Training, Ltd. 1 Copyright 2022 Adiuvo Engineering & Training, Ltd. 2
The contents of this workbook are created by Adiuvo Engineering & Training, Ltd.
Pre-Lab
If you have any questions about the contents, or need assistance, please contact Adam
Taylor at [email protected].
HLS Hero
Copyright 2022 Adiuvo Engineering & Training, Ltd. 3 Copyright 2022 Adiuvo Engineering & Training, Ltd. 4
Pre-Lab Pre-Lab
Required Hardware Downloads and Installations
Step 1 – Download and install the following at least 1 day prior to the workshop. This may take a
significant amount of time and drive space.
None Required Watch the video available here to show how to configure the installation
Copyright 2022 Adiuvo Engineering & Training, Ltd. 5 Copyright 2022 Adiuvo Engineering & Training, Ltd. 6
What is HLS
High Level Synthesis (HLS) enables generation of
Lab 1 RTL modules from higher level language such as C,
C++, OpenCL
Vitis HLS Flow
Of course, SW engineers still consider these low-
level languages.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 7 © Adiuvo Engineering and Training, Ltd. 2022
HLS Benefits Seconds / Minutes Iteration
Creating HLS Solutions
Software written for CPUs and software written for FPGAs is fundamentally
different
Developing in Higher Level language C Design
enables a faster iteration time.
• Development Time decreased as 1. Not all C constructs can be synthesised
untimed language – No RTL / Hours / Days Iteration 2. Learn about synthesizable C/C++ coding styles.
Behavioral level 3. Need to focus on correct micro architecture
1. Understand the producers and consumers
• Increased level of abstraction – 2. Decompose the algorithm into small section which interconnect
accelerates development RTL RTL
3. Understand throughput required for each element to achieve overall performance
goals
• Verification time is reduced as
untimed Simulation Verified RTL Verified RTL 4. Learn how to interpret the design reports
© Adiuvo Engineering and Training, Ltd. 2022 9 © Adiuvo Engineering and Training, Ltd. 2020 10
Package the IP Package for use in Vitis (XO) or Vivado (Xact IP)
© Adiuvo Engineering and Training, Ltd. 2022 11 © Adiuvo Engineering and Training, Ltd. 2022 12
Lab 1
Lab 1: Vitis HLS Flow
Clock Definition Step 1 – Open Vitis HLS 2021.2 and create a new project
© Adiuvo Engineering and Training, Ltd. 2022 13 Copyright 2022 Adiuvo Engineering & Training, Ltd. 14
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Enter a project name and select a location and click next Step 1 – I used the name VHlab1
Copyright 2022 Adiuvo Engineering & Training, Ltd. 15 Copyright 2022 Adiuvo Engineering & Training, Ltd. 16
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Click Next Step 1 – Click Next
Copyright 2022 Adiuvo Engineering & Training, Ltd. 17 Copyright 2022 Adiuvo Engineering & Training, Ltd. 18
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Leave all unchanged except for part selection, click to select Step 1 – Select board and select the SP701 Spartan 7 Board, Click OK
Copyright 2022 Adiuvo Engineering & Training, Ltd. 19 Copyright 2022 Adiuvo Engineering & Training, Ltd. 20
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Click Finish to create the project Step 1 – This will open the project ready for us to create the application
Copyright 2022 Adiuvo Engineering & Training, Ltd. 21 Copyright 2022 Adiuvo Engineering & Training, Ltd. 22
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Right Click on Source and Select new Source File Step 1 – Enter the name of the file as lab1.cpp, click save
Copyright 2022 Adiuvo Engineering & Training, Ltd. 23 Copyright 2022 Adiuvo Engineering & Training, Ltd. 24
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Enter the code as below – or Copy from the files on the GitHub. Save the file. Step 1 – Right Click on Source and Select new Source File
Copyright 2022 Adiuvo Engineering & Training, Ltd. 25 Copyright 2022 Adiuvo Engineering & Training, Ltd. 26
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Enter the name of the file as lab1.h click save Step 1 – Enter the code as below – or Copy from the files on the GitHub. Save the file.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 27 Copyright 2022 Adiuvo Engineering & Training, Ltd. 28
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Right Click on Test Bench and Select new Test Bench File. Step 1 – Enter the name of the file as tb_lab1.cpp click save
Copyright 2022 Adiuvo Engineering & Training, Ltd. 29 Copyright 2022 Adiuvo Engineering & Training, Ltd. 30
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Enter the code as below – or Copy from the files on the GitHub. Save the file. Step 1 – From the Run menus select C Simulation
Copyright 2022 Adiuvo Engineering & Training, Ltd. 31 Copyright 2022 Adiuvo Engineering & Training, Ltd. 32
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – On the dialog box select the launch debugger option, click OK Step 1 – This will open the debugger view, with the program paused for execution – we can run,
pause, single step using the menu, along with insert breakpoints
Copyright 2022 Adiuvo Engineering & Training, Ltd. 33 Copyright 2022 Adiuvo Engineering & Training, Ltd. 34
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Single Step a few of the instructions, hold the pointer over a variable and notice the contents Step 1 – Double click in the margin of line 29 to insert a breakpoint – this will be shown by a blue
pop up for inspection circle.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 35 Copyright 2022 Adiuvo Engineering & Training, Ltd. 36
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Click Run and you will see the breakpoint be hit, double click again in the margin to remove Step 1 – The application should run through, outputting pass or fail in the console and then terminate
the breakpoint and hit run. its run.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 37 Copyright 2022 Adiuvo Engineering & Training, Ltd. 38
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Exit the debug display by clicking exit debug Step 1 – From the setting menu select Project Settings
Copyright 2022 Adiuvo Engineering & Training, Ltd. 39 Copyright 2022 Adiuvo Engineering & Training, Ltd. 40
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Select Browse to select the top function Step 1 – Select lab1 (or the name of your function if you named it differently)
Copyright 2022 Adiuvo Engineering & Training, Ltd. 41 Copyright 2022 Adiuvo Engineering & Training, Ltd. 42
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Click OK Step 1 – Click on run and select C Synthesis
Copyright 2022 Adiuvo Engineering & Training, Ltd. 43 Copyright 2022 Adiuvo Engineering & Training, Ltd. 44
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Leave all options unchanged and select OK Step 1 – Once synthesis is complete you will see the report open notice the resources and interfaces
Copyright 2022 Adiuvo Engineering & Training, Ltd. 45 Copyright 2022 Adiuvo Engineering & Training, Ltd. 46
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Scroll down the report you will see the Top level Controls and Interface Info Step 1 – From the Schedule menu select Schedule View
Copyright 2022 Adiuvo Engineering & Training, Ltd. 47 Copyright 2022 Adiuvo Engineering & Training, Ltd. 48
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Examine the schedule view Step 1 – From the run menu select Co-Simulation
Copyright 2022 Adiuvo Engineering & Training, Ltd. 49 Copyright 2022 Adiuvo Engineering & Training, Ltd. 50
Lab 1 Lab 1
Lab 1: Vitis HLS Flow Lab 1: Vitis HLS Flow
Step 1 – Leave the options unchanged and click OK Step 1 – Observe the report which shows the completion of the Co Simulation and pass / fail.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 51 Copyright 2022 Adiuvo Engineering & Training, Ltd. 52
Lab 1 Summary
Lab 1 Summary
The concludes lab 1, throughout this lab we have demonstrated
Copyright 2022 Adiuvo Engineering & Training, Ltd. 53 Copyright 2022 Adiuvo Engineering & Training, Ltd. 54
© Adiuvo Engineering and Training, Ltd. 2022 55 © Adiuvo Engineering and Training, Ltd. 2022 56
Lab 2 Lab 2
Lab 2: Vitis HLS Interfacing Lab 2: Vitis HLS Interfacing
Step 1 – Create a new project called VHLab2, click OK. Step 1 – Create a new source file called lab2.cpp and enter the code below or copy from the GitHub.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 57 Copyright 2022 Adiuvo Engineering & Training, Ltd. 58
Lab 2 Lab 2
Lab 2: Vitis HLS Interfacing Lab 2: Vitis HLS Interfacing
Step 1 – Create a new source file called lab2.h and enter the code below or copy from the GitHub. Step 1 – Create a new source file called tb_lab2.cpp and enter the code below or copy from the
GitHub.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 59 Copyright 2022 Adiuvo Engineering & Training, Ltd. 60
Lab 2 Lab 2
Lab 2: Vitis HLS Interfacing Lab 2: Vitis HLS Interfacing
Step 1 – Run a C Simulation in the debugger, notice how this time the application is batch based Step 1 – Close the C Simulation and open the Lab2.cpp file, select the directives' view. Right click on
the lb2_label0 and select Insert Directive.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 61 Copyright 2022 Adiuvo Engineering & Training, Ltd. 62
Lab 2 Lab 2
Lab 2: Vitis HLS Interfacing Lab 2: Vitis HLS Interfacing
Step 1 – Insert the directive LOOP_TRIPCOUNT this informs the tool how many times the loop will Step 1 – Run the Synthesis you will notice the Trip Count is now recorded under the lab2 label0
execute in the maximum case.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 63 Copyright 2022 Adiuvo Engineering & Training, Ltd. 64
Lab 2 Lab 2
Lab 2: Vitis HLS Interfacing Lab 2: Vitis HLS Interfacing
Step 1 – Examine the HW Interfaces and notice the RAM Interfaces are AP_MEMORY and Register Step 1 – In the synthesis view add in a new directive for the source code for the port loop. Select
Interfaces. INTERFACE directive and for the mode select S_AXILITE
Copyright 2022 Adiuvo Engineering & Training, Ltd. 65 Copyright 2022 Adiuvo Engineering & Training, Ltd. 66
Lab 2 Lab 2
Lab 2: Vitis HLS Interfacing Lab 2: Vitis HLS Interfacing
Step 1 – In the synthesis view add in a new directive for the source code for the function. Select Step 1 – The Directives should appear as shown in the directives tab – Rerun synthesis
INTERFACE directive and for the mode select S_AXILITE
Copyright 2022 Adiuvo Engineering & Training, Ltd. 67 Copyright 2022 Adiuvo Engineering & Training, Ltd. 68
Lab 2 Lab 2 Summary
Lab 2: Vitis HLS Interfacing Lab 2 Summary
Step 1 – Examine the HW Interfaces in the report and notice control of the block and loop register are The concludes lab 2, throughout this lab we have demonstrated
now AXI registers
Copyright 2022 Adiuvo Engineering & Training, Ltd. 69 Copyright 2022 Adiuvo Engineering & Training, Ltd. 70
Lab 3
Lab 3: Vitis HLS Optimization
Step 1 – Create a new project called VHlab3.cpp
Lab 3
Vitis HLS Optimization
Copyright 2022 Adiuvo Engineering & Training, Ltd.2 71 Copyright 2022 Adiuvo Engineering & Training, Ltd. 72
Lab 3 Lab 3
Lab 3: Vitis HLS Optimization Lab 3: Vitis HLS Optimization
Step 1 – Create a new source file called lab3.cpp and enter the code below or copy from the GitHub. Step 1 – Create a new source file called lab3.h and enter the code below or copy from the GitHub.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 73 Copyright 2022 Adiuvo Engineering & Training, Ltd. 74
Lab 3 Lab 3
Lab 3: Vitis HLS Optimization Lab 3: Vitis HLS Optimization
Step 1 – Create a new source file called tb_lab3.cpp and enter the code below or copy from the Step 1 – Right Click on Test Bench File and select add Test Bench File
GitHub.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 75 Copyright 2022 Adiuvo Engineering & Training, Ltd. 76
Lab 3 Lab 3
Lab 3: Vitis HLS Optimization Lab 3: Vitis HLS Optimization
Step 1 – Add in the input.dat file provided on the GitHub Step 1 – Run the C Simulation and ensure the result is as shown below.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 77 Copyright 2022 Adiuvo Engineering & Training, Ltd. 78
Lab 3 Lab 3
Lab 3: Vitis HLS Optimization Lab 3: Vitis HLS Optimization
Step 1 – Select the top function of Sensor_Filter to allow synthesis – perform synthesis. Step 1 – Observe the synthesis interval and resources reported in the synthesis report.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 79 Copyright 2022 Adiuvo Engineering & Training, Ltd. 80
Lab 3 Lab 3
Lab 3: Vitis HLS Optimization Lab 3: Vitis HLS Optimization
Step 1 – Open the Function Call Graph for the Synthesis. Step 1 – Observe the information presented, change the heat map.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 81 Copyright 2022 Adiuvo Engineering & Training, Ltd. 82
Lab 3 Lab 3
Lab 3: Vitis HLS Optimization Lab 3: Vitis HLS Optimization
Step 1 – In the directives view for the source code add in a pragma to unroll the loop labelled accum. Step 1 – In the directives view for the source code add in a pragma to partition the array Input .
Copyright 2022 Adiuvo Engineering & Training, Ltd. 83 Copyright 2022 Adiuvo Engineering & Training, Ltd. 84
Lab 3 Lab 3 Summary
Lab 3: Vitis HLS Optimization Lab 3 Summary
Step 1 – Rerun synthesis and observe the interval and resources again. The concludes lab 3, throughout this lab we have demonstrated
2. How optimization pragma will change the resource and latency performance
Copyright 2022 Adiuvo Engineering & Training, Ltd. 85 Copyright 2022 Adiuvo Engineering & Training, Ltd. 86
Lab 4
Lab 4: Vitis HLS Arbitrary Precision Math
Step 1 – Create a new project called vhlab4.
Lab 4
Vitis HLS Arbitrary Precision Math
Copyright 2022 Adiuvo Engineering & Training, Ltd. 87 Copyright 2022 Adiuvo Engineering & Training, Ltd. 88
Lab 4 Lab 4
Lab 4: Vitis HLS Arbitrary Precision Math Lab 4: Vitis HLS Arbitrary Precision Math
Step 1 – Create a new source file called lab4.cpp and enter the code below or copy from the GitHub. Step 1 – Create a new source file called lab4.h and enter the code below or copy from the GitHub.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 89 Copyright 2022 Adiuvo Engineering & Training, Ltd. 90
Lab 4 Lab 4
Lab 4: Vitis HLS Arbitrary Precision Math Lab 4: Vitis HLS Arbitrary Precision Math
Step 1 – Create a new source file called tb_lab4.cpp and enter the code below or copy from the Step 1 – Run the Synthesis observe the interval and the resources required.
GitHub.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 91 Copyright 2022 Adiuvo Engineering & Training, Ltd. 92
Lab 4 Lab 4
Lab 4: Vitis HLS Arbitrary Precision Math Lab 4: Vitis HLS Arbitrary Precision Math
Step 1 – Examine the analysis view to see the operations involved. Step 1 – In the file lab4.h comment out the line define float_type.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 93 Copyright 2022 Adiuvo Engineering & Training, Ltd. 94
1. How to switch between floating point and arbitrary precision in your application
Copyright 2022 Adiuvo Engineering & Training, Ltd. 95 Copyright 2022 Adiuvo Engineering & Training, Ltd. 96
Lab 5
Lab 5: Vitis HLS Vitis Libraries
Step 1 – Open the Vitis libraries repository in GitHub.
Lab 5
Vitis HLS Vitis Libraries
Copyright 2022 Adiuvo Engineering & Training, Ltd. 97 Copyright 2022 Adiuvo Engineering & Training, Ltd. 98
Lab 5 Lab 5
Lab 5: Vitis HLS Vitis Libraries Lab 5: Vitis HLS Vitis Libraries
Step 1 – Download or clone the repository. Step 1 – If you downloaded the Zip Extract the files .
Copyright 2022 Adiuvo Engineering & Training, Ltd. 99 Copyright 2022 Adiuvo Engineering & Training, Ltd. 100
Lab 5 Lab 5
Lab 5: Vitis HLS Vitis Libraries Lab 5: Vitis HLS Vitis Libraries
Step 1 – Create a project called vhlab5. Step 1 – Right click on source and select Add Source File .
Copyright 2022 Adiuvo Engineering & Training, Ltd. 101 Copyright 2022 Adiuvo Engineering & Training, Ltd. 102
Lab 5 Lab 5
Lab 5: Vitis HLS Vitis Libraries Lab 5: Vitis HLS Vitis Libraries
Step 1 – Select the files, data_path.hpp, top_module.cpp and top_module.hpp from the location Step 1 – Right click on Test Bench and select Add Source File .
<install>\Vitis_Libraries\dsp\L1\examples\1Dfix_impluse\src
Copyright 2022 Adiuvo Engineering & Training, Ltd. 103 Copyright 2022 Adiuvo Engineering & Training, Ltd. 104
Lab 5 Lab 5
Lab 5: Vitis HLS Vitis Libraries Lab 5: Vitis HLS Vitis Libraries
Step 1 – Select the file main.cpp from the location Step 1 – Select the fft_top as the top function for the project
<install>\Vitis_Libraries\dsp\L1\examples\1Dfix_impluse\src
Copyright 2022 Adiuvo Engineering & Training, Ltd. 105 Copyright 2022 Adiuvo Engineering & Training, Ltd. 106
Lab 5 Lab 5
Lab 5: Vitis HLS Vitis Libraries Lab 5: Vitis HLS Vitis Libraries
Step 1 – Set the Cflags and Csimflags to Step 1 – Run synthesis this might take some time
-I../../../../../GIT/Vitis_Libraries/dsp/L1/include/hw/vitis_fft/fixed
Copyright 2022 Adiuvo Engineering & Training, Ltd. 107 Copyright 2022 Adiuvo Engineering & Training, Ltd. 108
Lab 5 Lab 5
Lab 5: Vitis HLS Vitis Libraries Lab 5: Vitis HLS Vitis Libraries
Step 1 – Examine the function call graph Step 1 – Examine the Dataflow graph
Copyright 2022 Adiuvo Engineering & Training, Ltd. 109 Copyright 2022 Adiuvo Engineering & Training, Ltd. 110
Lab 5 Lab 5
Lab 5: Vitis HLS Vitis Libraries Lab 5: Vitis HLS Vitis Libraries
Step 1 – Notice there is a timing error, Step 1 – Right click on the error and select go to timing violation
Copyright 2022 Adiuvo Engineering & Training, Ltd. 111 Copyright 2022 Adiuvo Engineering & Training, Ltd. 112
Lab 5 Lab 5
Lab 5: Vitis HLS Vitis Libraries Lab 5: Vitis HLS Vitis Libraries
Step 1 – Observe the timing violation in the schedule viewer Step 1 – Back in the timing violation, go to the source- notice the line of code causing the delay is
highlighted.
Copyright 2022 Adiuvo Engineering & Training, Ltd. 113 Copyright 2022 Adiuvo Engineering & Training, Ltd. 114
Lab 5 Summary
Lab 5 Summary
The concludes lab 5, throughout this lab we have demonstrated
2. How to include Level One elements from the library within Vitis HLS
4. How to observe the results in the function call and dataflow graph