XCORE SDK
XCORE Software Development Kit
|
Macros | |
#define | XS3_S32_SQRT_MAX_DEPTH (31) |
Maximum bit-depth to calculate with xs3_s32_sqrt(). | |
Functions | |
float | xs3_pack_float (const int32_t mantissa, const exponent_t exp) |
Pack a floating point value into an IEEE 754 single-precision float. More... | |
void | xs3_unpack_float (int32_t *mantissa, exponent_t *exp, const float input) |
Unpack an IEEE 754 single-precision float into a 32-bit mantissa and exponent. More... | |
void | xs3_unpack_float_s16 (int16_t *mantissa, exponent_t *exp, const float input) |
Unpack an IEEE 754 single-precision float into a 16-bit mantissa and exponent. More... | |
int32_t | xs3_scalar_s64_to_s32 (exponent_t *a_exp, const int64_t b, const exponent_t b_exp) |
Convert a 64-bit floating-point scalar to a 32-bit floating-point scalar. More... | |
int16_t | xs3_scalar_s32_to_s16 (exponent_t *a_exp, const int32_t b, const exponent_t b_exp) |
Convert a 32-bit floating-point scalar to a 16-bit floating-point scalar. More... | |
int32_t | xs3_scalar_s16_to_s32 (exponent_t *a_exp, const int16_t b, const exponent_t b_exp, const unsigned remove_hr) |
Convert a 16-bit floating-point scalar to a 32-bit floating-point scalar. More... | |
int32_t | xs3_s32_sqrt (exponent_t *a_exp, const int32_t b, const exponent_t b_exp, const unsigned depth) |
Compute the square root of a 32-bit floating-point scalar. More... | |
int32_t | xs3_s32_inverse (exponent_t *a_exp, const int32_t b) |
Compute the inverse of a 32-bit integer. More... | |
int16_t | xs3_s16_inverse (exponent_t *a_exp, const int16_t b) |
Compute the inverse of a 16-bit integer. More... | |
int16_t | xs3_s16_mul (exponent_t *a_exp, const int16_t b, const int16_t c, const exponent_t b_exp, const exponent_t c_exp) |
Compute the product of two 16-bit floating-point scalars. More... | |
int32_t | xs3_s32_mul (exponent_t *a_exp, const int32_t b, const int32_t c, const exponent_t b_exp, const exponent_t c_exp) |
Compute the product of two 32-bit floating-point scalars. More... | |
float xs3_pack_float | ( | const int32_t | mantissa, |
const exponent_t | exp | ||
) |
Pack a floating point value into an IEEE 754 single-precision float.
The value returned is the nearest representable approximation to \( m \cdot 2^{p} \) where \(m\) is mantissa
and \(p\) is exp
.
[in] | mantissa | Mantissa of value to be packed |
[in] | exp | Exponent of value to be packed |
float
representation of input value int16_t xs3_s16_inverse | ( | exponent_t * | a_exp, |
const int16_t | b | ||
) |
Compute the inverse of a 16-bit integer.
b
represents the integer \(b\). a
and a_exp
together represent the result \(a \cdot 2^{a\_exp}\).
\begin{align*} a \cdot 2^{a\_exp} \leftarrow \frac{1}{b} \end{align*}
[out] | a_exp | Output exponent \(a\_exp\) |
[in] | b | Input integer \(b\) |
int16_t xs3_s16_mul | ( | exponent_t * | a_exp, |
const int16_t | b, | ||
const int16_t | c, | ||
const exponent_t | b_exp, | ||
const exponent_t | c_exp | ||
) |
Compute the product of two 16-bit floating-point scalars.
a
and a_exp
together represent the result \(a \cdot 2^{a\_exp}\).
b
and b_exp
together represent the result \(b \cdot 2^{b\_exp}\).
c
and c_exp
together represent the result \(c \cdot 2^{c\_exp}\).
\begin{align*} a \cdot 2^{a\_exp} \leftarrow \left( b\cdot 2^{b\_exp} \right) \cdot \left( c\cdot 2^{c\_exp} \right) \end{align*}
[out] | a_exp | Output exponent \(a\_exp\) |
[in] | b | First input mantissa \(b\) |
[in] | c | Second input mantissa \(c\) |
[in] | b_exp | First input exponent \(b\_exp\) |
[in] | c_exp | Second input exponent \(c\_exp\) |
int32_t xs3_s32_inverse | ( | exponent_t * | a_exp, |
const int32_t | b | ||
) |
Compute the inverse of a 32-bit integer.
b
represents the integer \(b\). a
and a_exp
together represent the result \(a \cdot 2^{a\_exp}\).
\begin{align*} a \cdot 2^{a\_exp} \leftarrow \frac{1}{b} \end{align*}
[out] | a_exp | Output exponent \(a\_exp\) |
[in] | b | Input integer \(b\) |
int32_t xs3_s32_mul | ( | exponent_t * | a_exp, |
const int32_t | b, | ||
const int32_t | c, | ||
const exponent_t | b_exp, | ||
const exponent_t | c_exp | ||
) |
Compute the product of two 32-bit floating-point scalars.
a
and a_exp
together represent the result \(a \cdot 2^{a\_exp}\).
b
and b_exp
together represent the result \(b \cdot 2^{b\_exp}\).
c
and c_exp
together represent the result \(c \cdot 2^{c\_exp}\).
\begin{align*} a \cdot 2^{a\_exp} \leftarrow \left( b\cdot 2^{b\_exp} \right) \cdot \left( c\cdot 2^{c\_exp} \right) \end{align*}
[out] | a_exp | Output exponent \(a\_exp\) |
[in] | b | First input mantissa \(b\) |
[in] | c | Second input mantissa \(c\) |
[in] | b_exp | First input exponent \(b\_exp\) |
[in] | c_exp | Second input exponent \(c\_exp\) |
int32_t xs3_s32_sqrt | ( | exponent_t * | a_exp, |
const int32_t | b, | ||
const exponent_t | b_exp, | ||
const unsigned | depth | ||
) |
Compute the square root of a 32-bit floating-point scalar.
b
and b_exp
together represent the input \(b \cdot 2^{b\_exp}\). Likewise, a
and a_exp
together represent the result \(a \cdot 2^{a\_exp}\).
depth
indicates the number of MSb's which will be calculated. Smaller values here will execute more quickly at the cost of reduced precision. The maximum valid value for depth
is XS3_S32_SQRT_MAX_DEPTH.
\begin{align*} a \cdot 2^{a\_exp} \leftarrow \sqrt{\left( b \cdot 2^{b\_exp} \right)} \end{align*}
[out] | a_exp | Output exponent \(a\_exp\) |
[in] | b | Input mantissa \(b\) |
[in] | b_exp | Input exponent \(b\_exp\) |
[in] | depth | Number of most significant bits to calculate |
int32_t xs3_scalar_s16_to_s32 | ( | exponent_t * | a_exp, |
const int16_t | b, | ||
const exponent_t | b_exp, | ||
const unsigned | remove_hr | ||
) |
Convert a 16-bit floating-point scalar to a 32-bit floating-point scalar.
Converts a 16-bit floating-point scalar, represented by the 16-bit mantissa b
and exponent b_exp
, into a 32-bit floating-point scalar, represented by the 32-bit returned mantissa and output exponent a_exp
.
remove_hr
, if nonzero, indicates that the output mantissa should have no headroom. Otherwise, the output mantissa will be the same as the input mantissa.
[out] | a_exp | Output exponent |
[in] | b | 16-bit input mantissa |
[in] | b_exp | Input exponent |
[in] | remove_hr | Whether to remove headroom in output |
int16_t xs3_scalar_s32_to_s16 | ( | exponent_t * | a_exp, |
const int32_t | b, | ||
const exponent_t | b_exp | ||
) |
Convert a 32-bit floating-point scalar to a 16-bit floating-point scalar.
Converts a 32-bit floating-point scalar, represented by the 32-bit mantissa b
and exponent b_exp
, into a 16-bit floating-point scalar, represented by the 16-bit returned mantissa and output exponent a_exp
.
[out] | a_exp | Output exponent |
[in] | b | 32-bit input mantissa |
[in] | b_exp | Input exponent |
int32_t xs3_scalar_s64_to_s32 | ( | exponent_t * | a_exp, |
const int64_t | b, | ||
const exponent_t | b_exp | ||
) |
Convert a 64-bit floating-point scalar to a 32-bit floating-point scalar.
Converts a 64-bit floating-point scalar, represented by the 64-bit mantissa b
and exponent b_exp
, into a 32-bit floating-point scalar, represented by the 32-bit returned mantissa and output exponent a_exp
.
[out] | a_exp | Output exponent |
[in] | b | 64-bit input mantissa |
[in] | b_exp | Input exponent |
void xs3_unpack_float | ( | int32_t * | mantissa, |
exponent_t * | exp, | ||
const float | input | ||
) |
Unpack an IEEE 754 single-precision float into a 32-bit mantissa and exponent.
[out] | mantissa | Unpacked output mantissa |
[out] | exp | Unpacked output exponent |
[in] | input | Float value to be unpacked |
void xs3_unpack_float_s16 | ( | int16_t * | mantissa, |
exponent_t * | exp, | ||
const float | input | ||
) |
Unpack an IEEE 754 single-precision float into a 16-bit mantissa and exponent.
[out] | mantissa | Unpacked output mantissa |
[out] | exp | Unpacked output exponent |
[in] | input | Float value to be unpacked |