PSPSDK 2024-10-31
Loading...
Searching...
No Matches
pspfpu.h File Reference
#include <stdint.h>
Include dependency graph for pspfpu.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PSP_FPU_RM_MASK   0x03
 Mask value for rounding mode.
 
#define PSP_FPU_FLAGS_POS   2
 Bit position of the flag bits.
 
#define PSP_FPU_ENABLE_POS   7
 Bit position of the enable bits.
 
#define PSP_FPU_CAUSE_POS   12
 Bit position of the cause bits.
 
#define PSP_FPU_CC0_POS   23
 Bit position of the cc0 bit.
 
#define PSP_FPU_FS_POS   24
 Bit position of the fs bit.
 
#define PSP_FPU_CC17_POS   25
 Bit position of the cc1->7 bits.
 
#define PSP_FPU_FLAGS_MASK   (0x1F << PSP_FPU_FLAGS_POS)
 
#define PSP_FPU_ENABLE_MASK   (0x1F << PSP_FPU_ENABLE_POS)
 
#define PSP_FPU_CAUSE_MASK   (0x3F << PSP_FPU_CAUSE_POS)
 
#define PSP_FPU_CC0_MASK   (1 << PSP_FPU_CC0_POS)
 
#define PSP_FPU_FS_MASK   (1 << PSP_FPU_FS_POS)
 
#define PSP_FPU_CC17_MASK   (0x7F << PSP_FPU_CC17_POS)
 

Enumerations

enum  PspFpuRoundMode { PSP_FPU_RN = 0 , PSP_FPU_RZ = 1 , PSP_FPU_RP = 2 , PSP_FPU_RM = 3 }
 Enumeration for FPU rounding modes. More...
 
enum  PspFpuExceptions {
  PSP_FPU_EXCEPTION_INEXACT = 0x01 , PSP_FPU_EXCEPTION_UNDERFLOW = 0x02 , PSP_FPU_EXCEPTION_OVERFLOW = 0x04 , PSP_FPU_EXCEPTION_DIVBYZERO = 0x08 ,
  PSP_FPU_EXCEPTION_INVALIDOP = 0x10 , PSP_FPU_EXCEPTION_UNIMPOP = 0x20 , PSP_FPU_EXCEPTION_ALL = 0x3F
}
 Enumeration for FPU exceptions. More...
 

Functions

uint32_t pspFpuGetFCR31 (void)
 Get the current value of the control/status register.
 
void pspFpuSetFCR31 (uint32_t var)
 Set the current value of the control/status register.
 
void pspFpuSetRoundmode (enum PspFpuRoundMode mode)
 Set the current round mode.
 
enum PspFpuRoundMode pspFpuGetRoundmode (void)
 Get the current round mode.
 
uint32_t pspFpuGetFlags (void)
 Get the exception flags (set when an exception occurs but the actual exception bit is not enabled)
 
void pspFpuClearFlags (uint32_t clear)
 Clear the flags bits.
 
uint32_t pspFpuGetEnable (void)
 Get the exception enable flags.
 
void pspFpuSetEnable (uint32_t enable)
 Set the enable flags bits.
 
uint32_t pspFpuGetCause (void)
 Get the cause bits (only useful if you installed your own exception handler)
 
void pspFpuClearCause (uint32_t clear)
 Clear the cause bits.
 
