0
1
00:00:01,000 --> 00:00:05,860
In the previous lecture, we design the leading one example using the HLS coding style.
1

2
00:00:06,340 --> 00:00:12,700
Here, we are going to use the Vivado-HLS toolset to program the Basys 3 board and examine the example 
2

3
00:00:12,700 --> 00:00:13,420
in practice.
3

4
00:00:14,600 --> 00:00:20,360
Firstly, download the design and testbench files available in the course resources part and save them 
4

5
00:00:20,360 --> 00:00:24,620
in a folder on your computer. Then, open the Vivado-HLS GUI.
5

6
00:00:25,660 --> 00:00:28,090
Vivado-HLS opens with the welcome screen. 
6

7
00:00:29,830 --> 00:00:36,440
Click on the “Create New Project” option to open the project wizard Choose “leading_one-vhls” 
7

8
00:00:36,460 --> 00:00:42,460
as the project name and choose a proper path for the project files and then click Next.
8

9
00:00:43,320 --> 00:00:48,020
In the “Add/Remove Files” step, insert leading_one as the Top-Function name.
9

10
00:00:52,580 --> 00:00:58,040
Click on Add Files and go to the folder containing the design files and add them to the project and 
10

11
00:00:58,040 --> 00:00:58,880
then click next.
11

12
00:01:05,130 --> 00:01:10,650
Now add the testbench files by clicking on the Add Files option and selecting the testbench files from 
12

13
00:01:10,650 --> 00:01:13,090
where you have saved them and then click Next.
13

14
00:01:13,770 --> 00:01:17,580
Don’t forget to choose the Basys3 board as the target FPGA platform.
14

15
00:01:28,010 --> 00:01:34,750
Let’s have a look at the design and testbench files.
The design header file only includes the ap_int.h 
15

16
00:01:34,760 --> 00:01:36,170
header file to the design.
16

17
00:01:37,180 --> 00:01:43,090
The design file contains the top function which has a nine-bit integer input argument and returns a 
17

18
00:01:43,090 --> 00:01:47,250
5-bit integer as the index of leading-one in the input argument. 
18

19
00:01:48,070 --> 00:01:53,740
The chain of if-else statements explained in the previous lecture implements the leading-one functionality. 
19

20
00:01:54,430 --> 00:01:57,130
Two pragmas define the design interfaces.
20

21
00:01:57,640 --> 00:02:03,310
The testbench header file includes the design file and defines the design top-function prototype.
21

22
00:02:09,960 --> 00:02:16,530
The testbench source file has the main() function, which implements the testbench functionality. Another function 
22

23
00:02:16,530 --> 00:02:22,290
called find_leading_one_golden is a software implementation of the 
23

24
00:02:22,290 --> 00:02:29,070
design which its results are compared against the hardware results. A for-loop in the main function generates 
24

25
00:02:29,070 --> 00:02:35,100
all the possible inputs and sends them to the design and compares the results with that of the golden 
25

26
00:02:35,100 --> 00:02:37,620
model.  In the case of any discrepancy, 
26

27
00:02:37,830 --> 00:02:42,350
the status variable will get the value of -1. Later, 
27

28
00:02:42,900 --> 00:02:47,850
the main() function returns the status variable to determine the design failure or success.
28

29
00:02:49,190 --> 00:02:54,740
Using the cout object; the code prints the input and result values on the screen for more examination.  
29

30
00:02:56,880 --> 00:03:00,660
Now we can perform the C-simulation to check the design functionality.
30

31
00:03:13,570 --> 00:03:18,040
As can be seen, the testbench has checked all the possible outcomes successfully. 
31

32
00:03:30,030 --> 00:03:34,830
After performing the C-Simulation successfully, we are ready to call the high-level synthesis.
32

33
00:03:41,030 --> 00:03:46,730
If we have a look at the synthesis report, we can see that the RTL design utilises 11 flip-flops,
33

34
00:03:46,910 --> 00:03:49,460
which means the resulted hardware is not combinational. 
34

35
00:03:50,120 --> 00:03:51,240
To find out the reason 
35

36
00:03:51,470 --> 00:03:54,650
let’s have a look at the Analysis Perspective, here 
36

37
00:03:54,830 --> 00:04:00,890
we see that the design execution requires two steps which means most probably the design propagation 
37

38
00:04:00,890 --> 00:04:06,680
delay is bigger than the design clock period constraint considered during the project creation wizard. 
38

39
00:04:07,190 --> 00:04:10,700
To change that got back to the design perspective. Then 
39

40
00:04:11,000 --> 00:04:11,330
right-click 
40

41
00:04:11,330 --> 00:04:14,870
on the Solution1 folder and choose the “Solution Settings” option.
41

42
00:04:17,470 --> 00:04:23,560
Now click on synthesis located on the left and on the right area change the period option from 10 
42

43
00:04:23,560 --> 00:04:24,100
to 20.
43

44
00:04:30,330 --> 00:04:31,800
Now synthesise the code again. 
44

45
00:04:49,040 --> 00:04:56,000
This time you should get a combinational circuit which its propagation delay is 10.046ns.
45

46
00:04:56,000 --> 00:04:56,600
10.046ns.
46

47
00:05:08,500 --> 00:05:13,870
If you go to the Analysis Perspective, you will see that the design only requires one step to finish. 
47

48
00:05:20,150 --> 00:05:23,330
To make sure that the resulted RTL design is also correct.
48

49
00:05:24,260 --> 00:05:26,630
We can perform RTL/C-cosimulation. 
49

50
00:06:18,540 --> 00:06:22,550
The results confirm that the design cycle-accurate simulation is correct.
50

51
00:06:44,440 --> 00:06:49,090
Now we can generate the IP and ready to instantiate that in a Vivado-project.
51

52
00:06:58,400 --> 00:07:04,820
In order to generate the final FPGA bitstream, Firstly, launch the Vivado Design Suite. From the Welcome
52

53
00:07:04,820 --> 00:07:11,780
screen, click Create Project. Click Next on the first page of the Create a New Vivado Project wizard.
53

54
00:07:12,990 --> 00:07:18,960
Choose “leading_one-vivado” as the project name and select a proper path 
54

55
00:07:18,960 --> 00:07:19,760
for the project,
55

56
00:07:20,630 --> 00:07:25,160
and it is a good practice if you check the “Create Project Subdirector” option.
56

57
00:07:26,120 --> 00:07:29,120
Click Next to move to the Project Type page of the wizard.
57

58
00:07:30,250 --> 00:07:36,970
Select the “RTL Project” option. Select Do not specify sources at this time (if not the default). Click Next. On the Default 
58

59
00:07:36,970 --> 00:07:40,210
Part page, under Specify, click Boards and select the Basys3 board.
59

60
00:07:41,100 --> 00:07:47,910
On the New Project Summary Page, click Finish to complete the new project setup. The Vivado workspace populates 
60

61
00:07:47,910 --> 00:07:48,660
and appears.
61

62
00:07:50,660 --> 00:07:57,140
Click on the Create Block Design option under IP integrator in the Flow Navigator. In the resulting 
62

63
00:07:57,140 --> 00:07:59,780
dialog box accept the default name and press ok.
63

64
00:08:06,960 --> 00:08:12,660
The Diagram window will be open. Right-click somewhere inside the diagram window and select the “IP 
64

65
00:08:12,660 --> 00:08:13,680
settings…” option.
65

66
00:08:14,590 --> 00:08:21,670
In the setting dialog, select repository under the IP option on the left-hand side. Click on the plus 
66

67
00:08:21,670 --> 00:08:26,770
icon on the right and browse the folder of the Vivado-HLS project and press Select.
67

68
00:08:32,860 --> 00:08:37,660
The vivado searches the path for any IP ands add that to the repository.
68

69
00:08:39,540 --> 00:08:42,860
Then press ok to get back to the diagram window. 
69

70
00:08:45,110 --> 00:08:49,010
Then right-click somewhere inside the window and select the Add IP … option.
70

71
00:08:50,220 --> 00:08:56,370
In the Search box type “leading_one” and then select “leading_one” and press Enter.
71

72
00:08:58,170 --> 00:09:01,440
After successfully instantiating the IP in the design, 
72

73
00:09:02,500 --> 00:09:08,500
select its ports and press right-click and make them external. You can change their names with more 
73

74
00:09:08,500 --> 00:09:09,700
convenient options.
74

75
00:09:37,910 --> 00:09:43,030
Now we should define a few physical constraints to connect the design ports to the FPGA pins.
75

76
00:09:44,510 --> 00:09:51,430
For this purpose, go to the design view and right-click on the constraints folder and select Add Resources. 
76

77
00:09:51,770 --> 00:09:56,630
Make sure that the “Add or create constraints” option is selected in the Add sources dialog, 
77

78
00:09:57,020 --> 00:10:02,030
then click Next.  Create a constraint file with the name of “leading_one”.
78

79
00:10:07,820 --> 00:10:14,140
Copy the commented constraints for the Basys3 board provided by the vendor into the created file. 
79

80
00:10:14,360 --> 00:10:18,710
Uncomment nine switch constraints and assign them to the a input port of the design.
80

81
00:11:13,270 --> 00:11:17,980
Then uncomment five lED constraints and assign them to the design output port. 
81

82
00:11:48,290 --> 00:11:50,660
Now select the “Generate Output Products” option.
82

83
00:12:07,960 --> 00:12:10,240
After that Create HDL Wrapper.
83

84
00:12:19,880 --> 00:12:25,610
Now you are ready to generate the FPGA bitstream. After generating the bitstream successfully, connect the 
84

85
00:12:25,880 --> 00:12:27,630
board to the computer and program the board.
85

86
00:12:28,100 --> 00:12:30,360
Now lets examine the design on the board.
86

87
00:13:57,950 --> 00:14:04,760
After programming the board, as all slide switches are at the zero position, all five output LEDs 
87

88
00:14:04,760 --> 00:14:07,100
are ON representing the number -1.
88

89
00:14:07,490 --> 00:14:13,640
If we turn ON some of the slide switches, the index of the leading one is shown by the 5 output LEDs.
89

90
00:14:42,110 --> 00:14:48,560
This lecture is the last in this section that explained the design concepts and techniques. So the 
90

91
00:14:48,560 --> 00:14:54,710
next lecture will give you a couple of hardware designs as exercises through which you review and master
91

92
00:14:54,710 --> 00:14:56,360
the proposed techniques in this section. 
92

93
00:14:59,290 --> 00:15:06,190
This is our takeaway message. If you expect that an HLS C/C++ code describes a combinational circuit, 
93

94
00:15:06,280 --> 00:15:11,920
but the synthesis repost shows FF usage, then the propagation delay of the circuit is higher 
94

95
00:15:11,920 --> 00:15:13,960
than the design clock period constraint; 
95

96
00:15:14,440 --> 00:15:20,610
so increase the design clock period constraint and synthesise the code again to generate a fully 
96

97
00:15:20,620 --> 00:15:20,740
combinational circuit.
97

98
00:15:23,250 --> 00:15:24,300
Now, the quiz question.
98

99
00:15:25,450 --> 00:15:31,980
During C-simulation, print on the screen the design inputs and outputs by using cout object inside 
99

100
00:15:31,990 --> 00:15:32,740
the design file.
