0
1
00:00:01,800 --> 00:00:08,080
Bit-level operations are often desirable to be used in control hardware designs. In this lecture, 
1

2
00:00:08,340 --> 00:00:12,500
I will talk about the common bit-level operations available in Vivado-HLS.
2

3
00:00:14,180 --> 00:00:17,870
The length() member function returns the width of the arbitrary precision data type.
3

4
00:00:18,830 --> 00:00:21,440
For example, if a has 41 bits, 
4

5
00:00:22,740 --> 00:00:24,420
then the function returns 41.
5

6
00:00:25,470 --> 00:00:30,510
This function is synthesisable and can be used both in design and test bench files.
6

7
00:00:33,020 --> 00:00:36,380
The concatenation operator mergers two numbers together.
7

8
00:00:37,400 --> 00:00:43,670
The width of the returned value is the sum of the widths of the operands.  The concat member function 
8

9
00:00:43,670 --> 00:00:45,230
can perform this operation. 
9

10
00:00:46,360 --> 00:00:55,000
Let’s assume a 5-bit variable named b and a 7-bit variable called c. Then b.concat(c) has 
10

11
00:00:55,000 --> 00:01:00,900
12 bits in which c is placed on the lower bits and b is located on the higher bits.
11

12
00:01:02,880 --> 00:01:09,840
The c.concat(b) also has 12 bits in which b is placed on the lower bits and c is located on 
12

13
00:01:09,840 --> 00:01:10,650
the higher bits.
13

14
00:01:12,420 --> 00:01:19,140
The overloaded comma operator also can be used to perform the concatenation. In this case, parentheses enclose 
14

15
00:01:19,140 --> 00:01:24,050
the two concatenated values that are separated by an overloaded comma.
15

16
00:01:25,070 --> 00:01:31,910
This slide shows the same concatenation operations as the previous slide but by using the overloaded 
16

17
00:01:31,910 --> 00:01:32,270
comma.
17

18
00:01:35,480 --> 00:01:42,890
Selecting a specific bit position in a variable is another common operator used in hardware design.  The overloaded 
18

19
00:01:42,890 --> 00:01:47,990
square brackets can be used to point out a specific bit in an arbitrary precision value. 
19

20
00:01:49,290 --> 00:01:54,960
An integer value inside the brackets denotes the index of the position. The index of the LSB bit
20

21
00:01:55,110 --> 00:02:00,090
of the value is 0, and the MSB index is the value bit-width minus one.
21

22
00:02:01,280 --> 00:02:06,950
The returned value by the overloaded square brackets is a reference value that can set or clear 
22

23
00:02:06,950 --> 00:02:07,930
the corresponding bit.
23

24
00:02:08,630 --> 00:02:14,450
Let’s consider a 7-bit variable shown in this example. The bit value at index 4 is 0 
24

25
00:02:14,930 --> 00:02:17,060
and can be accessed by n[4].
25

26
00:02:18,210 --> 00:02:21,810
And it can be modified by assigning the value 1 to n[4].
26

27
00:02:26,750 --> 00:02:33,380
Selecting a set of consecutive bits in an arbitrary precision data type is very useful in designing hardware 
27

28
00:02:33,380 --> 00:02:34,100
controllers.
28

29
00:02:35,290 --> 00:02:41,110
The rang member function receives two input arguments and returns the value represented by the range 
29

30
00:02:41,110 --> 00:02:46,960
of bits specified by the arguments. The two arguments represent the most significant bit (MSB) position of the 
30

31
00:02:46,960 --> 00:02:49,160
range, and the least significant bit (LSB).
31

32
00:02:49,720 --> 00:02:56,590
Let’s consider the two-variable r and p. Then p.rang(3, 0) returns the four bits of the 
32

33
00:02:56,770 --> 00:02:59,230
p variable from index 3 to 0. 
33

34
00:02:59,680 --> 00:03:02,920
Overloaded parentheses also can be used to determine a range. 
34

35
00:03:09,610 --> 00:03:15,610
Bit-level logical operators perform another group of bit-wise operations on arbitrary precision values.
35

36
00:03:15,880 --> 00:03:19,120
The goal of the next lecture is to introduce these operators. 
36

37
00:03:21,310 --> 00:03:22,660
This is our takeaway message.
37

38
00:03:23,230 --> 00:03:30,130
There are several bit-level operations in HLS including Concatenation, Bit selection, Range selection 
38

39
00:03:31,960 --> 00:03:36,940
Now the quiz question. What is your suggestion for the bit-width of the r variable and what 
39

40
00:03:36,940 --> 00:03:40,270
would be its value after execution of this code snippet?
