XilinxProcessorIPLib/drivers/v_warp_init/src/xv_warp_init_utils.c
unsigned short XVWarpInit_Inverse(unsigned short x, int M, char* N) {
	//assert((M <= 16) && "Integer part of x should always be less than or equal to 16 bits.");
	unsigned short val = 0;
	unsigned int index;
	int B_L;

	if (x == 0) {
		val = division_lut[0];
		*N = 16;
	}
	else {
		B_L = 17 - XVWarpInit_DominantBit(x);
		index = (((x << (B_L - 1)) & 0x7FFF) + 4) >> (INV_BIT_SHIFT);

		val = division_lut[index];
		*N = M + DATA_SIZE - B_L;
	}
	return val;
}
/*****************************************************************************/
/**
* This function computes inverse of positive short
*
* @param  x, integer value for calculating 1/x. x is QM.(16-M) fixed point format
* @param  M, integer part of the value x.
*
* @return N, Fractional bits in return value.
* @return returns inverse of value x in Q(16-N).N fixed point format
*
******************************************************************************/
This function computes inverse of positive short
This function computes inverse of positive short
unsigned short XVWarpInit_Inverse(unsigned short x, int M, char* N) {
	unsigned short val = 0;
	unsigned int index;
	int B_L;
	if (x == 0) {
		val = division_lut[0];
		*N = 16;
	}
	else {
		B_L = 17 - XVWarpInit_DominantBit(x);
		index = (((x << (B_L - 1)) & 0x7FFF) + 4) >> (INV_BIT_SHIFT);
		val = division_lut[index];
		*N = M + DATA_SIZE - B_L;
	}
	return val;
}
unsigned short XVWarpInit_Inverse ( unsigned short x , int M , char * N ) { unsigned short val = 0 ; unsigned int index ; int B_L ; if ( x == 0 ) { val = division_lut [ 0 ] ; * N = 16 ; } else { B_L = 17 - XVWarpInit_DominantBit ( x ) ; index = ( ( ( x << ( B_L - 1 ) ) & 0x7FFF ) + 4 ) >> ( INV_BIT_SHIFT ) ; val = division_lut [ index ] ; * N = M + DATA_SIZE - B_L ; } return val ; }
This function computes inverse of positive short
This function computes inverse of positive short
//assert((M <= 16) && "Integer part of x should always be less than or equal to 16 bits.");