Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# Util functions and macros

group util_macros

  Defines

  MAX(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:

      - A – [in] First input

      - B – [in] Second input

    Returns:

      Maximum of the inputs.

  MIN(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:

      - A – [in] First input

      - B – [in] Second input

    Returns:

      Minimum of the inputs.

  CLS_S8(X)

    Count leading sign bits of an `int8_t`.

    Parameters:

      - X – [in] Input

    Returns:

      Leading sign bits of `X`

  CLS_S16(X)

    Count leading sign bits of an `int16_t`.

    Parameters:

      - X – [in] Input

    Returns:

      Leading sign bits of `X`

  CLS_S32(X)

    Count leading sign bits of an `int32_t`.

    Parameters:

      - X – [in] Input

    Returns:

      Leading sign bits of `X`

  CLS_S64(X)

    Count leading sign bits of an `int64_t`.

    Parameters:

      - X – [in] Input

    Returns:

      Leading sign bits of `X`

  CLS_C16(X)

    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:

      - X – [in] Input

    Returns:

      Leading sign bits of `X`

  CLS_C32(X)

    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:

      - X – [in] Input

    Returns:

      Leading sign bits of `X`

  HR_S64(X)

    Get the headroom of an `int64_t`.

    Parameters:

      - X – [in] Input

    Returns:

      Headroom of `X`

  HR_S32(X)

    Get the headroom of an `int32_t`.

    Parameters:

      - X – [in] Input

    Returns:

      Headroom of `X`

  HR_S16(X)

    Get the headroom of an `int16_t`.

    Parameters:

      - X – [in] Input

    Returns:

      Headroom of `X`

  HR_S8(X)

    Get the headroom of an `int8_t`.

    Parameters:

      - X – [in] Input

    Returns:

      Headroom of `X`

  HR_C32(X)

    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:

      - X – [in] Input

    Returns:

      Headroom of `X`

  HR_C16(X)

    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:

      - X – [in] Input

    Returns:

      Headroom of `X`

  Functions

  void xs3_memcpy(void *dst, const void *src, unsigned bytes)

    VPU-based memcpy implementation.

    Same as standard `memcpy()` except for an extra constraint that both `dst and`src` must be word-aligned addresses.

    Parameters:

      - dst – [out] Destination address

      - src – [in] Source address

      - bytes – [in] Number of bytes to copy

  static inline unsigned cls(const int32_t a)

    Count leading sign bits of `int32_t`.

    This function returns the number of most-significant bits in `a` which are equal to its sign bit.

    Note

    This is the total number of leading sign bits, not redundant leading sign bits.

    Parameters:

      - a – [in] Input value

    Returns:

      Number of leading sign bits of `a`

  static inline unsigned n_bitrev(const unsigned index, const unsigned bits)

    Reverse the bits of an integer.

    This function returns takes an integer `index` and reverses the `bits` least-significant bits to form a new integer which is returned. All more significant bits are ignored.

    This is useful for algorithms, such as the FFT, whose implementation requires reordering of elements by reversing the bits of the indices.

    Parameters:

      - index – [in] Input value

      - bits – [in] The number of least-significant bits to reverse.

    Returns:

      The `bits` LSb’s of `index` reversed.