One of the requirements during design simulation is the ability to print variables on the screen. For 1
this purpose, a C/C++ code usually uses the printf function or cout object. In this lecture, 2
I will explain how to use these functions in HLS. 3
Vivado HLS supports printing values that require more than 64-bits to represent. 4
The printing functions are not synthesizable and only should be used during C-Simulation. 5
The easiest way to output any value stored in an arbitrary precision variable is to use the C++ standard 6
output stream. For this purpose, the #include or header file should be added 7
to the test-bench file. The C++ modifiers std::oct, std::dec, std::hex 8
can be used to format the printed value. 9
It is also possible to use the standard C library (#include ) to print out values larger than 64-bits. For this purpose, 10
Firstly, convert the value to a C++ std::string by using the to_string() member function provided 11
by the arbitrary precision class template. And then convert the result to a null-terminated C character 12
string by using the c_str() method. 13
The arbitrary precision integer template class provides a member function, called to_string 14
to convert the value into the corresponding C++ string. This function gets an optional argument that 15
determines the output radix. 16
Working with a multi-bit data type in a hardware design usually needs direct access to the bits in 17
the corresponding variables. HLS provides a set of functions for bit-level manipulation, which is 18
the subject of the next lecture. 19
These are our takeaway messages. Vivado HLS supports printing values that require more than 64-bits 20
to represent. The member function, called to_string, converts the value of an arbitrary 21
precision integer data types into the corresponding C++ string. 22
Now the quiz question. What is the output of this code?