📄 example 5-8.asm
字号:
; Example 5 - 8. FIR Filter Implementation ASM Listing for the TMS320C62x DSP
* ========================================================================= *
* *
* TEXAS INSTRUMENTS, INC. *
* *
* NAME *
* DSP_fir_gen *
* *
* REVISION DATE *
* 15-Feb-2002 *
* *
* USAGE *
* This routine is C-callable and can be called as: *
* *
* void DSP_fir_gen *
* ( *
* const short *restrict x, *
* const short *restrict h, *
* short *restrict r, *
* int nh, *
* int nr *
* ) *
* *
* x[nr+nh-1] : Input array *
* h[nh] : Coefficient array. Must be in reverse order. *
* r[nr] : Output array *
* nh : Number of coefficients. Must be >= 5. *
* nr : Number of output samples *
* *
* DESCRIPTION *
* Computes a real FIR filter (direct-form) using coefficients stored *
* in vector h. The coefficients have to be arranged in reverse *
* order. The real data input is stored in vector x. The filter *
* output result is stored in vector r. It operates on 16-bit data *
* with a 32-bit accumulate. The filter is nr output samples and nh *
* coefficients. *
* *
* C CODE *
* void DSP_fir_gen *
* ( *
* const short *restrict x, *
* const short *restrict h, *
* short *restrict r, *
* int nh, *
* int nr *
* ) *
* { *
* int i, j, sum; *
* *
* for (j = 0; j < nr; j++) *
* { *
* sum = 0; *
* for (i = 0; i < nh; i++) *
* sum += x[i + j] * h[i]; *
* r[j] = sum >> 15; *
* } *
* } *
* *
* TECHNIQUES *
* The inner loop is unrolled four times, but the last three *
* accumulates are executed conditionally to allow for a number of *
* coefficients that is not a multiple of four. The outer loop is *
* unrolled twice, but the last store is executed conditionally to *
* allow for a number of output samples that is not a multiple of *
* two. Both the inner and outer loops are software pipelined. *
* *
* ASSUMPTIONS *
* nh must be >= 5. *
* *
* MEMORY NOTE *
* No memory bank hits under any conditions. *
* *
* NOTES *
* This function is interrupt-tolerant but not interruptible. *
* This function is endian neutral. *
* *
* CYCLES *
* (4 * ceil(nh/4) + 9) * ceil(nr/2) + 18 *
* *
* For nh = 13, nr = 19: 268 cycles *
* *
* CODESIZE *
* 640 bytes *
* *
* ------------------------------------------------------------------------- *
* Copyright (c) 2002 Texas Instruments, Incorporated. *
* All Rights Reserved. *
* ========================================================================= *
.text
.global _DSP_fir_gen
_DSP_fir_gen:
STW .D2T1 A14,*B15--[8] ; push register (for c-callable func)
|| MV .L1X B15,A14
STW .D2T1 A13,*+B15[6] ; push register (for c-callable func)
|| STW .D1T2 B13,*-A14[4] ; push register (for c-callable func)
|| SUB .L2 B6,1,B6 ; used to do last h mults if necessary
STW .D1T1 A12,*-A14[3] ; push register (for c-callable func)
|| STW .D2T2 B11,*+B15[2] ; push register (for c-callable func)
|| ADD .S2 B6,4,B6 ; set up inner loop counter
|| AND .L2 B6,3,B13 ; used to do last h mults if necessary
|| MVK .S1 7,A13 ; used to do last h mults if necessary
STW .D2T2 B12,*+B15[3] ; push register (for c-callable func)
|| SHR .S2 B6,2,B12 ; set up inner loop counter
|| AND .S1 A8,1,A12 ; used to do last r store if necessary
|| ADD .L1 A8,1,A8 ; set up outer loop counter
|| XOR .L2 3,B13,B13 ; used to do last h mults if necessary
STW .D1T2 B10,*-A14[7] ; push register (for c-callable func)
|| ADD .L2X A6,2,B11 ; set up pointer to r[1]
|| SHR .S1 A8,1,A2 ; set up outer loop counter
LDH .D1 *A4++,B8 ; x0 = x[j]
|| ADD .L2X A4,4,B1 ; set up pointer to x[j+2]
|| ADD .L1X B4,2,A8 ; set up pointer to h[1]
||[A2] SUB .S1 A2,1,A2 ; decrement outer loop counter
LDH .D2 *B1++[2],B0 ; x2 = x[j+i+2]
|| LDH .D1 *A4++[2],A0 ; x1 = x[j+i+1]
|| SHR .S2X A13,B13,B13 ; used to do last h mults if necessary
|| XOR .S1 A12,1,A12 ; used to do last r store if necessary
LDH .D1 *A8++[2],B6 ; h1 = h[i+1]
|| LDH .D2 *B4++[2],A14 ; h0 = h[i]
|| SHL .S1 B12,3,A3 ; used to rst x pointer each outer loop
|| SHL .S2 B12,3,B10 ; used to rst h pointer each outer loop
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -