In this lecture, I will explain the structure of the HLS code for the Home Alarm System project 1
explained in the previous lecture. 2
The design code should contain a top-function. The top-function should check all the sensors for any 3
security breach and send the proper information to the display panel. 4
Two separate sub-functions help to send window or motion sensors information to the 7-segment displays. 5
We also need a testbench to test the design behaviour. 6
The test starts with the C/C++ main function. 7
The function generates the input data and applies them to the design 8
and the golden software model and compares the results. 9
The design top-function receives two groups of input signals and generates three groups of output signals. 10
Here, two 16-bit and 5-bit arbitrary precision call-by-value arguments are used to read the slide 11
switches and push-buttons. Also, three 16-bit, 8-bit and 4-bit arbitrary precision 12
call-by-reference 13
arguments are defined to provide data for LEDs and seven-segments. 14
We define an array to represent the seven-segment code in the design. Later we refer to this array to 15
extract the desired code for 7-segments. 16
The data format in the 16-bit slide_switches argument was presented in the previous lecture. 17
In the first step, the top-function splits these data into different variables. 18
Also, it saves the push_button states into a 5-bit variable with a more descriptive name. 19
Then it directly connects all the slide-switches to LEDs. 20
The top-function should check the value of the code to see if the system is ON or OFF. According to 21
the project definition 22
in the previous lecture, the binary code of 1011 turns on the system. 23
If the system is OFF, then all the 7-segments should display the letter O or the number 0. 24
If the system is ON, then the output of the sensors should be checked. If there is any activation 25
in sensors, then the security_breach function is called for more inspection. 26
Otherwise, all the 7-segment displays should show the letter A. 27
Now let’s have a look at the security_breach sub-function. Firstly, it sends the letter E to all 28
7-segments. Then, it checks the pattern on the show_fault variable (which represents the push-buttons 29
sates). 30
If any of the push_buttons is pressed, then the code checks whether it is related to the window sensors 31
or the motion sensors. And call the corresponding function for displaying the proper number on 32
seven segments. 33
Let’s have a look at the display_window function. Before that, it is helpful to remember the data format 34
of the show_fault variable explained in the previous lecture. 35
This function sends the letter E to all 7-segments again. 36
This process is done to make sure that the 7-segments receive data for all paths inside 37
the function. 38
Otherwise, as some paths may not generate data for the 7-segments than the HLS code saves 39
the previous values, 40
that means it should instantiate some flip-flips. 41
Consequently, the resulted circuit won’t be combinational. 42
Then the function modifies the 7-segment data according to the value of show_fault variable and 43
the sensor outputs. 44
The display_motion function also has a similar structure and generates the corresponding 7-segment 45
data base on the value of show_fault variable and the motion sensors outputs. 46
The test bench, firstly, define the status variables which keeps the status of the test. And report that 47
properly. 48
Then it declares a couple of variables for design and software implementation inputs and outputs. 49
Then using four nested for-loops, it generates all the possible inputs and prepares the design input 50
data. 51
Then it calls the design and the software model and compares the results. 52
The next lecture puts all the codes in a Vivado-HLS project and generates the bitstream and examine 53
the system on the Basys-3 board.