FAST RTS C29x TMU API

Module: MATHLIB API / FAST RTS TMU API

More…

Functions

Name

float32

sqrtf_tmu(float32 x)
sqrtf — hardware square root using C29x SQRTF32 instruction

float32

atan2f_tmu(float32 y, float32 x)
atan2f — four-quadrant arctangent using C29x QUADF32 + PUATANF32

float32

atanf_tmu(float32 x)
atanf — single-argument arctangent, derived from atan2f_tmu

float32

acosf_tmu(float32 x)
acosf — inverse cosine using SQRTF32 + QUADF32 + PUATANF32

float32

asinf_tmu(float32 x)
asinf — inverse sine using SQRTF32 + QUADF32 + PUATANF32

float32

expf_tmu(float32 x)
expf — natural exponential using C29x IEXP2F32

float32

logf_tmu(float32 x)
logf — natural logarithm using C29x LOG2F32

float32

powf_tmu(float32 x, float32 y)
powf — power function using C29x LOG2F32 + IEXP2F32

float32

truncf_tmu(float32 x)
truncf — truncate toward zero using C29x FRACF32

float32

floorf_tmu(float32 x)
floorf — floor (round toward -infinity) using C29x FRACF32

float32

ceilf_tmu(float32 x)
ceilf — ceiling (round toward +infinity) using C29x FRACF32

float32

roundf_tmu(float32 x)
roundf — round to nearest integer using C29x FRACF32

float32

fmodf_tmu(float32 num, float32 den)
fmodf — floating-point remainder using C29x FRACF32

float32

divf_tmu(float32 y, float32 x)
divf_tmu — hardware-assisted floating-point divide (non-standard)

Detailed Description

C29x TMU built-in redefinitions of standard math library (math.h) functions. Include fastrts_tmu.h (top-level) rather than including this file directly.

Architecture notes

The C29x TMU provides hardware acceleration via dedicated instructions. The compiler exposes the following built-in functions:

  • __builtin_c29_i32_sqrtf32_m(x) — square root (SQRTF32)

  • __builtin_c29_i32_fracf32_m(x) — fractional part (FRACF32)

  • __builtin_c29_i32_puatanf32_m(x) — per-unit arctangent (PUATANF32)

  • __builtin_c29_i32_log2f32_m(x) — base-2 logarithm (LOG2F32)

  • __builtin_c29_i32_iexp2f32_m(x) — base-2 inverse exponential (IEXP2F32)

  • __builtin_c29_quadf32(flags,y,x) — quadrant correction (QUADF32)

sinf / cosf / divf

The C29x compiler does not expose explicit built-in functions for SINPUF32, COSPUF32, or DIVF32. These instructions are emitted automatically when the compiler option -ffast-math (or --fp_mode=relaxed) is active. Therefore sinf, cosf, and the / operator are not remapped by this header; they rely on the build-system enabling -ffast-math.

Functions Documentation

function sqrtf_tmu

static inline float32 sqrtf_tmu(
    float32 x
)

sqrtf — hardware square root using C29x SQRTF32 instruction

Parameters:

  • x Input value (must be >= 0)

Return: sqrt(x)

function atan2f_tmu

static inline float32 atan2f_tmu(
    float32 y,
    float32 x
)

atan2f — four-quadrant arctangent using C29x QUADF32 + PUATANF32

Parameters:

  • y Numerator (opposite side)

  • x Denominator (adjacent side)

Return: atan2(y, x) in radians, range (-PI, PI]

Computes atan2(y, x) in radians via per-unit arctangent and quadrant correction. The PUATANF32 instruction returns a per-unit angle (0…1 maps to 0…2PI). The QUADF32 instruction adds the quadrant offset. Both results are scaled by 2PI to produce radians.

function atanf_tmu

static inline float32 atanf_tmu(
    float32 x
)

atanf — single-argument arctangent, derived from atan2f_tmu

Parameters:

  • x Input value

Return: atan(x) in radians, range (-PI/2, PI/2)

function acosf_tmu

static inline float32 acosf_tmu(
    float32 x
)

acosf — inverse cosine using SQRTF32 + QUADF32 + PUATANF32

Parameters:

  • x Input value, range [-1, 1]

Return: acos(x) in radians, range [0, PI]

Uses the identity: acos(x) = atan2(sqrt(1 - x^2), x)

function asinf_tmu

static inline float32 asinf_tmu(
    float32 x
)

asinf — inverse sine using SQRTF32 + QUADF32 + PUATANF32

Parameters:

  • x Input value, range [-1, 1]

Return: asin(x) in radians, range [-PI/2, PI/2]

Uses the identity: asin(x) = atan2(x, sqrt(1 - x^2))

function expf_tmu

static inline float32 expf_tmu(
    float32 x
)

expf — natural exponential using C29x IEXP2F32

Parameters:

  • x Input value

Return: e^x

Uses the identity: exp(x) = 2^(x * log2(e)) = 1 / 2^(-x * log2(e)) The IEXP2F32 instruction computes 2^(-|n|) for positive inputs.

function logf_tmu

static inline float32 logf_tmu(
    float32 x
)

logf — natural logarithm using C29x LOG2F32

Parameters:

  • x Input value (must be > 0)

Return: ln(x)

Uses the identity: ln(x) = log2(x) * ln(2)

function powf_tmu

static inline float32 powf_tmu(
    float32 x,
    float32 y
)

powf — power function using C29x LOG2F32 + IEXP2F32

Parameters:

  • x Base value (must be > 0)

  • y Exponent value

Return: x^y

Uses the identity: x^y = 2^(y * log2(x))

function truncf_tmu

static inline float32 truncf_tmu(
    float32 x
)

truncf — truncate toward zero using C29x FRACF32

Parameters:

  • x Input value

Return: Truncated value (rounded toward zero)

Uses FRACF32 which returns the fractional part of the input. truncf(x) = x - frac(x), which removes the fractional part.

function floorf_tmu

static inline float32 floorf_tmu(
    float32 x
)

floorf — floor (round toward -infinity) using C29x FRACF32

Parameters:

  • x Input value

Return: Largest integer not greater than x

function ceilf_tmu

static inline float32 ceilf_tmu(
    float32 x
)

ceilf — ceiling (round toward +infinity) using C29x FRACF32

Parameters:

  • x Input value

Return: Smallest integer not less than x

function roundf_tmu

static inline float32 roundf_tmu(
    float32 x
)

roundf — round to nearest integer using C29x FRACF32

Parameters:

  • x Input value

Return: x rounded to nearest integer

Rounds half-way cases away from zero (matches C99 roundf behavior).

function fmodf_tmu

static inline float32 fmodf_tmu(
    float32 num,
    float32 den
)

fmodf — floating-point remainder using C29x FRACF32

Parameters:

  • num Numerator

  • den Denominator (must be non-zero)

Return: Remainder of num / den with the sign of num

Computes fmod(num, den) = num - trunc(num/den) * den

function divf_tmu

static inline float32 divf_tmu(
    float32 y,
    float32 x
)

divf_tmu — hardware-assisted floating-point divide (non-standard)

Parameters:

  • y Numerator

  • x Denominator (must be non-zero)

Return: y / x

Note: On C29x, DIVF32 is emitted automatically by the compiler for the / operator when -ffast-math is active. This wrapper forces a software divide and relies on the compiler to optimize; it does NOT guarantee TMU hardware use without -ffast-math.

Performs y/x using the DIVF32 instruction (emitted via -ffast-math for the / operator). This explicit wrapper is provided for use cases where -ffast-math is not enabled globally.