0
1
00:00:02,010 --> 00:00:05,640
HLS enables us to use software languages to describe a hardware module, 
1

2
00:00:05,910 --> 00:00:11,520
but what is the analogy between a software function and its corresponding hardware module? Answering this 
2

3
00:00:11,520 --> 00:00:16,220
question helps us to have a big picture of the hardware description in a software context.
3

4
00:00:17,680 --> 00:00:22,670
There is a direct analogy between a hardware module and a software C function. To find out more, 
4

5
00:00:22,810 --> 00:00:25,360
let’s compare a software function with a hardware module. 
5

6
00:00:25,630 --> 00:00:27,770
This is a general structure of a C function. 
6

7
00:00:28,570 --> 00:00:34,540
It consists of a list of arguments for data input and output and a function body that describes a specific 
7

8
00:00:34,540 --> 00:00:35,020
task.
8

9
00:00:35,230 --> 00:00:39,070
An argument can be considered as input, output or both.
9

10
00:00:40,680 --> 00:00:46,240
The function body consists of a sequence of instructions, that traditionally executes sequentially. 
10

11
00:00:46,590 --> 00:00:53,070
This is a typical hardware module which comprises of a body that implements the module’s task and a 
11

12
00:00:53,070 --> 00:00:57,110
list of input/output ports for exchanging data with the rest of the system. 
12

13
00:00:58,020 --> 00:01:04,200
There is an interface with an associated protocol attached to each port that implements its communication 
13

14
00:01:04,200 --> 00:01:04,710
mechanism. 
14

15
00:01:04,890 --> 00:01:07,380
There is a clear analogy between these two structures:
15

16
00:01:07,590 --> 00:01:11,370
Software body is similar to the Hardware body.  And input/output 
16

17
00:01:11,370 --> 00:01:16,230
arguments in the C function are similar to the input/output ports in the hardware module.
17

18
00:01:18,100 --> 00:01:23,860
There are also differences between a C function and a hardware module. Whereas the statements in a 
18

19
00:01:23,860 --> 00:01:30,070
C functions are executed sequentially, thanks to the CPU fetch and execution model, the elements 
19

20
00:01:30,070 --> 00:01:35,230
in a hardware module are parallel which is the intrinsic feature of electronic circuits.
20

21
00:01:35,710 --> 00:01:41,650
The arguments in a C function, can easily communicate with other functions or access the data in the memory 
21

22
00:01:41,650 --> 00:01:46,090
because of the underlying memory hierarchy along with its fixed hardware architecture. 
22

23
00:01:46,600 --> 00:01:52,660
However, ports in a hardware module should implement a specific interface with the associated protocols 
23

24
00:01:52,660 --> 00:01:56,050
to access a memory cell or communicate with other modules. 
24

25
00:01:57,780 --> 00:02:04,530
The main role of HLS is hiding these differences from the designer perspective. HLS provides mechanisms 
25

26
00:02:04,530 --> 00:02:11,670
to synthesise both the module body and ports along with their attached interfaces in a c/c++ 
26

27
00:02:11,670 --> 00:02:12,010
code.
27

28
00:02:12,660 --> 00:02:15,800
Therefore there are two different concepts in HLS
28

29
00:02:17,180 --> 00:02:23,330
Function synthesis, And Interface synthesis. The key technique in function synthesis is extracting parallelism. 
29

30
00:02:23,960 --> 00:02:27,500
This can be done automatically or with a little help from designers.
30

31
00:02:27,830 --> 00:02:33,800
Designers can add compiler directives in the form of pragmas to the code to make the parallel extraction 
31

32
00:02:33,800 --> 00:02:36,170
process easier for synthesis tools.
32

33
00:02:36,800 --> 00:02:39,980
Adding proper interfaces to the hardware is very important 
33

34
00:02:39,980 --> 00:02:43,670
to provide enough bandwidth and throughput for the hardware module
34

35
00:02:43,670 --> 00:02:49,850
functionality. To add interfaces to port, designers also can add a few pragmas to the C code.
35

36
00:02:51,630 --> 00:02:56,580
To clarify the usage of compiler directives via pragmas in an HLS design,
36

37
00:02:56,700 --> 00:03:00,000
let’s take an example. Through a loop statement, 
37

38
00:03:00,210 --> 00:03:07,500
this code reads elements of two arrays a and b, located in a RAM, adds them together and writes 
38

39
00:03:07,500 --> 00:03:10,350
the results into the c array, also located in the RAM. 
39

40
00:03:10,770 --> 00:03:14,570
Each iteration of the loop consists of four subtasks, read 
40

41
00:03:14,610 --> 00:03:18,300
a[i], read b[i], addition and write c[i]. 
41

42
00:03:18,630 --> 00:03:23,480
Traditionally, in the software execution, these four subtasks execute sequentially. 
42

43
00:03:23,790 --> 00:03:25,140
In an HLS description, 
43

44
00:03:25,290 --> 00:03:30,480
we should add a few pragmas to the code to determine the memory transaction protocol between the 
44

45
00:03:30,480 --> 00:03:33,450
external RAM and the hardware module inside the FPGA.
45

46
00:03:33,780 --> 00:03:38,760
Here I’ve used the master AXI interface and protocol. In an hardware implementation, 
46

47
00:03:38,790 --> 00:03:45,150
iterations of the for-loop can be executed in parallel, and only the data dependency among the associated 
47

48
00:03:45,150 --> 00:03:51,660
subtasks dictates the execution order between them. Unrolling the loop by adding a pragma guides 
48

49
00:03:51,660 --> 00:03:54,180
the HLS synthesis tool to schedule the subtasks 
49

50
00:03:54,180 --> 00:04:00,690
in parallel. Our goal in the course is learning these two groups of pragmas for function synthesis and interface 
50

51
00:04:00,690 --> 00:04:02,960
synthesis. Throughout this course, 
51

52
00:04:02,960 --> 00:04:08,310
I will explain the different compiler directives to implement a C code on an FPGA efficiently. 
52

53
00:04:10,820 --> 00:04:17,720
After understanding the HLS design concepts, we should establish our lab environment by installing and 
53

54
00:04:17,720 --> 00:04:24,170
getting familiar with the required software tools and hardware platforms to perform some real experiments. 
54

55
00:04:24,710 --> 00:04:29,710
The next section introduces the software and hardware components and how to install them.
55

56
00:04:31,660 --> 00:04:38,110
These are the takeaway messages.	There are clear analogy between a software C function and a hardware 
56

57
00:04:38,110 --> 00:04:45,030
module.  Compiler directives should be added to the C-code to add hardware-related information and guide 
57

58
00:04:45,030 --> 00:04:47,680
the synthesis tool to implement the code efficiently.
58

59
00:04:49,720 --> 00:04:55,210
Now, the quiz question: What are the roles of two groups of pragmas added to an HLS description of 
59

60
00:04:55,210 --> 00:04:55,810
an algorithm?
