home *** CD-ROM | disk | FTP | other *** search
- ;; Author - Rick Vander Kam
- ;; Copyright (c) 1992 - All rights reserved
- ;; Modification history
- ;; --------------------
- ;; 2/29/92/rvk - initial file created from /usr/lib/dsp/ugsrc/onezero.asm
- ;;
- ;;------------------------------ DOCUMENTATION ---------------------------
- ;; NAME
- ;; fir3 (UG macro) - three-point FIR filter section
- ;;
- ;; SYNOPSIS
- ;; fir3 pf,ic,sout,aout0,sinp,ainp0,s10,s20,bb00,bb10,bb20
- ;;
- ;; MACRO ARGUMENTS
- ;; pf = global label prefix (any text unique to invoking macro)
- ;; ic = instance count (s.t. pf\_fir3_\ic\_ is globally unique)
- ;; sout = output vector memory space ('x' or 'y')
- ;; aout0 = initial output vector memory address
- ;; sinp = input vector memory space ('x' or 'y')
- ;; ainp0 = initial input vector memory address
- ;; bb00 = initial coefficient of undelayed input
- ;; bb10 = initial coefficient of once delayed input
- ;; bb20 = initial coefficient of twice delayed input
- ;; s10 = initial once delayed state variable
- ;; s20 = initial twice delayed state variable
- ;;
- ;; DSP MEMORY ARGUMENTS
- ;; Access Description Initialization
- ;; ------ ----------- --------------
- ;; x:(R_X)+ Current output address aout0
- ;; x:(R_X)+ Current input address ainp0
- ;; x:(R_X)+ bb2 coefficient bb20
- ;; x:(R_X)+ s1 state variable s10
- ;; y:(R_Y)+ bb0 coefficient bb00
- ;; y:(R_Y)+ bb1 coefficient bb10
- ;; y:(R_Y)+ s2 state variable s20
- ;;
- ;; DESCRIPTION
- ;; The fir3 unit-generator implements a three-point
- ;; FIR filter section in direct form. For best performance,
- ;; output memory space should be y.
- ;;
- ;; In pseudo-C notation:
- ;;
- ;; ainp = x:(R_X)+;
- ;; aout = x:(R_X)+;
- ;; bb2 = x:(R_X)+;
- ;; s1 = x:(R_X)+;
- ;; bb0 = y:(R_Y)+;
- ;; bb1 = y:(R_Y)+;
- ;; s2 = y:(R_Y)+;
- ;;
- ;; for (n=0;n<I_NTICK;n++) {
- ;; in = sinp:ainp[n];
- ;; sout:aout[n] = bb0*in + bb1*s1 + bb2*s2;
- ;; s1 = in;
- ;; s2 = s1;
- ;; }
- ;;
- ;; DSPWRAP ARGUMENT INFO
- ;; fir3 (prefix)pf,(instance)ic,(dspace)sout,(output)aout,
- ;; (dspace)sinp,(input)ainp,s1,s2,bb0,bb1,bb2
- ;;
- ;; MAXIMUM EXECUTION TIME
- ;; ???
- ;;
- ;; MINIMUM EXECUTION TIME
- ;; ???
- ;;
- ;; SOURCE
- ;; /user/rvk/ee265/test/fir3UG/fir3.asm
- ;;
- ;; SEE ALSO
- ;; /usr/lib/dsp/ugsrc/biquad.asm - two-pole, two-zero filter section
- ;; /usr/lib/dsp/ugsrc/onepole.asm - one-pole filter section
- ;; /usr/lib/dsp/ugsrc/twopole.asm - two-pole filter section
- ;;
- ;; ALU REGISTER USE
- ;; X0 = x(n) and x(n-1) , input and s1 = once delayed input
- ;; X1 = x(n-2) = s2 = twice delayed input
- ;; Y0 = bb0,bb2 = undelayed and twice-delayed signal coefficients
- ;; Y1 = bb1 = once-delayed signal coefficient
- ;; A = multiply-add accumulator
- ;; B = holder for bb0
- ;;
- fir3 macro pf,ic,sout,aout0,sinp,ainp0,s10,s20,bb00,bb10,bb20
- new_xarg pf\_fir3_\ic\_,aout,aout0 ; output address arg
- new_xarg pf\_fir3_\ic\_,ainp,ainp0 ; input address arg
- new_xarg pf\_fir3_\ic\_,bb2,bb20 ; twice delayed input coeff
- new_xarg pf\_fir3_\ic\_,s2,s20 ; once delayed input sample
- new_yarg pf\_fir3_\ic\_,bb0,bb00 ; undelayed input coeff
- new_yarg pf\_fir3_\ic\_,bb1,bb10 ; once-delayed input coeff
- new_yarg pf\_fir3_\ic\_,s1,s10 ; twice-delayed input
-
- move x:(R_X)+,R_O ; output address to R_O
- move x:(R_X)+,R_I1 ; input address to R_I1
-
- move x:(R_X)+,Y1 ;bb2 to Y1
- move x:(R_X),X1 y:(R_Y)+,B ; s2 to X1, bb0 to B
- move y:(R_Y)+,Y0 ; bb1 to Y0
- move y:(R_Y),X0 ; s1 to X0
- mpy X1,Y1,A X0,X1 ; s2*bb2, update s2=x(n-1)
- macr X0,Y0,A sinp:(R_I1)+,X0 ; A += s1*bb1, update s1=x(n)
- tfr Y0,B B,Y0 ;bb0 to Y0, bb1 to B (swap)
- macr X0,Y0,A ;A += bb0*x(n) (= first output)
- do #I_NTICK-1,pf\_fir3_\ic\_tickloop
- tfr Y0,B B,Y0 ;bb0 to B, bb1 to Y0
- move A,sout:(R_O)+ ;ship output
- mpy X1,Y1,A X0,X1 ;A=bb2*x(n-2), s2=x(n-1)
- macr X0,Y0,A sinp:(R_I1)+,X0 ;A+=bb1*x(n-1), s1=x(n)
- tfr Y0,B B,Y0 ;bb0 to Y0, bb1 to B (swap)
- macr X0,Y0,A ;A += bb0*x(n)
- pf\_fir3_\ic\_tickloop
- if "sout"!='x'
- move X1,x:(R_X)+ A,sout:(R_O)+
- move X0,y:(R_Y)+
- else
- move A,sout:(R_O)+ ; ship last output
- move X1,x:(R_X)+ ; save s2 in mem arg
- move X0,y:(R_Y)+ ; save s1 in mem arg
- endif
- endm
-
-
-