Using the BCD and the 7-segment codes, here I am going to design a combinational circuit to show a 1
2-digit BCD number on the Basys3 7-segments. 2
Our goal is to convert a binary number into a two-digit BCD code and then show that on two 7-segments 3
available on the Baysis3 board. 4
Eight slide switches are used to enter a binary number less than 100 that has at most 5
two decimal digits. 6
The FPGA design reads this number, converts that to the corresponding BCD code and then sends that to 7
7-segments. 8
Up to now, we learned how to turn on only one 7-segment at a time. 9
So we use the push-buttons on the Basys3 board to choose between the two active 7-segments. 10
We use eight right-hand switches for entering the binary number. Two right-hand side 7segments 11
show the corresponding BCD number. 12
We activate a 7segment at a time. The push-button switch at the top activates the second 13
7-segment, and the one at the left activates the first seven-segment. 14
The HLS code that drives 7segments to show a number has five steps: 1- Defining input and 15
output mechanisms via top-function arguments. 16
2- Encoding the input binary to BCD. 3- Checking the push-button states. 4-Encoding 17
the BCD to the 7-segment code. 5- Sending the code to 7-segments. Before starting to implement 18
these five steps, 19
let’s define a few data types for the HLS code. 20
We use arbitrary precision unsigned integer data types for this purpose. In the code, we need 16-bit, 21
8-bit, 4-bit and 2-bit data types. 22
Now, let’s write the HLS top-function. Firstly, the code should define a few arguments for inputs and 23
outputs. 24
The in_binary and push_button variables are defined for receiving the input binary number and the 25
push-buttons’ states. 26
The outputs are the signals for driving the 7-segments that are control and data signals. 27
So the two-pointer arguments code and anodes carry data and control signals, respectively. 28
Then the input binary should be converted to the equivalent BCD. This conversion can be done by calling 29
the function that we wrote in the previous lecture. 30
Then we check the push buttons to know which 7segment should be activated. 31
Then, we convert the BCD into 7-segment code using the algorithm explained in the 32
7Segment-OneDigit lecture. 33
Finally, we send the results out. But, before that, we need to define the ports interfaces. 34
Synthesising the code using the Xilinx Vivado-HLS and Vivado tools and generating the FPGA bitstream 35
are our tasks for the next lecture. 36
Also, we program the board to check the design. 37
This is the takeaway message. Push-button switches can be used to get temporary inputs 38
Now the quiz. Write an HLS description to show a 4-digit number on 7-segments. Use 39
4-push-buttons, as shown in the picture to activate each 7-segment.