📄 chebps.asm
字号:
/*******************************************************************************
Copyright(c) 2000 - 2002 Analog Devices. All Rights Reserved.
Developed by Joint Development Software Application Team, IPDC, Bangalore, India
for Blackfin DSPs ( Micro Signal Architecture 1.0 specification).
By using this module you agree to the terms of the Analog Devices License
Agreement for DSP Software.
********************************************************************************
Module Name : cheb.asm
Label name : __cheb
Version : 1.0
Change History :
Version Date Author Comments
1.0 06/19/2001 Srinivas Original
Description : Evaluates the chebyshev polynomial series
- The polynomial F(z) (F1(z) or F2(z)) is given by
F(w) = 2 exp(-j5w) C(x)
where
C(x) = T_n(x) + f(1)T_n-1(x) + ... +f(n-1)T_1(x) + f(n)/2
and T_m(x) = cos(mw) is the mth order Chebyshev polynomial
( x=cos(w) )
- The routine returns the value of C(x) for the input x.
Prototype :
fract16 _cheb(fract16 x, fract16* f)
x -> value at which chebyshev polynomial series to be
evaluated,
f -> pointer to coefficients of sumlpc(z)/(1+z**-1) or
difflpc(z)/(1-z**-1) polynomial.
Algorithm :
b2 = 1.0;
b1 = 2*x + f[1];
for (i = 2; i < n; i++)
{
b0 = 2.0*x*b1 - b2 + f[i];
b2 = b1;
b1 = b0;
}
return(x*b1 - b2 + f[i]/2);
Assumptions : (1) order of the polynomial is assumed to be n = 5
Registers Used : A1, R0-R3, P0, P1, LC0.
Performance :
` Code size : 124 bytes
*******************************************************************************/
.section L1_code;
.global __cheb;
.align 8;
__cheb:
P1 = R1; //Pointer to coefficients of polynomial
R2.H = 256; //b2 = 1 in 8.24 format
R2.L = 0;
P0 = 3;
R1 = R0 << 10 || R3 = W[P1++] (X);
//2*x in 8.24, f[1]
R3 = R3 << 14; //f[1] in 8.24 format
R1 = R1 + R3(S); //b1 = 2*x + f[1]
LSETUP(LSTART0,LEND0) LC0 = P0;
LSTART0:
A1 = R0.L * R1.L (M);
//X * B1.L (x*b1) 16_32 bit multiplication
A1 = A1 >>> 15; //cross product in lower 16 bits
R3 = (A1 += R1.H * R0.L)(S2RND);
//B1.H * X + X * B1.L (x*b1)
R3 = R3 - R2 (S)|| R2 = W[P1++] (X);
//2*x*b1 - b2, Load f[i]
R2 = R2 << 14; //f[i] in 8.24 format
R3 = R3 + R2 (S); //b0 = 2*x*b1 - b2 + f[i]
R2 = R1; //b2 = b1
LEND0: R1 = R3; //b1 = b0
A1 = R0.L * R1.L (M) ; //x*b1
A1 = A1 >>> 15;
R3 = (A1 += R1.H * R0.L);
//x*b1
R3 = R3 - R2 (S)|| R2 = W[P1++] (X);
//x*b1 - b2, Load f[i]
R2 = R2 << 13; //f[5]/2 in 8.24 format
R3 = R3 + R2(s); //x*b1 - b2 + f[5]/2
R0 = R3 >>> 10; //result in R0.L
R1 = R0.L * R3.H || NOP;//for overflow checking due to final shift
CC = R1 < 0; //check for overflow
IF CC JUMP OVERFLOW;
RTS;
OVERFLOW: CC = R3 < 0;
R0 = 32767(X); //assign MAX_16 = 0X7FFF
R1 = -32768 (X); //assign MIN_16 = 0X8000
IF CC R0 = R1;
TERMINATE: RTS;
__cheb.end:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -