0
1
00:00:03,460 --> 00:00:06,680
Ports and interfaces are playing a crucial role in HLS. 
1

2
00:00:06,940 --> 00:00:12,580
Now the question is,  What are the suitable interfaces for the ports in our simple input/output example?
2

3
00:00:12,940 --> 00:00:13,760
In the next lecture, 
3

4
00:00:13,900 --> 00:00:15,550
I am going to handle this question.
4

5
00:00:19,340 --> 00:00:25,640
Let's develop the C function that connects switches to LEDs in our simple input/output example. First, 
5

6
00:00:26,090 --> 00:00:29,850
as we are going to read and write 8 bits of data, 
6

7
00:00:30,020 --> 00:00:33,090
let's consider the unsigned char as our data type.
7

8
00:00:33,540 --> 00:00:37,070
Also, we use function arguments to receive and send data.
8

9
00:00:37,190 --> 00:00:39,140
So the function looks like this. 
9

10
00:00:40,440 --> 00:00:46,200
It has two arguments. The argument that returns data is defined as a pointer. Now, the function body 
10

11
00:00:46,200 --> 00:00:48,150
is as simple as a single assignment. 
11

12
00:00:48,660 --> 00:00:54,330
The synthesis tool translates this individual assignment into a set of wires that connect the inputs 
12

13
00:00:54,330 --> 00:00:57,660
to the outputs.  Before adding interface pragmas to this code, 
13

14
00:00:57,840 --> 00:01:00,360
let's talk about the function hierarchy in HLS.
14

15
00:01:01,050 --> 00:01:05,640
Each hardware module described in C/C++ can have multiple functions calling each other. 
15

16
00:01:06,330 --> 00:01:09,360
However, only one function is called top-function. 
16

17
00:01:09,630 --> 00:01:15,600
Other functions should be invoked through this top-function, directly or by other functions under the top-
17

18
00:01:15,600 --> 00:01:16,050
function.
18

19
00:01:16,350 --> 00:01:21,090
This diagram shows the function call graph, which has only one root, that is the top function. 
19

20
00:01:21,360 --> 00:01:26,670
The top-function arguments are the hardware ports through which the module communicate with the rest of 
20

21
00:01:26,670 --> 00:01:27,360
the systems.
21

22
00:01:28,110 --> 00:01:34,010
Therefore, these arguments should be synthesised into digital circuits that provide suitable signalling 
22

23
00:01:34,020 --> 00:01:40,500
for the communication considered for each port. Such as serial communication, synchronise communication
23

24
00:01:41,220 --> 00:01:43,830
and accessing an external memory with a specific communication protocol, just to name a few.
24

25
00:01:43,920 --> 00:01:46,680
This synthesis process is called interface synthesis. 
25

26
00:01:46,800 --> 00:01:52,860
The Vivado-HLS tool performs this interface synthesis automatically. Users should only mention 
26

27
00:01:52,860 --> 00:01:57,060
the type of the protocol which should be supported by the synthesised interface.
27

28
00:01:58,540 --> 00:02:05,350
An interface assigned to a port can have different modes. Each mode defines a protocol and its associated 
28

29
00:02:05,350 --> 00:02:06,940
signaling for data exchange.
29

30
00:02:07,750 --> 00:02:11,910
Here it is the list of modes of an interface available in vivado-HLS. 
30

31
00:02:12,100 --> 00:02:14,640
I will explain some of them throughout this course.
31

32
00:02:15,040 --> 00:02:18,820
And these figures show the signalling associated with three modes, 
32

33
00:02:19,570 --> 00:02:25,750
as can be seen, a port can have a simple or a sophisticated hardware implementation.  If the communication
33

34
00:02:25,750 --> 00:02:31,690
is very naive via simple wires without any specific signalling, which is the case in combinational
34

35
00:02:31,690 --> 00:02:36,070
circuits, the interface mode (or type) would be ap_none.
35

36
00:02:38,010 --> 00:02:45,960
The HLS tool packages the synthesised hardware into an IP (intellectual property). This IP can have a 
36

37
00:02:45,960 --> 00:02:53,130
few block-level signals to control the functionality of the modules such as start, done, clock, reset,
37

38
00:02:53,130 --> 00:02:53,670
etc..
38

39
00:02:54,420 --> 00:02:59,200
This should be defined as an interface assigned to the top-function in the C description. 
39

40
00:02:59,640 --> 00:03:03,240
As for a combinational circuit, we don't have such signals 
40

41
00:03:03,330 --> 00:03:10,470
the type (or mode) of this interface is ap_ctrl_none. Other block-level interface modes add more 
41

42
00:03:10,470 --> 00:03:14,040
signals to the design to control its activation states.
42

43
00:03:16,010 --> 00:03:21,020
Ok, let's go back to our design	 and add the interface related directives to our top-function. 
43

44
00:03:21,620 --> 00:03:27,590
We need an interface for each function argument and one for the function itself. Whereas the argument names 
44

45
00:03:27,590 --> 00:03:34,550
are used as the name of their related ports, the port name of the function, in vivado-HLS, is the return keyword.
45

46
00:03:36,250 --> 00:03:41,940
Another way to implement our example is by using a function with one argument and a return value. 
46

47
00:03:41,980 --> 00:03:44,230
Here is the function with its interfaces directives.
47

48
00:03:46,580 --> 00:03:51,920
Notice that a top-function in HLS cannot return a pointer value. That's not synthesisable.
48

49
00:03:53,680 --> 00:03:58,830
In the next lecture, I will explain how to implement our design C function in vivado-HLS.
49

50
00:04:00,570 --> 00:04:05,970
These are our takeaway messages. Each HLS hardware description can have only one top-function,
50

51
00:04:06,720 --> 00:04:10,780
Only an argument in the top function requires an associated interface
51

52
00:04:11,520 --> 00:04:14,940
There is also a block-level interface assigned to the top-function 
52

53
00:04:16,760 --> 00:04:21,770
Now the quiz of this lecture. Add interfaces pragmas to this top-level function.
