📄 sl1_basic_op.h
字号:
/*! \def _sl1_sadd_p(p1, ar1, p2, ar2) * \brief a macro that add two 16 bit integer stored in address registers and update address of p1 and p2 according with ar1 and ar2 * \param p1 a pointer variable map to address register(INT16 *) * \param ar1 ar mode of p1 * \param p2 a pointer variable map to address register(INT16 *) * \param ar2 ar mode of p2 * \return a saturated value(INT16) * \note c3.saaddh.a acc, p1, ar1, p2, ar2, 0 */#define _sl1_sadd_p(p1, ar1, p2, ar2) \ SL1_sadd_p(p1, ar1, p2, ar2, 0)/*! \def _sl1_ssub_shl(var1, var2, shl) * \brief a macro that subtract var2 from var1 and shift the result left by shl * \param var1 INT16 * \param var2 INT16 * \param shl unsigned immediate integer, should be in range of (0, 31) * \return a saturated value(INT16) * \note c3.sasubsh rd, var1, var2, shl */#define _sl1_ssub_shl(var1, var2, shl) \ SL1_ssub_shl (var1, var2, shl)/*! \def _sl1_ssub_p(p1, ar1, p2, ar2) * \brief a macro that subtract 16 bit integer stored in address registers and update address of p1 and p2 according with ar1 and ar2 * \param p1 a pointer variable map to address register(INT16 *) * \param ar1 ar mode of p1 * \param p2 a pointer variable map to address register(INT16 *) * \param ar2 ar mode of p2 * \return a saturated value(INT16) * \note c3.sasubh.a rd, p1, ar1, p2, ar2, 0 */#define _sl1_ssub_p(p1, ar1, p2, ar2) \ SL1_ssub_p (p1, ar1, p2, ar2, 0)/*! \def _sl1_smul_shl_hi(var1, var2, shl) * \brief a macro that multiply 16 bit var1 and var2 and shift the result left by shl with saturation * \param var1 INT16 * \param var2 INT16 * \param shl unsigned immediate integer, should be in range of (0, 31) * \return high 16 bit of result(INT16) * \note c3.samulsh rd, var1, var2, shl */#define _sl1_smul_shl_hi(var1, var2, shl) \ SL1_smul_shl_hi (var1, var2, shl)/*! \def _sl1_smul_hi_p(p1, ar1, p2, ar2) * \brief a macro that multiply 16 bit integer load from address registers and and shift the result left by 1 with saturation, * update address of p1 and p2 according with ar1 and ar2 * \param p1 a pointer variable map to address register(INT16 *) * \param ar1 ar mode of p1 * \param p2 a pointer variable map to address register(INT16 *) * \param ar2 ar mode of p2 * \return high 16 bit of result(INT16) * \note c3.samulh.a rd, p1, ar1, p2, ar2, 0 */#define _sl1_smul_hi_p(p1, ar1, p2, ar2) \ SL1_smul_hi_p(p1, ar1, p2, ar2, 0)/*! \def _sl1_round16_mmode_shr(L_var1, rmode, shr) * \brief a macro that round the lower 16 bits of the input number L_var1 into its MS 16 bits with multimode, do shift the result by shr if L_var1 hasn't acquired an acc register * \param L_var1 variable to be rounded(INT32) * \param rmode round mode, see enum ROUND_MODE * \param shr immediate integer * \return round result * \note L_var1 should not acquired an acc register before <br> c3.mvts acc, L_var1, 0 <br> c3.round acc, 0, rmode <br> c3.mvfs rd, acc, shr <br> * \see _sl1_round16_mmode(L_var1, rmode) if L_var1 acquired an acc register */#define _sl1_round16_mmode_shr(L_var1, rmode, shr) \ SL1_shl_round_shr(L_var1, 0, rmode, shr) /*! \def _sl1_round16_mmode(L_var1, rmode) * \brief a macro that round the lower 16 bits of the 32 bit input number into its MS 16 bits with multimode * \param L_var1 variable to be rounded(INT32) * \param rmode round mode, see enum ROUND_MODE * \return round result * \note c3.round acc, 0, rmode * \see _sl1_round16_mmode_shr(L_var1, rmode, shr) */#define _sl1_round16_mmode(L_var1, rmode) \ SL1_shl_round_shr(L_var1, 0, rmode, 0)/*! \def _sl1_roundx_mmode_shr(L_var1, x, rmode, shr) * \brief a macro that shift L_var1 left by (16-x) and round the lower 16 bits into its MS 16 bits with multimode, do shift the result by shr if L_var1 hasn't acquired an acc register * \param L_var1 variable to be rounded(INT32) * \param x immediate integer, shift left by (16-x) * \param rmode round mode, see enum ROUND_MODE * \param shr immediate integer * \return round result * \note L_var1 should not acquire an acc register before <br> c3.mvts acc, L_var1, 0 <br> c3.round acc, (16-bit), mode <br> c3.mvfs rd, acc, shr <br> * \see _sl1_roundx_mmode(L_var1, x, rmode) if L_var1 acquired an acc register */#define _sl1_roundx_mmode_shr(L_var1, x, rmode, shr) \ SL1_shl_round_shr(L_var1, (16-x), rmode, shr)/*! \def _sl1_roundx_mmode(L_var1, x, rmode) * \brief a macro that shift L_var1 left by (16-x) and round the lower 16 bits into its MS 16 bits with multimode * \param L_var1 variable to be rounded(INT32) * \param x immediate integer, shift left by (16-x) * \param rmode round mode, see enum ROUND_MODE * \return round result * \note if L_var1 acquired an acc register <br> c3.round acc, (16-bit), mode or <br> c3.mvts acc, L_var1, 0 <br> c3.round acc, (16-bit), mode <br> c3.mvfs rd, acc, 0 <br> * \see _sl1_roundx_mmode_shr(L_var1, x, rmode) */#define _sl1_roundx_mmode(L_var1, x, rmode) \ SL1_shl_round_shr(L_var1, (16-x), rmode, 0)/*! \def _sl1_lead_mmode(L_var1, mode) * \brief a macro that count the number of zero/one in L_var1 by mode * \param L_var1 variable(INT32) * \param mode see LEAD_MODE * \return count numbers * \note if L_var1 acquired an acc register before <br> c3.lead rd, acc, mode */#define _sl1_lead_mmode(L_var1, mode) \ SL1_lead(L_var1, mode)/*! \def _sl1_l_muld_shl(L_var1, L_var2, shl) * \brief a macro that signed multiply 32 bit L_var1 and L_var2 and shift the result left by shl, get low 32 bits * \param L_var1 variable(INT32) * \param L_var2 variable(INT32) * \param shl unsigned immediate integer, should be in range of (0,31) * \return low 32 bit of result * \note c3.muls rd, L_var1, L_var2, shl */#define _sl1_l_muld_shl(L_var1, L_var2, shl) \ SL1_L_muld_shl(L_var1, L_var2, shl)/*! \def _sl1_l_mulud_shl(U_var1, U_var2, shl) * \brief a macro that unsigned multiply 32 bit L_var1 and L_var2 and shift the result left by shl, get low 32 bits * \param U_var1 variable(UINT32) * \param U_var2 variable(UINT32) * \param shl unsigned immediate integer, should be in range of (0,31) * \return low 32 bit of result * \note c3.mulus rd, L_var1, L_var2, shl */#define _sl1_l_mulud_shl(U_var1, U_var2, shl) \ SL1_L_muld_shl_unsigned(U_var1, U_var2, shl) /*! \def _sl1_l_muld_shl_hi(L_var1, L_var2, shl) * \brief a macro that multiply 32 bit L_var1 and L_var2 and shift the result left by shl, get high 32 bits * \param L_var1 variable(INT32) * \param L_var2 variable(INT32) * \param shl unsigned immediate integer, should be in range of (0,31) * \return high 32 bit of result * \note c3.muls Hi, $0, L_var1, L_var2, shl <br> c3.mvfs rd, Hi, 0 */#define _sl1_l_muld_shl_hi(L_var1, L_var2, shl) \ SL1_L_muld_shl_hi(L_var1, L_var2, shl)/*! \def _sl1_l_mulud_shl_hi(U_var1, U_var2, shl) * \brief a macro that unsigned multiply 32 bit L_var1 and L_var2 and shift the result left by shl, get high 32 bits * \param U_var1 variable(UINT32) * \param U_var2 variable(UINT32) * \param shl unsigned immediate integer, should be in range of (0,31) * \return high 32 bit of result * \note c3.mulus Hi, $0, U_var1, U_var2, shl <br> c3.mvfs rd, Hi, 0 */#define _sl1_l_mulud_shl_hi(U_var1, U_var2, shl) \ SL1_L_muld_shl_hi_unsigned(U_var1, U_var2, shl)/*! \def _sl1_l_sadd_shl(L_var1, L_var2, shl) * \brief a macro that add two 32 bit variable and shift the result left by shl with saturation * \param L_var1 variable(INT32) * \param L_var2 variable(INT32) * \param shl unsigned immediate integer,should be in range of (0, 31) * \return a saturated result(INT32) * \note c3.saadds rd, L_var1, L_var2, shl */#define _sl1_l_sadd_shl(L_var1, L_var2, shl) \ SL1_L_sadd_shl(L_var1, L_var2, shl)/*! \def _sl1_l_sadd_shl(L_var1, L_var2, shl) * \brief a macro that subtract L_var2 from L_var1 and shift the result left by sh1 with saturation * \param L_var1 variable(INT32) * \param L_var2 variable(INT32) * \param shl unsigned immediate integer,should be in range of (0, 31) * \return a saturated result(INT32) * \note c3.sasubs rd, L_var1, L_var2, shl */#define _sl1_l_ssub_shl(L_var1, L_var2, shl) \ SL1_L_ssub_shl(L_var1, L_var2, shl)/*! \def _sl1_l_mult_mmode_shr(var1, var2, mode, shr) * \brief a macro that multiply two 16 bits variable with different mode and shift right by shr * \param var1 variable(INT16) * \param var2 variable(INT16) * \param mode see ACC_MODE * \param shr unsigned immediate integer, should be in range of (0, 31) * \return result(INT32) * \note c3.mula acc, var1, var2, mode <br> c3.mvfs rd, acc, shr */#define _sl1_l_mult_mmode_shr(var1, var2, mode, shr) \ SL1_L_mul_shr(0, var1, var2, mode, shr)/*! \def _sl1_l_mult_mmode(L_acc, var1, var2, mode) * \brief a macro that multiply two 16 bits variable with different mode and store to an acc register required by L_acc * \param L_acc variable acquired an acc register * \param var1 variable(INT16) * \param var2 variable(INT16) * \param mode see ACC_MODE * \return result(INT32) * \note c3.mula L_acc, var1, var2, mode */#define _sl1_l_mult_mmode(L_acc, var1, var2, mode) \ SL1_L_mul_shr(L_acc, var1, var2, mode, 0) /*! \def _sl1_mult_mmode_hi(var1, var2, mode) * \brief a macro that multiply two 16 bits variable with different mode, get high 16 bits of result * \param var1 variable(INT16) * \param var2 variable(INT16) * \param mode see ACC_MODE * \return high 16-bit of mutilply result(INT16) * \note c3.mula acc, var1, var2, mode <br> c3.mvfs rd, acc, 16 */#define _sl1_mult_mmode_hi(var1, var2, mode) \ SL1_L_mul_shr(0, var1, var2, mode, 16) /*! \def _sl1_l_mult_shr_p(p1, am1, p2, am2, mode, shr) * \brief a macro that multiply two 16 bits variable load from addreg with different mode, shift right the result by shr * update address of p1 and p2 according with am1 and am2 * \param p1 a pointer variable map to address register(INT16 *) * \param am1 ar mode of p1 * \param p2 a pointer variable map to address register(INT16 *) * \param am2 ar mode of p2 * \param mode see ACC_MODE * \param shr unsigned immediate integer, should be in range of (0, 31) * \return result(INT32) * \note if p1 and p2 acquired address registers before <br> c3.mula.a acc, mode, p1, am1, p2, am2, 0 <br> c3.mvfs rd, acc, shr <br> or<br> c3.mvts ar1, p1, 0 <br> c3.mvts ar2, p2, 0 <br> c3.mula.a acc, mode, ar1, am1, ar2, am2, 0 <br> c3.mvfs rd, acc, shr <br> c3.mvfs p1, ar1, 0 <br> c3.mvfs p2, ar2, 0 <br> */#define _sl1_l_mult_shr_p(p1, am1, p2, am2, mode, shr) \ SL1_L_mul_shr_p(0, mode, p1, am1, p2, am2, 0, shr)/*! \def _sl1_l_mult_p(L_acc, p1, am1, p2, am2, mode) * \brief a macro that multiply two 16 bits variable loaded from addreg with different mode, * update address of p1 and p2 according with am1 and am2 * \param L_acc variable(INT32) prefer to acquire an acc register * \param p1 a pointer variable map to address register(INT16 *) * \param am1 ar mode of p1 * \param p2 a pointer variable map to address register(INT16 *) * \param am2 ar mode of p2 * \param mode see ACC_MODE * \return result(INT32) * \note if L_acc acquired an acc register && p1 and p2 acquired address registers before <br> c3.mula.a acc, mode, p1, am1, p2, am2, 0 # return acc <br> else<br> c3.mvts acc, L_acc, 0 <br> c3.mvts ar1, p1, 0 <br> c3.mvts ar2, p2, 0 <br> c3.mula.a acc, mode, ar1, am1, ar2, am2, 0 <br> c3.mvfs rd, acc, 0 <br> c3.mvfs p1, ar1, 0 <br> c3.mvfs p2, ar2, 0 <br> */#define _sl1_l_mult_p(L_acc, p1, am1, p2, am2, mode) \ SL1_L_mul_shr_p(L_acc, mode, p1, am1, p2, am2, 0, 0)/*! \def _sl1_l_mult_shr_v_p(var1, p2, am2, mode, shr) * \brief a macro that multiply var1 and variable loaded from addreg with different mode and shift right result by shr, * update address of p2 according with am2 * \param var1 variable(INT16) * \param p2 a pointer variable map to address register(INT16 *) * \param am2 ar mode of p2 * \param mode see ACC_MODE * \param shr unsigned immediate integer, should be in range of (0, 31) * \return result(INT32) * \note if p2 acquired an address register before <br> c3.mula.ar acc, mode, var1, p2, am2, 0 <br> c3.mvfs rd, acc, shr <br> or <br> c3.mvts ar1, p2, 0 <br> c3.mula.ar acc, mode, var1, ar1, am2, 0 <br> c3.mvfs rd, acc, shr <br> c3.mvfs p2, ar1, 0 */#define _sl1_l_mult_shr_v_p(var1, p2, am2, mode, shr) \ SL1_L_mul_shr_v_p(0, mode, var1, p2, am2, 0, shr)/*! \def _sl1_l_mult_v_p(L_acc, var1, p2, am2, mode) * \brief a macro that multiply var1 and variable load from address register with different mode, store to the acc register required by L_acc, update address of p2 according with ar2 * \param L_acc variable(INT32), prefer to acquire an acc register * \param var1 variable(INT16) * \param p2 a pointer variable map to address register(INT16 *) * \param am2 ar mode of p2 * \param mode see ACC_MODE * \return result(INT32) * \note if L_acc acquired an acc register && p2 acquired an address register before <br> c3.mula.ar L_acc, mode, var1, p2, am2, 0 <br> else <br> c3.mvts acc, L_acc, 0 <br> c3.mvts ar1, p2, 0 <br> c3.mula.ar acc, mode, var1, ar1, am2, 0 <br> c3.mvfs rd, acc, 0 <br> c3.mvfs p2, ar1, 0 <br> */#define _sl1_l_mult_v_p(L_acc, var1, p2, am2, mode) \ SL1_L_mul_shr_v_p(L_acc, mode, var1, p2, am2, 0, 0)/*! \def _sl1_l_mac(L_acc, var1, var2, mode) * \brief a macro that multiply \a var1 and \a var2 and add with \a L_acc with different mode * \param L_acc variable(INT32), prefer to acquire an acc register
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -