Now we are ready to write a C function to show a decimal digit on a single 7-segment display. 1
In our example, we are going to show a digit whose binary code is represented by the four right-hand 2
side slide switches on the right-hand side 7-segment. 3
The algorithm that controls the 7-segment has three steps. 4
1- Receiving the decimal digit binary code, 2-Encoding the decimal digit into the corresponding 5
7-segment code, 3- Drive the target 7-segment display with this code 6
This table shows a decimal digit, its binary and 7-segment codes. A multiplexer can be used 7
to encode the decimal digit. 8
The 10 7-segment codes drive the multiplexer inputs, and the decimal digit feeds the multiplexer control 9
signals as an index to connect proper input code to the output. 10
For example, Let’s consider the digit 6 as the input, 11
then its corresponding code is connected to the output and illuminates the 7-segments. 12
Now, let’s write the HLS code for this simple combinational design. 13
A switch-case statement can describe the multiplexer. Each case represents an input in our multiplexer. 14
Notice that in the default case, I’ve assumed that all segments are off. This switch can be encapsulated 15
in a function that receives the decimal digit and returns the 7-segment control and data signals. 16
As we just want to enable only one display, 17
the corresponding signal is 0 in the value of the common anode. 18
Finally, we should define the function arguments’ interfaces. As a group of simple wires implements them, 19
then their interface is ap_none. 20
In addition, there is no block-level signalling in this simple example, 21
then the interface attached to the funtion return is ap_ctrl_none. 22
Now, we are able to show a decimal digit on a 7-segment. Is there any coding mechanism that facilitates 23
representing a multiple-digit decimal number on a set of seven-segments? 24
To answer this question, in the next lecture, 25
I will explain the Binary Coded Decimal (BCD) technique, which is widely used to represent multiple-digit 26
decimal numbers. 27
Also, I show how to convert this coding mechanism into the 7-Segment display code. 28
The takeaway message from this lecture is: The C-Code representing a combinational multiplexer can 29
describe the single 7-segment controller. 30
Now the quiz question. 31
Write the one_digit_seven_segment function explained earlier in this lecture by using the if-else 32
statement instead of switch-case.