Integer library with built-in support for sc_int and ac_int datatypes.
More...
|
template<typename type1 , typename type2 > |
type1 | nvhls::set_slc (type1 X, type2 Y, const unsigned int i) |
| Function that replaces slice of bits. More...
|
|
template<unsigned int W, typename type > |
nvhls_t< W >::nvuint_t | nvhls::get_slc (type X, const unsigned int i) |
| Function that returns slice of bits. More...
|
|
template<typename type > |
type | nvhls::get_slc (type X, const unsigned int i, const unsigned int j) |
| Function that returns slice of bits with dynamic range. More...
|
|
template<unsigned int W1, typename type1 , typename type2 > |
type2 | nvhls::leading_ones (type1 X) |
| LeadingOne Detector. More...
|
|
template<typename type1 > |
unsigned int | nvhls::lzd (type1 X) |
| Leading zero detector. More...
|
|
template<typename type > |
type | nvhls::get_min_val () |
| Minimum Value of a type. More...
|
|
template<typename type > |
type | nvhls::left_shift (type X, int shift) |
| Function that performs left shift while preserving sign. More...
|
|
template<typename type > |
type | nvhls::right_shift (type X, int shift) |
| Function that performs right shift while preserving sign. More...
|
|
template<typename type1 , typename type2 > |
bool | nvhls::normalize (type1 &X, type2 &Y) |
| Normalize function. More...
|
|
Integer library with built-in support for sc_int and ac_int datatypes.
◆ NVUINTW
Macro to declare nvuint type with template parameter width
- A Simple Example
#include <nvhls_types.h>
template <unsigned NumInputLanes, unsigned NumOutputLanes>
NVUINTW(Wrapped< T >::width) TypeToNVUINT(T in)
Convert Type to NVUINT.
Definition at line 35 of file nvhls_types.h.
◆ NVINTW
Macro to declare nvint type with template parameter width
- A Simple Example
#include <nvhls_types.h>
template <unsigned NumInputLanes, unsigned NumOutputLanes>
Definition at line 51 of file nvhls_types.h.
◆ NVINTC
Macro to declare nvuint type with constant width
- A Simple Example
#include <nvhls_types.h>
static const int NumInputs = 4;
Definition at line 79 of file nvhls_types.h.
◆ NVUINTC
Macro to declare nvint type with constant width
- A Simple Example
#include <nvhls_types.h>
static const int NumInputs = 4;
◆ set_slc()
template<typename type1 , typename type2 >
type1 nvhls::set_slc |
( |
type1 |
X, |
|
|
type2 |
Y, |
|
|
const unsigned int |
i |
|
) |
| |
Function that replaces slice of bits.
- Template Parameters
-
type1 | Datatype of X |
type2 | Datatype of Y |
- Parameters
-
[in] | X | Variable whose bits are to be replaced |
[in] | Y | Variable that stores new bits for the bit slice |
[in] | i | Starting LSB position in variable X |
[out] | ReturnType | variable of type1 with slice of bits replaced. |
- Overview
- Function that replaces slice of bits [i,i+W2-1] in X with Y.
- type1 and type2 can be: nvint or nvuint type.
- W2 is width of Y.
- A Simple Example
#include <nvhls_int.h>
#include <nvhls_types.h>
...
NVUINT8 X = 5;
NVUINT2 Y = 3;
int pos = 3;
...
type1 set_slc(type1 X, type2 Y, const unsigned int i)
Function that replaces slice of bits.
Definition at line 387 of file nvhls_int.h.
◆ get_slc() [1/2]
template<unsigned int W, typename type >
nvhls_t<W>::nvuint_t nvhls::get_slc |
( |
type |
X, |
|
|
const unsigned int |
i |
|
) |
| |
Function that returns slice of bits.
- Template Parameters
-
type | Datatype |
W | width of slice |
- Parameters
-
[in] | X | Variable whose bit slice is requested |
[in] | i | Starting LSB position in variable X |
[out] | ReturnType | Slice of bits |
- Overview
- Function that returns slice of bits [i+W-1,i] in X.
- W should be a constant.
- type can be: nvint or nvuint type.
- Stratus does not work with typename nvhls_t<W>::nvuint_t as return type. Modifying it to scuint<W>. This will be a problem if W>64.
- A Simple Example
#include <nvhls_int.h>
#include <nvhls_types.h>
...
NVUINT8 X = 5;
int pos = 3;
NVUINT2 Y = nvhls::get_slc<2>(X, pos)
...
Definition at line 437 of file nvhls_int.h.
◆ get_slc() [2/2]
template<typename type >
type nvhls::get_slc |
( |
type |
X, |
|
|
const unsigned int |
i, |
|
|
const unsigned int |
j |
|
) |
| |
Function that returns slice of bits with dynamic range.
- Template Parameters
-
- Parameters
-
[in] | X | Variable whose bit slice is requested |
[in] | i | LSB position for bit-slice in variable X |
[in] | j | MSB position for bit-slice in variable X |
[out] | ReturnType | Slice of bits |
- Overview
- Function that returns slice of bits [i, j] in X.
- i >= j.
- type can be: nvint or nvuint type.
- SystemC supports this with range function. ac_int does not have equivalent functionality.
- A Simple Example
#include <nvhls_int.h>
#include <nvhls_types.h>
...
NVUINT8 X = 5;
const int pos1 = 5;
const int pos2 = 3;
...
nvhls_t< W >::nvuint_t get_slc(type X, const unsigned int i)
Function that returns slice of bits.
Definition at line 487 of file nvhls_int.h.
◆ leading_ones()
template<unsigned int W1, typename type1 , typename type2 >
type2 nvhls::leading_ones |
( |
type1 |
X | ) |
|
|
inline |
LeadingOne Detector.
- Template Parameters
-
type1 | InputDatatype |
type2 | ReturnType |
W1 | Width of type1 |
- Parameters
-
[in] | X | Variable whose leading one pos is requested |
[out] | ReturnType | Position of leading one |
- Overview
- Function that returns position of leading one.
- type can be: nvint or nvuint type.
- A Simple Example
#include <nvhls_int.h>
#include <nvhls_types.h>
...
NVUINT8 X = 5;
NVUINT3 pos =
NVUINT3>(X);
...
type2 leading_ones(type1 X)
LeadingOne Detector.
Definition at line 561 of file nvhls_int.h.
◆ lzd()
template<typename type1 >
unsigned int nvhls::lzd |
( |
type1 |
X | ) |
|
Leading zero detector.
- Template Parameters
-
- Parameters
-
[in] | X | Variable whose leading zero position is requested |
[out] | ReturnType | Position of leading one |
- Overview
- Function that returns position of leading zero.
- A Simple Example
#include <nvhls_int.h>
#include <nvhls_types.h>
...
NVUINT8 X = 5;
NVUINT3 pos =
nvhls::lzd<NVUINT8>(X);
...
Definition at line 627 of file nvhls_int.h.
◆ get_min_val()
template<typename type >
type nvhls::get_min_val |
( |
| ) |
|
Minimum Value of a type.
- Template Parameters
-
- Parameters
-
[out] | ReturnVal | Minimum value of the type |
- Overview
- Returns minumum value of nvint and nvuint depending on their bitwidth
- A Simple Example
#include <nvhls_int.h>
#include <nvhls_types.h>
...
NVINT3 min_val =
nvhls::get_min_val<NVINT3>();
...
Definition at line 682 of file nvhls_int.h.
◆ left_shift()
template<typename type >
type nvhls::left_shift |
( |
type |
X, |
|
|
int |
shift |
|
) |
| |
Function that performs left shift while preserving sign.
- Template Parameters
-
- Parameters
-
[in] | X | Input variable |
[in] | shift | Number of bits to be shifted |
[out] | ReturnVal | X shifted left while preserving sign |
- Overview
- Function that performs left shift while preserving sign
- A Simple Example
#include <nvhls_int.h>
...
NVINT8 X = -5;
NVINT8 ShiftedX =
nvhls::left_shift<NVINT8>(X, 2);
...
Definition at line 722 of file nvhls_int.h.
◆ right_shift()
template<typename type >
type nvhls::right_shift |
( |
type |
X, |
|
|
int |
shift |
|
) |
| |
Function that performs right shift while preserving sign.
- Template Parameters
-
- Parameters
-
[in] | X | Input variable |
[in] | shift | Number of bits to be shifted |
[out] | ReturnVal | X shifted right while preserving sign |
- Overview
- Function that performs right shift while preserving sign
- A Simple Example
#include <nvhls_int.h>
...
NVINT8 X = -5;
NVINT8 ShiftedX =
nvhls::right_shift<NVINT8>(X, 2);
...
Definition at line 782 of file nvhls_int.h.
◆ normalize()
template<typename type1 , typename type2 >
bool nvhls::normalize |
( |
type1 & |
X, |
|
|
type2 & |
Y |
|
) |
| |
Normalize function.
- Template Parameters
-
type1 | MantissaType |
type2 | ExponentType |
- Parameters
-
[in,out] | X | mantissa |
[in,out] | Y | exponent |
[out] | ReturnVal | success? |
- Overview
- Function that takes exponent and mantissa as input and returns normalized mantissa and exponent
- Return value indicates success or failure
- A Simple Example
#include <nvhls_int.h>
...
NVINT8 X = -5;
NVINT8 Y = 2;
bool is_normalized =
nvhls::normalize<NVINT8, NVINT8>(X, Y);
...
Definition at line 848 of file nvhls_int.h.