NEORV32 - Software Framework Documentation
Data Structures | Macros | Functions
neorv32_zfinx_extension_intrinsics.h File Reference

"Intrinsic" library for the NEORV32 single-precision floating-point in x registers (Zfinx) extension More...

#include <fenv.h>
#include <float.h>
#include <math.h>

Go to the source code of this file.

Data Structures

union  float_conv_t
 

Functions

float subnormal_flush (float tmp)
 
uint32_t get_hw_exceptions (void)
 
uint32_t get_sw_exceptions (void)
 
float riscv_intrinsic_fadds (float rs1, float rs2)
 
float riscv_intrinsic_fsubs (float rs1, float rs2)
 
float riscv_intrinsic_fmuls (float rs1, float rs2)
 
float riscv_intrinsic_fmins (float rs1, float rs2)
 
float riscv_intrinsic_fmaxs (float rs1, float rs2)
 
uint32_t riscv_intrinsic_fcvt_wus (float rs1)
 
int32_t riscv_intrinsic_fcvt_ws (float rs1)
 
float riscv_intrinsic_fcvt_swu (uint32_t rs1)
 
float riscv_intrinsic_fcvt_sw (int32_t rs1)
 
uint32_t riscv_intrinsic_feqs (float rs1, float rs2)
 
uint32_t riscv_intrinsic_flts (float rs1, float rs2)
 
uint32_t riscv_intrinsic_fles (float rs1, float rs2)
 
float riscv_intrinsic_fsgnjs (float rs1, float rs2)
 
float riscv_intrinsic_fsgnjns (float rs1, float rs2)
 
float riscv_intrinsic_fsgnjxs (float rs1, float rs2)
 
uint32_t riscv_intrinsic_fclasss (float rs1)
 
float riscv_intrinsic_fdivs (float rs1, float rs2)
 
float riscv_intrinsic_fsqrts (float rs1)
 
float riscv_intrinsic_fmadds (float rs1, float rs2, float rs3)
 
float riscv_intrinsic_fmsubs (float rs1, float rs2, float rs3)
 
float riscv_intrinsic_fnmsubs (float rs1, float rs2, float rs3)
 
float riscv_intrinsic_fnmadds (float rs1, float rs2, float rs3)
 
float riscv_emulate_fadds (float rs1, float rs2)
 
float riscv_emulate_fsubs (float rs1, float rs2)
 
float riscv_emulate_fmuls (float rs1, float rs2)
 
float riscv_emulate_fmins (float rs1, float rs2)
 
float riscv_emulate_fmaxs (float rs1, float rs2)
 
uint32_t riscv_emulate_fcvt_wus (float rs1)
 
int32_t riscv_emulate_fcvt_ws (float rs1)
 
float riscv_emulate_fcvt_swu (uint32_t rs1)
 
float riscv_emulate_fcvt_sw (int32_t rs1)
 
uint32_t riscv_emulate_feqs (float rs1, float rs2)
 
uint32_t riscv_emulate_flts (float rs1, float rs2)
 
uint32_t riscv_emulate_fles (float rs1, float rs2)
 
float riscv_emulate_fsgnjs (float rs1, float rs2)
 
float riscv_emulate_fsgnjns (float rs1, float rs2)
 
float riscv_emulate_fsgnjxs (float rs1, float rs2)
 
uint32_t riscv_emulate_fclasss (float rs1)
 
float riscv_emulate_fdivs (float rs1, float rs2)
 
float riscv_emulate_fsqrts (float rs1)
 
float riscv_emulate_fmadds (float rs1, float rs2, float rs3)
 
float riscv_emulate_fmsubs (float rs1, float rs2, float rs3)
 
float riscv_emulate_fnmsubs (float rs1, float rs2, float rs3)
 
float riscv_emulate_fnmadds (float rs1, float rs2, float rs3)
 

Detailed Description

"Intrinsic" library for the NEORV32 single-precision floating-point in x registers (Zfinx) extension

Author
Stephan Nolting

Also provides emulation functions for all intrinsics (functionality re-built in pure software). The functionality of the emulation

functions is based on the RISC-V floating-point spec.

Note
All operations from this library use the default GCC "round to nearest, ties to even" rounding mode.
Warning
This library is just a temporary fall-back until the Zfinx extensions are supported by the upstream RISC-V GCC port.

Function Documentation

◆ get_hw_exceptions()

uint32_t get_hw_exceptions ( void  )

Get exception flags from fflags CSR (floating-point hardware).

Returns
Floating point exception status word.

◆ get_sw_exceptions()

uint32_t get_sw_exceptions ( void  )

Get exception flags from C runtime (floating-point emulation).

