home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-06-28 | 260.4 KB | 8,078 lines |
- 1
- 5
- %
- TMS32010; Direct Paged Memory
- 2594
- 1
- 5
- %
- TMS32010; Direct Paged Memory; Increased Precision
- 10228
- 1
- 6
- %
- TMS32020; Direct Paged Memory
- 18230
- 1
- 6
- %
- TMS32020; Direct Paged Memory; Increased Precision
- 25603
- 1
- 6
- %
- TMS32020; Indexed Memory
- 33534
- 1
- 6
- %
- TMS32020; Indexed Memory; Increased Precision
- 40890
- 1
- 6
- %
- TMS32020; Index Memory; Looping Control
- 48693
- 1
- 6
- %
- TMS32020; Indexed Memory; Looping Control; Increased Precision
- 54791
- 2
- 5
- %
- TMS32010; Direct Paged Memory
- 61095
- 2
- 6
- %
- TMS32020/c25; Indexed Memory; MACD realization
- 65890
- 2
- 6
- %
- TMS32020/c25; Internal Direct Paged Memory
- 71234
- 2
- 6
- %
- TMS32020/c25; Indexed Memory; Internal Delay Memory
- 75728
- 2
- 6
- %
- TMS32020/c25; Indexed Memory; Internal or External Memory
- 81019
- 3
- 5
- %
- TMS32010; Direct Paged Memory
- 86062
- 3
- 6
- %
- TMS32020/c25; Indexed Memory; MACD realization
- 90858
- 3
- 6
- %
- TMS32020/c25; Internal Direct Paged Memory
- 96203
- 3
- 6
- %
- TMS32020/c25; Indexed Memory; Internal Delay Memory
- 100698
- 3
- 6
- %
- TMS32020/c25; Indexed Memory; Internal or External Memory
- 105990
- 1
- 7
- %
- TMS320c25; Direct Paged Memory
- 111035
- 1
- 7
- %
- TMS320c25; Direct Paged Memory; Increased Precision
- 118385
- 1
- 7
- %
- TMS320c25; Indexed Memory
- 126293
- 1
- 7
- %
- TMS320c25; Indexed Memory; Increased Precision
- 133629
- 1
- 7
- %
- TMS320c25; Indexed Memory; Looping Control
- 141413
- 1
- 7
- %
- TMS320c25; Indexed Memory; Looping Control; Increased Precision
- 147504
- 3
- 8
- ~
- TMS320C30; 'C' interface; Time Optimize w/ Optimized Filter Routine
- 153837
- 3
- 8
- ~
- TMS320C30; 'C' interface; Time Optimize
- 161881
- 3
- 8
- ~
- TMS320C30; 'C' interface; Size Optimize
- 167052
- 3
- 8
- ~
- TMS320C30; ASM30 interface; Time Optimize w/ Optimized Filter Routine
- 173430
- 3
- 8
- ~
- TMS320C30; ASM30 interface; Time Optimized
- 181107
- 3
- 8
- ~
- TMS320C30; ASM30 interface; Size Optimized
- 185967
- 2
- 8
- ~
- TMS320C30; 'C' interface; Time Optimize w/ Optimized Filter Routine
- 192225
- 2
- 8
- ~
- TMS320C30; 'C' interface; Time Optimize
- 200269
- 2
- 8
- ~
- TMS320C30; 'C' interface; Size Optimize
- 205440
- 2
- 8
- ~
- TMS320C30; ASM30 interface; Time Optimize w/ Optimized Filter Routine
- 211818
- 2
- 8
- ~
- TMS320C30; ASM30 interface; Time Optimized
- 219495
- 2
- 8
- ~
- TMS320C30; ASM30 interface; Size Optimized
- 224355
- 1
- 8
- ~
- TMS320C30; 'C' interface; Optimized Filter Routine
- 230596
- 1
- 8
- ~
- TMS320C30; 'C' interface
- 243029
- 1
- 8
- ~
- TMS320C30; ASM30 interface; Optimized Filter Routine
- 249007
- 1
- 8
- ~
- TMS320C30; ASM30 interface
- 260959
- >>>>
- >>>
- 1
- 5
- %
- TMS32010; Direct Paged Memory
- >>>
- %batch_files 2 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32010 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;*
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 6*16
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- LDPK IOPAGE ;SET PAGE POINTER
- SOVM ;SATURATION ARITHMETIC
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 0 ;FILTER TEMPORY DATA
- VSAMPL .set 1 ;FILTER INPUT/OUTPUT DATA
- IOPAGE .set 0
- %else% .global FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- %section%;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %if B0<%%else% .word %B0% ;B0
- %endif%%if B1<>% .word %B1% ;B1
- %endif%%if A1<%%else% .word %A1% ;A1
- %endif%%if half%%else% .word %A2% ;A2
- %if B2<%%else% .word %B2% ;B2
- %endif%%endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;* DELAY STORAGE DATA STORAGE AREA
- ;*
- DELAY:
- %section%Z%section_n%1: .space 1*16
- %if half%%else%Z%section_n%2: .space 1*16
- %endif%%loop%;*
- ;*
- ;* COEFFICIENT DATA STORAGE AREA
- ;*
- FDATA:
- %section%;*
- %if B0<%%else%B%section_n%0: .space 1*16 ;B0
- %endif%%if B1<>%B%section_n%1: .space 1*16 ;B1
- %endif%%if A1<%%else%A%section_n%1: .space 1*16 ;A1
- %endif%%if half%%else%A%section_n%2: .space 1*16 ;A2
- %if B2<%%else%B%section_n%2: .space 1*16 ;B2
- %endif%%endif%%loop%;*
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%: LACK 1 ;GET A 1
- SACL FILTT ;TEMPORARY SAVE
- LT FILTT ;LOAD 1 IN T
- MPYK COEF
- PAC ;AC HAS ADDRESS OF COEF DATA
- MPYK 1 ;1 INTO P
- LARK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% LARK 1,%points% ;COUNT FOR NUMBER OF POINTS
- ILP: LARP 0 ;RESET AR TO 0
- TBLR *+,1 ;TRANSFER DATA VALUE
- APAC ;INCREMENT POINTER
- BANZ ILP ;LOOP
- %endif% LARK 1,%ndelay% ;NUMBER OF DELAY POINTS
- ZAC ;CLEAR ACCUMULATOR
- LARK 0,Z011 ;POINT TO DELAY MEMORY
- ILPA: LARP 0 ;RESET AR TO 0
- SACL *+,0,1 ;CLEAR DATA VALUE
- BANZ ILPA ;LOOP
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* PAGE REGISTER IS SET TO COEF. PAGE
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- %if option M%FILTER%else%F%IDT%%endif%:
- %section%;*
- ;* SECOND-ORDER FILTER SECTION # %section_n%
- ;*
- %filtin%%if half% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = (B0 * INPUT)/2
- %else% MPY B%section_n%0 ;P = (B0 * INPUT)/2
- %endif% ZALH Z%section_n%1
- ADDH Z%section_n%1 ;AC = Z-1
- %if B1<>% APAC
- APAC ;AC = Z-1 + (B0 * INPUT)
- MPY B%section_n%1 ;P = (B1 * INPUT)/2
- %else% APAC
- APAC ;AC = Z-1 + (B0 * INPUT)
- %endif% SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- %if B1<>% PAC
- %endif% LT %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>% ;AC = (B1 * INPUT)/2%endif%
- %if A1<% MPYK %A1% ;P = (A1 * OUTPUT)/2
- %else% MPY A%section_n%1 ;P = (A1 * OUTPUT)/2
- %endif% %if B1<>%A%endif%PAC ;AC = ((B1 * INPUT) + (A1 * OUTPUT))/2
- %if A1shft% APAC
- %endif% SACH Z%section_n%1 ;Save in Z-1
- %else
-
- %%if B1<>% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = (B0 * INPUT)/2
- %else% MPY B%section_n%0 ;P = (B0 * INPUT)/2
- %endif% ZALH Z%section_n%1
- ADDH Z%section_n%1 ;AC = Z-1
- APAC
- APAC ;AC = Z-1 + (B0 * INPUT)
- MPY B%section_n%1 ;P = (B1 * INPUT)/2
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- PAC
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;AC = (B1 * INPUT)/2
- ADDH Z%section_n%2 ;AC = (Z-2 + (B1 * INPUT))/2
- %if A1<% MPYK %A1% ;P = (A1 * OUTPUT)/2
- %else% MPY A%section_n%1 ;P = (A1 * OUTPUT)/2
- %endif%%if A1shft% APAC
- %endif% APAC ;AC = (Z-2 + (B1 * INPUT) + (A1 * OUTPUT))/2
- MPY A%section_n%2 ;P = (A2 * OUTPUT)/2
- SACH Z%section_n%1 ;Save in Z-1
- PAC ;AC = A2 * OUTPUT
- LT FILTT
- %if B2<% MPYK %B2% ;P = (B2 * INPUT)/2
- %else% MPY B%section_n%2 ;P = (B2 * INPUT)/2
- %endif% APAC ;AC = ((B2 * INPUT) + (A2 * OUTPUT))/2
- SACH Z%section_n%2 ;Save in Z-2
- %else
-
-
- % LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = (B0 * INPUT)/2
- %else% MPY B%section_n%0 ;P = (B0 * INPUT)/2
- %endif% ZALH Z%section_n%1
- ADDH Z%section_n%1 ;AC = Z-1
- APAC
- APAC ;AC = Z-1 + (B0 * INPUT)
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;Get OUTPUT
- ZALH Z%section_n%2 ;AC = (Z-2)/2
- %if A1<% MPYK %A1% ;P = (A1 * OUTPUT)/2
- %else% MPY A%section_n%1 ;P = (A1 * OUTPUT)/2
- %endif%%if A1shft% APAC
- %endif% APAC
- MPY A%section_n%2 ;AC = ((B1 * INPUT) + (A1 * OUTPUT))/2
- * ;P = (A2 * OUTPUT)/2
- SACH Z%section_n%1 ;Save in Z-1
- PAC ;AC = A2 * OUTPUT
- LT FILTT
- %if B2<% MPYK %B2% ;P = (B2 * INPUT)/2
- %else% MPY B%section_n%2 ;P = (B2 * INPUT)/2
- %endif% APAC ;AC = ((B2 * INPUT) + (A2 * OUTPUT))/2
- SACH Z%section_n%2 ;Save in Z-2
- %endif%%endif%%loop%*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 5
- %
- TMS32010; Direct Paged Memory; Increased Precision
- >>>
- %batch_files 2 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32010 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* INCREASED PRECISION IMPLEMENTATION
- ;*
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 6*16
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- LDPK IOPAGE ;SET PAGE POINTER
- SOVM ;SATURATION ARITHMETIC
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 0 ;FILTER TEMPORY DATA
- VSAMPL .set 1 ;FILTER INPUT/OUTPUT DATA
- IOPAGE .set 0
- %else% .global FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- %section%;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %if B0<%%else% .word %B0% ;B0
- %endif%%if B1<>% .word %B1% ;B1
- %endif%%if A1<%%else% .word %A1% ;A1
- %endif%%if half%%else% .word %A2% ;A2
- %if B2<%%else% .word %B2% ;B2
- %endif%%endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;* DELAY STORAGE DATA STORAGE AREA
- ;*
- DELAY:
- %section%Z%section_n%1: .space 1*16
- L%section_n%1: .space 1*16
- %if half%%else%Z%section_n%2: .space 1*16
- L%section_n%2: .space 1*16
- %endif%%loop%;*
- ;*
- ;* COEFFICIENT DATA STORAGE AREA
- ;*
- FDATA:
- %section%;*
- %if B0<%%else%B%section_n%0: .space 1*16 ;B0
- %endif%%if B1<>%B%section_n%1: .space 1*16 ;B1
- %endif%%if A1<%%else%A%section_n%1: .space 1*16 ;A1
- %endif%%if half%%else%A%section_n%2: .space 1*16 ;A2
- %if B2<%%else%B%section_n%2: .space 1*16 ;B2
- %endif%%endif%%loop%;*
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%: LACK 1 ;GET A 1
- SACL FILTT ;TEMPORARY SAVE
- LT FILTT ;LOAD 1 IN T
- MPYK COEF
- PAC ;AC HAS ADDRESS OF COEF DATA
- MPYK 1 ;1 INTO P
- LARK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% LARK 1,%points% ;COUNT FOR NUMBER OF POINTS
- ILP: LARP 0 ;RESET AR TO 0
- TBLR *+,1 ;TRANSFER DATA VALUE
- APAC ;INCREMENT POINTER
- BANZ ILP ;LOOP
- %endif% LARK 1,%ndelay%+%ndelay%+1 ;NUMBER OF DELAY POINTS
- ZAC ;CLEAR ACCUMULATOR
- LARK 0,Z011 ;POINT TO DELAY MEMORY
- ILPA: LARP 0 ;RESET AR TO 0
- SACL *+,0,1 ;CLEAR DATA VALUE
- BANZ ILPA ;LOOP
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* PAGE REGISTER IS SET TO COEF. PAGE
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- %if option M%FILTER%else%F%IDT%%endif%:
- %section%;*
- ;* SECOND-ORDER FILTER SECTION # %section_n%
- ;*
- %filtin%%if half% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = (B0 * INPUT)/2
- %else% MPY B%section_n%0 ;P = (B0 * INPUT)/2
- %endif% ZALH Z%section_n%1
- ADDS L%section_n%1
- ADDH Z%section_n%1
- ADDS L%section_n%1 ;AC = Z-1
- %if B1<>% APAC
- APAC ;AC = Z-1 + (B0 * INPUT)
- MPY B%section_n%1 ;P = (B1 * INPUT)/2
- %else% APAC
- APAC ;AC = Z-1 + (B0 * INPUT)
- %endif% SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- %if B1<>% PAC
- %endif% LT %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>% ;AC = (B1 * INPUT)/2%endif%
- %if A1<% MPYK %A1% ;P = (A1 * OUTPUT)/2
- %else% MPY A%section_n%1 ;P = (A1 * OUTPUT)/2
- %endif% %if B1<>%A%endif%PAC ;AC = ((B1 * INPUT) + (A1 * OUTPUT))/2
- %if A1shft% APAC
- %endif% SACH Z%section_n%1 ;Save in Z-1
- SACL L%section_n%1
- %else
-
- %%if B1<>% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = (B0 * INPUT)/2
- %else% MPY B%section_n%0 ;P = (B0 * INPUT)/2
- %endif% ZALH Z%section_n%1
- ADDS L%section_n%1
- ADDH Z%section_n%1
- ADDS L%section_n%1 ;AC = Z-1
- APAC
- APAC ;AC = Z-1 + (B0 * INPUT)
- MPY B%section_n%1 ;P = (B1 * INPUT)/2
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- PAC
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;AC = (B1 * INPUT)/2
- ADDH Z%section_n%2
- ADDS L%section_n%2 ;AC = (Z-2 + (B1 * INPUT))/2
- %if A1<% MPYK %A1% ;P = (A1 * OUTPUT)/2
- %else% MPY A%section_n%1 ;P = (A1 * OUTPUT)/2
- %endif%%if A1shft% APAC
- %endif% APAC ;AC = (Z-2 + (B1 * INPUT) + (A1 * OUTPUT))/2
- MPY A%section_n%2 ;P = (A2 * OUTPUT)/2
- SACH Z%section_n%1 ;Save in Z-1
- SACL L%section_n%1
- PAC ;AC = A2 * OUTPUT
- LT FILTT
- %if B2<% MPYK %B2% ;P = (B2 * INPUT)/2
- %else% MPY B%section_n%2 ;P = (B2 * INPUT)/2
- %endif% APAC ;AC = ((B2 * INPUT) + (A2 * OUTPUT))/2
- SACH Z%section_n%2 ;Save in Z-2
- SACL L%section_n%2
- %else
-
-
- % LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = (B0 * INPUT)/2
- %else% MPY B%section_n%0 ;P = (B0 * INPUT)/2
- %endif% ZALH Z%section_n%1
- ADDS L%section_n%1
- ADDH Z%section_n%1
- ADDS L%section_n%1 ;AC = Z-1
- APAC
- APAC ;AC = Z-1 + (B0 * INPUT)
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;Get OUTPUT
- ZALH Z%section_n%2
- ADDS L%section_n%2 ;AC = (Z-2)/2
- %if A1<% MPYK %A1% ;P = (A1 * OUTPUT)/2
- %else% MPY A%section_n%1 ;P = (A1 * OUTPUT)/2
- %endif%%if A1shft% APAC
- %endif% APAC ;AC = ((B1 * INPUT) + (A1 * OUTPUT) + Z-2)/2
- MPY A%section_n%2 ;P = (A2 * OUTPUT)/2
- SACH Z%section_n%1 ;Save in Z-1
- SACL L%section_n%1
- PAC ;AC = A2 * OUTPUT
- LT FILTT
- %if B2<% MPYK %B2% ;P = (B2 * INPUT)/2
- %else% MPY B%section_n%2 ;P = (B2 * INPUT)/2
- %endif% APAC ;AC = ((B2 * INPUT) + (A2 * OUTPUT))/2
- SACH Z%section_n%2 ;Save in Z-2
- SACL L%section_n%2
- %endif%%endif%%loop%;*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 6
- %
- TMS32020; Direct Paged Memory
- >>>
- %batch_files 2 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 0 ;TEMPORARY FILTER DATA
- VSAMPL .set 1 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 6
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %if B0<%%else% .word %B0% ;B0
- %endif%%if B1<>% .word %B1% ;B1
- %endif%%if A1<%%else% .word %A1% ;A1
- %endif%%if half%%else% .word %A2% ;A2
- %if B2<%%else% .word %B2% ;B2
- %endif%%endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;* DELAY STORAGE DATA STORAGE AREA
- ;*
- DELAY:
- %section%Z%section_n%1: .space 1*16
- %if half%%else%Z%section_n%2: .space 1*16
- %endif%%loop%;*
- ;*
- ;* COEFFICIENT DATA STORAGE AREA
- ;*
- FDATA:
- %section%;*
- %if B0<%%else%B%section_n%0: .space 1*16 ;B0
- %endif%%if B1<>%B%section_n%1: .space 1*16 ;B1
- %endif%%if A1<%%else%A%section_n%1: .space 1*16 ;A1
- %endif%%if half%%else%A%section_n%2: .space 1*16 ;A2
- %if B2<%%else%B%section_n%2: .space 1*16 ;B2
- %endif%%endif%%loop%;*
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% RPTK %points% ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- %endif% ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay% ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- %section%;*
- ;* SECOND-ORDER FILTER SECTION # %section_n%
- ;*
- %filtin%%if half% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- %if B1<>% APAC
- MPY B%section_n%1 ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- %else% APAC ;AC = Z-1 + (B0 * INPUT)
- %endif% SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT%if B1<>%P%endif% %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>% ;AC = B1 * INPUT%endif%
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif% %if B1<>%A%endif%PAC ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- %if A1shft% APAC
- %endif% SACH Z%section_n%1 ;Save in Z-1
- %else
-
- %%if B1<>% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- APAC
- MPY B%section_n%1 ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LTP %if option M%VSAMPL%else%V%IDT%%endif% ;AC = B1 * INPUT
- ADDH Z%section_n%2 ;AC = Z-2 + (B1 * INPUT)
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% APAC
- MPY A%section_n%2 ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH Z%section_n%1 ;Save in Z-1
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY B%section_n%2 ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH Z%section_n%2 ;Save in Z-2
- %else
-
-
- % LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- APAC ;AC = Z-1 + (B0 * INPUT)
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;Get OUTPUT
- ZALH Z%section_n%2 ;AC = Z-2
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% APAC
- MPY A%section_n%2 ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH Z%section_n%1 ;Save in Z-1
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY B%section_n%2 ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH Z%section_n%2 ;Save in Z-2
- %endif%%endif%%loop%*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 6
- %
- TMS32020; Direct Paged Memory; Increased Precision
- >>>
- %batch_files 2 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;*Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* INCREASED PRECISION IMPLEMENTATION
- ;*
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT EQU 6 ;D/A OUTPUT
- DIN EQU 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 0 ;TEMPORARY FILTER DATA
- VSAMPL .set 1 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 6
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %if B0<%%else% .word %B0% ;B0
- %endif%%if B1<>% .word %B1% ;B1
- %endif%%if A1<%%else% .word %A1% ;A1
- %endif%%if half%%else% .word %A2% ;A2
- %if B2<%%else% .word %B2% ;B2
- %endif%%endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;* DELAY STORAGE DATA STORAGE AREA
- ;*
- DELAY:
- %section%Z%section_n%1: .space 1*16
- L%section_n%1: .space 1*16
- %if half%%else%Z%section_n%2: .space 1*16
- L%section_n%2: .space 1*16
- %endif%%loop%;*
- ;*
- ;* COEFFICIENT DATA STORAGE AREA
- ;*
- FDATA:
- %section%;*
- %if B0<%%else%B%section_n%0: .space 1*16 ;B0
- %endif%%if B1<>%B%section_n%1: .space 1*16 ;B1
- %endif%%if A1<%%else%A%section_n%1: .space 1*16 ;A1
- %endif%%if half%%else%A%section_n%2: .space 1*16 ;A2
- %if B2<%%else%B%section_n%2: .space 1*16 ;B2
- %endif%%endif%%loop%;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% RPTK %points% ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- %endif% ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay%+%ndelay%+1 ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- %section%;*
- ;* SECOND-ORDER FILTER SECTION # %section_n%
- ;*
- %filtin%%if half% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- ADDS L%section_n%1 ;ADD in least significant
- %if B1<>% APAC
- MPY B%section_n%1 ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- %else% APAC ;AC = Z-1 + (B0 * INPUT)
- %endif% SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT%if B1<>%P%endif% %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>% ;AC = B1 * INPUT%endif%
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif% %if B1<>%A%endif%PAC ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- %if A1shft% APAC
- %endif% SACH Z%section_n%1 ;Save in Z-1
- SACL L%section_n%1 ;Save least significant
- %else
-
- %%if B1<>% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- ADDS L%section_n%1 ;ADD in least significant
- APAC
- MPY B%section_n%1 ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LTP %if option M%VSAMPL%else%V%IDT%%endif% ;AC = B1 * INPUT
- ADDH Z%section_n%2 ;AC = Z-2 + (B1 * INPUT)
- ADDS L%section_n%2 ;ADD in least significant
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% APAC
- MPY A%section_n%2 ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH Z%section_n%1 ;Save in Z-1
- SACL L%section_n%1 ;Save least significant
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY B%section_n%2 ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH Z%section_n%2 ;Save in Z-2
- SACL L%section_n%2 ;Save least significant
- %else
-
-
- % LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- ADDS L%section_n%1 ;ADD in least significant
- APAC ;AC = Z-1 + (B0 * INPUT)
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;Get OUTPUT
- ZALH Z%section_n%2 ;AC = Z-2
- ADDS L%section_n%2 ;ADD in least significant
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% APAC
- MPY A%section_n%2 ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH Z%section_n%1 ;Save in Z-1
- SACL L%section_n%1 ;Save least significant
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY B%section_n%2 ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH Z%section_n%2 ;Save in Z-2
- SACL L%section_n%2 ;Save least significant
- %endif%%endif%%loop%*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 6
- %
- TMS32020; Indexed Memory
- >>>
- %batch_files 0 % .title "%IDT%" ;UNIQUE NAME
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %if B0<%%else% .word %B0% ;B0
- %endif%%if B1<>% .word %B1% ;B1
- %endif%%if A1<%%else% .word %A1% ;A1
- %endif%%if half%%else% .word %A2% ;A2
- %if B2<%%else% .word %B2% ;B2
- %endif%%endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;*
- ;* COEFFICIENT DATA STORAGE AREA
- ;*
- FDATA: .space (%points%+1)*16
- ;*
- ;* DELAY STORAGE DATA STORAGE AREA
- ;*
- DELAY: .space (%ndelay%+1)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% RPTK %points% ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- %endif% ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay% ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- COEFAR .set 1 ;Use AR1 to point to COEF's
- DELAR .set 2 ;Use AR2 to point to DELAY's
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LRLK COEFAR,FDATA ;Load COEF AR with beginning of COEF's
- LRLK DELAR,DELAY ;Load DELAY AR with beginning of DELAY's
- LARP %if B10<%DELAR%else%COEFAR%endif% ;Select Proper AR for initial use
- %section%;*
- ;* SECOND-ORDER FILTER SECTION # %section_n%
- ;*
- %filtin%%if half% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *,COEFAR ;AC = Z-1
- %if B1<>% APAC
- MPY *+,%if A1<%DELAR%else%COEFAR%endif% ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- %else% APAC ;AC = Z-1 + (B0 * INPUT)
- %endif% SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT%if B1<>%P%endif% %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>% ;AC = B1 * INPUT%endif%
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+,DELAR ;P = A1 * OUTPUT
- %endif% %if B1<>%A%endif%PAC ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- %if A1shft% APAC
- %endif% SACH *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save in Z-1
- %else
-
- %%if B1<>% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *+,COEFAR ;AC = Z-1
- APAC
- MPY *+,DELAR ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LTP %if option M%VSAMPL%else%V%IDT%%endif% ;AC = B1 * INPUT
- ADDH *-,COEFAR ;AC = Z-2 + (B1 * INPUT)
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+ ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% APAC
- MPY *+,DELAR ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH *+,0,%if B2<%DELAR%else%COEFAR%endif% ;Save in Z-1
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY *+,DELAR ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save in Z-2
- %else
-
-
- % LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *+,DELAR ;AC = Z-1
- APAC ;AC = Z-1 + (B0 * INPUT)
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;Get OUTPUT
- ZALH *-,COEFAR ;AC = Z-2
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+ ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% APAC
- MPY *+,DELAR ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH *+,0,%if B2<%DELAR%else%COEFAR%endif% ;Save in Z-1
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY *+,DELAR ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save in Z-2
- %endif%%endif%%loop%;*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 6
- %
- TMS32020; Indexed Memory; Increased Precision
- >>>
- %batch_files 0 % .title "%IDT%" ;UNIQUE NAME
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* Increased Precision
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %if B0<%%else% .word %B0% ;B0
- %endif%%if B1<>% .word %B1% ;B1
- %endif%%if A1<%%else% .word %A1% ;A1
- %endif%%if half%%else% .word %A2% ;A2
- %if B2<%%else% .word %B2% ;B2
- %endif%%endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;*
- ;* COEFFICIENT DATA STORAGE AREA
- ;*
- FDATA: .space (%points%+1)*16
- ;*
- ;* DELAY STORAGE DATA STORAGE AREA
- ;*
- DELAY: .space (%ndelay%+%ndelay%+2)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% RPTK %points% ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- %endif% ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay%+%ndelay%+1 ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- COEFAR .set 1 ;Use AR1 to point to COEF's
- DELAR .set 2 ;Use AR2 to point to DELAY's
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LARK 0,3 ;Set up AR0 for subtract
- LRLK COEFAR,FDATA ;Load COEF AR with beginning of COEF's
- LRLK DELAR,DELAY ;Load DELAY AR with beginning of DELAY's
- LARP %if B10<%DELAR%else%COEFAR%endif% ;Select Proper AR for initial use
- %section%;*
- ;* SECOND-ORDER FILTER SECTION # %section_n%
- ;*
- %filtin%%if half% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *+ ;AC = Z-1
- ADDS *-,COEFAR ;ADD Least Significant
- %if B1<>% APAC
- MPY *+,%if A1<%DELAR%else%COEFAR%endif% ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- %else% APAC ;AC = Z-1 + (B0 * INPUT)
- %endif% SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT%if B1<>%P%endif% %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>% ;AC = B1 * INPUT%endif%
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+,DELAR ;P = A1 * OUTPUT
- %endif% %if B1<>%A%endif%PAC ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- %if A1shft% APAC
- %endif% SACH *+ ;Save in Z-1
- SACL *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save Least Significant
- %else
-
- %%if B1<>% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *+ ;AC = Z-1
- ADDS *+,COEFAR ;ADD in least significant
- APAC
- MPY *+,DELAR ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LTP %if option M%VSAMPL%else%V%IDT%%endif% ;AC = B1 * INPUT
- ADDH *+ ;AC = Z-2 + (B1 * INPUT)
- ADDS *0-,COEFAR ;ADD in least significant
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+ ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% APAC
- MPY *+,DELAR ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH *+ ;Save in Z-1
- SACL *+,0,%if B2<%DELAR%else%COEFAR%endif% ;Save least significant
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY *+,DELAR ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH *+ ;Save in Z-2
- SACL *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save least significant
- %else
-
-
- % LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *+ ;AC = Z-1
- ADDS *+,DELAR ;ADD in least significant
- APAC ;AC = Z-1 + (B0 * INPUT)
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;Get OUTPUT
- ZALH *+ ;AC = Z-2
- ADDS *0-,COEFAR ;ADD in least significant
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+ ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% APAC
- MPY *+,DELAR ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH *+ ;Save in Z-1
- SACL *+,0,%if B2<%DELAR%else%COEFAR%endif% ;Save least significant
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY *+,DELAR ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH *+ ;Save in Z-2
- SACL *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save least significant
- %endif%%endif%%loop%;*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 6
- %
- TMS32020; Index Memory; Looping Control
- >>>
- %batch_files 0 % .title "%IDT%" ;UNIQUE NAME
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* LOOPING CONTROL
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER to I/O PAGE
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* INITIALIZATION FOR COEFFICIENTS
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- DATA %stages%-1 ;*Number of stages -1 to follow
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %tunable%
- DATA %b_scale% ;BLOCK FLOATING POINT SHIFT
- DATA %B0% ;B0
- DATA %B1% ;B1
- DATA %A1% ;A1
- DATA %A2% ;A2
- DATA %B2% ;B2
- %loop%;*
- ;*
- .sect "X%IDT%"
- ;*
- ;*COEFICIENT DATA STORAGE AREA (including block floating point shifts
- ;* and storage for the number of stages)
- ;*
- FDATA: .space (%points%+2)*16
- ;*
- ;* DELAY STORAGE STORAGE AREA
- ;*
- DELAY: .space (%ndelay%+1)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- RPTK %points%+1 ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay% ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* PAGE.
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- COEFAR .set 1 ;Use AR1 to point to COEF's
- DELAR .set 2 ;Use AR2 to point to DELAY's
- LOOPAR .set 3 ;Use AR3 as loop counter
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LRLK COEFAR,FDATA ;Load COEF AR with beginning of COEF's
- LRLK DELAR,DELAY ;Load DELAY AR with beginning of DELAY's
- LARP COEFAR ;Point to COEF AR
- LAR LOOPAR,*+ ;SET SECTION LOOP COUNT
- ;*
- ;* SECOND-ORDER FILTER SECTION LOOP
- ;*
- LT *+ ;GET SCALE FACTOR
- FLOOP:
- LACT %if option M%VSAMPL%else%V%IDT%%endif% ;GET and SCALE INPUT
- SACH FILTT,4 ;SAVE SCALED INPUT
- LT FILTT ;GET SCALED INPUT
- MPY *+,DELAR ;P = B0 * INPUT
- PAC ;AC = B0 * INPUT
- ADDH *+,COEFAR ;AC = (B0 * INPUT) + Z-1
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;SAVE IN OUTPUT
- MPY *+,DELAR ;P = B1 * OUTPUT
- ZALH *-,COEFAR ;AC = Z-2
- LTA %if option M%VSAMPL%else%V%IDT%%endif% ;AC = (B1 * INPUT) + Z-2, GET CURRENT OUTPUT
- MPY *+,DELAR ;P = A1/2 * OUTPUT
- APAC
- APAC ;AC = (A1 * OUTPUT) + (B1 * INPUT) + Z-2
- SACH *+,0,COEFAR ;SAVE Z-1
- MPY *+ ;P = A2 * OUTPUT
- LTP FILTT ;AC = A2 * OUTPUT, GET SCALED INPUT
- MPY *+ ;P = B2 * INPUT
- LTA *+,DELAR ;AC = (A2 * OUTPUT) + (B2 * INPUT)
- ;* ; & GET NEXT SCALE FACTOR
- SACH *+,0,LOOPAR ;SAVE Z-2
- ;*
- BANZ FLOOP,*-,COEFAR ;REPEAT FOR ALL SECTIONS
- ;*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 6
- %
- TMS32020; Indexed Memory; Looping Control; Increased Precision
- >>>
- %batch_files 0 % .title "%IDT%" ;UNIQUE NAME
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* Increased Precision
- ;* LOOPING CONTROL
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER to I/O PAGE
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* INITIALIZATION FOR COEFFICIENTS
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- DATA %stages%-1 ;*Number of stages -1 to follow
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %tunable%
- DATA %b_scale% ;BLOCK FLOATING POINT SHIFT
- DATA %B0% ;B0
- DATA %B1% ;B1
- DATA %A1% ;A1
- DATA %A2% ;A2
- DATA %B2% ;B2
- %loop%;*
- ;*
- .sect "X%IDT%"
- ;*
- ;*COEFICIENT DATA STORAGE AREA (including block floating point shifts
- ;* and storage for the number of stages)
- ;*
- FDATA: .space (%points%+2)*16
- ;*
- ;* DELAY STORAGE STORAGE AREA
- ;*
- DELAY: .space (%ndelay%+%ndelay%+2)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- RPTK %points%+1 ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay%+%ndelay%+1 ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* PAGE.
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- COEFAR .set 1 ;Use AR1 to point to COEF's
- DELAR .set 2 ;Use AR2 to point to DELAY's
- LOOPAR .set 3 ;Use AR3 as loop counter
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LARK 0,3 ;SET UP AR0
- LRLK COEFAR,FDATA ;Load COEF AR with beginning of COEF's
- LRLK DELAR,DELAY ;Load DELAY AR with beginning of DELAY's
- LARP COEFAR ;Point to COEF AR
- LAR LOOPAR,*+ ;SET SECTION LOOP COUNT
- ;*
- ;* SECOND-ORDER FILTER SECTION LOOP
- ;*
- LT *+ ;GET SCALE FACTOR
- FLOOP:
- LACT %if option M%VSAMPL%else%V%IDT%%endif% ;GET and SCALE INPUT
- SACH FILTT,4 ;SAVE SCALED INPUT
- LT FILTT ;GET SCALED INPUT
- MPY *+,DELAR ;P = B0 * INPUT
- PAC ;AC = B0 * INPUT
- ADDH *+ ;AC = (B0 * INPUT) + Z-1
- ADDS *+,COEFAR ;ADD LEAST SIG. PART OF Z-1
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;SAVE IN OUTPUT
- MPY *+,DELAR ;P = B1 * OUTPUT
- ZALH *+ ;AC = Z-2
- ADDS *0-,COEFAR ;ADD LEAST SIG. PART OF Z-2
- LTA %if option M%VSAMPL%else%V%IDT%%endif% ;AC = (B1 * INPUT) + Z-2, GET CURRENT OUTPUT
- MPY *+,DELAR ;P = A1/2 * OUTPUT
- APAC
- APAC ;AC = (A1 * OUTPUT) + (B1 * INPUT) + Z-2
- SACH *+ ;SAVE Z-1
- SACL *+,0,COEFAR ;SAVE LEAST SIGNIFICANT PART
- MPY *+ ;P = A2 * OUTPUT
- LTP FILTT ;AC = A2 * OUTPUT, GET SCALED INPUT
- MPY *+ ;P = B2 * INPUT
- LTA *+,DELAR ;AC = (A2 * OUTPUT) + (B2 * INPUT)
- ;* ; & GET NEXT SCALE FACTOR
- SACH *+ ;SAVE Z-2
- SACL *+,0,LOOPAR ;SAVE LEAST SIGNIFICANT PART
- ;*
- BANZ FLOOP,*-,COEFAR ;REPEAT FOR ALL SECTIONS
- ;*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 2
- 5
- %
- TMS32010; Direct Paged Memory
- >>>
- %batch_files 2 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32010 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* Direct Page
- ;* KAISER WINDOW
- ;* %taps%-TAP FIR FILTER
- ;*
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 6*16
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- ROVM ;2S COMPLEMENT
- LDPK IOPAGE ;SET PAGE POINTER
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to perform filter operations
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percentage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate either a busy state or
- ;* that the filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 1 ;TEMPORARY FILTER DATA
- VSAMPL .set 0 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl V%IDT%,FILTT
- %endif%;*
- COEF:
- ;*
- ;* FIR COEFFICIENTS
- ;*
- %do%%if coef<%%else% .word %coef% ;%coef_name%
- %endif%%loop%;*
- ;*
- .sect "D%IDT%"
- ;*
- ;* DELAY MEMORY STORAGE
- ;*
- DELAY:
- %do%%Z_nameI%: .space 1*16
- %loop%;*
- ;* COEFFICIENT DATA STORAGE
- ;*
- FDATA:
- %do%%if coef<%%else%%coef_name%: .space 1*16
- %endif%%loop%;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%: LACK 1 ;GET A 1
- LDPK 0 ;SET PAGE POINTER
- SACL FILTT ;TEMPORARY SAVE
- LT FILTT ;LOAD 1 IN T
- MPYK COEF
- PAC ;AC HAS ADDRESS OF COEF DATA
- MPYK 1 ;1 INTO P
- LARK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% LARK 1,%points% ;COUNT FOR NUMBER OF POINTS
- ILP: LARP 0 ;RESET AR TO 0
- TBLR *+,1 ;TRANSFER DATA VALUE
- APAC ;INCREMENT POINTER
- BANZ ILP ;LOOP
- %endif% LARK 1,%ndelay% ;NUMBER OF DELAY POINTS
- ZAC ;CLEAR ACCUMULATOR
- LARK 0,DELAY ;POINT TO DELAY MEMORY
- ILPA: LARP 0 ;RESET AR TO 0
- SACL *+,0,1 ;CLEAR DATA VALUE
- BANZ ILPA ;LOOP
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- %if option M%FILTER%else%F%IDT%%endif%:
- %pshift%%filtin% ZAC ;INIT. ACC
- %do%%if coef<>% LT%if first%%else%D%endif% %Z_name%
- %if coef<% MPYK %coef% ;%coef_name%
- %else% MPY %coef_name%
- %endif%%else%%if firstd%%else% DMOV %Z_name%
- %endif%%endif%%loop% APAC ;FORM RESULT
- SACH %if option M%VSAMPL%else%V%IDT%%endif%%output_shift% ;SAVE OUTPUT
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 2
- 6
- %
- TMS32020/c25; Indexed Memory; MACD realization
- >>>
- %batch_files 0 D% .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* INTERNAL DELAY MEMORY
- ;* COEF. in PROGRAM MEMORY
- ;*
- ;* NOTE: This realization uses internal memory
- ;* BANK 0 for program memory. This allows
- ;* for very fast execution of the filter
- ;* by storing the coefficients in BANK 0.
- ;* However, BANK 0 can not be accessed
- ;* as data in this mode. Also, the delay
- ;* memory must reside in BANK 1 or BANK 2
- ;*
- ;* KAISER WINDOW
- ;* %taps%-TAP FIR FILTER
- ;*
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- ROVM ;2S COMPLEMENT
- SSXM ;SIGN EXTEND MODE
- LDPK IOPAGE ;SET PAGE POINTER
- SPM 1 ;P output is shifted left 1 bit
- CALL INIT ;INITIALIZE
- ;*
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT EQU 6 ;D/A OUTPUT
- DIN EQU 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to perform filter operations
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percentage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate either a busy state or
- ;* that the filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl V%IDT%,FILTT
- %endif%;*
- COEF:
- ;*
- ;* FIR COEFFICIENTS
- ;*
- %do%%ndata+% DATA %coef% ;%coef_name%
- %loop%;*
- ;*
- .sect "D%IDT%"
- ;*
- ;* DELAY STORAGE
- ;*
- Z000: .space 1*16
- .space (%ndelay%-1)*16
- ZLAST: .space 1*16
- .space 1*16 ;Extra storage: MACD destroys this
- ;* Location.
- ;*
- ;* COEFFICIENT DATA STORAGE
- ;*
- .sect "C%IDT%"
- ;*
- FDATA: .space (%points%+1)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0
- CNFD
- LRLK 0,FDATA ;POINTER TO COEF. MEMORY
- RPTK %points%
- BLKP COEF,*+ ;MOVE COEF.
- CNFP
- LRLK 0,Z000 ;POINTER TO DELAY MEMORY
- ZAC ;CLEAR ACCUMULATOR
- RPTK %ndelay%
- SACL *+ ;CLEAR DELAY MEMORY
- RET
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* BANK 0 is set to PROGRAM MEMORY.
- ;* COEFFICIENTS are located at 'FDATA'.
- ;* DELAY elements are located at 'DELAY'.
- ;* NOTE: COEF's must be in BANK 0 and DELAY's
- ;* must be in BANK 1 or BANK 2.
- ;* 'DELAR' AR is destroyed by filter routine.
- ;* P output shift is set to 1.
- ;* SIGN EXTEND mode is ON.
- ;* Two's Complement Arithmetic.
- ;*
- ;*************************************************
- DELAR .set 1 ;DELAY AR REGISTER
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LARP DELAR ;POINT TO THE DELAY INDEX REGISTER
- LRLK DELAR,Z000 ;INDEX POINTS TO Z-0 (INPUT)
- %filtinI%
- MPYK 0 ;P = 0
- ZAC ;AC = 0
- LRLK DELAR,ZLAST ;INDEX POINTS TO Z-N
- RPTK %points%
- MACD FDATA+0FD00h,*- ;MULTIPLY, ACCUM. and DELAY
- APAC ;FORM RESULT
- SACH %if option M%VSAMPL%else%V%IDT%%endif%%output_shift% ;SAVE OUTPUT
- RET ;RETURN
- ;*
- .end
- %end%
- >>>>
- >>>
- 2
- 6
- %
- TMS32020/c25; Internal Direct Paged Memory
- >>>
- %batch_files 2 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* Direct Page
- ;* KAISER WINDOW
- ;* %taps%-TAP FIR FILTER
- ;*
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- ROVM ;2S COMPLEMENT
- SSXM ;SIGN EXTEND MODE
- SPM 1 ;P output is shifted left 1 bit
- LDPK IOPAGE
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to perform filter operations
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percentage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate either a busy state or
- ;* that the filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 1 ;TEMPORARY FILTER DATA
- VSAMPL .set 0 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 4
- %else% .globl V%IDT%,FILTT
- %endif%;*
- COEF:
- ;*
- ;* FIR COEFFICIENTS
- ;*
- %do%%if coef<%%else% .word %coef% ;%coef_name%
- %endif%%loop%;*
- ;*
- .sect "D%IDT%"
- ;*
- ;* DELAY MEMORY STORAGE
- ;*
- DELAY:
- %do%%Z_nameI%: .space 1*16
- %loop%;*
- ;* COEFFICIENT DATA STORAGE
- ;*
- FDATA:
- %do%%if coef<%%else%%coef_name%: .space 1*16
- %endif%%loop%;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0
- %if data% LRLK 0,FDATA ;POINTER TO COEF. MEMORY
- %copy_coef%%endif% LRLK 0,DELAY ;POINTER TO DELAY MEMORY
- ZAC ;CLEAR ACCUMULATOR
- %zero_delay% RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- %if option M%FILTER%else%F%IDT%%endif%:
- %filtin% ZAC ;INIT. ACC
- %do%%if coef<>% LT%if first%%else%D%endif% %Z_name%
- %if coef<% MPYK %coef% ;%coef_name%
- %else% MPY %coef_name%
- %endif%%else%%if firstd%%else% DMOV %Z_name%
- %endif%%endif%%loop% APAC ;FORM RESULT
- SACH %if option M%VSAMPL%else%V%IDT%%endif%%output_shift% ;SAVE OUTPUT
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 2
- 6
- %
- TMS32020/c25; Indexed Memory; Internal Delay Memory
- >>>
- %batch_files 0 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* EXTERNAL COEFFICIENTS
- ;* INTERNAL DELAYS
- ;*
- ;* KAISER WINDOW
- ;* %taps%-TAP FIR FILTER
- ;*
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- ROVM ;2S COMPLEMENT
- SSXM ;SIGN EXTEND MODE
- LDPK IOPAGE ;SET PAGE POINTER
- SPM 1 ;P output is shifted left 1 bit
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to perform filter operations
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percentage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate either a busy state or
- ;* that the filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl V%IDT%,FILTT
- %endif%;*
- COEF:
- ;*
- ;* FIR COEFFICIENTS
- ;*
- %do%%if coef<%%else% .word %coef% ;%coef_name%
- %endif%%loop%;*
- ;*
- .sect "D%IDT%"
- ;*
- ;* DELAY STORAGE
- ;*
- .globl Z%IDT%,L%IDT%
- Z%IDT%: .space 1*16
- .space (%ndelay%-1)*16
- L%IDT%: .space 1*16
- ;*
- ;*
- .sect "X%IDT%"
- ;*
- ;* COEFFICIENT DATA STORAGE
- ;*
- FDATA: .space (%points%+1)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0
- %if data% LRLK 0,FDATA ;POINTER TO COEF. MEMORY
- %copy_coef%%endif% LRLK 0,Z%IDT% ;POINTER TO DELAY MEMORY
- ZAC ;CLEAR ACCUMULATOR
- %zero_delay% RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* PAGE POINTER must be set to 'DPAGE'.
- ;* The AR pointer register is destroyed.
- ;* The address registers 'COEFAR' and 'DELAR'
- ;* are destroyed by filter routine.
- ;* P output shift is set to 1.
- ;* SIGN EXTEND mode is ON.
- ;* Two's Complement Arithmetic.
- ;* COEF. elements are located in any in
- ;* data memory.
- ;* DELAY elements must be in internal memory
- ;* and must not cross a page boundary.
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- DELAR .set 2
- COEFAR .set 1
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LARP DELAR ;POINT TO CORRECT AR
- LRLK COEFAR,FDATA ;AR = START OF COEF.
- LRLK DELAR,Z%IDT%
- %filtinI% LRLK DELAR,L%IDT%
- ZAC ;INIT AC.
- %do%%if coef<>% LT%if first%%else%D%endif% *-%if coef<% %else%,COEFAR%endif% ;%Z_name%
- %if coef<% MPYK %coef% ;%coef_name%
- %else% MPY *+,DELAR ;%coef_name%
- %endif%%else%%if firstd% MAR *-
- %else% DMOV *- ;%Z_name%
- %endif%%endif%%loop% APAC ;FORM RESULT
- SACH %if option M%VSAMPL%else%V%IDT%%endif%%output_shift% ;SAVE OUTPUT
- ;*
- RET ;RETURN
- ;*
- .end
- %end%
- >>>>
- >>>
- 2
- 6
- %
- TMS32020/c25; Indexed Memory; Internal or External Memory
- >>>
- %batch_files 0 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* EXTERNAL MEMORY MODEL
- ;*
- ;* KAISER WINDOW
- ;* %taps%-TAP FIR FILTER
- ;*
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- ROVM ;2S COMPLEMENT
- SSXM ;SIGN EXTEND MODE
- SPM 1 ;P output is shifted left 1 bit
- LDPK IOPAGE
- CALL INIT ;INITIALIZE
- ;*
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to perform filter operations
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percentage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate either a busy state or
- ;* that the filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl V%IDT%,FILTT
- %endif%;*
- COEF:
- ;*
- ;* FIR INITIALIZATION COEFFICIENTS
- ;*
- %do%%if coef<%%else% .word %coef% ;%coef_name%
- %endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;*
- ;* COEFFICIENT DATA STORAGE
- ;*
- FDATA: .space %points%*16
- LCOEF: .space 1*16
- ;*
- ;* DELAY STORAGE
- ;*
- ZLAST: .space 1*16
- .space (%ndelay%-1)*16
- Z000: .space 1*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0
- %if data% LRLK 0,FDATA ;POINTER TO COEF. MEMORY
- %copy_coef%%endif% LRLK 0,ZLAST ;POINTER TO DELAY MEMORY
- ZAC ;CLEAR ACCUMULATOR
- %zero_delay% RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* PAGE POINTER must point to page with
- ;* %if option M%VSAMPL%else%V%IDT%%endif%.
- ;* The address registers 'COEFAR' and 'DELAR'
- ;* are destroyed by filter routine.
- ;* P output shift is set to 1.
- ;* SIGN EXTEND mode is ON.
- ;* Two's Complement Arithmetic.
- ;* COEF. & DELAY elements are located any in
- ;* data memory.
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- COEFAR .set 1
- DELAR .set 2
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LRLK COEFAR,LCOEF ;INIT INDEX REGISTER POINTERS
- LRLK DELAR,Z000
- LARP DELAR ;POINTER TO CORRECT INDEX REGISTER
- %filtinI%%do% LT%if first%%elseif second%P%else%A%endif% *-%if coef<%%else%,COEFAR%endif%
- %if coef<% MPYK %coefI% ;%coef_nameI%
- %else% MPY *-,DELAR ;%coef_nameI%
- %endif%%loop% APAC ;FORM RESULT
- SACH %if option M%VSAMPL%else%V%IDT%%endif%%output_shift% ;SAVE OUTPUT
- ;*
- LRLK DELAR,ZLAST
- %move_delay%;*
- RET ;RETURN
- ;*
- .end
- %end%
- >>>>
- >>>
- 3
- 5
- %
- TMS32010; Direct Paged Memory
- >>>
- %batch_files 2 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32010 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* Direct Page
- ;* PARK-MCCLELLAN
- ;* %taps%-TAP FIR FILTER
- ;*
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 6*16
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- ROVM ;2S COMPLEMENT
- LDPK IOPAGE ;SET PAGE POINTER
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to perform filter operations
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percentage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate either a busy state or
- ;* that the filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 1 ;TEMPORARY FILTER DATA
- VSAMPL .set 0 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl V%IDT%,FILTT
- %endif%;*
- COEF:
- ;*
- ;* FIR COEFFICIENTS
- ;*
- %do%%if coef<%%else% .word %coef% ;%coef_name%
- %endif%%loop%;*
- ;*
- .sect "D%IDT%"
- ;*
- ;* DELAY MEMORY STORAGE
- ;*
- DELAY:
- %do%%Z_nameI%: .space 1*16
- %loop%;*
- ;* COEFFICIENT DATA STORAGE
- ;*
- FDATA:
- %do%%if coef<%%else%%coef_name%: .space 1*16
- %endif%%loop%;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%: LACK 1 ;GET A 1
- LDPK 0 ;SET PAGE POINTER
- SACL FILTT ;TEMPORARY SAVE
- LT FILTT ;LOAD 1 IN T
- MPYK COEF
- PAC ;AC HAS ADDRESS OF COEF DATA
- MPYK 1 ;1 INTO P
- LARK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% LARK 1,%points% ;COUNT FOR NUMBER OF POINTS
- ILP: LARP 0 ;RESET AR TO 0
- TBLR *+,1 ;TRANSFER DATA VALUE
- APAC ;INCREMENT POINTER
- BANZ ILP ;LOOP
- %endif% LARK 1,%ndelay% ;NUMBER OF DELAY POINTS
- ZAC ;CLEAR ACCUMULATOR
- LARK 0,DELAY ;POINT TO DELAY MEMORY
- ILPA: LARP 0 ;RESET AR TO 0
- SACL *+,0,1 ;CLEAR DATA VALUE
- BANZ ILPA ;LOOP
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- %if option M%FILTER%else%F%IDT%%endif%:
- %pshift%%filtin% ZAC ;INIT. ACC
- %do%%if coef<>% LT%if first%%else%D%endif% %Z_name%
- %if coef<% MPYK %coef% ;%coef_name%
- %else% MPY %coef_name%
- %endif%%else%%if firstd%%else% DMOV %Z_name%
- %endif%%endif%%loop% APAC ;FORM RESULT
- SACH %if option M%VSAMPL%else%V%IDT%%endif%%output_shift% ;SAVE OUTPUT
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 3
- 6
- %
- TMS32020/c25; Indexed Memory; MACD realization
- >>>
- %batch_files 0 D% .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* INTERNAL DELAY MEMORY
- ;* COEF. in PROGRAM MEMORY
- ;*
- ;* NOTE: This realization uses internal memory
- ;* BANK 0 for program memory. This allows
- ;* for very fast execution of the filter
- ;* by storing the coefficients in BANK 0.
- ;* However, BANK 0 can not be accessed
- ;* as data in this mode. Also, the delay
- ;* memory must reside in BANK 1 or BANK 2
- ;*
- ;* PARK-MCCLELLAN
- ;* %taps%-TAP FIR FILTER
- ;*
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- ROVM ;2S COMPLEMENT
- SSXM ;SIGN EXTEND MODE
- LDPK IOPAGE ;SET PAGE POINTER
- SPM 1 ;P output is shifted left 1 bit
- CALL INIT ;INITIALIZE
- ;*
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT EQU 6 ;D/A OUTPUT
- DIN EQU 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to perform filter operations
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percentage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate either a busy state or
- ;* that the filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl V%IDT%,FILTT
- %endif%;*
- COEF:
- ;*
- ;* FIR COEFFICIENTS
- ;*
- %do%%ndata+% DATA %coef% ;%coef_name%
- %loop%;*
- ;*
- .sect "D%IDT%"
- ;*
- ;* DELAY STORAGE
- ;*
- Z000: .space 1*16
- .space (%ndelay%-1)*16
- ZLAST: .space 1*16
- .space 1*16 ;Extra storage: MACD destroys this
- ;* Location.
- ;*
- ;* COEFFICIENT DATA STORAGE
- ;*
- .sect "C%IDT%"
- ;*
- FDATA: .space (%points%+1)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0
- CNFD
- LRLK 0,FDATA ;POINTER TO COEF. MEMORY
- RPTK %points%
- BLKP COEF,*+ ;MOVE COEF.
- CNFP
- LRLK 0,Z000 ;POINTER TO DELAY MEMORY
- ZAC ;CLEAR ACCUMULATOR
- RPTK %ndelay%
- SACL *+ ;CLEAR DELAY MEMORY
- RET
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* BANK 0 is set to PROGRAM MEMORY.
- ;* COEFFICIENTS are located at 'FDATA'.
- ;* DELAY elements are located at 'DELAY'.
- ;* NOTE: COEF's must be in BANK 0 and DELAY's
- ;* must be in BANK 1 or BANK 2.
- ;* 'DELAR' AR is destroyed by filter routine.
- ;* P output shift is set to 1.
- ;* SIGN EXTEND mode is ON.
- ;* Two's Complement Arithmetic.
- ;*
- ;*************************************************
- DELAR .set 1 ;DELAY AR REGISTER
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LARP DELAR ;POINT TO THE DELAY INDEX REGISTER
- LRLK DELAR,Z000 ;INDEX POINTS TO Z-0 (INPUT)
- %filtinI%
- MPYK 0 ;P = 0
- ZAC ;AC = 0
- LRLK DELAR,ZLAST ;INDEX POINTS TO Z-N
- RPTK %points%
- MACD FDATA+0FD00h,*- ;MULTIPLY, ACCUM. and DELAY
- APAC ;FORM RESULT
- SACH %if option M%VSAMPL%else%V%IDT%%endif%%output_shift% ;SAVE OUTPUT
- RET ;RETURN
- ;*
- .end
- %end%
- >>>>
- >>>
- 3
- 6
- %
- TMS32020/c25; Internal Direct Paged Memory
- >>>
- %batch_files 2 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* Direct Page
- ;* PARK-MCCLELLAN
- ;* %taps%-TAP FIR FILTER
- ;*
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- ROVM ;2S COMPLEMENT
- SSXM ;SIGN EXTEND MODE
- SPM 1 ;P output is shifted left 1 bit
- LDPK IOPAGE
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to perform filter operations
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percentage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate either a busy state or
- ;* that the filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 1 ;TEMPORARY FILTER DATA
- VSAMPL .set 0 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 4
- %else% .globl V%IDT%,FILTT
- %endif%;*
- COEF:
- ;*
- ;* FIR COEFFICIENTS
- ;*
- %do%%if coef<%%else% .word %coef% ;%coef_name%
- %endif%%loop%;*
- ;*
- .sect "D%IDT%"
- ;*
- ;* DELAY MEMORY STORAGE
- ;*
- DELAY:
- %do%%Z_nameI%: .space 1*16
- %loop%;*
- ;* COEFFICIENT DATA STORAGE
- ;*
- FDATA:
- %do%%if coef<%%else%%coef_name%: .space 1*16
- %endif%%loop%;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0
- %if data% LRLK 0,FDATA ;POINTER TO COEF. MEMORY
- %copy_coef%%endif% LRLK 0,DELAY ;POINTER TO DELAY MEMORY
- ZAC ;CLEAR ACCUMULATOR
- %zero_delay% RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- %if option M%FILTER%else%F%IDT%%endif%:
- %filtin% ZAC ;INIT. ACC
- %do%%if coef<>% LT%if first%%else%D%endif% %Z_name%
- %if coef<% MPYK %coef% ;%coef_name%
- %else% MPY %coef_name%
- %endif%%else%%if firstd%%else% DMOV %Z_name%
- %endif%%endif%%loop% APAC ;FORM RESULT
- SACH %if option M%VSAMPL%else%V%IDT%%endif%%output_shift% ;SAVE OUTPUT
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 3
- 6
- %
- TMS32020/c25; Indexed Memory; Internal Delay Memory
- >>>
- %batch_files 0 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* EXTERNAL COEFFICIENTS
- ;* INTERNAL DELAYS
- ;*
- ;* PARK-MCCLELLAN
- ;* %taps%-TAP FIR FILTER
- ;*
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- ROVM ;2S COMPLEMENT
- SSXM ;SIGN EXTEND MODE
- LDPK IOPAGE ;SET PAGE POINTER
- SPM 1 ;P output is shifted left 1 bit
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to perform filter operations
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percentage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate either a busy state or
- ;* that the filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl V%IDT%,FILTT
- %endif%;*
- COEF:
- ;*
- ;* FIR COEFFICIENTS
- ;*
- %do%%if coef<%%else% .word %coef% ;%coef_name%
- %endif%%loop%;*
- ;*
- .sect "D%IDT%"
- ;*
- ;* DELAY STORAGE
- ;*
- .globl Z%IDT%,L%IDT%
- Z%IDT%: .space 1*16
- .space (%ndelay%-1)*16
- L%IDT%: .space 1*16
- ;*
- ;*
- .sect "X%IDT%"
- ;*
- ;* COEFFICIENT DATA STORAGE
- ;*
- FDATA: .space (%points%+1)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0
- %if data% LRLK 0,FDATA ;POINTER TO COEF. MEMORY
- %copy_coef%%endif% LRLK 0,Z%IDT% ;POINTER TO DELAY MEMORY
- ZAC ;CLEAR ACCUMULATOR
- %zero_delay% RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* PAGE POINTER must be set to 'DPAGE'.
- ;* The AR pointer register is destroyed.
- ;* The address registers 'COEFAR' and 'DELAR'
- ;* are destroyed by filter routine.
- ;* P output shift is set to 1.
- ;* SIGN EXTEND mode is ON.
- ;* Two's Complement Arithmetic.
- ;* COEF. elements are located in any in
- ;* data memory.
- ;* DELAY elements must be in internal memory
- ;* and must not cross a page boundary.
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- DELAR .set 2
- COEFAR .set 1
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LARP DELAR ;POINT TO CORRECT AR
- LRLK COEFAR,FDATA ;AR = START OF COEF.
- LRLK DELAR,Z%IDT%
- %filtinI% LRLK DELAR,L%IDT%
- ZAC ;INIT AC.
- %do%%if coef<>% LT%if first%%else%D%endif% *-%if coef<% %else%,COEFAR%endif% ;%Z_name%
- %if coef<% MPYK %coef% ;%coef_name%
- %else% MPY *+,DELAR ;%coef_name%
- %endif%%else%%if firstd% MAR *-
- %else% DMOV *- ;%Z_name%
- %endif%%endif%%loop% APAC ;FORM RESULT
- SACH %if option M%VSAMPL%else%V%IDT%%endif%%output_shift% ;SAVE OUTPUT
- ;*
- RET ;RETURN
- ;*
- .end
- %end%
- >>>>
- >>>
- 3
- 6
- %
- TMS32020/c25; Indexed Memory; Internal or External Memory
- >>>
- %batch_files 0 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS32020 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* EXTERNAL MEMORY MODEL
- ;*
- ;* PARK-MCCLELLAN
- ;* %taps%-TAP FIR FILTER
- ;*
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- ROVM ;2S COMPLEMENT
- SSXM ;SIGN EXTEND MODE
- SPM 1 ;P output is shifted left 1 bit
- LDPK IOPAGE
- CALL INIT ;INITIALIZE
- ;*
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to perform filter operations
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percentage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate either a busy state or
- ;* that the filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl V%IDT%,FILTT
- %endif%;*
- COEF:
- ;*
- ;* FIR INITIALIZATION COEFFICIENTS
- ;*
- %do%%if coef<%%else% .word %coef% ;%coef_name%
- %endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;*
- ;* COEFFICIENT DATA STORAGE
- ;*
- FDATA: .space %points%*16
- LCOEF: .space 1*16
- ;*
- ;* DELAY STORAGE
- ;*
- ZLAST: .space 1*16
- .space (%ndelay%-1)*16
- Z000: .space 1*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0
- %if data% LRLK 0,FDATA ;POINTER TO COEF. MEMORY
- %copy_coef%%endif% LRLK 0,ZLAST ;POINTER TO DELAY MEMORY
- ZAC ;CLEAR ACCUMULATOR
- %zero_delay% RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* PAGE POINTER must point to page with
- ;* %if option M%VSAMPL%else%V%IDT%%endif%.
- ;* The address registers 'COEFAR' and 'DELAR'
- ;* are destroyed by filter routine.
- ;* P output shift is set to 1.
- ;* SIGN EXTEND mode is ON.
- ;* Two's Complement Arithmetic.
- ;* COEF. & DELAY elements are located any in
- ;* data memory.
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- COEFAR .set 1
- DELAR .set 2
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LRLK COEFAR,LCOEF ;INIT INDEX REGISTER POINTERS
- LRLK DELAR,Z000
- LARP DELAR ;POINTER TO CORRECT INDEX REGISTER
- %filtinI%%do% LT%if first%%elseif second%P%else%A%endif% *-%if coef<%%else%,COEFAR%endif%
- %if coef<% MPYK %coefI% ;%coef_nameI%
- %else% MPY *-,DELAR ;%coef_nameI%
- %endif%%loop% APAC ;FORM RESULT
- SACH %if option M%VSAMPL%else%V%IDT%%endif%%output_shift% ;SAVE OUTPUT
- ;*
- LRLK DELAR,ZLAST
- %move_delay%;*
- RET ;RETURN
- ;*
- .end
- %end%
- >>>>
- >>>
- 1
- 7
- %
- TMS320c25; Direct Paged Memory
- >>>
- %batch_files 2 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS320c25 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 0 ;TEMPORARY FILTER DATA
- VSAMPL .set 1 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 6
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %if B0<%%else% .word %B0% ;B0
- %endif%%if B1<>% .word %B1% ;B1
- %endif%%if A1<%%else% .word %A1% ;A1
- %endif%%if half%%else% .word %A2% ;A2
- %if B2<%%else% .word %B2% ;B2
- %endif%%endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;* DELAY STORAGE DATA STORAGE AREA
- ;*
- DELAY:
- %section%Z%section_n%1: .space 1*16
- %if half%%else%Z%section_n%2: .space 1*16
- %endif%%loop%;*
- ;*
- ;* COEFFICIENT DATA STORAGE AREA
- ;*
- FDATA:
- %section%;*
- %if B0<%%else%B%section_n%0: .space 1*16 ;B0
- %endif%%if B1<>%B%section_n%1: .space 1*16 ;B1
- %endif%%if A1<%%else%A%section_n%1: .space 1*16 ;A1
- %endif%%if half%%else%A%section_n%2: .space 1*16 ;A2
- %if B2<%%else%B%section_n%2: .space 1*16 ;B2
- %endif%%endif%%loop%;*
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% RPTK %points% ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- %endif% ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay% ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- %section%;*
- ;* SECOND-ORDER FILTER SECTION # %section_n%
- ;*
- %filtin%%if half% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- %if B1<>% MPYA B%section_n%1 ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- %else% APAC ;AC = Z-1 + (B0 * INPUT)
- %endif% SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT%if B1<>%P%endif% %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>% ;AC = B1 * INPUT%endif%
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif% %if B1<>%A%endif%PAC ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- %if A1shft% APAC
- %endif% SACH Z%section_n%1 ;Save in Z-1
- %else
-
- %%if B1<>% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- MPYA B%section_n%1 ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LTP %if option M%VSAMPL%else%V%IDT%%endif% ;AC = B1 * INPUT
- ADDH Z%section_n%2 ;AC = Z-2 + (B1 * INPUT)
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% MPYA A%section_n%2 ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH Z%section_n%1 ;Save in Z-1
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY B%section_n%2 ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH Z%section_n%2 ;Save in Z-2
- %else
-
-
- % LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- APAC ;AC = Z-1 + (B0 * INPUT)
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;Get OUTPUT
- ZALH Z%section_n%2 ;AC = Z-2
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% MPYA A%section_n%2 ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH Z%section_n%1 ;Save in Z-1
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY B%section_n%2 ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH Z%section_n%2 ;Save in Z-2
- %endif%%endif%%loop%*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 7
- %
- TMS320c25; Direct Paged Memory; Increased Precision
- >>>
- %batch_files 2 % .title "%IDT%" ;Unique Identifier
- %if option M%%else% .globl F%IDT% ;*Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS320c25 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* INCREASED PRECISION IMPLEMENTATION
- ;*
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT EQU 6 ;D/A OUTPUT
- DIN EQU 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 0 ;TEMPORARY FILTER DATA
- VSAMPL .set 1 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 6
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %if B0<%%else% .word %B0% ;B0
- %endif%%if B1<>% .word %B1% ;B1
- %endif%%if A1<%%else% .word %A1% ;A1
- %endif%%if half%%else% .word %A2% ;A2
- %if B2<%%else% .word %B2% ;B2
- %endif%%endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;* DELAY STORAGE DATA STORAGE AREA
- ;*
- DELAY:
- %section%Z%section_n%1: .space 1*16
- L%section_n%1: .space 1*16
- %if half%%else%Z%section_n%2: .space 1*16
- L%section_n%2: .space 1*16
- %endif%%loop%;*
- ;*
- ;* COEFFICIENT DATA STORAGE AREA
- ;*
- FDATA:
- %section%;*
- %if B0<%%else%B%section_n%0: .space 1*16 ;B0
- %endif%%if B1<>%B%section_n%1: .space 1*16 ;B1
- %endif%%if A1<%%else%A%section_n%1: .space 1*16 ;A1
- %endif%%if half%%else%A%section_n%2: .space 1*16 ;A2
- %if B2<%%else%B%section_n%2: .space 1*16 ;B2
- %endif%%endif%%loop%;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% RPTK %points% ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- %endif% ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay%+%ndelay%+1 ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- %section%;*
- ;* SECOND-ORDER FILTER SECTION # %section_n%
- ;*
- %filtin%%if half% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- ADDS L%section_n%1 ;ADD in least significant
- %if B1<>% MPYA B%section_n%1 ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- %else% APAC ;AC = Z-1 + (B0 * INPUT)
- %endif% SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT%if B1<>%P%endif% %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>% ;AC = B1 * INPUT%endif%
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif% %if B1<>%A%endif%PAC ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- %if A1shft% APAC
- %endif% SACH Z%section_n%1 ;Save in Z-1
- SACL L%section_n%1 ;Save least significant
- %else
-
- %%if B1<>% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- ADDS L%section_n%1 ;ADD in least significant
- MPYA B%section_n%1 ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LTP %if option M%VSAMPL%else%V%IDT%%endif% ;AC = B1 * INPUT
- ADDH Z%section_n%2 ;AC = Z-2 + (B1 * INPUT)
- ADDS L%section_n%2 ;ADD in least significant
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% MPYA A%section_n%2 ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH Z%section_n%1 ;Save in Z-1
- SACL L%section_n%1 ;Save least significant
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY B%section_n%2 ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH Z%section_n%2 ;Save in Z-2
- SACL L%section_n%2 ;Save least significant
- %else
-
-
- % LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY B%section_n%0 ;P = B0 * INPUT
- %endif% ZALH Z%section_n%1 ;AC = Z-1
- ADDS L%section_n%1 ;ADD in least significant
- APAC ;AC = Z-1 + (B0 * INPUT)
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;Get OUTPUT
- ZALH Z%section_n%2 ;AC = Z-2
- ADDS L%section_n%2 ;ADD in least significant
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY A%section_n%1 ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% MPYA A%section_n%2 ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH Z%section_n%1 ;Save in Z-1
- SACL L%section_n%1 ;Save least significant
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY B%section_n%2 ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH Z%section_n%2 ;Save in Z-2
- SACL L%section_n%2 ;Save least significant
- %endif%%endif%%loop%*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 7
- %
- TMS320c25; Indexed Memory
- >>>
- %batch_files 0 % .title "%IDT%" ;UNIQUE NAME
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;**************************************************
- ;* ASPI TMS320c25 DIGITAL FILTER REALIZATION *
- ;**************************************************
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %if B0<%%else% .word %B0% ;B0
- %endif%%if B1<>% .word %B1% ;B1
- %endif%%if A1<%%else% .word %A1% ;A1
- %endif%%if half%%else% .word %A2% ;A2
- %if B2<%%else% .word %B2% ;B2
- %endif%%endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;*
- ;* COEFFICIENT DATA STORAGE AREA
- ;*
- FDATA: .space (%points%+1)*16
- ;*
- ;* DELAY STORAGE DATA STORAGE AREA
- ;*
- DELAY: .space (%ndelay%+1)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% RPTK %points% ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- %endif% ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay% ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- COEFAR .set 1 ;Use AR1 to point to COEF's
- DELAR .set 2 ;Use AR2 to point to DELAY's
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LRLK COEFAR,FDATA ;Load COEF AR with beginning of COEF's
- LRLK DELAR,DELAY ;Load DELAY AR with beginning of DELAY's
- LARP %if B10<%DELAR%else%COEFAR%endif% ;Select Proper AR for initial use
- %section%;*
- ;* SECOND-ORDER FILTER SECTION # %section_n%
- ;*
- %filtin%%if half% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *,COEFAR ;AC = Z-1
- %if B1<>% MPYA *+,%if A1<%DELAR%else%COEFAR%endif% ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- %else% APAC ;AC = Z-1 + (B0 * INPUT)
- %endif% SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT%if B1<>%P%endif% %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>% ;AC = B1 * INPUT%endif%
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+,DELAR ;P = A1 * OUTPUT
- %endif% %if B1<>%A%endif%PAC ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- %if A1shft% APAC
- %endif% SACH *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save in Z-1
- %else
-
- %%if B1<>% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *+,COEFAR ;AC = Z-1
- MPYA *+,DELAR ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LTP %if option M%VSAMPL%else%V%IDT%%endif% ;AC = B1 * INPUT
- ADDH *-,COEFAR ;AC = Z-2 + (B1 * INPUT)
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+ ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% MPYA *+,DELAR ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH *+,0,%if B2<%DELAR%else%COEFAR%endif% ;Save in Z-1
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY *+,DELAR ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save in Z-2
- %else
-
-
- % LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *+,DELAR ;AC = Z-1
- APAC ;AC = Z-1 + (B0 * INPUT)
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;Get OUTPUT
- ZALH *-,COEFAR ;AC = Z-2
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+ ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% MPYA *+,DELAR ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH *+,0,%if B2<%DELAR%else%COEFAR%endif% ;Save in Z-1
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY *+,DELAR ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save in Z-2
- %endif%%endif%%loop%;*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 7
- %
- TMS320c25; Indexed Memory; Increased Precision
- >>>
- %batch_files 0 % .title "%IDT%" ;UNIQUE NAME
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;**************************************************
- ;* ASPI TMS320c25 DIGITAL FILTER REALIZATION *
- ;**************************************************
- ;* Increased Precision
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %if B0<%%else% .word %B0% ;B0
- %endif%%if B1<>% .word %B1% ;B1
- %endif%%if A1<%%else% .word %A1% ;A1
- %endif%%if half%%else% .word %A2% ;A2
- %if B2<%%else% .word %B2% ;B2
- %endif%%endif%%loop%;*
- ;*
- .sect "X%IDT%"
- ;*
- ;* COEFFICIENT DATA STORAGE AREA
- ;*
- FDATA: .space (%points%+1)*16
- ;*
- ;* DELAY STORAGE DATA STORAGE AREA
- ;*
- DELAY: .space (%ndelay%+%ndelay%+2)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- %if data% RPTK %points% ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- %endif% ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay%+%ndelay%+1 ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- COEFAR .set 1 ;Use AR1 to point to COEF's
- DELAR .set 2 ;Use AR2 to point to DELAY's
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LARK 0,3 ;Set up AR0 for subtract
- LRLK COEFAR,FDATA ;Load COEF AR with beginning of COEF's
- LRLK DELAR,DELAY ;Load DELAY AR with beginning of DELAY's
- LARP %if B10<%DELAR%else%COEFAR%endif% ;Select Proper AR for initial use
- %section%;*
- ;* SECOND-ORDER FILTER SECTION # %section_n%
- ;*
- %filtin%%if half% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *+ ;AC = Z-1
- ADDS *-,COEFAR ;ADD Least Significant
- %if B1<>% MPYA *+,%if A1<%DELAR%else%COEFAR%endif% ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- %else% APAC ;AC = Z-1 + (B0 * INPUT)
- %endif% SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT%if B1<>%P%endif% %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>% ;AC = B1 * INPUT%endif%
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+,DELAR ;P = A1 * OUTPUT
- %endif% %if B1<>%A%endif%PAC ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- %if A1shft% APAC
- %endif% SACH *+ ;Save in Z-1
- SACL *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save Least Significant
- %else
-
- %%if B1<>% LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *+ ;AC = Z-1
- ADDS *+,COEFAR ;ADD in least significant
- MPYA *+,DELAR ;AC = Z-1 + (B0 * INPUT)
- ;* ;P = B1 * INPUT
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LTP %if option M%VSAMPL%else%V%IDT%%endif% ;AC = B1 * INPUT
- ADDH *+ ;AC = Z-2 + (B1 * INPUT)
- ADDS *0-,COEFAR ;ADD in least significant
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+ ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% MPYA *+,DELAR ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH *+ ;Save in Z-1
- SACL *+,0,%if B2<%DELAR%else%COEFAR%endif% ;Save least significant
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY *+,DELAR ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH *+ ;Save in Z-2
- SACL *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save least significant
- %else
-
-
- % LT FILTT ;GET SCALED INPUT
- %if B0<% MPYK %B0% ;P = B0 * INPUT
- %else% MPY *+,DELAR ;P = B0 * INPUT
- %endif% ZALH *+ ;AC = Z-1
- ADDS *+,DELAR ;ADD in least significant
- APAC ;AC = Z-1 + (B0 * INPUT)
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;Save in OUTPUT
- LT %if option M%VSAMPL%else%V%IDT%%endif% ;Get OUTPUT
- ZALH *+ ;AC = Z-2
- ADDS *0-,COEFAR ;ADD in least significant
- %if A1<% MPYK %A1% ;P = A1 * OUTPUT
- %else% MPY *+ ;P = A1 * OUTPUT
- %endif%%if A1shft% APAC
- %endif% MPYA *+,DELAR ;AC = (B1 * INPUT) + (A1 * OUTPUT)
- ;* ;P = A2 * OUTPUT
- SACH *+ ;Save in Z-1
- SACL *+,0,%if B2<%DELAR%else%COEFAR%endif% ;Save least significant
- LTP FILTT ;AC = A2 * OUTPUT
- %if B2<% MPYK %B2% ;P = B2 * INPUT
- %else% MPY *+,DELAR ;P = B2 * INPUT
- %endif% APAC ;AC = (B2 * INPUT) + (A2 * OUTPUT)
- SACH *+ ;Save in Z-2
- SACL *+,0,%if BN0<%DELAR%else%COEFAR%endif% ;Save least significant
- %endif%%endif%%loop%*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 7
- %
- TMS320c25; Indexed Memory; Looping Control
- >>>
- %batch_files 0 % .title "%IDT%" ;UNIQUE NAME
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS320c25 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* LOOPING CONTROL
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER to I/O PAGE
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* INITIALIZATION FOR COEFFICIENTS
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- DATA %stages%-1 ;*Number of stages -1 to follow
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %tunable%
- DATA %b_scale% ;BLOCK FLOATING POINT SHIFT
- DATA %B0% ;B0
- DATA %B1% ;B1
- DATA %A1% ;A1
- DATA %A2% ;A2
- DATA %B2% ;B2
- %loop%;*
- ;*
- .sect "X%IDT%"
- ;*
- ;*COEFICIENT DATA STORAGE AREA (including block floating point shifts
- ;* and storage for the number of stages)
- ;*
- FDATA: .space (%points%+2)*16
- ;*
- ;* DELAY STORAGE STORAGE AREA
- ;*
- DELAY: .space (%ndelay%+1)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- RPTK %points%+1 ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay% ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* PAGE.
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- COEFAR .set 1 ;Use AR1 to point to COEF's
- DELAR .set 2 ;Use AR2 to point to DELAY's
- LOOPAR .set 3 ;Use AR3 as loop counter
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LRLK COEFAR,FDATA ;Load COEF AR with beginning of COEF's
- LRLK DELAR,DELAY ;Load DELAY AR with beginning of DELAY's
- LARP COEFAR ;Point to COEF AR
- LAR LOOPAR,*+ ;SET SECTION LOOP COUNT
- ;*
- ;* SECOND-ORDER FILTER SECTION LOOP
- ;*
- LT *+ ;GET SCALE FACTOR
- FLOOP:
- LACT %if option M%VSAMPL%else%V%IDT%%endif% ;GET and SCALE INPUT
- SACH FILTT,4 ;SAVE SCALED INPUT
- LT FILTT ;GET SCALED INPUT
- MPY *+,DELAR ;P = B0 * INPUT
- ZALH *+,COEFAR ;AC = Z-1
- MPYA *+,DELAR ;P = B1 * OUTPUT
- ;* ;AC = (B0 * INPUT) + Z-1
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;SAVE IN OUTPUT
- ZALH *-,COEFAR ;AC = Z-2
- LTA %if option M%VSAMPL%else%V%IDT%%endif% ;AC = (B1 * INPUT) + Z-2, GET CURRENT OUTPUT
- MPY *+ ;P = A1/2 * OUTPUT
- APAC
- MPYA *+,DELAR ;P = A2 * OUTPUT
- ;* ;AC = (A1 * OUTPUT) + (B1 * INPUT) + Z-2
- SACH *+,0,COEFAR ;SAVE Z-1
- LTP FILTT ;AC = A2 * OUTPUT, GET SCALED INPUT
- MPY *+ ;P = B2 * INPUT
- LTA *+,DELAR ;AC = (A2 * OUTPUT) + (B2 * INPUT)
- ;* ; & GET NEXT SCALE FACTOR
- SACH *+,0,LOOPAR ;SAVE Z-2
- ;*
- BANZ FLOOP,*-,COEFAR ;REPEAT FOR ALL SECTIONS
- ;*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 1
- 7
- %
- TMS320c25; Indexed Memory; Looping Control; Increased Precision
- >>>
- %batch_files 0 % .title "%IDT%" ;UNIQUE NAME
- %if option M%%else% .globl F%IDT% ;Name of filter subroutine
- .globl I%IDT% ;Name of filter initialization subroutine
- %endif%;*************************************************
- ;* ASPI TMS320c25 DIGITAL FILTER REALIZATION *
- ;*************************************************
- ;* Increased Precision
- ;* LOOPING CONTROL
- ;* %stages%-STAGE RECURSIVE FILTER
- ;* SECOND ORDER SECTIONS
- ;* FILTER GENERATED FROM FILE
- %filter_file%
- ;*
- ;*************************************************
- .text
- %if option M%%if main%%else% B START
- .space 254*16 ;Programs start at 100 Hex.
- ;************************************************
- ;* ASPI CARD INITIALIZATION CODE *
- ;************************************************
- START:
- CNFD ;SET BANK 0 TO DATA MEMORY
- LDPK IOPAGE ;SET PAGE POINTER to I/O PAGE
- SOVM ;SATURATION ARITHMETIC
- SSXM ;SET SIGN EXTEND MODE ON
- SPM 1 ;SET P REGISTER OUTPUT SHIFT TO 1
- CALL INIT ;INITIALIZE
- ;************************************************
- ;* MAIN I/O LOOP *
- ;************************************************
- DOUT .set 6 ;D/A OUTPUT
- DIN .set 6 ;A/D INPUT
- ;*
- ;* The following three instructions are used in conjunction
- ;* with the PATCH program to indicate an idle state where no
- ;* machine cycles are being used to preform filter operation
- ;* (i.e. The time that location 4 is 1 could be used to do
- ;* other useful things). PATCH monitors location 4 to determine
- ;* percetage utilization of the processor by the filter.
- ;*
- LPTS: LACK 1
- SACL FILTT
- OUT FILTT,4 ;SIGNAL IDLE STATE
- ;*
- LPTSA: BIOZ GET ;WAIT FOR CLOCK
- B LPTSA ;BRANCH IF NO CLOCK
- ;*
- GET: OUT VSAMPL,DOUT ;OUTPUT LAST OUTPUT
- IN VSAMPL,DIN ;INPUT SAMPLE
- ;*
- ;* The following three instructions are used in conjuction
- ;* with the PATCH program to indicate a busy state or that the
- ;* filter is in operation.
- ;*
- LACK 0 ;GET CONSTANT FOR IDLE
- SACL FILTT ;SAVE FOR OUTPUT
- OUT FILTT,4 ;SIGNAL BUSY STATE
- ;*
- ;* The following three instructions are used to determine whether
- ;* or not the filter should be active. In the non-active state the
- ;* input data is simply passed to the output. In the active state
- ;* the input data is filtered, then passed to the output.
- ;*
- IN FILTT,5 ;CHECK FOR ACTIVE STATE
- LAC FILTT
- BNZ LPTS ;NOT ACTIVE, PASS DATA THROUGH
- ;*
- CALL FILTER ;ACTIVE EXECUTE FILTER
- B LPTS ;LOOP
- %endif%%endif%;*************************************************
- ;* DATA MEMORY DEFINITION *
- ;*************************************************
- ;* CONTAINS:
- ;* STORAGE FOR FILTER INPUT AND OUTPUT
- ;* INITIALIZATION FOR COEFFICIENTS
- ;* STORAGE FOR COEFFICIENTS
- ;* STORAGE FOR DELAY ELEMENTS
- ;*************************************************
- ;*
- ;* FILTER INPUT and OUTPUT STORAGE
- ;*
- %if option M%FILTT .set 96 ;TEMPORARY FILTER DATA
- VSAMPL .set 97 ;INPUT/OUTPUT FILTER DATA
- IOPAGE .set 0
- %else% .globl FILTT,V%IDT%
- %endif%;*
- COEF:
- ;* COEFFICIENT INITIALIZATION STORAGE AREA
- ;*
- DATA %stages%-1 ;*Number of stages -1 to follow
- %section%;*
- ;*
- ;* SECOND-ORDER SECTION # %section_n%
- ;*
- %tunable%
- DATA %b_scale% ;BLOCK FLOATING POINT SHIFT
- DATA %B0% ;B0
- DATA %B1% ;B1
- DATA %A1% ;A1
- DATA %A2% ;A2
- DATA %B2% ;B2
- %loop%;*
- ;*
- .sect "X%IDT%"
- ;*
- ;*COEFICIENT DATA STORAGE AREA (including block floating point shifts
- ;* and storage for the number of stages)
- ;*
- FDATA: .space (%points%+2)*16
- ;*
- ;* DELAY STORAGE STORAGE AREA
- ;*
- DELAY: .space (%ndelay%+%ndelay%+2)*16
- ;*
- ;*
- .text
- ;*************************************************
- ;* FILTER INITIALIZATION SUBROUTINE *
- ;*************************************************
- %if option M%INIT%else%I%IDT%%endif%:
- LARP 0 ;POINT TO AR0
- LRLK 0,FDATA ;POINTER TO DATA MEMORY
- RPTK %points%+1 ;COUNT FOR NUMBER OF POINTS
- BLKP COEF,*+ ;BLOCK MOVE OF COEF.
- ZAC ;CLEAR ACCUMULATOR
- LRLK 0,DELAY
- RPTK %ndelay%+%ndelay%+1 ;NUMBER OF DELAY POINTS
- SACL *+ ;CLEAR DATA VALUE
- RET ;INIT RETURN
- ;*************************************************
- ;* FILTER SUBROUTINE *
- ;*************************************************
- ;* ASSUMPTIONS:
- ;* SATURATION ARITHMETIC MODE IS ON
- ;* P REGISTER OUTPUT SHIFT = 1
- ;* PAGE REGISTER IS SET TO 'IOPAGE'
- ;* PAGE.
- ;* SIGN EXTEND MODE IS ON
- ;*
- ;* INPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;* OUTPUT: %if option M%VSAMPL%else%V%IDT%%endif%
- ;*
- ;*************************************************
- COEFAR .set 1 ;Use AR1 to point to COEF's
- DELAR .set 2 ;Use AR2 to point to DELAY's
- LOOPAR .set 3 ;Use AR3 as loop counter
- ;*
- %if option M%FILTER%else%F%IDT%%endif%:
- LARK 0,3 ;Set up AR0 for subtract
- LRLK COEFAR,FDATA ;Load COEF AR with beginning of COEF's
- LRLK DELAR,DELAY ;Load DELAY AR with beginning of DELAY's
- LARP COEFAR ;Point to COEF AR
- LAR LOOPAR,*+ ;SET SECTION LOOP COUNT
- ;*
- ;* SECOND-ORDER FILTER SECTION LOOP
- ;*
- LT *+ ;GET SCALE FACTOR
- FLOOP:
- LACT %if option M%VSAMPL%else%V%IDT%%endif% ;GET and SCALE INPUT
- SACH FILTT,4 ;SAVE SCALED INPUT
- LT FILTT ;GET SCALED INPUT
- MPY *+,DELAR ;P = B0 * INPUT
- ZALH *+ ;AC = Z-1
- ADDS *+,COEFAR ;ADD in least significant
- MPYA *+,DELAR ;P = B1 * OUTPUT
- ;* ;AC = (B0 * INPUT) + Z-1
- SACH %if option M%VSAMPL%else%V%IDT%%endif% ;SAVE IN OUTPUT
- ZALH *+ ;AC = Z-2
- ADDS *0-,COEFAR ;ADD in least significant
- LTA %if option M%VSAMPL%else%V%IDT%%endif% ;AC = (B1 * INPUT) + Z-2, GET CURRENT OUTPUT
- MPY *+ ;P = A1/2 * OUTPUT
- APAC
- MPYA *+,DELAR ;P = A2 * OUTPUT
- ;* ;AC = (A1 * OUTPUT) + (B1 * INPUT) + Z-2
- SACH *+ ;SAVE Z-1
- SACL *+,0,COEFAR ;Save least significant
- LTP FILTT ;AC = A2 * OUTPUT, GET SCALED INPUT
- MPY *+ ;P = B2 * INPUT
- LTA *+,DELAR ;AC = (A2 * OUTPUT) + (B2 * INPUT)
- ;* ; & GET NEXT SCALE FACTOR
- SACH *+ ;SAVE Z-2
- SACL *+,0,LOOPAR ;Save least significant
- ;*
- BANZ FLOOP,*-,COEFAR ;REPEAT FOR ALL SECTIONS
- ;*
- RET ;RETURN
- .end
- %end%
- >>>>
- >>>
- 3
- 8
- ~
- TMS320C30; 'C' interface; Time Optimize w/ Optimized Filter Routine
- >>>
- ~set_C~~set_A~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Parks-McClellan Design ;
- ; ;
- ; Super Time Optimized ;
- ; ;
- ; 'C' compiler interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the 'C' structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routines ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;struct FIR initf()
- ;
- ;Calling sequence from 'C':
- ;
- ; FIR = ~if option M~init_filter~else~I_~IDT~~endif~();
- ;
- ; where FIR is a structure as defined above.
- ;
- ~if option M~ .globl _I_FILTER
- _I_FILTER:
- ~else~ .globl _I_~IDT~
- _I_~IDT~:
- ~endif~ .if large_model
- LDP fmema
- .endif
- LDI @fmema,AR2 ;Get address of address of init memory
- LDI *AR2++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR0(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR0(4) ;Set zero in FIR structure
- LDI taps,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI *AR2++,R0 ;Get address of coef.
- STI R0,*+AR0(2) ;Put address of coef. in FIR structure
- LDI *AR2++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR0(0) ;Put in FIR filter structure
- LDI *AR2++,R0 ;Get address of array filter routine
- STI R0,*+AR0(1) ;Put in FIR filter structure
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Subroutine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .globl _F_~IDT~
- .globl _F_~IDT~a
-
- ; PERFORM ARRAY FILTERING
- ;void (*param->filtera)(xy,xn,n,param)
- ;float *xn, *yn
- ;int n;
- ;struct FIR *param;
- ;
- ; filter returns y(n) for input x(n)
- ; xn and yn are pointers to arrays of size n+1 floats
- ; n is the number of samples - 1
- ;
- ; the filter routine must be called with x(0) thru x(n)
- ; first then x(n+1) thru x(....) and so on.
-
- _F_~IDT~a:
- .if array_filter
- PUSH FP
- LDI SP,FP
- PUSH AR6
- PUSH AR7
-
- LDI *-FP(5),AR2 ; AR2 = address of FIR filter structure
- LDI *++AR2(2),AR1 ; AR1 = address of coefficients
- LDI *++AR2,AR0 ; AR0 = address of x(n) in circular
- ; delay memory
- ; Note: AR2 now points to delay memory address
- LDI taps,BK ; Set block size for circular buffer
- ; of x(n)
- LDI *-FP(2),AR7 ; AR7 = address of y(n)
- LDI *-FP(3),AR6 ; AR6 = address of x(n)
- LDI taps-1,IR0 ; size of coef memory - 1
- LDF *AR6++,R0 ; get x(n)
- LDI *-FP(4),RC ; get number of samples - 1
-
- LDF *+AR2,R2 ; initialize R2 to 0.0
- || STF R0,*AR0 ; put x(n) in delay memory
- MPYF *AR1++,*AR0++%,R0 ;
-
- RPTB loop
- ~do~ MPYF *AR1~coef_inc~,*AR0++%,R0
- || ~s~F R0,R2,R2
- ~loopm2~~if symetric~ MPYF *AR1,*AR0%,R0
- || ~s~F R0,R2,R3
- ~else~ MPYF *AR1--(IR0),*AR0%,R0
- || ~s~F R0,R2,R3
- ~endif~
- LDF *AR6,R1 ; get next sample
- || LDF *+AR2,R2 ; initialize R2 to 0.0
- MPYF3 *AR6++,*AR1++,R0; x(n+1) * h(0) -> R0
- || ~s~F3 R0,R3,R3 ; final sum for y(n) -> R3
- loop: STF R3,*AR7++ ; store y(n) into array
- || STF R1,*AR0++% ; store x(n+1) into delay memory
-
- NOP *AR0--% ; back up delay pointer for next x(n)
- STI AR0,*AR2 ; save updated circular buffer point
- ; for next sample
- POP AR7
- POP AR6
- POP FP
- RETS ; return y(n) in R0
- .else
- CALL 40h ; signal error with break point
- .endif
-
- ; PERFORM THE SAMPLE BY SAMPLE FILTERING
- ;float (*param->filter)(xn,param)
- ;float xn
- ;struct FIR *param;
- ;
- ; filter returns y(n) for input x(n)
- ;
- ; the filter routine must be called with x(0) first then x(1)
- ; and so on.
-
- _F_~IDT~:
- .if s_by_s_filter
- PUSH FP
- LDI SP,FP
-
- LDI *-FP(3),AR2 ; AR2 = address of FIR filter structure
- LDI *++AR2(2),AR1 ; AR1 = address of coefficients
- LDI *++AR2,AR0 ; AR0 = address of x(n) in circular
- ; delay memory
- LDI taps,BK ; Set block size for circular buffer
- ; of x(n)
- LDF 0.0,R2 ; initialize R2 = 0.0
- LDF *-FP(2),R0 ; R0 = x(n)
- STF R0,*AR0 ; put x(n) in delay memory
- MPYF *AR1++,*AR0++%,R0 ;
- ~do~ MPYF *AR1~coef_inc~,*AR0++%,R0
- || ~s~F R0,R2,R2
- ~loopm2~ MPYF *AR1,*AR0%,R0
- || ~s~F R0,R2,R2
- ~s~F R0,R2,R0 ; add last product
-
- STI AR0,*AR2 ; save updated circular buffer point
- ; for next sample
- POP FP
- RETS ; return y(n) in R0
- .else
- CALL 40h ; signal error with break point
- .endif
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build .bss and .cinit sections ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ; The .cinit section exists to provide initialization data
- ; for the .bss section. The .bss section is where 'C'
- ; keeps all of its static and global storage.
-
- .sect ".cinit"
- .word 1,fmema ;init one word at location fmema
- .word fmem ;address of fmem to be put into fmema
- .bss fmema,1 ;reserve fmema in .bss
- .word 4,fmem
- .word delay_m ;address of delay memory
- .word coef_m ;address of coef_mem
- .word _F_~IDT~ ;address of sample by sample filter
- .word _F_~IDT~a ;address of array filter routine
- .bss fmem,4
- .if coef_ram
- .word ~if symetric~(taps+1)/2~else~taps~endif~,coef_m
- .else
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~if symetric~~do~ .float ~coeff~ ; ~coef_name~ = ~esign~~coef_nameI~
- ~looph~
- ~else~~do~ .float ~coeff~ ; ~coef_name~
- ~loop~~endif~
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Coefficients ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps
-
- .end
- ~end~
- >>>>
- >>>
- 3
- 8
- ~
- TMS320C30; 'C' interface; Time Optimize
- >>>
- ~set_C~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Parks-McClellan Design ;
- ; ;
- ; Time Optimized ;
- ; ;
- ; 'C' compiler interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the 'C' structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; int BK_reg; /* value to be placed in BK register */
- ; int frtaps; /* number of taps for RPTS forward */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routines ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;struct FIR initf()
- ;
- ;Calling sequence from 'C':
- ;
- ; FIR = ~if option M~init_filter~else~I_~IDT~~endif~();
- ;
- ; where FIR is a structure as defined above.
- ;
- ~if option M~ .globl _I_FILTER
- _I_FILTER:
- ~else~ .globl _I_~IDT~
- _I_~IDT~:
- ~endif~ .if large_model
- LDP fmema
- .endif
- LDI @fmema,AR2 ;Get address of address of init memory
- LDI *AR2++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR0(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR0(4) ;Set zero in FIR structure
- LDI taps+1,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI taps-3,R0 ;Get number for RPTS instruction
- STI R0,*+AR0(6) ;Store in FIR filter structure
- LDI *AR2++,R0 ;Get address of coef.
- STI R0,*+AR0(2) ;Put address of coef. in FIR structure
- LDI *AR2++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR0(0) ;Put in FIR filter structure
- LDI *AR2++,R0 ;Get address of array filter routine
- STI R0,*+AR0(1) ;Put in FIR filter structure
- STI BK,*+AR0(5) ;Put BK in FIR structure
- LDI taps-1,R0 ;Get number for RPTS instruction
- STI R0,*+AR0(7) ;Store in FIR filter structure
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build .bss and .cinit sections ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ; The .cinit section exists to provide initialization data
- ; for the .bss section. The .bss section is where 'C'
- ; keeps all of its static and global storage.
-
- .sect ".cinit"
- .word 1,fmema ;init one word at location fmema
- .word fmem ;address of fmem to be put into fmema
- .bss fmema,1 ;reserve fmema in .bss
- .globl _FIR_C
- .globl _FIR_Ca
- .word 4,fmem
- .word delay_m ;address of delay memory
- .word coef_m ;address of coef_mem
- .word _FIR_C ;address of sample by sample filter
- .word _FIR_Ca ;address of array filter routine
- .bss fmem,4
- .if coef_ram
- .word taps,coef_m
- .else
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~do~ .float ~coeff~ ; ~coef_name~
- ~loop~
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Coefficients Space ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",taps
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps+1
-
- .end
- ~end~
- >>>>
- >>>
- 3
- 8
- ~
- TMS320C30; 'C' interface; Size Optimize
- >>>
- ~set_C~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Parks-McClellan Design ;
- ; ;
- ; Size Optimized ;
- ; ;
- ; 'C' compiler interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the 'C' structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; int BK_reg; /* value to be placed in BK register */
- ; int frtaps; /* number of taps for RPTS forward */
- ; int rrtaps; /* number of taps for RPTS reverse */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routines ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;struct FIR initf()
- ;
- ;Calling sequence from 'C':
- ;
- ; FIR = ~if option M~I_FILTER~else~I_~IDT~~endif~();
- ;
- ; where FIR is a structure as defined above.
- ;
- ~if option M~ .globl _I_FILTER
- _I_FILTER:
- ~else~ .globl _I_~IDT~
- _I_~IDT~:
- ~endif~ .if large_model
- LDP fmema
- .endif
- LDI @fmema,AR2 ;Get address of address of init memory
- LDI *AR2++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR0(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR0(4) ;Set zero in FIR structure
- LDI taps+1,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI taps~if symetric~/2-2~else~-3~endif~,R0 ;Get number for RPTS instruction
- STI R0,*+AR0(6) ;Store in FIR filter structure
- ~if symetric~
- LDI (taps-1)/2~if asym_odd~-1~endif~~if asym_even~-1~endif~,R0 ;Get number for RPTS instruction
- ~else~
- LDI taps-1,R0 ;Get number for RPTS instruction
- ~endif~
- STI R0,*+AR0(7) ;Store in FIR filter structure
- LDI *AR2++,R0 ;Get address of coef.
- STI R0,*+AR0(2) ;Put address of coef. in FIR structure
- LDI *AR2++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR0(0) ;Put in FIR filter structure
- LDI *AR2++,R0 ;Get address of array filter routine
- STI R0,*+AR0(1) ;Put in FIR filter structure
- STI BK,*+AR0(5) ;Put BK in FIR structure
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build .bss and .cinit sections ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ; The .cinit section exists to provide initialization data
- ; for the .bss section. The .bss section is where 'C'
- ; keeps all of its static and global storage.
-
- .sect ".cinit"
- .word 1,fmema ;init one word at location fmema
- .word fmem ;address of fmem to be put into fmema
- .bss fmema,1 ;reserve fmema in .bss
- ~if sym_even~ .globl _FIR_Cse
- .globl _FIR_Csea
- ~endif~~if sym_odd~ .globl _FIR_Cso
- .globl _FIR_Csoa
- ~endif~~if asym_even~ .globl _FIR_Case
- .globl _FIR_Casea
- ~endif~~if asym_odd~ .globl _FIR_Caso
- .globl _FIR_Casoa
- ~endif~~if symetric~~else~ .globl _FIR_C
- .globl _FIR_Ca
- ~endif~ .word 4,fmem
- .word delay_m ;address of delay memory
- .word coef_m ;address of coef_mem
- ~if sym_even~ .word _FIR_Cse ;address of sample by sample filter
- .word _FIR_Csea ;address of array filter routine
- ~endif~~if sym_odd~ .word _FIR_Cso ;address of sample by sample filter
- .word _FIR_Csoa ;address of array filter routine
- ~endif~~if asym_even~ .word _FIR_Case ;address of sample by sample filter
- .word _FIR_Casea ;address of array filter routine
- ~endif~~if asym_odd~ .word _FIR_Caso ;address of sample by sample filter
- .word _FIR_Casoa ;address of array filter routine
- ~endif~~if symetric~~else~ .word _FIR_C ;address of sample by sample filter
- .word _FIR_Ca ;address of array filter routine
- ~endif~ .bss fmem,4
- .if coef_ram
- .word ~if symetric~(taps+1)/2~else~taps~endif~,coef_m
- .else
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~if symetric~~do~ .float ~coeff~ ; ~coef_name~ = ~esign~~coef_nameI~
- ~looph~
- ~else~~do~ .float ~coeff~ ; ~coef_name~
- ~loop~~endif~
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Coefficients Space ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps+1
-
- .end
- ~status~~end~
- >>>>
- >>>
- 3
- 8
- ~
- TMS320C30; ASM30 interface; Time Optimize w/ Optimized Filter Routine
- >>>
- ~set_A~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Parks-McClellan Design ;
- ; ;
- ; Super Time Optimized ;
- ; ;
- ; ASM30 compiler interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the data structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routines ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;Calling sequence:
- ; CALL ~if option M~init_filter~else~I_~IDT~~endif~
- ;
- ;Input:
- ; AR7 pointer to FIR filter structure
- ;Output:
- ; AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
- ;
- ;
- ~if option M~ .globl I_FILTER
- I_FILTER:
- ~else~ .globl I_~IDT~
- I_~IDT~:
- ~endif~ LDP fmema
- LDI @fmema,AR0 ;Get address of init memory
- LDI *AR0++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR7(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR7(4) ;Set zero in FIR structure
- LDI taps,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI *AR0++,R0 ;Get address of coef.
- STI R0,*+AR7(2) ;Put address of coef. in FIR structure
- LDI *AR0++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR7(0) ;Put in FIR filter structure
- LDI *AR0++,R0 ;Get address of array filter routine
- STI R0,*+AR7(1) ;Put in FIR filter structure
-
- .if coef_ram
- LDI *+AR7(2),AR1 ;get address of RAM coef
- LDI *AR0++,R0 ;Get first ROM coef
- RPTS ~if symetric~(taps+1)/2~else~taps~endif~-1
- LDI *AR0++,R0
- || STI R0,*AR1++ ;copy ROM coef to RAM coef
- .endif
-
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Subroutine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .globl _F_~IDT~
- .globl _F_~IDT~a
-
- ; PERFORM ARRAY FILTERING
- ;Input:
- ; AR4 address of x(n) array
- ; AR5 address of y(n) array
- ; AR6 number of samples-1 in array
- ; AR7 address of FIR filter structure
- ;Output:
- ; AR(0-2), AR(4-6), R(0-3), IR0, BK, RC, RS, RE, DP destroyed
-
- ; filter returns y(n) for input x(n)
- ; AR2 and AR4 are pointers to arrays of size n+1 floats
- ; n is the number of samples - 1
- ;
- ; the filter routine must be called with x(0) thru x(n)
- ; first then x(n+1) thru x(....) and so on.
-
- _F_~IDT~a:
- .if array_filter
- LDI *++AR7(2),AR1 ; AR1 = address of coefficients
- LDI *++AR7,AR0 ; AR0 = address of x(n) in circular
- ; delay memory
- ; Note: AR2 now points to delay memory address
- LDI taps,BK ; Set block size for circular buffer
- ; of x(n)
- LDF *AR4++,R0 ; get x(n)
- LDI AR6,RC ; get number of samples - 1
- LDI taps-1,IR0
-
- LDF *+AR7,R2 ; initialize R2 to 0.0
- || STF R0,*AR0 ; put x(n) in delay memory
- MPYF *AR1++,*AR0++%,R0 ;
-
- RPTB loop
- ~do~ MPYF *AR1~coef_inc~,*AR0++%,R0
- || ~s~F R0,R2,R2
- ~loopm2~~if symetric~ MPYF *AR1,*AR0%,R0
- || ~s~F R0,R2,R3
- ~else~ MPYF *AR1--(IR0),*AR0%,R0
- || ~s~F R0,R2,R3
- ~endif~
- LDF *AR4,R1 ; get next sample
- || LDF *+AR7,R2 ; initialize R2 to 0.0
- MPYF3 *AR1++,*AR4++,R0; x(n+1) * h(0) -> R0
- || ~s~F3 R0,R3,R3 ; final sum for y(n) -> R3
- loop: STF R3,*AR5++ ; store y(n) into array
- || STF R1,*AR0++% ; store x(n+1) into delay memory
-
- NOP *AR0--% ; back up delay pointer for next x(n)
- STI AR0,*AR7--(3) ; save updated circular buffer point
- ; for next sample
- RETS ; return y(n) in R0
- .else
- CALL 40h ; signal error with break point
- .endif
-
- ; PERFORM THE SAMPLE BY SAMPLE FILTERING
- ;Input:
- ; R0 x(n)
- ; AR7 pointer to FIR filter structure
- ;Ouput:
- ; R0 y(n)
- ; R2, AR0, AR1, BK, RC, RS, RE destroyed
-
- ;
- ; filter returns y(n) for input x(n)
- ;
- ; the filter routine must be called with x(0) first then x(1)
- ; and so on.
-
- _F_~IDT~:
- .if s_by_s_filter
- LDI *++AR7(2),AR1 ; AR1 = address of coefficients
- LDI *++AR7,AR0 ; AR0 = address of x(n) in circular
- ; delay memory
- LDI taps,BK ; Set block size for circular buffer
- ; of x(n)
- LDF 0.0,R2 ; initialize R2 = 0.0
- STF R0,*AR0 ; put x(n) in delay memory
- MPYF *AR1++,*AR0++%,R0 ;
- ~do~ MPYF *AR1~coef_inc~,*AR0++%,R0
- || ~s~F R0,R2,R2
- ~loopm2~ MPYF *AR1,*AR0%,R0
- || ~s~F R0,R2,R2
- ~s~F R0,R2,R0 ; add last product
-
- STI AR0,*AR7--(3) ; save updated circular buffer point
- ; for next sample
- RETS ; return y(n) in R0
- .else
- CALL 40h ; signal error with break point
- .endif
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build Coefficients ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- fmema: .word fmem
- fmem .word delay_m ;address of delay memory
- .word coef_m ;address of coef_mem
- .word _F_~IDT~ ;address of sample by sample filter
- .word _F_~IDT~a ;address of array filter routine
- .if coef_ram = 0
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~if symetric~~do~ .float ~coeff~ ; ~coef_name~ = ~esign~~coef_nameI~
- ~looph~
- ~else~~do~ .float ~coeff~ ; ~coef_name~
- ~loop~~endif~
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Coefficients Space ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps
-
- .end
- ~end~
- >>>>
- >>>
- 3
- 8
- ~
- TMS320C30; ASM30 interface; Time Optimized
- >>>
- ~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Parks-McClellan Design ;
- ; ;
- ; Time Optimized ;
- ; ;
- ; Assembly Language Interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the data structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; int BK_reg; /* value to be placed in BK register */
- ; int frtaps; /* number of taps for RPTS forward */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;Calling sequence:
- ; CALL ~if option M~init_filter~else~I_~IDT~~endif~
- ;
- ;Input:
- ; AR7 pointer to FIR filter structure
- ;Output:
- ; AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
- ;
- ;
- ~if option M~ .globl I_FILTER
- I_FILTER:
- ~else~ .globl I_~IDT~
- I_~IDT~:
- ~endif~
- LDP fmema
- LDI @fmema,AR0 ;Get address of address of delay memory
- LDI *AR0++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR7(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR7(4) ;Set zero in FIR structure
- LDI taps+1,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI *AR0++,R0 ;Get address of coef
- STI R0,*+AR7(2) ;Put address of coef. in FIR structure
- LDI *AR0++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR7(0) ;Put in FIR filter structure
- LDI *AR0++,R0 ;Get address of array filter routine
- STI R0,*+AR7(1) ;Put in FIR filter structure
- STI BK,*+AR7(5) ;Put BK in FIR structure
- LDI taps-3,R0 ;Get number taps for RPTS instruction
- STI R0,*+AR7(6) ;Put in FIR structure
- LDI taps-1,R0 ;Get number for RPTS instruction
- STI R0,*+AR7(7) ;Store in FIR filter structure
-
- .if coef_ram
- LDI *+AR7(2),AR1 ;get address of RAM coef
- LDI *AR0++,R0 ;Get first ROM coef
- RPTS taps-1
- LDI *AR0++,R0
- || STI R0,*AR1++ ;copy ROM coef to RAM coef
- .endif
-
- RETS
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build constants ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .globl FIR_A
- .globl FIR_Aa
-
- fmema: .word fmem
- fmem: .word delay_m
- .word coef_m
- .word FIR_A
- .word FIR_Aa
- .if coef_ram = 0
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~do~ .float ~coeff~ ; ~coef_name~
- ~loop~
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Coefficients Space ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",taps
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps+1
-
- .end
- ~end~
- >>>>
- >>>
- 3
- 8
- ~
- TMS320C30; ASM30 interface; Size Optimized
- >>>
- ~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Parks-McClellan Design ;
- ; ;
- ; Size Optimized ;
- ; ;
- ; Assembly Language Interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the data structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; int BK_reg; /* value to be placed in BK register */
- ; int frtaps; /* number of taps for RPTS forward */
- ; int rrtaps; /* number of taps for RPTS reverse */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;Calling sequence:
- ; CALL ~if option M~init_filter~else~I_~IDT~~endif~
- ;
- ;Input:
- ; AR7 pointer to FIR filter structure
- ;Output:
- ; AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
- ;
- ;
- ~if option M~ .globl I_FILTER
- I_FILTER:
- ~else~ .globl I_~IDT~
- I_~IDT~:
- ~endif~
- LDP fmema
- LDI @fmema,AR0 ;Get address of address of delay memory
- LDI *AR0++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR7(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR7(4) ;Set zero in FIR structure
- LDI taps+1,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI *AR0++,R0 ;Get address of coef
- STI R0,*+AR7(2) ;Put address of coef. in FIR structure
- LDI *AR0++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR7(0) ;Put in FIR filter structure
- LDI *AR0++,R0 ;Get address of array filter routine
- STI R0,*+AR7(1) ;Put in FIR filter structure
- STI BK,*+AR7(5) ;Put BK in FIR structure
- LDI taps~if symetric~/2-2~else~-3~endif~,R0 ;Get number for RPTS instruction
- STI R0,*+AR7(6) ;Put in FIR structure
- ~if symetric~
- LDI (taps-1)/2~if asym_odd~-1~endif~~if asym_even~-1~endif~,R0 ;Get number for RPTS instruction
- ~else~
- LDI taps-1,R0 ;Get number for RPTS instruction
- ~endif~
- STI R0,*+AR7(7) ;Store in FIR filter structure
-
- .if coef_ram
- LDI *+AR7(2),AR1 ;get address of RAM coef
- LDI *AR0++,R0 ;Get first ROM coef
- RPTS ~if symetric~(taps+1)/2~else~taps~endif~-1
- LDI *AR0++,R0
- || STI R0,*AR1++ ;copy ROM coef to RAM coef
- .endif
-
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build init data ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .word 1,fmema ;init one word at location fmema
- fmema: .word fmem ;address of fmem to be put into fmema
- ~if sym_even~ .globl FIR_Ase
- .globl FIR_Asea
- ~endif~~if sym_odd~ .globl FIR_Aso
- .globl FIR_Asoa
- ~endif~~if asym_even~ .globl FIR_Aase
- .globl FIR_Aasea
- ~endif~~if asym_odd~ .globl FIR_Aaso
- .globl FIR_Aasoa
- ~endif~~if symetric~~else~ .globl FIR_A
- .globl FIR_Aa
- ~endif~
- fmem: .word delay_m ;address of delay memory
- .word coef_m ;address of coef_mem
- ~if sym_even~ .word FIR_Ase ;address of sample by sample filter
- .word FIR_Asea ;address of array filter routine
- ~endif~~if sym_odd~ .word FIR_Aso ;address of sample by sample filter
- .word FIR_Asoa ;address of array filter routine
- ~endif~~if asym_even~ .word FIR_Aase ;address of sample by sample filter
- .word FIR_Aasea ;address of array filter routine
- ~endif~~if asym_odd~ .word FIR_Aaso ;address of sample by sample filter
- .word FIR_Aasoa ;address of array filter routine
- ~endif~~if symetric~~else~ .word FIR_A ;address of sample by sample filter
- .word FIR_Aa ;address of array filter routine
- ~endif~
- .if coef_ram = 0
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~if symetric~~do~ .float ~coeff~ ; ~coef_name~ = ~esign~~coef_nameI~
- ~looph~
- ~else~~do~ .float ~coeff~ ; ~coef_name~
- ~loop~~endif~
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Coefficients Space ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps+1
-
- .end
- ~status~~end~
- >>>>
- >>>
- 2
- 8
- ~
- TMS320C30; 'C' interface; Time Optimize w/ Optimized Filter Routine
- >>>
- ~set_C~~set_A~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Kaiser Window Design ;
- ; ;
- ; Super Time Optimized ;
- ; ;
- ; 'C' compiler interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the 'C' structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routines ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;struct FIR initf()
- ;
- ;Calling sequence from 'C':
- ;
- ; FIR = ~if option M~init_filter~else~I_~IDT~~endif~();
- ;
- ; where FIR is a structure as defined above.
- ;
- ~if option M~ .globl _I_FILTER
- _I_FILTER:
- ~else~ .globl _I_~IDT~
- _I_~IDT~:
- ~endif~ .if large_model
- LDP fmema
- .endif
- LDI @fmema,AR2 ;Get address of address of init memory
- LDI *AR2++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR0(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR0(4) ;Set zero in FIR structure
- LDI taps,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI *AR2++,R0 ;Get address of coef.
- STI R0,*+AR0(2) ;Put address of coef. in FIR structure
- LDI *AR2++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR0(0) ;Put in FIR filter structure
- LDI *AR2++,R0 ;Get address of array filter routine
- STI R0,*+AR0(1) ;Put in FIR filter structure
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Subroutine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .globl _F_~IDT~
- .globl _F_~IDT~a
-
- ; PERFORM ARRAY FILTERING
- ;void (*param->filtera)(xy,xn,n,param)
- ;float *xn, *yn
- ;int n;
- ;struct FIR *param;
- ;
- ; filter returns y(n) for input x(n)
- ; xn and yn are pointers to arrays of size n+1 floats
- ; n is the number of samples - 1
- ;
- ; the filter routine must be called with x(0) thru x(n)
- ; first then x(n+1) thru x(....) and so on.
-
- _F_~IDT~a:
- .if array_filter
- PUSH FP
- LDI SP,FP
- PUSH AR6
- PUSH AR7
-
- LDI *-FP(5),AR2 ; AR2 = address of FIR filter structure
- LDI *++AR2(2),AR1 ; AR1 = address of coefficients
- LDI *++AR2,AR0 ; AR0 = address of x(n) in circular
- ; delay memory
- ; Note: AR2 now points to delay memory address
- LDI taps,BK ; Set block size for circular buffer
- ; of x(n)
- LDI *-FP(2),AR7 ; AR7 = address of y(n)
- LDI *-FP(3),AR6 ; AR6 = address of x(n)
- LDI taps-1,IR0 ; size of coef memory - 1
- LDF *AR6++,R0 ; get x(n)
- LDI *-FP(4),RC ; get number of samples - 1
-
- LDF *+AR2,R2 ; initialize R2 to 0.0
- || STF R0,*AR0 ; put x(n) in delay memory
- MPYF *AR1++,*AR0++%,R0 ;
-
- RPTB loop
- ~do~ MPYF *AR1~coef_inc~,*AR0++%,R0
- || ~s~F R0,R2,R2
- ~loopm2~~if symetric~ MPYF *AR1,*AR0%,R0
- || ~s~F R0,R2,R3
- ~else~ MPYF *AR1--(IR0),*AR0%,R0
- || ~s~F R0,R2,R3
- ~endif~
- LDF *AR6,R1 ; get next sample
- || LDF *+AR2,R2 ; initialize R2 to 0.0
- MPYF3 *AR6++,*AR1++,R0; x(n+1) * h(0) -> R0
- || ~s~F3 R0,R3,R3 ; final sum for y(n) -> R3
- loop: STF R3,*AR7++ ; store y(n) into array
- || STF R1,*AR0++% ; store x(n+1) into delay memory
-
- NOP *AR0--% ; back up delay pointer for next x(n)
- STI AR0,*AR2 ; save updated circular buffer point
- ; for next sample
- POP AR7
- POP AR6
- POP FP
- RETS ; return y(n) in R0
- .else
- CALL 40h ; signal error with break point
- .endif
-
- ; PERFORM THE SAMPLE BY SAMPLE FILTERING
- ;float (*param->filter)(xn,param)
- ;float xn
- ;struct FIR *param;
- ;
- ; filter returns y(n) for input x(n)
- ;
- ; the filter routine must be called with x(0) first then x(1)
- ; and so on.
-
- _F_~IDT~:
- .if s_by_s_filter
- PUSH FP
- LDI SP,FP
-
- LDI *-FP(3),AR2 ; AR2 = address of FIR filter structure
- LDI *++AR2(2),AR1 ; AR1 = address of coefficients
- LDI *++AR2,AR0 ; AR0 = address of x(n) in circular
- ; delay memory
- LDI taps,BK ; Set block size for circular buffer
- ; of x(n)
- LDF 0.0,R2 ; initialize R2 = 0.0
- LDF *-FP(2),R0 ; R0 = x(n)
- STF R0,*AR0 ; put x(n) in delay memory
- MPYF *AR1++,*AR0++%,R0 ;
- ~do~ MPYF *AR1~coef_inc~,*AR0++%,R0
- || ~s~F R0,R2,R2
- ~loopm2~ MPYF *AR1,*AR0%,R0
- || ~s~F R0,R2,R2
- ~s~F R0,R2,R0 ; add last product
-
- STI AR0,*AR2 ; save updated circular buffer point
- ; for next sample
- POP FP
- RETS ; return y(n) in R0
- .else
- CALL 40h ; signal error with break point
- .endif
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build .bss and .cinit sections ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ; The .cinit section exists to provide initialization data
- ; for the .bss section. The .bss section is where 'C'
- ; keeps all of its static and global storage.
-
- .sect ".cinit"
- .word 1,fmema ;init one word at location fmema
- .word fmem ;address of fmem to be put into fmema
- .bss fmema,1 ;reserve fmema in .bss
- .word 4,fmem
- .word delay_m ;address of delay memory
- .word coef_m ;address of coef_mem
- .word _F_~IDT~ ;address of sample by sample filter
- .word _F_~IDT~a ;address of array filter routine
- .bss fmem,4
- .if coef_ram
- .word ~if symetric~(taps+1)/2~else~taps~endif~,coef_m
- .else
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~if symetric~~do~ .float ~coeff~ ; ~coef_name~ = ~esign~~coef_nameI~
- ~looph~
- ~else~~do~ .float ~coeff~ ; ~coef_name~
- ~loop~~endif~
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Coefficients ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps
-
- .end
- ~end~
- >>>>
- >>>
- 2
- 8
- ~
- TMS320C30; 'C' interface; Time Optimize
- >>>
- ~set_C~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Kaiser Window Design ;
- ; ;
- ; Time Optimized ;
- ; ;
- ; 'C' compiler interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the 'C' structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; int BK_reg; /* value to be placed in BK register */
- ; int frtaps; /* number of taps for RPTS forward */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routines ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;struct FIR initf()
- ;
- ;Calling sequence from 'C':
- ;
- ; FIR = ~if option M~init_filter~else~I_~IDT~~endif~();
- ;
- ; where FIR is a structure as defined above.
- ;
- ~if option M~ .globl _I_FILTER
- _I_FILTER:
- ~else~ .globl _I_~IDT~
- _I_~IDT~:
- ~endif~ .if large_model
- LDP fmema
- .endif
- LDI @fmema,AR2 ;Get address of address of init memory
- LDI *AR2++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR0(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR0(4) ;Set zero in FIR structure
- LDI taps+1,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI taps-3,R0 ;Get number for RPTS instruction
- STI R0,*+AR0(6) ;Store in FIR filter structure
- LDI *AR2++,R0 ;Get address of coef.
- STI R0,*+AR0(2) ;Put address of coef. in FIR structure
- LDI *AR2++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR0(0) ;Put in FIR filter structure
- LDI *AR2++,R0 ;Get address of array filter routine
- STI R0,*+AR0(1) ;Put in FIR filter structure
- STI BK,*+AR0(5) ;Put BK in FIR structure
- LDI taps-1,R0 ;Get number for RPTS instruction
- STI R0,*+AR0(7) ;Store in FIR filter structure
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build .bss and .cinit sections ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ; The .cinit section exists to provide initialization data
- ; for the .bss section. The .bss section is where 'C'
- ; keeps all of its static and global storage.
-
- .sect ".cinit"
- .word 1,fmema ;init one word at location fmema
- .word fmem ;address of fmem to be put into fmema
- .bss fmema,1 ;reserve fmema in .bss
- .globl _FIR_C
- .globl _FIR_Ca
- .word 4,fmem
- .word delay_m ;address of delay memory
- .word coef_m ;address of coef_mem
- .word _FIR_C ;address of sample by sample filter
- .word _FIR_Ca ;address of array filter routine
- .bss fmem,4
- .if coef_ram
- .word taps,coef_m
- .else
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~do~ .float ~coeff~ ; ~coef_name~
- ~loop~
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Coefficients Space ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",taps
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps+1
-
- .end
- ~end~
- >>>>
- >>>
- 2
- 8
- ~
- TMS320C30; 'C' interface; Size Optimize
- >>>
- ~set_C~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Kaiser Window Design ;
- ; ;
- ; Size Optimized ;
- ; ;
- ; 'C' compiler interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the 'C' structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; int BK_reg; /* value to be placed in BK register */
- ; int frtaps; /* number of taps for RPTS forward */
- ; int rrtaps; /* number of taps for RPTS reverse */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routines ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;struct FIR initf()
- ;
- ;Calling sequence from 'C':
- ;
- ; FIR = ~if option M~I_FILTER~else~I_~IDT~~endif~();
- ;
- ; where FIR is a structure as defined above.
- ;
- ~if option M~ .globl _I_FILTER
- _I_FILTER:
- ~else~ .globl _I_~IDT~
- _I_~IDT~:
- ~endif~ .if large_model
- LDP fmema
- .endif
- LDI @fmema,AR2 ;Get address of address of init memory
- LDI *AR2++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR0(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR0(4) ;Set zero in FIR structure
- LDI taps+1,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI taps~if symetric~/2-2~else~-3~endif~,R0 ;Get number for RPTS instruction
- STI R0,*+AR0(6) ;Store in FIR filter structure
- ~if symetric~
- LDI (taps-1)/2~if asym_odd~-1~endif~~if asym_even~-1~endif~,R0 ;Get number for RPTS instruction
- ~else~
- LDI taps-1,R0 ;Get number for RPTS instruction
- ~endif~
- STI R0,*+AR0(7) ;Store in FIR filter structure
- LDI *AR2++,R0 ;Get address of coef.
- STI R0,*+AR0(2) ;Put address of coef. in FIR structure
- LDI *AR2++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR0(0) ;Put in FIR filter structure
- LDI *AR2++,R0 ;Get address of array filter routine
- STI R0,*+AR0(1) ;Put in FIR filter structure
- STI BK,*+AR0(5) ;Put BK in FIR structure
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build .bss and .cinit sections ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ; The .cinit section exists to provide initialization data
- ; for the .bss section. The .bss section is where 'C'
- ; keeps all of its static and global storage.
-
- .sect ".cinit"
- .word 1,fmema ;init one word at location fmema
- .word fmem ;address of fmem to be put into fmema
- .bss fmema,1 ;reserve fmema in .bss
- ~if sym_even~ .globl _FIR_Cse
- .globl _FIR_Csea
- ~endif~~if sym_odd~ .globl _FIR_Cso
- .globl _FIR_Csoa
- ~endif~~if asym_even~ .globl _FIR_Case
- .globl _FIR_Casea
- ~endif~~if asym_odd~ .globl _FIR_Caso
- .globl _FIR_Casoa
- ~endif~~if symetric~~else~ .globl _FIR_C
- .globl _FIR_Ca
- ~endif~ .word 4,fmem
- .word delay_m ;address of delay memory
- .word coef_m ;address of coef_mem
- ~if sym_even~ .word _FIR_Cse ;address of sample by sample filter
- .word _FIR_Csea ;address of array filter routine
- ~endif~~if sym_odd~ .word _FIR_Cso ;address of sample by sample filter
- .word _FIR_Csoa ;address of array filter routine
- ~endif~~if asym_even~ .word _FIR_Case ;address of sample by sample filter
- .word _FIR_Casea ;address of array filter routine
- ~endif~~if asym_odd~ .word _FIR_Caso ;address of sample by sample filter
- .word _FIR_Casoa ;address of array filter routine
- ~endif~~if symetric~~else~ .word _FIR_C ;address of sample by sample filter
- .word _FIR_Ca ;address of array filter routine
- ~endif~ .bss fmem,4
- .if coef_ram
- .word ~if symetric~(taps+1)/2~else~taps~endif~,coef_m
- .else
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~if symetric~~do~ .float ~coeff~ ; ~coef_name~ = ~esign~~coef_nameI~
- ~looph~
- ~else~~do~ .float ~coeff~ ; ~coef_name~
- ~loop~~endif~
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Coefficients Space ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps+1
-
- .end
- ~status~~end~
- >>>>
- >>>
- 2
- 8
- ~
- TMS320C30; ASM30 interface; Time Optimize w/ Optimized Filter Routine
- >>>
- ~set_A~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Kaiser Window Design ;
- ; ;
- ; Super Time Optimized ;
- ; ;
- ; ASM30 compiler interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the data structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routines ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;Calling sequence:
- ; CALL ~if option M~init_filter~else~I_~IDT~~endif~
- ;
- ;Input:
- ; AR7 pointer to FIR filter structure
- ;Output:
- ; AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
- ;
- ;
- ~if option M~ .globl I_FILTER
- I_FILTER:
- ~else~ .globl I_~IDT~
- I_~IDT~:
- ~endif~ LDP fmema
- LDI @fmema,AR0 ;Get address of init memory
- LDI *AR0++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR7(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR7(4) ;Set zero in FIR structure
- LDI taps,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI *AR0++,R0 ;Get address of coef.
- STI R0,*+AR7(2) ;Put address of coef. in FIR structure
- LDI *AR0++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR7(0) ;Put in FIR filter structure
- LDI *AR0++,R0 ;Get address of array filter routine
- STI R0,*+AR7(1) ;Put in FIR filter structure
-
- .if coef_ram
- LDI *+AR7(2),AR1 ;get address of RAM coef
- LDI *AR0++,R0 ;Get first ROM coef
- RPTS ~if symetric~(taps+1)/2~else~taps~endif~-1
- LDI *AR0++,R0
- || STI R0,*AR1++ ;copy ROM coef to RAM coef
- .endif
-
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Subroutine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .globl _F_~IDT~
- .globl _F_~IDT~a
-
- ; PERFORM ARRAY FILTERING
- ;Input:
- ; AR4 address of x(n) array
- ; AR5 address of y(n) array
- ; AR6 number of samples-1 in array
- ; AR7 address of FIR filter structure
- ;Output:
- ; AR(0-2), AR(4-6), R(0-3), IR0, BK, RC, RS, RE, DP destroyed
-
- ; filter returns y(n) for input x(n)
- ; AR2 and AR4 are pointers to arrays of size n+1 floats
- ; n is the number of samples - 1
- ;
- ; the filter routine must be called with x(0) thru x(n)
- ; first then x(n+1) thru x(....) and so on.
-
- _F_~IDT~a:
- .if array_filter
- LDI *++AR7(2),AR1 ; AR1 = address of coefficients
- LDI *++AR7,AR0 ; AR0 = address of x(n) in circular
- ; delay memory
- ; Note: AR2 now points to delay memory address
- LDI taps,BK ; Set block size for circular buffer
- ; of x(n)
- LDF *AR4++,R0 ; get x(n)
- LDI AR6,RC ; get number of samples - 1
- LDI taps-1,IR0
-
- LDF *+AR7,R2 ; initialize R2 to 0.0
- || STF R0,*AR0 ; put x(n) in delay memory
- MPYF *AR1++,*AR0++%,R0 ;
-
- RPTB loop
- ~do~ MPYF *AR1~coef_inc~,*AR0++%,R0
- || ~s~F R0,R2,R2
- ~loopm2~~if symetric~ MPYF *AR1,*AR0%,R0
- || ~s~F R0,R2,R3
- ~else~ MPYF *AR1--(IR0),*AR0%,R0
- || ~s~F R0,R2,R3
- ~endif~
- LDF *AR4,R1 ; get next sample
- || LDF *+AR7,R2 ; initialize R2 to 0.0
- MPYF3 *AR1++,*AR4++,R0; x(n+1) * h(0) -> R0
- || ~s~F3 R0,R3,R3 ; final sum for y(n) -> R3
- loop: STF R3,*AR5++ ; store y(n) into array
- || STF R1,*AR0++% ; store x(n+1) into delay memory
-
- NOP *AR0--% ; back up delay pointer for next x(n)
- STI AR0,*AR7--(3) ; save updated circular buffer point
- ; for next sample
- RETS ; return y(n) in R0
- .else
- CALL 40h ; signal error with break point
- .endif
-
- ; PERFORM THE SAMPLE BY SAMPLE FILTERING
- ;Input:
- ; R0 x(n)
- ; AR7 pointer to FIR filter structure
- ;Ouput:
- ; R0 y(n)
- ; R2, AR0, AR1, BK, RC, RS, RE destroyed
-
- ;
- ; filter returns y(n) for input x(n)
- ;
- ; the filter routine must be called with x(0) first then x(1)
- ; and so on.
-
- _F_~IDT~:
- .if s_by_s_filter
- LDI *++AR7(2),AR1 ; AR1 = address of coefficients
- LDI *++AR7,AR0 ; AR0 = address of x(n) in circular
- ; delay memory
- LDI taps,BK ; Set block size for circular buffer
- ; of x(n)
- LDF 0.0,R2 ; initialize R2 = 0.0
- STF R0,*AR0 ; put x(n) in delay memory
- MPYF *AR1++,*AR0++%,R0 ;
- ~do~ MPYF *AR1~coef_inc~,*AR0++%,R0
- || ~s~F R0,R2,R2
- ~loopm2~ MPYF *AR1,*AR0%,R0
- || ~s~F R0,R2,R2
- ~s~F R0,R2,R0 ; add last product
-
- STI AR0,*AR7--(3) ; save updated circular buffer point
- ; for next sample
- RETS ; return y(n) in R0
- .else
- CALL 40h ; signal error with break point
- .endif
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build Coefficients ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- fmema: .word fmem
- fmem .word delay_m ;address of delay memory
- .word coef_m ;address of coef_mem
- .word _F_~IDT~ ;address of sample by sample filter
- .word _F_~IDT~a ;address of array filter routine
- .if coef_ram = 0
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~if symetric~~do~ .float ~coeff~ ; ~coef_name~ = ~esign~~coef_nameI~
- ~looph~
- ~else~~do~ .float ~coeff~ ; ~coef_name~
- ~loop~~endif~
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Coefficients Space ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps
-
- .end
- ~end~
- >>>>
- >>>
- 2
- 8
- ~
- TMS320C30; ASM30 interface; Time Optimized
- >>>
- ~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Kaiser Window Design ;
- ; ;
- ; Time Optimized ;
- ; ;
- ; Assembly Language Interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the data structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; int BK_reg; /* value to be placed in BK register */
- ; int frtaps; /* number of taps for RPTS forward */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;Calling sequence:
- ; CALL ~if option M~init_filter~else~I_~IDT~~endif~
- ;
- ;Input:
- ; AR7 pointer to FIR filter structure
- ;Output:
- ; AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
- ;
- ;
- ~if option M~ .globl I_FILTER
- I_FILTER:
- ~else~ .globl I_~IDT~
- I_~IDT~:
- ~endif~
- LDP fmema
- LDI @fmema,AR0 ;Get address of address of delay memory
- LDI *AR0++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR7(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR7(4) ;Set zero in FIR structure
- LDI taps+1,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI *AR0++,R0 ;Get address of coef
- STI R0,*+AR7(2) ;Put address of coef. in FIR structure
- LDI *AR0++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR7(0) ;Put in FIR filter structure
- LDI *AR0++,R0 ;Get address of array filter routine
- STI R0,*+AR7(1) ;Put in FIR filter structure
- STI BK,*+AR7(5) ;Put BK in FIR structure
- LDI taps-3,R0 ;Get number taps for RPTS instruction
- STI R0,*+AR7(6) ;Put in FIR structure
- LDI taps-1,R0 ;Get number for RPTS instruction
- STI R0,*+AR7(7) ;Store in FIR filter structure
-
- .if coef_ram
- LDI *+AR7(2),AR1 ;get address of RAM coef
- LDI *AR0++,R0 ;Get first ROM coef
- RPTS taps-1
- LDI *AR0++,R0
- || STI R0,*AR1++ ;copy ROM coef to RAM coef
- .endif
-
- RETS
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build constants ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .globl FIR_A
- .globl FIR_Aa
-
- fmema: .word fmem
- fmem: .word delay_m
- .word coef_m
- .word FIR_A
- .word FIR_Aa
- .if coef_ram = 0
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~do~ .float ~coeff~ ; ~coef_name~
- ~loop~
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Coefficients Space ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",taps
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps+1
-
- .end
- ~end~
- >>>>
- >>>
- 2
- 8
- ~
- TMS320C30; ASM30 interface; Size Optimized
- >>>
- ~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 FIR filter realization ;
- ; ;
- ; Kaiser Window Design ;
- ; ;
- ; Size Optimized ;
- ; ;
- ; Assembly Language Interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the data structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct FIR {
- ; float (*filter)(); /* pointer to sample by sample filter routine */
- ; void (*filtera)(); /* pointer to array filter routine */
- ; float *coef_mem; /* pointer to coef. memory */
- ; float *delay_mem; /* pointer to delay memory */
- ; float zero; /* a floating point 0 */
- ; int BK_reg; /* value to be placed in BK register */
- ; int frtaps; /* number of taps for RPTS forward */
- ; int rrtaps; /* number of taps for RPTS reverse */
- ; };
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; FIR Filter Init Routine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- taps .set ~taps~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;Calling sequence:
- ; CALL ~if option M~init_filter~else~I_~IDT~~endif~
- ;
- ;Input:
- ; AR7 pointer to FIR filter structure
- ;Output:
- ; AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
- ;
- ;
- ~if option M~ .globl I_FILTER
- I_FILTER:
- ~else~ .globl I_~IDT~
- I_~IDT~:
- ~endif~
- LDP fmema
- LDI @fmema,AR0 ;Get address of address of delay memory
- LDI *AR0++,AR1 ;Get address of delay memory
-
- STI AR1,*+AR7(3) ;Put in FIR structure
- LDF 0.0,R0
- STF R0,*+AR7(4) ;Set zero in FIR structure
- LDI taps+1,BK ;Set block size for circular buffer
- ; of x(n)
- RPTS taps
- STF R0,*AR1++% ;Zero the delay memory
- LDI *AR0++,R0 ;Get address of coef
- STI R0,*+AR7(2) ;Put address of coef. in FIR structure
- LDI *AR0++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR7(0) ;Put in FIR filter structure
- LDI *AR0++,R0 ;Get address of array filter routine
- STI R0,*+AR7(1) ;Put in FIR filter structure
- STI BK,*+AR7(5) ;Put BK in FIR structure
- LDI taps~if symetric~/2-2~else~-3~endif~,R0 ;Get number for RPTS instruction
- STI R0,*+AR7(6) ;Put in FIR structure
- ~if symetric~
- LDI (taps-1)/2~if asym_odd~-1~endif~~if asym_even~-1~endif~,R0 ;Get number for RPTS instruction
- ~else~
- LDI taps-1,R0 ;Get number for RPTS instruction
- ~endif~
- STI R0,*+AR7(7) ;Store in FIR filter structure
-
- .if coef_ram
- LDI *+AR7(2),AR1 ;get address of RAM coef
- LDI *AR0++,R0 ;Get first ROM coef
- RPTS ~if symetric~(taps+1)/2~else~taps~endif~-1
- LDI *AR0++,R0
- || STI R0,*AR1++ ;copy ROM coef to RAM coef
- .endif
-
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build init data ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .word 1,fmema ;init one word at location fmema
- fmema: .word fmem ;address of fmem to be put into fmema
- ~if sym_even~ .globl FIR_Ase
- .globl FIR_Asea
- ~endif~~if sym_odd~ .globl FIR_Aso
- .globl FIR_Asoa
- ~endif~~if asym_even~ .globl FIR_Aase
- .globl FIR_Aasea
- ~endif~~if asym_odd~ .globl FIR_Aaso
- .globl FIR_Aasoa
- ~endif~~if symetric~~else~ .globl FIR_A
- .globl FIR_Aa
- ~endif~
- fmem: .word delay_m ;address of delay memory
- .word coef_m ;address of coef_mem
- ~if sym_even~ .word FIR_Ase ;address of sample by sample filter
- .word FIR_Asea ;address of array filter routine
- ~endif~~if sym_odd~ .word FIR_Aso ;address of sample by sample filter
- .word FIR_Asoa ;address of array filter routine
- ~endif~~if asym_even~ .word FIR_Aase ;address of sample by sample filter
- .word FIR_Aasea ;address of array filter routine
- ~endif~~if asym_odd~ .word FIR_Aaso ;address of sample by sample filter
- .word FIR_Aasoa ;address of array filter routine
- ~endif~~if symetric~~else~ .word FIR_A ;address of sample by sample filter
- .word FIR_Aa ;address of array filter routine
- ~endif~
- .if coef_ram = 0
- .sect "C_~IDT~"
- coef_m:
- .endif
- ~if symetric~~do~ .float ~coeff~ ; ~coef_name~ = ~esign~~coef_nameI~
- ~looph~
- ~else~~do~ .float ~coeff~ ; ~coef_name~
- ~loop~~endif~
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Coefficients Space ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",taps+1
-
- .end
- ~status~~end~
- >>>>
- >>>
- 1
- 8
- ~
- TMS320C30; 'C' interface; Optimized Filter Routine
- >>>
- ~set_C~~order_coef~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 IIR filter realization ;
- ; ;
- ; 'C' compiler interface ;
- ; ;
- ; Super Time Optimized ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file determines the
- ;the compiler memory model. By default
- ;it is set to the small model.
-
- ;The following structure defines the 'C' structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct IIR {
- ; float *filter; ;address of sample by sample filter rout.
- ; float *filtera; ;address of array filter routine
- ; float *coef; ;address of coeficients
- ; float *delay; ;address of Z-1 delays
- ; float BK2; ;size of circular buffer/2
- ; int BK; ;size of circular buffer
- ; int nRPTB; ;number for RPTB instruction
- ; int coef_size ;size of coef. buffer
- ~if one~~else~
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; IIR Filter Routine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- FP .set AR3
-
- ; y(n) = (*param->filter)(x(n),param)
- ;
- ; float filter(xn,param)
- ; float xn;
- ; struct IIR *param;
- ;
- .global _F_~IDT~
- _F_~IDT~:
- .if s_by_s_filter
- PUSH FP
- LDI SP,FP
- PUSH AR7
-
- LDI *-FP(3),AR7 ;address of param -> AR7
- LDF *-FP(2),R2 ;Y0(n) = x(n) -> R2
- LDI *+AR7(3),AR1 ;Get address of Z-1's
- LDI *+AR7(2),AR0 ;Get address of coefficients
- LDI AR1,AR2 ;Copy into AR2
- LDI *+AR7(4),IR0 ;Get 1/2 size of circular buffer
- LDI *+AR7(5),BK ;Get size of circular buffer
- NOP *AR2++(IR0)% ;Make address of Z-2
-
- MPYF3 *AR0++,*AR1,R0 ;A1 * Z-1 -> R0 (for first sample)
- ~do~;section ~section_n~
- ~if !first~ MPYF3 *AR0++,*AR1,R0 ;A1 * Z-1 -> R0
- ~if l_b0=mb2~|| SUBF3 R2,R0,R2 ;Z + B1' * Z-1 + Z-2 -> R2
- ~else~|| ADDF3 R0,R2,R2 ;Z + B1' * Z-1 + Z-2 -> R2
- ~endif~ ;from last iteration
- ~endif~~if s_b0=b2~;4 cycle section b0=b2
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- ADDF3 *AR2,R2,R2 ;Z + Z-2 -> R2
- || STF R2,*AR2++% ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
- ~endif~~if s_b0=mb2~;4 cycle section b0=-b2
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- SUBF3 R2,*AR2,R2 ;-(Z + Z-2) -> R2
- || STF R2,*AR2++% ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
- ~endif~~if s_2sa~;9 cycle 2 sections (section a)
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR2~if last2s~~else~++%~endif~,R0;B2' * Z-2 -> R0
- || ADDF3 R0,R2,R3 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R3,R2 ;Z + B2' * Z-2 -> R2
- ~endif~~if s_2sb~;9 cycle 2 sections (section b)
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR2,R0 ;B2' * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- STF R3,*-AR2(1) ;save Z(last section) for next sample
- || STF R2,*AR2++% ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;Z + B2' * Z-2 -> R2
- ~endif~~if s_half~;half section
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;Z = A1 * Z-1 + Yi(n) -> R2
- ~if firsthalf~~if l_2sa~ STF R3,*AR2++% ;save Z for next sample
- ~endif~~endif~~if lasthalf~~else~ STF R2,*AR2++% ;save Z for next sample
- ~endif~~endif~~loop~
-
- ~if l_b0=mb2~ SUBF R2,R0 ;Z + B1' * Z-1 + B2' * Z-2 -> R2
- ~else~ ADDF R2,R0 ;Z + B1' * Z-1 + b2' * Z-2 -> R2
- ~endif~ MPYF3 *+AR0,R0,R0 ;Do final gain compensation
- ~if l_half~|| STF R2,*AR2++% ;save Z for next sample
- ~endif~~if l_2sa~|| STF R3,*AR2++% ;save Z for next sample
- ~endif~ STI AR1,*+AR7(3) ;Update Z-1 address
-
- POP AR7
- POP FP
- RETS
- .else
- CALL @40h ;Call 40 hex to signal error
- .endif
- ; PERFORM ARRAY FILTERING
- ;void (*param->filtera)(xy,xn,n,param)
- ;float *xn, *yn
- ;int n;
- ;struct IIR *param;
- ;
- ; filter returns y(n) for input x(n)
- ; xn and yn are pointers to arrays of size n+1 floats
- ;
- ; the filter routine must be called with x(0) thru x(n)
- ; first then x(n+1) thru x(....) and so on.
-
- .global _F_~IDT~a
- _F_~IDT~a:
- .if array_filter
- PUSH FP
- LDI SP,FP
- PUSH AR7
- PUSH AR6
- PUSH AR5
- PUSH AR4
-
- LDI *-FP(2),AR5 ;Get address of y(n)
- LDI *-FP(3),AR4 ;Get address of x(n)
- LDI *-FP(5),AR7 ;address of param -> AR7
- LDI *+AR7(3),AR1 ;Get address of Z-1's
- LDI *+AR7(2),AR0 ;Get address of coefficients
- LDI AR1,AR2 ;Copy into AR2
- LDI *-FP(4),RC ;Get number of samples-1 to filter
- LDI *+AR7(4),IR0 ;Get 1/2 size of circular buffer
- LDI *+AR7(5),BK ;Get size of circular buffer
- NOP *AR2++(IR0)% ;Make address of Z-2
- LDF *AR4++,R2 ;Get x(n)
- LDI *+AR7(7),IR0 ;Get length of coef. buffer-2
-
- MPYF3 *AR0++,*AR1,R0 ;A1 * Z-1 -> R0 (for first sample)
-
- RPTB loopa ;do sections
- ~do~;section ~section_n~
- ~if !first~ MPYF3 *AR0++,*AR1,R0 ;A1 * Z-1 -> R0
- ~if l_b0=mb2~|| SUBF3 R2,R0,R2 ;Z + B1' * Z-1 + Z-2 -> R2
- ~else~|| ADDF3 R0,R2,R2 ;Z + B1' * Z-1 + Z-2 -> R2
- ~endif~ ;from last iteration
- ~endif~~if s_b0=b2~;4 cycle section b0=b2
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- ADDF3 *AR2,R2,R2 ;Z + Z-2 -> R2
- || STF R2,*AR2++% ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
- ~endif~~if s_b0=mb2~;4 cycle section b0=-b2
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- SUBF3 R2,*AR2,R2 ;-(Z + Z-2) -> R2
- || STF R2,*AR2++% ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
- ~endif~~if s_2sa~;9 cycle 2 sections (section a)
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR2~if last2s~~else~++%~endif~,R0;B2' * Z-2 -> R0
- || ADDF3 R0,R2,R3 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R3,R2 ;Z + B2' * Z-2 -> R2
- ~endif~~if s_2sb~;9 cycle 2 sections (section b)
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR2,R0 ;B2' * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- STF R3,*-AR2(1) ;save Z(last section) for next sample
- || STF R2,*AR2++% ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;Z + B2' * Z-2 -> R2
- ~endif~~if s_half~;half section
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,~if lasthalf~R3~else~R2~endif~ ;Z = A1 * Z-1 + Yi(n) -> R2
- ~if firsthalf~~if l_2sa~ STF R3,*AR2++% ;save Z for next sample
- ~endif~~endif~~if lasthalf~~else~ STF R2,*AR2++% ;save Z for next sample
- ~endif~~endif~~loop~
-
- MPYF3 *AR0++,*AR1,R0 ;A1 * Z-1 -> R0 (for next sample)
- ~if l_b0=mb2~|| SUBF3 R2,R0,R2 ;Z + B1' * Z-1 + B1' * Z-2 -> R2
- ~else~|| ADDF3 R0,~if l_half~R3~else~R2~endif~,R2 ;Z + B1' * Z-1 + Z-2 -> R2
- ~endif~ MPYF3 *AR0--(IR0),R2,R1;Do final gain compensation
- ~if l_half~|| STF R3,*AR2++% ;save Z for next sample
- ~endif~~if l_2sa~|| STF R3,*AR2++% ;save Z for next sample
- ~endif~loopa LDF *AR4++,R2 ;Get y0(n+1) = x(n+1) -> R2
- || STF R1,*AR5++ ;Output filtered data to array
-
- STI AR1,*+AR7(3) ;Update Z-1 address
-
- POP AR4
- POP AR5
- POP AR6
- POP AR7
- POP FP
- RETS
- .else
- CALL @40h ;Call 40 hex to signal error
- .endif
- ~endif~
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; IIR Filter Init Routine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- sects .set ~sects~
-
- ; INITIALIZE THE FILTER memory and the IIR structure
- ;
- ;struct IIR initf()
- ;
- ;Calling sequence from 'C':
- ;
- ; IIR = ~if option M~init_filter~else~I_~IDT~~endif~();
- ;
- ; where IIR is a structure as defined above.
- ;
- ~if option M~ .globl _I_FILTER
- _I_FILTER:
- ~else~ .globl _I_~IDT~
- _I_~IDT~:
- ~endif~
- .if large_model
- LDP fmema
- .endif
- LDI @fmema,AR2 ;Get address of init memory
- LDI *AR2++,AR1 ;Get address of delay memory Z-1
- STI AR1,*+AR0(3) ;Put in IIR structure
-
- LDF 0.0,R0
- RPTS sects*2-1
- STF R0,*AR1++ ;Zero the delay memory
-
- LDI sects,R0 ;Get size of circular buffer/2
- STI R0,*+AR0(4) ;Put in IIR filter structure
- LDI sects*2,R0 ;Get size of circular buffer
- STI R0,*+AR0(5) ;Put in IIR filter structure
- LDI *AR2++,R0 ;Get address of coef.
- STI R0,*+AR0(2) ;Put address of coef. in IIR structure
- LDI *AR2++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR0(0) ;Put in IIR filter structure
- LDI *AR2++,R0 ;Get address of array filter routine
- STI R0,*+AR0(1) ;Put in IIR filter structure
- ~if one~~else~ LDI ~c_size~-2,R0 ;Get size of coef. buffer-2
- STI R0,*+AR0(7) ;Put in IIR filter structure
- ~endif~ RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build .bss and .cinit sections ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ; The .cinit section exists to provide initialization data
- ; for the .bss section. The .bss section is where 'C'
- ; keeps all of its static and global storage.
-
- .globl ~if one~_IIR_C5~else~_F_~IDT~~endif~
- .globl ~if one~_IIR_C5~else~_F_~IDT~~endif~a
-
- .sect ".cinit"
- .word 1,fmema ;init one word at location fmema
- .word fmem ;address of fmem to be put into fmema
- .bss fmema,1 ;reserve fmema in .bss
-
- .word 4,fmem
- .word delay_m ;address of delay memory1
- .word coef_m ;address of coef_mem
- .word ~if one~_IIR_C5~else~_F_~IDT~~endif~ ;address of sample by sample filter
- .word ~if one~_IIR_C5~else~_F_~IDT~~endif~a ;address of array filter
- .bss fmem,4
-
- .if coef_ram
- .word ~if one~5~else~~c_size~~endif~,coef_m
- .else
- .sect "coef"
- coef_m:
- .endif
- ~if one~~do~; section 1
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B2~ ;b2
- .float ~B0~ ;b0
- .float ~B1~ ;b1
- ~else~~do~~if s_b0=+-b2~ ;section ~section_n~
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B1'~ ;b1'
- ~else~~if s_half~; section ~section_n~
- .float ~A1~ ;a1
- .float ~B1'~ ;b1'
- ~else~; section ~section_n~
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B2'~ ;b2'
- .float ~B1'~ ;b1'
- ~endif~~endif~~loop~
- .float ~A11~ ;a1 of section 1
-
- .float ~gain~ ;final gain
- ~endif~
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Coefficients ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if one~5~else~~c_size~~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",sects*2
-
- .end
- ~end~
- >>>>
- >>>
- 1
- 8
- ~
- TMS320C30; 'C' interface
- >>>
- ~set_C~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 IIR filter realization ;
- ; ;
- ; 'C' compiler interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file determines the
- ;the compiler memory model. By default
- ;it is set to the small model.
-
- ;The following structure defines the 'C' structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct IIR {
- ; float *filter; ;address of sample by sample filter rout.
- ; float *filtera; ;address of array filter routine
- ; float *coef; ;address of coeficients
- ; float *delay; ;address of Z-1 delays
- ; float BK2; ;size of circular buffer/2
- ; int BK; ;size of circular buffer
- ; int nRPTB; ;number for RPTB instruction
- ; int coef_size ;size of coef. buffer
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; IIR Filter Init Routine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- FP .set AR3
- sects .set ~sects~
-
- ; INITIALIZE THE FILTER memory and the IIR structure
- ;
- ;struct IIR initf()
- ;
- ;Calling sequence from 'C':
- ;
- ; IIR = ~if option M~init_filter~else~I_~IDT~~endif~();
- ;
- ; where IIR is a structure as defined above.
- ;
- ~if option M~ .globl _I_FILTER
- _I_FILTER:
- ~else~ .globl _I_~IDT~
- _I_~IDT~:
- ~endif~
- .if large_model
- LDP fmema
- .endif
- LDI @fmema,AR2 ;Get address of init memory
- LDI *AR2++,AR1 ;Get address of delay memory Z-1
- STI AR1,*+AR0(3) ;Put in IIR structure
-
- LDF 0.0,R0
- RPTS sects*2-1
- STF R0,*AR1++ ;Zero the delay memory
-
- LDI ~if one~sects-1~else~~if b0=+-b2~sects-1~else~(sects/2)-1~endif~~endif~,R0 ;Get number for RPTS instruction
- STI R0,*+AR0(6) ;Store in IIR filter structure
- LDI sects,R0 ;Get size of circular buffer/2
- STI R0,*+AR0(4) ;Put in IIR filter structure
- LDI sects*2,R0 ;Get size of circular buffer
- STI R0,*+AR0(5) ;Put in IIR filter structure
- LDI *AR2++,R0 ;Get address of coef.
- STI R0,*+AR0(2) ;Put address of coef. in IIR structure
- LDI *AR2++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR0(0) ;Put in IIR filter structure
- LDI *AR2++,R0 ;Get address of array filter routine
- STI R0,*+AR0(1) ;Put in IIR filter structure
- LDI sects*~if one~5-2~else~~if b0=+-b2~3~else~4~endif~~endif~,R0 ;Get size of coef. buffer-2
- STI R0,*+AR0(7) ;Put in IIR filter structure
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build .bss and .cinit sections ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ; The .cinit section exists to provide initialization data
- ; for the .bss section. The .bss section is where 'C'
- ; keeps all of its static and global storage.
-
- .globl _IIR_C~if one~5~else~~if b0=+-b2~4~if b0=-b2~m~endif~~else~45~if odd~o~endif~~endif~~endif~
- .globl _IIR_C~if one~5~else~~if b0=+-b2~4~if b0=-b2~m~endif~~else~45~if odd~o~endif~~endif~~endif~a
-
- .sect ".cinit"
- .word 1,fmema ;init one word at location fmema
- .word fmem ;address of fmem to be put into fmema
- .bss fmema,1 ;reserve fmema in .bss
-
- .word 4,fmem
- .word delay_m ;address of delay memory1
- .word coef_m ;address of coef_mem
- .word _IIR_C~if one~5~else~~if b0=+-b2~4~if b0=-b2~m~endif~~else~45~if odd~o~endif~~endif~~endif~ ;address of sample by sample filter
- .word _IIR_C~if one~5~else~~if b0=+-b2~4~if b0=-b2~m~endif~~else~45~if odd~o~endif~~endif~~endif~a ;address of array filter routine
- .bss fmem,4
-
- .if coef_ram
- .word ~if one~sects*5~else~~if b0=+-b2~sects*3+2~else~sects*4+2~endif~~endif~,coef_m
- .else
- .sect "coef"
- coef_m:
- .endif
- ~if one~~do~; section 1
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B2~ ;b2
- .float ~B0~ ;b0
- .float ~B1~ ;b1
- ~else~~if b0=+-b2~~do~ ;section ~section_n~
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B1'~ ;b1'
- ~loop~
- .float ~A11~ ;a1 of section 1
-
- .float ~gain~ ;final gain
- ~else~~do~; section ~section_n~
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B2'~ ;b2'
- .float ~B1'~ ;b1'
- ~loop~
- .float ~A11~ ;a1 of section 1
-
- .float ~gain~ ;final gain
- ~endif~~endif~
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Coefficients ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if one~sects*5~else~~if b0=+-b2~sects*3+2~else~sects*4+2~endif~~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",sects*2
-
- .end
- ~end~
- >>>>
- >>>
- 1
- 8
- ~
- TMS320C30; ASM30 interface; Optimized Filter Routine
- >>>
- ~order_coef~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 IIR filter realization ;
- ; ;
- ; Assembly Language Interface ;
- ; ;
- ; Super Time Optimized ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the data structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct IIR {
- ; float *filter; ;address of sample by sample filter rout.
- ; float *filtera; ;address of array filter routine
- ; float *coef; ;address of coeficients
- ; float *delay; ;address of Z-1 delays
- ; float BK2; ;size of circular buffer/2
- ; int BK; ;size of circular buffer
- ; int nRPTB; ;number for RPTB instruction
- ; int coef_size ;size of coef. buffer
- ~if one~~else~
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; IIR Filter Routine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- ; PERFORM THE SAMPLE BY SAMPLE FILTERING
- ;Input:
- ; R0 x(n)
- ; AR7 pointer to FIR filter structure
- ;Ouput:
- ; R0 y(n)
- ; R2, AR0, AR1, AR2, BK, RC, RS, RE destroyed
-
- .global _F_~IDT~
- _F_~IDT~:
- .if s_by_s_filter
- LDI *+AR7(3),AR1 ;Get address of Z-1's
- LDI *+AR7(2),AR0 ;Get address of coefficients
- LDI AR1,AR2 ;Copy into AR2
- LDI *+AR7(4),IR0 ;Get 1/2 size of circular buffer
- LDI *+AR7(5),BK ;Get size of circular buffer
- NOP *AR2++(IR0)% ;Make address of Z-2
-
- MPYF3 *AR0++,*AR1,R2 ;A1 * Z-1 -> R0 (for first sample)
- ~do~;section ~section_n~
- ~if !first~ MPYF3 *AR0++,*AR1,R0 ;A1 * Z-1 -> R0
- ~if l_b0=mb2~|| SUBF3 R2,R0,R2 ;Z + B1' * Z-1 + Z-2 -> R2
- ~else~|| ADDF3 R0,R2,R2 ;Z + B1' * Z-1 + Z-2 -> R2
- ~endif~ ;from last iteration
- ~endif~~if s_b0=b2~;4 cycle section b0=b2
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- ADDF3 *AR2,R2,R2 ;Z + Z-2 -> R2
- || STF R2,*AR2++% ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
- ~endif~~if s_b0=mb2~;4 cycle section b0=-b2
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- SUBF3 R2,*AR2,R2 ;-(Z + Z-2) -> R2
- || STF R2,*AR2++% ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
- ~endif~~if s_2sa~;9 cycle 2 sections (section a)
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR2~if last2s~~else~++%~endif~,R0;B2' * Z-2 -> R0
- || ADDF3 R0,R2,R3 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R3,R2 ;Z + B2' * Z-2 -> R2
- ~endif~~if s_2sb~;9 cycle 2 sections (section b)
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR2,R0 ;B2' * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- STF R3,*-AR2(1) ;save Z(last section) for next sample
- || STF R2,*AR2++% ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;Z + B2' * Z-2 -> R2
- ~endif~~if s_half~;half section
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;Z = A1 * Z-1 + Yi(n) -> R2
- ~if firsthalf~~if l_2sa~ STF R3,*AR2++% ;save Z for next sample
- ~endif~~endif~~if lasthalf~~else~ STF R2,*AR2++% ;save Z for next sample
- ~endif~~endif~~loop~
-
- ~if l_b0=mb2~ SUBF R2,R0 ;Z + B1' * Z-1 + B2' * Z-2 -> R2
- ~else~ ADDF R2,R0 ;Z + B1' * Z-1 + b2' * Z-2 -> R2
- ~endif~ MPYF3 *+AR0,R0,R0 ;Do final gain compensation
- ~if l_half~|| STF R2,*AR2++% ;save Z for next sample
- ~endif~~if l_2sa~|| STF R3,*AR2++% ;save Z for next sample
- ~endif~ STI AR1,*+AR7(3) ;Update Z-1 address
-
- RETS
- .else
- CALL @40h ;Call location 40 hex to signal error
- .endif
-
- ; PERFORM ARRAY FILTERING
- ;Input:
- ; AR4 address of x(n) array
- ; AR5 address of y(n) array
- ; AR6 number of samples-1 in array
- ; AR7 address of FIR filter structure
- ;Output:
- ; AR(0-2), AR(4-6), R(0-3), IR0, BK, RC, RS, RE, DP destroyed
-
- .global _F_~IDT~a
- _F_~IDT~a:
- .if array_filter
- LDI *+AR7(3),AR1 ;Get address of Z-1's
- LDI AR1,AR2 ;Copy into AR2
- LDI *+AR7(2),AR0 ;Get address of coefficients
- LDI AR6,RC ;Get number of samples-1 to filter
- LDI *+AR7(4),IR0 ;Get 1/2 size of circular buffer
- LDI *+AR7(5),BK ;Get size of circular buffer
- NOP *AR2++(IR0)% ;Make address of Z-2
- LDF *AR4++,R2 ;Get x(n)
- LDI *+AR7(7),IR0 ;Get length of coef. buffer-2
-
- MPYF3 *AR0++,*AR1,R0 ;A1 * Z-1 -> R0 (for first sample)
-
- RPTB loopa ;do sections
- ~do~;section ~section_n~
- ~if !first~ MPYF3 *AR0++,*AR1,R0 ;A1 * Z-1 -> R0
- ~if l_b0=mb2~|| SUBF3 R2,R0,R2 ;Z + B1' * Z-1 + Z-2 -> R2
- ~else~|| ADDF3 R0,R2,R2 ;Z + B1' * Z-1 + Z-2 -> R2
- ~endif~ ;from last iteration
- ~endif~~if s_b0=b2~;4 cycle section b0=b2
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- ADDF3 *AR2,R2,R2 ;Z + Z-2 -> R2
- || STF R2,*AR2++% ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
- ~endif~~if s_b0=mb2~;4 cycle section b0=-b2
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- SUBF3 R2,*AR2,R2 ;-(Z + Z-2) -> R2
- || STF R2,*AR2++% ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
- ~endif~~if s_2sa~;9 cycle 2 sections (section a)
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR2~if last2s~~else~++%~endif~,R0;B2' * Z-2 -> R0
- || ADDF3 R0,R2,R3 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R3,R2 ;Z + B2' * Z-2 -> R2
- ~endif~~if s_2sb~;9 cycle 2 sections (section b)
- MPYF3 *AR0++,*AR2,R0 ;A2 * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) -> R2
- MPYF3 *AR0++,*AR2,R0 ;B2' * Z-2 -> R0
- || ADDF3 R0,R2,R2 ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
- STF R3,*-AR2(1) ;save Z(last section) for next sample
- || STF R2,*AR2++% ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,R2 ;Z + B2' * Z-2 -> R2
- ~endif~~if s_half~;half section
- MPYF3 *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
- || ADDF3 R0,R2,~if lasthalf~R3~else~R2~endif~ ;Z = A1 * Z-1 + Yi(n) -> R2
- ~if firsthalf~~if l_2sa~ STF R3,*AR2++% ;save Z for next sample
- ~endif~~endif~~if lasthalf~~else~ STF R2,*AR2++% ;save Z for next sample
- ~endif~~endif~~loop~
-
- MPYF3 *AR0++,*AR1,R0 ;A1 * Z-1 -> R0 (for next sample)
- ~if l_b0=mb2~|| SUBF3 R2,R0,R2 ;Z + B1' * Z-1 + B1' * Z-2 -> R2
- ~else~|| ADDF3 R0,~if l_half~R3~else~R2~endif~,R2 ;Z + B1' * Z-1 + Z-2 -> R2
- ~endif~ MPYF3 *AR0--(IR0),R2,R1;Do final gain compensation
- ~if l_half~|| STF R3,*AR2++% ;save Z for next sample
- ~endif~~if l_2sa~|| STF R3,*AR2++% ;save Z for next sample
- ~endif~loopa LDF *AR4++,R2 ;Get y0(n+1) = x(n+1) -> R2
- || STF R1,*AR5++ ;Output filtered data to array
-
- STI AR1,*+AR7(3) ;Update Z-1 address
-
- RETS
- .else
- CALL @40h ;Call location 40 hex to signal error
- .endif
- ~endif~
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; IIR Filter Init Routine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- sects .set ~sects~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;Calling sequence:
- ; CALL ~if option M~init_filter~else~I_~IDT~~endif~
- ;
- ;Input:
- ; AR7 pointer to FIR filter structure
- ;Output:
- ; AR1, AR2, R0, DP, BK, RC, RS, RE destroyed
- ;
- ;
- ~if option M~ .globl I_FILTER
- I_FILTER:
- ~else~ .globl I_~IDT~
- I_~IDT~:
- ~endif~
- LDP fmema
- LDI @fmema,AR2 ;Get address of init memory
- LDI *AR2++,AR1 ;Get address of delay memory Z-1
- STI AR1,*+AR7(3) ;Put in IIR structure
-
- LDF 0.0,R0
- RPTS sects*2-1
- STF R0,*AR1++ ;Zero the delay memory
-
- LDI sects,R0 ;Get size of circular buffer/2
- STI R0,*+AR7(4) ;Put in IIR filter structure
- LDI sects*2,R0 ;Get size of circular buffer
- STI R0,*+AR7(5) ;Put in IIR filter structure
- LDI *AR2++,R0 ;Get address of coef.
- STI R0,*+AR7(2) ;Put address of coef. in IIR structure
- LDI *AR2++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR7(0) ;Put in IIR filter structure
- LDI *AR2++,R0 ;Get address of array filter routine
- STI R0,*+AR7(1) ;Put in IIR filter structure
- ~if one~~else~ LDI ~c_size~-2,R0 ;Get size of coef. buffer-2
- STI R0,*+AR7(7) ;Put in IIR filter structure
- ~endif~
- .if coef_ram
- LDI *+AR7(2),AR1 ;get address of RAM coef
- LDI *AR2++,R0 ;Get first ROM coef
- RPTS ~if one~4~else~~c_size~-1~endif~
- LDI *AR2++,R0
- || STI R0,*AR1++ ;copy ROM coef to RAM coef
- .endif
-
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build Constant Data ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .globl ~if one~IIR_A5~else~_F_~IDT~~endif~ ;address of sample by sample filter
- .globl ~if one~IIR_A5~else~_F_~IDT~~endif~a ;address of array filter
-
- fmema: .word fmem ;address of fmem to be put into fmema
-
- fmem: .word delay_m ;address of delay memory1
- .word coef_m ;address of coef_mem
- .word ~if one~IIR_A5~else~_F_~IDT~~endif~ ;address of sample by sample filter
- .word ~if one~IIR_A5~else~_F_~IDT~~endif~a ;address of array filter
-
- .if coef_ram = 0
- .sect "coef"
- coef_m:
- .endif
- ~if one~~do~; section 1
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B2~ ;b2
- .float ~B0~ ;b0
- .float ~B1~ ;b1
- ~else~~do~~if s_b0=+-b2~ ;section ~section_n~
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B1'~ ;b1'
- ~else~~if s_half~; section ~section_n~
- .float ~A1~ ;a1
- .float ~B1'~ ;b1'
- ~else~; section ~section_n~
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B2'~ ;b2'
- .float ~B1'~ ;b1'
- ~endif~~endif~~loop~
- .float ~A11~ ;a1 of section 1
-
- .float ~gain~ ;final gain
- ~endif~
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Coefficients ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if one~5~else~~c_size~~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",sects*2
-
- .end
- ~end~
- >>>>
- >>>
- 1
- 8
- ~
- TMS320C30; ASM30 interface
- >>>
- ~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; ATLANTA SIGNAL PROCESSORS, INC. ;
- ; ;
- ; TMS320C30 IIR filter realization ;
- ; ;
- ; Assembly Language Interface ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- ~filter_file~
-
- .copy "model.inc" ;This include file specifies different
- ;memory models and ways of assembling
- ;the code.
-
- ;The following structure defines the data structure that the Init routine
- ;initializes. This structure is passed, along with x(n) to the filter
- ;routines.
- ;
- ;struct IIR {
- ; float *filter; ;address of sample by sample filter rout.
- ; float *filtera; ;address of array filter routine
- ; float *coef; ;address of coeficients
- ; float *delay; ;address of Z-1 delays
- ; float BK2; ;size of circular buffer/2
- ; int BK; ;size of circular buffer
- ; int nRPTB; ;number for RPTB instruction
- ; int coef_size ;size of coef. buffer
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; IIR Filter Init Routine ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .text
-
- sects .set ~sects~
-
- ; INITIALIZE THE FILTER memory and the FIR structure
- ;
- ;Calling sequence:
- ; CALL ~if option M~init_filter~else~I_~IDT~~endif~
- ;
- ;Input:
- ; AR7 pointer to FIR filter structure
- ;Output:
- ; AR1, AR2, R0, DP, BK, RC, RS, RE destroyed
- ;
- ;
- ~if option M~ .globl I_FILTER
- I_FILTER:
- ~else~ .globl I_~IDT~
- I_~IDT~:
- ~endif~
- LDP fmema
- LDI @fmema,AR2 ;Get address of init memory
- LDI *AR2++,AR1 ;Get address of delay memory Z-1
- STI AR1,*+AR7(3) ;Put in IIR structure
-
- LDF 0.0,R0
- RPTS sects*2-1
- STF R0,*AR1++ ;Zero the delay memory
-
- LDI ~if one~sects-1~else~~if b0=+-b2~sects-1~else~(sects/2)-1~endif~~endif~,R0 ;Get number for RPTS instruction
- STI R0,*+AR7(6) ;Store in IIR filter structure
- LDI sects,R0 ;Get size of circular buffer/2
- STI R0,*+AR7(4) ;Put in IIR filter structure
- LDI sects*2,R0 ;Get size of circular buffer
- STI R0,*+AR7(5) ;Put in IIR filter structure
- LDI *AR2++,R0 ;Get address of coef.
- STI R0,*+AR7(2) ;Put address of coef. in IIR structure
- LDI *AR2++,R0 ;Get address of sample by sample filter routine
- STI R0,*+AR7(0) ;Put in IIR filter structure
- LDI *AR2++,R0 ;Get address of array filter routine
- STI R0,*+AR7(1) ;Put in IIR filter structure
- LDI sects*~if one~5-2~else~~if b0=+-b2~3~else~4~endif~~endif~,R0 ;Get size of coef. buffer-2
- STI R0,*+AR7(7) ;Put in IIR filter structure
-
- .if coef_ram
- LDI *+AR7(2),AR1 ;get address of RAM coef
- LDI *AR2++,R0 ;Get first ROM coef
- RPTS ~if one~sects*5~else~~if b0=+-b2~sects*3+2~else~sects*4+2~endif~~endif~-1
- LDI *AR2++,R0
- || STI R0,*AR1++ ;copy ROM coef to RAM coef
- .endif
-
- RETS
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Build Constant Data ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- .globl IIR_A~if one~5~else~~if b0=+-b2~4~if b0=-b2~m~endif~~else~45~if odd~o~endif~~endif~~endif~
- .globl IIR_A~if one~5~else~~if b0=+-b2~4~if b0=-b2~m~endif~~else~45~if odd~o~endif~~endif~~endif~a
-
- fmema: .word fmem ;address of fmem to be put into fmema
-
- fmem: .word delay_m ;address of delay memory1
- .word coef_m ;address of coef_mem
- .word IIR_A~if one~5~else~~if b0=+-b2~4~if b0=-b2~m~endif~~else~45~if odd~o~endif~~endif~~endif~ ;address of sample by sample filter
- .word IIR_A~if one~5~else~~if b0=+-b2~4~if b0=-b2~m~endif~~else~45~if odd~o~endif~~endif~~endif~a ;address of array filter routine
-
- .if coef_ram = 0
- .sect "coef"
- coef_m:
- .endif
- ~if one~~do~; section 1
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B2~ ;b2
- .float ~B0~ ;b0
- .float ~B1~ ;b1
- ~else~~if b0=+-b2~~do~ ;section ~section_n~
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B1'~ ;b1'
- ~loop~
- .float ~A11~ ;a1 of section 1
-
- .float ~gain~ ;final gain
- ~else~~do~; section ~section_n~
- .float ~A1~ ;a1
- .float ~A2~ ;a2
- .float ~B2'~ ;b2'
- .float ~B1'~ ;b1'
- ~loop~
- .float ~A11~ ;a1 of section 1
-
- .float ~gain~ ;final gain
- ~endif~~endif~
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Coefficients ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .if coef_ram
- coef_m .usect "C_~IDT~",~if one~sects*5~else~~if b0=+-b2~sects*3+2~else~sects*4+2~endif~~endif~
- .endif
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; ;
- ; Reserve Space for Delay Memory ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;The following section must be unique in name and be aligned on
- ;a ~align~ word address boundary. This can be accomplished with a
- ;LNK30 command file. CGEN produces an example LNK30 command file
- ;named "LINK.CMD".
-
- delay_m .usect "D_~IDT~",sects*2
-
- .end
- ~end~
- >>>>
-