CP_SetSqrtImm*

Syntax

#include <nitro/cp.h>

void CP_SetSqrtImm64( u64 param );
void CP_SetSqrtImm32( u32 param );

Arguments

param Value of the square root to be calculated.

Return Values

None.

Description

Sets the parameters for square root calculations. It does not set the square root calculation mode, but merely stores the parameter. Calculation modes are listed below.

Square Root Calculation Mode Calculation Calculation Cycles CPU Cycle Conversion
CP_SQRT_32BIT_MODE Square root calculation of 32-bit values 13 cycles 26 cycles
CP_SQRT_64BIT_MODE Square root calculation of 64-bit values 13 cycles 26 cycles

Note: With the square root calculator, an interrupt may affect data integrity. If the parameters are set and an interrupt occurs during square root calculation, the result may not be accurate. Therefore, to maintain the integrity of an interrupted square root calculation, temporarily store and restore the calculator status using CP_SaveContext() and CP_RestoreContext(), respectively. The status of square root calculators is also automatically saved/restored when threads are switched.


Example: Restore the status of the square root calculator.

intr_func( void ) 
{
  CPContext context;
       
  CP_SaveContext( &context );
  CP_SetSqrt32( 1000 );
  CP_WaitSqrt();
  result = CP_GetDqrtResult32();
  CP_RestoreContext( &context );
}

Internal Operation

Stores values in SQRT_PARAM(0x40002B8) of the IO register.

See Also

CP_SetSqrt*
CP_IsSqrtBusy
CP_WaitSqrt
CP_GetSqrtResult*

Revision History

2006/08/09 Added a note about use inside interrupts.
2004/01/09/ Added content.
2003/12/01 Initial version.


CONFIDENTIAL