📄 block_fir.asm
字号:
/**************************************************************
File Name: Block_FIR.asm
Date Modified: 02/16/99 RFG
05/01/00 RFG
Description:
Subroutine that implements a Block FIR Filter given
coefficients and samples.
Equation: y(n) = Summation from k=0 to M of h(k)*x(n-k)
Calling Parameters:
b0,i0 = address of delay line buffer
l0 = length of delay line buffer - 1
b1,i1 = address of input samples buffer
b8,i8 = address of coefficients buffer
l8 = length of coefficients buffer
b9,i9 = address of output buffer
r1 = number of taps in the filter
r2 = number of samples
m0,l1,l9 = 0
m1,m10 = 1
m2 = -1
m3,m9 = 2
Assumptions:
All arrays must start on even address boundaries.
All arrays must have an even number length (zero pad if necessary)
Delay Line must be of length TAPS + 1
Delay line and Input buffers stored in Block 1.
Instructions, Output, and Coefficients stored in Block 0.
Return Values:
b9 = output buffer
i0 = delay line pointer
Registers Affected:
r0,s0,r1,r3,r4,s4,r8,s8,r10,s10,r12,s12
i0,i8,i9
Cycle Count:
14 + samples(6 + taps/2) + 8 cache misses
Memory Usage:
Instructions Words (48-bits):
22 instruction words
Data Words (16, 32, 40, or 64-bits):
Number of taps locations for coefficients (32-bits)
Number of taps + 1 locations for the delay line buffer (32-bits)
Number of samples locations for the input buffer (32-bits)
Number of samples + 2 locations for the output buffer (32-bits)
Notes:
Silicon Revision Issue:
This code will not function properly on silicon revision 0.0
due to an anomaly related to internal addressing in SIMD mode.
For more information please refer to the anomaly list.
Circular Buffering Issue:
Because SIMD or Long word access transfer two 32-bit words, programs
must be careful when using these accesses in circular buffering.
It is important that SIMD or Long word accesses do not cross a circular
buffer boundary. If a SIMD mode access occurs using a circular buffer
index register that points to the last location in the circular buffer
(end of buffer), the resulting access transfers the last location in
the circular buffer and the first location outside the buffer (end of buffer + 1).
**************************************************************/
#include "def21160.h" /* Symbol Definition File */
.global block_fir;
/* program memory code */
.section/pm seg_pmco;
block_fir:
bit set MODE1 CBUFEN; /* Circular Buffer Enable */
nop; /* Circular Buffering not in effect until next cycle */
s0 = dm(i0, m1); /* move pointer to delay[1] */
s0 = dm(i0, m2); /* load s0 with the value of delay[1] for SIMD store, move pointer to delay[0] */
r1 = lshift r1 by -1; /* r1 = taps/2 due to SIMD mode */
r3 = 3; /* 3 macs outside of fir mac loop */
r3 = r1 - r3; /* r3 = taps/2 - 3 for fir mac loop counter */
bit set MODE1 PEYEN; /* SIMD Mode Enable */
r0 = dm(i1,m1); /* read one sample from INPUT[i] */
/* SIMD not in effect until next cycle */
f4 = pm(i8,m9); /* read 2 coeffs */
lcntr = r2, do main_fir until lce; /* outer loop - sample loop */
dm(i0,m3)=f0, pm(i9,m10)=f8; /* transfer new sample and last new sample to delayline, write result to OUTPUT[i] */
f8=f0*f4, f0=dm(i0,m3), f4=pm(i8,m9); /* samples * coeffs, read 2 samples, read 2 coeffs */
f12=f0*f4, f0=dm(i0,m3), f4=pm(i8,m9); /* samples * coeffs, read 2 samples, read 2 coeffs */
lcntr=r3, do macs until lce; /* FIR loop */
macs: f12=f0*f4, f8=f8+f12, f0=dm(i0,m3), f4=pm(i8,m9); /* samples * coeffs, accum, read 2 samples, read 2 coeffs */
f12=f0*f4, f8=f8+f12, s0=dm(i0,m2); /* samples * coeffs, accum, load s0 with the value of delay[1] for SIMD store, move pointer to delay[0] */
f8=f8+f12, s10=dm(i1,m1); /* final SIMD accum, read new sample into s10 */
r12=s8; /* move PEy total into PEx register file */
f8=f8+f12, f4=pm(i8,m9); /* last accum, read sample into s0 for first MAC of next sample, read 2 coeffs */
main_fir: f0 <-> s10; /* place new sample from s10 into f0 without corrupting s0, swaps f0 and s10 only */
rts (db);
bit clr MODE1 CBUFEN | PEYEN; /* Circular Buffer Disable, SIMD Mode Disable */
pm(i9,m10)=f8; /* write result to OUTPUT[i] */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -