0
1
00:00:00,720 --> 00:00:06,630
One of the requirements during design simulation is the ability to print variables on the screen. For
1

2
00:00:06,630 --> 00:00:14,020
this purpose, a C/C++ code usually uses the printf function or cout object. In this lecture, 
2

3
00:00:14,310 --> 00:00:17,160
I will explain how to use these functions in HLS.
3

4
00:00:19,520 --> 00:00:24,950
Vivado HLS supports printing values that require more than 64-bits to represent. 
4

5
00:00:26,320 --> 00:00:31,990
The printing functions are not synthesizable and only should be used during C-Simulation.
5

6
00:00:34,620 --> 00:00:41,520
The easiest way to output any value stored in an arbitrary precision variable is to use the C++ standard 
6

7
00:00:41,520 --> 00:00:48,780
output stream. For this purpose, the #include <iostream> or <iostream.h> header file should be added 
7

8
00:00:48,780 --> 00:00:57,210
to the test-bench file. The C++ modifiers std::oct, std::dec, std::hex 
8

9
00:00:57,210 --> 00:00:59,850
can be used to format the printed value.
9

10
00:01:04,060 --> 00:01:11,050
It is also possible to use the standard C library (#include <stdio.h>) to print out values larger than 64-bits.  For this purpose, 
10

11
00:01:11,500 --> 00:01:18,130
Firstly, convert the value to a C++ std::string by using the to_string() member function provided
11

12
00:01:18,130 --> 00:01:23,740
by the arbitrary precision class template. And then convert the result to a null-terminated C character 
12

13
00:01:23,740 --> 00:01:27,210
string by using the c_str() method.
13

14
00:01:28,450 --> 00:01:34,390
The arbitrary precision integer template class provides a member function, called to_string 
14

15
00:01:34,600 --> 00:01:41,560
to convert the value into the corresponding C++ string. This function gets an optional argument that 
15

16
00:01:41,560 --> 00:01:43,270
determines the output radix.
16

17
00:01:44,860 --> 00:01:50,920
Working with a multi-bit data type in a hardware design usually needs direct access to the bits in 
17

18
00:01:50,920 --> 00:01:57,580
the corresponding variables. HLS provides a set of functions for bit-level manipulation, which is 
18

19
00:01:57,580 --> 00:01:59,010
the subject of the next lecture.
19

20
00:02:01,290 --> 00:02:07,650
These are our takeaway messages. Vivado HLS supports printing values that require more than 64-bits 
20

21
00:02:07,650 --> 00:02:14,400
to represent. The member function, called to_string, converts the value of an arbitrary 
21

22
00:02:14,400 --> 00:02:18,540
precision integer data types into the corresponding C++ string.
22

23
00:02:20,690 --> 00:02:23,900
Now the quiz question. What is the output of this code?
