Department of Information Engineering and Mathematics...

55
http://www.dii.unisi.it/~giorgi/teaching/hpca2 Vivado High Level Synthesis (HLS) Department of Information Engineering and Mathematics Presenter: Eng. Farnam Khalili (under supervision of Prof. Roberto Giorgi) Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55 1

Transcript of Department of Information Engineering and Mathematics...

Page 1: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

http://www.dii.unisi.it/~giorgi/teaching/hpca2

Vivado High Level Synthesis (HLS)

Department of Information Engineering and Mathematics

Presenter: Eng. Farnam Khalili(under supervision of Prof. Roberto Giorgi)

Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 551

Page 2: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Outline

• Introduction• HLS advantage/disadvantage• How does HLS work?• Vivado HLS work flow • Examples

Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 552

Page 3: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Introduction:

3Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Vivado High Level Synthesis (HLS)

Available in production today C/C++/SystemC• Adopted across broad base of applications and

markets • Proven on real customer designs • Clear differentiator for accelerating design

productivity

[1]

FPGA

Image courtesy of Xilinx

Page 4: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Introduction:

4Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

• The idea of HLS is to accelerate the HDL production (IP Core) of your desired algorithm base on C/C++/SystemC

• Create RTL implementation from C level source code

• Implements the design based on defaults and user applied directives

• Implements different solutions with the same source C description

Vivado High Level Synthesis (HLS)

[1]

Image courtesy of Xilinx

Sys Generator IP Catalog

Page 5: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)

[1]

Introduction:

5Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55Image courtesy of Xilinx

Page 6: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)

[1]

• Only for 7 series FPGA and Zynq SoC Vivado Implementation

Introduction:

6Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55 Image courtesy of Xilinx

Page 7: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)HLS Advantages:

• Increased system performance• Using HDL (Verilog/VHDL) sometimes is time consuming and inconvenient for high level algorithms like DSP (digital signal processing) and mathematical algorithms.

• BOM (Bill of Material )cost reduction • Reduced total power consumption • Build better system with fewer chips and faster way. • Efficient specification using C/C++/SystemC• Directive based design exploration• Comprehensive integration

7Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 8: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)HLS Disadvantages:

The generated HDL code is not the most readable You have not any control on your hardware architecture!• Vivado HLS has following C/C++ limitations:

1) No dynamic memory (all need to be static). For instance, no malloc, new, delete or free

2) Doesn’t support STD, FILE-I/O (no system calls)3) Recursive functions must be avoided

8Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 9: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)How does HLS work?

• Your code will be extracted as a Finite State Machine

9Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Function Start

Function End

For Loop Start

For Loop End

Image courtesy of Dr. F Rincon Calle

Page 10: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)How does HLS work?

• Operations are extracted and mapped to each states

10Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

A unified control dataflow behavior is created

Image courtesy of Dr. F Rincon Calle

Page 11: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)How does HLS work?

• Scheduling the operations by mapping them into clock cycles

11Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55Image courtesy of Dr. F Rincon Calle

Page 12: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)How does HLS work?

• Assigning the operations to available functional units

12Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55Image courtesy of Dr. F Rincon Calle

Page 13: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Key attributes of code

13Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Functions: represents the design hierarchy

Top Level IO: Top-level arguments determine interface ports

Types: Types influences area and performance

Loops: Their scheduling has major impact on areaAnd performance

Operators: can be shared or replicated to meet performance

Arrays: mapped into memory. May become main performance bottlenecks

Page 14: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Functions and RTL hierarchy

14Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Source Code (Function)Each function is translated to an RTL block using in

Vivado block design (As an IP)

Vivado HLS Environment

Vivado Block Design Enviroment

Page 15: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Example:

1) Definition of the function/algorithm2) Simulation the compiled code3) Synthesis of compiled cod (RTL implementation)4) Co-simulation the design

15Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 16: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Vivado HLS getting started:

16Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 17: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Creating a new project:

17Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 18: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Adding a new C/C++ file:

18Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 19: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Adding a test-bench file (c/c++):

19Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 20: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Setting the solution configuration:

20Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 21: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Vivado HLS Environment:

21Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Commands Toolbar Environment Perspectives

Auxiliary Pane : you canSet different Directives and

OutlinesInformation Pane: you can open/edit your codes (C/C++/Verilog/VHDL/etc) and check

solution reports.

Console Pane: you can monitor system messages, errors, warnings

Explorer Pane: hierarchical of project files

Page 22: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Specifying the Top Function:

22Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Once your code are finished you have to specify the top

function

Page 23: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Specifying the Top Function:

23Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Once your codes are finished you have to specify the top function

Page 24: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Running C Simulation:

24Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

To verify that your C code is correct and has no error!

Page 25: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Debugging your C project:

25Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

You may be asked to open the Debug perspective

Page 26: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Synthesizing your C code:

26Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 27: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Applying Directive to your Function:

27Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 28: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Applying Directive to your Function:

28Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 29: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Applying Directive to your Function:

29Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 30: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Synthesizing your C code with new Directive:

30Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 31: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Running C/RTL Co simulation:

31Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 32: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Running C/RTL Co simulation:

32Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 33: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Opening the wave viewer:

33Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 34: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Opening the wave viewer:

34Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 35: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Export RTL of your C code:

35Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 36: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Export RTL of your C code:

36Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 37: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

You can find generated Verilog from “impl” folder:

37Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 38: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Image courtesy of Xilinx

Using generated IP in Vivado block design:

•Creating a new Vivado project

38Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 39: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Using generated IP in Vivado block design:

• Getting started with Vivado 2017.2 design tool

39Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 40: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Using generated IP in Vivado block design:

•Getting started with Vivado 2017.2 design tool

40Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 41: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Using generated IP in Vivado block design:

•Creating a new Vivado project

41Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 42: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Using generated IP in Vivado block design:

•Creating a new Vivado project

42Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 43: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Using generated IP in Vivado block design:

• We have not any User VHDL/Verilog source code in our project, so just next please!

43Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 44: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Using generated IP in Vivado block design:

• We can later add the desired constraint file!

44Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 45: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)

Using generated IP in Vivado block design:

• Specifying the targeted Xilinx part

45Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 46: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Using generated IP in Vivado block design:

• Summary of the project that would be created:

46Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 47: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)The Vivado design suite environment

47Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 48: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)

HDL source HDL source codes/ Block

designsSynthesize Implement Generate

Bitstream

XSTXST BitGenBitGenFPGA

Bitstream

Translate Map Place & Route

Design flow in Vivado Design Suite

48Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 49: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)

1

2

3

4

Adding the generated IP to IP repositories of vivado project:

49Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 50: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Creating a new block design:

50Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 51: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Adding the generated IP into the block design:

51Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 52: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Adding the generated IP into the block design:

52Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 53: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)Adding the generated IP into the block design:

53Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 54: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)

1

2

3

Finally, your design could be something similiar to this:

54Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55

Page 55: Department of Information Engineering and Mathematics ...giorgi/teaching/lezioni/lezioni218/c218es07-vivado.pdfVivadoHigh Level Synthesis (HLS) 1 2 3 Finally, your design could be

Vivado High Level Synthesis (HLS)References:

• [1] www.Xilinx.com

55Roberto Giorgi, Universita' degli Studi di Siena, C218ES07--SL di 55