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