📄 firstereo.asm
字号:
/******************************************************************************
Copyright(c) 2000-2003 Analog Devices Inc.
*******************************************************************************
File Name : ASM_FIR.asm
Function Name : _ASM_fir
Description : This function performs FIR filter operation on given input.
Operands : R0 - Address of input vector,
R1 - Address of output vector,
R2 - Number of input elements
Filter structure is on stack.
Prototype:
void firStereo(const fract16 x[],fract16 y[],int n,fir_state_fr16 *s);
Structure of fir_state_fr16:
{
fract16 *h, // filter coefficients
fract16 *d, // start of delay line
fract16 *p, // read/write pointer
int k, // no. of coefficients
int l // interpolation/decimation index
} fir_state_fr16;
Registers used :
R0, R1, R2, R3, R3, R4, R5, R6, R7
I0 -> Address of delay line (used for updating the delay line)
I1 -> Address of delay line (used for fetching the delay line data)
I2 -> Address of filter coeff. h0, h1 , ... , hn-1
I3 -> Address of output array y[]
P0 -> Address of input array x[]
P1, P2, P4
P5 -> Address of structure s
Code size: 354 bytes
____________________________________________________________________________
Computation time:
a) Even Taps, Even no. inputs : 64 + Ni/2*(3 + Nc)
For Ni=256, L=8 : 1472
b) Odd Taps, Even no. inputs : 70 + Ni/2*(3 + Nc)
For Ni=256, L=9 : 1606
c) Even Taps, Odd no. inputs : 64 + (Ni-1)/2*(3 + Nc) + Nc
For Ni=257, L=8 : 1480
d) Odd Taps, Odd no. inputs : 73 + (Ni-1)/2*(3 + Nc) + Nc
For Ni=257, L=9 : 1618
_______________________________________________________________________________
******************************************************************************/
/* help to read program ****************
typedef struct
{
fract16 *h; // filter coefficients
fract16 *d; // start of delay line
fract16 *p; // read/write pointer
int k; // number of coefficients
int l; // interpolation/decimation index
} _fir_fr16_state; //defined in "filter.h", "..\Analog Devices\VisualDSP 4.5\Blackfin\include\filter.h"
fir_init(state, FIR_coefs_fract16, delay, NUM_TAPS, 1); //defined in "filter.h"
ASM_FIR(InData, FIROutData, VEC_SIZE, &state); //in "ASM_FIR.asm"
*/
.section program;
.global _firStereo;
.align 8;
_firStereo:
[--SP]=(R7:4,P5:4); //PUSH R7-R4,P5-P4 ON STACK
P5=[SP+36]; // ADDRESS OF FILTER STRUCTURE
P0=R0; // ADDRESS OF INPUT ARRAY
I3=R1; // ADDRESS OF OUTPUT ARRAY
CC=R2<=0; // CHECK IF NUMBER OF INPUT ELEMENTS<=0
P1=[P5++]; // POINTER TO FILTER COEFFICIENTS
P2=[P5++]; // POINTER TO DELAY LINE
P4=[P5++]; // ADDRESS TO READ/WRITE POINTER
R1=[P5--]; // NUMBER OF COEFFICIENTS
IF CC JUMP _fir_fr16_RET_END;
CC=R1<=0; // CHECK IF NUMBER OF COEFF. <=0
IF CC JUMP _fir_fr16_RET_END;
R5=R1; // STORE NUMBER OF FILTER COEFF. IN R5
R1=R1+R1; // DOUBLE R1 TO INCREMENT AS HALF WORD
I2=P1; // INITIALISE I2 TO FILTER COEFF. ARRAY
B2=P1; // MAKE FILTER COEFFS. AS CIRCULAR BUFFER
L2=R1;
R1=R1+R1;
I0=P4; // INDEX TO READ/WRITE POINTER
B0=P2; // INITIALISE B0 AND L0
L0=R1; // FOR DELAY LINE CIRCULAR BUFFER
P1=R2; // SET OUTER LOOP COUNTER
P2=R5; // SET INNER LOOP COUNTER
NOP;
NOP;
NOP;
I0-=4;
/*****************************************************************************/
LSETUP(_fir_fr16_E_FIR_START,_fir_fr16_E_FIR_END) LC0=P1; // Loop 1 to Ni
_fir_fr16_E_FIR_START:
A0=0;
A1=0;
R0.L=W[P0]; //get new data, from "Indata"
P0+=2;
R0.H=W[P0];
P0+=2;
W[I0]=R0.L; //change the oldest data, to "delay"
I0+=2;
W[I0]=R0.H;
I0-=2;
LSETUP(_fir_fr16_E_MAC_ST,_fir_fr16_E_MAC_END)LC1=P2; //Loop 1 to Nc
_fir_fr16_E_MAC_ST:
R0.L=W[I0++]; //get xn
R0.H=W[I0++]; //get xn
R2.L=W[I2++]; //get hn
A0+=R0.L*R2.L; //calculate yn
A1+=R0.H*R2.L; //calculate yn
_fir_fr16_E_MAC_END:
NOP;
R3.L=A0 (T);
I0-=4;
W[I3++]=R3.L; //save yn
R3.H=A1 (T);
W[I3++]=R3.H; //save yn
_fir_fr16_E_FIR_END:
NOP;
/*****************************************************************************/
_fir_fr16_RET_END:
L0=0; // Clear the circular buffer initialization
L2=0;
(R7:4,P5:4)=[SP++]; //POP R7-R4,P5-P4 FROM STACK
RTS;
._firStereo.end:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -