Using arbitrary bit-width signals, buses, and data is essential in a hardware design environment. 1
How does an HLS approach support arbitrary-length data and their required operations? 2
Answering this question is the main motivation behind this lecture. 3
Hardware circuits usually use accurate bit-width data that is required by design. For example, hardware 4
modules may communicate through different bit-width buses and signals. Alternatively, instruction codes in a CPU 5
usually come in different formats and shapes that may have various 6
bit-width fields. Decoding 7
each field requires its own digital circuit with an arbitrary bit-width data type. Or analogue-to-digital 8
converters commonly provide a variety of bit-width accuracy. 9
The native C data types only come with 1, 8, 16, 32, and 64-bit widths. If a design requires a 19-bit 10
multiplier, 11
we should not be forced to implement this with a 32-bit multiplier as the resulted design may not be 12
efficient. 13
On the other hand, if a hardware design uses data values or buses with more than 64 bits (such as 14
534 bits), then its implementation is not possible using the native C data types. 15
Therefore, to implement optimum hardware, we should be able to define and use bit-accurate data types 16
with an arbitrary size. Vivado HLS provides an arbitrary precision data type library. 17
This library supports arbitrary precision data type for both simulation and synthesis. 18
This library comes in two flavours: one for C and the other for C++. 19
In this course, I will talk only about the C++ version of this library. 20
This library supports integer precision and fixed-point precision data types. In this section, we focus 21
on integer precision data types. The arbitrary precision integer data type in C++ is a template class 22
that accepts one parameter that defines the data bit-width. 23
In order to use this library, first, we should include the ap_int.h header file in our 24
design source file. 25
They are two separate signed and unsigned classes. signed, and unsigned. This is an example of how to include the 26
header file and define a 5 bit signed integer variable and an 11-bit unsigned integer variable 27
The ap_int and ap_uint templates provide all: arithmetic, bitwise, logical, and relational operators. 28
In addition, these classes provide methods to handle some useful hardware operations, such as allowing 29
initialisation and conversion of variables of widths greater than 64 bits. 30
This library supports arbitrary bit-widths from 1 up to 1024 bits. 31
This is the default maximum width allowed. 32
You can override this default by defining the macro 33
AP_INT_MAX_W with a positive integer value less than or equal to 34
32768 before inclusion of the ap_int.h header file. 35
This is an example of how to define this macro. 36
After declaring a variable, we should initialise or assign a value or variable to that. The next lecture 37
explains how to do that. 38
These are the takeaway messages. 39
To implement optimum hardware, we should be able to define and use bit-accurate data types with 40
an arbitrary size. 41
The arbitrary-precision library in HLS supports integer precision and fixed-point precision data types. 42
The associated classes provide methods to handle some useful hardware operations. 43
Now the quiz question. What is the maximum default bit-width of an arbitrary-precision integer data type in 44
Vivado-HLS?