uint32_t pspFpuGetFS (void)
 Get the current value of the FS bit (if FS is 0 then an exception occurs with denormalized values, if 1 then they are rewritten as 0.
 
void pspFpuSetFS (uint32_t fs)
 Set the FS bit.
 
uint32_t pspFpuGetCondbits (void)
 Get the condition flags (8 bits)
 
void pspFpuClearCondbits (uint32_t clear)
 Clear the condition bits.
 
float pspFpuAbs (float f)
 returns absolute value
 
int pspFpuCeil (float f)
 Round up.
 
int pspFpuFloor (float f)
 Truncate.
 
float pspFpuMax (float f1, float f2)
 select maximum value
 
float pspFpuMin (float f1, float f2)
 select minimum value
 
float pspFpuNeg (float f)
 Sign reversal.
 
int pspFpuRound (float f)
 Round to nearest.
 
float pspFpuRsqrt (float f)
 
float pspFpuSqrt (float f)
 Square root.
 
int pspFpuTrunc (float f)
 Round towards zero.
 
float pspFpuFmod (float fs, float fd)
 
float pspFpuFrac (float f)
 
float pspFpuReinterpretFloat (uint32_t ui)
 
uint32_t pspFpuReinterpretUint (float f)
 
int pspFpuIsEqual (float f1, float f2)
 
float pspFpuSignFloat (float f)
 
int pspFpuSignInt (float f)
 
float pspFpuPositiveZero (void)
 Positive zero.
 
float pspFpuNegativeZero (void)
 Negative zero.
 
int pspFpuIsZero (float f)
 Test for zero value.
 
int pspFpuIsPositiveZero (float f)
 Test for positive zero.
 
int pspFpuIsNegativeZero (float f)
 Test for negative zero.
 
int pspFpuIsDenormal (float f)
 Test for denormalized number.
 
int pspFpuIsZeroOrDenormal (float f)
 Test for zero or denormalized number.
 
float pspFpuPositiveInf (void)
 Positive infinity.
 
float pspFpuNegativeInf (void)
 Negative infinity.
 
int pspFpuIsInf (float f)
 Test for infinity.
 
float pspFpuPositiveNaN (void)
 NaN (positive SNaN)
 
float pspFpuNegativeNaN (void)
 NaN (negative SNaN)
 
float pspFpuPositiveQNaN (void)
 Quiet NaN (positive QNaN)
 
float pspFpuNegativeQNaN (void)
 Quiet NaN (positive QNaN)
 
float pspFpuPositiveSNaN (unsigned int uiSignal)
 Signaling NaN (positive SNaN)
 
float pspFpuNegativeSNaN (unsigned int uiSignal)
 Signaling NaN (negative SNaN)
 
int pspFpuIsNaN (float f)
 Test for NaN.
 
int pspFpuIsInfOrNaN (float f)
 Test for infinity or NaN.
 
float pspFpuNormalizePhase (float f)
 
float pspFpuSin (float x)
 Sine.
 
float pspFpuCos (float x)
 Cosine.
 
float pspFpuAtan (float x)
 Arc tangent.
 
float pspFpuLog (float x)
 Natural Logarithm.
 
float pspFpuExp (float x)
 Exponential.
 
float pspFpuAsin (float x)
 ArcSin.
 
float pspFpuAcos (float x)
 ArcCos.
 
double pspFpuFloatToDouble (float a)
 convert float to double
 
float pspFpuDoubleToFloat (double a)
 convert double to float
 

Macro Definition Documentation

◆ PSP_FPU_CAUSE_MASK

#define PSP_FPU_CAUSE_MASK   (0x3F << PSP_FPU_CAUSE_POS)

◆ PSP_FPU_CAUSE_POS

#define PSP_FPU_CAUSE_POS   12

Bit position of the cause bits.

◆ PSP_FPU_CC0_MASK

#define PSP_FPU_CC0_MASK   (1 << PSP_FPU_CC0_POS)

◆ PSP_FPU_CC0_POS

#define PSP_FPU_CC0_POS   23

Bit position of the cc0 bit.

◆ PSP_FPU_CC17_MASK

#define PSP_FPU_CC17_MASK   (0x7F << PSP_FPU_CC17_POS)

◆ PSP_FPU_CC17_POS

#define PSP_FPU_CC17_POS   25

Bit position of the cc1->7 bits.

◆ PSP_FPU_ENABLE_MASK

#define PSP_FPU_ENABLE_MASK   (0x1F << PSP_FPU_ENABLE_POS)

◆ PSP_FPU_ENABLE_POS

#define PSP_FPU_ENABLE_POS   7

Bit position of the enable bits.

◆ PSP_FPU_FLAGS_MASK

#define PSP_FPU_FLAGS_MASK   (0x1F << PSP_FPU_FLAGS_POS)

◆ PSP_FPU_FLAGS_POS

#define PSP_FPU_FLAGS_POS   2

Bit position of the flag bits.

◆ PSP_FPU_FS_MASK

#define PSP_FPU_FS_MASK   (1 << PSP_FPU_FS_POS)

◆ PSP_FPU_FS_POS

#define PSP_FPU_FS_POS   24

Bit position of the fs bit.

◆ PSP_FPU_RM_MASK

#define PSP_FPU_RM_MASK   0x03

Mask value for rounding mode.

Enumeration Type Documentation

◆ PspFpuExceptions

Enumeration for FPU exceptions.

Enumerator
PSP_FPU_EXCEPTION_INEXACT 

Inexact operation exception.

PSP_FPU_EXCEPTION_UNDERFLOW 

Underflow exception.

PSP_FPU_EXCEPTION_OVERFLOW 

Overflow exception.

PSP_FPU_EXCEPTION_DIVBYZERO 

Division by zero exception.

PSP_FPU_EXCEPTION_INVALIDOP 

Invalid operation exception.

PSP_FPU_EXCEPTION_UNIMPOP 

Unimplemented operation exception (only supported in the cause bits)

PSP_FPU_EXCEPTION_ALL 

All exceptions.

◆ PspFpuRoundMode

Enumeration for FPU rounding modes.

Enumerator
PSP_FPU_RN 

Round to nearest representable value.

PSP_FPU_RZ 

Round towards zero.

PSP_FPU_RP 

Round towards plus infinity.

PSP_FPU_RM 

Round towards minus infinity.

Function Documentation

◆ pspFpuAbs()

float pspFpuAbs ( float  f)

returns absolute value

References x.

◆ pspFpuAcos()

float pspFpuAcos ( float  x)

ArcCos.

References pspFpuAtan(), and x.

◆ pspFpuAsin()

float pspFpuAsin ( float  x)

ArcSin.

References pspFpuAtan(), and x.

◆ pspFpuAtan()

float pspFpuAtan ( float  x)

Arc tangent.

References PSP_MATH_PI, and x.

Referenced by pspFpuAcos(), and pspFpuAsin().

◆ pspFpuCeil()

int pspFpuCeil ( float  f)

Round up.

References x.

◆ pspFpuClearCause()

void pspFpuClearCause ( uint32_t  clear)

Clear the cause bits.

Parameters
clear- Bitmask of the bits to clear, one or more of PspFpuExceptions

References PSP_FPU_CAUSE_POS, pspFpuGetFCR31(), pspFpuSetFCR31(), and x.

◆ pspFpuClearCondbits()

void pspFpuClearCondbits ( uint32_t  clear)

Clear the condition bits.

Parameters
clear- Bitmask of the bits to clear

References PSP_FPU_CC0_POS, PSP_FPU_CC17_POS, pspFpuGetFCR31(), pspFpuSetFCR31(), and x.

◆ pspFpuClearFlags()

void pspFpuClearFlags ( uint32_t  clear)

Clear the flags bits.

Parameters
clear- Bitmask of the bits to clear, one or more of PspFpuExceptions

References PSP_FPU_FLAGS_POS, pspFpuGetFCR31(), pspFpuSetFCR31(), and x.

◆ pspFpuCos()

float pspFpuCos ( float  x)

Cosine.

References COS_SIN_DIV, PSP_MATH_PI, x, and y.

◆ pspFpuDoubleToFloat()

float pspFpuDoubleToFloat ( double  a)

convert double to float

◆ pspFpuExp()

float pspFpuExp ( float  x)

Exponential.

References f, i, PSP_MATH_LN2, PSP_MATH_LOG2E, x, and z.

◆ pspFpuFloatToDouble()

double pspFpuFloatToDouble ( float  a)

convert float to double

◆ pspFpuFloor()

int pspFpuFloor ( float  f)

Truncate.

References x.

◆ pspFpuFmod()

float pspFpuFmod ( float  fs,
float  fd 
)

References x.

◆ pspFpuFrac()

float pspFpuFrac ( float  f)

References x.

◆ pspFpuGetCause()

uint32_t pspFpuGetCause ( void  )

Get the cause bits (only useful if you installed your own exception handler)

Returns
Bitmask of flags, zero or more of PspFpuExceptions

References PSP_FPU_CAUSE_MASK, PSP_FPU_CAUSE_POS, pspFpuGetFCR31(), and x.

◆ pspFpuGetCondbits()

uint32_t pspFpuGetCondbits ( void  )

Get the condition flags (8 bits)

Returns
The current condition flags

References PSP_FPU_CC0_MASK, PSP_FPU_CC0_POS, PSP_FPU_CC17_MASK, PSP_FPU_CC17_POS, pspFpuGetFCR31(), and x.

◆ pspFpuGetEnable()

uint32_t pspFpuGetEnable ( void  )

Get the exception enable flags.

Returns
Bitmask of the flags, zero or more of PspFpuExceptions

References PSP_FPU_ENABLE_MASK, PSP_FPU_ENABLE_POS, pspFpuGetFCR31(), and x.

◆ pspFpuGetFCR31()

uint32_t pspFpuGetFCR31 ( void  )

Get the current value of the control/status register.

Returns
The value of the control/status register

References x.

Referenced by pspFpuClearCause(), pspFpuClearCondbits(), pspFpuClearFlags(), pspFpuGetCause(), pspFpuGetCondbits(), pspFpuGetEnable(), pspFpuGetFlags(), pspFpuGetFS(), pspFpuGetRoundmode(), pspFpuSetEnable(), pspFpuSetFS(), and pspFpuSetRoundmode().

◆ pspFpuGetFlags()

uint32_t pspFpuGetFlags ( void  )

Get the exception flags (set when an exception occurs but the actual exception bit is not enabled)

Returns
Bitmask of the flags, zero or more of PspFpuExceptions

References PSP_FPU_FLAGS_MASK, PSP_FPU_FLAGS_POS, pspFpuGetFCR31(), and x.

◆ pspFpuGetFS()

uint32_t pspFpuGetFS ( void  )

Get the current value of the FS bit (if FS is 0 then an exception occurs with denormalized values, if 1 then they are rewritten as 0.

Returns
The current state of the FS bit (0 or 1)

References PSP_FPU_FS_MASK, PSP_FPU_FS_POS, pspFpuGetFCR31(), and x.

◆ pspFpuGetRoundmode()

enum PspFpuRoundMode pspFpuGetRoundmode ( void  )

Get the current round mode.

Returns
The round mode, one of PspFpuRoundMode

References PSP_FPU_RM_MASK, and pspFpuGetFCR31().

◆ pspFpuIsDenormal()

int pspFpuIsDenormal ( float  f)

Test for denormalized number.

References f.

◆ pspFpuIsEqual()

int pspFpuIsEqual ( float  f1,
float  f2 
)

References x.

◆ pspFpuIsInf()

int pspFpuIsInf ( float  f)

Test for infinity.

References f.

◆ pspFpuIsInfOrNaN()

int pspFpuIsInfOrNaN ( float  f)

Test for infinity or NaN.

References f.

◆ pspFpuIsNaN()

int pspFpuIsNaN ( float  f)

Test for NaN.

References f.

◆ pspFpuIsNegativeZero()

int pspFpuIsNegativeZero ( float  f)

Test for negative zero.

References f.

◆ pspFpuIsPositiveZero()

int pspFpuIsPositiveZero ( float  f)

Test for positive zero.

References f.

◆ pspFpuIsZero()

int pspFpuIsZero ( float  f)

Test for zero value.

References f.

◆ pspFpuIsZeroOrDenormal()

int pspFpuIsZeroOrDenormal ( float  f)

Test for zero or denormalized number.

References f.

◆ pspFpuLog()

float pspFpuLog ( float  x)

Natural Logarithm.

References a, b, f, i, x, y, and z.

◆ pspFpuMax()

float pspFpuMax ( float  f1,
float  f2 
)

select maximum value

References x.

◆ pspFpuMin()

float pspFpuMin ( float  f1,
float  f2 
)

select minimum value

References x.

◆ pspFpuNeg()

float pspFpuNeg ( float  f)

Sign reversal.

References x.

◆ pspFpuNegativeInf()

float pspFpuNegativeInf ( void  )

Negative infinity.

◆ pspFpuNegativeNaN()

float pspFpuNegativeNaN ( void  )

NaN (negative SNaN)

◆ pspFpuNegativeQNaN()

float pspFpuNegativeQNaN ( void  )

Quiet NaN (positive QNaN)

◆ pspFpuNegativeSNaN()

float pspFpuNegativeSNaN ( unsigned int  uiSignal)

Signaling NaN (negative SNaN)

References x.

◆ pspFpuNegativeZero()

float pspFpuNegativeZero ( void  )

Negative zero.

◆ pspFpuNormalizePhase()

float pspFpuNormalizePhase ( float  f)

References PSP_MATH_TWOPI, and x.

◆ pspFpuPositiveInf()

float pspFpuPositiveInf ( void  )

Positive infinity.

◆ pspFpuPositiveNaN()

float pspFpuPositiveNaN ( void  )

NaN (positive SNaN)

◆ pspFpuPositiveQNaN()

float pspFpuPositiveQNaN ( void  )

Quiet NaN (positive QNaN)

◆ pspFpuPositiveSNaN()

float pspFpuPositiveSNaN ( unsigned int  uiSignal)

Signaling NaN (positive SNaN)

References x.

◆ pspFpuPositiveZero()

float pspFpuPositiveZero ( void  )

Positive zero.

◆ pspFpuReinterpretFloat()

float pspFpuReinterpretFloat ( uint32_t  ui)

References ui.

◆ pspFpuReinterpretUint()

uint32_t pspFpuReinterpretUint ( float  f)

References x.

◆ pspFpuRound()

int pspFpuRound ( float  f)

Round to nearest.

References x.

◆ pspFpuRsqrt()

float pspFpuRsqrt ( float  f)

References x.

◆ pspFpuSetEnable()

void pspFpuSetEnable ( uint32_t  enable)

Set the enable flags bits.

Parameters
enable- Bitmask of exceptions to enable, zero or more of PspFpuExceptions

References PSP_FPU_ENABLE_POS, pspFpuGetFCR31(), pspFpuSetFCR31(), and x.

◆ pspFpuSetFCR31()

void pspFpuSetFCR31 ( uint32_t  var)

Set the current value of the control/status register.

Parameters
var- The value to set.

References x.

Referenced by pspFpuClearCause(), pspFpuClearCondbits(), pspFpuClearFlags(), pspFpuSetEnable(), pspFpuSetFS(), and pspFpuSetRoundmode().

◆ pspFpuSetFS()

void pspFpuSetFS ( uint32_t  fs)

Set the FS bit.

Parameters
fs- 0 or 1 to unset or set fs

References PSP_FPU_FS_POS, pspFpuGetFCR31(), pspFpuSetFCR31(), and x.

◆ pspFpuSetRoundmode()

void pspFpuSetRoundmode ( enum PspFpuRoundMode  mode)

Set the current round mode.

Parameters
mode- The rounding mode to set, one of PspFpuRoundMode

References PSP_FPU_RM_MASK, pspFpuGetFCR31(), pspFpuSetFCR31(), and x.

◆ pspFpuSignFloat()

float pspFpuSignFloat ( float  f)

References fv, and x.

◆ pspFpuSignInt()

int pspFpuSignInt ( float  f)

References x.

◆ pspFpuSin()

float pspFpuSin ( float  x)

Sine.

References COS_SIN_DIV, PSP_MATH_PI, x, and y.

◆ pspFpuSqrt()

float pspFpuSqrt ( float  f)

Square root.

References x.

◆ pspFpuTrunc()

int pspFpuTrunc ( float  f)

Round towards zero.

References x.