📄 quantfiltcoef.asm
字号:
;
; Project: Experiment 3.6.3 Quantization Filter Coefficients - Chapter 3
; File name: quantFiltCoef.asm
;
; Description: This function demonstrates the quantization effects to filter coefficients
;
; For the book "Real Time Digital Signal Processing:
; Implementation and Application, 2nd Ed"
; By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
; Publisher: John Wiley and Sons, Ltd
;
;
; Tools used: CCS v.2.12.07
; TMS320VC5510 DSK Rev-C
;
;
; IIR4.asm - 4th order IIR filter
;
.mmregs
.def _IIR4
.def _initIIR4
;
; Original coefficients of 4th-order IIR LPF
; with cut-off frequency and sampling frequency fc/fs = 0.225
;
; short b[5]={0.0072, 0.00287, 0.0431, 0.0287, 0.0072};
; short a[5]={1.0000, -2.16860,2.0097,-0.8766, 0.1505};
;
.data ; Q13 formatted coefficients
iirCoeff ; b0, b1, b2, b3, b4
.word 0x003B, 0x00EB
.word 0x0161, 0x00EB, 0x003B
; -a1, -a2, -a3, -a4
.word 0x4564, -0x404F
.word 0x1C0D, -0x04D1
.bss x,5 ; x delay line
.bss y,4 ; y delay line
.bss coeff,9 ; Filter coefficients
.text
;
; 4th Order IIR filter initialization routine
; Entry T0 = mask to mask filter coefficients
;
_initIIR4
pshboth XAR5
pshboth XAR6
amov #x,XAR5 ; Zero x delay line
rpt #4
mov #0,*AR5+
amov #y,XAR5 ; Zero y delay line
rpt #3
mov #0,*AR5+
mov #8,BRC0 ; Initialize coefficients and mask off some bits
amov #iirCoeff,XAR5
amov #coeff,XAR6
rptb maskCoefLoop-1
mov *AR5+,AC0
and T0,AC0
mov AC0,*AR6+
maskCoefLoop
popboth XAR6
popboth XAR5
ret
;
; 4th Order IIR filter
; Entry T0 = sample
; Exit T0 = filtered sample
;
_IIR4
pshboth XAR5
pshboth XAR6
bset SATD
bset SXM
amov #x,XAR5
amov #y,XAR6
amov #coeff,XCDP
bset FRCT
|| mov T0,*AR5 ; x[0] = indata
;
; perform IIR filtering
;
mpym *AR5+,*CDP+,AC0 ; AC0=x[0]*bn[0]
|| rpt #3 ; i=1,2,3,4
macm *AR5+,*CDP+,AC0 ; AC0+=x[i]*bn[i]
rpt #3 ; i=0,1,2,3
macm *AR6+,*CDP+,AC0 ; AC0+=y[i]*an[i]
amov #y+2,XAR5
amov #y+3,XAR6
sfts AC0,#2 ; Scale to Q15 format
|| rpt #2
mov *AR5-,*AR6- ; Update y[]
mov hi(AC0),*AR6
|| mov hi(AC0),T0 ; return y[0] in T0
amov #x+3,XAR5
amov #x+4,XAR6
bclr FRCT
|| rpt #3
mov *AR5-,*AR6- ; Update x[]
popboth XAR6
popboth XAR5
bclr SXM
bclr SATD
ret
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -