In this lecture, I am going to explain how to use a for-loop statement to describe a repetitive combinational 1
pattern in HLS. 2
For this purpose, let’s consider an N-bit combinational binary adder. It consists of N full-adders connected 3
together, sequentially, as each of which requires the carry bit generated by its predecessor. A set 4
of N separate function 5
calls can implement this design. However, without knowing the value of N, writing this code is not 6
possible. 7
Also, this code would not be efficient for a large value of N. 8
This code has two issues. Firstly, It is not parametric, which means it cannot accept N as an input 9
parameter. 10
Secondly, it is not easily generalisable to the large size problems. 11
Using the software loop statement is a solution for these two issues. 12
This code shows the software implementation that uses a for-loop statement. As the first function call is 13
a little bit different than others, 14
it is outside the loop and the for-loop index iterates from 1 to N. 15
The HLS process of this code generates only one instance of the full-adder that will be called several times, 16
sequentially to perform the loop task. 17
Therefore the synthesised circuit requires a few internal temporary memory to keep track of intermediate 18
carry-bits between two adjacent iterations. 19
In other words, the circuit is not combinational. 20
In order to get the same code similar to our first implementation, we should guide the HLS tool 21
to unroll the loop during the synthesis process. 22
A compiler directive can help us to do that. By adding the #pragma HLS UNROLL after the first line of 23
the for-loop, the HLS unrolls the loop and creates a separate logic circuit instance for each loop iteration. 24
In addition to the UNROLL pragma, How can we generally describe a loop statement in an HLS to guarantee 25
the combinational circuit implementation? 26
There are a few constraints and coding styles that should be followed in using loop statements in HLS 27
to describe a combination of a circuit. 28
The following lecture covers these constraints and coding styles. 29
The takeaway message from this lecture is: A software loop statement associated with an UNROLL pragma can 30
implement a repetitive combinational logic 31
circuit structure. 32
Now the quiz for this lecture. Write a for-loop statement to represent the following combinational 33
circuit.