Warning
WORK-IN-PROGRESS!
Returns
Floating point exception status word.

◆ riscv_emulate_fadds()

float riscv_emulate_fadds ( float  rs1,
float  rs2 
)

Single-precision floating-point addition

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_emulate_fclasss()

uint32_t riscv_emulate_fclasss ( float  rs1)

Single-precision floating-point number classification

Parameters
[in]rs1Source operand 1.
Returns
Result.

< Access as native float

< Access in binary representation

◆ riscv_emulate_fcvt_sw()

float riscv_emulate_fcvt_sw ( int32_t  rs1)

Single-precision floating-point signed integer to float

Parameters
[in]rs1Source operand 1.
Returns
Result.

◆ riscv_emulate_fcvt_swu()

float riscv_emulate_fcvt_swu ( uint32_t  rs1)

Single-precision floating-point unsigned integer to float

Parameters
[in]rs1Source operand 1.
Returns
Result.

◆ riscv_emulate_fcvt_ws()

int32_t riscv_emulate_fcvt_ws ( float  rs1)

Single-precision floating-point float to signed integer

Parameters
[in]rs1Source operand 1.
Returns
Result.

◆ riscv_emulate_fcvt_wus()

uint32_t riscv_emulate_fcvt_wus ( float  rs1)

Single-precision floating-point float to unsigned integer

Parameters
[in]rs1Source operand 1.
Returns
Result.

◆ riscv_emulate_fdivs()

float riscv_emulate_fdivs ( float  rs1,
float  rs2 
)

Single-precision floating-point division

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_emulate_feqs()

uint32_t riscv_emulate_feqs ( float  rs1,
float  rs2 
)

Single-precision floating-point equal comparison

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_emulate_fles()

uint32_t riscv_emulate_fles ( float  rs1,
float  rs2 
)

Single-precision floating-point less-than-or-equal comparison

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_emulate_flts()

uint32_t riscv_emulate_flts ( float  rs1,
float  rs2 
)

Single-precision floating-point less-than comparison

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_emulate_fmadds()

float riscv_emulate_fmadds ( float  rs1,
float  rs2,
float  rs3 
)

Single-precision floating-point fused multiply-add

Warning
This instruction is not supported!
Parameters
[in]rs1Source operand 1
[in]rs2Source operand 2
[in]rs3Source operand 3
Returns
Result.

◆ riscv_emulate_fmaxs()

float riscv_emulate_fmaxs ( float  rs1,
float  rs2 
)

Single-precision floating-point maximum

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

< Access as native float

< Access in binary representation

◆ riscv_emulate_fmins()

float riscv_emulate_fmins ( float  rs1,
float  rs2 
)

Single-precision floating-point minimum

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

< Access as native float

< Access in binary representation

◆ riscv_emulate_fmsubs()

float riscv_emulate_fmsubs ( float  rs1,
float  rs2,
float  rs3 
)

Single-precision floating-point fused multiply-sub

Parameters
[in]rs1Source operand 1
[in]rs2Source operand 2
[in]rs3Source operand 3
Returns
Result.

◆ riscv_emulate_fmuls()

float riscv_emulate_fmuls ( float  rs1,
float  rs2 
)

Single-precision floating-point multiplication

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_emulate_fnmadds()

float riscv_emulate_fnmadds ( float  rs1,
float  rs2,
float  rs3 
)

Single-precision floating-point fused negated multiply-add

Parameters
[in]rs1Source operand 1
[in]rs2Source operand 2
[in]rs3Source operand 3
Returns
Result.

◆ riscv_emulate_fnmsubs()

float riscv_emulate_fnmsubs ( float  rs1,
float  rs2,
float  rs3 
)

Single-precision floating-point fused negated multiply-sub

Parameters
[in]rs1Source operand 1
[in]rs2Source operand 2
[in]rs3Source operand 3
Returns
Result.

◆ riscv_emulate_fsgnjns()

float riscv_emulate_fsgnjns ( float  rs1,
float  rs2 
)

Single-precision floating-point sign-injection NOT

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_emulate_fsgnjs()

float riscv_emulate_fsgnjs ( float  rs1,
float  rs2 
)

Single-precision floating-point sign-injection

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_emulate_fsgnjxs()

float riscv_emulate_fsgnjxs ( float  rs1,
float  rs2 
)

Single-precision floating-point sign-injection XOR

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_emulate_fsqrts()

float riscv_emulate_fsqrts ( float  rs1)

Single-precision floating-point square root

Parameters
[in]rs1Source operand 1.
Returns
Result.

◆ riscv_emulate_fsubs()

float riscv_emulate_fsubs ( float  rs1,
float  rs2 
)

Single-precision floating-point subtraction

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_fadds()

