/* This C language subroutine computes the Finite Impulse Response (FIR) filter specified by its floating point input, coefficients, and delay line. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 6/23/90 Updated on 5/94 by AS #include
fract xfir(fract sample, fract coeffs[], \ fract *state[], int taps); float fir(float sample, float coeffs[], \ float *state[], int taps); */ #include "lib_glob.h" #include "trn_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; /* Fractional parts removed for now */ .GLOBAL _fir; .GLOBAL ___firDD, ___firDP, ___firPD, ___firPP; ___firDD: JUMP (PC, fircore) (DB); pm_ptr=dm_dm_fir; pm_lnt=0; ___firDP: JUMP (PC, fircore) (DB); pm_ptr=dm_pm_fir; pm_lnt=0; _fir: ___firPD: JUMP (PC, fircore) (DB); pm_ptr=pm_dm_fir; pm_lnt=0; ___firPP: JUMP (PC, fircore) (DB); pm_ptr=pm_pm_fir; pm_lnt=0; ___xfirDD: JUMP (PC, fircore) (DB); pm_ptr=dm_dm_xfir; pm_lnt=0; ___xfirDP: JUMP (PC, fircore) (DB); pm_ptr=dm_pm_xfir; pm_lnt=0; _xfir: ___xfirPD: JUMP (PC, fircore) (DB); pm_ptr=pm_dm_xfir; pm_lnt=0; ___xfirPP: JUMP (PC, fircore) (DB); pm_ptr=pm_pm_xfir; pm_lnt=0; fircore: R0=R0-R0, put(R15); /*In case of fall through on error*/ R15=PASS R4, put(R14); R14=PASS R8, put(R10); put(R13); R13=PASS R12,readparam4(R12); /*Read taps*/ IF NE JUMP (pm_0,pm_ptr) (DB);/*Jump to approriate routine*/ R1=MODE1; /*Save old mode*/ BIT SET MODE1 65536; /*Set to 40-BIT mode*/ restore_state: FETCH_RETURN dm_lnt=0; /*Restore this to zero for everyone else*/ MODE1=R1; /*Restore old mode*/ get(R13,1); get(R10,2); get(R14,3); get(R15,5); RETURN (DB); RESTORE_STACK RESTORE_FRAME dm_dm_fir: dm_pm_fir: pm_pm_fir: pm_dm_fir: R10=dma_i; /*Hold extra DM pointer*/ R13=R13+1, dma_i=R13; /*R13+1 --> base, dma_i --> delay*/ dm_bse=R13; /*Set base pointer*/ dm_lnt=R12; /*Set length pointer*/ R0=DM(dm_0,dma_i); /*Read pointer to delay location*/ R0=PASS R0, pm_ptr=R14; /*Point to delay location*/ IF EQ R0=R13; /*Initial access, set delay to 0*/ R13=PASS R12, dm_ptr=R0; /*Point to delay location*/ R2=R2-R2, DM(dm_ptr,dm_1)=R15; /*Store input in delay line*/ R8=R8-R8, R15=dm_ptr; R12=R12-R12, DM(dm_0,dma_i)=R15;/*Store new delay pointer*/ LCNTR=R13, DO pdconvolution UNTIL LCE; pdconvolution: F8=F2*F4, F12=F8+F12, F4=DM(dm_ptr,dm_1), F2=PM(pm_ptr,pm_1); JUMP (PC, restore_state) (DB); F8=F2*F4, F12=F8+F12; F0=F8+F12, dma_i=R10; /*Restore extra DM pointer*/ dm_dm_xfir: dm_pm_xfir: pm_pm_xfir: pm_dm_xfir: R10=dma_i; /*Hold extra DM pointer*/ R13=R13+1, dma_i=R13; /*R13+1 --> base, dma_i --> delay*/ dm_bse=R13; /*Set base pointer*/ MRF=0, dm_lnt=R12; /*Set length ptr, Clr accumulate reg*/ R0=DM(dm_0,dma_i); /*Read pointer to delay location*/ R0=PASS R0, pm_ptr=R14; /*Point to delay location*/ IF EQ R0=R13; /*Initial access, set delay to 0*/ R13=PASS R12, dm_ptr=R0; /*Point to delay location*/ R2=R2-R2, DM(dm_ptr,dm_1)=R15; /*Store input in delay line*/ R8=R8-R8, R15=dm_ptr; R12=R12-R12, DM(dm_0,dma_i)=R15;/*Store new delay pointer*/ LCNTR=R13, DO xpdconvolution UNTIL LCE; xpdconvolution: MRF=MRF+R2*R4 (SSF), R4=DM(dm_ptr,dm_1), R2=PM(pm_ptr,pm_1); JUMP (PC, restore_state) (DB); R0=MRF+R2*R4 (SSFR); dma_i=R10; .ENDSEG;