XCORE SDK
XCORE Software Development Kit
Macros
Utility Functions and Macros

Macros

#define MAX(A, B)   (((A) >= (B))? (A) : (B))
 Takes the greater of arguments A and B, preferring A on equality. More...
 
#define MIN(A, B)   (((A) <= (B))? (A) : (B))
 Takes the lesser of arguments A and B, preferring A on equality. More...
 
#define CLS_S16(X)   (cls(X) - 16)
 Count leading sign bits of an int16_t. More...
 
#define CLS_S32(X)   (cls(X))
 Count leading sign bits of an int32_t. More...
 
#define CLS_S64(X)
 Count leading sign bits of an int64_t. More...
 
#define CLS_C16(X)   (MIN(CLS_S16((X).re), CLS_S16((X).im)))
 Count leading sign bits of a complex_s16_t. More...
 
#define CLS_C32(X)   (MIN(CLS_S32(((int32_t)(X).re)), CLS_S32(((int32_t)(X).im))))
 Count leading sign bits of a complex_s32_t. More...
 
#define HR_S64(X)   (CLS_S64(X)-1)
 Get the headroom of an int64_t. More...
 
#define HR_S32(X)   (CLS_S32(X)-1)
 Get the headroom of an int32_t. More...
 
#define HR_S16(X)   (CLS_S16(((int16_t)X))-1)
 Get the headroom of an int16_t. More...
 
#define HR_C32(X)   (CLS_C32(X)-1)
 Get the headroom of a complex_s32_t. More...
 
#define HR_C16(X)   (CLS_C16(X)-1)
 Get the headroom of a complex_s16_t. More...
 

Detailed Description

Macro Definition Documentation

◆ CLS_C16

#define CLS_C16 (   X)    (MIN(CLS_S16((X).re), CLS_S16((X).im)))

Count leading sign bits of a complex_s16_t.

The number of leading sign bits for a complex integer is defined as the minimum of the number of leading sign bits for its real part and for its imaginary part.

Parameters
[in]XInput
Returns
Leading sign bits of X

◆ CLS_C32

#define CLS_C32 (   X)    (MIN(CLS_S32(((int32_t)(X).re)), CLS_S32(((int32_t)(X).im))))

Count leading sign bits of a complex_s32_t.

The number of leading sign bits for a complex integer is defined as the minimum of the number of leading sign bits for its real part and for its imaginary part.

Parameters
[in]XInput
Returns
Leading sign bits of X

◆ CLS_S16

#define CLS_S16 (   X)    (cls(X) - 16)

Count leading sign bits of an int16_t.

Parameters
[in]XInput
Returns
Leading sign bits of X

◆ CLS_S32

#define CLS_S32 (   X)    (cls(X))

Count leading sign bits of an int32_t.

Parameters
[in]XInput
Returns
Leading sign bits of X

◆ CLS_S64

#define CLS_S64 (   X)
Value:
( (cls((int32_t)(((int64_t)(X))>>32)) == 32)? \
(cls((int32_t)(((int64_t)(X))>>16)) == 32)? 32 + cls((int32_t)(X)) \
: 16 + cls((int32_t)(((int64_t)(X))>>16)) \
: cls((int32_t)(((int64_t)(X))>>32)) )

Count leading sign bits of an int64_t.

Parameters
[in]XInput
Returns
Leading sign bits of X

◆ HR_C16

#define HR_C16 (   X)    (CLS_C16(X)-1)

Get the headroom of a complex_s16_t.

The headroom of a complex N-bit integer is the minimum of the headroom of each of its N-bit real and imaginary parts.

Parameters
[in]XInput
Returns
Headroom of X

◆ HR_C32

#define HR_C32 (   X)    (CLS_C32(X)-1)

Get the headroom of a complex_s32_t.

The headroom of a complex N-bit integer is the minimum of the headroom of each of its N-bit real and imaginary parts.

Parameters
[in]XInput
Returns
Headroom of X

◆ HR_S16

#define HR_S16 (   X)    (CLS_S16(((int16_t)X))-1)

Get the headroom of an int16_t.

Parameters
[in]XInput
Returns
Headroom of X

◆ HR_S32

#define HR_S32 (   X)    (CLS_S32(X)-1)

Get the headroom of an int32_t.

Parameters
[in]XInput
Returns
Headroom of X

◆ HR_S64

#define HR_S64 (   X)    (CLS_S64(X)-1)

Get the headroom of an int64_t.

Parameters
[in]XInput
Returns
Headroom of X

◆ MAX

#define MAX (   A,
 
)    (((A) >= (B))? (A) : (B))

Takes the greater of arguments A and B, preferring A on equality.

Note
This is not safe from multiple evaluation of arguments.
Parameters
[in]AFirst input
[in]BSecond input
Returns
Maximum of the inputs.

◆ MIN

#define MIN (   A,
 
)    (((A) <= (B))? (A) : (B))

Takes the lesser of arguments A and B, preferring A on equality.

Note
This is not safe from multiple evaluation of arguments.
Parameters
[in]AFirst input
[in]BSecond input
Returns
Minimum of the inputs.