float riscv_intrinsic_fadds ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point addition

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_fclasss()

uint32_t riscv_intrinsic_fclasss ( float  rs1)
inline

Single-precision floating-point number classification

Parameters
[in]rs1Source operand 1.
Returns
Result.

◆ riscv_intrinsic_fcvt_sw()

float riscv_intrinsic_fcvt_sw ( int32_t  rs1)
inline

Single-precision floating-point convert signed integer to float

Parameters
[in]rs1Source operand 1.
Returns
Result.

◆ riscv_intrinsic_fcvt_swu()

float riscv_intrinsic_fcvt_swu ( uint32_t  rs1)
inline

Single-precision floating-point convert unsigned integer to float

Parameters
[in]rs1Source operand 1.
Returns
Result.

◆ riscv_intrinsic_fcvt_ws()

int32_t riscv_intrinsic_fcvt_ws ( float  rs1)
inline

Single-precision floating-point convert float to signed integer

Parameters
[in]rs1Source operand 1.
Returns
Result.

◆ riscv_intrinsic_fcvt_wus()

uint32_t riscv_intrinsic_fcvt_wus ( float  rs1)
inline

Single-precision floating-point convert float to unsigned integer

Parameters
[in]rs1Source operand 1.
Returns
Result.

◆ riscv_intrinsic_fdivs()

float riscv_intrinsic_fdivs ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point division

Warning
This instruction is not supported and should raise an illegal instruction exception when executed.
Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_feqs()

uint32_t riscv_intrinsic_feqs ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point equal comparison

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_fles()

uint32_t riscv_intrinsic_fles ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point less-than-or-equal comparison

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_flts()

uint32_t riscv_intrinsic_flts ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point less-than comparison

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_fmadds()

float riscv_intrinsic_fmadds ( float  rs1,
float  rs2,
float  rs3 
)
inline

Single-precision floating-point fused multiply-add

Warning
This instruction is not supported and should raise an illegal instruction exception when executed.
Parameters
[in]rs1Source operand 1
[in]rs2Source operand 2
[in]rs3Source operand 3
Returns
Result.

◆ riscv_intrinsic_fmaxs()

float riscv_intrinsic_fmaxs ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point maximum

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_fmins()

float riscv_intrinsic_fmins ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point minimum

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_fmsubs()

float riscv_intrinsic_fmsubs ( float  rs1,
float  rs2,
float  rs3 
)
inline

Single-precision floating-point fused multiply-sub

Warning
This instruction is not supported and should raise an illegal instruction exception when executed.
Parameters
[in]rs1Source operand 1
[in]rs2Source operand 2
[in]rs3Source operand 3
Returns
Result.

◆ riscv_intrinsic_fmuls()

float riscv_intrinsic_fmuls ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point multiplication

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_fnmadds()

float riscv_intrinsic_fnmadds ( float  rs1,
float  rs2,
float  rs3 
)
inline

Single-precision floating-point fused negated multiply-add

Warning
This instruction is not supported and should raise an illegal instruction exception when executed.
Parameters
[in]rs1Source operand 1
[in]rs2Source operand 2
[in]rs3Source operand 3
Returns
Result.

◆ riscv_intrinsic_fnmsubs()

float riscv_intrinsic_fnmsubs ( float  rs1,
float  rs2,
float  rs3 
)
inline

Single-precision floating-point fused negated multiply-sub

Warning
This instruction is not supported and should raise an illegal instruction exception when executed.
Parameters
[in]rs1Source operand 1
[in]rs2Source operand 2
[in]rs3Source operand 3
Returns
Result.

◆ riscv_intrinsic_fsgnjns()

float riscv_intrinsic_fsgnjns ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point sign-injection NOT

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_fsgnjs()

float riscv_intrinsic_fsgnjs ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point sign-injection

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_fsgnjxs()

float riscv_intrinsic_fsgnjxs ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point sign-injection XOR

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ riscv_intrinsic_fsqrts()

float riscv_intrinsic_fsqrts ( float  rs1)
inline

Single-precision floating-point square root

Warning
This instruction is not supported and should raise an illegal instruction exception when executed.
Parameters
[in]rs1Source operand 1.
Returns
Result.

◆ riscv_intrinsic_fsubs()

float riscv_intrinsic_fsubs ( float  rs1,
float  rs2 
)
inline

Single-precision floating-point subtraction

Parameters
[in]rs1Source operand 1.
[in]rs2Source operand 2.
Returns
Result.

◆ subnormal_flush()

float subnormal_flush ( float  tmp)

Flush to zero if de-normal number.

Warning
Subnormal numbers are not supported yet! Flush them to zero.
Parameters
[in]tmpSource operand.
Returns
Result.