IQtoQN

来源:互联网 发布:mac用什么浏览器比较好 编辑:程序博客网 时间:2024/05/21 10:32
This Macro converts a 32-bit number in GLOBAL_Q format to 16-bit number in QN format.
Declaration C int _IQtoQN(_iq A)
C++ int IQtoQN(const iq &A)
Input IQ number in GLOBAL_Q format
Output Equivalent value of input in QN format (16-bit fixed point number)
Usage This macro may be used in cases where the input and output data is 16-bits, but the intermediate operations are operated using IQ data types.
Example:
Sum of product computation using the input sequence that is not in GLOBAL_Q format:
Y = X0*C0 + X1*C1 + X2*C2 // X0, X1, X2 in Q15 format
//C0,C1, C2 in GLOBAL_Q format
We can convert the Q15 values to IQ, perform the intermediate sums using IQ and then store the result back as Q15:
short X0, X1, X2; // Q15 short
iq C0, C1, C2; // GLOBAL_Q
short Y; // Q15
_iq sum // IQ (GLOBAL_Q)
sum = _IQmpy(_Q15toIQ(X0), C0);
sum += _IQmpy(_Q15toIQ(X1), C1);
sum += _IQmpy(_Q15toIQ(X2), C2);
Y = _IQtoQ15(sum);
0 0
原创粉丝点击