0
1
00:00:02,980 --> 00:00:08,920
Using the BCD and the 7-segment codes, here I am going to design a combinational circuit to show a 
1

2
00:00:08,920 --> 00:00:12,520
2-digit BCD number on the Basys3 7-segments. 
2

3
00:00:14,770 --> 00:00:21,310
Our goal is to convert a binary number into a two-digit BCD code and then show that on two 7-segments 
3

4
00:00:21,320 --> 00:00:23,110
available on the Baysis3 board. 
4

5
00:00:25,100 --> 00:00:31,430
Eight slide switches are used to enter a binary number less than 100 that has at most 
5

6
00:00:31,430 --> 00:00:32,210
two decimal digits. 
6

7
00:00:32,720 --> 00:00:39,500
The FPGA design reads this number, converts that to the corresponding BCD code and then sends that to 
7

8
00:00:39,620 --> 00:00:40,620
7-segments. 
8

9
00:00:41,330 --> 00:00:46,150
Up to now, we learned how to turn on only one 7-segment at a time. 
9

10
00:00:46,700 --> 00:00:53,090
So we use the push-buttons on the Basys3 board to choose between the two active 7-segments.
10

11
00:00:55,590 --> 00:01:02,430
We use eight right-hand switches for entering the binary number.  Two right-hand side 7segments 
11

12
00:01:02,550 --> 00:01:04,320
show the corresponding BCD number.
12

13
00:01:05,560 --> 00:01:11,610
We activate a 7segment at a time. The push-button switch at the top activates the second 
13

14
00:01:11,620 --> 00:01:16,150
7-segment, and the one at the left activates the first seven-segment.
14

15
00:01:18,160 --> 00:01:24,490
The HLS code that drives 7segments to show a number has five steps: 1- Defining input and 
15

16
00:01:24,490 --> 00:01:27,190
output mechanisms via top-function arguments.
16

17
00:01:27,970 --> 00:01:35,560
2- Encoding the input binary to BCD. 3- Checking the push-button states. 4-Encoding 
17

18
00:01:35,560 --> 00:01:43,690
the BCD to the 7-segment code. 5- Sending the code to 7-segments. Before starting to implement 
18

19
00:01:43,690 --> 00:01:44,740
these five steps, 
19

20
00:01:44,890 --> 00:01:47,760
let’s define a few data types for the HLS code. 
20

21
00:01:49,700 --> 00:01:57,140
We use arbitrary precision unsigned integer data types for this purpose. In the code, we need 16-bit, 
21

22
00:01:57,380 --> 00:02:00,920
8-bit, 4-bit and 2-bit data types. 
22

23
00:02:02,560 --> 00:02:08,800
Now, let’s write the HLS top-function.  Firstly, the code should define a few arguments for inputs and 
23

24
00:02:08,800 --> 00:02:09,370
outputs.
24

25
00:02:09,940 --> 00:02:15,850
The in_binary and push_button variables are defined for receiving the input binary number and the
25

26
00:02:15,850 --> 00:02:16,340
push-buttons’ states. 
26

27
00:02:16,340 --> 00:02:22,860
The outputs are the signals for driving the 7-segments that are control and data signals. 
27

28
00:02:23,230 --> 00:02:29,530
So the two-pointer arguments code and anodes carry data and control signals, respectively.
28

29
00:02:30,800 --> 00:02:36,620
Then the input binary should be converted to the equivalent BCD. This conversion can be done by calling 
29

30
00:02:36,620 --> 00:02:39,160
the function that we wrote in the previous lecture.
30

31
00:02:40,550 --> 00:02:44,420
Then we check the push buttons to know which 7segment should be activated.
31

32
00:02:45,420 --> 00:02:51,210
Then, we convert the BCD into 7-segment code using the algorithm explained in the 
32

33
00:02:51,210 --> 00:02:52,260
7Segment-OneDigit lecture.
33

34
00:02:53,610 --> 00:02:59,730
Finally, we send the results out. But, before that, we need to define the ports interfaces.
34

35
00:03:02,330 --> 00:03:08,750
Synthesising the code using the Xilinx Vivado-HLS and Vivado tools and generating the FPGA bitstream 
35

36
00:03:08,750 --> 00:03:10,640
are our tasks for the next lecture. 
36

37
00:03:10,970 --> 00:03:13,550
Also, we program the board to check the design. 
37

38
00:03:15,250 --> 00:03:20,440
This is the takeaway message. Push-button switches can be used to get temporary inputs
38

39
00:03:21,980 --> 00:03:28,100
Now the quiz. Write an HLS description to show a 4-digit number on 7-segments. Use
39

40
00:03:28,100 --> 00:03:31,760
4-push-buttons, as shown in the picture to activate each 7-segment.
