0
1
00:00:01,470 --> 00:00:05,070
How can we describe a multiplexer in HLS? In this lecture, 
1

2
00:00:05,220 --> 00:00:09,480
I am going to introduce three different coding techniques to describe a multiplexer.
2

3
00:00:12,310 --> 00:00:15,750
Let’s consider the 2x1 mux defined in the previous lecture. 
3

4
00:00:16,400 --> 00:00:18,880
The input a is connected to the output 
4

5
00:00:19,330 --> 00:00:24,370
if s=0, otherwise b is transferred to the output.
5

6
00:00:26,680 --> 00:00:33,730
Probably, the simplest way to code this mux in C/C++ is using the ternary conditional operator, in which 
6

7
00:00:33,760 --> 00:00:39,430
a is copied to O if s equals to 0 otherwise b is copied to O.  
7

8
00:00:41,800 --> 00:00:48,550
Another way of coding this 2x1 MUX is by using the if-else statement. Notice that if you
8

9
00:00:48,550 --> 00:00:54,520
are going to implement a mux with a conditional if, you should clearly mention both if and else 
9

10
00:00:54,520 --> 00:00:55,090
parts.
10

11
00:00:57,540 --> 00:01:03,420
Notice that these two conditional if statements may not be synthesised into combinational circuits as 
11

12
00:01:03,420 --> 00:01:07,000
they both should keep track of the previous value of the output o.
12

13
00:01:10,900 --> 00:01:17,910
The left-hand side if statement does not define the else part, which means if s is not 0, the output 
13

14
00:01:17,980 --> 00:01:24,130
should keep its previous value which in some cases it needs a kind of memory in the hardware implementation. 
14

15
00:01:24,910 --> 00:01:30,820
The right-hand side if statement has defined the else part, but it says that that output should keep 
15

16
00:01:30,820 --> 00:01:31,850
its previous value.
16

17
00:01:32,670 --> 00:01:37,120
This if statement also can be synthesised into sequential logic in some cases. 
17

18
00:01:37,420 --> 00:01:41,080
Therefore, to make sure that the final implementation is combinational, 
18

19
00:01:41,290 --> 00:01:45,190
we should explicitly define all parts in if-else statements.
19

20
00:01:49,600 --> 00:01:56,260
Another way of describing a multiplexer in HLS is by using the switch-case statement.  Notice that, 
20

21
00:01:56,410 --> 00:02:02,160
there should be an execution path in the switch-case for any possible value of the select input to represent 
21

22
00:02:02,170 --> 00:02:02,860
a combinational circuit. 
22

23
00:02:06,480 --> 00:02:10,920
In this example, all cases in the switch have been mentioned explicitly. 
23

24
00:02:11,160 --> 00:02:17,310
In addition, the sel variable in the code has 2 bits that can directly connect to the MUX in the 
24

25
00:02:17,310 --> 00:02:18,480
hardware implementation.
25

26
00:02:21,530 --> 00:02:27,260
This code is another example of a combinational multiplexer described by the switch-case statement. 
26

27
00:02:28,550 --> 00:02:35,050
The sel variable in the code has 8-bits which means it can define 256 different cases. 
27

28
00:02:35,480 --> 00:02:42,110
However, the code only has 4 data inputs that are a, b, c and d. 
28

29
00:02:42,200 --> 00:02:48,740
Therefore multiple cases in the switch statement should send the same input to the output. So, the sel 
29

30
00:02:48,740 --> 00:02:51,620
cannot directly drive the MUX select input. 
30

31
00:02:52,400 --> 00:02:58,700
A selection logic” which is a combinational circuit” should generate the select input for the MUX. 
31

32
00:03:01,310 --> 00:03:07,430
Transforming data from one format to another is one of the combinational circuit task. The next lecture 
32

33
00:03:07,550 --> 00:03:13,190
will explain the concept of encoder and decoder, the two common combinational circuits transforming  
33

34
00:03:13,190 --> 00:03:13,540
data.
34

35
00:03:15,700 --> 00:03:22,560
These are our takeaway messages. The software if-then-else statement can be used to implement 
35

36
00:03:22,570 --> 00:03:23,050
multiplexers.
36

37
00:03:24,200 --> 00:03:28,880
The switch-case statement is another way of describing a multiplexer in HLS. 
37

38
00:03:30,930 --> 00:03:37,260
Now the quiz question. Draw the structure of a combinational circuit that can implement this HLS code.
