123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- #include "typedef.h"
- #include "basic_op.h"
- #include "oper_32b.h"
- #include "count.h"
- void L_Extract (Word32 L_32, Word16 *hi, Word16 *lo)
- {
- *hi = extract_h_ex (L_32);
- *lo = extract_l_ex (L_msu_ex (L_shr_ex (L_32, 1), *hi, 16384));
- return;
- }
- Word32 L_Comp (Word16 hi, Word16 lo)
- {
- Word32 L_32;
- L_32 = L_deposit_h_ex (hi);
- return (L_mac_ex (L_32, lo, 1));
- }
- Word32 Mpy_32 (Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
- {
- Word32 L_32;
- L_32 = L_mult_ex (hi1, hi2);
- L_32 = L_mac_ex (L_32, mult_ex (hi1, lo2), 1);
- L_32 = L_mac_ex (L_32, mult_ex (lo1, hi2), 1);
- return (L_32);
- }
- Word32 Mpy_32_16 (Word16 hi, Word16 lo, Word16 n)
- {
- Word32 L_32;
- L_32 = L_mult_ex (hi, n);
- L_32 = L_mac_ex (L_32, mult_ex (lo, n), 1);
- return (L_32);
- }
- Word32 Div_32 (Word32 L_num, Word16 denom_hi, Word16 denom_lo)
- {
- Word16 approx, hi, lo, n_hi, n_lo;
- Word32 L_32;
-
- approx = div_s ((Word16) 0x3fff, denom_hi);
-
- L_32 = Mpy_32_16 (denom_hi, denom_lo, approx);
- L_32 = L_sub_ex ((Word32) 0x7fffffffL, L_32);
- L_Extract (L_32, &hi, &lo);
- L_32 = Mpy_32_16 (hi, lo, approx);
-
- L_Extract (L_32, &hi, &lo);
- L_Extract (L_num, &n_hi, &n_lo);
- L_32 = Mpy_32 (n_hi, n_lo, hi, lo);
- L_32 = L_shl_ex (L_32, 2);
- return (L_32);
- }
|