0
1
00:00:01,000 --> 00:00:06,820
In this lecture, I am going to explain how to use a for-loop statement to describe a repetitive combinational 
1

2
00:00:06,820 --> 00:00:08,140
pattern in HLS.
2

3
00:00:09,370 --> 00:00:15,610
For this purpose, let’s consider an N-bit combinational binary adder.  It consists of N full-adders connected 
3

4
00:00:15,610 --> 00:00:22,280
together, sequentially, as each of which requires the carry bit generated by its predecessor. A set 
4

5
00:00:22,300 --> 00:00:23,440
of N separate function 
5

6
00:00:23,440 --> 00:00:29,830
calls can implement this design. However, without knowing the value of N, writing this code is not 
6

7
00:00:29,830 --> 00:00:30,310
possible.
7

8
00:00:30,700 --> 00:00:34,330
Also, this code would not be efficient for a large value of N. 
8

9
00:00:35,520 --> 00:00:42,390
This code has two issues. Firstly, It is not parametric, which means it cannot accept N as an input 
9

10
00:00:42,390 --> 00:00:42,830
parameter.
10

11
00:00:43,260 --> 00:00:47,490
Secondly, it is not easily generalisable to the large size problems.
11

12
00:00:50,140 --> 00:00:54,040
Using the software loop statement is a solution for these two issues. 
12

13
00:00:54,640 --> 00:01:00,910
This code shows the software implementation that uses a for-loop statement. As the first function call is 
13

14
00:01:00,910 --> 00:01:02,560
a little bit different than others, 
14

15
00:01:02,950 --> 00:01:07,330
it is outside the loop and the for-loop index iterates from 1 to N.
15

16
00:01:10,120 --> 00:01:16,440
The HLS process of this code generates only one instance of the full-adder that will be called several times,
16

17
00:01:16,440 --> 00:01:18,790
sequentially to perform the loop task. 
17

18
00:01:19,710 --> 00:01:25,920
Therefore the synthesised circuit requires a few internal temporary memory to keep track of intermediate
18

19
00:01:25,920 --> 00:01:28,600
carry-bits between two adjacent iterations. 
19

20
00:01:29,190 --> 00:01:31,920
In other words, the circuit is not combinational. 
20

21
00:01:33,780 --> 00:01:39,000
In order to get the same code similar to our first implementation, we should guide the HLS tool 
21

22
00:01:39,120 --> 00:01:41,540
to unroll the loop during the synthesis process. 
22

23
00:01:42,600 --> 00:01:50,100
A compiler directive can help us to do that. By adding the 
#pragma HLS UNROLL after the first line of 
23

24
00:01:50,110 --> 00:01:56,520
the for-loop, the HLS unrolls the loop and creates a separate logic circuit instance for each loop iteration. 
24

25
00:01:59,160 --> 00:02:05,760
In addition to the UNROLL pragma, How can we generally describe a loop statement in an HLS to guarantee
25

26
00:02:05,970 --> 00:02:07,890
the combinational circuit implementation?
26

27
00:02:08,610 --> 00:02:14,490
There are a few constraints and coding styles that should be followed in using loop statements in HLS 
27

28
00:02:14,520 --> 00:02:16,380
to describe a combination of a circuit.
28

29
00:02:16,890 --> 00:02:20,460
The following lecture covers these constraints and coding styles.
29

30
00:02:22,690 --> 00:02:28,750
The takeaway message from this lecture is: A software loop statement associated with an UNROLL pragma can 
30

31
00:02:28,750 --> 00:02:30,760
implement a repetitive combinational logic 
31

32
00:02:30,760 --> 00:02:31,750
circuit structure.
32

33
00:02:34,100 --> 00:02:38,900
Now the quiz for this lecture. Write a for-loop statement to represent the following combinational 
33

34
00:02:38,900 --> 00:02:39,470
circuit.
