0
1
00:00:00,450 --> 00:00:06,390
After declaring arbitrary precision variables, now the question is: What are the rules of assigning 
1

2
00:00:06,390 --> 00:00:07,930
values to these variables?
2

3
00:00:08,610 --> 00:00:10,530
This lecture will answer this question.
3

4
00:00:11,860 --> 00:00:17,470
Variable initialisation and assignment are possible because of the class constructors and overloaded 
4

5
00:00:17,470 --> 00:00:18,680
assignment operators.
5

6
00:00:18,910 --> 00:00:26,020
However, the method of initialisation is subject to the limitations of C++ which can represent numbers 
6

7
00:00:26,020 --> 00:00:27,340
up to 64 bits.
7

8
00:00:29,340 --> 00:00:36,300
To allow assignment of values wider than 64-bits, constructors are provided that allow initialisation
8

9
00:00:36,300 --> 00:00:38,250
from a string of arbitrary length.
9

10
00:00:39,560 --> 00:00:45,650
The constructor gets two arguments: a string representing the value and a radix. 
10

11
00:00:46,860 --> 00:00:53,340
The radix can be 2, 8, 10, or 16. If it is not defined, the string provided is represented 
11

12
00:00:53,340 --> 00:00:57,930
as a hexadecimal value as long as it contains only valid hexadecimal digits 
12

13
00:00:58,110 --> 00:01:01,050
(that is, 0-9 and a-f).
13

14
00:01:01,500 --> 00:01:07,020
The constructor can also infer the radix of the number in the string if it is prefixed with a zero (0) 
14

15
00:01:07,050 --> 00:01:16,350
followed by one of the following characters: “b”, “o” or “x”. The prefixes “0b”, “0o” and “0x” correspond 
15

16
00:01:16,350 --> 00:01:19,980
to binary, octal and hexadecimal formats respectively.
16

17
00:01:20,520 --> 00:01:26,300
These examples show four different ways of initialising a 41-bit variable with an octal number.
17

18
00:01:27,260 --> 00:01:33,350
In C/C++, when we initialise a value by putting ‘0’ before a number, the number is treated as 
18

19
00:01:33,360 --> 00:01:33,730
octal.
19

20
00:01:34,490 --> 00:01:40,670
These examples show three different ways of initialising a 763-bit variable with a hexadecimal 
20

21
00:01:40,670 --> 00:01:41,060
number.
21

22
00:01:42,870 --> 00:01:48,490
The arbitrary precision integer value can be printed on the screen in a test bench file using 
22

23
00:01:48,520 --> 00:01:51,960
std::cout C++ class or printf C function.
23

24
00:01:55,840 --> 00:02:03,550
The C++ modifiers std::oct, std::dec, std::hex can be used to format the printed value.
24

25
00:02:06,850 --> 00:02:12,730
Let’s have a look at the arbitrary precision data type initialisation in action. For this purpose, I 
25

26
00:02:12,730 --> 00:02:15,760
have created an HLS project containing four files.
26

27
00:02:16,510 --> 00:02:19,960
The design header file includes the arbitrary precision header file.
27

28
00:02:20,560 --> 00:02:27,100
The design source file contains the top-function which assigns seven constant values to its seven output 
28

29
00:02:27,100 --> 00:02:27,820
variables.
29

30
00:02:29,310 --> 00:02:35,040
The testbench header file includes the design header file and consists of the design function prototype.
30

31
00:02:36,000 --> 00:02:41,520
The testbench source file contains the main function that declares seven variables and sends them to 
31

32
00:02:41,520 --> 00:02:45,880
the design function for assigning values and finally prints them on the screen.
32

33
00:02:46,320 --> 00:02:51,810
If we perform the C simulation, then the output shows the values assigned to the variables in the design 
33

34
00:02:51,810 --> 00:02:52,020
file.
34

35
00:02:57,540 --> 00:02:59,690
These are the values that we have expected. 
35

36
00:03:09,780 --> 00:03:15,720
After declaring and initialising bit-accurate variables, we should study the rules of assigning variables 
36

37
00:03:15,720 --> 00:03:16,190
together.
37

38
00:03:17,100 --> 00:03:19,350
The next lecture addresses this challenge.
38

39
00:03:21,580 --> 00:03:28,180
These are our takeaway messages. We can use the C/C++ initialisation to assign a value to a declared 
39

40
00:03:28,180 --> 00:03:35,290
variable with length less than 64 bits.  For arbitrary precision data types, more than 64 bits
40

41
00:03:35,470 --> 00:03:38,620
class constructors can be used for initialisation
41

42
00:03:40,690 --> 00:03:47,770
Now the quiz question. Declare a 362-bit width variable of unsigned integer type and initialise that 
42

43
00:03:47,770 --> 00:03:50,050
with a value that set all bits to one.
