Loading lib_com/basop_util.c +87 −0 Original line number Diff line number Diff line Loading @@ -1037,8 +1037,94 @@ Word32 div_w( Word32 L_num, Word32 L_den ) } } #ifdef BASOP_DIVIDE3232_FHG // replace depreacted L_add_c() by L_add_co(); currently disabled, because of missing counting in L_add_co(); //#define REPLACE_DEPR_L_ADD_C Word32 BASOP_Util_Divide3232_Scale_FhG( Word32 x, Word32 y, Word16 *s, Word16 bits ) { Word32 z; Word16 sx; Word16 sy; Word32 sign; Word16 iteration; Flag Carry; #ifdef REPLACE_DEPR_L_ADD_C Flag Overflow; #endif Word16 s_val; unset_carry( &Carry ); #ifdef REPLACE_DEPR_L_ADD_C unset_overflow( &Overflow ); #endif /* assert (x >= (Word32)0); */ assert( y != (Word32) 0 ); IF( x == (Word32) 0 ) { *s = -31; move16(); return ( (Word32) 0 ); } sign = L_shr( L_xor( x, y ), 31 ); sx = norm_l( x ); x = L_shl( x, sx ); x = L_shr( x, 1 ); s_val = sub( 1, sx ); if ( x < 0 ) { x = L_negate( x ); } sy = norm_l( y ); y = L_shl( y, sy ); y = L_shr( y, 1 ); s_val = add( s_val, sy ); if ( y >= 0 ) { y = L_negate( y ); } *s = s_val; move16(); z = L_sub( x, x ); // z = 0 FOR( iteration = (Word16) 0; iteration < (Word16) bits; iteration++ ) { if ( L_add( x, y ) >= 0 ) { #ifdef REPLACE_DEPR_L_ADD_C x = L_add_co( x, y, &Carry, &Overflow ); // sets always carry=1 #else x = DEPR_L_add_c( x, y, &Carry ); // sets always carry=1 #endif } #ifdef REPLACE_DEPR_L_ADD_C z = L_add_co( z, z, &Carry, &Overflow ); // sets always carry=0 #else z = DEPR_L_add_c( z, z, &Carry ); // sets always carry=0 #endif x = L_add( x, x ); } if ( sign != 0 ) { z = L_negate( z ); } return L_shl( z, sub( 31, bits ) ); } #endif Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s ) { #ifdef BASOP_DIVIDE3232_FHG return BASOP_Util_Divide3232_Scale_FhG( x, y, s, 24 ); #else Word32 z; Word16 sx; Word16 sy; Loading Loading @@ -1087,6 +1173,7 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s ) } return z; #endif } Word16 BASOP_Util_Divide3232_Scale( Word32 x, Word32 y, Word16 *s ) Loading lib_com/basop_util.h +8 −0 Original line number Diff line number Diff line Loading @@ -328,6 +328,14 @@ Word16 BASOP_Util_Divide3232_Scale( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ #ifdef BASOP_DIVIDE3232_FHG Word32 BASOP_Util_Divide3232_Scale_FhG( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s, /*!< o : Additional scalefactor difference*/ Word16 bits ); /*!< i : number of mantissa bits of result*/ #endif Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ Loading lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -91,4 +91,5 @@ #define FIX_1054_IF_ELSE_CMPLX /* VA: Fix 1054 incorrect counting of complexity when ELSE-IF sequence is encoutered in two functions */ #define FIX_1052_COPY_CMPLX_DISCREPANCY /* VA: modify IF-ELSE statements used in Copy*() functions to avoid dependency on x[] and y[] in RAM */ #define FIX_1049_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */ #define BASOP_DIVIDE3232_FHG /* FhG: scalable 32 by 32 division, use with 24 bit precision */ #endif Loading
lib_com/basop_util.c +87 −0 Original line number Diff line number Diff line Loading @@ -1037,8 +1037,94 @@ Word32 div_w( Word32 L_num, Word32 L_den ) } } #ifdef BASOP_DIVIDE3232_FHG // replace depreacted L_add_c() by L_add_co(); currently disabled, because of missing counting in L_add_co(); //#define REPLACE_DEPR_L_ADD_C Word32 BASOP_Util_Divide3232_Scale_FhG( Word32 x, Word32 y, Word16 *s, Word16 bits ) { Word32 z; Word16 sx; Word16 sy; Word32 sign; Word16 iteration; Flag Carry; #ifdef REPLACE_DEPR_L_ADD_C Flag Overflow; #endif Word16 s_val; unset_carry( &Carry ); #ifdef REPLACE_DEPR_L_ADD_C unset_overflow( &Overflow ); #endif /* assert (x >= (Word32)0); */ assert( y != (Word32) 0 ); IF( x == (Word32) 0 ) { *s = -31; move16(); return ( (Word32) 0 ); } sign = L_shr( L_xor( x, y ), 31 ); sx = norm_l( x ); x = L_shl( x, sx ); x = L_shr( x, 1 ); s_val = sub( 1, sx ); if ( x < 0 ) { x = L_negate( x ); } sy = norm_l( y ); y = L_shl( y, sy ); y = L_shr( y, 1 ); s_val = add( s_val, sy ); if ( y >= 0 ) { y = L_negate( y ); } *s = s_val; move16(); z = L_sub( x, x ); // z = 0 FOR( iteration = (Word16) 0; iteration < (Word16) bits; iteration++ ) { if ( L_add( x, y ) >= 0 ) { #ifdef REPLACE_DEPR_L_ADD_C x = L_add_co( x, y, &Carry, &Overflow ); // sets always carry=1 #else x = DEPR_L_add_c( x, y, &Carry ); // sets always carry=1 #endif } #ifdef REPLACE_DEPR_L_ADD_C z = L_add_co( z, z, &Carry, &Overflow ); // sets always carry=0 #else z = DEPR_L_add_c( z, z, &Carry ); // sets always carry=0 #endif x = L_add( x, x ); } if ( sign != 0 ) { z = L_negate( z ); } return L_shl( z, sub( 31, bits ) ); } #endif Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s ) { #ifdef BASOP_DIVIDE3232_FHG return BASOP_Util_Divide3232_Scale_FhG( x, y, s, 24 ); #else Word32 z; Word16 sx; Word16 sy; Loading Loading @@ -1087,6 +1173,7 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s ) } return z; #endif } Word16 BASOP_Util_Divide3232_Scale( Word32 x, Word32 y, Word16 *s ) Loading
lib_com/basop_util.h +8 −0 Original line number Diff line number Diff line Loading @@ -328,6 +328,14 @@ Word16 BASOP_Util_Divide3232_Scale( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ #ifdef BASOP_DIVIDE3232_FHG Word32 BASOP_Util_Divide3232_Scale_FhG( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s, /*!< o : Additional scalefactor difference*/ Word16 bits ); /*!< i : number of mantissa bits of result*/ #endif Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ Loading
lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -91,4 +91,5 @@ #define FIX_1054_IF_ELSE_CMPLX /* VA: Fix 1054 incorrect counting of complexity when ELSE-IF sequence is encoutered in two functions */ #define FIX_1052_COPY_CMPLX_DISCREPANCY /* VA: modify IF-ELSE statements used in Copy*() functions to avoid dependency on x[] and y[] in RAM */ #define FIX_1049_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */ #define BASOP_DIVIDE3232_FHG /* FhG: scalable 32 by 32 division, use with 24 bit precision */ #endif