📄 fir2macs.asm
字号:
;
; fir2macs.asm - Dual-MAC Block FIR filter
;
; prototype: unsigned int fir2macs(int *, unsigned int, int *,
; unsigned int, int *, int *, unsigned int);
;
; Entry: arg0: AR0 - filter input buffer pointer
; arg1: T0 - number of samples in the input buffer
; arg2: AR1 - FIR coefficients array pointer
; arg3: T1 - FIR filter order
; arg4: AR2 - filter output buffer pointer
; arg5: AR3 - signal buffer pointer
; arg6: AR4 - signal buffer index
;
; Return: T0 = signal buffer index
;
.def _fir2macs
.sect "fir_code"
_fir2macs
pshm ST1_55 ; Save ST1, ST2, and ST3
pshm ST2_55
pshm ST3_55
or #0x340,mmap(ST1_55); Set FRCT,SXMD,SATD
bset SMUL ; Set SMUL
mov XAR1,XCDP ; CDP as coefficient pointer
mov mmap(AR1),BSAC ; Set up base address for CDP
mov #0,CDP ; Start from the 1st coefficient
mov mmap(T1),BKC ; Set the coefficient array size
mov XAR3,XAR1 ; AR1 & AR3 as signal buffer pointers
mov mmap(AR3),BSA01 ; Set base address for AR1
mov mmap(AR3),BSA23 ; Set base address for AR3
add #1,T1
mov mmap(T1),BK03 ; Set signal buffer x[] size as L+1
mov AR4,AR3 ; AR3 signal buffer index
mov AR4,AR1
or #0x10A,mmap(ST2_55); CDP, AR1, AR3 circular pointers
amar *AR1+ ; AR1 delayline index+1
|| sfts T0,#-1 ; Use half of data samples
sub #1,T0 ; as outer repeat counter
mov T0,BRC0 ; Outer loop couter
sub #4,T1,T0
mov T0,CSR ; Inner loop counter as L/2-2
|| rptblocal sample_loop-1
mov *AR0+,*AR1 ; Put new sample to signal buffer x[n]
mov *AR0+,*AR3 ; Put next new sample to location x[n+1]
mpy *AR1+,*CDP+,AC0 ; The first operation
:: mpy *AR3+,*CDP+,AC1
|| rpt CSR
mac *AR1+,*CDP+,AC0 ; The rest MAC iterations
:: mac *AR3+,*CDP+,AC1
macr *AR1,*CDP+,AC0
:: macr *AR3,*CDP+,AC1 ; The last MAC operation
mov pair(hi(AC0)),dbl(*AR2+); Store two output data
sample_loop
popm ST3_55 ; Restore ST1, ST2, and ST3
popm ST2_55
popm ST1_55
mov AR3,T0 ; Return signal buffer index
|| ret
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -