home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / DSPCG2.ZIP / CGEN.PAR
Encoding:
Text File  |  1989-06-28  |  260.4 KB  |  8,078 lines

  1. 1
  2. 5
  3. %
  4. TMS32010; Direct Paged Memory
  5.   2594
  6. 1
  7. 5
  8. %
  9. TMS32010; Direct Paged Memory; Increased Precision
  10.  10228
  11. 1
  12. 6
  13. %
  14. TMS32020; Direct Paged Memory
  15.  18230
  16. 1
  17. 6
  18. %
  19. TMS32020; Direct Paged Memory; Increased Precision
  20.  25603
  21. 1
  22. 6
  23. %
  24. TMS32020; Indexed Memory
  25.  33534
  26. 1
  27. 6
  28. %
  29. TMS32020; Indexed Memory; Increased Precision
  30.  40890
  31. 1
  32. 6
  33. %
  34. TMS32020; Index Memory; Looping Control
  35.  48693
  36. 1
  37. 6
  38. %
  39. TMS32020; Indexed Memory; Looping Control; Increased Precision
  40.  54791
  41. 2
  42. 5
  43. %
  44. TMS32010; Direct Paged Memory
  45.  61095
  46. 2
  47. 6
  48. %
  49. TMS32020/c25; Indexed Memory; MACD realization
  50.  65890
  51. 2
  52. 6
  53. %
  54. TMS32020/c25; Internal Direct Paged Memory
  55.  71234
  56. 2
  57. 6
  58. %
  59. TMS32020/c25; Indexed Memory; Internal Delay Memory
  60.  75728
  61. 2
  62. 6
  63. %
  64. TMS32020/c25; Indexed Memory; Internal or External Memory
  65.  81019
  66. 3
  67. 5
  68. %
  69. TMS32010; Direct Paged Memory
  70.  86062
  71. 3
  72. 6
  73. %
  74. TMS32020/c25; Indexed Memory; MACD realization
  75.  90858
  76. 3
  77. 6
  78. %
  79. TMS32020/c25; Internal Direct Paged Memory
  80.  96203
  81. 3
  82. 6
  83. %
  84. TMS32020/c25; Indexed Memory; Internal Delay Memory
  85. 100698
  86. 3
  87. 6
  88. %
  89. TMS32020/c25; Indexed Memory; Internal or External Memory
  90. 105990
  91. 1
  92. 7
  93. %
  94. TMS320c25; Direct Paged Memory
  95. 111035
  96. 1
  97. 7
  98. %
  99. TMS320c25; Direct Paged Memory; Increased Precision
  100. 118385
  101. 1
  102. 7
  103. %
  104. TMS320c25; Indexed Memory
  105. 126293
  106. 1
  107. 7
  108. %
  109. TMS320c25; Indexed Memory; Increased Precision
  110. 133629
  111. 1
  112. 7
  113. %
  114. TMS320c25; Indexed Memory; Looping Control
  115. 141413
  116. 1
  117. 7
  118. %
  119. TMS320c25; Indexed Memory; Looping Control; Increased Precision
  120. 147504
  121. 3
  122. 8
  123. ~
  124. TMS320C30; 'C' interface; Time Optimize w/ Optimized Filter Routine
  125. 153837
  126. 3
  127. 8
  128. ~
  129. TMS320C30; 'C' interface; Time Optimize
  130. 161881
  131. 3
  132. 8
  133. ~
  134. TMS320C30; 'C' interface; Size Optimize
  135. 167052
  136. 3
  137. 8
  138. ~
  139. TMS320C30; ASM30 interface; Time Optimize w/ Optimized Filter Routine
  140. 173430
  141. 3
  142. 8
  143. ~
  144. TMS320C30; ASM30 interface; Time Optimized
  145. 181107
  146. 3
  147. 8
  148. ~
  149. TMS320C30; ASM30 interface; Size Optimized
  150. 185967
  151. 2
  152. 8
  153. ~
  154. TMS320C30; 'C' interface; Time Optimize w/ Optimized Filter Routine
  155. 192225
  156. 2
  157. 8
  158. ~
  159. TMS320C30; 'C' interface; Time Optimize
  160. 200269
  161. 2
  162. 8
  163. ~
  164. TMS320C30; 'C' interface; Size Optimize
  165. 205440
  166. 2
  167. 8
  168. ~
  169. TMS320C30; ASM30 interface; Time Optimize w/ Optimized Filter Routine
  170. 211818
  171. 2
  172. 8
  173. ~
  174. TMS320C30; ASM30 interface; Time Optimized
  175. 219495
  176. 2
  177. 8
  178. ~
  179. TMS320C30; ASM30 interface; Size Optimized
  180. 224355
  181. 1
  182. 8
  183. ~
  184. TMS320C30; 'C' interface; Optimized Filter Routine
  185. 230596
  186. 1
  187. 8
  188. ~
  189. TMS320C30; 'C' interface
  190. 243029
  191. 1
  192. 8
  193. ~
  194. TMS320C30; ASM30 interface; Optimized Filter Routine
  195. 249007
  196. 1
  197. 8
  198. ~
  199. TMS320C30; ASM30 interface
  200. 260959
  201. >>>>
  202. >>>
  203. 1
  204. 5
  205. %
  206. TMS32010; Direct Paged Memory
  207. >>>
  208. %batch_files 2  %    .title    "%IDT%"        ;Unique Identifier
  209. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  210.     .globl    I%IDT%        ;Name of filter initialization subroutine
  211. %endif%;*************************************************
  212. ;*    ASPI TMS32010 DIGITAL FILTER REALIZATION   *
  213. ;*************************************************
  214. ;*
  215. ;*          %stages%-STAGE RECURSIVE FILTER
  216. ;*            SECOND ORDER SECTIONS
  217. ;*          FILTER GENERATED FROM FILE
  218. %filter_file%
  219. ;*************************************************
  220.     .text
  221. %if option M%%if main%%else%    B    START
  222.     .space    6*16
  223. ;************************************************
  224. ;*         ASPI CARD INITIALIZATION CODE        *
  225. ;************************************************
  226. START:
  227.     LDPK    IOPAGE        ;SET PAGE POINTER
  228.     SOVM            ;SATURATION ARITHMETIC
  229.     CALL    INIT        ;INITIALIZE
  230. ;************************************************
  231. ;*                MAIN I/O LOOP                 *
  232. ;************************************************
  233. DOUT    .set    6        ;D/A OUTPUT
  234. DIN    .set    6        ;A/D INPUT
  235. ;*
  236. ;* The following three instructions are used in conjunction
  237. ;* with the PATCH program to indicate an idle state where no
  238. ;* machine cycles are being used to preform filter operation
  239. ;* (i.e. The time that location 4 is 1 could be used to do
  240. ;* other useful things).  PATCH monitors location 4 to determine
  241. ;* percetage utilization of the processor by the filter.
  242. ;*
  243. LPTS:    LACK    1
  244.     SACL    FILTT
  245.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  246. ;*
  247. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  248.     B    LPTSA        ;BRANCH IF NO CLOCK
  249. ;*
  250. GET    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  251.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  252. ;*
  253. ;* The following three instructions are used in conjuction
  254. ;* with the PATCH program to indicate a busy state or that the
  255. ;* filter is in operation.
  256. ;*
  257.     LACK    0        ;GET CONSTANT FOR IDLE
  258.     SACL    FILTT        ;SAVE FOR OUTPUT
  259.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  260. ;*
  261. ;* The following three instructions are used to determine whether
  262. ;* or not the filter should be active.  In the non-active state the
  263. ;* input data is simply passed to the output.  In the active state
  264. ;* the input data is filtered, then passed to the output.
  265. ;*
  266.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  267.     LAC    FILTT
  268.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  269. ;*
  270.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  271.     B    LPTS        ;LOOP
  272. %endif%%endif%;*************************************************
  273. ;*           DATA MEMORY DEFINITION              *
  274. ;*************************************************
  275. ;*     CONTAINS:
  276. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  277. ;*          STORAGE FOR COEFFICIENTS
  278. ;*          STORAGE FOR DELAY ELEMENTS
  279. ;*************************************************
  280. ;*
  281. ;* FILTER INPUT and OUTPUT STORAGE
  282. ;*
  283. %if option M%FILTT    .set    0        ;FILTER TEMPORY DATA
  284. VSAMPL    .set    1        ;FILTER INPUT/OUTPUT DATA
  285. IOPAGE    .set    0
  286. %else%    .global    FILTT,V%IDT%
  287. %endif%;*
  288. COEF:
  289. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  290. ;*
  291. %section%;*
  292. ;*  SECOND-ORDER SECTION # %section_n%
  293. ;*
  294. %if B0<%%else%    .word    %B0%        ;B0
  295. %endif%%if B1<>%    .word    %B1%        ;B1
  296. %endif%%if A1<%%else%    .word    %A1%        ;A1
  297. %endif%%if half%%else%    .word    %A2%        ;A2
  298. %if B2<%%else%    .word    %B2%        ;B2
  299. %endif%%endif%%loop%;*
  300. ;*
  301.     .sect    "X%IDT%"
  302. ;* DELAY STORAGE DATA STORAGE AREA
  303. ;*
  304. DELAY:
  305. %section%Z%section_n%1:    .space    1*16
  306. %if half%%else%Z%section_n%2:    .space    1*16
  307. %endif%%loop%;*
  308. ;*
  309. ;* COEFFICIENT DATA STORAGE AREA
  310. ;*
  311. FDATA:
  312. %section%;*
  313. %if B0<%%else%B%section_n%0:    .space    1*16    ;B0
  314. %endif%%if B1<>%B%section_n%1:    .space    1*16    ;B1
  315. %endif%%if A1<%%else%A%section_n%1:    .space    1*16    ;A1
  316. %endif%%if half%%else%A%section_n%2:    .space    1*16    ;A2
  317. %if B2<%%else%B%section_n%2:    .space    1*16    ;B2
  318. %endif%%endif%%loop%;*
  319. ;*
  320. ;*
  321.     .text
  322. ;*************************************************
  323. ;*       FILTER INITIALIZATION SUBROUTINE        *
  324. ;*************************************************
  325. %if option M%INIT%else%I%IDT%%endif%:    LACK    1        ;GET A 1
  326.     SACL    FILTT        ;TEMPORARY SAVE
  327.     LT    FILTT        ;LOAD 1 IN T
  328.     MPYK    COEF
  329.     PAC            ;AC HAS ADDRESS OF COEF DATA
  330.     MPYK    1        ;1 INTO P
  331.     LARK    0,FDATA        ;POINTER TO DATA MEMORY
  332. %if data%    LARK    1,%points%        ;COUNT FOR NUMBER OF POINTS
  333. ILP:    LARP    0        ;RESET AR TO 0
  334.     TBLR    *+,1        ;TRANSFER DATA VALUE
  335.     APAC            ;INCREMENT POINTER
  336.     BANZ    ILP        ;LOOP
  337. %endif%    LARK    1,%ndelay%        ;NUMBER OF DELAY POINTS
  338.     ZAC            ;CLEAR ACCUMULATOR
  339.     LARK    0,Z011        ;POINT TO DELAY MEMORY
  340. ILPA:    LARP    0        ;RESET AR TO 0
  341.     SACL    *+,0,1        ;CLEAR DATA VALUE
  342.     BANZ    ILPA        ;LOOP
  343.     RET            ;INIT RETURN
  344. ;*************************************************
  345. ;*              FILTER SUBROUTINE                *
  346. ;*************************************************
  347. ;*   ASSUMPTIONS:
  348. ;*      SATURATION ARITHMETIC MODE IS ON
  349. ;*      PAGE REGISTER IS SET TO COEF. PAGE
  350. ;*
  351. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  352. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  353. ;*
  354. ;*************************************************
  355. %if option M%FILTER%else%F%IDT%%endif%:
  356. %section%;*
  357. ;* SECOND-ORDER FILTER SECTION # %section_n%
  358. ;*
  359. %filtin%%if half%    LT    FILTT        ;GET SCALED INPUT
  360. %if B0<%    MPYK    %B0%        ;P = (B0 * INPUT)/2
  361. %else%    MPY    B%section_n%0        ;P = (B0 * INPUT)/2
  362. %endif%    ZALH    Z%section_n%1
  363.     ADDH    Z%section_n%1        ;AC = Z-1
  364. %if B1<>%    APAC
  365.     APAC            ;AC = Z-1 + (B0 * INPUT)
  366.     MPY    B%section_n%1        ;P = (B1 * INPUT)/2
  367. %else%    APAC
  368.     APAC            ;AC = Z-1 + (B0 * INPUT)
  369. %endif%    SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  370. %if B1<>%    PAC
  371. %endif%    LT    %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>%        ;AC = (B1 * INPUT)/2%endif%
  372. %if A1<%    MPYK    %A1%        ;P = (A1 * OUTPUT)/2
  373. %else%    MPY    A%section_n%1        ;P = (A1 * OUTPUT)/2
  374. %endif%    %if B1<>%A%endif%PAC            ;AC = ((B1 * INPUT) + (A1 * OUTPUT))/2
  375. %if A1shft%    APAC
  376. %endif%    SACH    Z%section_n%1        ;Save in Z-1
  377. %else 
  378.  
  379. %%if B1<>%    LT    FILTT        ;GET SCALED INPUT
  380. %if B0<%    MPYK    %B0%        ;P = (B0 * INPUT)/2
  381. %else%    MPY    B%section_n%0        ;P = (B0 * INPUT)/2
  382. %endif%    ZALH    Z%section_n%1
  383.     ADDH    Z%section_n%1        ;AC = Z-1
  384.     APAC
  385.     APAC                ;AC = Z-1 + (B0 * INPUT)
  386.     MPY    B%section_n%1            ;P = (B1 * INPUT)/2
  387.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  388.     PAC
  389.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = (B1 * INPUT)/2
  390.     ADDH    Z%section_n%2        ;AC = (Z-2 + (B1 * INPUT))/2
  391. %if A1<%    MPYK    %A1%        ;P = (A1 * OUTPUT)/2
  392. %else%    MPY    A%section_n%1        ;P = (A1 * OUTPUT)/2
  393. %endif%%if A1shft%    APAC
  394. %endif%    APAC            ;AC = (Z-2 + (B1 * INPUT) + (A1 * OUTPUT))/2
  395.     MPY    A%section_n%2        ;P = (A2 * OUTPUT)/2
  396.     SACH    Z%section_n%1        ;Save in Z-1
  397.     PAC            ;AC = A2 * OUTPUT
  398.     LT    FILTT
  399. %if B2<%    MPYK    %B2%        ;P = (B2 * INPUT)/2
  400. %else%    MPY    B%section_n%2        ;P = (B2 * INPUT)/2
  401. %endif%    APAC            ;AC = ((B2 * INPUT) + (A2 * OUTPUT))/2
  402.      SACH    Z%section_n%2    ;Save in Z-2
  403. %else 
  404.  
  405.  
  406. %    LT    FILTT        ;GET SCALED INPUT
  407. %if B0<%    MPYK    %B0%        ;P = (B0 * INPUT)/2
  408. %else%    MPY    B%section_n%0        ;P = (B0 * INPUT)/2
  409. %endif%    ZALH    Z%section_n%1
  410.     ADDH    Z%section_n%1        ;AC = Z-1
  411.     APAC
  412.     APAC            ;AC = Z-1 + (B0 * INPUT)
  413.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  414.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;Get OUTPUT
  415.     ZALH    Z%section_n%2        ;AC = (Z-2)/2
  416. %if A1<%    MPYK    %A1%        ;P = (A1 * OUTPUT)/2
  417. %else%    MPY    A%section_n%1        ;P = (A1 * OUTPUT)/2
  418. %endif%%if A1shft%    APAC
  419. %endif%    APAC
  420.     MPY    A%section_n%2        ;AC = ((B1 * INPUT) + (A1 * OUTPUT))/2
  421. *                ;P = (A2 * OUTPUT)/2
  422.     SACH    Z%section_n%1    ;Save in Z-1
  423.     PAC        ;AC = A2 * OUTPUT
  424.     LT    FILTT
  425. %if B2<%    MPYK    %B2%        ;P = (B2 * INPUT)/2
  426. %else%    MPY    B%section_n%2        ;P = (B2 * INPUT)/2
  427. %endif%    APAC            ;AC = ((B2 * INPUT) + (A2 * OUTPUT))/2
  428.      SACH    Z%section_n%2    ;Save in Z-2
  429. %endif%%endif%%loop%*
  430.     RET            ;RETURN
  431.     .end
  432. %end%
  433. >>>>
  434. >>>
  435. 1
  436. 5
  437. %
  438. TMS32010; Direct Paged Memory; Increased Precision
  439. >>>
  440. %batch_files 2  %    .title    "%IDT%"        ;Unique Identifier
  441. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  442.     .globl    I%IDT%        ;Name of filter initialization subroutine
  443. %endif%;*************************************************
  444. ;*    ASPI TMS32010 DIGITAL FILTER REALIZATION   *
  445. ;*************************************************
  446. ;*       INCREASED PRECISION IMPLEMENTATION
  447. ;*
  448. ;*          %stages%-STAGE RECURSIVE FILTER
  449. ;*            SECOND ORDER SECTIONS
  450. ;*          FILTER GENERATED FROM FILE
  451. %filter_file%
  452. ;*************************************************
  453.     .text
  454. %if option M%%if main%%else%    B    START
  455.     .space    6*16
  456. ;************************************************
  457. ;*         ASPI CARD INITIALIZATION CODE        *
  458. ;************************************************
  459. START:
  460.     LDPK    IOPAGE        ;SET PAGE POINTER
  461.     SOVM            ;SATURATION ARITHMETIC
  462.     CALL    INIT        ;INITIALIZE
  463. ;************************************************
  464. ;*                MAIN I/O LOOP                 *
  465. ;************************************************
  466. DOUT    .set    6        ;D/A OUTPUT
  467. DIN    .set    6        ;A/D INPUT
  468. ;*
  469. ;* The following three instructions are used in conjunction
  470. ;* with the PATCH program to indicate an idle state where no
  471. ;* machine cycles are being used to preform filter operation
  472. ;* (i.e. The time that location 4 is 1 could be used to do
  473. ;* other useful things).  PATCH monitors location 4 to determine
  474. ;* percetage utilization of the processor by the filter.
  475. ;*
  476. LPTS:    LACK    1
  477.     SACL    FILTT
  478.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  479. ;*
  480. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  481.     B    LPTSA        ;BRANCH IF NO CLOCK
  482. ;*
  483. GET    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  484.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  485. ;*
  486. ;* The following three instructions are used in conjuction
  487. ;* with the PATCH program to indicate a busy state or that the
  488. ;* filter is in operation.
  489. ;*
  490.     LACK    0        ;GET CONSTANT FOR IDLE
  491.     SACL    FILTT        ;SAVE FOR OUTPUT
  492.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  493. ;*
  494. ;* The following three instructions are used to determine whether
  495. ;* or not the filter should be active.  In the non-active state the
  496. ;* input data is simply passed to the output.  In the active state
  497. ;* the input data is filtered, then passed to the output.
  498. ;*
  499.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  500.     LAC    FILTT
  501.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  502. ;*
  503.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  504.     B    LPTS        ;LOOP
  505. %endif%%endif%;*************************************************
  506. ;*           DATA MEMORY DEFINITION              *
  507. ;*************************************************
  508. ;*     CONTAINS:
  509. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  510. ;*          STORAGE FOR COEFFICIENTS
  511. ;*          STORAGE FOR DELAY ELEMENTS
  512. ;*************************************************
  513. ;*
  514. ;* FILTER INPUT and OUTPUT STORAGE
  515. ;*
  516. %if option M%FILTT    .set    0        ;FILTER TEMPORY DATA
  517. VSAMPL    .set    1        ;FILTER INPUT/OUTPUT DATA
  518. IOPAGE    .set    0
  519. %else%    .global    FILTT,V%IDT%
  520. %endif%;*
  521. COEF:
  522. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  523. ;*
  524. %section%;*
  525. ;*  SECOND-ORDER SECTION # %section_n%
  526. ;*
  527. %if B0<%%else%    .word    %B0%        ;B0
  528. %endif%%if B1<>%    .word    %B1%        ;B1
  529. %endif%%if A1<%%else%    .word    %A1%        ;A1
  530. %endif%%if half%%else%    .word    %A2%        ;A2
  531. %if B2<%%else%    .word    %B2%        ;B2
  532. %endif%%endif%%loop%;*
  533. ;*
  534.     .sect    "X%IDT%"
  535. ;* DELAY STORAGE DATA STORAGE AREA
  536. ;*
  537. DELAY:
  538. %section%Z%section_n%1:    .space    1*16
  539. L%section_n%1:    .space    1*16
  540. %if half%%else%Z%section_n%2:    .space    1*16
  541. L%section_n%2:    .space    1*16
  542. %endif%%loop%;*
  543. ;*
  544. ;* COEFFICIENT DATA STORAGE AREA
  545. ;*
  546. FDATA:
  547. %section%;*
  548. %if B0<%%else%B%section_n%0:    .space    1*16    ;B0
  549. %endif%%if B1<>%B%section_n%1:    .space    1*16    ;B1
  550. %endif%%if A1<%%else%A%section_n%1:    .space    1*16    ;A1
  551. %endif%%if half%%else%A%section_n%2:    .space    1*16    ;A2
  552. %if B2<%%else%B%section_n%2:    .space    1*16    ;B2
  553. %endif%%endif%%loop%;*
  554. ;*
  555. ;*
  556.     .text
  557. ;*************************************************
  558. ;*       FILTER INITIALIZATION SUBROUTINE        *
  559. ;*************************************************
  560. %if option M%INIT%else%I%IDT%%endif%:    LACK    1        ;GET A 1
  561.     SACL    FILTT        ;TEMPORARY SAVE
  562.     LT    FILTT        ;LOAD 1 IN T
  563.     MPYK    COEF
  564.     PAC            ;AC HAS ADDRESS OF COEF DATA
  565.     MPYK    1        ;1 INTO P
  566.     LARK    0,FDATA        ;POINTER TO DATA MEMORY
  567. %if data%    LARK    1,%points%        ;COUNT FOR NUMBER OF POINTS
  568. ILP:    LARP    0        ;RESET AR TO 0
  569.     TBLR    *+,1        ;TRANSFER DATA VALUE
  570.     APAC            ;INCREMENT POINTER
  571.     BANZ    ILP        ;LOOP
  572. %endif%    LARK    1,%ndelay%+%ndelay%+1        ;NUMBER OF DELAY POINTS
  573.     ZAC            ;CLEAR ACCUMULATOR
  574.     LARK    0,Z011        ;POINT TO DELAY MEMORY
  575. ILPA:    LARP    0        ;RESET AR TO 0
  576.     SACL    *+,0,1        ;CLEAR DATA VALUE
  577.     BANZ    ILPA        ;LOOP
  578.     RET            ;INIT RETURN
  579. ;*************************************************
  580. ;*              FILTER SUBROUTINE                *
  581. ;*************************************************
  582. ;*   ASSUMPTIONS:
  583. ;*      SATURATION ARITHMETIC MODE IS ON
  584. ;*      PAGE REGISTER IS SET TO COEF. PAGE
  585. ;*
  586. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  587. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  588. ;*
  589. ;*************************************************
  590. %if option M%FILTER%else%F%IDT%%endif%:
  591. %section%;*
  592. ;* SECOND-ORDER FILTER SECTION # %section_n%
  593. ;*
  594. %filtin%%if half%    LT    FILTT        ;GET SCALED INPUT
  595. %if B0<%    MPYK    %B0%        ;P = (B0 * INPUT)/2
  596. %else%    MPY    B%section_n%0        ;P = (B0 * INPUT)/2
  597. %endif%    ZALH    Z%section_n%1
  598.     ADDS    L%section_n%1
  599.     ADDH    Z%section_n%1
  600.     ADDS    L%section_n%1        ;AC = Z-1
  601. %if B1<>%    APAC
  602.     APAC            ;AC = Z-1 + (B0 * INPUT)
  603.     MPY    B%section_n%1        ;P = (B1 * INPUT)/2
  604. %else%    APAC
  605.     APAC            ;AC = Z-1 + (B0 * INPUT)
  606. %endif%    SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  607. %if B1<>%    PAC
  608. %endif%    LT    %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>%        ;AC = (B1 * INPUT)/2%endif%
  609. %if A1<%    MPYK    %A1%        ;P = (A1 * OUTPUT)/2
  610. %else%    MPY    A%section_n%1        ;P = (A1 * OUTPUT)/2
  611. %endif%    %if B1<>%A%endif%PAC            ;AC = ((B1 * INPUT) + (A1 * OUTPUT))/2
  612. %if A1shft%    APAC
  613. %endif%    SACH    Z%section_n%1        ;Save in Z-1
  614.     SACL    L%section_n%1
  615. %else 
  616.  
  617. %%if B1<>%    LT    FILTT        ;GET SCALED INPUT
  618. %if B0<%    MPYK    %B0%        ;P = (B0 * INPUT)/2
  619. %else%    MPY    B%section_n%0        ;P = (B0 * INPUT)/2
  620. %endif%    ZALH    Z%section_n%1
  621.     ADDS    L%section_n%1
  622.     ADDH    Z%section_n%1
  623.     ADDS    L%section_n%1        ;AC = Z-1
  624.     APAC
  625.     APAC            ;AC = Z-1 + (B0 * INPUT)
  626.     MPY    B%section_n%1        ;P = (B1 * INPUT)/2
  627.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  628.     PAC
  629.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = (B1 * INPUT)/2
  630.     ADDH    Z%section_n%2
  631.     ADDS    L%section_n%2        ;AC = (Z-2 + (B1 * INPUT))/2
  632. %if A1<%    MPYK    %A1%        ;P = (A1 * OUTPUT)/2
  633. %else%    MPY    A%section_n%1        ;P = (A1 * OUTPUT)/2
  634. %endif%%if A1shft%    APAC
  635. %endif%    APAC            ;AC = (Z-2 + (B1 * INPUT) + (A1 * OUTPUT))/2
  636.     MPY    A%section_n%2        ;P = (A2 * OUTPUT)/2
  637.     SACH    Z%section_n%1        ;Save in Z-1
  638.     SACL    L%section_n%1
  639.     PAC            ;AC = A2 * OUTPUT
  640.     LT    FILTT
  641. %if B2<%    MPYK    %B2%        ;P = (B2 * INPUT)/2
  642. %else%    MPY    B%section_n%2        ;P = (B2 * INPUT)/2
  643. %endif%    APAC            ;AC = ((B2 * INPUT) + (A2 * OUTPUT))/2
  644.      SACH    Z%section_n%2        ;Save in Z-2
  645.     SACL    L%section_n%2
  646. %else 
  647.  
  648.  
  649. %    LT    FILTT        ;GET SCALED INPUT
  650. %if B0<%    MPYK    %B0%        ;P = (B0 * INPUT)/2
  651. %else%    MPY    B%section_n%0        ;P = (B0 * INPUT)/2
  652. %endif%    ZALH    Z%section_n%1
  653.     ADDS    L%section_n%1
  654.     ADDH    Z%section_n%1
  655.     ADDS    L%section_n%1        ;AC = Z-1
  656.     APAC
  657.     APAC            ;AC = Z-1 + (B0 * INPUT)
  658.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  659.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;Get OUTPUT
  660.     ZALH    Z%section_n%2
  661.     ADDS    L%section_n%2        ;AC = (Z-2)/2
  662. %if A1<%    MPYK    %A1%        ;P = (A1 * OUTPUT)/2
  663. %else%    MPY    A%section_n%1        ;P = (A1 * OUTPUT)/2
  664. %endif%%if A1shft%    APAC
  665. %endif%    APAC            ;AC = ((B1 * INPUT) + (A1 * OUTPUT) + Z-2)/2
  666.     MPY    A%section_n%2        ;P = (A2 * OUTPUT)/2
  667.     SACH    Z%section_n%1    ;Save in Z-1
  668.     SACL    L%section_n%1
  669.     PAC            ;AC = A2 * OUTPUT
  670.     LT    FILTT
  671. %if B2<%    MPYK    %B2%        ;P = (B2 * INPUT)/2
  672. %else%    MPY    B%section_n%2        ;P = (B2 * INPUT)/2
  673. %endif%    APAC            ;AC = ((B2 * INPUT) + (A2 * OUTPUT))/2
  674.      SACH    Z%section_n%2        ;Save in Z-2
  675.     SACL    L%section_n%2
  676. %endif%%endif%%loop%;*
  677.     RET            ;RETURN
  678.     .end
  679. %end%
  680. >>>>
  681. >>>
  682. 1
  683. 6
  684. %
  685. TMS32020; Direct Paged Memory
  686. >>>
  687. %batch_files 2  %    .title    "%IDT%"        ;Unique Identifier
  688. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  689.     .globl    I%IDT%        ;Name of filter initialization subroutine
  690. %endif%;*************************************************
  691. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  692. ;*************************************************
  693. ;*          %stages%-STAGE RECURSIVE FILTER
  694. ;*            SECOND ORDER SECTIONS
  695. ;*          FILTER GENERATED FROM FILE
  696. %filter_file%
  697. ;*
  698. ;*************************************************
  699.     .text
  700. %if option M%%if main%%else%    B    START
  701.     .space    254*16        ;Programs start at 100 Hex.
  702. ;************************************************
  703. ;*         ASPI CARD INITIALIZATION CODE        *
  704. ;************************************************
  705. START:
  706.     CNFD            ;SET BANK 0 TO DATA MEMORY
  707.     LDPK    IOPAGE        ;SET PAGE POINTER
  708.     SOVM            ;SATURATION ARITHMETIC
  709.     SSXM            ;SET SIGN EXTEND MODE ON
  710.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  711.     CALL    INIT        ;INITIALIZE
  712. ;************************************************
  713. ;*                MAIN I/O LOOP                 *
  714. ;************************************************
  715. DOUT    .set    6        ;D/A OUTPUT
  716. DIN    .set    6        ;A/D INPUT
  717. ;*
  718. ;* The following three instructions are used in conjunction
  719. ;* with the PATCH program to indicate an idle state where no
  720. ;* machine cycles are being used to preform filter operation
  721. ;* (i.e. The time that location 4 is 1 could be used to do
  722. ;* other useful things).  PATCH monitors location 4 to determine
  723. ;* percetage utilization of the processor by the filter.
  724. ;*
  725. LPTS:    LACK    1
  726.     SACL    FILTT
  727.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  728. ;*
  729. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  730.     B    LPTSA        ;BRANCH IF NO CLOCK
  731. ;*
  732. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  733.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  734. ;*
  735. ;* The following three instructions are used in conjuction
  736. ;* with the PATCH program to indicate a busy state or that the
  737. ;* filter is in operation.
  738. ;*
  739.     LACK    0        ;GET CONSTANT FOR IDLE
  740.     SACL    FILTT        ;SAVE FOR OUTPUT
  741.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  742. ;*
  743. ;* The following three instructions are used to determine whether
  744. ;* or not the filter should be active.  In the non-active state the
  745. ;* input data is simply passed to the output.  In the active state
  746. ;* the input data is filtered, then passed to the output.
  747. ;*
  748.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  749.     LAC    FILTT
  750.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  751. ;*
  752.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  753.     B    LPTS        ;LOOP
  754. %endif%%endif%;*************************************************
  755. ;*           DATA MEMORY DEFINITION              *
  756. ;*************************************************
  757. ;*     CONTAINS:
  758. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  759. ;*          STORAGE FOR COEFFICIENTS
  760. ;*          STORAGE FOR DELAY ELEMENTS
  761. ;*************************************************
  762. ;*
  763. ;* FILTER INPUT and OUTPUT STORAGE
  764. ;*
  765. %if option M%FILTT    .set    0        ;TEMPORARY FILTER DATA
  766. VSAMPL    .set    1        ;INPUT/OUTPUT FILTER DATA
  767. IOPAGE    .set    6
  768. %else%    .globl    FILTT,V%IDT%
  769. %endif%;*
  770. COEF:
  771. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  772. ;*
  773. %section%;*
  774. ;*
  775. ;*  SECOND-ORDER SECTION # %section_n%
  776. ;*
  777. %if B0<%%else%    .word    %B0%        ;B0
  778. %endif%%if B1<>%    .word    %B1%        ;B1
  779. %endif%%if A1<%%else%    .word    %A1%        ;A1
  780. %endif%%if half%%else%    .word    %A2%        ;A2
  781. %if B2<%%else%    .word    %B2%        ;B2
  782. %endif%%endif%%loop%;*
  783. ;*
  784.     .sect    "X%IDT%"
  785. ;* DELAY STORAGE DATA STORAGE AREA
  786. ;*
  787. DELAY:
  788. %section%Z%section_n%1:    .space    1*16
  789. %if half%%else%Z%section_n%2:    .space    1*16
  790. %endif%%loop%;*
  791. ;*
  792. ;* COEFFICIENT DATA STORAGE AREA
  793. ;*
  794. FDATA:
  795. %section%;*
  796. %if B0<%%else%B%section_n%0:    .space    1*16    ;B0
  797. %endif%%if B1<>%B%section_n%1:    .space    1*16    ;B1
  798. %endif%%if A1<%%else%A%section_n%1:    .space    1*16    ;A1
  799. %endif%%if half%%else%A%section_n%2:    .space    1*16    ;A2
  800. %if B2<%%else%B%section_n%2:    .space    1*16    ;B2
  801. %endif%%endif%%loop%;*
  802. ;*
  803. ;*
  804.     .text
  805. ;*************************************************
  806. ;*       FILTER INITIALIZATION SUBROUTINE        *
  807. ;*************************************************
  808. %if option M%INIT%else%I%IDT%%endif%:
  809.     LARP    0        ;POINT TO AR0
  810.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  811. %if data%    RPTK    %points%        ;COUNT FOR NUMBER OF POINTS
  812.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  813. %endif%    ZAC            ;CLEAR ACCUMULATOR
  814.     LRLK    0,DELAY
  815.     RPTK    %ndelay%        ;NUMBER OF DELAY POINTS
  816.     SACL    *+        ;CLEAR DATA VALUE
  817.     RET            ;INIT RETURN
  818. ;*************************************************
  819. ;*              FILTER SUBROUTINE                *
  820. ;*************************************************
  821. ;*   ASSUMPTIONS:
  822. ;*      SATURATION ARITHMETIC MODE IS ON
  823. ;*      P REGISTER OUTPUT SHIFT = 1
  824. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  825. ;*      SIGN EXTEND MODE IS ON
  826. ;*
  827. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  828. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  829. ;*
  830. ;*************************************************
  831. ;*
  832. %if option M%FILTER%else%F%IDT%%endif%:
  833. %section%;*
  834. ;* SECOND-ORDER FILTER SECTION # %section_n%
  835. ;*
  836. %filtin%%if half%    LT    FILTT        ;GET SCALED INPUT
  837. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  838. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  839. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  840. %if B1<>%    APAC
  841.     MPY    B%section_n%1        ;AC = Z-1 + (B0 * INPUT)
  842. ;*                ;P = B1 * INPUT
  843. %else%    APAC            ;AC = Z-1 + (B0 * INPUT)
  844. %endif%    SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  845.     LT%if B1<>%P%endif%    %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>%        ;AC = B1 * INPUT%endif%
  846. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  847. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  848. %endif%    %if B1<>%A%endif%PAC            ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  849. %if A1shft%    APAC
  850. %endif%    SACH    Z%section_n%1        ;Save in Z-1
  851. %else 
  852.  
  853. %%if B1<>%    LT    FILTT        ;GET SCALED INPUT
  854. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  855. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  856. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  857.     APAC
  858.     MPY    B%section_n%1        ;AC = Z-1 + (B0 * INPUT)
  859. ;*                ;P = B1 * INPUT
  860.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  861.     LTP    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = B1 * INPUT 
  862.     ADDH    Z%section_n%2        ;AC = Z-2 + (B1 * INPUT)
  863. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  864. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  865. %endif%%if A1shft%    APAC
  866. %endif%    APAC
  867.     MPY    A%section_n%2        ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
  868. ;*                ;P = A2 * OUTPUT
  869.     SACH    Z%section_n%1        ;Save in Z-1
  870.     LTP    FILTT        ;AC = A2 * OUTPUT
  871. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  872. %else%    MPY    B%section_n%2        ;P = B2 * INPUT
  873. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  874.      SACH    Z%section_n%2    ;Save in Z-2
  875. %else 
  876.  
  877.  
  878. %    LT    FILTT        ;GET SCALED INPUT
  879. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  880. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  881. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  882.     APAC            ;AC = Z-1 + (B0 * INPUT)
  883.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  884.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;Get OUTPUT
  885.     ZALH    Z%section_n%2        ;AC = Z-2
  886. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  887. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  888. %endif%%if A1shft%    APAC
  889. %endif%    APAC
  890.     MPY    A%section_n%2        ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  891. ;*                ;P = A2 * OUTPUT
  892.     SACH    Z%section_n%1    ;Save in Z-1
  893.     LTP    FILTT        ;AC = A2 * OUTPUT
  894. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  895. %else%    MPY    B%section_n%2        ;P = B2 * INPUT
  896. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  897.      SACH    Z%section_n%2    ;Save in Z-2
  898. %endif%%endif%%loop%*
  899.     RET            ;RETURN
  900.     .end
  901. %end%
  902. >>>>
  903. >>>
  904. 1
  905. 6
  906. %
  907. TMS32020; Direct Paged Memory; Increased Precision
  908. >>>
  909. %batch_files 2  %    .title    "%IDT%"        ;Unique Identifier
  910. %if option M%%else%    .globl    F%IDT%        ;*Name of filter subroutine
  911.     .globl    I%IDT%        ;Name of filter initialization subroutine
  912. %endif%;*************************************************
  913. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  914. ;*************************************************
  915. ;*       INCREASED PRECISION IMPLEMENTATION
  916. ;*
  917. ;*          %stages%-STAGE RECURSIVE FILTER
  918. ;*            SECOND ORDER SECTIONS
  919. ;*          FILTER GENERATED FROM FILE
  920. %filter_file%
  921. ;*
  922. ;*************************************************
  923.     .text
  924. %if option M%%if main%%else%    B    START
  925.     .space    254*16        ;Programs start at 100 Hex.
  926. ;************************************************
  927. ;*         ASPI CARD INITIALIZATION CODE        *
  928. ;************************************************
  929. START:
  930.     CNFD            ;SET BANK 0 TO DATA MEMORY
  931.     LDPK    IOPAGE        ;SET PAGE POINTER
  932.     SOVM            ;SATURATION ARITHMETIC
  933.     SSXM            ;SET SIGN EXTEND MODE ON
  934.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  935.     CALL    INIT        ;INITIALIZE
  936. ;************************************************
  937. ;*                MAIN I/O LOOP                 *
  938. ;************************************************
  939. DOUT    EQU    6        ;D/A OUTPUT
  940. DIN    EQU    6        ;A/D INPUT
  941. ;*
  942. ;* The following three instructions are used in conjunction
  943. ;* with the PATCH program to indicate an idle state where no
  944. ;* machine cycles are being used to preform filter operation
  945. ;* (i.e. The time that location 4 is 1 could be used to do
  946. ;* other useful things).  PATCH monitors location 4 to determine
  947. ;* percetage utilization of the processor by the filter.
  948. ;*
  949. LPTS:    LACK    1
  950.     SACL    FILTT
  951.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  952. ;*
  953. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  954.     B    LPTSA        ;BRANCH IF NO CLOCK
  955. ;*
  956. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  957.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  958. ;*
  959. ;* The following three instructions are used in conjuction
  960. ;* with the PATCH program to indicate a busy state or that the
  961. ;* filter is in operation.
  962. ;*
  963.     LACK    0        ;GET CONSTANT FOR IDLE
  964.     SACL    FILTT        ;SAVE FOR OUTPUT
  965.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  966. ;*
  967. ;* The following three instructions are used to determine whether
  968. ;* or not the filter should be active.  In the non-active state the
  969. ;* input data is simply passed to the output.  In the active state
  970. ;* the input data is filtered, then passed to the output.
  971. ;*
  972.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  973.     LAC    FILTT
  974.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  975. ;*
  976.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  977.     B    LPTS        ;LOOP
  978. %endif%%endif%;*************************************************
  979. ;*           DATA MEMORY DEFINITION              *
  980. ;*************************************************
  981. ;*     CONTAINS:
  982. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  983. ;*          STORAGE FOR COEFFICIENTS
  984. ;*          STORAGE FOR DELAY ELEMENTS
  985. ;*************************************************
  986. ;*
  987. ;* FILTER INPUT and OUTPUT STORAGE
  988. ;*
  989. %if option M%FILTT    .set    0        ;TEMPORARY FILTER DATA
  990. VSAMPL    .set    1        ;INPUT/OUTPUT FILTER DATA
  991. IOPAGE    .set    6
  992. %else%    .globl    FILTT,V%IDT%
  993. %endif%;*
  994. COEF:
  995. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  996. ;*
  997. %section%;*
  998. ;*
  999. ;*  SECOND-ORDER SECTION # %section_n%
  1000. ;*
  1001. %if B0<%%else%    .word    %B0%        ;B0
  1002. %endif%%if B1<>%    .word    %B1%        ;B1
  1003. %endif%%if A1<%%else%    .word    %A1%        ;A1
  1004. %endif%%if half%%else%    .word    %A2%        ;A2
  1005. %if B2<%%else%    .word    %B2%        ;B2
  1006. %endif%%endif%%loop%;*
  1007. ;*
  1008.     .sect    "X%IDT%"
  1009. ;* DELAY STORAGE DATA STORAGE AREA
  1010. ;*
  1011. DELAY:
  1012. %section%Z%section_n%1:    .space    1*16
  1013. L%section_n%1:    .space    1*16
  1014. %if half%%else%Z%section_n%2:    .space    1*16
  1015. L%section_n%2:    .space    1*16
  1016. %endif%%loop%;*
  1017. ;*
  1018. ;* COEFFICIENT DATA STORAGE AREA
  1019. ;*
  1020. FDATA:
  1021. %section%;*
  1022. %if B0<%%else%B%section_n%0:    .space    1*16    ;B0
  1023. %endif%%if B1<>%B%section_n%1:    .space    1*16    ;B1
  1024. %endif%%if A1<%%else%A%section_n%1:    .space    1*16    ;A1
  1025. %endif%%if half%%else%A%section_n%2:    .space    1*16    ;A2
  1026. %if B2<%%else%B%section_n%2:    .space    1*16    ;B2
  1027. %endif%%endif%%loop%;*
  1028. ;*
  1029.     .text
  1030. ;*************************************************
  1031. ;*       FILTER INITIALIZATION SUBROUTINE        *
  1032. ;*************************************************
  1033. %if option M%INIT%else%I%IDT%%endif%:
  1034.     LARP    0        ;POINT TO AR0
  1035.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  1036. %if data%    RPTK    %points%        ;COUNT FOR NUMBER OF POINTS
  1037.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  1038. %endif%    ZAC            ;CLEAR ACCUMULATOR
  1039.     LRLK    0,DELAY
  1040.     RPTK    %ndelay%+%ndelay%+1        ;NUMBER OF DELAY POINTS
  1041.     SACL    *+        ;CLEAR DATA VALUE
  1042.     RET            ;INIT RETURN
  1043. ;*************************************************
  1044. ;*              FILTER SUBROUTINE                *
  1045. ;*************************************************
  1046. ;*   ASSUMPTIONS:
  1047. ;*      SATURATION ARITHMETIC MODE IS ON
  1048. ;*      P REGISTER OUTPUT SHIFT = 1
  1049. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  1050. ;*      SIGN EXTEND MODE IS ON
  1051. ;*
  1052. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  1053. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  1054. ;*
  1055. ;*************************************************
  1056. ;*
  1057. %if option M%FILTER%else%F%IDT%%endif%:
  1058. %section%;*
  1059. ;* SECOND-ORDER FILTER SECTION # %section_n%
  1060. ;*
  1061. %filtin%%if half%    LT    FILTT        ;GET SCALED INPUT
  1062. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  1063. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  1064. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  1065.     ADDS    L%section_n%1        ;ADD in least significant
  1066. %if B1<>%    APAC
  1067.     MPY    B%section_n%1        ;AC = Z-1 + (B0 * INPUT)
  1068. ;*                ;P = B1 * INPUT
  1069. %else%    APAC            ;AC = Z-1 + (B0 * INPUT)
  1070. %endif%    SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  1071.     LT%if B1<>%P%endif%    %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>%        ;AC = B1 * INPUT%endif%
  1072. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  1073. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  1074. %endif%    %if B1<>%A%endif%PAC            ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  1075. %if A1shft%    APAC
  1076. %endif%    SACH    Z%section_n%1        ;Save in Z-1
  1077.     SACL    L%section_n%1        ;Save least significant
  1078. %else 
  1079.  
  1080. %%if B1<>%    LT    FILTT        ;GET SCALED INPUT
  1081. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  1082. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  1083. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  1084.     ADDS    L%section_n%1        ;ADD in least significant
  1085.     APAC
  1086.     MPY    B%section_n%1        ;AC = Z-1 + (B0 * INPUT)
  1087. ;*                ;P = B1 * INPUT
  1088.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  1089.     LTP    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = B1 * INPUT 
  1090.     ADDH    Z%section_n%2        ;AC = Z-2 + (B1 * INPUT)
  1091.     ADDS    L%section_n%2        ;ADD in least significant
  1092. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  1093. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  1094. %endif%%if A1shft%    APAC
  1095. %endif%    APAC
  1096.     MPY    A%section_n%2        ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
  1097. ;*                ;P = A2 * OUTPUT
  1098.     SACH    Z%section_n%1        ;Save in Z-1
  1099.     SACL    L%section_n%1        ;Save least significant
  1100.     LTP    FILTT        ;AC = A2 * OUTPUT
  1101. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  1102. %else%    MPY    B%section_n%2        ;P = B2 * INPUT
  1103. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  1104.      SACH    Z%section_n%2        ;Save in Z-2
  1105.     SACL    L%section_n%2        ;Save least significant
  1106. %else 
  1107.  
  1108.  
  1109. %    LT    FILTT        ;GET SCALED INPUT
  1110. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  1111. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  1112. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  1113.     ADDS    L%section_n%1        ;ADD in least significant
  1114.     APAC            ;AC = Z-1 + (B0 * INPUT)
  1115.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  1116.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;Get OUTPUT
  1117.     ZALH    Z%section_n%2        ;AC = Z-2
  1118.     ADDS    L%section_n%2        ;ADD in least significant
  1119. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  1120. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  1121. %endif%%if A1shft%    APAC
  1122. %endif%    APAC
  1123.     MPY    A%section_n%2        ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  1124. ;*                ;P = A2 * OUTPUT
  1125.     SACH    Z%section_n%1        ;Save in Z-1
  1126.     SACL    L%section_n%1        ;Save least significant
  1127.     LTP    FILTT        ;AC = A2 * OUTPUT
  1128. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  1129. %else%    MPY    B%section_n%2        ;P = B2 * INPUT
  1130. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  1131.      SACH    Z%section_n%2        ;Save in Z-2
  1132.     SACL    L%section_n%2        ;Save least significant
  1133. %endif%%endif%%loop%*
  1134.     RET            ;RETURN
  1135.     .end
  1136. %end%
  1137. >>>>
  1138. >>>
  1139. 1
  1140. 6
  1141. %
  1142. TMS32020; Indexed Memory
  1143. >>>
  1144. %batch_files 0  %    .title    "%IDT%"            ;UNIQUE NAME
  1145. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  1146.     .globl    I%IDT%        ;Name of filter initialization subroutine
  1147. %endif%;*************************************************
  1148. ;*   ASPI TMS32020 DIGITAL FILTER REALIZATION    *
  1149. ;*************************************************
  1150. ;*          %stages%-STAGE RECURSIVE FILTER
  1151. ;*            SECOND ORDER SECTIONS
  1152. ;*          FILTER GENERATED FROM FILE
  1153. %filter_file%
  1154. ;*
  1155. ;*************************************************
  1156.     .text
  1157. %if option M%%if main%%else%    B    START
  1158.     .space    254*16        ;Programs start at 100 Hex.
  1159. ;************************************************
  1160. ;*         ASPI CARD INITIALIZATION CODE        *
  1161. ;************************************************
  1162. START:
  1163.     CNFD            ;SET BANK 0 TO DATA MEMORY
  1164.     LDPK    IOPAGE        ;SET PAGE POINTER
  1165.     SOVM            ;SATURATION ARITHMETIC
  1166.     SSXM            ;SET SIGN EXTEND MODE ON
  1167.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  1168.     CALL    INIT        ;INITIALIZE
  1169. ;************************************************
  1170. ;*                MAIN I/O LOOP                 *
  1171. ;************************************************
  1172. DOUT    .set    6        ;D/A OUTPUT
  1173. DIN    .set    6        ;A/D INPUT
  1174. ;*
  1175. ;* The following three instructions are used in conjunction
  1176. ;* with the PATCH program to indicate an idle state where no
  1177. ;* machine cycles are being used to preform filter operation
  1178. ;* (i.e. The time that location 4 is 1 could be used to do
  1179. ;* other useful things).  PATCH monitors location 4 to determine
  1180. ;* percetage utilization of the processor by the filter.
  1181. ;*
  1182. LPTS:    LACK    1
  1183.     SACL    FILTT
  1184.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  1185. ;*
  1186. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  1187.     B    LPTSA        ;BRANCH IF NO CLOCK
  1188. ;*
  1189. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  1190.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  1191. ;*
  1192. ;* The following three instructions are used in conjuction
  1193. ;* with the PATCH program to indicate a busy state or that the
  1194. ;* filter is in operation.
  1195. ;*
  1196.     LACK    0        ;GET CONSTANT FOR IDLE
  1197.     SACL    FILTT        ;SAVE FOR OUTPUT
  1198.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  1199. ;*
  1200. ;* The following three instructions are used to determine whether
  1201. ;* or not the filter should be active.  In the non-active state the
  1202. ;* input data is simply passed to the output.  In the active state
  1203. ;* the input data is filtered, then passed to the output.
  1204. ;*
  1205.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  1206.     LAC    FILTT
  1207.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  1208. ;*
  1209.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  1210.     B    LPTS        ;LOOP
  1211. %endif%%endif%;*************************************************
  1212. ;*           DATA MEMORY DEFINITION              *
  1213. ;*************************************************
  1214. ;*     CONTAINS:
  1215. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  1216. ;*          STORAGE FOR COEFFICIENTS
  1217. ;*          STORAGE FOR DELAY ELEMENTS
  1218. ;*************************************************
  1219. ;*
  1220. ;* FILTER INPUT and OUTPUT STORAGE
  1221. ;*
  1222. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  1223. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  1224. IOPAGE    .set    0
  1225. %else%    .globl    FILTT,V%IDT%
  1226. %endif%;*
  1227. COEF:
  1228. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  1229. ;*
  1230. %section%;*
  1231. ;*
  1232. ;*  SECOND-ORDER SECTION # %section_n%
  1233. ;*
  1234. %if B0<%%else%    .word    %B0%        ;B0
  1235. %endif%%if B1<>%    .word    %B1%        ;B1
  1236. %endif%%if A1<%%else%    .word    %A1%        ;A1
  1237. %endif%%if half%%else%    .word    %A2%        ;A2
  1238. %if B2<%%else%    .word    %B2%        ;B2
  1239. %endif%%endif%%loop%;*
  1240. ;*
  1241.     .sect    "X%IDT%"
  1242. ;*
  1243. ;* COEFFICIENT DATA STORAGE AREA
  1244. ;*
  1245. FDATA:    .space    (%points%+1)*16
  1246. ;*
  1247. ;* DELAY STORAGE DATA STORAGE AREA
  1248. ;*
  1249. DELAY:    .space    (%ndelay%+1)*16
  1250. ;*
  1251. ;*
  1252.     .text
  1253. ;*************************************************
  1254. ;*       FILTER INITIALIZATION SUBROUTINE        *
  1255. ;*************************************************
  1256. %if option M%INIT%else%I%IDT%%endif%:
  1257.     LARP    0        ;POINT TO AR0
  1258.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  1259. %if data%    RPTK    %points%        ;COUNT FOR NUMBER OF POINTS
  1260.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  1261. %endif%    ZAC            ;CLEAR ACCUMULATOR
  1262.     LRLK    0,DELAY
  1263.     RPTK    %ndelay%        ;NUMBER OF DELAY POINTS
  1264.     SACL    *+        ;CLEAR DATA VALUE
  1265.     RET            ;INIT RETURN
  1266. ;*************************************************
  1267. ;*              FILTER SUBROUTINE                *
  1268. ;*************************************************
  1269. ;*   ASSUMPTIONS:
  1270. ;*      SATURATION ARITHMETIC MODE IS ON
  1271. ;*      P REGISTER OUTPUT SHIFT = 1
  1272. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  1273. ;*      SIGN EXTEND MODE IS ON
  1274. ;*
  1275. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  1276. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  1277. ;*
  1278. ;*************************************************
  1279. COEFAR    .set    1        ;Use AR1 to point to COEF's
  1280. DELAR    .set    2        ;Use AR2 to point to DELAY's
  1281. ;*
  1282. %if option M%FILTER%else%F%IDT%%endif%:
  1283.     LRLK    COEFAR,FDATA    ;Load COEF AR with beginning of COEF's
  1284.     LRLK    DELAR,DELAY    ;Load DELAY AR with beginning of DELAY's
  1285.     LARP    %if B10<%DELAR%else%COEFAR%endif%        ;Select Proper AR for initial use
  1286. %section%;*
  1287. ;* SECOND-ORDER FILTER SECTION # %section_n%
  1288. ;*
  1289. %filtin%%if half%    LT    FILTT        ;GET SCALED INPUT
  1290. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  1291. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  1292. %endif%    ZALH    *,COEFAR    ;AC = Z-1
  1293. %if B1<>%    APAC
  1294.     MPY    *+,%if A1<%DELAR%else%COEFAR%endif%    ;AC = Z-1 + (B0 * INPUT)
  1295. ;*                ;P = B1 * INPUT
  1296. %else%    APAC            ;AC = Z-1 + (B0 * INPUT)
  1297. %endif%    SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  1298.     LT%if B1<>%P%endif%    %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>%        ;AC = B1 * INPUT%endif%
  1299. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  1300. %else%    MPY    *+,DELAR    ;P = A1 * OUTPUT
  1301. %endif%    %if B1<>%A%endif%PAC            ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  1302. %if A1shft%    APAC
  1303. %endif%    SACH    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save in Z-1
  1304. %else 
  1305.  
  1306. %%if B1<>%    LT    FILTT        ;GET SCALED INPUT
  1307. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  1308. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  1309. %endif%    ZALH    *+,COEFAR    ;AC = Z-1
  1310.     APAC
  1311.     MPY    *+,DELAR    ;AC = Z-1 + (B0 * INPUT)
  1312. ;*                ;P = B1 * INPUT
  1313.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  1314.     LTP    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = B1 * INPUT 
  1315.     ADDH    *-,COEFAR    ;AC = Z-2 + (B1 * INPUT)
  1316. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  1317. %else%    MPY    *+        ;P = A1 * OUTPUT
  1318. %endif%%if A1shft%    APAC
  1319. %endif%    APAC
  1320.     MPY    *+,DELAR    ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
  1321. ;*                ;P = A2 * OUTPUT
  1322.     SACH    *+,0,%if B2<%DELAR%else%COEFAR%endif%    ;Save in Z-1
  1323.     LTP    FILTT        ;AC = A2 * OUTPUT
  1324. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  1325. %else%    MPY    *+,DELAR    ;P = B2 * INPUT
  1326. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  1327.      SACH    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save in Z-2
  1328. %else 
  1329.  
  1330.  
  1331. %    LT    FILTT        ;GET SCALED INPUT
  1332. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  1333. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  1334. %endif%    ZALH    *+,DELAR    ;AC = Z-1
  1335.     APAC            ;AC = Z-1 + (B0 * INPUT)
  1336.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  1337.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;Get OUTPUT
  1338.     ZALH    *-,COEFAR    ;AC = Z-2
  1339. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  1340. %else%    MPY    *+        ;P = A1 * OUTPUT
  1341. %endif%%if A1shft%    APAC
  1342. %endif%    APAC
  1343.     MPY    *+,DELAR    ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  1344. ;*                ;P = A2 * OUTPUT
  1345.     SACH    *+,0,%if B2<%DELAR%else%COEFAR%endif%    ;Save in Z-1
  1346.     LTP    FILTT        ;AC = A2 * OUTPUT
  1347. %if B2<%    MPYK    %B2%    ;P = B2 * INPUT
  1348. %else%    MPY    *+,DELAR    ;P = B2 * INPUT
  1349. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  1350.      SACH    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save in Z-2
  1351. %endif%%endif%%loop%;*
  1352.     RET            ;RETURN
  1353.     .end
  1354. %end%
  1355. >>>>
  1356. >>>
  1357. 1
  1358. 6
  1359. %
  1360. TMS32020; Indexed Memory; Increased Precision
  1361. >>>
  1362. %batch_files 0  %    .title    "%IDT%"            ;UNIQUE NAME
  1363. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  1364.     .globl    I%IDT%        ;Name of filter initialization subroutine
  1365. %endif%;*************************************************
  1366. ;*   ASPI TMS32020 DIGITAL FILTER REALIZATION    *
  1367. ;*************************************************
  1368. ;*             Increased Precision
  1369. ;*          %stages%-STAGE RECURSIVE FILTER
  1370. ;*            SECOND ORDER SECTIONS
  1371. ;*          FILTER GENERATED FROM FILE
  1372. %filter_file%
  1373. ;*
  1374. ;*************************************************
  1375.     .text
  1376. %if option M%%if main%%else%    B    START
  1377.     .space    254*16        ;Programs start at 100 Hex.
  1378. ;************************************************
  1379. ;*         ASPI CARD INITIALIZATION CODE        *
  1380. ;************************************************
  1381. START:
  1382.     CNFD            ;SET BANK 0 TO DATA MEMORY
  1383.     LDPK    IOPAGE        ;SET PAGE POINTER
  1384.     SOVM            ;SATURATION ARITHMETIC
  1385.     SSXM            ;SET SIGN EXTEND MODE ON
  1386.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  1387.     CALL    INIT        ;INITIALIZE
  1388. ;************************************************
  1389. ;*                MAIN I/O LOOP                 *
  1390. ;************************************************
  1391. DOUT    .set    6        ;D/A OUTPUT
  1392. DIN    .set    6        ;A/D INPUT
  1393. ;*
  1394. ;* The following three instructions are used in conjunction
  1395. ;* with the PATCH program to indicate an idle state where no
  1396. ;* machine cycles are being used to preform filter operation
  1397. ;* (i.e. The time that location 4 is 1 could be used to do
  1398. ;* other useful things).  PATCH monitors location 4 to determine
  1399. ;* percetage utilization of the processor by the filter.
  1400. ;*
  1401. LPTS:    LACK    1
  1402.     SACL    FILTT
  1403.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  1404. ;*
  1405. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  1406.     B    LPTSA        ;BRANCH IF NO CLOCK
  1407. ;*
  1408. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  1409.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  1410. ;*
  1411. ;* The following three instructions are used in conjuction
  1412. ;* with the PATCH program to indicate a busy state or that the
  1413. ;* filter is in operation.
  1414. ;*
  1415.     LACK    0        ;GET CONSTANT FOR IDLE
  1416.     SACL    FILTT        ;SAVE FOR OUTPUT
  1417.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  1418. ;*
  1419. ;* The following three instructions are used to determine whether
  1420. ;* or not the filter should be active.  In the non-active state the
  1421. ;* input data is simply passed to the output.  In the active state
  1422. ;* the input data is filtered, then passed to the output.
  1423. ;*
  1424.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  1425.     LAC    FILTT
  1426.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  1427. ;*
  1428.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  1429.     B    LPTS        ;LOOP
  1430. %endif%%endif%;*************************************************
  1431. ;*           DATA MEMORY DEFINITION              *
  1432. ;*************************************************
  1433. ;*     CONTAINS:
  1434. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  1435. ;*          STORAGE FOR COEFFICIENTS
  1436. ;*          STORAGE FOR DELAY ELEMENTS
  1437. ;*************************************************
  1438. ;*
  1439. ;* FILTER INPUT and OUTPUT STORAGE
  1440. ;*
  1441. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  1442. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  1443. IOPAGE    .set    0
  1444. %else%    .globl    FILTT,V%IDT%
  1445. %endif%;*
  1446. COEF:
  1447. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  1448. ;*
  1449. %section%;*
  1450. ;*
  1451. ;*  SECOND-ORDER SECTION # %section_n%
  1452. ;*
  1453. %if B0<%%else%    .word    %B0%        ;B0
  1454. %endif%%if B1<>%    .word    %B1%        ;B1
  1455. %endif%%if A1<%%else%    .word    %A1%        ;A1
  1456. %endif%%if half%%else%    .word    %A2%        ;A2
  1457. %if B2<%%else%    .word    %B2%        ;B2
  1458. %endif%%endif%%loop%;*
  1459. ;*
  1460.     .sect    "X%IDT%"
  1461. ;*
  1462. ;* COEFFICIENT DATA STORAGE AREA
  1463. ;*
  1464. FDATA:    .space    (%points%+1)*16
  1465. ;*
  1466. ;* DELAY STORAGE DATA STORAGE AREA
  1467. ;*
  1468. DELAY:    .space    (%ndelay%+%ndelay%+2)*16
  1469. ;*
  1470. ;*
  1471.     .text
  1472. ;*************************************************
  1473. ;*       FILTER INITIALIZATION SUBROUTINE        *
  1474. ;*************************************************
  1475. %if option M%INIT%else%I%IDT%%endif%:
  1476.     LARP    0        ;POINT TO AR0
  1477.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  1478. %if data%    RPTK    %points%        ;COUNT FOR NUMBER OF POINTS
  1479.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  1480. %endif%    ZAC            ;CLEAR ACCUMULATOR
  1481.     LRLK    0,DELAY
  1482.     RPTK    %ndelay%+%ndelay%+1        ;NUMBER OF DELAY POINTS
  1483.     SACL    *+        ;CLEAR DATA VALUE
  1484.     RET            ;INIT RETURN
  1485. ;*************************************************
  1486. ;*              FILTER SUBROUTINE                *
  1487. ;*************************************************
  1488. ;*   ASSUMPTIONS:
  1489. ;*      SATURATION ARITHMETIC MODE IS ON
  1490. ;*      P REGISTER OUTPUT SHIFT = 1
  1491. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  1492. ;*      SIGN EXTEND MODE IS ON
  1493. ;*
  1494. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  1495. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  1496. ;*
  1497. ;*************************************************
  1498. COEFAR    .set    1        ;Use AR1 to point to COEF's
  1499. DELAR    .set    2        ;Use AR2 to point to DELAY's
  1500. ;*
  1501. %if option M%FILTER%else%F%IDT%%endif%:
  1502.     LARK    0,3        ;Set up AR0 for subtract
  1503.     LRLK    COEFAR,FDATA    ;Load COEF AR with beginning of COEF's
  1504.     LRLK    DELAR,DELAY    ;Load DELAY AR with beginning of DELAY's
  1505.     LARP    %if B10<%DELAR%else%COEFAR%endif%        ;Select Proper AR for initial use
  1506. %section%;*
  1507. ;* SECOND-ORDER FILTER SECTION # %section_n%
  1508. ;*
  1509. %filtin%%if half%    LT    FILTT        ;GET SCALED INPUT
  1510. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  1511. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  1512. %endif%    ZALH    *+        ;AC = Z-1
  1513.     ADDS    *-,COEFAR    ;ADD Least Significant
  1514. %if B1<>%    APAC
  1515.     MPY    *+,%if A1<%DELAR%else%COEFAR%endif%    ;AC = Z-1 + (B0 * INPUT)
  1516. ;*                ;P = B1 * INPUT
  1517. %else%    APAC            ;AC = Z-1 + (B0 * INPUT)
  1518. %endif%    SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  1519.     LT%if B1<>%P%endif%    %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>%        ;AC = B1 * INPUT%endif%
  1520. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  1521. %else%    MPY    *+,DELAR    ;P = A1 * OUTPUT
  1522. %endif%    %if B1<>%A%endif%PAC            ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  1523. %if A1shft%    APAC
  1524. %endif%    SACH    *+        ;Save in Z-1
  1525.     SACL    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save Least Significant
  1526. %else 
  1527.  
  1528. %%if B1<>%    LT    FILTT        ;GET SCALED INPUT
  1529. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  1530. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  1531. %endif%    ZALH    *+        ;AC = Z-1
  1532.     ADDS    *+,COEFAR    ;ADD in least significant
  1533.     APAC
  1534.     MPY    *+,DELAR    ;AC = Z-1 + (B0 * INPUT)
  1535. ;*                ;P = B1 * INPUT
  1536.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  1537.     LTP    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = B1 * INPUT 
  1538.     ADDH    *+        ;AC = Z-2 + (B1 * INPUT)
  1539.     ADDS    *0-,COEFAR    ;ADD in least significant
  1540. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  1541. %else%    MPY    *+        ;P = A1 * OUTPUT
  1542. %endif%%if A1shft%    APAC
  1543. %endif%    APAC
  1544.     MPY    *+,DELAR    ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
  1545. ;*                ;P = A2 * OUTPUT
  1546.     SACH    *+        ;Save in Z-1
  1547.     SACL    *+,0,%if B2<%DELAR%else%COEFAR%endif%    ;Save least significant
  1548.     LTP    FILTT        ;AC = A2 * OUTPUT
  1549. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  1550. %else%    MPY    *+,DELAR    ;P = B2 * INPUT
  1551. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  1552.      SACH    *+        ;Save in Z-2
  1553.     SACL    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save least significant
  1554. %else 
  1555.  
  1556.  
  1557. %    LT    FILTT        ;GET SCALED INPUT
  1558. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  1559. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  1560. %endif%    ZALH    *+        ;AC = Z-1
  1561.     ADDS    *+,DELAR    ;ADD in least significant
  1562.     APAC            ;AC = Z-1 + (B0 * INPUT)
  1563.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  1564.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;Get OUTPUT
  1565.     ZALH    *+        ;AC = Z-2
  1566.     ADDS    *0-,COEFAR    ;ADD in least significant
  1567. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  1568. %else%    MPY    *+        ;P = A1 * OUTPUT
  1569. %endif%%if A1shft%    APAC
  1570. %endif%    APAC
  1571.     MPY    *+,DELAR    ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  1572. ;*                ;P = A2 * OUTPUT
  1573.     SACH    *+        ;Save in Z-1
  1574.     SACL    *+,0,%if B2<%DELAR%else%COEFAR%endif%    ;Save least significant
  1575.     LTP    FILTT        ;AC = A2 * OUTPUT
  1576. %if B2<%    MPYK    %B2%    ;P = B2 * INPUT
  1577. %else%    MPY    *+,DELAR    ;P = B2 * INPUT
  1578. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  1579.      SACH    *+        ;Save in Z-2
  1580.     SACL    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save least significant
  1581. %endif%%endif%%loop%;*
  1582.     RET            ;RETURN
  1583.     .end
  1584. %end%
  1585. >>>>
  1586. >>>
  1587. 1
  1588. 6
  1589. %
  1590. TMS32020; Index Memory; Looping Control
  1591. >>>
  1592. %batch_files 0  %    .title    "%IDT%"            ;UNIQUE NAME
  1593. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  1594.     .globl    I%IDT%        ;Name of filter initialization subroutine
  1595. %endif%;*************************************************
  1596. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  1597. ;*************************************************
  1598. ;*               LOOPING CONTROL
  1599. ;*          %stages%-STAGE RECURSIVE FILTER
  1600. ;*            SECOND ORDER SECTIONS
  1601. ;*          FILTER GENERATED FROM FILE
  1602. %filter_file%
  1603. ;*
  1604. ;*************************************************
  1605.     .text
  1606. %if option M%%if main%%else%    B    START
  1607.     .space    254*16        ;Programs start at 100 Hex.
  1608. ;************************************************
  1609. ;*         ASPI CARD INITIALIZATION CODE        *
  1610. ;************************************************
  1611. START:
  1612.     CNFD            ;SET BANK 0 TO DATA MEMORY
  1613.     LDPK    IOPAGE        ;SET PAGE POINTER to I/O PAGE
  1614.     SOVM            ;SATURATION ARITHMETIC
  1615.     SSXM            ;SET SIGN EXTEND MODE ON
  1616.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  1617.     CALL    INIT        ;INITIALIZE
  1618. ;************************************************
  1619. ;*                MAIN I/O LOOP                 *
  1620. ;************************************************
  1621. DOUT    .set    6        ;D/A OUTPUT
  1622. DIN    .set    6        ;A/D INPUT
  1623. ;*
  1624. ;* The following three instructions are used in conjunction
  1625. ;* with the PATCH program to indicate an idle state where no
  1626. ;* machine cycles are being used to preform filter operation
  1627. ;* (i.e. The time that location 4 is 1 could be used to do
  1628. ;* other useful things).  PATCH monitors location 4 to determine
  1629. ;* percetage utilization of the processor by the filter.
  1630. ;*
  1631. LPTS:    LACK    1
  1632.     SACL    FILTT
  1633.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  1634. ;*
  1635. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  1636.     B    LPTSA        ;BRANCH IF NO CLOCK
  1637. ;*
  1638. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  1639.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  1640. ;*
  1641. ;* The following three instructions are used in conjuction
  1642. ;* with the PATCH program to indicate a busy state or that the
  1643. ;* filter is in operation.
  1644. ;*
  1645.     LACK    0        ;GET CONSTANT FOR IDLE
  1646.     SACL    FILTT        ;SAVE FOR OUTPUT
  1647.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  1648. ;*
  1649. ;* The following three instructions are used to determine whether
  1650. ;* or not the filter should be active.  In the non-active state the
  1651. ;* input data is simply passed to the output.  In the active state
  1652. ;* the input data is filtered, then passed to the output.
  1653. ;*
  1654.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  1655.     LAC    FILTT
  1656.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  1657. ;*
  1658.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  1659.     B    LPTS        ;LOOP
  1660. %endif%%endif%;*************************************************
  1661. ;*           DATA MEMORY DEFINITION              *
  1662. ;*************************************************
  1663. ;*     CONTAINS:
  1664. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  1665. ;*          INITIALIZATION FOR COEFFICIENTS
  1666. ;*          STORAGE FOR COEFFICIENTS
  1667. ;*          STORAGE FOR DELAY ELEMENTS
  1668. ;*************************************************
  1669. ;*
  1670. ;* FILTER INPUT and OUTPUT STORAGE
  1671. ;*
  1672. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  1673. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  1674. IOPAGE    .set    0
  1675. %else%    .globl    FILTT,V%IDT%
  1676. %endif%;*
  1677. COEF:
  1678. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  1679. ;*
  1680.     DATA    %stages%-1        ;*Number of stages -1 to follow
  1681. %section%;*
  1682. ;*
  1683. ;*  SECOND-ORDER SECTION # %section_n%
  1684. ;*
  1685. %tunable%
  1686.     DATA    %b_scale%        ;BLOCK FLOATING POINT SHIFT
  1687.     DATA    %B0%        ;B0
  1688.     DATA    %B1%        ;B1
  1689.     DATA    %A1%        ;A1
  1690.     DATA    %A2%        ;A2
  1691.     DATA    %B2%        ;B2
  1692. %loop%;*
  1693. ;*
  1694.     .sect    "X%IDT%"
  1695. ;*
  1696. ;*COEFICIENT DATA STORAGE AREA (including block floating point shifts
  1697. ;*                              and storage for the number of stages)
  1698. ;*
  1699. FDATA:    .space    (%points%+2)*16
  1700. ;*
  1701. ;* DELAY STORAGE STORAGE AREA
  1702. ;*
  1703. DELAY:    .space    (%ndelay%+1)*16
  1704. ;*
  1705. ;*
  1706.     .text
  1707. ;*************************************************
  1708. ;*       FILTER INITIALIZATION SUBROUTINE        *
  1709. ;*************************************************
  1710. %if option M%INIT%else%I%IDT%%endif%:
  1711.     LARP    0        ;POINT TO AR0
  1712.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  1713.     RPTK    %points%+1        ;COUNT FOR NUMBER OF POINTS
  1714.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  1715.     ZAC            ;CLEAR ACCUMULATOR
  1716.     LRLK    0,DELAY
  1717.     RPTK    %ndelay%        ;NUMBER OF DELAY POINTS
  1718.     SACL    *+        ;CLEAR DATA VALUE
  1719.     RET            ;INIT RETURN
  1720. ;*************************************************
  1721. ;*              FILTER SUBROUTINE                *
  1722. ;*************************************************
  1723. ;*   ASSUMPTIONS:
  1724. ;*      SATURATION ARITHMETIC MODE IS ON
  1725. ;*      P REGISTER OUTPUT SHIFT = 1
  1726. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  1727. ;*          PAGE.
  1728. ;*      SIGN EXTEND MODE IS ON
  1729. ;*
  1730. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  1731. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  1732. ;*
  1733. ;*************************************************
  1734. COEFAR    .set    1        ;Use AR1 to point to COEF's
  1735. DELAR    .set    2        ;Use AR2 to point to DELAY's
  1736. LOOPAR    .set    3        ;Use AR3 as loop counter
  1737. ;*
  1738. %if option M%FILTER%else%F%IDT%%endif%:
  1739.     LRLK    COEFAR,FDATA    ;Load COEF AR with beginning of COEF's
  1740.     LRLK    DELAR,DELAY    ;Load DELAY AR with beginning of DELAY's
  1741.     LARP    COEFAR        ;Point to COEF AR
  1742.     LAR    LOOPAR,*+    ;SET SECTION LOOP COUNT
  1743. ;*
  1744. ;* SECOND-ORDER FILTER SECTION LOOP
  1745. ;*
  1746.     LT    *+        ;GET SCALE FACTOR
  1747. FLOOP:
  1748.     LACT    %if option M%VSAMPL%else%V%IDT%%endif%        ;GET and SCALE INPUT
  1749.     SACH    FILTT,4        ;SAVE SCALED INPUT
  1750.     LT    FILTT        ;GET SCALED INPUT
  1751.     MPY    *+,DELAR    ;P = B0 * INPUT
  1752.     PAC            ;AC = B0 * INPUT
  1753.     ADDH    *+,COEFAR    ;AC = (B0 * INPUT) + Z-1
  1754.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;SAVE IN OUTPUT
  1755.     MPY    *+,DELAR    ;P = B1 * OUTPUT
  1756.     ZALH    *-,COEFAR    ;AC = Z-2
  1757.     LTA    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = (B1 * INPUT) + Z-2, GET CURRENT OUTPUT
  1758.     MPY    *+,DELAR    ;P = A1/2 * OUTPUT
  1759.     APAC
  1760.     APAC            ;AC = (A1 * OUTPUT) + (B1 * INPUT) + Z-2
  1761.     SACH    *+,0,COEFAR    ;SAVE Z-1
  1762.     MPY    *+        ;P = A2 * OUTPUT
  1763.     LTP    FILTT        ;AC = A2 * OUTPUT, GET SCALED INPUT
  1764.     MPY    *+        ;P = B2 * INPUT
  1765.     LTA    *+,DELAR    ;AC = (A2 * OUTPUT) + (B2 * INPUT)
  1766. ;*                ; & GET NEXT SCALE FACTOR
  1767.     SACH    *+,0,LOOPAR    ;SAVE Z-2
  1768. ;*
  1769.     BANZ    FLOOP,*-,COEFAR    ;REPEAT FOR ALL SECTIONS
  1770. ;*
  1771.     RET            ;RETURN
  1772.     .end
  1773. %end%
  1774. >>>>
  1775. >>>
  1776. 1
  1777. 6
  1778. %
  1779. TMS32020; Indexed Memory; Looping Control; Increased Precision
  1780. >>>
  1781. %batch_files 0  %    .title    "%IDT%"            ;UNIQUE NAME
  1782. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  1783.     .globl    I%IDT%        ;Name of filter initialization subroutine
  1784. %endif%;*************************************************
  1785. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  1786. ;*************************************************
  1787. ;*             Increased Precision
  1788. ;*               LOOPING CONTROL
  1789. ;*          %stages%-STAGE RECURSIVE FILTER
  1790. ;*            SECOND ORDER SECTIONS
  1791. ;*          FILTER GENERATED FROM FILE
  1792. %filter_file%
  1793. ;*
  1794. ;*************************************************
  1795.     .text
  1796. %if option M%%if main%%else%    B    START
  1797.     .space    254*16        ;Programs start at 100 Hex.
  1798. ;************************************************
  1799. ;*         ASPI CARD INITIALIZATION CODE        *
  1800. ;************************************************
  1801. START:
  1802.     CNFD            ;SET BANK 0 TO DATA MEMORY
  1803.     LDPK    IOPAGE        ;SET PAGE POINTER to I/O PAGE
  1804.     SOVM            ;SATURATION ARITHMETIC
  1805.     SSXM            ;SET SIGN EXTEND MODE ON
  1806.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  1807.     CALL    INIT        ;INITIALIZE
  1808. ;************************************************
  1809. ;*                MAIN I/O LOOP                 *
  1810. ;************************************************
  1811. DOUT    .set    6        ;D/A OUTPUT
  1812. DIN    .set    6        ;A/D INPUT
  1813. ;*
  1814. ;* The following three instructions are used in conjunction
  1815. ;* with the PATCH program to indicate an idle state where no
  1816. ;* machine cycles are being used to preform filter operation
  1817. ;* (i.e. The time that location 4 is 1 could be used to do
  1818. ;* other useful things).  PATCH monitors location 4 to determine
  1819. ;* percetage utilization of the processor by the filter.
  1820. ;*
  1821. LPTS:    LACK    1
  1822.     SACL    FILTT
  1823.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  1824. ;*
  1825. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  1826.     B    LPTSA        ;BRANCH IF NO CLOCK
  1827. ;*
  1828. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  1829.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  1830. ;*
  1831. ;* The following three instructions are used in conjuction
  1832. ;* with the PATCH program to indicate a busy state or that the
  1833. ;* filter is in operation.
  1834. ;*
  1835.     LACK    0        ;GET CONSTANT FOR IDLE
  1836.     SACL    FILTT        ;SAVE FOR OUTPUT
  1837.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  1838. ;*
  1839. ;* The following three instructions are used to determine whether
  1840. ;* or not the filter should be active.  In the non-active state the
  1841. ;* input data is simply passed to the output.  In the active state
  1842. ;* the input data is filtered, then passed to the output.
  1843. ;*
  1844.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  1845.     LAC    FILTT
  1846.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  1847. ;*
  1848.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  1849.     B    LPTS        ;LOOP
  1850. %endif%%endif%;*************************************************
  1851. ;*           DATA MEMORY DEFINITION              *
  1852. ;*************************************************
  1853. ;*     CONTAINS:
  1854. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  1855. ;*          INITIALIZATION FOR COEFFICIENTS
  1856. ;*          STORAGE FOR COEFFICIENTS
  1857. ;*          STORAGE FOR DELAY ELEMENTS
  1858. ;*************************************************
  1859. ;*
  1860. ;* FILTER INPUT and OUTPUT STORAGE
  1861. ;*
  1862. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  1863. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  1864. IOPAGE    .set    0
  1865. %else%    .globl    FILTT,V%IDT%
  1866. %endif%;*
  1867. COEF:
  1868. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  1869. ;*
  1870.     DATA    %stages%-1        ;*Number of stages -1 to follow
  1871. %section%;*
  1872. ;*
  1873. ;*  SECOND-ORDER SECTION # %section_n%
  1874. ;*
  1875. %tunable%
  1876.     DATA    %b_scale%        ;BLOCK FLOATING POINT SHIFT
  1877.     DATA    %B0%        ;B0
  1878.     DATA    %B1%        ;B1
  1879.     DATA    %A1%        ;A1
  1880.     DATA    %A2%        ;A2
  1881.     DATA    %B2%        ;B2
  1882. %loop%;*
  1883. ;*
  1884.     .sect    "X%IDT%"
  1885. ;*
  1886. ;*COEFICIENT DATA STORAGE AREA (including block floating point shifts
  1887. ;*                              and storage for the number of stages)
  1888. ;*
  1889. FDATA:    .space    (%points%+2)*16
  1890. ;*
  1891. ;* DELAY STORAGE STORAGE AREA
  1892. ;*
  1893. DELAY:    .space    (%ndelay%+%ndelay%+2)*16
  1894. ;*
  1895. ;*
  1896.     .text
  1897. ;*************************************************
  1898. ;*       FILTER INITIALIZATION SUBROUTINE        *
  1899. ;*************************************************
  1900. %if option M%INIT%else%I%IDT%%endif%:
  1901.     LARP    0        ;POINT TO AR0
  1902.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  1903.     RPTK    %points%+1        ;COUNT FOR NUMBER OF POINTS
  1904.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  1905.     ZAC            ;CLEAR ACCUMULATOR
  1906.     LRLK    0,DELAY
  1907.     RPTK    %ndelay%+%ndelay%+1        ;NUMBER OF DELAY POINTS
  1908.     SACL    *+        ;CLEAR DATA VALUE
  1909.     RET            ;INIT RETURN
  1910. ;*************************************************
  1911. ;*              FILTER SUBROUTINE                *
  1912. ;*************************************************
  1913. ;*   ASSUMPTIONS:
  1914. ;*      SATURATION ARITHMETIC MODE IS ON
  1915. ;*      P REGISTER OUTPUT SHIFT = 1
  1916. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  1917. ;*          PAGE.
  1918. ;*      SIGN EXTEND MODE IS ON
  1919. ;*
  1920. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  1921. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  1922. ;*
  1923. ;*************************************************
  1924. COEFAR    .set    1        ;Use AR1 to point to COEF's
  1925. DELAR    .set    2        ;Use AR2 to point to DELAY's
  1926. LOOPAR    .set    3        ;Use AR3 as loop counter
  1927. ;*
  1928. %if option M%FILTER%else%F%IDT%%endif%:
  1929.     LARK    0,3        ;SET UP AR0
  1930.     LRLK    COEFAR,FDATA    ;Load COEF AR with beginning of COEF's
  1931.     LRLK    DELAR,DELAY    ;Load DELAY AR with beginning of DELAY's
  1932.     LARP    COEFAR        ;Point to COEF AR
  1933.     LAR    LOOPAR,*+    ;SET SECTION LOOP COUNT
  1934. ;*
  1935. ;* SECOND-ORDER FILTER SECTION LOOP
  1936. ;*
  1937.     LT    *+        ;GET SCALE FACTOR
  1938. FLOOP:
  1939.     LACT    %if option M%VSAMPL%else%V%IDT%%endif%        ;GET and SCALE INPUT
  1940.     SACH    FILTT,4        ;SAVE SCALED INPUT
  1941.     LT    FILTT        ;GET SCALED INPUT
  1942.     MPY    *+,DELAR    ;P = B0 * INPUT
  1943.     PAC            ;AC = B0 * INPUT
  1944.     ADDH    *+        ;AC = (B0 * INPUT) + Z-1
  1945.     ADDS    *+,COEFAR    ;ADD LEAST SIG. PART OF Z-1
  1946.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;SAVE IN OUTPUT
  1947.     MPY    *+,DELAR    ;P = B1 * OUTPUT
  1948.     ZALH    *+        ;AC = Z-2
  1949.     ADDS    *0-,COEFAR    ;ADD LEAST SIG. PART OF Z-2
  1950.     LTA    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = (B1 * INPUT) + Z-2, GET CURRENT OUTPUT
  1951.     MPY    *+,DELAR    ;P = A1/2 * OUTPUT
  1952.     APAC
  1953.     APAC            ;AC = (A1 * OUTPUT) + (B1 * INPUT) + Z-2
  1954.     SACH    *+        ;SAVE Z-1
  1955.     SACL    *+,0,COEFAR    ;SAVE LEAST SIGNIFICANT PART
  1956.     MPY    *+        ;P = A2 * OUTPUT
  1957.     LTP    FILTT        ;AC = A2 * OUTPUT, GET SCALED INPUT
  1958.     MPY    *+        ;P = B2 * INPUT
  1959.     LTA    *+,DELAR    ;AC = (A2 * OUTPUT) + (B2 * INPUT)
  1960. ;*                ; & GET NEXT SCALE FACTOR
  1961.     SACH    *+        ;SAVE Z-2
  1962.     SACL    *+,0,LOOPAR    ;SAVE LEAST SIGNIFICANT PART
  1963. ;*
  1964.     BANZ    FLOOP,*-,COEFAR    ;REPEAT FOR ALL SECTIONS
  1965. ;*
  1966.     RET            ;RETURN
  1967.     .end
  1968. %end%
  1969. >>>>
  1970. >>>
  1971. 2
  1972. 5
  1973. %
  1974. TMS32010; Direct Paged Memory
  1975. >>>
  1976. %batch_files 2  %    .title    "%IDT%"        ;Unique Identifier
  1977. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  1978.     .globl    I%IDT%        ;Name of filter initialization subroutine
  1979. %endif%;*************************************************
  1980. ;*    ASPI TMS32010 DIGITAL FILTER REALIZATION   *
  1981. ;*************************************************
  1982. ;*                  Direct Page
  1983. ;*                 KAISER WINDOW
  1984. ;*               %taps%-TAP FIR FILTER
  1985. ;*
  1986. ;*           FILTER GENERATED FROM FILE
  1987. %filter_file%
  1988. ;*
  1989. ;*************************************************
  1990.     .text
  1991. %if option M%%if main%%else%    B       START
  1992.     .space    6*16
  1993. ;************************************************
  1994. ;*         ASPI CARD INITIALIZATION CODE        *
  1995. ;************************************************
  1996. START:
  1997.     ROVM            ;2S COMPLEMENT
  1998.     LDPK    IOPAGE        ;SET PAGE POINTER
  1999.     CALL    INIT        ;INITIALIZE
  2000. ;************************************************
  2001. ;*                MAIN I/O LOOP                 *
  2002. ;************************************************
  2003. DOUT    .set    6        ;D/A OUTPUT
  2004. DIN    .set    6        ;A/D INPUT
  2005. ;*
  2006. ;* The following three instructions are used in conjunction
  2007. ;* with the PATCH program to indicate an idle state where no
  2008. ;* machine cycles are being used to perform filter operations
  2009. ;* (i.e. The time that location 4 is 1 could be used to do
  2010. ;* other useful things).  PATCH monitors location 4 to determine
  2011. ;* percentage utilization of the processor by the filter.
  2012. ;*
  2013. LPTS:    LACK    1
  2014.     SACL    FILTT
  2015.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  2016. ;*
  2017. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  2018.     B    LPTSA        ;BRANCH IF NO CLOCK
  2019. ;*
  2020. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  2021.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  2022. ;*
  2023. ;* The following three instructions are used in conjunction
  2024. ;* with the PATCH program to indicate either a busy state or
  2025. ;* that the filter is in operation.
  2026. ;*
  2027.     LACK    0        ;GET CONSTANT FOR IDLE
  2028.     SACL    FILTT        ;SAVE FOR OUTPUT
  2029.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  2030. ;*
  2031. ;* The following three instructions are used to determine whether
  2032. ;* or not the filter should be active.  In the non-active state the
  2033. ;* input data is simply passed to the output.  In the active state
  2034. ;* the input data is filtered, then passed to the output.
  2035. ;*
  2036.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  2037.     LAC    FILTT
  2038.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  2039. ;*
  2040.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  2041.     B    LPTS        ;LOOP
  2042. %endif%%endif%;*************************************************
  2043. ;*           DATA MEMORY DEFINITION              *
  2044. ;*************************************************
  2045. ;*     CONTAINS:
  2046. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  2047. ;*          STORAGE FOR COEFFICIENTS
  2048. ;*          STORAGE FOR DELAY ELEMENTS
  2049. ;*************************************************
  2050. ;*
  2051. ;* FILTER INPUT and OUTPUT STORAGE
  2052. ;*
  2053. %if option M%FILTT    .set    1        ;TEMPORARY FILTER DATA
  2054. VSAMPL    .set    0        ;INPUT/OUTPUT FILTER DATA
  2055. IOPAGE    .set    0
  2056. %else%    .globl    V%IDT%,FILTT
  2057. %endif%;*
  2058. COEF:
  2059. ;*
  2060. ;*  FIR COEFFICIENTS
  2061. ;*
  2062. %do%%if coef<%%else%    .word    %coef%        ;%coef_name%
  2063. %endif%%loop%;*
  2064. ;*
  2065.     .sect    "D%IDT%"
  2066. ;*
  2067. ;* DELAY MEMORY STORAGE
  2068. ;*
  2069. DELAY:
  2070. %do%%Z_nameI%:    .space    1*16
  2071. %loop%;*
  2072. ;* COEFFICIENT DATA STORAGE
  2073. ;*
  2074. FDATA:
  2075. %do%%if coef<%%else%%coef_name%:    .space     1*16
  2076. %endif%%loop%;*
  2077. ;*
  2078.     .text
  2079. ;*************************************************
  2080. ;*       FILTER INITIALIZATION SUBROUTINE        *
  2081. ;*************************************************
  2082. %if option M%INIT%else%I%IDT%%endif%:    LACK    1        ;GET A 1
  2083.     LDPK    0        ;SET PAGE POINTER
  2084.     SACL    FILTT        ;TEMPORARY SAVE
  2085.     LT    FILTT        ;LOAD 1 IN T
  2086.     MPYK    COEF
  2087.     PAC            ;AC HAS ADDRESS OF COEF DATA
  2088.     MPYK    1        ;1 INTO P
  2089.     LARK    0,FDATA        ;POINTER TO DATA MEMORY
  2090. %if data%    LARK    1,%points%        ;COUNT FOR NUMBER OF POINTS
  2091. ILP:    LARP    0        ;RESET AR TO 0
  2092.     TBLR    *+,1        ;TRANSFER DATA VALUE
  2093.     APAC            ;INCREMENT POINTER
  2094.     BANZ    ILP        ;LOOP
  2095. %endif%    LARK    1,%ndelay%        ;NUMBER OF DELAY POINTS
  2096.     ZAC            ;CLEAR ACCUMULATOR
  2097.     LARK    0,DELAY        ;POINT TO DELAY MEMORY
  2098. ILPA:    LARP    0        ;RESET AR TO 0
  2099.     SACL    *+,0,1        ;CLEAR DATA VALUE
  2100.     BANZ    ILPA        ;LOOP
  2101.     RET            ;INIT RETURN
  2102. ;*************************************************
  2103. ;*              FILTER SUBROUTINE                *
  2104. ;*************************************************
  2105. ;*
  2106. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  2107. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  2108. ;* 
  2109. ;*************************************************
  2110. %if option M%FILTER%else%F%IDT%%endif%:
  2111. %pshift%%filtin%    ZAC            ;INIT. ACC
  2112. %do%%if coef<>%    LT%if first%%else%D%endif%    %Z_name%
  2113. %if coef<%    MPYK    %coef%        ;%coef_name%
  2114. %else%    MPY    %coef_name%
  2115. %endif%%else%%if firstd%%else%    DMOV    %Z_name%
  2116. %endif%%endif%%loop%    APAC            ;FORM RESULT
  2117.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%%output_shift%    ;SAVE OUTPUT
  2118.     RET            ;RETURN
  2119.     .end
  2120. %end%
  2121. >>>>
  2122. >>>
  2123. 2
  2124. 6
  2125. %
  2126. TMS32020/c25; Indexed Memory; MACD realization
  2127. >>>
  2128. %batch_files 0 D%    .title    "%IDT%"        ;Unique Identifier
  2129. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  2130.     .globl    I%IDT%        ;Name of filter initialization subroutine
  2131. %endif%;*************************************************
  2132. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  2133. ;*************************************************
  2134. ;*           INTERNAL DELAY MEMORY
  2135. ;*          COEF. in PROGRAM MEMORY
  2136. ;*
  2137. ;* NOTE: This realization uses internal memory
  2138. ;*       BANK 0 for program memory.  This allows
  2139. ;*       for very fast execution of the filter
  2140. ;*       by storing the coefficients in BANK 0.
  2141. ;*       However, BANK 0 can not be accessed
  2142. ;*       as data in this mode.  Also, the delay
  2143. ;*       memory must reside in BANK 1 or BANK 2
  2144. ;*
  2145. ;*                 KAISER WINDOW
  2146. ;*               %taps%-TAP FIR FILTER
  2147. ;*
  2148. ;*           FILTER GENERATED FROM FILE
  2149. %filter_file%
  2150. ;*
  2151. ;*************************************************
  2152.     .text
  2153. %if option M%%if main%%else%    B       START                   
  2154.     .space    254*16        ;Programs start at 100 Hex.
  2155. ;************************************************
  2156. ;*         ASPI CARD INITIALIZATION CODE        *
  2157. ;************************************************
  2158. START:
  2159.     ROVM            ;2S COMPLEMENT
  2160.     SSXM            ;SIGN EXTEND MODE
  2161.     LDPK    IOPAGE        ;SET PAGE POINTER
  2162.     SPM    1        ;P output is shifted left 1 bit
  2163.     CALL    INIT        ;INITIALIZE
  2164. ;*
  2165. ;************************************************
  2166. ;*                MAIN I/O LOOP                 *
  2167. ;************************************************
  2168. DOUT    EQU    6        ;D/A OUTPUT
  2169. DIN    EQU    6        ;A/D INPUT
  2170. ;*
  2171. ;* The following three instructions are used in conjunction
  2172. ;* with the PATCH program to indicate an idle state where no
  2173. ;* machine cycles are being used to perform filter operations
  2174. ;* (i.e. The time that location 4 is 1 could be used to do
  2175. ;* other useful things).  PATCH monitors location 4 to determine
  2176. ;* percentage utilization of the processor by the filter.
  2177. ;*
  2178. LPTS:    LACK    1
  2179.     SACL    FILTT
  2180.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  2181. ;*
  2182. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  2183.     B    LPTSA        ;BRANCH IF NO CLOCK
  2184. ;*
  2185. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  2186.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  2187. ;*
  2188. ;* The following three instructions are used in conjunction
  2189. ;* with the PATCH program to indicate either a busy state or
  2190. ;* that the filter is in operation.
  2191. ;*
  2192.     LACK    0        ;GET CONSTANT FOR IDLE
  2193.     SACL    FILTT        ;SAVE FOR OUTPUT
  2194.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  2195. ;*
  2196. ;* The following three instructions are used to determine whether
  2197. ;* or not the filter should be active.  In the non-active state the
  2198. ;* input data is simply passed to the output.  In the active state
  2199. ;* the input data is filtered, then passed to the output.
  2200. ;*
  2201.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  2202.     LAC    FILTT
  2203.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  2204. ;*
  2205.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  2206.     B    LPTS        ;LOOP
  2207. %endif%%endif%;*************************************************
  2208. ;*           DATA MEMORY DEFINITION              *
  2209. ;*************************************************
  2210. ;*     CONTAINS:
  2211. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  2212. ;*          STORAGE FOR COEFFICIENTS
  2213. ;*          STORAGE FOR DELAY ELEMENTS
  2214. ;*************************************************
  2215. ;*
  2216. ;* FILTER INPUT and OUTPUT STORAGE
  2217. ;*
  2218. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  2219. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  2220. IOPAGE    .set    0
  2221. %else%    .globl    V%IDT%,FILTT
  2222. %endif%;*
  2223. COEF:
  2224. ;*
  2225. ;*  FIR COEFFICIENTS
  2226. ;*
  2227. %do%%ndata+%    DATA    %coef%        ;%coef_name%
  2228. %loop%;*
  2229. ;*
  2230.     .sect    "D%IDT%"
  2231. ;*
  2232. ;* DELAY STORAGE
  2233. ;*
  2234. Z000:    .space    1*16
  2235.     .space    (%ndelay%-1)*16
  2236. ZLAST:    .space    1*16
  2237.     .space    1*16        ;Extra storage: MACD destroys this
  2238. ;*                                Location.
  2239. ;*
  2240. ;* COEFFICIENT DATA STORAGE
  2241. ;*
  2242.     .sect    "C%IDT%"
  2243. ;*
  2244. FDATA:    .space    (%points%+1)*16
  2245. ;*
  2246. ;*
  2247.     .text
  2248. ;*************************************************
  2249. ;*       FILTER INITIALIZATION SUBROUTINE        *
  2250. ;*************************************************
  2251. %if option M%INIT%else%I%IDT%%endif%:
  2252.     LARP    0
  2253.     CNFD
  2254.     LRLK    0,FDATA        ;POINTER TO COEF. MEMORY
  2255.     RPTK    %points%
  2256.     BLKP    COEF,*+        ;MOVE COEF.
  2257.     CNFP
  2258.     LRLK    0,Z000        ;POINTER TO DELAY MEMORY
  2259.     ZAC            ;CLEAR ACCUMULATOR
  2260.     RPTK    %ndelay%
  2261.     SACL    *+        ;CLEAR DELAY MEMORY
  2262.     RET    
  2263. ;*************************************************
  2264. ;*              FILTER SUBROUTINE                *
  2265. ;*************************************************
  2266. ;* ASSUMPTIONS:
  2267. ;*     BANK 0 is set to PROGRAM MEMORY.
  2268. ;*     COEFFICIENTS are located at 'FDATA'.
  2269. ;*     DELAY elements are located at 'DELAY'.
  2270. ;* NOTE: COEF's must be in BANK 0 and DELAY's
  2271. ;*       must be in BANK 1 or BANK 2.
  2272. ;*     'DELAR' AR is destroyed by filter routine.
  2273. ;*     P output shift is set to 1.
  2274. ;*     SIGN EXTEND mode is ON.
  2275. ;*     Two's Complement Arithmetic.
  2276. ;*
  2277. ;*************************************************
  2278. DELAR    .set    1        ;DELAY AR REGISTER
  2279. ;*
  2280. %if option M%FILTER%else%F%IDT%%endif%:
  2281.     LARP    DELAR        ;POINT TO THE DELAY INDEX REGISTER
  2282.     LRLK    DELAR,Z000    ;INDEX POINTS TO Z-0 (INPUT)
  2283. %filtinI%
  2284.     MPYK    0        ;P = 0
  2285.     ZAC            ;AC = 0
  2286.     LRLK    DELAR,ZLAST    ;INDEX POINTS TO Z-N
  2287.     RPTK    %points%
  2288.     MACD    FDATA+0FD00h,*-    ;MULTIPLY, ACCUM. and  DELAY
  2289.     APAC            ;FORM RESULT
  2290.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%%output_shift%    ;SAVE OUTPUT
  2291.     RET            ;RETURN
  2292. ;*
  2293.     .end
  2294. %end%
  2295. >>>>
  2296. >>>
  2297. 2
  2298. 6
  2299. %
  2300. TMS32020/c25; Internal Direct Paged Memory
  2301. >>>
  2302. %batch_files 2  %    .title    "%IDT%"        ;Unique Identifier
  2303. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  2304.     .globl    I%IDT%        ;Name of filter initialization subroutine
  2305. %endif%;*************************************************
  2306. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  2307. ;*************************************************
  2308. ;*                   Direct Page
  2309. ;*                  KAISER WINDOW
  2310. ;*               %taps%-TAP FIR FILTER
  2311. ;*
  2312. ;*           FILTER GENERATED FROM FILE
  2313. %filter_file%
  2314. ;*
  2315. ;*************************************************
  2316.     .text
  2317. %if option M%%if main%%else%    B       START
  2318.     .space    254*16        ;Programs start at 100 Hex.
  2319. ;************************************************
  2320. ;*         ASPI CARD INITIALIZATION CODE        *
  2321. ;************************************************
  2322. START:
  2323.     CNFD            ;SET BANK 0 TO DATA MEMORY
  2324.     ROVM            ;2S COMPLEMENT
  2325.     SSXM            ;SIGN EXTEND MODE
  2326.     SPM    1        ;P output is shifted left 1 bit
  2327.     LDPK    IOPAGE
  2328.     CALL    INIT        ;INITIALIZE
  2329. ;************************************************
  2330. ;*                MAIN I/O LOOP                 *
  2331. ;************************************************
  2332. DOUT    .set    6        ;D/A OUTPUT
  2333. DIN    .set    6        ;A/D INPUT
  2334. ;*
  2335. ;* The following three instructions are used in conjunction
  2336. ;* with the PATCH program to indicate an idle state where no
  2337. ;* machine cycles are being used to perform filter operations
  2338. ;* (i.e. The time that location 4 is 1 could be used to do
  2339. ;* other useful things).  PATCH monitors location 4 to determine
  2340. ;* percentage utilization of the processor by the filter.
  2341. ;*
  2342. LPTS:    LACK    1
  2343.     SACL    FILTT
  2344.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  2345. ;*
  2346. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  2347.     B    LPTSA        ;BRANCH IF NO CLOCK
  2348. ;*
  2349. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  2350.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  2351. ;*
  2352. ;* The following three instructions are used in conjunction
  2353. ;* with the PATCH program to indicate either a busy state or
  2354. ;* that the filter is in operation.
  2355. ;*
  2356.     LACK    0        ;GET CONSTANT FOR IDLE
  2357.     SACL    FILTT        ;SAVE FOR OUTPUT
  2358.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  2359. ;*
  2360. ;* The following three instructions are used to determine whether
  2361. ;* or not the filter should be active.  In the non-active state the
  2362. ;* input data is simply passed to the output.  In the active state
  2363. ;* the input data is filtered, then passed to the output.
  2364. ;*
  2365.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  2366.     LAC    FILTT
  2367.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  2368. ;*
  2369.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  2370.     B    LPTS        ;LOOP
  2371. %endif%%endif%;*************************************************
  2372. ;*           DATA MEMORY DEFINITION              *
  2373. ;*************************************************
  2374. ;*     CONTAINS:
  2375. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  2376. ;*          STORAGE FOR COEFFICIENTS
  2377. ;*          STORAGE FOR DELAY ELEMENTS
  2378. ;*************************************************
  2379. ;*
  2380. ;* FILTER INPUT and OUTPUT STORAGE
  2381. ;*
  2382. %if option M%FILTT    .set    1        ;TEMPORARY FILTER DATA
  2383. VSAMPL    .set    0        ;INPUT/OUTPUT FILTER DATA
  2384. IOPAGE    .set    4
  2385. %else%    .globl    V%IDT%,FILTT
  2386. %endif%;*
  2387. COEF:
  2388. ;*
  2389. ;*  FIR COEFFICIENTS
  2390. ;*
  2391. %do%%if coef<%%else%    .word    %coef%        ;%coef_name%
  2392. %endif%%loop%;*
  2393. ;*
  2394.     .sect    "D%IDT%"
  2395. ;*
  2396. ;* DELAY MEMORY STORAGE
  2397. ;*
  2398. DELAY:
  2399. %do%%Z_nameI%:    .space    1*16
  2400. %loop%;*
  2401. ;* COEFFICIENT DATA STORAGE
  2402. ;*
  2403. FDATA:
  2404. %do%%if coef<%%else%%coef_name%:    .space    1*16
  2405. %endif%%loop%;*
  2406. ;*
  2407.     .text
  2408. ;*************************************************
  2409. ;*       FILTER INITIALIZATION SUBROUTINE        *
  2410. ;*************************************************
  2411. %if option M%INIT%else%I%IDT%%endif%:
  2412.     LARP    0
  2413. %if data%    LRLK    0,FDATA        ;POINTER TO COEF. MEMORY
  2414. %copy_coef%%endif%    LRLK    0,DELAY        ;POINTER TO DELAY MEMORY
  2415.     ZAC            ;CLEAR ACCUMULATOR
  2416. %zero_delay%    RET            ;INIT RETURN
  2417. ;*************************************************
  2418. ;*              FILTER SUBROUTINE                *
  2419. ;*************************************************
  2420. ;*
  2421. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  2422. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  2423. ;* 
  2424. ;*************************************************
  2425. %if option M%FILTER%else%F%IDT%%endif%:
  2426. %filtin%    ZAC            ;INIT. ACC
  2427. %do%%if coef<>%    LT%if first%%else%D%endif%    %Z_name%
  2428. %if coef<%    MPYK    %coef%        ;%coef_name%
  2429. %else%    MPY    %coef_name%
  2430. %endif%%else%%if firstd%%else%    DMOV    %Z_name%
  2431. %endif%%endif%%loop%    APAC            ;FORM RESULT
  2432.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%%output_shift%    ;SAVE OUTPUT
  2433.     RET            ;RETURN
  2434.     .end
  2435. %end%
  2436. >>>>
  2437. >>>
  2438. 2
  2439. 6
  2440. %
  2441. TMS32020/c25; Indexed Memory; Internal Delay Memory
  2442. >>>
  2443. %batch_files 0  %    .title    "%IDT%"        ;Unique Identifier
  2444. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  2445.     .globl    I%IDT%        ;Name of filter initialization subroutine
  2446. %endif%;*************************************************
  2447. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  2448. ;*************************************************
  2449. ;*              EXTERNAL COEFFICIENTS
  2450. ;*                 INTERNAL DELAYS
  2451. ;*
  2452. ;*                 KAISER WINDOW
  2453. ;*               %taps%-TAP FIR FILTER
  2454. ;*
  2455. ;*           FILTER GENERATED FROM FILE
  2456. %filter_file%
  2457. ;*
  2458. ;*************************************************
  2459.     .text
  2460. %if option M%%if main%%else%    B       START
  2461.     .space    254*16        ;Programs start at 100 Hex.
  2462. ;************************************************
  2463. ;*         ASPI CARD INITIALIZATION CODE        *
  2464. ;************************************************
  2465. START:
  2466.     CNFD            ;SET BANK 0 TO DATA MEMORY
  2467.     ROVM            ;2S COMPLEMENT
  2468.     SSXM            ;SIGN EXTEND MODE
  2469.     LDPK    IOPAGE        ;SET PAGE POINTER
  2470.     SPM    1        ;P output is shifted left 1 bit
  2471.     CALL    INIT        ;INITIALIZE
  2472. ;************************************************
  2473. ;*                MAIN I/O LOOP                 *
  2474. ;************************************************
  2475. DOUT    .set    6        ;D/A OUTPUT
  2476. DIN    .set    6        ;A/D INPUT
  2477. ;*
  2478. ;* The following three instructions are used in conjunction
  2479. ;* with the PATCH program to indicate an idle state where no
  2480. ;* machine cycles are being used to perform filter operations
  2481. ;* (i.e. The time that location 4 is 1 could be used to do
  2482. ;* other useful things).  PATCH monitors location 4 to determine
  2483. ;* percentage utilization of the processor by the filter.
  2484. ;*
  2485. LPTS:    LACK    1
  2486.     SACL    FILTT
  2487.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  2488. ;*
  2489. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  2490.     B    LPTSA        ;BRANCH IF NO CLOCK
  2491. ;*
  2492. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  2493.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  2494. ;*
  2495. ;* The following three instructions are used in conjunction
  2496. ;* with the PATCH program to indicate either a busy state or
  2497. ;* that the filter is in operation.
  2498. ;*
  2499.     LACK    0        ;GET CONSTANT FOR IDLE
  2500.     SACL    FILTT        ;SAVE FOR OUTPUT
  2501.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  2502. ;*
  2503. ;* The following three instructions are used to determine whether
  2504. ;* or not the filter should be active.  In the non-active state the
  2505. ;* input data is simply passed to the output.  In the active state
  2506. ;* the input data is filtered, then passed to the output.
  2507. ;*
  2508.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  2509.     LAC    FILTT
  2510.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  2511. ;*
  2512.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  2513.     B    LPTS        ;LOOP
  2514. %endif%%endif%;*************************************************
  2515. ;*           DATA MEMORY DEFINITION              *
  2516. ;*************************************************
  2517. ;*     CONTAINS:
  2518. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  2519. ;*          STORAGE FOR COEFFICIENTS
  2520. ;*          STORAGE FOR DELAY ELEMENTS
  2521. ;*************************************************
  2522. ;*
  2523. ;* FILTER INPUT and OUTPUT STORAGE
  2524. ;*
  2525. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  2526. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  2527. IOPAGE    .set    0
  2528. %else%    .globl    V%IDT%,FILTT
  2529. %endif%;*
  2530. COEF:
  2531. ;*
  2532. ;*  FIR COEFFICIENTS
  2533. ;*
  2534. %do%%if coef<%%else%    .word    %coef%        ;%coef_name%
  2535. %endif%%loop%;*
  2536. ;*
  2537.     .sect    "D%IDT%"
  2538. ;*
  2539. ;* DELAY STORAGE
  2540. ;*
  2541.     .globl    Z%IDT%,L%IDT%
  2542. Z%IDT%:    .space    1*16
  2543.     .space    (%ndelay%-1)*16
  2544. L%IDT%:    .space    1*16
  2545. ;*
  2546. ;*
  2547.     .sect    "X%IDT%"
  2548. ;*
  2549. ;* COEFFICIENT DATA STORAGE
  2550. ;*
  2551. FDATA:    .space    (%points%+1)*16
  2552. ;*
  2553. ;*
  2554.     .text
  2555. ;*************************************************
  2556. ;*       FILTER INITIALIZATION SUBROUTINE        *
  2557. ;*************************************************
  2558. %if option M%INIT%else%I%IDT%%endif%:
  2559.     LARP    0
  2560. %if data%    LRLK    0,FDATA        ;POINTER TO COEF. MEMORY
  2561. %copy_coef%%endif%    LRLK    0,Z%IDT%       ;POINTER TO DELAY MEMORY
  2562.     ZAC            ;CLEAR ACCUMULATOR
  2563. %zero_delay%    RET            ;INIT RETURN
  2564. ;*************************************************
  2565. ;*              FILTER SUBROUTINE                *
  2566. ;*************************************************
  2567. ;* ASSUMPTIONS:
  2568. ;*     PAGE POINTER must be set to 'DPAGE'.
  2569. ;*     The AR pointer register is destroyed.
  2570. ;*     The address registers 'COEFAR' and 'DELAR'
  2571. ;*        are destroyed by filter routine.
  2572. ;*     P output shift is set to 1.
  2573. ;*     SIGN EXTEND mode is ON.
  2574. ;*     Two's Complement Arithmetic.
  2575. ;*     COEF. elements are located in any in
  2576. ;*        data memory.
  2577. ;*     DELAY elements must be in internal memory
  2578. ;*        and must not cross a page boundary.
  2579. ;*
  2580. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  2581. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  2582. ;*
  2583. ;*************************************************
  2584. DELAR    .set    2
  2585. COEFAR    .set    1
  2586. ;*
  2587. %if option M%FILTER%else%F%IDT%%endif%:
  2588.     LARP    DELAR        ;POINT TO CORRECT AR
  2589.     LRLK    COEFAR,FDATA    ;AR = START OF COEF.
  2590.     LRLK    DELAR,Z%IDT%
  2591. %filtinI%    LRLK    DELAR,L%IDT%
  2592.     ZAC            ;INIT AC.
  2593. %do%%if coef<>%    LT%if first%%else%D%endif%    *-%if coef<%    %else%,COEFAR%endif%    ;%Z_name%
  2594. %if coef<%    MPYK    %coef%        ;%coef_name%
  2595. %else%    MPY    *+,DELAR    ;%coef_name%
  2596. %endif%%else%%if firstd%    MAR    *-
  2597. %else%    DMOV    *-        ;%Z_name%
  2598. %endif%%endif%%loop%    APAC            ;FORM RESULT
  2599.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%%output_shift%        ;SAVE OUTPUT
  2600. ;*
  2601.     RET            ;RETURN
  2602. ;*
  2603.     .end
  2604. %end%
  2605. >>>>
  2606. >>>
  2607. 2
  2608. 6
  2609. %
  2610. TMS32020/c25; Indexed Memory; Internal or External Memory
  2611. >>>
  2612. %batch_files 0  %    .title    "%IDT%"        ;Unique Identifier
  2613. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  2614.     .globl    I%IDT%        ;Name of filter initialization subroutine
  2615. %endif%;*************************************************
  2616. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  2617. ;*************************************************
  2618. ;*              EXTERNAL MEMORY MODEL
  2619. ;*
  2620. ;*                 KAISER WINDOW
  2621. ;*               %taps%-TAP FIR FILTER
  2622. ;*
  2623. ;*           FILTER GENERATED FROM FILE
  2624. %filter_file%
  2625. ;*
  2626. ;*************************************************
  2627.     .text
  2628. %if option M%%if main%%else%    B    START
  2629.     .space    254*16        ;Programs start at 100 Hex.
  2630. ;************************************************
  2631. ;*         ASPI CARD INITIALIZATION CODE        *
  2632. ;************************************************
  2633. START:
  2634.     CNFD            ;SET BANK 0 TO DATA MEMORY
  2635.     ROVM            ;2S COMPLEMENT
  2636.     SSXM            ;SIGN EXTEND MODE
  2637.     SPM    1        ;P output is shifted left 1 bit
  2638.     LDPK    IOPAGE
  2639.     CALL    INIT        ;INITIALIZE
  2640. ;*
  2641. ;************************************************
  2642. ;*                MAIN I/O LOOP                 *
  2643. ;************************************************
  2644. DOUT    .set    6        ;D/A OUTPUT
  2645. DIN    .set    6        ;A/D INPUT
  2646. ;*
  2647. ;* The following three instructions are used in conjunction
  2648. ;* with the PATCH program to indicate an idle state where no
  2649. ;* machine cycles are being used to perform filter operations
  2650. ;* (i.e. The time that location 4 is 1 could be used to do
  2651. ;* other useful things).  PATCH monitors location 4 to determine
  2652. ;* percentage utilization of the processor by the filter.
  2653. ;*
  2654. LPTS:    LACK    1
  2655.     SACL    FILTT
  2656.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  2657. ;*
  2658. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  2659.     B    LPTSA        ;BRANCH IF NO CLOCK
  2660. ;*
  2661. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  2662.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  2663. ;*
  2664. ;* The following three instructions are used in conjunction
  2665. ;* with the PATCH program to indicate either a busy state or
  2666. ;* that the filter is in operation.
  2667. ;*
  2668.     LACK    0        ;GET CONSTANT FOR IDLE
  2669.     SACL    FILTT        ;SAVE FOR OUTPUT
  2670.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  2671. ;*
  2672. ;* The following three instructions are used to determine whether
  2673. ;* or not the filter should be active.  In the non-active state the
  2674. ;* input data is simply passed to the output.  In the active state
  2675. ;* the input data is filtered, then passed to the output.
  2676. ;*
  2677.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  2678.     LAC    FILTT
  2679.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  2680. ;*
  2681.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  2682.     B    LPTS        ;LOOP
  2683. %endif%%endif%;*************************************************
  2684. ;*           DATA MEMORY DEFINITION              *
  2685. ;*************************************************
  2686. ;*     CONTAINS:
  2687. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  2688. ;*          STORAGE FOR COEFFICIENTS
  2689. ;*          STORAGE FOR DELAY ELEMENTS
  2690. ;*************************************************
  2691. ;*
  2692. ;* FILTER INPUT and OUTPUT STORAGE
  2693. ;*
  2694. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  2695. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  2696. IOPAGE    .set    0
  2697. %else%    .globl    V%IDT%,FILTT
  2698. %endif%;*
  2699. COEF:
  2700. ;*
  2701. ;*  FIR INITIALIZATION COEFFICIENTS
  2702. ;*
  2703. %do%%if coef<%%else%    .word    %coef%        ;%coef_name%
  2704. %endif%%loop%;*
  2705. ;*
  2706.     .sect    "X%IDT%"
  2707. ;*
  2708. ;* COEFFICIENT DATA STORAGE
  2709. ;*
  2710. FDATA:    .space    %points%*16
  2711. LCOEF:    .space    1*16
  2712. ;*
  2713. ;* DELAY STORAGE
  2714. ;*
  2715. ZLAST:    .space    1*16
  2716.     .space    (%ndelay%-1)*16
  2717. Z000:    .space    1*16
  2718. ;*
  2719. ;*
  2720.     .text
  2721. ;*************************************************
  2722. ;*       FILTER INITIALIZATION SUBROUTINE        *
  2723. ;*************************************************
  2724. %if option M%INIT%else%I%IDT%%endif%:
  2725.     LARP    0
  2726. %if data%    LRLK    0,FDATA        ;POINTER TO COEF. MEMORY
  2727. %copy_coef%%endif%    LRLK    0,ZLAST        ;POINTER TO DELAY MEMORY
  2728.     ZAC            ;CLEAR ACCUMULATOR
  2729. %zero_delay%    RET            ;INIT RETURN
  2730. ;*************************************************
  2731. ;*              FILTER SUBROUTINE                *
  2732. ;*************************************************
  2733. ;* ASSUMPTIONS:
  2734. ;*     PAGE POINTER must point to page with
  2735. ;*        %if option M%VSAMPL%else%V%IDT%%endif%.
  2736. ;*     The address registers 'COEFAR' and 'DELAR'
  2737. ;*        are destroyed by filter routine.
  2738. ;*     P output shift is set to 1.
  2739. ;*     SIGN EXTEND mode is ON.
  2740. ;*     Two's Complement Arithmetic.
  2741. ;*     COEF. & DELAY elements are located any in
  2742. ;*        data memory.
  2743. ;*
  2744. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  2745. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  2746. ;*
  2747. ;*************************************************
  2748. COEFAR    .set    1
  2749. DELAR    .set    2
  2750. ;*
  2751. %if option M%FILTER%else%F%IDT%%endif%:
  2752.     LRLK    COEFAR,LCOEF    ;INIT INDEX REGISTER POINTERS
  2753.     LRLK    DELAR,Z000
  2754.     LARP    DELAR        ;POINTER TO CORRECT INDEX REGISTER
  2755. %filtinI%%do%    LT%if first%%elseif second%P%else%A%endif%    *-%if coef<%%else%,COEFAR%endif%
  2756. %if coef<%    MPYK    %coefI%        ;%coef_nameI%
  2757. %else%    MPY    *-,DELAR    ;%coef_nameI%
  2758. %endif%%loop%    APAC            ;FORM RESULT
  2759.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%%output_shift%    ;SAVE OUTPUT
  2760. ;*
  2761.     LRLK    DELAR,ZLAST
  2762. %move_delay%;*
  2763.     RET            ;RETURN
  2764. ;*
  2765.     .end
  2766. %end%
  2767. >>>>
  2768. >>>
  2769. 3
  2770. 5
  2771. %
  2772. TMS32010; Direct Paged Memory
  2773. >>>
  2774. %batch_files 2  %    .title    "%IDT%"        ;Unique Identifier
  2775. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  2776.     .globl    I%IDT%        ;Name of filter initialization subroutine
  2777. %endif%;*************************************************
  2778. ;*    ASPI TMS32010 DIGITAL FILTER REALIZATION   *
  2779. ;*************************************************
  2780. ;*                  Direct Page
  2781. ;*                 PARK-MCCLELLAN
  2782. ;*               %taps%-TAP FIR FILTER
  2783. ;*
  2784. ;*           FILTER GENERATED FROM FILE
  2785. %filter_file%
  2786. ;*
  2787. ;*************************************************
  2788.     .text
  2789. %if option M%%if main%%else%    B       START
  2790.     .space    6*16
  2791. ;************************************************
  2792. ;*         ASPI CARD INITIALIZATION CODE        *
  2793. ;************************************************
  2794. START:
  2795.     ROVM            ;2S COMPLEMENT
  2796.     LDPK    IOPAGE        ;SET PAGE POINTER
  2797.     CALL    INIT        ;INITIALIZE
  2798. ;************************************************
  2799. ;*                MAIN I/O LOOP                 *
  2800. ;************************************************
  2801. DOUT    .set    6        ;D/A OUTPUT
  2802. DIN    .set    6        ;A/D INPUT
  2803. ;*
  2804. ;* The following three instructions are used in conjunction
  2805. ;* with the PATCH program to indicate an idle state where no
  2806. ;* machine cycles are being used to perform filter operations
  2807. ;* (i.e. The time that location 4 is 1 could be used to do
  2808. ;* other useful things).  PATCH monitors location 4 to determine
  2809. ;* percentage utilization of the processor by the filter.
  2810. ;*
  2811. LPTS:    LACK    1
  2812.     SACL    FILTT
  2813.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  2814. ;*
  2815. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  2816.     B    LPTSA        ;BRANCH IF NO CLOCK
  2817. ;*
  2818. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  2819.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  2820. ;*
  2821. ;* The following three instructions are used in conjunction
  2822. ;* with the PATCH program to indicate either a busy state or
  2823. ;* that the filter is in operation.
  2824. ;*
  2825.     LACK    0        ;GET CONSTANT FOR IDLE
  2826.     SACL    FILTT        ;SAVE FOR OUTPUT
  2827.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  2828. ;*
  2829. ;* The following three instructions are used to determine whether
  2830. ;* or not the filter should be active.  In the non-active state the
  2831. ;* input data is simply passed to the output.  In the active state
  2832. ;* the input data is filtered, then passed to the output.
  2833. ;*
  2834.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  2835.     LAC    FILTT
  2836.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  2837. ;*
  2838.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  2839.     B    LPTS        ;LOOP
  2840. %endif%%endif%;*************************************************
  2841. ;*           DATA MEMORY DEFINITION              *
  2842. ;*************************************************
  2843. ;*     CONTAINS:
  2844. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  2845. ;*          STORAGE FOR COEFFICIENTS
  2846. ;*          STORAGE FOR DELAY ELEMENTS
  2847. ;*************************************************
  2848. ;*
  2849. ;* FILTER INPUT and OUTPUT STORAGE
  2850. ;*
  2851. %if option M%FILTT    .set    1        ;TEMPORARY FILTER DATA
  2852. VSAMPL    .set    0        ;INPUT/OUTPUT FILTER DATA
  2853. IOPAGE    .set    0
  2854. %else%    .globl    V%IDT%,FILTT
  2855. %endif%;*
  2856. COEF:
  2857. ;*
  2858. ;*  FIR COEFFICIENTS
  2859. ;*
  2860. %do%%if coef<%%else%    .word    %coef%        ;%coef_name%
  2861. %endif%%loop%;*
  2862. ;*
  2863.     .sect    "D%IDT%"
  2864. ;*
  2865. ;* DELAY MEMORY STORAGE
  2866. ;*
  2867. DELAY:
  2868. %do%%Z_nameI%:    .space    1*16
  2869. %loop%;*
  2870. ;* COEFFICIENT DATA STORAGE
  2871. ;*
  2872. FDATA:
  2873. %do%%if coef<%%else%%coef_name%:    .space     1*16
  2874. %endif%%loop%;*
  2875. ;*
  2876.     .text
  2877. ;*************************************************
  2878. ;*       FILTER INITIALIZATION SUBROUTINE        *
  2879. ;*************************************************
  2880. %if option M%INIT%else%I%IDT%%endif%:    LACK    1        ;GET A 1
  2881.     LDPK    0        ;SET PAGE POINTER
  2882.     SACL    FILTT        ;TEMPORARY SAVE
  2883.     LT    FILTT        ;LOAD 1 IN T
  2884.     MPYK    COEF
  2885.     PAC            ;AC HAS ADDRESS OF COEF DATA
  2886.     MPYK    1        ;1 INTO P
  2887.     LARK    0,FDATA        ;POINTER TO DATA MEMORY
  2888. %if data%    LARK    1,%points%        ;COUNT FOR NUMBER OF POINTS
  2889. ILP:    LARP    0        ;RESET AR TO 0
  2890.     TBLR    *+,1        ;TRANSFER DATA VALUE
  2891.     APAC            ;INCREMENT POINTER
  2892.     BANZ    ILP        ;LOOP
  2893. %endif%    LARK    1,%ndelay%        ;NUMBER OF DELAY POINTS
  2894.     ZAC            ;CLEAR ACCUMULATOR
  2895.     LARK    0,DELAY        ;POINT TO DELAY MEMORY
  2896. ILPA:    LARP    0        ;RESET AR TO 0
  2897.     SACL    *+,0,1        ;CLEAR DATA VALUE
  2898.     BANZ    ILPA        ;LOOP
  2899.     RET            ;INIT RETURN
  2900. ;*************************************************
  2901. ;*              FILTER SUBROUTINE                *
  2902. ;*************************************************
  2903. ;*
  2904. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  2905. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  2906. ;* 
  2907. ;*************************************************
  2908. %if option M%FILTER%else%F%IDT%%endif%:
  2909. %pshift%%filtin%    ZAC            ;INIT. ACC
  2910. %do%%if coef<>%    LT%if first%%else%D%endif%    %Z_name%
  2911. %if coef<%    MPYK    %coef%        ;%coef_name%
  2912. %else%    MPY    %coef_name%
  2913. %endif%%else%%if firstd%%else%    DMOV    %Z_name%
  2914. %endif%%endif%%loop%    APAC            ;FORM RESULT
  2915.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%%output_shift%    ;SAVE OUTPUT
  2916.     RET            ;RETURN
  2917.     .end
  2918. %end%
  2919. >>>>
  2920. >>>
  2921. 3
  2922. 6
  2923. %
  2924. TMS32020/c25; Indexed Memory; MACD realization
  2925. >>>
  2926. %batch_files 0 D%    .title    "%IDT%"        ;Unique Identifier
  2927. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  2928.     .globl    I%IDT%        ;Name of filter initialization subroutine
  2929. %endif%;*************************************************
  2930. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  2931. ;*************************************************
  2932. ;*           INTERNAL DELAY MEMORY
  2933. ;*          COEF. in PROGRAM MEMORY
  2934. ;*
  2935. ;* NOTE: This realization uses internal memory
  2936. ;*       BANK 0 for program memory.  This allows
  2937. ;*       for very fast execution of the filter
  2938. ;*       by storing the coefficients in BANK 0.
  2939. ;*       However, BANK 0 can not be accessed
  2940. ;*       as data in this mode.  Also, the delay
  2941. ;*       memory must reside in BANK 1 or BANK 2
  2942. ;*
  2943. ;*                 PARK-MCCLELLAN
  2944. ;*               %taps%-TAP FIR FILTER
  2945. ;*
  2946. ;*           FILTER GENERATED FROM FILE
  2947. %filter_file%
  2948. ;*
  2949. ;*************************************************
  2950.     .text
  2951. %if option M%%if main%%else%    B       START                   
  2952.     .space    254*16        ;Programs start at 100 Hex.
  2953. ;************************************************
  2954. ;*         ASPI CARD INITIALIZATION CODE        *
  2955. ;************************************************
  2956. START:
  2957.     ROVM            ;2S COMPLEMENT
  2958.     SSXM            ;SIGN EXTEND MODE
  2959.     LDPK    IOPAGE        ;SET PAGE POINTER
  2960.     SPM    1        ;P output is shifted left 1 bit
  2961.     CALL    INIT        ;INITIALIZE
  2962. ;*
  2963. ;************************************************
  2964. ;*                MAIN I/O LOOP                 *
  2965. ;************************************************
  2966. DOUT    EQU    6        ;D/A OUTPUT
  2967. DIN    EQU    6        ;A/D INPUT
  2968. ;*
  2969. ;* The following three instructions are used in conjunction
  2970. ;* with the PATCH program to indicate an idle state where no
  2971. ;* machine cycles are being used to perform filter operations
  2972. ;* (i.e. The time that location 4 is 1 could be used to do
  2973. ;* other useful things).  PATCH monitors location 4 to determine
  2974. ;* percentage utilization of the processor by the filter.
  2975. ;*
  2976. LPTS:    LACK    1
  2977.     SACL    FILTT
  2978.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  2979. ;*
  2980. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  2981.     B    LPTSA        ;BRANCH IF NO CLOCK
  2982. ;*
  2983. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  2984.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  2985. ;*
  2986. ;* The following three instructions are used in conjunction
  2987. ;* with the PATCH program to indicate either a busy state or
  2988. ;* that the filter is in operation.
  2989. ;*
  2990.     LACK    0        ;GET CONSTANT FOR IDLE
  2991.     SACL    FILTT        ;SAVE FOR OUTPUT
  2992.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  2993. ;*
  2994. ;* The following three instructions are used to determine whether
  2995. ;* or not the filter should be active.  In the non-active state the
  2996. ;* input data is simply passed to the output.  In the active state
  2997. ;* the input data is filtered, then passed to the output.
  2998. ;*
  2999.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  3000.     LAC    FILTT
  3001.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  3002. ;*
  3003.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  3004.     B    LPTS        ;LOOP
  3005. %endif%%endif%;*************************************************
  3006. ;*           DATA MEMORY DEFINITION              *
  3007. ;*************************************************
  3008. ;*     CONTAINS:
  3009. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  3010. ;*          STORAGE FOR COEFFICIENTS
  3011. ;*          STORAGE FOR DELAY ELEMENTS
  3012. ;*************************************************
  3013. ;*
  3014. ;* FILTER INPUT and OUTPUT STORAGE
  3015. ;*
  3016. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  3017. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  3018. IOPAGE    .set    0
  3019. %else%    .globl    V%IDT%,FILTT
  3020. %endif%;*
  3021. COEF:
  3022. ;*
  3023. ;*  FIR COEFFICIENTS
  3024. ;*
  3025. %do%%ndata+%    DATA    %coef%        ;%coef_name%
  3026. %loop%;*
  3027. ;*
  3028.     .sect    "D%IDT%"
  3029. ;*
  3030. ;* DELAY STORAGE
  3031. ;*
  3032. Z000:    .space    1*16
  3033.     .space    (%ndelay%-1)*16
  3034. ZLAST:    .space    1*16
  3035.     .space    1*16        ;Extra storage: MACD destroys this
  3036. ;*                                Location.
  3037. ;*
  3038. ;* COEFFICIENT DATA STORAGE
  3039. ;*
  3040.     .sect    "C%IDT%"
  3041. ;*
  3042. FDATA:    .space    (%points%+1)*16
  3043. ;*
  3044. ;*
  3045.     .text
  3046. ;*************************************************
  3047. ;*       FILTER INITIALIZATION SUBROUTINE        *
  3048. ;*************************************************
  3049. %if option M%INIT%else%I%IDT%%endif%:
  3050.     LARP    0
  3051.     CNFD
  3052.     LRLK    0,FDATA        ;POINTER TO COEF. MEMORY
  3053.     RPTK    %points%
  3054.     BLKP    COEF,*+        ;MOVE COEF.
  3055.     CNFP
  3056.     LRLK    0,Z000        ;POINTER TO DELAY MEMORY
  3057.     ZAC            ;CLEAR ACCUMULATOR
  3058.     RPTK    %ndelay%
  3059.     SACL    *+        ;CLEAR DELAY MEMORY
  3060.     RET    
  3061. ;*************************************************
  3062. ;*              FILTER SUBROUTINE                *
  3063. ;*************************************************
  3064. ;* ASSUMPTIONS:
  3065. ;*     BANK 0 is set to PROGRAM MEMORY.
  3066. ;*     COEFFICIENTS are located at 'FDATA'.
  3067. ;*     DELAY elements are located at 'DELAY'.
  3068. ;* NOTE: COEF's must be in BANK 0 and DELAY's
  3069. ;*       must be in BANK 1 or BANK 2.
  3070. ;*     'DELAR' AR is destroyed by filter routine.
  3071. ;*     P output shift is set to 1.
  3072. ;*     SIGN EXTEND mode is ON.
  3073. ;*     Two's Complement Arithmetic.
  3074. ;*
  3075. ;*************************************************
  3076. DELAR    .set    1        ;DELAY AR REGISTER
  3077. ;*
  3078. %if option M%FILTER%else%F%IDT%%endif%:
  3079.     LARP    DELAR        ;POINT TO THE DELAY INDEX REGISTER
  3080.     LRLK    DELAR,Z000    ;INDEX POINTS TO Z-0 (INPUT)
  3081. %filtinI%
  3082.     MPYK    0        ;P = 0
  3083.     ZAC            ;AC = 0
  3084.     LRLK    DELAR,ZLAST    ;INDEX POINTS TO Z-N
  3085.     RPTK    %points%
  3086.     MACD    FDATA+0FD00h,*-    ;MULTIPLY, ACCUM. and  DELAY
  3087.     APAC            ;FORM RESULT
  3088.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%%output_shift%    ;SAVE OUTPUT
  3089.     RET            ;RETURN
  3090. ;*
  3091.     .end
  3092. %end%
  3093. >>>>
  3094. >>>
  3095. 3
  3096. 6
  3097. %
  3098. TMS32020/c25; Internal Direct Paged Memory
  3099. >>>
  3100. %batch_files 2  %    .title    "%IDT%"        ;Unique Identifier
  3101. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  3102.     .globl    I%IDT%        ;Name of filter initialization subroutine
  3103. %endif%;*************************************************
  3104. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  3105. ;*************************************************
  3106. ;*                   Direct Page
  3107. ;*                  PARK-MCCLELLAN
  3108. ;*               %taps%-TAP FIR FILTER
  3109. ;*
  3110. ;*           FILTER GENERATED FROM FILE
  3111. %filter_file%
  3112. ;*
  3113. ;*************************************************
  3114.     .text
  3115. %if option M%%if main%%else%    B       START
  3116.     .space    254*16        ;Programs start at 100 Hex.
  3117. ;************************************************
  3118. ;*         ASPI CARD INITIALIZATION CODE        *
  3119. ;************************************************
  3120. START:
  3121.     CNFD            ;SET BANK 0 TO DATA MEMORY
  3122.     ROVM            ;2S COMPLEMENT
  3123.     SSXM            ;SIGN EXTEND MODE
  3124.     SPM    1        ;P output is shifted left 1 bit
  3125.     LDPK    IOPAGE
  3126.     CALL    INIT        ;INITIALIZE
  3127. ;************************************************
  3128. ;*                MAIN I/O LOOP                 *
  3129. ;************************************************
  3130. DOUT    .set    6        ;D/A OUTPUT
  3131. DIN    .set    6        ;A/D INPUT
  3132. ;*
  3133. ;* The following three instructions are used in conjunction
  3134. ;* with the PATCH program to indicate an idle state where no
  3135. ;* machine cycles are being used to perform filter operations
  3136. ;* (i.e. The time that location 4 is 1 could be used to do
  3137. ;* other useful things).  PATCH monitors location 4 to determine
  3138. ;* percentage utilization of the processor by the filter.
  3139. ;*
  3140. LPTS:    LACK    1
  3141.     SACL    FILTT
  3142.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  3143. ;*
  3144. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  3145.     B    LPTSA        ;BRANCH IF NO CLOCK
  3146. ;*
  3147. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  3148.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  3149. ;*
  3150. ;* The following three instructions are used in conjunction
  3151. ;* with the PATCH program to indicate either a busy state or
  3152. ;* that the filter is in operation.
  3153. ;*
  3154.     LACK    0        ;GET CONSTANT FOR IDLE
  3155.     SACL    FILTT        ;SAVE FOR OUTPUT
  3156.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  3157. ;*
  3158. ;* The following three instructions are used to determine whether
  3159. ;* or not the filter should be active.  In the non-active state the
  3160. ;* input data is simply passed to the output.  In the active state
  3161. ;* the input data is filtered, then passed to the output.
  3162. ;*
  3163.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  3164.     LAC    FILTT
  3165.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  3166. ;*
  3167.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  3168.     B    LPTS        ;LOOP
  3169. %endif%%endif%;*************************************************
  3170. ;*           DATA MEMORY DEFINITION              *
  3171. ;*************************************************
  3172. ;*     CONTAINS:
  3173. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  3174. ;*          STORAGE FOR COEFFICIENTS
  3175. ;*          STORAGE FOR DELAY ELEMENTS
  3176. ;*************************************************
  3177. ;*
  3178. ;* FILTER INPUT and OUTPUT STORAGE
  3179. ;*
  3180. %if option M%FILTT    .set    1        ;TEMPORARY FILTER DATA
  3181. VSAMPL    .set    0        ;INPUT/OUTPUT FILTER DATA
  3182. IOPAGE    .set    4
  3183. %else%    .globl    V%IDT%,FILTT
  3184. %endif%;*
  3185. COEF:
  3186. ;*
  3187. ;*  FIR COEFFICIENTS
  3188. ;*
  3189. %do%%if coef<%%else%    .word    %coef%        ;%coef_name%
  3190. %endif%%loop%;*
  3191. ;*
  3192.     .sect    "D%IDT%"
  3193. ;*
  3194. ;* DELAY MEMORY STORAGE
  3195. ;*
  3196. DELAY:
  3197. %do%%Z_nameI%:    .space    1*16
  3198. %loop%;*
  3199. ;* COEFFICIENT DATA STORAGE
  3200. ;*
  3201. FDATA:
  3202. %do%%if coef<%%else%%coef_name%:    .space    1*16
  3203. %endif%%loop%;*
  3204. ;*
  3205.     .text
  3206. ;*************************************************
  3207. ;*       FILTER INITIALIZATION SUBROUTINE        *
  3208. ;*************************************************
  3209. %if option M%INIT%else%I%IDT%%endif%:
  3210.     LARP    0
  3211. %if data%    LRLK    0,FDATA        ;POINTER TO COEF. MEMORY
  3212. %copy_coef%%endif%    LRLK    0,DELAY        ;POINTER TO DELAY MEMORY
  3213.     ZAC            ;CLEAR ACCUMULATOR
  3214. %zero_delay%    RET            ;INIT RETURN
  3215. ;*************************************************
  3216. ;*              FILTER SUBROUTINE                *
  3217. ;*************************************************
  3218. ;*
  3219. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  3220. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  3221. ;* 
  3222. ;*************************************************
  3223. %if option M%FILTER%else%F%IDT%%endif%:
  3224. %filtin%    ZAC            ;INIT. ACC
  3225. %do%%if coef<>%    LT%if first%%else%D%endif%    %Z_name%
  3226. %if coef<%    MPYK    %coef%        ;%coef_name%
  3227. %else%    MPY    %coef_name%
  3228. %endif%%else%%if firstd%%else%    DMOV    %Z_name%
  3229. %endif%%endif%%loop%    APAC            ;FORM RESULT
  3230.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%%output_shift%    ;SAVE OUTPUT
  3231.     RET            ;RETURN
  3232.     .end
  3233. %end%
  3234. >>>>
  3235. >>>
  3236. 3
  3237. 6
  3238. %
  3239. TMS32020/c25; Indexed Memory; Internal Delay Memory
  3240. >>>
  3241. %batch_files 0  %    .title    "%IDT%"        ;Unique Identifier
  3242. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  3243.     .globl    I%IDT%        ;Name of filter initialization subroutine
  3244. %endif%;*************************************************
  3245. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  3246. ;*************************************************
  3247. ;*              EXTERNAL COEFFICIENTS
  3248. ;*                 INTERNAL DELAYS
  3249. ;*
  3250. ;*                 PARK-MCCLELLAN
  3251. ;*               %taps%-TAP FIR FILTER
  3252. ;*
  3253. ;*           FILTER GENERATED FROM FILE
  3254. %filter_file%
  3255. ;*
  3256. ;*************************************************
  3257.     .text
  3258. %if option M%%if main%%else%    B       START
  3259.     .space    254*16        ;Programs start at 100 Hex.
  3260. ;************************************************
  3261. ;*         ASPI CARD INITIALIZATION CODE        *
  3262. ;************************************************
  3263. START:
  3264.     CNFD            ;SET BANK 0 TO DATA MEMORY
  3265.     ROVM            ;2S COMPLEMENT
  3266.     SSXM            ;SIGN EXTEND MODE
  3267.     LDPK    IOPAGE        ;SET PAGE POINTER
  3268.     SPM    1        ;P output is shifted left 1 bit
  3269.     CALL    INIT        ;INITIALIZE
  3270. ;************************************************
  3271. ;*                MAIN I/O LOOP                 *
  3272. ;************************************************
  3273. DOUT    .set    6        ;D/A OUTPUT
  3274. DIN    .set    6        ;A/D INPUT
  3275. ;*
  3276. ;* The following three instructions are used in conjunction
  3277. ;* with the PATCH program to indicate an idle state where no
  3278. ;* machine cycles are being used to perform filter operations
  3279. ;* (i.e. The time that location 4 is 1 could be used to do
  3280. ;* other useful things).  PATCH monitors location 4 to determine
  3281. ;* percentage utilization of the processor by the filter.
  3282. ;*
  3283. LPTS:    LACK    1
  3284.     SACL    FILTT
  3285.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  3286. ;*
  3287. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  3288.     B    LPTSA        ;BRANCH IF NO CLOCK
  3289. ;*
  3290. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  3291.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  3292. ;*
  3293. ;* The following three instructions are used in conjunction
  3294. ;* with the PATCH program to indicate either a busy state or
  3295. ;* that the filter is in operation.
  3296. ;*
  3297.     LACK    0        ;GET CONSTANT FOR IDLE
  3298.     SACL    FILTT        ;SAVE FOR OUTPUT
  3299.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  3300. ;*
  3301. ;* The following three instructions are used to determine whether
  3302. ;* or not the filter should be active.  In the non-active state the
  3303. ;* input data is simply passed to the output.  In the active state
  3304. ;* the input data is filtered, then passed to the output.
  3305. ;*
  3306.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  3307.     LAC    FILTT
  3308.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  3309. ;*
  3310.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  3311.     B    LPTS        ;LOOP
  3312. %endif%%endif%;*************************************************
  3313. ;*           DATA MEMORY DEFINITION              *
  3314. ;*************************************************
  3315. ;*     CONTAINS:
  3316. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  3317. ;*          STORAGE FOR COEFFICIENTS
  3318. ;*          STORAGE FOR DELAY ELEMENTS
  3319. ;*************************************************
  3320. ;*
  3321. ;* FILTER INPUT and OUTPUT STORAGE
  3322. ;*
  3323. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  3324. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  3325. IOPAGE    .set    0
  3326. %else%    .globl    V%IDT%,FILTT
  3327. %endif%;*
  3328. COEF:
  3329. ;*
  3330. ;*  FIR COEFFICIENTS
  3331. ;*
  3332. %do%%if coef<%%else%    .word    %coef%        ;%coef_name%
  3333. %endif%%loop%;*
  3334. ;*
  3335.     .sect    "D%IDT%"
  3336. ;*
  3337. ;* DELAY STORAGE
  3338. ;*
  3339.     .globl    Z%IDT%,L%IDT%
  3340. Z%IDT%:    .space    1*16
  3341.     .space    (%ndelay%-1)*16
  3342. L%IDT%:    .space    1*16
  3343. ;*
  3344. ;*
  3345.     .sect    "X%IDT%"
  3346. ;*
  3347. ;* COEFFICIENT DATA STORAGE
  3348. ;*
  3349. FDATA:    .space    (%points%+1)*16
  3350. ;*
  3351. ;*
  3352.     .text
  3353. ;*************************************************
  3354. ;*       FILTER INITIALIZATION SUBROUTINE        *
  3355. ;*************************************************
  3356. %if option M%INIT%else%I%IDT%%endif%:
  3357.     LARP    0
  3358. %if data%    LRLK    0,FDATA        ;POINTER TO COEF. MEMORY
  3359. %copy_coef%%endif%    LRLK    0,Z%IDT%       ;POINTER TO DELAY MEMORY
  3360.     ZAC            ;CLEAR ACCUMULATOR
  3361. %zero_delay%    RET            ;INIT RETURN
  3362. ;*************************************************
  3363. ;*              FILTER SUBROUTINE                *
  3364. ;*************************************************
  3365. ;* ASSUMPTIONS:
  3366. ;*     PAGE POINTER must be set to 'DPAGE'.
  3367. ;*     The AR pointer register is destroyed.
  3368. ;*     The address registers 'COEFAR' and 'DELAR'
  3369. ;*        are destroyed by filter routine.
  3370. ;*     P output shift is set to 1.
  3371. ;*     SIGN EXTEND mode is ON.
  3372. ;*     Two's Complement Arithmetic.
  3373. ;*     COEF. elements are located in any in
  3374. ;*        data memory.
  3375. ;*     DELAY elements must be in internal memory
  3376. ;*        and must not cross a page boundary.
  3377. ;*
  3378. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  3379. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  3380. ;*
  3381. ;*************************************************
  3382. DELAR    .set    2
  3383. COEFAR    .set    1
  3384. ;*
  3385. %if option M%FILTER%else%F%IDT%%endif%:
  3386.     LARP    DELAR        ;POINT TO CORRECT AR
  3387.     LRLK    COEFAR,FDATA    ;AR = START OF COEF.
  3388.     LRLK    DELAR,Z%IDT%
  3389. %filtinI%    LRLK    DELAR,L%IDT%
  3390.     ZAC            ;INIT AC.
  3391. %do%%if coef<>%    LT%if first%%else%D%endif%    *-%if coef<%    %else%,COEFAR%endif%    ;%Z_name%
  3392. %if coef<%    MPYK    %coef%        ;%coef_name%
  3393. %else%    MPY    *+,DELAR    ;%coef_name%
  3394. %endif%%else%%if firstd%    MAR    *-
  3395. %else%    DMOV    *-        ;%Z_name%
  3396. %endif%%endif%%loop%    APAC            ;FORM RESULT
  3397.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%%output_shift%        ;SAVE OUTPUT
  3398. ;*
  3399.     RET            ;RETURN
  3400. ;*
  3401.     .end
  3402. %end%
  3403. >>>>
  3404. >>>
  3405. 3
  3406. 6
  3407. %
  3408. TMS32020/c25; Indexed Memory; Internal or External Memory
  3409. >>>
  3410. %batch_files 0  %    .title    "%IDT%"        ;Unique Identifier
  3411. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  3412.     .globl    I%IDT%        ;Name of filter initialization subroutine
  3413. %endif%;*************************************************
  3414. ;*    ASPI TMS32020 DIGITAL FILTER REALIZATION   *
  3415. ;*************************************************
  3416. ;*              EXTERNAL MEMORY MODEL
  3417. ;*
  3418. ;*                 PARK-MCCLELLAN
  3419. ;*               %taps%-TAP FIR FILTER
  3420. ;*
  3421. ;*           FILTER GENERATED FROM FILE
  3422. %filter_file%
  3423. ;*
  3424. ;*************************************************
  3425.     .text
  3426. %if option M%%if main%%else%    B    START
  3427.     .space    254*16        ;Programs start at 100 Hex.
  3428. ;************************************************
  3429. ;*         ASPI CARD INITIALIZATION CODE        *
  3430. ;************************************************
  3431. START:
  3432.     CNFD            ;SET BANK 0 TO DATA MEMORY
  3433.     ROVM            ;2S COMPLEMENT
  3434.     SSXM            ;SIGN EXTEND MODE
  3435.     SPM    1        ;P output is shifted left 1 bit
  3436.     LDPK    IOPAGE
  3437.     CALL    INIT        ;INITIALIZE
  3438. ;*
  3439. ;************************************************
  3440. ;*                MAIN I/O LOOP                 *
  3441. ;************************************************
  3442. DOUT    .set    6        ;D/A OUTPUT
  3443. DIN    .set    6        ;A/D INPUT
  3444. ;*
  3445. ;* The following three instructions are used in conjunction
  3446. ;* with the PATCH program to indicate an idle state where no
  3447. ;* machine cycles are being used to perform filter operations
  3448. ;* (i.e. The time that location 4 is 1 could be used to do
  3449. ;* other useful things).  PATCH monitors location 4 to determine
  3450. ;* percentage utilization of the processor by the filter.
  3451. ;*
  3452. LPTS:    LACK    1
  3453.     SACL    FILTT
  3454.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  3455. ;*
  3456. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  3457.     B    LPTSA        ;BRANCH IF NO CLOCK
  3458. ;*
  3459. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  3460.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  3461. ;*
  3462. ;* The following three instructions are used in conjunction
  3463. ;* with the PATCH program to indicate either a busy state or
  3464. ;* that the filter is in operation.
  3465. ;*
  3466.     LACK    0        ;GET CONSTANT FOR IDLE
  3467.     SACL    FILTT        ;SAVE FOR OUTPUT
  3468.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  3469. ;*
  3470. ;* The following three instructions are used to determine whether
  3471. ;* or not the filter should be active.  In the non-active state the
  3472. ;* input data is simply passed to the output.  In the active state
  3473. ;* the input data is filtered, then passed to the output.
  3474. ;*
  3475.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  3476.     LAC    FILTT
  3477.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  3478. ;*
  3479.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  3480.     B    LPTS        ;LOOP
  3481. %endif%%endif%;*************************************************
  3482. ;*           DATA MEMORY DEFINITION              *
  3483. ;*************************************************
  3484. ;*     CONTAINS:
  3485. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  3486. ;*          STORAGE FOR COEFFICIENTS
  3487. ;*          STORAGE FOR DELAY ELEMENTS
  3488. ;*************************************************
  3489. ;*
  3490. ;* FILTER INPUT and OUTPUT STORAGE
  3491. ;*
  3492. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  3493. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  3494. IOPAGE    .set    0
  3495. %else%    .globl    V%IDT%,FILTT
  3496. %endif%;*
  3497. COEF:
  3498. ;*
  3499. ;*  FIR INITIALIZATION COEFFICIENTS
  3500. ;*
  3501. %do%%if coef<%%else%    .word    %coef%        ;%coef_name%
  3502. %endif%%loop%;*
  3503. ;*
  3504.     .sect    "X%IDT%"
  3505. ;*
  3506. ;* COEFFICIENT DATA STORAGE
  3507. ;*
  3508. FDATA:    .space    %points%*16
  3509. LCOEF:    .space    1*16
  3510. ;*
  3511. ;* DELAY STORAGE
  3512. ;*
  3513. ZLAST:    .space    1*16
  3514.     .space    (%ndelay%-1)*16
  3515. Z000:    .space    1*16
  3516. ;*
  3517. ;*
  3518.     .text
  3519. ;*************************************************
  3520. ;*       FILTER INITIALIZATION SUBROUTINE        *
  3521. ;*************************************************
  3522. %if option M%INIT%else%I%IDT%%endif%:
  3523.     LARP    0
  3524. %if data%    LRLK    0,FDATA        ;POINTER TO COEF. MEMORY
  3525. %copy_coef%%endif%    LRLK    0,ZLAST        ;POINTER TO DELAY MEMORY
  3526.     ZAC            ;CLEAR ACCUMULATOR
  3527. %zero_delay%    RET            ;INIT RETURN
  3528. ;*************************************************
  3529. ;*              FILTER SUBROUTINE                *
  3530. ;*************************************************
  3531. ;* ASSUMPTIONS:
  3532. ;*     PAGE POINTER must point to page with
  3533. ;*        %if option M%VSAMPL%else%V%IDT%%endif%.
  3534. ;*     The address registers 'COEFAR' and 'DELAR'
  3535. ;*        are destroyed by filter routine.
  3536. ;*     P output shift is set to 1.
  3537. ;*     SIGN EXTEND mode is ON.
  3538. ;*     Two's Complement Arithmetic.
  3539. ;*     COEF. & DELAY elements are located any in
  3540. ;*        data memory.
  3541. ;*
  3542. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  3543. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  3544. ;*
  3545. ;*************************************************
  3546. COEFAR    .set    1
  3547. DELAR    .set    2
  3548. ;*
  3549. %if option M%FILTER%else%F%IDT%%endif%:
  3550.     LRLK    COEFAR,LCOEF    ;INIT INDEX REGISTER POINTERS
  3551.     LRLK    DELAR,Z000
  3552.     LARP    DELAR        ;POINTER TO CORRECT INDEX REGISTER
  3553. %filtinI%%do%    LT%if first%%elseif second%P%else%A%endif%    *-%if coef<%%else%,COEFAR%endif%
  3554. %if coef<%    MPYK    %coefI%        ;%coef_nameI%
  3555. %else%    MPY    *-,DELAR    ;%coef_nameI%
  3556. %endif%%loop%    APAC            ;FORM RESULT
  3557.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%%output_shift%    ;SAVE OUTPUT
  3558. ;*
  3559.     LRLK    DELAR,ZLAST
  3560. %move_delay%;*
  3561.     RET            ;RETURN
  3562. ;*
  3563.     .end
  3564. %end%
  3565. >>>>
  3566. >>>
  3567. 1
  3568. 7
  3569. %
  3570. TMS320c25; Direct Paged Memory
  3571. >>>
  3572. %batch_files 2  %    .title    "%IDT%"        ;Unique Identifier
  3573. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  3574.     .globl    I%IDT%        ;Name of filter initialization subroutine
  3575. %endif%;*************************************************
  3576. ;*   ASPI TMS320c25 DIGITAL FILTER REALIZATION   *
  3577. ;*************************************************
  3578. ;*          %stages%-STAGE RECURSIVE FILTER
  3579. ;*            SECOND ORDER SECTIONS
  3580. ;*          FILTER GENERATED FROM FILE
  3581. %filter_file%
  3582. ;*
  3583. ;*************************************************
  3584.     .text
  3585. %if option M%%if main%%else%    B    START
  3586.     .space    254*16        ;Programs start at 100 Hex.
  3587. ;************************************************
  3588. ;*         ASPI CARD INITIALIZATION CODE        *
  3589. ;************************************************
  3590. START:
  3591.     CNFD            ;SET BANK 0 TO DATA MEMORY
  3592.     LDPK    IOPAGE        ;SET PAGE POINTER
  3593.     SOVM            ;SATURATION ARITHMETIC
  3594.     SSXM            ;SET SIGN EXTEND MODE ON
  3595.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  3596.     CALL    INIT        ;INITIALIZE
  3597. ;************************************************
  3598. ;*                MAIN I/O LOOP                 *
  3599. ;************************************************
  3600. DOUT    .set    6        ;D/A OUTPUT
  3601. DIN    .set    6        ;A/D INPUT
  3602. ;*
  3603. ;* The following three instructions are used in conjunction
  3604. ;* with the PATCH program to indicate an idle state where no
  3605. ;* machine cycles are being used to preform filter operation
  3606. ;* (i.e. The time that location 4 is 1 could be used to do
  3607. ;* other useful things).  PATCH monitors location 4 to determine
  3608. ;* percetage utilization of the processor by the filter.
  3609. ;*
  3610. LPTS:    LACK    1
  3611.     SACL    FILTT
  3612.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  3613. ;*
  3614. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  3615.     B    LPTSA        ;BRANCH IF NO CLOCK
  3616. ;*
  3617. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  3618.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  3619. ;*
  3620. ;* The following three instructions are used in conjuction
  3621. ;* with the PATCH program to indicate a busy state or that the
  3622. ;* filter is in operation.
  3623. ;*
  3624.     LACK    0        ;GET CONSTANT FOR IDLE
  3625.     SACL    FILTT        ;SAVE FOR OUTPUT
  3626.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  3627. ;*
  3628. ;* The following three instructions are used to determine whether
  3629. ;* or not the filter should be active.  In the non-active state the
  3630. ;* input data is simply passed to the output.  In the active state
  3631. ;* the input data is filtered, then passed to the output.
  3632. ;*
  3633.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  3634.     LAC    FILTT
  3635.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  3636. ;*
  3637.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  3638.     B    LPTS        ;LOOP
  3639. %endif%%endif%;*************************************************
  3640. ;*           DATA MEMORY DEFINITION              *
  3641. ;*************************************************
  3642. ;*     CONTAINS:
  3643. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  3644. ;*          STORAGE FOR COEFFICIENTS
  3645. ;*          STORAGE FOR DELAY ELEMENTS
  3646. ;*************************************************
  3647. ;*
  3648. ;* FILTER INPUT and OUTPUT STORAGE
  3649. ;*
  3650. %if option M%FILTT    .set    0        ;TEMPORARY FILTER DATA
  3651. VSAMPL    .set    1        ;INPUT/OUTPUT FILTER DATA
  3652. IOPAGE    .set    6
  3653. %else%    .globl    FILTT,V%IDT%
  3654. %endif%;*
  3655. COEF:
  3656. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  3657. ;*
  3658. %section%;*
  3659. ;*
  3660. ;*  SECOND-ORDER SECTION # %section_n%
  3661. ;*
  3662. %if B0<%%else%    .word    %B0%        ;B0
  3663. %endif%%if B1<>%    .word    %B1%        ;B1
  3664. %endif%%if A1<%%else%    .word    %A1%        ;A1
  3665. %endif%%if half%%else%    .word    %A2%        ;A2
  3666. %if B2<%%else%    .word    %B2%        ;B2
  3667. %endif%%endif%%loop%;*
  3668. ;*
  3669.     .sect    "X%IDT%"
  3670. ;* DELAY STORAGE DATA STORAGE AREA
  3671. ;*
  3672. DELAY:
  3673. %section%Z%section_n%1:    .space    1*16
  3674. %if half%%else%Z%section_n%2:    .space    1*16
  3675. %endif%%loop%;*
  3676. ;*
  3677. ;* COEFFICIENT DATA STORAGE AREA
  3678. ;*
  3679. FDATA:
  3680. %section%;*
  3681. %if B0<%%else%B%section_n%0:    .space    1*16    ;B0
  3682. %endif%%if B1<>%B%section_n%1:    .space    1*16    ;B1
  3683. %endif%%if A1<%%else%A%section_n%1:    .space    1*16    ;A1
  3684. %endif%%if half%%else%A%section_n%2:    .space    1*16    ;A2
  3685. %if B2<%%else%B%section_n%2:    .space    1*16    ;B2
  3686. %endif%%endif%%loop%;*
  3687. ;*
  3688. ;*
  3689.     .text
  3690. ;*************************************************
  3691. ;*       FILTER INITIALIZATION SUBROUTINE        *
  3692. ;*************************************************
  3693. %if option M%INIT%else%I%IDT%%endif%:
  3694.     LARP    0        ;POINT TO AR0
  3695.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  3696. %if data%    RPTK    %points%        ;COUNT FOR NUMBER OF POINTS
  3697.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  3698. %endif%    ZAC            ;CLEAR ACCUMULATOR
  3699.     LRLK    0,DELAY
  3700.     RPTK    %ndelay%        ;NUMBER OF DELAY POINTS
  3701.     SACL    *+        ;CLEAR DATA VALUE
  3702.     RET            ;INIT RETURN
  3703. ;*************************************************
  3704. ;*              FILTER SUBROUTINE                *
  3705. ;*************************************************
  3706. ;*   ASSUMPTIONS:
  3707. ;*      SATURATION ARITHMETIC MODE IS ON
  3708. ;*      P REGISTER OUTPUT SHIFT = 1
  3709. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  3710. ;*      SIGN EXTEND MODE IS ON
  3711. ;*
  3712. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  3713. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  3714. ;*
  3715. ;*************************************************
  3716. ;*
  3717. %if option M%FILTER%else%F%IDT%%endif%:
  3718. %section%;*
  3719. ;* SECOND-ORDER FILTER SECTION # %section_n%
  3720. ;*
  3721. %filtin%%if half%    LT    FILTT        ;GET SCALED INPUT
  3722. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  3723. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  3724. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  3725. %if B1<>%    MPYA    B%section_n%1        ;AC = Z-1 + (B0 * INPUT)
  3726. ;*                ;P = B1 * INPUT
  3727. %else%    APAC            ;AC = Z-1 + (B0 * INPUT)
  3728. %endif%    SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  3729.     LT%if B1<>%P%endif%    %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>%        ;AC = B1 * INPUT%endif%
  3730. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  3731. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  3732. %endif%    %if B1<>%A%endif%PAC            ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  3733. %if A1shft%    APAC
  3734. %endif%    SACH    Z%section_n%1        ;Save in Z-1
  3735. %else 
  3736.  
  3737. %%if B1<>%    LT    FILTT        ;GET SCALED INPUT
  3738. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  3739. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  3740. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  3741.     MPYA    B%section_n%1        ;AC = Z-1 + (B0 * INPUT)
  3742. ;*                ;P = B1 * INPUT
  3743.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  3744.     LTP    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = B1 * INPUT 
  3745.     ADDH    Z%section_n%2        ;AC = Z-2 + (B1 * INPUT)
  3746. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  3747. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  3748. %endif%%if A1shft%    APAC
  3749. %endif%    MPYA    A%section_n%2        ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
  3750. ;*                ;P = A2 * OUTPUT
  3751.     SACH    Z%section_n%1        ;Save in Z-1
  3752.     LTP    FILTT        ;AC = A2 * OUTPUT
  3753. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  3754. %else%    MPY    B%section_n%2        ;P = B2 * INPUT
  3755. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  3756.      SACH    Z%section_n%2    ;Save in Z-2
  3757. %else 
  3758.  
  3759.  
  3760. %    LT    FILTT        ;GET SCALED INPUT
  3761. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  3762. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  3763. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  3764.     APAC            ;AC = Z-1 + (B0 * INPUT)
  3765.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  3766.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;Get OUTPUT
  3767.     ZALH    Z%section_n%2        ;AC = Z-2
  3768. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  3769. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  3770. %endif%%if A1shft%    APAC
  3771. %endif%    MPYA    A%section_n%2        ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  3772. ;*                ;P = A2 * OUTPUT
  3773.     SACH    Z%section_n%1    ;Save in Z-1
  3774.     LTP    FILTT        ;AC = A2 * OUTPUT
  3775. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  3776. %else%    MPY    B%section_n%2        ;P = B2 * INPUT
  3777. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  3778.      SACH    Z%section_n%2    ;Save in Z-2
  3779. %endif%%endif%%loop%*
  3780.     RET            ;RETURN
  3781.     .end
  3782. %end%
  3783. >>>>
  3784. >>>
  3785. 1
  3786. 7
  3787. %
  3788. TMS320c25; Direct Paged Memory; Increased Precision
  3789. >>>
  3790. %batch_files 2  %    .title    "%IDT%"        ;Unique Identifier
  3791. %if option M%%else%    .globl    F%IDT%        ;*Name of filter subroutine
  3792.     .globl    I%IDT%        ;Name of filter initialization subroutine
  3793. %endif%;*************************************************
  3794. ;*   ASPI TMS320c25 DIGITAL FILTER REALIZATION   *
  3795. ;*************************************************
  3796. ;*       INCREASED PRECISION IMPLEMENTATION
  3797. ;*
  3798. ;*          %stages%-STAGE RECURSIVE FILTER
  3799. ;*            SECOND ORDER SECTIONS
  3800. ;*          FILTER GENERATED FROM FILE
  3801. %filter_file%
  3802. ;*
  3803. ;*************************************************
  3804.     .text
  3805. %if option M%%if main%%else%    B    START
  3806.     .space    254*16        ;Programs start at 100 Hex.
  3807. ;************************************************
  3808. ;*         ASPI CARD INITIALIZATION CODE        *
  3809. ;************************************************
  3810. START:
  3811.     CNFD            ;SET BANK 0 TO DATA MEMORY
  3812.     LDPK    IOPAGE        ;SET PAGE POINTER
  3813.     SOVM            ;SATURATION ARITHMETIC
  3814.     SSXM            ;SET SIGN EXTEND MODE ON
  3815.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  3816.     CALL    INIT        ;INITIALIZE
  3817. ;************************************************
  3818. ;*                MAIN I/O LOOP                 *
  3819. ;************************************************
  3820. DOUT    EQU    6        ;D/A OUTPUT
  3821. DIN    EQU    6        ;A/D INPUT
  3822. ;*
  3823. ;* The following three instructions are used in conjunction
  3824. ;* with the PATCH program to indicate an idle state where no
  3825. ;* machine cycles are being used to preform filter operation
  3826. ;* (i.e. The time that location 4 is 1 could be used to do
  3827. ;* other useful things).  PATCH monitors location 4 to determine
  3828. ;* percetage utilization of the processor by the filter.
  3829. ;*
  3830. LPTS:    LACK    1
  3831.     SACL    FILTT
  3832.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  3833. ;*
  3834. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  3835.     B    LPTSA        ;BRANCH IF NO CLOCK
  3836. ;*
  3837. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  3838.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  3839. ;*
  3840. ;* The following three instructions are used in conjuction
  3841. ;* with the PATCH program to indicate a busy state or that the
  3842. ;* filter is in operation.
  3843. ;*
  3844.     LACK    0        ;GET CONSTANT FOR IDLE
  3845.     SACL    FILTT        ;SAVE FOR OUTPUT
  3846.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  3847. ;*
  3848. ;* The following three instructions are used to determine whether
  3849. ;* or not the filter should be active.  In the non-active state the
  3850. ;* input data is simply passed to the output.  In the active state
  3851. ;* the input data is filtered, then passed to the output.
  3852. ;*
  3853.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  3854.     LAC    FILTT
  3855.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  3856. ;*
  3857.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  3858.     B    LPTS        ;LOOP
  3859. %endif%%endif%;*************************************************
  3860. ;*           DATA MEMORY DEFINITION              *
  3861. ;*************************************************
  3862. ;*     CONTAINS:
  3863. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  3864. ;*          STORAGE FOR COEFFICIENTS
  3865. ;*          STORAGE FOR DELAY ELEMENTS
  3866. ;*************************************************
  3867. ;*
  3868. ;* FILTER INPUT and OUTPUT STORAGE
  3869. ;*
  3870. %if option M%FILTT    .set    0        ;TEMPORARY FILTER DATA
  3871. VSAMPL    .set    1        ;INPUT/OUTPUT FILTER DATA
  3872. IOPAGE    .set    6
  3873. %else%    .globl    FILTT,V%IDT%
  3874. %endif%;*
  3875. COEF:
  3876. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  3877. ;*
  3878. %section%;*
  3879. ;*
  3880. ;*  SECOND-ORDER SECTION # %section_n%
  3881. ;*
  3882. %if B0<%%else%    .word    %B0%        ;B0
  3883. %endif%%if B1<>%    .word    %B1%        ;B1
  3884. %endif%%if A1<%%else%    .word    %A1%        ;A1
  3885. %endif%%if half%%else%    .word    %A2%        ;A2
  3886. %if B2<%%else%    .word    %B2%        ;B2
  3887. %endif%%endif%%loop%;*
  3888. ;*
  3889.     .sect    "X%IDT%"
  3890. ;* DELAY STORAGE DATA STORAGE AREA
  3891. ;*
  3892. DELAY:
  3893. %section%Z%section_n%1:    .space    1*16
  3894. L%section_n%1:    .space    1*16
  3895. %if half%%else%Z%section_n%2:    .space    1*16
  3896. L%section_n%2:    .space    1*16
  3897. %endif%%loop%;*
  3898. ;*
  3899. ;* COEFFICIENT DATA STORAGE AREA
  3900. ;*
  3901. FDATA:
  3902. %section%;*
  3903. %if B0<%%else%B%section_n%0:    .space    1*16    ;B0
  3904. %endif%%if B1<>%B%section_n%1:    .space    1*16    ;B1
  3905. %endif%%if A1<%%else%A%section_n%1:    .space    1*16    ;A1
  3906. %endif%%if half%%else%A%section_n%2:    .space    1*16    ;A2
  3907. %if B2<%%else%B%section_n%2:    .space    1*16    ;B2
  3908. %endif%%endif%%loop%;*
  3909. ;*
  3910.     .text
  3911. ;*************************************************
  3912. ;*       FILTER INITIALIZATION SUBROUTINE        *
  3913. ;*************************************************
  3914. %if option M%INIT%else%I%IDT%%endif%:
  3915.     LARP    0        ;POINT TO AR0
  3916.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  3917. %if data%    RPTK    %points%        ;COUNT FOR NUMBER OF POINTS
  3918.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  3919. %endif%    ZAC            ;CLEAR ACCUMULATOR
  3920.     LRLK    0,DELAY
  3921.     RPTK    %ndelay%+%ndelay%+1        ;NUMBER OF DELAY POINTS
  3922.     SACL    *+        ;CLEAR DATA VALUE
  3923.     RET            ;INIT RETURN
  3924. ;*************************************************
  3925. ;*              FILTER SUBROUTINE                *
  3926. ;*************************************************
  3927. ;*   ASSUMPTIONS:
  3928. ;*      SATURATION ARITHMETIC MODE IS ON
  3929. ;*      P REGISTER OUTPUT SHIFT = 1
  3930. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  3931. ;*      SIGN EXTEND MODE IS ON
  3932. ;*
  3933. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  3934. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  3935. ;*
  3936. ;*************************************************
  3937. ;*
  3938. %if option M%FILTER%else%F%IDT%%endif%:
  3939. %section%;*
  3940. ;* SECOND-ORDER FILTER SECTION # %section_n%
  3941. ;*
  3942. %filtin%%if half%    LT    FILTT        ;GET SCALED INPUT
  3943. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  3944. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  3945. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  3946.     ADDS    L%section_n%1        ;ADD in least significant
  3947. %if B1<>%    MPYA    B%section_n%1        ;AC = Z-1 + (B0 * INPUT)
  3948. ;*                ;P = B1 * INPUT
  3949. %else%    APAC            ;AC = Z-1 + (B0 * INPUT)
  3950. %endif%    SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  3951.     LT%if B1<>%P%endif%    %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>%        ;AC = B1 * INPUT%endif%
  3952. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  3953. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  3954. %endif%    %if B1<>%A%endif%PAC            ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  3955. %if A1shft%    APAC
  3956. %endif%    SACH    Z%section_n%1        ;Save in Z-1
  3957.     SACL    L%section_n%1        ;Save least significant
  3958. %else 
  3959.  
  3960. %%if B1<>%    LT    FILTT        ;GET SCALED INPUT
  3961. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  3962. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  3963. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  3964.     ADDS    L%section_n%1        ;ADD in least significant
  3965.     MPYA    B%section_n%1        ;AC = Z-1 + (B0 * INPUT)
  3966. ;*                ;P = B1 * INPUT
  3967.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  3968.     LTP    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = B1 * INPUT 
  3969.     ADDH    Z%section_n%2        ;AC = Z-2 + (B1 * INPUT)
  3970.     ADDS    L%section_n%2        ;ADD in least significant
  3971. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  3972. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  3973. %endif%%if A1shft%    APAC
  3974. %endif%    MPYA    A%section_n%2        ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
  3975. ;*                ;P = A2 * OUTPUT
  3976.     SACH    Z%section_n%1        ;Save in Z-1
  3977.     SACL    L%section_n%1        ;Save least significant
  3978.     LTP    FILTT        ;AC = A2 * OUTPUT
  3979. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  3980. %else%    MPY    B%section_n%2        ;P = B2 * INPUT
  3981. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  3982.      SACH    Z%section_n%2        ;Save in Z-2
  3983.     SACL    L%section_n%2        ;Save least significant
  3984. %else 
  3985.  
  3986.  
  3987. %    LT    FILTT        ;GET SCALED INPUT
  3988. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  3989. %else%    MPY    B%section_n%0        ;P = B0 * INPUT
  3990. %endif%    ZALH    Z%section_n%1        ;AC = Z-1
  3991.     ADDS    L%section_n%1        ;ADD in least significant
  3992.     APAC            ;AC = Z-1 + (B0 * INPUT)
  3993.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  3994.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;Get OUTPUT
  3995.     ZALH    Z%section_n%2        ;AC = Z-2
  3996.     ADDS    L%section_n%2        ;ADD in least significant
  3997. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  3998. %else%    MPY    A%section_n%1        ;P = A1 * OUTPUT
  3999. %endif%%if A1shft%    APAC
  4000. %endif%    MPYA    A%section_n%2        ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  4001. ;*                ;P = A2 * OUTPUT
  4002.     SACH    Z%section_n%1        ;Save in Z-1
  4003.     SACL    L%section_n%1        ;Save least significant
  4004.     LTP    FILTT        ;AC = A2 * OUTPUT
  4005. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  4006. %else%    MPY    B%section_n%2        ;P = B2 * INPUT
  4007. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  4008.      SACH    Z%section_n%2        ;Save in Z-2
  4009.     SACL    L%section_n%2        ;Save least significant
  4010. %endif%%endif%%loop%*
  4011.     RET            ;RETURN
  4012.     .end
  4013. %end%
  4014. >>>>
  4015. >>>
  4016. 1
  4017. 7
  4018. %
  4019. TMS320c25; Indexed Memory
  4020. >>>
  4021. %batch_files 0  %    .title    "%IDT%"            ;UNIQUE NAME
  4022. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  4023.     .globl    I%IDT%        ;Name of filter initialization subroutine
  4024. %endif%;**************************************************
  4025. ;*   ASPI TMS320c25 DIGITAL FILTER REALIZATION    *
  4026. ;**************************************************
  4027. ;*          %stages%-STAGE RECURSIVE FILTER
  4028. ;*            SECOND ORDER SECTIONS
  4029. ;*          FILTER GENERATED FROM FILE
  4030. %filter_file%
  4031. ;*
  4032. ;*************************************************
  4033.     .text
  4034. %if option M%%if main%%else%    B    START
  4035.     .space    254*16        ;Programs start at 100 Hex.
  4036. ;************************************************
  4037. ;*         ASPI CARD INITIALIZATION CODE        *
  4038. ;************************************************
  4039. START:
  4040.     CNFD            ;SET BANK 0 TO DATA MEMORY
  4041.     LDPK    IOPAGE        ;SET PAGE POINTER
  4042.     SOVM            ;SATURATION ARITHMETIC
  4043.     SSXM            ;SET SIGN EXTEND MODE ON
  4044.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  4045.     CALL    INIT        ;INITIALIZE
  4046. ;************************************************
  4047. ;*                MAIN I/O LOOP                 *
  4048. ;************************************************
  4049. DOUT    .set    6        ;D/A OUTPUT
  4050. DIN    .set    6        ;A/D INPUT
  4051. ;*
  4052. ;* The following three instructions are used in conjunction
  4053. ;* with the PATCH program to indicate an idle state where no
  4054. ;* machine cycles are being used to preform filter operation
  4055. ;* (i.e. The time that location 4 is 1 could be used to do
  4056. ;* other useful things).  PATCH monitors location 4 to determine
  4057. ;* percetage utilization of the processor by the filter.
  4058. ;*
  4059. LPTS:    LACK    1
  4060.     SACL    FILTT
  4061.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  4062. ;*
  4063. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  4064.     B    LPTSA        ;BRANCH IF NO CLOCK
  4065. ;*
  4066. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  4067.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  4068. ;*
  4069. ;* The following three instructions are used in conjuction
  4070. ;* with the PATCH program to indicate a busy state or that the
  4071. ;* filter is in operation.
  4072. ;*
  4073.     LACK    0        ;GET CONSTANT FOR IDLE
  4074.     SACL    FILTT        ;SAVE FOR OUTPUT
  4075.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  4076. ;*
  4077. ;* The following three instructions are used to determine whether
  4078. ;* or not the filter should be active.  In the non-active state the
  4079. ;* input data is simply passed to the output.  In the active state
  4080. ;* the input data is filtered, then passed to the output.
  4081. ;*
  4082.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  4083.     LAC    FILTT
  4084.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  4085. ;*
  4086.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  4087.     B    LPTS        ;LOOP
  4088. %endif%%endif%;*************************************************
  4089. ;*           DATA MEMORY DEFINITION              *
  4090. ;*************************************************
  4091. ;*     CONTAINS:
  4092. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  4093. ;*          STORAGE FOR COEFFICIENTS
  4094. ;*          STORAGE FOR DELAY ELEMENTS
  4095. ;*************************************************
  4096. ;*
  4097. ;* FILTER INPUT and OUTPUT STORAGE
  4098. ;*
  4099. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  4100. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  4101. IOPAGE    .set    0
  4102. %else%    .globl    FILTT,V%IDT%
  4103. %endif%;*
  4104. COEF:
  4105. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  4106. ;*
  4107. %section%;*
  4108. ;*
  4109. ;*  SECOND-ORDER SECTION # %section_n%
  4110. ;*
  4111. %if B0<%%else%    .word    %B0%        ;B0
  4112. %endif%%if B1<>%    .word    %B1%        ;B1
  4113. %endif%%if A1<%%else%    .word    %A1%        ;A1
  4114. %endif%%if half%%else%    .word    %A2%        ;A2
  4115. %if B2<%%else%    .word    %B2%        ;B2
  4116. %endif%%endif%%loop%;*
  4117. ;*
  4118.     .sect    "X%IDT%"
  4119. ;*
  4120. ;* COEFFICIENT DATA STORAGE AREA
  4121. ;*
  4122. FDATA:    .space    (%points%+1)*16
  4123. ;*
  4124. ;* DELAY STORAGE DATA STORAGE AREA
  4125. ;*
  4126. DELAY:    .space    (%ndelay%+1)*16
  4127. ;*
  4128. ;*
  4129.     .text
  4130. ;*************************************************
  4131. ;*       FILTER INITIALIZATION SUBROUTINE        *
  4132. ;*************************************************
  4133. %if option M%INIT%else%I%IDT%%endif%:
  4134.     LARP    0        ;POINT TO AR0
  4135.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  4136. %if data%    RPTK    %points%        ;COUNT FOR NUMBER OF POINTS
  4137.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  4138. %endif%    ZAC            ;CLEAR ACCUMULATOR
  4139.     LRLK    0,DELAY
  4140.     RPTK    %ndelay%        ;NUMBER OF DELAY POINTS
  4141.     SACL    *+        ;CLEAR DATA VALUE
  4142.     RET            ;INIT RETURN
  4143. ;*************************************************
  4144. ;*              FILTER SUBROUTINE                *
  4145. ;*************************************************
  4146. ;*   ASSUMPTIONS:
  4147. ;*      SATURATION ARITHMETIC MODE IS ON
  4148. ;*      P REGISTER OUTPUT SHIFT = 1
  4149. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  4150. ;*      SIGN EXTEND MODE IS ON
  4151. ;*
  4152. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  4153. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  4154. ;*
  4155. ;*************************************************
  4156. COEFAR    .set    1        ;Use AR1 to point to COEF's
  4157. DELAR    .set    2        ;Use AR2 to point to DELAY's
  4158. ;*
  4159. %if option M%FILTER%else%F%IDT%%endif%:
  4160.     LRLK    COEFAR,FDATA    ;Load COEF AR with beginning of COEF's
  4161.     LRLK    DELAR,DELAY    ;Load DELAY AR with beginning of DELAY's
  4162.     LARP    %if B10<%DELAR%else%COEFAR%endif%        ;Select Proper AR for initial use
  4163. %section%;*
  4164. ;* SECOND-ORDER FILTER SECTION # %section_n%
  4165. ;*
  4166. %filtin%%if half%    LT    FILTT        ;GET SCALED INPUT
  4167. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  4168. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  4169. %endif%    ZALH    *,COEFAR    ;AC = Z-1
  4170. %if B1<>%    MPYA    *+,%if A1<%DELAR%else%COEFAR%endif%    ;AC = Z-1 + (B0 * INPUT)
  4171. ;*                ;P = B1 * INPUT
  4172. %else%    APAC            ;AC = Z-1 + (B0 * INPUT)
  4173. %endif%    SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  4174.     LT%if B1<>%P%endif%    %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>%        ;AC = B1 * INPUT%endif%
  4175. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  4176. %else%    MPY    *+,DELAR    ;P = A1 * OUTPUT
  4177. %endif%    %if B1<>%A%endif%PAC            ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  4178. %if A1shft%    APAC
  4179. %endif%    SACH    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save in Z-1
  4180. %else 
  4181.  
  4182. %%if B1<>%    LT    FILTT        ;GET SCALED INPUT
  4183. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  4184. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  4185. %endif%    ZALH    *+,COEFAR    ;AC = Z-1
  4186.     MPYA    *+,DELAR    ;AC = Z-1 + (B0 * INPUT)
  4187. ;*                ;P = B1 * INPUT
  4188.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  4189.     LTP    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = B1 * INPUT 
  4190.     ADDH    *-,COEFAR    ;AC = Z-2 + (B1 * INPUT)
  4191. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  4192. %else%    MPY    *+        ;P = A1 * OUTPUT
  4193. %endif%%if A1shft%    APAC
  4194. %endif%    MPYA    *+,DELAR    ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
  4195. ;*                ;P = A2 * OUTPUT
  4196.     SACH    *+,0,%if B2<%DELAR%else%COEFAR%endif%    ;Save in Z-1
  4197.     LTP    FILTT        ;AC = A2 * OUTPUT
  4198. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  4199. %else%    MPY    *+,DELAR    ;P = B2 * INPUT
  4200. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  4201.      SACH    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save in Z-2
  4202. %else 
  4203.  
  4204.  
  4205. %    LT    FILTT        ;GET SCALED INPUT
  4206. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  4207. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  4208. %endif%    ZALH    *+,DELAR    ;AC = Z-1
  4209.     APAC            ;AC = Z-1 + (B0 * INPUT)
  4210.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  4211.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;Get OUTPUT
  4212.     ZALH    *-,COEFAR    ;AC = Z-2
  4213. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  4214. %else%    MPY    *+        ;P = A1 * OUTPUT
  4215. %endif%%if A1shft%    APAC
  4216. %endif%    MPYA    *+,DELAR    ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  4217. ;*                ;P = A2 * OUTPUT
  4218.     SACH    *+,0,%if B2<%DELAR%else%COEFAR%endif%    ;Save in Z-1
  4219.     LTP    FILTT        ;AC = A2 * OUTPUT
  4220. %if B2<%    MPYK    %B2%    ;P = B2 * INPUT
  4221. %else%    MPY    *+,DELAR    ;P = B2 * INPUT
  4222. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  4223.      SACH    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save in Z-2
  4224. %endif%%endif%%loop%;*
  4225.     RET            ;RETURN
  4226.     .end
  4227. %end%
  4228. >>>>
  4229. >>>
  4230. 1
  4231. 7
  4232. %
  4233. TMS320c25; Indexed Memory; Increased Precision
  4234. >>>
  4235. %batch_files 0  %    .title    "%IDT%"            ;UNIQUE NAME
  4236. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  4237.     .globl    I%IDT%        ;Name of filter initialization subroutine
  4238. %endif%;**************************************************
  4239. ;*   ASPI TMS320c25 DIGITAL FILTER REALIZATION    *
  4240. ;**************************************************
  4241. ;*             Increased Precision
  4242. ;*          %stages%-STAGE RECURSIVE FILTER
  4243. ;*            SECOND ORDER SECTIONS
  4244. ;*          FILTER GENERATED FROM FILE
  4245. %filter_file%
  4246. ;*
  4247. ;*************************************************
  4248.     .text
  4249. %if option M%%if main%%else%    B    START
  4250.     .space    254*16        ;Programs start at 100 Hex.
  4251. ;************************************************
  4252. ;*         ASPI CARD INITIALIZATION CODE        *
  4253. ;************************************************
  4254. START:
  4255.     CNFD            ;SET BANK 0 TO DATA MEMORY
  4256.     LDPK    IOPAGE        ;SET PAGE POINTER
  4257.     SOVM            ;SATURATION ARITHMETIC
  4258.     SSXM            ;SET SIGN EXTEND MODE ON
  4259.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  4260.     CALL    INIT        ;INITIALIZE
  4261. ;************************************************
  4262. ;*                MAIN I/O LOOP                 *
  4263. ;************************************************
  4264. DOUT    .set    6        ;D/A OUTPUT
  4265. DIN    .set    6        ;A/D INPUT
  4266. ;*
  4267. ;* The following three instructions are used in conjunction
  4268. ;* with the PATCH program to indicate an idle state where no
  4269. ;* machine cycles are being used to preform filter operation
  4270. ;* (i.e. The time that location 4 is 1 could be used to do
  4271. ;* other useful things).  PATCH monitors location 4 to determine
  4272. ;* percetage utilization of the processor by the filter.
  4273. ;*
  4274. LPTS:    LACK    1
  4275.     SACL    FILTT
  4276.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  4277. ;*
  4278. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  4279.     B    LPTSA        ;BRANCH IF NO CLOCK
  4280. ;*
  4281. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  4282.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  4283. ;*
  4284. ;* The following three instructions are used in conjuction
  4285. ;* with the PATCH program to indicate a busy state or that the
  4286. ;* filter is in operation.
  4287. ;*
  4288.     LACK    0        ;GET CONSTANT FOR IDLE
  4289.     SACL    FILTT        ;SAVE FOR OUTPUT
  4290.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  4291. ;*
  4292. ;* The following three instructions are used to determine whether
  4293. ;* or not the filter should be active.  In the non-active state the
  4294. ;* input data is simply passed to the output.  In the active state
  4295. ;* the input data is filtered, then passed to the output.
  4296. ;*
  4297.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  4298.     LAC    FILTT
  4299.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  4300. ;*
  4301.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  4302.     B    LPTS        ;LOOP
  4303. %endif%%endif%;*************************************************
  4304. ;*           DATA MEMORY DEFINITION              *
  4305. ;*************************************************
  4306. ;*     CONTAINS:
  4307. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  4308. ;*          STORAGE FOR COEFFICIENTS
  4309. ;*          STORAGE FOR DELAY ELEMENTS
  4310. ;*************************************************
  4311. ;*
  4312. ;* FILTER INPUT and OUTPUT STORAGE
  4313. ;*
  4314. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  4315. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  4316. IOPAGE    .set    0
  4317. %else%    .globl    FILTT,V%IDT%
  4318. %endif%;*
  4319. COEF:
  4320. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  4321. ;*
  4322. %section%;*
  4323. ;*
  4324. ;*  SECOND-ORDER SECTION # %section_n%
  4325. ;*
  4326. %if B0<%%else%    .word    %B0%        ;B0
  4327. %endif%%if B1<>%    .word    %B1%        ;B1
  4328. %endif%%if A1<%%else%    .word    %A1%        ;A1
  4329. %endif%%if half%%else%    .word    %A2%        ;A2
  4330. %if B2<%%else%    .word    %B2%        ;B2
  4331. %endif%%endif%%loop%;*
  4332. ;*
  4333.     .sect    "X%IDT%"
  4334. ;*
  4335. ;* COEFFICIENT DATA STORAGE AREA
  4336. ;*
  4337. FDATA:    .space    (%points%+1)*16
  4338. ;*
  4339. ;* DELAY STORAGE DATA STORAGE AREA
  4340. ;*
  4341. DELAY:    .space    (%ndelay%+%ndelay%+2)*16
  4342. ;*
  4343. ;*
  4344.     .text
  4345. ;*************************************************
  4346. ;*       FILTER INITIALIZATION SUBROUTINE        *
  4347. ;*************************************************
  4348. %if option M%INIT%else%I%IDT%%endif%:
  4349.     LARP    0        ;POINT TO AR0
  4350.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  4351. %if data%    RPTK    %points%        ;COUNT FOR NUMBER OF POINTS
  4352.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  4353. %endif%    ZAC            ;CLEAR ACCUMULATOR
  4354.     LRLK    0,DELAY
  4355.     RPTK    %ndelay%+%ndelay%+1        ;NUMBER OF DELAY POINTS
  4356.     SACL    *+        ;CLEAR DATA VALUE
  4357.     RET            ;INIT RETURN
  4358. ;*************************************************
  4359. ;*              FILTER SUBROUTINE                *
  4360. ;*************************************************
  4361. ;*   ASSUMPTIONS:
  4362. ;*      SATURATION ARITHMETIC MODE IS ON
  4363. ;*      P REGISTER OUTPUT SHIFT = 1
  4364. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  4365. ;*      SIGN EXTEND MODE IS ON
  4366. ;*
  4367. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  4368. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  4369. ;*
  4370. ;*************************************************
  4371. COEFAR    .set    1        ;Use AR1 to point to COEF's
  4372. DELAR    .set    2        ;Use AR2 to point to DELAY's
  4373. ;*
  4374. %if option M%FILTER%else%F%IDT%%endif%:
  4375.     LARK    0,3        ;Set up AR0 for subtract
  4376.     LRLK    COEFAR,FDATA    ;Load COEF AR with beginning of COEF's
  4377.     LRLK    DELAR,DELAY    ;Load DELAY AR with beginning of DELAY's
  4378.     LARP    %if B10<%DELAR%else%COEFAR%endif%        ;Select Proper AR for initial use
  4379. %section%;*
  4380. ;* SECOND-ORDER FILTER SECTION # %section_n%
  4381. ;*
  4382. %filtin%%if half%    LT    FILTT        ;GET SCALED INPUT
  4383. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  4384. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  4385. %endif%    ZALH    *+        ;AC = Z-1
  4386.     ADDS    *-,COEFAR    ;ADD Least Significant
  4387. %if B1<>%    MPYA    *+,%if A1<%DELAR%else%COEFAR%endif%    ;AC = Z-1 + (B0 * INPUT)
  4388. ;*                ;P = B1 * INPUT
  4389. %else%    APAC            ;AC = Z-1 + (B0 * INPUT)
  4390. %endif%    SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  4391.     LT%if B1<>%P%endif%    %if option M%VSAMPL%else%V%IDT%%endif%%if B1<>%        ;AC = B1 * INPUT%endif%
  4392. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  4393. %else%    MPY    *+,DELAR    ;P = A1 * OUTPUT
  4394. %endif%    %if B1<>%A%endif%PAC            ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  4395. %if A1shft%    APAC
  4396. %endif%    SACH    *+        ;Save in Z-1
  4397.     SACL    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save Least Significant
  4398. %else 
  4399.  
  4400. %%if B1<>%    LT    FILTT        ;GET SCALED INPUT
  4401. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  4402. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  4403. %endif%    ZALH    *+        ;AC = Z-1
  4404.     ADDS    *+,COEFAR    ;ADD in least significant
  4405.     MPYA    *+,DELAR    ;AC = Z-1 + (B0 * INPUT)
  4406. ;*                ;P = B1 * INPUT
  4407.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  4408.     LTP    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = B1 * INPUT 
  4409.     ADDH    *+        ;AC = Z-2 + (B1 * INPUT)
  4410.     ADDS    *0-,COEFAR    ;ADD in least significant
  4411. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  4412. %else%    MPY    *+        ;P = A1 * OUTPUT
  4413. %endif%%if A1shft%    APAC
  4414. %endif%    MPYA    *+,DELAR    ;AC = Z-2 + (B1 * INPUT) + (A1 * OUTPUT)
  4415. ;*                ;P = A2 * OUTPUT
  4416.     SACH    *+        ;Save in Z-1
  4417.     SACL    *+,0,%if B2<%DELAR%else%COEFAR%endif%    ;Save least significant
  4418.     LTP    FILTT        ;AC = A2 * OUTPUT
  4419. %if B2<%    MPYK    %B2%        ;P = B2 * INPUT
  4420. %else%    MPY    *+,DELAR    ;P = B2 * INPUT
  4421. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  4422.      SACH    *+        ;Save in Z-2
  4423.     SACL    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save least significant
  4424. %else 
  4425.  
  4426.  
  4427. %    LT    FILTT        ;GET SCALED INPUT
  4428. %if B0<%    MPYK    %B0%        ;P = B0 * INPUT
  4429. %else%    MPY    *+,DELAR    ;P = B0 * INPUT
  4430. %endif%    ZALH    *+        ;AC = Z-1
  4431.     ADDS    *+,DELAR    ;ADD in least significant
  4432.     APAC            ;AC = Z-1 + (B0 * INPUT)
  4433.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;Save in OUTPUT
  4434.     LT    %if option M%VSAMPL%else%V%IDT%%endif%        ;Get OUTPUT
  4435.     ZALH    *+        ;AC = Z-2
  4436.     ADDS    *0-,COEFAR    ;ADD in least significant
  4437. %if A1<%    MPYK    %A1%        ;P = A1 * OUTPUT
  4438. %else%    MPY    *+        ;P = A1 * OUTPUT
  4439. %endif%%if A1shft%    APAC
  4440. %endif%    MPYA    *+,DELAR    ;AC = (B1 * INPUT) + (A1 * OUTPUT)
  4441. ;*                ;P = A2 * OUTPUT
  4442.     SACH    *+        ;Save in Z-1
  4443.     SACL    *+,0,%if B2<%DELAR%else%COEFAR%endif%    ;Save least significant
  4444.     LTP    FILTT        ;AC = A2 * OUTPUT
  4445. %if B2<%    MPYK    %B2%    ;P = B2 * INPUT
  4446. %else%    MPY    *+,DELAR    ;P = B2 * INPUT
  4447. %endif%    APAC            ;AC = (B2 * INPUT) + (A2 * OUTPUT)
  4448.      SACH    *+        ;Save in Z-2
  4449.     SACL    *+,0,%if BN0<%DELAR%else%COEFAR%endif%    ;Save least significant
  4450. %endif%%endif%%loop%*
  4451.     RET            ;RETURN
  4452.     .end
  4453. %end%
  4454. >>>>
  4455. >>>
  4456. 1
  4457. 7
  4458. %
  4459. TMS320c25; Indexed Memory; Looping Control
  4460. >>>
  4461. %batch_files 0  %    .title    "%IDT%"            ;UNIQUE NAME
  4462. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  4463.     .globl    I%IDT%        ;Name of filter initialization subroutine
  4464. %endif%;*************************************************
  4465. ;*   ASPI TMS320c25 DIGITAL FILTER REALIZATION   *
  4466. ;*************************************************
  4467. ;*               LOOPING CONTROL
  4468. ;*          %stages%-STAGE RECURSIVE FILTER
  4469. ;*            SECOND ORDER SECTIONS
  4470. ;*          FILTER GENERATED FROM FILE
  4471. %filter_file%
  4472. ;*
  4473. ;*************************************************
  4474.     .text
  4475. %if option M%%if main%%else%    B    START
  4476.     .space    254*16        ;Programs start at 100 Hex.
  4477. ;************************************************
  4478. ;*         ASPI CARD INITIALIZATION CODE        *
  4479. ;************************************************
  4480. START:
  4481.     CNFD            ;SET BANK 0 TO DATA MEMORY
  4482.     LDPK    IOPAGE        ;SET PAGE POINTER to I/O PAGE
  4483.     SOVM            ;SATURATION ARITHMETIC
  4484.     SSXM            ;SET SIGN EXTEND MODE ON
  4485.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  4486.     CALL    INIT        ;INITIALIZE
  4487. ;************************************************
  4488. ;*                MAIN I/O LOOP                 *
  4489. ;************************************************
  4490. DOUT    .set    6        ;D/A OUTPUT
  4491. DIN    .set    6        ;A/D INPUT
  4492. ;*
  4493. ;* The following three instructions are used in conjunction
  4494. ;* with the PATCH program to indicate an idle state where no
  4495. ;* machine cycles are being used to preform filter operation
  4496. ;* (i.e. The time that location 4 is 1 could be used to do
  4497. ;* other useful things).  PATCH monitors location 4 to determine
  4498. ;* percetage utilization of the processor by the filter.
  4499. ;*
  4500. LPTS:    LACK    1
  4501.     SACL    FILTT
  4502.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  4503. ;*
  4504. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  4505.     B    LPTSA        ;BRANCH IF NO CLOCK
  4506. ;*
  4507. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  4508.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  4509. ;*
  4510. ;* The following three instructions are used in conjuction
  4511. ;* with the PATCH program to indicate a busy state or that the
  4512. ;* filter is in operation.
  4513. ;*
  4514.     LACK    0        ;GET CONSTANT FOR IDLE
  4515.     SACL    FILTT        ;SAVE FOR OUTPUT
  4516.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  4517. ;*
  4518. ;* The following three instructions are used to determine whether
  4519. ;* or not the filter should be active.  In the non-active state the
  4520. ;* input data is simply passed to the output.  In the active state
  4521. ;* the input data is filtered, then passed to the output.
  4522. ;*
  4523.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  4524.     LAC    FILTT
  4525.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  4526. ;*
  4527.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  4528.     B    LPTS        ;LOOP
  4529. %endif%%endif%;*************************************************
  4530. ;*           DATA MEMORY DEFINITION              *
  4531. ;*************************************************
  4532. ;*     CONTAINS:
  4533. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  4534. ;*          INITIALIZATION FOR COEFFICIENTS
  4535. ;*          STORAGE FOR COEFFICIENTS
  4536. ;*          STORAGE FOR DELAY ELEMENTS
  4537. ;*************************************************
  4538. ;*
  4539. ;* FILTER INPUT and OUTPUT STORAGE
  4540. ;*
  4541. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  4542. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  4543. IOPAGE    .set    0
  4544. %else%    .globl    FILTT,V%IDT%
  4545. %endif%;*
  4546. COEF:
  4547. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  4548. ;*
  4549.     DATA    %stages%-1        ;*Number of stages -1 to follow
  4550. %section%;*
  4551. ;*
  4552. ;*  SECOND-ORDER SECTION # %section_n%
  4553. ;*
  4554. %tunable%
  4555.     DATA    %b_scale%        ;BLOCK FLOATING POINT SHIFT
  4556.     DATA    %B0%        ;B0
  4557.     DATA    %B1%        ;B1
  4558.     DATA    %A1%        ;A1
  4559.     DATA    %A2%        ;A2
  4560.     DATA    %B2%        ;B2
  4561. %loop%;*
  4562. ;*
  4563.     .sect    "X%IDT%"
  4564. ;*
  4565. ;*COEFICIENT DATA STORAGE AREA (including block floating point shifts
  4566. ;*                              and storage for the number of stages)
  4567. ;*
  4568. FDATA:    .space    (%points%+2)*16
  4569. ;*
  4570. ;* DELAY STORAGE STORAGE AREA
  4571. ;*
  4572. DELAY:    .space    (%ndelay%+1)*16
  4573. ;*
  4574. ;*
  4575.     .text
  4576. ;*************************************************
  4577. ;*       FILTER INITIALIZATION SUBROUTINE        *
  4578. ;*************************************************
  4579. %if option M%INIT%else%I%IDT%%endif%:
  4580.     LARP    0        ;POINT TO AR0
  4581.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  4582.     RPTK    %points%+1        ;COUNT FOR NUMBER OF POINTS
  4583.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  4584.     ZAC            ;CLEAR ACCUMULATOR
  4585.     LRLK    0,DELAY
  4586.     RPTK    %ndelay%        ;NUMBER OF DELAY POINTS
  4587.     SACL    *+        ;CLEAR DATA VALUE
  4588.     RET            ;INIT RETURN
  4589. ;*************************************************
  4590. ;*              FILTER SUBROUTINE                *
  4591. ;*************************************************
  4592. ;*   ASSUMPTIONS:
  4593. ;*      SATURATION ARITHMETIC MODE IS ON
  4594. ;*      P REGISTER OUTPUT SHIFT = 1
  4595. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  4596. ;*          PAGE.
  4597. ;*      SIGN EXTEND MODE IS ON
  4598. ;*
  4599. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  4600. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  4601. ;*
  4602. ;*************************************************
  4603. COEFAR    .set    1        ;Use AR1 to point to COEF's
  4604. DELAR    .set    2        ;Use AR2 to point to DELAY's
  4605. LOOPAR    .set    3        ;Use AR3 as loop counter
  4606. ;*
  4607. %if option M%FILTER%else%F%IDT%%endif%:
  4608.     LRLK    COEFAR,FDATA    ;Load COEF AR with beginning of COEF's
  4609.     LRLK    DELAR,DELAY    ;Load DELAY AR with beginning of DELAY's
  4610.     LARP    COEFAR        ;Point to COEF AR
  4611.     LAR    LOOPAR,*+    ;SET SECTION LOOP COUNT
  4612. ;*
  4613. ;* SECOND-ORDER FILTER SECTION LOOP
  4614. ;*
  4615.     LT    *+        ;GET SCALE FACTOR
  4616. FLOOP:
  4617.     LACT    %if option M%VSAMPL%else%V%IDT%%endif%        ;GET and SCALE INPUT
  4618.     SACH    FILTT,4        ;SAVE SCALED INPUT
  4619.     LT    FILTT        ;GET SCALED INPUT
  4620.     MPY    *+,DELAR    ;P = B0 * INPUT
  4621.     ZALH    *+,COEFAR    ;AC = Z-1
  4622.     MPYA    *+,DELAR    ;P = B1 * OUTPUT
  4623. ;*                ;AC = (B0 * INPUT) + Z-1
  4624.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;SAVE IN OUTPUT
  4625.     ZALH    *-,COEFAR    ;AC = Z-2
  4626.     LTA    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = (B1 * INPUT) + Z-2, GET CURRENT OUTPUT
  4627.     MPY    *+        ;P = A1/2 * OUTPUT
  4628.     APAC
  4629.     MPYA    *+,DELAR    ;P = A2 * OUTPUT
  4630. ;*                ;AC = (A1 * OUTPUT) + (B1 * INPUT) + Z-2
  4631.     SACH    *+,0,COEFAR    ;SAVE Z-1
  4632.     LTP    FILTT        ;AC = A2 * OUTPUT, GET SCALED INPUT
  4633.     MPY    *+        ;P = B2 * INPUT
  4634.     LTA    *+,DELAR    ;AC = (A2 * OUTPUT) + (B2 * INPUT)
  4635. ;*                ; & GET NEXT SCALE FACTOR
  4636.     SACH    *+,0,LOOPAR    ;SAVE Z-2
  4637. ;*
  4638.     BANZ    FLOOP,*-,COEFAR    ;REPEAT FOR ALL SECTIONS
  4639. ;*
  4640.     RET            ;RETURN
  4641.     .end
  4642. %end%
  4643. >>>>
  4644. >>>
  4645. 1
  4646. 7
  4647. %
  4648. TMS320c25; Indexed Memory; Looping Control; Increased Precision
  4649. >>>
  4650. %batch_files 0  %    .title    "%IDT%"            ;UNIQUE NAME
  4651. %if option M%%else%    .globl    F%IDT%        ;Name of filter subroutine
  4652.     .globl    I%IDT%        ;Name of filter initialization subroutine
  4653. %endif%;*************************************************
  4654. ;*   ASPI TMS320c25 DIGITAL FILTER REALIZATION   *
  4655. ;*************************************************
  4656. ;*             Increased Precision
  4657. ;*               LOOPING CONTROL
  4658. ;*          %stages%-STAGE RECURSIVE FILTER
  4659. ;*            SECOND ORDER SECTIONS
  4660. ;*          FILTER GENERATED FROM FILE
  4661. %filter_file%
  4662. ;*
  4663. ;*************************************************
  4664.     .text
  4665. %if option M%%if main%%else%    B    START
  4666.     .space    254*16        ;Programs start at 100 Hex.
  4667. ;************************************************
  4668. ;*         ASPI CARD INITIALIZATION CODE        *
  4669. ;************************************************
  4670. START:
  4671.     CNFD            ;SET BANK 0 TO DATA MEMORY
  4672.     LDPK    IOPAGE        ;SET PAGE POINTER to I/O PAGE
  4673.     SOVM            ;SATURATION ARITHMETIC
  4674.     SSXM            ;SET SIGN EXTEND MODE ON
  4675.     SPM    1        ;SET P REGISTER OUTPUT SHIFT TO 1
  4676.     CALL    INIT        ;INITIALIZE
  4677. ;************************************************
  4678. ;*                MAIN I/O LOOP                 *
  4679. ;************************************************
  4680. DOUT    .set    6        ;D/A OUTPUT
  4681. DIN    .set    6        ;A/D INPUT
  4682. ;*
  4683. ;* The following three instructions are used in conjunction
  4684. ;* with the PATCH program to indicate an idle state where no
  4685. ;* machine cycles are being used to preform filter operation
  4686. ;* (i.e. The time that location 4 is 1 could be used to do
  4687. ;* other useful things).  PATCH monitors location 4 to determine
  4688. ;* percetage utilization of the processor by the filter.
  4689. ;*
  4690. LPTS:    LACK    1
  4691.     SACL    FILTT
  4692.     OUT    FILTT,4        ;SIGNAL IDLE STATE
  4693. ;*
  4694. LPTSA:    BIOZ    GET        ;WAIT FOR CLOCK
  4695.     B    LPTSA        ;BRANCH IF NO CLOCK
  4696. ;*
  4697. GET:    OUT    VSAMPL,DOUT    ;OUTPUT LAST OUTPUT
  4698.     IN    VSAMPL,DIN    ;INPUT SAMPLE
  4699. ;*
  4700. ;* The following three instructions are used in conjuction
  4701. ;* with the PATCH program to indicate a busy state or that the
  4702. ;* filter is in operation.
  4703. ;*
  4704.     LACK    0        ;GET CONSTANT FOR IDLE
  4705.     SACL    FILTT        ;SAVE FOR OUTPUT
  4706.     OUT    FILTT,4        ;SIGNAL BUSY STATE
  4707. ;*
  4708. ;* The following three instructions are used to determine whether
  4709. ;* or not the filter should be active.  In the non-active state the
  4710. ;* input data is simply passed to the output.  In the active state
  4711. ;* the input data is filtered, then passed to the output.
  4712. ;*
  4713.     IN    FILTT,5        ;CHECK FOR ACTIVE STATE
  4714.     LAC    FILTT
  4715.     BNZ    LPTS        ;NOT ACTIVE, PASS DATA THROUGH
  4716. ;*
  4717.     CALL    FILTER        ;ACTIVE EXECUTE FILTER
  4718.     B    LPTS        ;LOOP
  4719. %endif%%endif%;*************************************************
  4720. ;*           DATA MEMORY DEFINITION              *
  4721. ;*************************************************
  4722. ;*     CONTAINS:
  4723. ;*          STORAGE FOR FILTER INPUT AND OUTPUT
  4724. ;*          INITIALIZATION FOR COEFFICIENTS
  4725. ;*          STORAGE FOR COEFFICIENTS
  4726. ;*          STORAGE FOR DELAY ELEMENTS
  4727. ;*************************************************
  4728. ;*
  4729. ;* FILTER INPUT and OUTPUT STORAGE
  4730. ;*
  4731. %if option M%FILTT    .set    96        ;TEMPORARY FILTER DATA
  4732. VSAMPL    .set    97        ;INPUT/OUTPUT FILTER DATA
  4733. IOPAGE    .set    0
  4734. %else%    .globl    FILTT,V%IDT%
  4735. %endif%;*
  4736. COEF:
  4737. ;* COEFFICIENT INITIALIZATION STORAGE AREA
  4738. ;*
  4739.     DATA    %stages%-1        ;*Number of stages -1 to follow
  4740. %section%;*
  4741. ;*
  4742. ;*  SECOND-ORDER SECTION # %section_n%
  4743. ;*
  4744. %tunable%
  4745.     DATA    %b_scale%        ;BLOCK FLOATING POINT SHIFT
  4746.     DATA    %B0%        ;B0
  4747.     DATA    %B1%        ;B1
  4748.     DATA    %A1%        ;A1
  4749.     DATA    %A2%        ;A2
  4750.     DATA    %B2%        ;B2
  4751. %loop%;*
  4752. ;*
  4753.     .sect    "X%IDT%"
  4754. ;*
  4755. ;*COEFICIENT DATA STORAGE AREA (including block floating point shifts
  4756. ;*                              and storage for the number of stages)
  4757. ;*
  4758. FDATA:    .space    (%points%+2)*16
  4759. ;*
  4760. ;* DELAY STORAGE STORAGE AREA
  4761. ;*
  4762. DELAY:    .space    (%ndelay%+%ndelay%+2)*16
  4763. ;*
  4764. ;*
  4765.     .text
  4766. ;*************************************************
  4767. ;*       FILTER INITIALIZATION SUBROUTINE        *
  4768. ;*************************************************
  4769. %if option M%INIT%else%I%IDT%%endif%:
  4770.     LARP    0        ;POINT TO AR0
  4771.     LRLK    0,FDATA        ;POINTER TO DATA MEMORY
  4772.     RPTK    %points%+1        ;COUNT FOR NUMBER OF POINTS
  4773.     BLKP    COEF,*+        ;BLOCK MOVE OF COEF.
  4774.     ZAC            ;CLEAR ACCUMULATOR
  4775.     LRLK    0,DELAY
  4776.     RPTK    %ndelay%+%ndelay%+1        ;NUMBER OF DELAY POINTS
  4777.     SACL    *+        ;CLEAR DATA VALUE
  4778.     RET            ;INIT RETURN
  4779. ;*************************************************
  4780. ;*              FILTER SUBROUTINE                *
  4781. ;*************************************************
  4782. ;*   ASSUMPTIONS:
  4783. ;*      SATURATION ARITHMETIC MODE IS ON
  4784. ;*      P REGISTER OUTPUT SHIFT = 1
  4785. ;*      PAGE REGISTER IS SET TO 'IOPAGE'
  4786. ;*          PAGE.
  4787. ;*      SIGN EXTEND MODE IS ON
  4788. ;*
  4789. ;*   INPUT:    %if option M%VSAMPL%else%V%IDT%%endif%
  4790. ;*   OUTPUT:   %if option M%VSAMPL%else%V%IDT%%endif%
  4791. ;*
  4792. ;*************************************************
  4793. COEFAR    .set    1        ;Use AR1 to point to COEF's
  4794. DELAR    .set    2        ;Use AR2 to point to DELAY's
  4795. LOOPAR    .set    3        ;Use AR3 as loop counter
  4796. ;*
  4797. %if option M%FILTER%else%F%IDT%%endif%:
  4798.     LARK    0,3        ;Set up AR0 for subtract
  4799.     LRLK    COEFAR,FDATA    ;Load COEF AR with beginning of COEF's
  4800.     LRLK    DELAR,DELAY    ;Load DELAY AR with beginning of DELAY's
  4801.     LARP    COEFAR        ;Point to COEF AR
  4802.     LAR    LOOPAR,*+    ;SET SECTION LOOP COUNT
  4803. ;*
  4804. ;* SECOND-ORDER FILTER SECTION LOOP
  4805. ;*
  4806.     LT    *+        ;GET SCALE FACTOR
  4807. FLOOP:
  4808.     LACT    %if option M%VSAMPL%else%V%IDT%%endif%        ;GET and SCALE INPUT
  4809.     SACH    FILTT,4        ;SAVE SCALED INPUT
  4810.     LT    FILTT        ;GET SCALED INPUT
  4811.     MPY    *+,DELAR    ;P = B0 * INPUT
  4812.     ZALH    *+        ;AC = Z-1
  4813.     ADDS    *+,COEFAR    ;ADD in least significant
  4814.     MPYA    *+,DELAR    ;P = B1 * OUTPUT
  4815. ;*                ;AC = (B0 * INPUT) + Z-1
  4816.     SACH    %if option M%VSAMPL%else%V%IDT%%endif%        ;SAVE IN OUTPUT
  4817.     ZALH    *+        ;AC = Z-2
  4818.     ADDS    *0-,COEFAR    ;ADD in least significant
  4819.     LTA    %if option M%VSAMPL%else%V%IDT%%endif%        ;AC = (B1 * INPUT) + Z-2, GET CURRENT OUTPUT
  4820.     MPY    *+        ;P = A1/2 * OUTPUT
  4821.     APAC
  4822.     MPYA    *+,DELAR    ;P = A2 * OUTPUT
  4823. ;*                ;AC = (A1 * OUTPUT) + (B1 * INPUT) + Z-2
  4824.     SACH    *+        ;SAVE Z-1
  4825.     SACL    *+,0,COEFAR    ;Save least significant
  4826.     LTP    FILTT        ;AC = A2 * OUTPUT, GET SCALED INPUT
  4827.     MPY    *+        ;P = B2 * INPUT
  4828.     LTA    *+,DELAR    ;AC = (A2 * OUTPUT) + (B2 * INPUT)
  4829. ;*                ; & GET NEXT SCALE FACTOR
  4830.     SACH    *+        ;SAVE Z-2
  4831.     SACL    *+,0,LOOPAR    ;Save least significant
  4832. ;*
  4833.     BANZ    FLOOP,*-,COEFAR    ;REPEAT FOR ALL SECTIONS
  4834. ;*
  4835.     RET            ;RETURN
  4836.     .end
  4837. %end%
  4838. >>>>
  4839. >>>
  4840. 3
  4841. 8
  4842. ~
  4843. TMS320C30; 'C' interface; Time Optimize w/ Optimized Filter Routine
  4844. >>>
  4845. ~set_C~~set_A~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4846. ;                                                           ;
  4847. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  4848. ;                                                           ;
  4849. ;               TMS320C30 FIR filter realization            ;
  4850. ;                                                           ;
  4851. ;                   Parks-McClellan Design                  ;
  4852. ;                                                           ;
  4853. ;                    Super Time Optimized                   ;
  4854. ;                                                           ;
  4855. ;                   'C' compiler interface                  ;
  4856. ;                                                           ;
  4857. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4858. ;
  4859. ~filter_file~
  4860.  
  4861.     .copy "model.inc"    ;This include file specifies different
  4862.                 ;memory models and ways of assembling
  4863.                 ;the code.
  4864.  
  4865. ;The following structure defines the 'C' structure that the Init routine
  4866. ;initializes.  This structure is passed, along with x(n) to the filter
  4867. ;routines.
  4868. ;
  4869. ;struct FIR {
  4870. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  4871. ;    void    (*filtera)();    /* pointer to array filter routine */
  4872. ;    float    *coef_mem;    /* pointer to coef. memory */
  4873. ;    float    *delay_mem;    /* pointer to delay memory */
  4874. ;    float    zero;        /* a floating point 0 */
  4875. ;    };
  4876.  
  4877. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4878. ;                                                           ;
  4879. ;                 FIR Filter Init Routines                  ;
  4880. ;                                                           ;
  4881. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4882.  
  4883.     .text
  4884.  
  4885. FP    .set    AR3
  4886. taps    .set    ~taps~
  4887.  
  4888. ;        INITIALIZE THE FILTER memory and the FIR structure
  4889. ;
  4890. ;struct FIR initf()
  4891. ;
  4892. ;Calling sequence from 'C':
  4893. ;
  4894. ;    FIR = ~if option M~init_filter~else~I_~IDT~~endif~();
  4895. ;
  4896. ;      where FIR is a structure as defined above.
  4897. ;
  4898. ~if option M~    .globl    _I_FILTER
  4899. _I_FILTER:
  4900. ~else~    .globl    _I_~IDT~
  4901. _I_~IDT~:
  4902. ~endif~    .if    large_model
  4903.     LDP    fmema
  4904.     .endif
  4905.     LDI    @fmema,AR2    ;Get address of address of init memory
  4906.     LDI    *AR2++,AR1    ;Get address of delay memory
  4907.  
  4908.     STI    AR1,*+AR0(3)    ;Put in FIR structure
  4909.     LDF    0.0,R0
  4910.     STF    R0,*+AR0(4)    ;Set zero in FIR structure
  4911.     LDI    taps,BK        ;Set block size for circular buffer
  4912.                 ; of x(n)
  4913.     RPTS    taps
  4914.     STF    R0,*AR1++%    ;Zero the delay memory
  4915.     LDI    *AR2++,R0    ;Get address of coef.
  4916.     STI    R0,*+AR0(2)    ;Put address of coef. in FIR structure
  4917.     LDI    *AR2++,R0    ;Get address of sample by sample filter routine
  4918.     STI    R0,*+AR0(0)    ;Put in FIR filter structure
  4919.     LDI    *AR2++,R0    ;Get address of array filter routine
  4920.     STI    R0,*+AR0(1)    ;Put in FIR filter structure
  4921.     RETS
  4922.     
  4923. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4924. ;                                                           ;
  4925. ;                   FIR Filter Subroutine                   ;
  4926. ;                                                           ;
  4927. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4928.     .globl    _F_~IDT~
  4929.     .globl    _F_~IDT~a
  4930.  
  4931. ;        PERFORM ARRAY FILTERING
  4932. ;void (*param->filtera)(xy,xn,n,param)
  4933. ;float *xn, *yn
  4934. ;int n;
  4935. ;struct FIR *param;
  4936. ;
  4937. ; filter returns y(n) for input x(n)
  4938. ; xn and yn are pointers to arrays of size n+1 floats
  4939. ; n is the number of samples - 1
  4940. ;
  4941. ; the filter routine must be called with x(0) thru x(n)
  4942. ; first then x(n+1) thru x(....) and so on.
  4943.  
  4944. _F_~IDT~a:
  4945.     .if array_filter
  4946.     PUSH    FP
  4947.     LDI    SP,FP
  4948.     PUSH    AR6
  4949.     PUSH    AR7
  4950.  
  4951.     LDI    *-FP(5),AR2    ; AR2 = address of FIR filter structure
  4952.     LDI    *++AR2(2),AR1    ; AR1 = address of coefficients
  4953.     LDI    *++AR2,AR0    ; AR0 = address of x(n) in circular
  4954.                 ; delay memory
  4955.                 ; Note: AR2 now points to delay memory address
  4956.     LDI    taps,BK        ; Set block size for circular buffer
  4957.                 ; of x(n)
  4958.     LDI    *-FP(2),AR7    ; AR7 = address of y(n)
  4959.     LDI    *-FP(3),AR6    ; AR6 = address of x(n)
  4960.     LDI    taps-1,IR0    ; size of coef memory - 1
  4961.     LDF    *AR6++,R0    ; get x(n)
  4962.     LDI    *-FP(4),RC    ; get number of samples - 1
  4963.  
  4964.     LDF    *+AR2,R2    ; initialize R2 to 0.0
  4965. ||    STF    R0,*AR0        ; put x(n) in delay memory
  4966.     MPYF    *AR1++,*AR0++%,R0 ;
  4967.  
  4968.     RPTB    loop
  4969. ~do~    MPYF    *AR1~coef_inc~,*AR0++%,R0
  4970. ||    ~s~F    R0,R2,R2
  4971. ~loopm2~~if symetric~    MPYF    *AR1,*AR0%,R0
  4972. ||    ~s~F    R0,R2,R3
  4973. ~else~    MPYF    *AR1--(IR0),*AR0%,R0
  4974. ||    ~s~F    R0,R2,R3
  4975. ~endif~
  4976.     LDF    *AR6,R1        ; get next sample
  4977. ||    LDF    *+AR2,R2    ; initialize R2 to 0.0
  4978.     MPYF3    *AR6++,*AR1++,R0; x(n+1) * h(0) -> R0
  4979. ||    ~s~F3    R0,R3,R3    ; final sum for y(n) -> R3
  4980. loop:    STF    R3,*AR7++    ; store y(n) into array
  4981. ||    STF    R1,*AR0++%    ; store x(n+1) into delay memory
  4982.  
  4983.     NOP    *AR0--%        ; back up delay pointer for next x(n)
  4984.     STI    AR0,*AR2    ; save updated circular buffer point
  4985.                 ; for next sample
  4986.     POP    AR7
  4987.     POP    AR6
  4988.     POP    FP
  4989.     RETS            ; return y(n) in R0
  4990.     .else
  4991.     CALL    40h        ; signal error with break point
  4992.     .endif
  4993.     
  4994. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  4995. ;float (*param->filter)(xn,param)
  4996. ;float xn
  4997. ;struct FIR *param;
  4998. ;
  4999. ; filter returns y(n) for input x(n)
  5000. ;
  5001. ; the filter routine must be called with x(0) first then x(1)
  5002. ; and so on.
  5003.  
  5004. _F_~IDT~:
  5005.     .if    s_by_s_filter
  5006.     PUSH    FP
  5007.     LDI    SP,FP
  5008.  
  5009.     LDI    *-FP(3),AR2    ; AR2 = address of FIR filter structure
  5010.     LDI    *++AR2(2),AR1    ; AR1 = address of coefficients
  5011.     LDI    *++AR2,AR0    ; AR0 = address of x(n) in circular
  5012.                 ; delay memory
  5013.     LDI    taps,BK        ; Set block size for circular buffer
  5014.                 ; of x(n)
  5015.     LDF    0.0,R2        ; initialize R2 = 0.0
  5016.     LDF    *-FP(2),R0    ; R0 = x(n)
  5017.     STF    R0,*AR0        ; put x(n) in delay memory
  5018.     MPYF    *AR1++,*AR0++%,R0 ;
  5019. ~do~    MPYF    *AR1~coef_inc~,*AR0++%,R0
  5020. ||    ~s~F    R0,R2,R2
  5021. ~loopm2~    MPYF    *AR1,*AR0%,R0
  5022. ||    ~s~F    R0,R2,R2
  5023.     ~s~F    R0,R2,R0    ; add last product
  5024.     
  5025.     STI    AR0,*AR2    ; save updated circular buffer point
  5026.                 ; for next sample
  5027.     POP    FP
  5028.     RETS            ; return y(n) in R0
  5029.     .else
  5030.     CALL    40h        ; signal error with break point
  5031.     .endif
  5032.  
  5033. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5034. ;                                                           ;
  5035. ;              Build .bss and .cinit sections               ;
  5036. ;                                                           ;
  5037. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5038.  
  5039. ; The .cinit section exists to provide initialization data
  5040. ; for the .bss section.  The .bss section is where 'C'
  5041. ; keeps all of its static and global storage.
  5042.  
  5043.     .sect    ".cinit"
  5044.     .word    1,fmema        ;init one word at location fmema
  5045.     .word    fmem        ;address of fmem to be put into fmema
  5046.     .bss    fmema,1        ;reserve fmema in .bss
  5047.     .word    4,fmem
  5048.     .word    delay_m        ;address of delay memory
  5049.     .word    coef_m        ;address of coef_mem
  5050.     .word    _F_~IDT~    ;address of sample by sample filter
  5051.     .word    _F_~IDT~a    ;address of array filter routine
  5052.     .bss    fmem,4
  5053.     .if coef_ram
  5054.     .word    ~if symetric~(taps+1)/2~else~taps~endif~,coef_m
  5055.     .else
  5056.     .sect    "C_~IDT~"
  5057. coef_m:
  5058.     .endif
  5059. ~if symetric~~do~    .float   ~coeff~     ; ~coef_name~ = ~esign~~coef_nameI~
  5060. ~looph~
  5061. ~else~~do~    .float   ~coeff~     ; ~coef_name~
  5062. ~loop~~endif~
  5063.  
  5064. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5065. ;                                                           ;
  5066. ;              Reserve Space for Coefficients               ;
  5067. ;                                                           ;
  5068. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5069.     .if coef_ram
  5070. coef_m    .usect    "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
  5071.     .endif
  5072. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5073. ;                                                           ;
  5074. ;              Reserve Space for Delay Memory               ;
  5075. ;                                                           ;
  5076. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5077.  
  5078. ;The following section must be unique in name and be aligned on
  5079. ;a ~align~ word address boundary.  This can be accomplished with a
  5080. ;LNK30 command file.  CGEN produces an example LNK30 command file
  5081. ;named "LINK.CMD".
  5082.  
  5083. delay_m    .usect    "D_~IDT~",taps
  5084.  
  5085.     .end
  5086. ~end~
  5087. >>>>
  5088. >>>
  5089. 3
  5090. 8
  5091. ~
  5092. TMS320C30; 'C' interface; Time Optimize
  5093. >>>
  5094. ~set_C~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5095. ;                                                           ;
  5096. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  5097. ;                                                           ;
  5098. ;               TMS320C30 FIR filter realization            ;
  5099. ;                                                           ;
  5100. ;                   Parks-McClellan Design                  ;
  5101. ;                                                           ;
  5102. ;                       Time Optimized                      ;
  5103. ;                                                           ;
  5104. ;                   'C' compiler interface                  ;
  5105. ;                                                           ;
  5106. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5107. ;
  5108. ~filter_file~
  5109.  
  5110.     .copy "model.inc"    ;This include file specifies different
  5111.                 ;memory models and ways of assembling
  5112.                 ;the code.
  5113.  
  5114. ;The following structure defines the 'C' structure that the Init routine
  5115. ;initializes.  This structure is passed, along with x(n) to the filter
  5116. ;routines.
  5117. ;
  5118. ;struct FIR {
  5119. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  5120. ;    void    (*filtera)();    /* pointer to array filter routine */
  5121. ;    float    *coef_mem;    /* pointer to coef. memory */
  5122. ;    float    *delay_mem;    /* pointer to delay memory */
  5123. ;    float    zero;        /* a floating point 0 */
  5124. ;    int    BK_reg;        /* value to be placed in BK register */
  5125. ;    int    frtaps;        /* number of taps for RPTS forward */
  5126. ;    };
  5127.  
  5128. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5129. ;                                                           ;
  5130. ;                 FIR Filter Init Routines                  ;
  5131. ;                                                           ;
  5132. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5133.  
  5134.     .text
  5135.  
  5136. FP    .set    AR3
  5137. taps    .set    ~taps~
  5138.  
  5139. ;        INITIALIZE THE FILTER memory and the FIR structure
  5140. ;
  5141. ;struct FIR initf()
  5142. ;
  5143. ;Calling sequence from 'C':
  5144. ;
  5145. ;    FIR = ~if option M~init_filter~else~I_~IDT~~endif~();
  5146. ;
  5147. ;      where FIR is a structure as defined above.
  5148. ;
  5149. ~if option M~    .globl    _I_FILTER
  5150. _I_FILTER:
  5151. ~else~    .globl    _I_~IDT~
  5152. _I_~IDT~:
  5153. ~endif~    .if    large_model
  5154.     LDP    fmema
  5155.     .endif
  5156.     LDI    @fmema,AR2    ;Get address of address of init memory
  5157.     LDI    *AR2++,AR1    ;Get address of delay memory
  5158.  
  5159.     STI    AR1,*+AR0(3)    ;Put in FIR structure
  5160.     LDF    0.0,R0
  5161.     STF    R0,*+AR0(4)    ;Set zero in FIR structure
  5162.     LDI    taps+1,BK    ;Set block size for circular buffer
  5163.                 ; of x(n)
  5164.     RPTS    taps
  5165.     STF    R0,*AR1++%    ;Zero the delay memory
  5166.     LDI    taps-3,R0    ;Get number for RPTS instruction
  5167.     STI    R0,*+AR0(6)    ;Store in FIR filter structure
  5168.     LDI    *AR2++,R0    ;Get address of coef.
  5169.     STI    R0,*+AR0(2)    ;Put address of coef. in FIR structure
  5170.     LDI    *AR2++,R0    ;Get address of sample by sample filter routine
  5171.     STI    R0,*+AR0(0)    ;Put in FIR filter structure
  5172.     LDI    *AR2++,R0    ;Get address of array filter routine
  5173.     STI    R0,*+AR0(1)    ;Put in FIR filter structure
  5174.     STI    BK,*+AR0(5)    ;Put BK in FIR structure
  5175.     LDI    taps-1,R0    ;Get number for RPTS instruction
  5176.     STI    R0,*+AR0(7)    ;Store in FIR filter structure
  5177.     RETS
  5178.     
  5179. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5180. ;                                                           ;
  5181. ;              Build .bss and .cinit sections               ;
  5182. ;                                                           ;
  5183. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5184.  
  5185. ; The .cinit section exists to provide initialization data
  5186. ; for the .bss section.  The .bss section is where 'C'
  5187. ; keeps all of its static and global storage.
  5188.  
  5189.     .sect    ".cinit"
  5190.     .word    1,fmema            ;init one word at location fmema
  5191.     .word    fmem            ;address of fmem to be put into fmema
  5192.     .bss    fmema,1            ;reserve fmema in .bss
  5193.     .globl    _FIR_C
  5194.     .globl    _FIR_Ca
  5195.     .word    4,fmem
  5196.     .word    delay_m            ;address of delay memory
  5197.     .word    coef_m            ;address of coef_mem
  5198.     .word    _FIR_C            ;address of sample by sample filter
  5199.     .word    _FIR_Ca            ;address of array filter routine
  5200.     .bss    fmem,4
  5201.     .if coef_ram
  5202.     .word    taps,coef_m
  5203.     .else
  5204.     .sect    "C_~IDT~"
  5205. coef_m:
  5206.     .endif
  5207. ~do~    .float   ~coeff~     ; ~coef_name~
  5208. ~loop~
  5209. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5210. ;                                                           ;
  5211. ;                Reserve Coefficients Space                 ;
  5212. ;                                                           ;
  5213. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5214.     .if coef_ram
  5215. coef_m    .usect    "C_~IDT~",taps
  5216.     .endif
  5217. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5218. ;                                                           ;
  5219. ;              Reserve Space for Delay Memory               ;
  5220. ;                                                           ;
  5221. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5222.  
  5223. ;The following section must be unique in name and be aligned on
  5224. ;a ~align~ word address boundary.  This can be accomplished with a
  5225. ;LNK30 command file.  CGEN produces an example LNK30 command file
  5226. ;named "LINK.CMD".
  5227.  
  5228. delay_m    .usect    "D_~IDT~",taps+1
  5229.  
  5230.     .end
  5231. ~end~
  5232. >>>>
  5233. >>>
  5234. 3
  5235. 8
  5236. ~
  5237. TMS320C30; 'C' interface; Size Optimize
  5238. >>>
  5239. ~set_C~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5240. ;                                                           ;
  5241. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  5242. ;                                                           ;
  5243. ;               TMS320C30 FIR filter realization            ;
  5244. ;                                                           ;
  5245. ;                   Parks-McClellan Design                  ;
  5246. ;                                                           ;
  5247. ;                       Size Optimized                      ;
  5248. ;                                                           ;
  5249. ;                   'C' compiler interface                  ;
  5250. ;                                                           ;
  5251. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5252. ;
  5253. ~filter_file~
  5254.  
  5255.     .copy "model.inc"    ;This include file specifies different
  5256.                 ;memory models and ways of assembling
  5257.                 ;the code.
  5258.  
  5259. ;The following structure defines the 'C' structure that the Init routine
  5260. ;initializes.  This structure is passed, along with x(n) to the filter
  5261. ;routines.
  5262. ;
  5263. ;struct FIR {
  5264. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  5265. ;    void    (*filtera)();    /* pointer to array filter routine */
  5266. ;    float    *coef_mem;    /* pointer to coef. memory */
  5267. ;    float    *delay_mem;    /* pointer to delay memory */
  5268. ;    float    zero;        /* a floating point 0 */
  5269. ;    int    BK_reg;        /* value to be placed in BK register */
  5270. ;    int    frtaps;        /* number of taps for RPTS forward */
  5271. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  5272. ;    };
  5273.  
  5274. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5275. ;                                                           ;
  5276. ;                 FIR Filter Init Routines                  ;
  5277. ;                                                           ;
  5278. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5279.  
  5280.     .text
  5281.  
  5282. FP    .set    AR3
  5283. taps    .set    ~taps~
  5284.  
  5285. ;        INITIALIZE THE FILTER memory and the FIR structure
  5286. ;
  5287. ;struct FIR initf()
  5288. ;
  5289. ;Calling sequence from 'C':
  5290. ;
  5291. ;    FIR = ~if option M~I_FILTER~else~I_~IDT~~endif~();
  5292. ;
  5293. ;      where FIR is a structure as defined above.
  5294. ;
  5295. ~if option M~    .globl    _I_FILTER
  5296. _I_FILTER:
  5297. ~else~    .globl    _I_~IDT~
  5298. _I_~IDT~:
  5299. ~endif~    .if    large_model
  5300.     LDP    fmema
  5301.     .endif
  5302.     LDI    @fmema,AR2    ;Get address of address of init memory
  5303.     LDI    *AR2++,AR1    ;Get address of delay memory
  5304.  
  5305.     STI    AR1,*+AR0(3)    ;Put in FIR structure
  5306.     LDF    0.0,R0
  5307.     STF    R0,*+AR0(4)    ;Set zero in FIR structure
  5308.     LDI    taps+1,BK    ;Set block size for circular buffer
  5309.                 ; of x(n)
  5310.     RPTS    taps
  5311.     STF    R0,*AR1++%    ;Zero the delay memory
  5312.     LDI    taps~if symetric~/2-2~else~-3~endif~,R0    ;Get number for RPTS instruction
  5313.     STI    R0,*+AR0(6)    ;Store in FIR filter structure
  5314. ~if symetric~
  5315.     LDI    (taps-1)/2~if asym_odd~-1~endif~~if asym_even~-1~endif~,R0    ;Get number for RPTS instruction
  5316. ~else~
  5317.     LDI    taps-1,R0    ;Get number for RPTS instruction
  5318. ~endif~
  5319.     STI    R0,*+AR0(7)    ;Store in FIR filter structure
  5320.     LDI    *AR2++,R0    ;Get address of coef.
  5321.     STI    R0,*+AR0(2)    ;Put address of coef. in FIR structure
  5322.     LDI    *AR2++,R0    ;Get address of sample by sample filter routine
  5323.     STI    R0,*+AR0(0)    ;Put in FIR filter structure
  5324.     LDI    *AR2++,R0    ;Get address of array filter routine
  5325.     STI    R0,*+AR0(1)    ;Put in FIR filter structure
  5326.     STI    BK,*+AR0(5)    ;Put BK in FIR structure
  5327.     RETS
  5328.     
  5329. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5330. ;                                                           ;
  5331. ;              Build .bss and .cinit sections               ;
  5332. ;                                                           ;
  5333. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5334.  
  5335. ; The .cinit section exists to provide initialization data
  5336. ; for the .bss section.  The .bss section is where 'C'
  5337. ; keeps all of its static and global storage.
  5338.  
  5339.     .sect    ".cinit"
  5340.     .word    1,fmema            ;init one word at location fmema
  5341.     .word    fmem            ;address of fmem to be put into fmema
  5342.     .bss    fmema,1            ;reserve fmema in .bss
  5343. ~if sym_even~    .globl    _FIR_Cse
  5344.     .globl    _FIR_Csea
  5345. ~endif~~if sym_odd~    .globl    _FIR_Cso
  5346.     .globl    _FIR_Csoa
  5347. ~endif~~if asym_even~    .globl    _FIR_Case
  5348.     .globl    _FIR_Casea
  5349. ~endif~~if asym_odd~    .globl    _FIR_Caso
  5350.     .globl    _FIR_Casoa
  5351. ~endif~~if symetric~~else~    .globl    _FIR_C
  5352.     .globl    _FIR_Ca
  5353. ~endif~    .word    4,fmem
  5354.     .word    delay_m            ;address of delay memory
  5355.     .word    coef_m            ;address of coef_mem
  5356. ~if sym_even~    .word    _FIR_Cse        ;address of sample by sample filter
  5357.     .word    _FIR_Csea        ;address of array filter routine
  5358. ~endif~~if sym_odd~    .word    _FIR_Cso        ;address of sample by sample filter
  5359.     .word    _FIR_Csoa        ;address of array filter routine
  5360. ~endif~~if asym_even~    .word    _FIR_Case        ;address of sample by sample filter
  5361.     .word    _FIR_Casea        ;address of array filter routine
  5362. ~endif~~if asym_odd~    .word    _FIR_Caso        ;address of sample by sample filter
  5363.     .word    _FIR_Casoa        ;address of array filter routine
  5364. ~endif~~if symetric~~else~    .word    _FIR_C        ;address of sample by sample filter
  5365.     .word    _FIR_Ca            ;address of array filter routine
  5366. ~endif~    .bss    fmem,4
  5367.     .if coef_ram
  5368.     .word    ~if symetric~(taps+1)/2~else~taps~endif~,coef_m
  5369.     .else
  5370.     .sect    "C_~IDT~"
  5371. coef_m:
  5372.     .endif
  5373. ~if symetric~~do~    .float   ~coeff~     ; ~coef_name~ = ~esign~~coef_nameI~
  5374. ~looph~
  5375. ~else~~do~    .float   ~coeff~     ; ~coef_name~
  5376. ~loop~~endif~
  5377. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5378. ;                                                           ;
  5379. ;                Reserve Coefficients Space                 ;
  5380. ;                                                           ;
  5381. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5382.     .if coef_ram
  5383. coef_m    .usect    "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
  5384.     .endif
  5385. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5386. ;                                                           ;
  5387. ;              Reserve Space for Delay Memory               ;
  5388. ;                                                           ;
  5389. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5390.  
  5391. ;The following section must be unique in name and be aligned on
  5392. ;a ~align~ word address boundary.  This can be accomplished with a
  5393. ;LNK30 command file.  CGEN produces an example LNK30 command file
  5394. ;named "LINK.CMD".
  5395.  
  5396. delay_m    .usect    "D_~IDT~",taps+1
  5397.  
  5398.     .end
  5399. ~status~~end~
  5400. >>>>
  5401. >>>
  5402. 3
  5403. 8
  5404. ~
  5405. TMS320C30; ASM30 interface; Time Optimize w/ Optimized Filter Routine
  5406. >>>
  5407. ~set_A~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5408. ;                                                           ;
  5409. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  5410. ;                                                           ;
  5411. ;               TMS320C30 FIR filter realization            ;
  5412. ;                                                           ;
  5413. ;                   Parks-McClellan Design                  ;
  5414. ;                                                           ;
  5415. ;                    Super Time Optimized                   ;
  5416. ;                                                           ;
  5417. ;                  ASM30 compiler interface                 ;
  5418. ;                                                           ;
  5419. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5420. ;
  5421. ~filter_file~
  5422.  
  5423.     .copy "model.inc"    ;This include file specifies different
  5424.                 ;memory models and ways of assembling
  5425.                 ;the code.
  5426.  
  5427. ;The following structure defines the data structure that the Init routine
  5428. ;initializes.  This structure is passed, along with x(n) to the filter
  5429. ;routines.
  5430. ;
  5431. ;struct FIR {
  5432. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  5433. ;    void    (*filtera)();    /* pointer to array filter routine */
  5434. ;    float    *coef_mem;    /* pointer to coef. memory */
  5435. ;    float    *delay_mem;    /* pointer to delay memory */
  5436. ;    float    zero;        /* a floating point 0 */
  5437. ;    };
  5438.  
  5439. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5440. ;                                                           ;
  5441. ;                 FIR Filter Init Routines                  ;
  5442. ;                                                           ;
  5443. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5444.  
  5445.     .text
  5446.  
  5447. FP    .set    AR3
  5448. taps    .set    ~taps~
  5449.  
  5450. ;        INITIALIZE THE FILTER memory and the FIR structure
  5451. ;
  5452. ;Calling sequence:
  5453. ;    CALL    ~if option M~init_filter~else~I_~IDT~~endif~
  5454. ;
  5455. ;Input:
  5456. ;    AR7    pointer to FIR filter structure
  5457. ;Output:
  5458. ;    AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
  5459. ;
  5460. ;
  5461. ~if option M~    .globl    I_FILTER
  5462. I_FILTER:
  5463. ~else~    .globl    I_~IDT~
  5464. I_~IDT~:
  5465. ~endif~    LDP    fmema
  5466.     LDI    @fmema,AR0    ;Get address of init memory
  5467.     LDI    *AR0++,AR1    ;Get address of delay memory
  5468.  
  5469.     STI    AR1,*+AR7(3)    ;Put in FIR structure
  5470.     LDF    0.0,R0
  5471.     STF    R0,*+AR7(4)    ;Set zero in FIR structure
  5472.     LDI    taps,BK        ;Set block size for circular buffer
  5473.                 ; of x(n)
  5474.     RPTS    taps
  5475.     STF    R0,*AR1++%    ;Zero the delay memory
  5476.     LDI    *AR0++,R0    ;Get address of coef.
  5477.     STI    R0,*+AR7(2)    ;Put address of coef. in FIR structure
  5478.     LDI    *AR0++,R0    ;Get address of sample by sample filter routine
  5479.     STI    R0,*+AR7(0)    ;Put in FIR filter structure
  5480.     LDI    *AR0++,R0    ;Get address of array filter routine
  5481.     STI    R0,*+AR7(1)    ;Put in FIR filter structure
  5482.  
  5483.     .if coef_ram
  5484.     LDI    *+AR7(2),AR1    ;get address of RAM coef
  5485.     LDI    *AR0++,R0    ;Get first ROM coef
  5486.     RPTS    ~if symetric~(taps+1)/2~else~taps~endif~-1
  5487.     LDI    *AR0++,R0
  5488. ||    STI    R0,*AR1++    ;copy ROM coef to RAM coef
  5489.     .endif
  5490.  
  5491.     RETS
  5492.     
  5493. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5494. ;                                                           ;
  5495. ;                   FIR Filter Subroutine                   ;
  5496. ;                                                           ;
  5497. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5498.     .globl    _F_~IDT~
  5499.     .globl    _F_~IDT~a
  5500.  
  5501. ;        PERFORM ARRAY FILTERING
  5502. ;Input:
  5503. ;    AR4    address of x(n) array
  5504. ;    AR5    address of y(n) array
  5505. ;    AR6    number of samples-1 in array
  5506. ;    AR7    address of FIR filter structure
  5507. ;Output:
  5508. ;    AR(0-2), AR(4-6), R(0-3), IR0, BK, RC, RS, RE, DP destroyed
  5509.  
  5510. ; filter returns y(n) for input x(n)
  5511. ; AR2 and AR4 are pointers to arrays of size n+1 floats
  5512. ; n is the number of samples - 1
  5513. ;
  5514. ; the filter routine must be called with x(0) thru x(n)
  5515. ; first then x(n+1) thru x(....) and so on.
  5516.  
  5517. _F_~IDT~a:
  5518.     .if array_filter
  5519.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  5520.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  5521.                 ; delay memory
  5522.                 ; Note: AR2 now points to delay memory address
  5523.     LDI    taps,BK        ; Set block size for circular buffer
  5524.                 ; of x(n)
  5525.     LDF    *AR4++,R0    ; get x(n)
  5526.     LDI    AR6,RC        ; get number of samples - 1
  5527.     LDI    taps-1,IR0
  5528.  
  5529.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  5530. ||    STF    R0,*AR0        ; put x(n) in delay memory
  5531.     MPYF    *AR1++,*AR0++%,R0 ;
  5532.  
  5533.     RPTB    loop
  5534. ~do~    MPYF    *AR1~coef_inc~,*AR0++%,R0
  5535. ||    ~s~F    R0,R2,R2
  5536. ~loopm2~~if symetric~    MPYF    *AR1,*AR0%,R0
  5537. ||    ~s~F    R0,R2,R3
  5538. ~else~    MPYF    *AR1--(IR0),*AR0%,R0
  5539. ||    ~s~F    R0,R2,R3
  5540. ~endif~
  5541.     LDF    *AR4,R1        ; get next sample
  5542. ||    LDF    *+AR7,R2    ; initialize R2 to 0.0
  5543.     MPYF3    *AR1++,*AR4++,R0; x(n+1) * h(0) -> R0
  5544. ||    ~s~F3    R0,R3,R3    ; final sum for y(n) -> R3
  5545. loop:    STF    R3,*AR5++    ; store y(n) into array
  5546. ||    STF    R1,*AR0++%    ; store x(n+1) into delay memory
  5547.  
  5548.     NOP    *AR0--%        ; back up delay pointer for next x(n)
  5549.     STI    AR0,*AR7--(3)    ; save updated circular buffer point
  5550.                 ; for next sample
  5551.     RETS            ; return y(n) in R0
  5552.     .else
  5553.     CALL    40h        ; signal error with break point
  5554.     .endif
  5555.     
  5556. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  5557. ;Input:
  5558. ;    R0    x(n)
  5559. ;    AR7    pointer to FIR filter structure
  5560. ;Ouput:
  5561. ;    R0    y(n)
  5562. ;    R2, AR0, AR1, BK, RC, RS, RE destroyed
  5563.  
  5564. ;
  5565. ; filter returns y(n) for input x(n)
  5566. ;
  5567. ; the filter routine must be called with x(0) first then x(1)
  5568. ; and so on.
  5569.  
  5570. _F_~IDT~:
  5571.     .if    s_by_s_filter
  5572.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  5573.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  5574.                 ; delay memory
  5575.     LDI    taps,BK        ; Set block size for circular buffer
  5576.                 ; of x(n)
  5577.     LDF    0.0,R2        ; initialize R2 = 0.0
  5578.     STF    R0,*AR0        ; put x(n) in delay memory
  5579.     MPYF    *AR1++,*AR0++%,R0 ;
  5580. ~do~    MPYF    *AR1~coef_inc~,*AR0++%,R0
  5581. ||    ~s~F    R0,R2,R2
  5582. ~loopm2~    MPYF    *AR1,*AR0%,R0
  5583. ||    ~s~F    R0,R2,R2
  5584.     ~s~F    R0,R2,R0    ; add last product
  5585.     
  5586.     STI    AR0,*AR7--(3)    ; save updated circular buffer point
  5587.                 ; for next sample
  5588.     RETS            ; return y(n) in R0
  5589.     .else
  5590.     CALL    40h        ; signal error with break point
  5591.     .endif
  5592.  
  5593.  
  5594. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5595. ;                                                           ;
  5596. ;                     Build Coefficients                    ;
  5597. ;                                                           ;
  5598. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5599. fmema:    .word    fmem
  5600. fmem    .word    delay_m        ;address of delay memory
  5601.     .word    coef_m        ;address of coef_mem
  5602.     .word    _F_~IDT~    ;address of sample by sample filter
  5603.     .word    _F_~IDT~a    ;address of array filter routine
  5604.     .if coef_ram = 0
  5605.     .sect    "C_~IDT~"
  5606. coef_m:
  5607.     .endif
  5608. ~if symetric~~do~    .float   ~coeff~     ; ~coef_name~ = ~esign~~coef_nameI~
  5609. ~looph~
  5610. ~else~~do~    .float   ~coeff~     ; ~coef_name~
  5611. ~loop~~endif~
  5612.  
  5613. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5614. ;                                                           ;
  5615. ;                Reserve Coefficients Space                 ;
  5616. ;                                                           ;
  5617. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5618.     .if coef_ram
  5619. coef_m    .usect    "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
  5620.     .endif
  5621. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5622. ;                                                           ;
  5623. ;              Reserve Space for Delay Memory               ;
  5624. ;                                                           ;
  5625. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5626.  
  5627. ;The following section must be unique in name and be aligned on
  5628. ;a ~align~ word address boundary.  This can be accomplished with a
  5629. ;LNK30 command file.  CGEN produces an example LNK30 command file
  5630. ;named "LINK.CMD".
  5631.  
  5632. delay_m    .usect    "D_~IDT~",taps
  5633.  
  5634.     .end
  5635. ~end~
  5636. >>>>
  5637. >>>
  5638. 3
  5639. 8
  5640. ~
  5641. TMS320C30; ASM30 interface; Time Optimized
  5642. >>>
  5643. ~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5644. ;                                                           ;
  5645. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  5646. ;                                                           ;
  5647. ;               TMS320C30 FIR filter realization            ;
  5648. ;                                                           ;
  5649. ;                   Parks-McClellan Design                  ;
  5650. ;                                                           ;
  5651. ;                       Time Optimized                      ;
  5652. ;                                                           ;
  5653. ;                 Assembly Language Interface               ;
  5654. ;                                                           ;
  5655. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5656. ;
  5657. ~filter_file~
  5658.  
  5659.     .copy "model.inc"    ;This include file specifies different
  5660.                 ;memory models and ways of assembling
  5661.                 ;the code.
  5662.  
  5663. ;The following structure defines the data structure that the Init routine
  5664. ;initializes.  This structure is passed, along with x(n) to the filter
  5665. ;routines.
  5666. ;
  5667. ;struct FIR {
  5668. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  5669. ;    void    (*filtera)();    /* pointer to array filter routine */
  5670. ;    float    *coef_mem;    /* pointer to coef. memory */
  5671. ;    float    *delay_mem;    /* pointer to delay memory */
  5672. ;    float    zero;        /* a floating point 0 */
  5673. ;    int    BK_reg;        /* value to be placed in BK register */
  5674. ;    int    frtaps;        /* number of taps for RPTS forward */
  5675. ;    };
  5676.  
  5677. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5678. ;                                                           ;
  5679. ;                 FIR Filter Init Routine                   ;
  5680. ;                                                           ;
  5681. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5682.  
  5683.     .text
  5684.  
  5685. FP    .set    AR3
  5686. taps    .set    ~taps~
  5687.  
  5688. ;        INITIALIZE THE FILTER memory and the FIR structure
  5689. ;
  5690. ;Calling sequence:
  5691. ;    CALL    ~if option M~init_filter~else~I_~IDT~~endif~
  5692. ;
  5693. ;Input:
  5694. ;    AR7    pointer to FIR filter structure
  5695. ;Output:
  5696. ;    AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
  5697. ;
  5698. ;
  5699. ~if option M~    .globl    I_FILTER
  5700. I_FILTER:
  5701. ~else~    .globl    I_~IDT~
  5702. I_~IDT~:
  5703. ~endif~    
  5704.     LDP    fmema
  5705.     LDI    @fmema,AR0    ;Get address of address of delay memory
  5706.     LDI    *AR0++,AR1    ;Get address of delay memory
  5707.  
  5708.     STI    AR1,*+AR7(3)    ;Put in FIR structure
  5709.     LDF    0.0,R0
  5710.     STF    R0,*+AR7(4)    ;Set zero in FIR structure
  5711.     LDI    taps+1,BK    ;Set block size for circular buffer
  5712.                 ; of x(n)
  5713.     RPTS    taps
  5714.     STF    R0,*AR1++%    ;Zero the delay memory
  5715.     LDI    *AR0++,R0    ;Get address of coef
  5716.     STI    R0,*+AR7(2)    ;Put address of coef. in FIR structure
  5717.     LDI    *AR0++,R0    ;Get address of sample by sample filter routine
  5718.     STI    R0,*+AR7(0)    ;Put in FIR filter structure
  5719.     LDI    *AR0++,R0    ;Get address of array filter routine
  5720.     STI    R0,*+AR7(1)    ;Put in FIR filter structure
  5721.     STI    BK,*+AR7(5)    ;Put BK in FIR structure
  5722.     LDI    taps-3,R0    ;Get number taps for RPTS instruction
  5723.     STI    R0,*+AR7(6)    ;Put in FIR structure
  5724.     LDI    taps-1,R0    ;Get number for RPTS instruction
  5725.     STI    R0,*+AR7(7)    ;Store in FIR filter structure
  5726.  
  5727.     .if coef_ram
  5728.     LDI    *+AR7(2),AR1    ;get address of RAM coef
  5729.     LDI    *AR0++,R0    ;Get first ROM coef
  5730.     RPTS    taps-1
  5731.     LDI    *AR0++,R0
  5732. ||    STI    R0,*AR1++    ;copy ROM coef to RAM coef
  5733.     .endif
  5734.  
  5735.     RETS
  5736.     
  5737.  
  5738. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5739. ;                                                           ;
  5740. ;                      Build constants                      ;
  5741. ;                                                           ;
  5742. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5743.     .globl    FIR_A
  5744.     .globl    FIR_Aa
  5745.  
  5746. fmema:    .word    fmem
  5747. fmem:    .word    delay_m
  5748.     .word    coef_m
  5749.     .word    FIR_A
  5750.     .word    FIR_Aa
  5751.     .if coef_ram = 0
  5752.     .sect    "C_~IDT~"
  5753. coef_m:
  5754.     .endif
  5755. ~do~    .float   ~coeff~     ; ~coef_name~
  5756. ~loop~
  5757.  
  5758. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5759. ;                                                           ;
  5760. ;                Reserve Coefficients Space                 ;
  5761. ;                                                           ;
  5762. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5763.     .if coef_ram
  5764. coef_m    .usect    "C_~IDT~",taps
  5765.     .endif
  5766. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5767. ;                                                           ;
  5768. ;              Reserve Space for Delay Memory               ;
  5769. ;                                                           ;
  5770. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5771.  
  5772. ;The following section must be unique in name and be aligned on
  5773. ;a ~align~ word address boundary.  This can be accomplished with a
  5774. ;LNK30 command file.  CGEN produces an example LNK30 command file
  5775. ;named "LINK.CMD".
  5776.  
  5777. delay_m    .usect    "D_~IDT~",taps+1
  5778.  
  5779.     .end
  5780. ~end~
  5781. >>>>
  5782. >>>
  5783. 3
  5784. 8
  5785. ~
  5786. TMS320C30; ASM30 interface; Size Optimized
  5787. >>>
  5788. ~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5789. ;                                                           ;
  5790. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  5791. ;                                                           ;
  5792. ;               TMS320C30 FIR filter realization            ;
  5793. ;                                                           ;
  5794. ;                   Parks-McClellan Design                  ;
  5795. ;                                                           ;
  5796. ;                       Size Optimized                      ;
  5797. ;                                                           ;
  5798. ;                 Assembly Language Interface               ;
  5799. ;                                                           ;
  5800. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5801. ;
  5802. ~filter_file~
  5803.  
  5804.     .copy "model.inc"    ;This include file specifies different
  5805.                 ;memory models and ways of assembling
  5806.                 ;the code.
  5807.  
  5808. ;The following structure defines the data structure that the Init routine
  5809. ;initializes.  This structure is passed, along with x(n) to the filter
  5810. ;routines.
  5811. ;
  5812. ;struct FIR {
  5813. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  5814. ;    void    (*filtera)();    /* pointer to array filter routine */
  5815. ;    float    *coef_mem;    /* pointer to coef. memory */
  5816. ;    float    *delay_mem;    /* pointer to delay memory */
  5817. ;    float    zero;        /* a floating point 0 */
  5818. ;    int    BK_reg;        /* value to be placed in BK register */
  5819. ;    int    frtaps;        /* number of taps for RPTS forward */
  5820. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  5821. ;    };
  5822.  
  5823. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5824. ;                                                           ;
  5825. ;                 FIR Filter Init Routine                   ;
  5826. ;                                                           ;
  5827. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5828.  
  5829.     .text
  5830.  
  5831. FP    .set    AR3
  5832. taps    .set    ~taps~
  5833.  
  5834. ;        INITIALIZE THE FILTER memory and the FIR structure
  5835. ;
  5836. ;Calling sequence:
  5837. ;    CALL    ~if option M~init_filter~else~I_~IDT~~endif~
  5838. ;
  5839. ;Input:
  5840. ;    AR7    pointer to FIR filter structure
  5841. ;Output:
  5842. ;    AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
  5843. ;
  5844. ;
  5845. ~if option M~    .globl    I_FILTER
  5846. I_FILTER:
  5847. ~else~    .globl    I_~IDT~
  5848. I_~IDT~:
  5849. ~endif~    
  5850.     LDP    fmema
  5851.     LDI    @fmema,AR0    ;Get address of address of delay memory
  5852.     LDI    *AR0++,AR1    ;Get address of delay memory
  5853.  
  5854.     STI    AR1,*+AR7(3)    ;Put in FIR structure
  5855.     LDF    0.0,R0
  5856.     STF    R0,*+AR7(4)    ;Set zero in FIR structure
  5857.     LDI    taps+1,BK    ;Set block size for circular buffer
  5858.                 ; of x(n)
  5859.     RPTS    taps
  5860.     STF    R0,*AR1++%    ;Zero the delay memory
  5861.     LDI    *AR0++,R0    ;Get address of coef
  5862.     STI    R0,*+AR7(2)    ;Put address of coef. in FIR structure
  5863.     LDI    *AR0++,R0    ;Get address of sample by sample filter routine
  5864.     STI    R0,*+AR7(0)    ;Put in FIR filter structure
  5865.     LDI    *AR0++,R0    ;Get address of array filter routine
  5866.     STI    R0,*+AR7(1)    ;Put in FIR filter structure
  5867.     STI    BK,*+AR7(5)    ;Put BK in FIR structure
  5868.     LDI    taps~if symetric~/2-2~else~-3~endif~,R0    ;Get number for RPTS instruction
  5869.     STI    R0,*+AR7(6)    ;Put in FIR structure
  5870. ~if symetric~
  5871.     LDI    (taps-1)/2~if asym_odd~-1~endif~~if asym_even~-1~endif~,R0    ;Get number for RPTS instruction
  5872. ~else~
  5873.     LDI    taps-1,R0    ;Get number for RPTS instruction
  5874. ~endif~
  5875.     STI    R0,*+AR7(7)    ;Store in FIR filter structure
  5876.  
  5877.     .if coef_ram
  5878.     LDI    *+AR7(2),AR1    ;get address of RAM coef
  5879.     LDI    *AR0++,R0    ;Get first ROM coef
  5880.     RPTS    ~if symetric~(taps+1)/2~else~taps~endif~-1
  5881.     LDI    *AR0++,R0
  5882. ||    STI    R0,*AR1++    ;copy ROM coef to RAM coef
  5883.     .endif
  5884.  
  5885.     RETS
  5886.     
  5887. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5888. ;                                                           ;
  5889. ;                     Build init data                       ;
  5890. ;                                                           ;
  5891. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5892.  
  5893.     .word    1,fmema            ;init one word at location fmema
  5894. fmema:    .word    fmem            ;address of fmem to be put into fmema
  5895. ~if sym_even~    .globl    FIR_Ase
  5896.     .globl    FIR_Asea
  5897. ~endif~~if sym_odd~    .globl    FIR_Aso
  5898.     .globl    FIR_Asoa
  5899. ~endif~~if asym_even~    .globl    FIR_Aase
  5900.     .globl    FIR_Aasea
  5901. ~endif~~if asym_odd~    .globl    FIR_Aaso
  5902.     .globl    FIR_Aasoa
  5903. ~endif~~if symetric~~else~    .globl    FIR_A
  5904.     .globl    FIR_Aa
  5905. ~endif~
  5906. fmem:    .word    delay_m            ;address of delay memory
  5907.     .word    coef_m            ;address of coef_mem
  5908. ~if sym_even~    .word    FIR_Ase        ;address of sample by sample filter
  5909.     .word    FIR_Asea        ;address of array filter routine
  5910. ~endif~~if sym_odd~    .word    FIR_Aso        ;address of sample by sample filter
  5911.     .word    FIR_Asoa        ;address of array filter routine
  5912. ~endif~~if asym_even~    .word    FIR_Aase        ;address of sample by sample filter
  5913.     .word    FIR_Aasea        ;address of array filter routine
  5914. ~endif~~if asym_odd~    .word    FIR_Aaso        ;address of sample by sample filter
  5915.     .word    FIR_Aasoa        ;address of array filter routine
  5916. ~endif~~if symetric~~else~    .word    FIR_A        ;address of sample by sample filter
  5917.     .word    FIR_Aa            ;address of array filter routine
  5918. ~endif~
  5919.     .if coef_ram = 0
  5920.     .sect    "C_~IDT~"
  5921. coef_m:
  5922.     .endif
  5923. ~if symetric~~do~    .float   ~coeff~     ; ~coef_name~ = ~esign~~coef_nameI~
  5924. ~looph~
  5925. ~else~~do~    .float   ~coeff~     ; ~coef_name~
  5926. ~loop~~endif~
  5927. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5928. ;                                                           ;
  5929. ;                Reserve Coefficients Space                 ;
  5930. ;                                                           ;
  5931. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5932.     .if coef_ram
  5933. coef_m    .usect    "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
  5934.     .endif
  5935. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5936. ;                                                           ;
  5937. ;              Reserve Space for Delay Memory               ;
  5938. ;                                                           ;
  5939. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5940.  
  5941. ;The following section must be unique in name and be aligned on
  5942. ;a ~align~ word address boundary.  This can be accomplished with a
  5943. ;LNK30 command file.  CGEN produces an example LNK30 command file
  5944. ;named "LINK.CMD".
  5945.  
  5946. delay_m    .usect    "D_~IDT~",taps+1
  5947.  
  5948.     .end
  5949. ~status~~end~
  5950. >>>>
  5951. >>>
  5952. 2
  5953. 8
  5954. ~
  5955. TMS320C30; 'C' interface; Time Optimize w/ Optimized Filter Routine
  5956. >>>
  5957. ~set_C~~set_A~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5958. ;                                                           ;
  5959. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  5960. ;                                                           ;
  5961. ;               TMS320C30 FIR filter realization            ;
  5962. ;                                                           ;
  5963. ;                    Kaiser Window Design                   ;
  5964. ;                                                           ;
  5965. ;                    Super Time Optimized                   ;
  5966. ;                                                           ;
  5967. ;                   'C' compiler interface                  ;
  5968. ;                                                           ;
  5969. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5970. ;
  5971. ~filter_file~
  5972.  
  5973.     .copy "model.inc"    ;This include file specifies different
  5974.                 ;memory models and ways of assembling
  5975.                 ;the code.
  5976.  
  5977. ;The following structure defines the 'C' structure that the Init routine
  5978. ;initializes.  This structure is passed, along with x(n) to the filter
  5979. ;routines.
  5980. ;
  5981. ;struct FIR {
  5982. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  5983. ;    void    (*filtera)();    /* pointer to array filter routine */
  5984. ;    float    *coef_mem;    /* pointer to coef. memory */
  5985. ;    float    *delay_mem;    /* pointer to delay memory */
  5986. ;    float    zero;        /* a floating point 0 */
  5987. ;    };
  5988.  
  5989. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5990. ;                                                           ;
  5991. ;                 FIR Filter Init Routines                  ;
  5992. ;                                                           ;
  5993. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5994.  
  5995.     .text
  5996.  
  5997. FP    .set    AR3
  5998. taps    .set    ~taps~
  5999.  
  6000. ;        INITIALIZE THE FILTER memory and the FIR structure
  6001. ;
  6002. ;struct FIR initf()
  6003. ;
  6004. ;Calling sequence from 'C':
  6005. ;
  6006. ;    FIR = ~if option M~init_filter~else~I_~IDT~~endif~();
  6007. ;
  6008. ;      where FIR is a structure as defined above.
  6009. ;
  6010. ~if option M~    .globl    _I_FILTER
  6011. _I_FILTER:
  6012. ~else~    .globl    _I_~IDT~
  6013. _I_~IDT~:
  6014. ~endif~    .if    large_model
  6015.     LDP    fmema
  6016.     .endif
  6017.     LDI    @fmema,AR2    ;Get address of address of init memory
  6018.     LDI    *AR2++,AR1    ;Get address of delay memory
  6019.  
  6020.     STI    AR1,*+AR0(3)    ;Put in FIR structure
  6021.     LDF    0.0,R0
  6022.     STF    R0,*+AR0(4)    ;Set zero in FIR structure
  6023.     LDI    taps,BK        ;Set block size for circular buffer
  6024.                 ; of x(n)
  6025.     RPTS    taps
  6026.     STF    R0,*AR1++%    ;Zero the delay memory
  6027.     LDI    *AR2++,R0    ;Get address of coef.
  6028.     STI    R0,*+AR0(2)    ;Put address of coef. in FIR structure
  6029.     LDI    *AR2++,R0    ;Get address of sample by sample filter routine
  6030.     STI    R0,*+AR0(0)    ;Put in FIR filter structure
  6031.     LDI    *AR2++,R0    ;Get address of array filter routine
  6032.     STI    R0,*+AR0(1)    ;Put in FIR filter structure
  6033.     RETS
  6034.     
  6035. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6036. ;                                                           ;
  6037. ;                   FIR Filter Subroutine                   ;
  6038. ;                                                           ;
  6039. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6040.     .globl    _F_~IDT~
  6041.     .globl    _F_~IDT~a
  6042.  
  6043. ;        PERFORM ARRAY FILTERING
  6044. ;void (*param->filtera)(xy,xn,n,param)
  6045. ;float *xn, *yn
  6046. ;int n;
  6047. ;struct FIR *param;
  6048. ;
  6049. ; filter returns y(n) for input x(n)
  6050. ; xn and yn are pointers to arrays of size n+1 floats
  6051. ; n is the number of samples - 1
  6052. ;
  6053. ; the filter routine must be called with x(0) thru x(n)
  6054. ; first then x(n+1) thru x(....) and so on.
  6055.  
  6056. _F_~IDT~a:
  6057.     .if array_filter
  6058.     PUSH    FP
  6059.     LDI    SP,FP
  6060.     PUSH    AR6
  6061.     PUSH    AR7
  6062.  
  6063.     LDI    *-FP(5),AR2    ; AR2 = address of FIR filter structure
  6064.     LDI    *++AR2(2),AR1    ; AR1 = address of coefficients
  6065.     LDI    *++AR2,AR0    ; AR0 = address of x(n) in circular
  6066.                 ; delay memory
  6067.                 ; Note: AR2 now points to delay memory address
  6068.     LDI    taps,BK        ; Set block size for circular buffer
  6069.                 ; of x(n)
  6070.     LDI    *-FP(2),AR7    ; AR7 = address of y(n)
  6071.     LDI    *-FP(3),AR6    ; AR6 = address of x(n)
  6072.     LDI    taps-1,IR0    ; size of coef memory - 1
  6073.     LDF    *AR6++,R0    ; get x(n)
  6074.     LDI    *-FP(4),RC    ; get number of samples - 1
  6075.  
  6076.     LDF    *+AR2,R2    ; initialize R2 to 0.0
  6077. ||    STF    R0,*AR0        ; put x(n) in delay memory
  6078.     MPYF    *AR1++,*AR0++%,R0 ;
  6079.  
  6080.     RPTB    loop
  6081. ~do~    MPYF    *AR1~coef_inc~,*AR0++%,R0
  6082. ||    ~s~F    R0,R2,R2
  6083. ~loopm2~~if symetric~    MPYF    *AR1,*AR0%,R0
  6084. ||    ~s~F    R0,R2,R3
  6085. ~else~    MPYF    *AR1--(IR0),*AR0%,R0
  6086. ||    ~s~F    R0,R2,R3
  6087. ~endif~
  6088.     LDF    *AR6,R1        ; get next sample
  6089. ||    LDF    *+AR2,R2    ; initialize R2 to 0.0
  6090.     MPYF3    *AR6++,*AR1++,R0; x(n+1) * h(0) -> R0
  6091. ||    ~s~F3    R0,R3,R3    ; final sum for y(n) -> R3
  6092. loop:    STF    R3,*AR7++    ; store y(n) into array
  6093. ||    STF    R1,*AR0++%    ; store x(n+1) into delay memory
  6094.  
  6095.     NOP    *AR0--%        ; back up delay pointer for next x(n)
  6096.     STI    AR0,*AR2    ; save updated circular buffer point
  6097.                 ; for next sample
  6098.     POP    AR7
  6099.     POP    AR6
  6100.     POP    FP
  6101.     RETS            ; return y(n) in R0
  6102.     .else
  6103.     CALL    40h        ; signal error with break point
  6104.     .endif
  6105.     
  6106. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  6107. ;float (*param->filter)(xn,param)
  6108. ;float xn
  6109. ;struct FIR *param;
  6110. ;
  6111. ; filter returns y(n) for input x(n)
  6112. ;
  6113. ; the filter routine must be called with x(0) first then x(1)
  6114. ; and so on.
  6115.  
  6116. _F_~IDT~:
  6117.     .if    s_by_s_filter
  6118.     PUSH    FP
  6119.     LDI    SP,FP
  6120.  
  6121.     LDI    *-FP(3),AR2    ; AR2 = address of FIR filter structure
  6122.     LDI    *++AR2(2),AR1    ; AR1 = address of coefficients
  6123.     LDI    *++AR2,AR0    ; AR0 = address of x(n) in circular
  6124.                 ; delay memory
  6125.     LDI    taps,BK        ; Set block size for circular buffer
  6126.                 ; of x(n)
  6127.     LDF    0.0,R2        ; initialize R2 = 0.0
  6128.     LDF    *-FP(2),R0    ; R0 = x(n)
  6129.     STF    R0,*AR0        ; put x(n) in delay memory
  6130.     MPYF    *AR1++,*AR0++%,R0 ;
  6131. ~do~    MPYF    *AR1~coef_inc~,*AR0++%,R0
  6132. ||    ~s~F    R0,R2,R2
  6133. ~loopm2~    MPYF    *AR1,*AR0%,R0
  6134. ||    ~s~F    R0,R2,R2
  6135.     ~s~F    R0,R2,R0    ; add last product
  6136.     
  6137.     STI    AR0,*AR2    ; save updated circular buffer point
  6138.                 ; for next sample
  6139.     POP    FP
  6140.     RETS            ; return y(n) in R0
  6141.     .else
  6142.     CALL    40h        ; signal error with break point
  6143.     .endif
  6144.  
  6145. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6146. ;                                                           ;
  6147. ;              Build .bss and .cinit sections               ;
  6148. ;                                                           ;
  6149. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6150.  
  6151. ; The .cinit section exists to provide initialization data
  6152. ; for the .bss section.  The .bss section is where 'C'
  6153. ; keeps all of its static and global storage.
  6154.  
  6155.     .sect    ".cinit"
  6156.     .word    1,fmema        ;init one word at location fmema
  6157.     .word    fmem        ;address of fmem to be put into fmema
  6158.     .bss    fmema,1        ;reserve fmema in .bss
  6159.     .word    4,fmem
  6160.     .word    delay_m        ;address of delay memory
  6161.     .word    coef_m        ;address of coef_mem
  6162.     .word    _F_~IDT~    ;address of sample by sample filter
  6163.     .word    _F_~IDT~a    ;address of array filter routine
  6164.     .bss    fmem,4
  6165.     .if coef_ram
  6166.     .word    ~if symetric~(taps+1)/2~else~taps~endif~,coef_m
  6167.     .else
  6168.     .sect    "C_~IDT~"
  6169. coef_m:
  6170.     .endif
  6171. ~if symetric~~do~    .float   ~coeff~     ; ~coef_name~ = ~esign~~coef_nameI~
  6172. ~looph~
  6173. ~else~~do~    .float   ~coeff~     ; ~coef_name~
  6174. ~loop~~endif~
  6175.  
  6176. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6177. ;                                                           ;
  6178. ;              Reserve Space for Coefficients               ;
  6179. ;                                                           ;
  6180. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6181.     .if coef_ram
  6182. coef_m    .usect    "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
  6183.     .endif
  6184. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6185. ;                                                           ;
  6186. ;              Reserve Space for Delay Memory               ;
  6187. ;                                                           ;
  6188. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6189.  
  6190. ;The following section must be unique in name and be aligned on
  6191. ;a ~align~ word address boundary.  This can be accomplished with a
  6192. ;LNK30 command file.  CGEN produces an example LNK30 command file
  6193. ;named "LINK.CMD".
  6194.  
  6195. delay_m    .usect    "D_~IDT~",taps
  6196.  
  6197.     .end
  6198. ~end~
  6199. >>>>
  6200. >>>
  6201. 2
  6202. 8
  6203. ~
  6204. TMS320C30; 'C' interface; Time Optimize
  6205. >>>
  6206. ~set_C~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6207. ;                                                           ;
  6208. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  6209. ;                                                           ;
  6210. ;               TMS320C30 FIR filter realization            ;
  6211. ;                                                           ;
  6212. ;                    Kaiser Window Design                   ;
  6213. ;                                                           ;
  6214. ;                       Time Optimized                      ;
  6215. ;                                                           ;
  6216. ;                   'C' compiler interface                  ;
  6217. ;                                                           ;
  6218. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6219. ;
  6220. ~filter_file~
  6221.  
  6222.     .copy "model.inc"    ;This include file specifies different
  6223.                 ;memory models and ways of assembling
  6224.                 ;the code.
  6225.  
  6226. ;The following structure defines the 'C' structure that the Init routine
  6227. ;initializes.  This structure is passed, along with x(n) to the filter
  6228. ;routines.
  6229. ;
  6230. ;struct FIR {
  6231. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  6232. ;    void    (*filtera)();    /* pointer to array filter routine */
  6233. ;    float    *coef_mem;    /* pointer to coef. memory */
  6234. ;    float    *delay_mem;    /* pointer to delay memory */
  6235. ;    float    zero;        /* a floating point 0 */
  6236. ;    int    BK_reg;        /* value to be placed in BK register */
  6237. ;    int    frtaps;        /* number of taps for RPTS forward */
  6238. ;    };
  6239.  
  6240. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6241. ;                                                           ;
  6242. ;                 FIR Filter Init Routines                  ;
  6243. ;                                                           ;
  6244. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6245.  
  6246.     .text
  6247.  
  6248. FP    .set    AR3
  6249. taps    .set    ~taps~
  6250.  
  6251. ;        INITIALIZE THE FILTER memory and the FIR structure
  6252. ;
  6253. ;struct FIR initf()
  6254. ;
  6255. ;Calling sequence from 'C':
  6256. ;
  6257. ;    FIR = ~if option M~init_filter~else~I_~IDT~~endif~();
  6258. ;
  6259. ;      where FIR is a structure as defined above.
  6260. ;
  6261. ~if option M~    .globl    _I_FILTER
  6262. _I_FILTER:
  6263. ~else~    .globl    _I_~IDT~
  6264. _I_~IDT~:
  6265. ~endif~    .if    large_model
  6266.     LDP    fmema
  6267.     .endif
  6268.     LDI    @fmema,AR2    ;Get address of address of init memory
  6269.     LDI    *AR2++,AR1    ;Get address of delay memory
  6270.  
  6271.     STI    AR1,*+AR0(3)    ;Put in FIR structure
  6272.     LDF    0.0,R0
  6273.     STF    R0,*+AR0(4)    ;Set zero in FIR structure
  6274.     LDI    taps+1,BK    ;Set block size for circular buffer
  6275.                 ; of x(n)
  6276.     RPTS    taps
  6277.     STF    R0,*AR1++%    ;Zero the delay memory
  6278.     LDI    taps-3,R0    ;Get number for RPTS instruction
  6279.     STI    R0,*+AR0(6)    ;Store in FIR filter structure
  6280.     LDI    *AR2++,R0    ;Get address of coef.
  6281.     STI    R0,*+AR0(2)    ;Put address of coef. in FIR structure
  6282.     LDI    *AR2++,R0    ;Get address of sample by sample filter routine
  6283.     STI    R0,*+AR0(0)    ;Put in FIR filter structure
  6284.     LDI    *AR2++,R0    ;Get address of array filter routine
  6285.     STI    R0,*+AR0(1)    ;Put in FIR filter structure
  6286.     STI    BK,*+AR0(5)    ;Put BK in FIR structure
  6287.     LDI    taps-1,R0    ;Get number for RPTS instruction
  6288.     STI    R0,*+AR0(7)    ;Store in FIR filter structure
  6289.     RETS
  6290.     
  6291. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6292. ;                                                           ;
  6293. ;              Build .bss and .cinit sections               ;
  6294. ;                                                           ;
  6295. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6296.  
  6297. ; The .cinit section exists to provide initialization data
  6298. ; for the .bss section.  The .bss section is where 'C'
  6299. ; keeps all of its static and global storage.
  6300.  
  6301.     .sect    ".cinit"
  6302.     .word    1,fmema            ;init one word at location fmema
  6303.     .word    fmem            ;address of fmem to be put into fmema
  6304.     .bss    fmema,1            ;reserve fmema in .bss
  6305.     .globl    _FIR_C
  6306.     .globl    _FIR_Ca
  6307.     .word    4,fmem
  6308.     .word    delay_m            ;address of delay memory
  6309.     .word    coef_m            ;address of coef_mem
  6310.     .word    _FIR_C            ;address of sample by sample filter
  6311.     .word    _FIR_Ca            ;address of array filter routine
  6312.     .bss    fmem,4
  6313.     .if coef_ram
  6314.     .word    taps,coef_m
  6315.     .else
  6316.     .sect    "C_~IDT~"
  6317. coef_m:
  6318.     .endif
  6319. ~do~    .float   ~coeff~     ; ~coef_name~
  6320. ~loop~
  6321. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6322. ;                                                           ;
  6323. ;                Reserve Coefficients Space                 ;
  6324. ;                                                           ;
  6325. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6326.     .if coef_ram
  6327. coef_m    .usect    "C_~IDT~",taps
  6328.     .endif
  6329. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6330. ;                                                           ;
  6331. ;              Reserve Space for Delay Memory               ;
  6332. ;                                                           ;
  6333. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6334.  
  6335. ;The following section must be unique in name and be aligned on
  6336. ;a ~align~ word address boundary.  This can be accomplished with a
  6337. ;LNK30 command file.  CGEN produces an example LNK30 command file
  6338. ;named "LINK.CMD".
  6339.  
  6340. delay_m    .usect    "D_~IDT~",taps+1
  6341.  
  6342.     .end
  6343. ~end~
  6344. >>>>
  6345. >>>
  6346. 2
  6347. 8
  6348. ~
  6349. TMS320C30; 'C' interface; Size Optimize
  6350. >>>
  6351. ~set_C~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6352. ;                                                           ;
  6353. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  6354. ;                                                           ;
  6355. ;               TMS320C30 FIR filter realization            ;
  6356. ;                                                           ;
  6357. ;                    Kaiser Window Design                   ;
  6358. ;                                                           ;
  6359. ;                       Size Optimized                      ;
  6360. ;                                                           ;
  6361. ;                   'C' compiler interface                  ;
  6362. ;                                                           ;
  6363. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6364. ;
  6365. ~filter_file~
  6366.  
  6367.     .copy "model.inc"    ;This include file specifies different
  6368.                 ;memory models and ways of assembling
  6369.                 ;the code.
  6370.  
  6371. ;The following structure defines the 'C' structure that the Init routine
  6372. ;initializes.  This structure is passed, along with x(n) to the filter
  6373. ;routines.
  6374. ;
  6375. ;struct FIR {
  6376. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  6377. ;    void    (*filtera)();    /* pointer to array filter routine */
  6378. ;    float    *coef_mem;    /* pointer to coef. memory */
  6379. ;    float    *delay_mem;    /* pointer to delay memory */
  6380. ;    float    zero;        /* a floating point 0 */
  6381. ;    int    BK_reg;        /* value to be placed in BK register */
  6382. ;    int    frtaps;        /* number of taps for RPTS forward */
  6383. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  6384. ;    };
  6385.  
  6386. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6387. ;                                                           ;
  6388. ;                 FIR Filter Init Routines                  ;
  6389. ;                                                           ;
  6390. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6391.  
  6392.     .text
  6393.  
  6394. FP    .set    AR3
  6395. taps    .set    ~taps~
  6396.  
  6397. ;        INITIALIZE THE FILTER memory and the FIR structure
  6398. ;
  6399. ;struct FIR initf()
  6400. ;
  6401. ;Calling sequence from 'C':
  6402. ;
  6403. ;    FIR = ~if option M~I_FILTER~else~I_~IDT~~endif~();
  6404. ;
  6405. ;      where FIR is a structure as defined above.
  6406. ;
  6407. ~if option M~    .globl    _I_FILTER
  6408. _I_FILTER:
  6409. ~else~    .globl    _I_~IDT~
  6410. _I_~IDT~:
  6411. ~endif~    .if    large_model
  6412.     LDP    fmema
  6413.     .endif
  6414.     LDI    @fmema,AR2    ;Get address of address of init memory
  6415.     LDI    *AR2++,AR1    ;Get address of delay memory
  6416.  
  6417.     STI    AR1,*+AR0(3)    ;Put in FIR structure
  6418.     LDF    0.0,R0
  6419.     STF    R0,*+AR0(4)    ;Set zero in FIR structure
  6420.     LDI    taps+1,BK    ;Set block size for circular buffer
  6421.                 ; of x(n)
  6422.     RPTS    taps
  6423.     STF    R0,*AR1++%    ;Zero the delay memory
  6424.     LDI    taps~if symetric~/2-2~else~-3~endif~,R0    ;Get number for RPTS instruction
  6425.     STI    R0,*+AR0(6)    ;Store in FIR filter structure
  6426. ~if symetric~
  6427.     LDI    (taps-1)/2~if asym_odd~-1~endif~~if asym_even~-1~endif~,R0    ;Get number for RPTS instruction
  6428. ~else~
  6429.     LDI    taps-1,R0    ;Get number for RPTS instruction
  6430. ~endif~
  6431.     STI    R0,*+AR0(7)    ;Store in FIR filter structure
  6432.     LDI    *AR2++,R0    ;Get address of coef.
  6433.     STI    R0,*+AR0(2)    ;Put address of coef. in FIR structure
  6434.     LDI    *AR2++,R0    ;Get address of sample by sample filter routine
  6435.     STI    R0,*+AR0(0)    ;Put in FIR filter structure
  6436.     LDI    *AR2++,R0    ;Get address of array filter routine
  6437.     STI    R0,*+AR0(1)    ;Put in FIR filter structure
  6438.     STI    BK,*+AR0(5)    ;Put BK in FIR structure
  6439.     RETS
  6440.     
  6441. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6442. ;                                                           ;
  6443. ;              Build .bss and .cinit sections               ;
  6444. ;                                                           ;
  6445. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6446.  
  6447. ; The .cinit section exists to provide initialization data
  6448. ; for the .bss section.  The .bss section is where 'C'
  6449. ; keeps all of its static and global storage.
  6450.  
  6451.     .sect    ".cinit"
  6452.     .word    1,fmema            ;init one word at location fmema
  6453.     .word    fmem            ;address of fmem to be put into fmema
  6454.     .bss    fmema,1            ;reserve fmema in .bss
  6455. ~if sym_even~    .globl    _FIR_Cse
  6456.     .globl    _FIR_Csea
  6457. ~endif~~if sym_odd~    .globl    _FIR_Cso
  6458.     .globl    _FIR_Csoa
  6459. ~endif~~if asym_even~    .globl    _FIR_Case
  6460.     .globl    _FIR_Casea
  6461. ~endif~~if asym_odd~    .globl    _FIR_Caso
  6462.     .globl    _FIR_Casoa
  6463. ~endif~~if symetric~~else~    .globl    _FIR_C
  6464.     .globl    _FIR_Ca
  6465. ~endif~    .word    4,fmem
  6466.     .word    delay_m            ;address of delay memory
  6467.     .word    coef_m            ;address of coef_mem
  6468. ~if sym_even~    .word    _FIR_Cse        ;address of sample by sample filter
  6469.     .word    _FIR_Csea        ;address of array filter routine
  6470. ~endif~~if sym_odd~    .word    _FIR_Cso        ;address of sample by sample filter
  6471.     .word    _FIR_Csoa        ;address of array filter routine
  6472. ~endif~~if asym_even~    .word    _FIR_Case        ;address of sample by sample filter
  6473.     .word    _FIR_Casea        ;address of array filter routine
  6474. ~endif~~if asym_odd~    .word    _FIR_Caso        ;address of sample by sample filter
  6475.     .word    _FIR_Casoa        ;address of array filter routine
  6476. ~endif~~if symetric~~else~    .word    _FIR_C        ;address of sample by sample filter
  6477.     .word    _FIR_Ca            ;address of array filter routine
  6478. ~endif~    .bss    fmem,4
  6479.     .if coef_ram
  6480.     .word    ~if symetric~(taps+1)/2~else~taps~endif~,coef_m
  6481.     .else
  6482.     .sect    "C_~IDT~"
  6483. coef_m:
  6484.     .endif
  6485. ~if symetric~~do~    .float   ~coeff~     ; ~coef_name~ = ~esign~~coef_nameI~
  6486. ~looph~
  6487. ~else~~do~    .float   ~coeff~     ; ~coef_name~
  6488. ~loop~~endif~
  6489. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6490. ;                                                           ;
  6491. ;                Reserve Coefficients Space                 ;
  6492. ;                                                           ;
  6493. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6494.     .if coef_ram
  6495. coef_m    .usect    "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
  6496.     .endif
  6497. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6498. ;                                                           ;
  6499. ;              Reserve Space for Delay Memory               ;
  6500. ;                                                           ;
  6501. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6502.  
  6503. ;The following section must be unique in name and be aligned on
  6504. ;a ~align~ word address boundary.  This can be accomplished with a
  6505. ;LNK30 command file.  CGEN produces an example LNK30 command file
  6506. ;named "LINK.CMD".
  6507.  
  6508. delay_m    .usect    "D_~IDT~",taps+1
  6509.  
  6510.     .end
  6511. ~status~~end~
  6512. >>>>
  6513. >>>
  6514. 2
  6515. 8
  6516. ~
  6517. TMS320C30; ASM30 interface; Time Optimize w/ Optimized Filter Routine
  6518. >>>
  6519. ~set_A~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6520. ;                                                           ;
  6521. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  6522. ;                                                           ;
  6523. ;               TMS320C30 FIR filter realization            ;
  6524. ;                                                           ;
  6525. ;                    Kaiser Window Design                   ;
  6526. ;                                                           ;
  6527. ;                    Super Time Optimized                   ;
  6528. ;                                                           ;
  6529. ;                  ASM30 compiler interface                 ;
  6530. ;                                                           ;
  6531. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6532. ;
  6533. ~filter_file~
  6534.  
  6535.     .copy "model.inc"    ;This include file specifies different
  6536.                 ;memory models and ways of assembling
  6537.                 ;the code.
  6538.  
  6539. ;The following structure defines the data structure that the Init routine
  6540. ;initializes.  This structure is passed, along with x(n) to the filter
  6541. ;routines.
  6542. ;
  6543. ;struct FIR {
  6544. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  6545. ;    void    (*filtera)();    /* pointer to array filter routine */
  6546. ;    float    *coef_mem;    /* pointer to coef. memory */
  6547. ;    float    *delay_mem;    /* pointer to delay memory */
  6548. ;    float    zero;        /* a floating point 0 */
  6549. ;    };
  6550.  
  6551. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6552. ;                                                           ;
  6553. ;                 FIR Filter Init Routines                  ;
  6554. ;                                                           ;
  6555. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6556.  
  6557.     .text
  6558.  
  6559. FP    .set    AR3
  6560. taps    .set    ~taps~
  6561.  
  6562. ;        INITIALIZE THE FILTER memory and the FIR structure
  6563. ;
  6564. ;Calling sequence:
  6565. ;    CALL    ~if option M~init_filter~else~I_~IDT~~endif~
  6566. ;
  6567. ;Input:
  6568. ;    AR7    pointer to FIR filter structure
  6569. ;Output:
  6570. ;    AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
  6571. ;
  6572. ;
  6573. ~if option M~    .globl    I_FILTER
  6574. I_FILTER:
  6575. ~else~    .globl    I_~IDT~
  6576. I_~IDT~:
  6577. ~endif~    LDP    fmema
  6578.     LDI    @fmema,AR0    ;Get address of init memory
  6579.     LDI    *AR0++,AR1    ;Get address of delay memory
  6580.  
  6581.     STI    AR1,*+AR7(3)    ;Put in FIR structure
  6582.     LDF    0.0,R0
  6583.     STF    R0,*+AR7(4)    ;Set zero in FIR structure
  6584.     LDI    taps,BK        ;Set block size for circular buffer
  6585.                 ; of x(n)
  6586.     RPTS    taps
  6587.     STF    R0,*AR1++%    ;Zero the delay memory
  6588.     LDI    *AR0++,R0    ;Get address of coef.
  6589.     STI    R0,*+AR7(2)    ;Put address of coef. in FIR structure
  6590.     LDI    *AR0++,R0    ;Get address of sample by sample filter routine
  6591.     STI    R0,*+AR7(0)    ;Put in FIR filter structure
  6592.     LDI    *AR0++,R0    ;Get address of array filter routine
  6593.     STI    R0,*+AR7(1)    ;Put in FIR filter structure
  6594.  
  6595.     .if coef_ram
  6596.     LDI    *+AR7(2),AR1    ;get address of RAM coef
  6597.     LDI    *AR0++,R0    ;Get first ROM coef
  6598.     RPTS    ~if symetric~(taps+1)/2~else~taps~endif~-1
  6599.     LDI    *AR0++,R0
  6600. ||    STI    R0,*AR1++    ;copy ROM coef to RAM coef
  6601.     .endif
  6602.  
  6603.     RETS
  6604.     
  6605. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6606. ;                                                           ;
  6607. ;                   FIR Filter Subroutine                   ;
  6608. ;                                                           ;
  6609. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6610.     .globl    _F_~IDT~
  6611.     .globl    _F_~IDT~a
  6612.  
  6613. ;        PERFORM ARRAY FILTERING
  6614. ;Input:
  6615. ;    AR4    address of x(n) array
  6616. ;    AR5    address of y(n) array
  6617. ;    AR6    number of samples-1 in array
  6618. ;    AR7    address of FIR filter structure
  6619. ;Output:
  6620. ;    AR(0-2), AR(4-6), R(0-3), IR0, BK, RC, RS, RE, DP destroyed
  6621.  
  6622. ; filter returns y(n) for input x(n)
  6623. ; AR2 and AR4 are pointers to arrays of size n+1 floats
  6624. ; n is the number of samples - 1
  6625. ;
  6626. ; the filter routine must be called with x(0) thru x(n)
  6627. ; first then x(n+1) thru x(....) and so on.
  6628.  
  6629. _F_~IDT~a:
  6630.     .if array_filter
  6631.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  6632.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  6633.                 ; delay memory
  6634.                 ; Note: AR2 now points to delay memory address
  6635.     LDI    taps,BK        ; Set block size for circular buffer
  6636.                 ; of x(n)
  6637.     LDF    *AR4++,R0    ; get x(n)
  6638.     LDI    AR6,RC        ; get number of samples - 1
  6639.     LDI    taps-1,IR0
  6640.  
  6641.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  6642. ||    STF    R0,*AR0        ; put x(n) in delay memory
  6643.     MPYF    *AR1++,*AR0++%,R0 ;
  6644.  
  6645.     RPTB    loop
  6646. ~do~    MPYF    *AR1~coef_inc~,*AR0++%,R0
  6647. ||    ~s~F    R0,R2,R2
  6648. ~loopm2~~if symetric~    MPYF    *AR1,*AR0%,R0
  6649. ||    ~s~F    R0,R2,R3
  6650. ~else~    MPYF    *AR1--(IR0),*AR0%,R0
  6651. ||    ~s~F    R0,R2,R3
  6652. ~endif~
  6653.     LDF    *AR4,R1        ; get next sample
  6654. ||    LDF    *+AR7,R2    ; initialize R2 to 0.0
  6655.     MPYF3    *AR1++,*AR4++,R0; x(n+1) * h(0) -> R0
  6656. ||    ~s~F3    R0,R3,R3    ; final sum for y(n) -> R3
  6657. loop:    STF    R3,*AR5++    ; store y(n) into array
  6658. ||    STF    R1,*AR0++%    ; store x(n+1) into delay memory
  6659.  
  6660.     NOP    *AR0--%        ; back up delay pointer for next x(n)
  6661.     STI    AR0,*AR7--(3)    ; save updated circular buffer point
  6662.                 ; for next sample
  6663.     RETS            ; return y(n) in R0
  6664.     .else
  6665.     CALL    40h        ; signal error with break point
  6666.     .endif
  6667.     
  6668. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  6669. ;Input:
  6670. ;    R0    x(n)
  6671. ;    AR7    pointer to FIR filter structure
  6672. ;Ouput:
  6673. ;    R0    y(n)
  6674. ;    R2, AR0, AR1, BK, RC, RS, RE destroyed
  6675.  
  6676. ;
  6677. ; filter returns y(n) for input x(n)
  6678. ;
  6679. ; the filter routine must be called with x(0) first then x(1)
  6680. ; and so on.
  6681.  
  6682. _F_~IDT~:
  6683.     .if    s_by_s_filter
  6684.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  6685.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  6686.                 ; delay memory
  6687.     LDI    taps,BK        ; Set block size for circular buffer
  6688.                 ; of x(n)
  6689.     LDF    0.0,R2        ; initialize R2 = 0.0
  6690.     STF    R0,*AR0        ; put x(n) in delay memory
  6691.     MPYF    *AR1++,*AR0++%,R0 ;
  6692. ~do~    MPYF    *AR1~coef_inc~,*AR0++%,R0
  6693. ||    ~s~F    R0,R2,R2
  6694. ~loopm2~    MPYF    *AR1,*AR0%,R0
  6695. ||    ~s~F    R0,R2,R2
  6696.     ~s~F    R0,R2,R0    ; add last product
  6697.     
  6698.     STI    AR0,*AR7--(3)    ; save updated circular buffer point
  6699.                 ; for next sample
  6700.     RETS            ; return y(n) in R0
  6701.     .else
  6702.     CALL    40h        ; signal error with break point
  6703.     .endif
  6704.  
  6705.  
  6706. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6707. ;                                                           ;
  6708. ;                     Build Coefficients                    ;
  6709. ;                                                           ;
  6710. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6711. fmema:    .word    fmem
  6712. fmem    .word    delay_m        ;address of delay memory
  6713.     .word    coef_m        ;address of coef_mem
  6714.     .word    _F_~IDT~    ;address of sample by sample filter
  6715.     .word    _F_~IDT~a    ;address of array filter routine
  6716.     .if coef_ram = 0
  6717.     .sect    "C_~IDT~"
  6718. coef_m:
  6719.     .endif
  6720. ~if symetric~~do~    .float   ~coeff~     ; ~coef_name~ = ~esign~~coef_nameI~
  6721. ~looph~
  6722. ~else~~do~    .float   ~coeff~     ; ~coef_name~
  6723. ~loop~~endif~
  6724.  
  6725. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6726. ;                                                           ;
  6727. ;                Reserve Coefficients Space                 ;
  6728. ;                                                           ;
  6729. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6730.     .if coef_ram
  6731. coef_m    .usect    "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
  6732.     .endif
  6733. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6734. ;                                                           ;
  6735. ;              Reserve Space for Delay Memory               ;
  6736. ;                                                           ;
  6737. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6738.  
  6739. ;The following section must be unique in name and be aligned on
  6740. ;a ~align~ word address boundary.  This can be accomplished with a
  6741. ;LNK30 command file.  CGEN produces an example LNK30 command file
  6742. ;named "LINK.CMD".
  6743.  
  6744. delay_m    .usect    "D_~IDT~",taps
  6745.  
  6746.     .end
  6747. ~end~
  6748. >>>>
  6749. >>>
  6750. 2
  6751. 8
  6752. ~
  6753. TMS320C30; ASM30 interface; Time Optimized
  6754. >>>
  6755. ~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6756. ;                                                           ;
  6757. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  6758. ;                                                           ;
  6759. ;               TMS320C30 FIR filter realization            ;
  6760. ;                                                           ;
  6761. ;                    Kaiser Window Design                   ;
  6762. ;                                                           ;
  6763. ;                       Time Optimized                      ;
  6764. ;                                                           ;
  6765. ;                 Assembly Language Interface               ;
  6766. ;                                                           ;
  6767. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6768. ;
  6769. ~filter_file~
  6770.  
  6771.     .copy "model.inc"    ;This include file specifies different
  6772.                 ;memory models and ways of assembling
  6773.                 ;the code.
  6774.  
  6775. ;The following structure defines the data structure that the Init routine
  6776. ;initializes.  This structure is passed, along with x(n) to the filter
  6777. ;routines.
  6778. ;
  6779. ;struct FIR {
  6780. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  6781. ;    void    (*filtera)();    /* pointer to array filter routine */
  6782. ;    float    *coef_mem;    /* pointer to coef. memory */
  6783. ;    float    *delay_mem;    /* pointer to delay memory */
  6784. ;    float    zero;        /* a floating point 0 */
  6785. ;    int    BK_reg;        /* value to be placed in BK register */
  6786. ;    int    frtaps;        /* number of taps for RPTS forward */
  6787. ;    };
  6788.  
  6789. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6790. ;                                                           ;
  6791. ;                 FIR Filter Init Routine                   ;
  6792. ;                                                           ;
  6793. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6794.  
  6795.     .text
  6796.  
  6797. FP    .set    AR3
  6798. taps    .set    ~taps~
  6799.  
  6800. ;        INITIALIZE THE FILTER memory and the FIR structure
  6801. ;
  6802. ;Calling sequence:
  6803. ;    CALL    ~if option M~init_filter~else~I_~IDT~~endif~
  6804. ;
  6805. ;Input:
  6806. ;    AR7    pointer to FIR filter structure
  6807. ;Output:
  6808. ;    AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
  6809. ;
  6810. ;
  6811. ~if option M~    .globl    I_FILTER
  6812. I_FILTER:
  6813. ~else~    .globl    I_~IDT~
  6814. I_~IDT~:
  6815. ~endif~    
  6816.     LDP    fmema
  6817.     LDI    @fmema,AR0    ;Get address of address of delay memory
  6818.     LDI    *AR0++,AR1    ;Get address of delay memory
  6819.  
  6820.     STI    AR1,*+AR7(3)    ;Put in FIR structure
  6821.     LDF    0.0,R0
  6822.     STF    R0,*+AR7(4)    ;Set zero in FIR structure
  6823.     LDI    taps+1,BK    ;Set block size for circular buffer
  6824.                 ; of x(n)
  6825.     RPTS    taps
  6826.     STF    R0,*AR1++%    ;Zero the delay memory
  6827.     LDI    *AR0++,R0    ;Get address of coef
  6828.     STI    R0,*+AR7(2)    ;Put address of coef. in FIR structure
  6829.     LDI    *AR0++,R0    ;Get address of sample by sample filter routine
  6830.     STI    R0,*+AR7(0)    ;Put in FIR filter structure
  6831.     LDI    *AR0++,R0    ;Get address of array filter routine
  6832.     STI    R0,*+AR7(1)    ;Put in FIR filter structure
  6833.     STI    BK,*+AR7(5)    ;Put BK in FIR structure
  6834.     LDI    taps-3,R0    ;Get number taps for RPTS instruction
  6835.     STI    R0,*+AR7(6)    ;Put in FIR structure
  6836.     LDI    taps-1,R0    ;Get number for RPTS instruction
  6837.     STI    R0,*+AR7(7)    ;Store in FIR filter structure
  6838.  
  6839.     .if coef_ram
  6840.     LDI    *+AR7(2),AR1    ;get address of RAM coef
  6841.     LDI    *AR0++,R0    ;Get first ROM coef
  6842.     RPTS    taps-1
  6843.     LDI    *AR0++,R0
  6844. ||    STI    R0,*AR1++    ;copy ROM coef to RAM coef
  6845.     .endif
  6846.  
  6847.     RETS
  6848.     
  6849.  
  6850. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6851. ;                                                           ;
  6852. ;                      Build constants                      ;
  6853. ;                                                           ;
  6854. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6855.     .globl    FIR_A
  6856.     .globl    FIR_Aa
  6857.  
  6858. fmema:    .word    fmem
  6859. fmem:    .word    delay_m
  6860.     .word    coef_m
  6861.     .word    FIR_A
  6862.     .word    FIR_Aa
  6863.     .if coef_ram = 0
  6864.     .sect    "C_~IDT~"
  6865. coef_m:
  6866.     .endif
  6867. ~do~    .float   ~coeff~     ; ~coef_name~
  6868. ~loop~
  6869.  
  6870. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6871. ;                                                           ;
  6872. ;                Reserve Coefficients Space                 ;
  6873. ;                                                           ;
  6874. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6875.     .if coef_ram
  6876. coef_m    .usect    "C_~IDT~",taps
  6877.     .endif
  6878. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6879. ;                                                           ;
  6880. ;              Reserve Space for Delay Memory               ;
  6881. ;                                                           ;
  6882. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6883.  
  6884. ;The following section must be unique in name and be aligned on
  6885. ;a ~align~ word address boundary.  This can be accomplished with a
  6886. ;LNK30 command file.  CGEN produces an example LNK30 command file
  6887. ;named "LINK.CMD".
  6888.  
  6889. delay_m    .usect    "D_~IDT~",taps+1
  6890.  
  6891.     .end
  6892. ~end~
  6893. >>>>
  6894. >>>
  6895. 2
  6896. 8
  6897. ~
  6898. TMS320C30; ASM30 interface; Size Optimized
  6899. >>>
  6900. ~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6901. ;                                                           ;
  6902. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  6903. ;                                                           ;
  6904. ;               TMS320C30 FIR filter realization            ;
  6905. ;                                                           ;
  6906. ;                    Kaiser Window Design                   ;
  6907. ;                                                           ;
  6908. ;                       Size Optimized                      ;
  6909. ;                                                           ;
  6910. ;                 Assembly Language Interface               ;
  6911. ;                                                           ;
  6912. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6913. ;
  6914. ~filter_file~
  6915.  
  6916.     .copy "model.inc"    ;This include file specifies different
  6917.                 ;memory models and ways of assembling
  6918.                 ;the code.
  6919.  
  6920. ;The following structure defines the data structure that the Init routine
  6921. ;initializes.  This structure is passed, along with x(n) to the filter
  6922. ;routines.
  6923. ;
  6924. ;struct FIR {
  6925. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  6926. ;    void    (*filtera)();    /* pointer to array filter routine */
  6927. ;    float    *coef_mem;    /* pointer to coef. memory */
  6928. ;    float    *delay_mem;    /* pointer to delay memory */
  6929. ;    float    zero;        /* a floating point 0 */
  6930. ;    int    BK_reg;        /* value to be placed in BK register */
  6931. ;    int    frtaps;        /* number of taps for RPTS forward */
  6932. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  6933. ;    };
  6934.  
  6935. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6936. ;                                                           ;
  6937. ;                 FIR Filter Init Routine                   ;
  6938. ;                                                           ;
  6939. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6940.  
  6941.     .text
  6942.  
  6943. FP    .set    AR3
  6944. taps    .set    ~taps~
  6945.  
  6946. ;        INITIALIZE THE FILTER memory and the FIR structure
  6947. ;
  6948. ;Calling sequence:
  6949. ;    CALL    ~if option M~init_filter~else~I_~IDT~~endif~
  6950. ;
  6951. ;Input:
  6952. ;    AR7    pointer to FIR filter structure
  6953. ;Output:
  6954. ;    AR0, AR1, R0, DP, BK, RC, RS, RE destroyed
  6955. ;
  6956. ;
  6957. ~if option M~    .globl    I_FILTER
  6958. I_FILTER:
  6959. ~else~    .globl    I_~IDT~
  6960. I_~IDT~:
  6961. ~endif~    
  6962.     LDP    fmema
  6963.     LDI    @fmema,AR0    ;Get address of address of delay memory
  6964.     LDI    *AR0++,AR1    ;Get address of delay memory
  6965.  
  6966.     STI    AR1,*+AR7(3)    ;Put in FIR structure
  6967.     LDF    0.0,R0
  6968.     STF    R0,*+AR7(4)    ;Set zero in FIR structure
  6969.     LDI    taps+1,BK    ;Set block size for circular buffer
  6970.                 ; of x(n)
  6971.     RPTS    taps
  6972.     STF    R0,*AR1++%    ;Zero the delay memory
  6973.     LDI    *AR0++,R0    ;Get address of coef
  6974.     STI    R0,*+AR7(2)    ;Put address of coef. in FIR structure
  6975.     LDI    *AR0++,R0    ;Get address of sample by sample filter routine
  6976.     STI    R0,*+AR7(0)    ;Put in FIR filter structure
  6977.     LDI    *AR0++,R0    ;Get address of array filter routine
  6978.     STI    R0,*+AR7(1)    ;Put in FIR filter structure
  6979.     STI    BK,*+AR7(5)    ;Put BK in FIR structure
  6980.     LDI    taps~if symetric~/2-2~else~-3~endif~,R0    ;Get number for RPTS instruction
  6981.     STI    R0,*+AR7(6)    ;Put in FIR structure
  6982. ~if symetric~
  6983.     LDI    (taps-1)/2~if asym_odd~-1~endif~~if asym_even~-1~endif~,R0    ;Get number for RPTS instruction
  6984. ~else~
  6985.     LDI    taps-1,R0    ;Get number for RPTS instruction
  6986. ~endif~
  6987.     STI    R0,*+AR7(7)    ;Store in FIR filter structure
  6988.  
  6989.     .if coef_ram
  6990.     LDI    *+AR7(2),AR1    ;get address of RAM coef
  6991.     LDI    *AR0++,R0    ;Get first ROM coef
  6992.     RPTS    ~if symetric~(taps+1)/2~else~taps~endif~-1
  6993.     LDI    *AR0++,R0
  6994. ||    STI    R0,*AR1++    ;copy ROM coef to RAM coef
  6995.     .endif
  6996.  
  6997.     RETS
  6998.     
  6999. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7000. ;                                                           ;
  7001. ;                     Build init data                       ;
  7002. ;                                                           ;
  7003. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7004.  
  7005.     .word    1,fmema            ;init one word at location fmema
  7006. fmema:    .word    fmem            ;address of fmem to be put into fmema
  7007. ~if sym_even~    .globl    FIR_Ase
  7008.     .globl    FIR_Asea
  7009. ~endif~~if sym_odd~    .globl    FIR_Aso
  7010.     .globl    FIR_Asoa
  7011. ~endif~~if asym_even~    .globl    FIR_Aase
  7012.     .globl    FIR_Aasea
  7013. ~endif~~if asym_odd~    .globl    FIR_Aaso
  7014.     .globl    FIR_Aasoa
  7015. ~endif~~if symetric~~else~    .globl    FIR_A
  7016.     .globl    FIR_Aa
  7017. ~endif~
  7018. fmem:    .word    delay_m            ;address of delay memory
  7019.     .word    coef_m            ;address of coef_mem
  7020. ~if sym_even~    .word    FIR_Ase        ;address of sample by sample filter
  7021.     .word    FIR_Asea        ;address of array filter routine
  7022. ~endif~~if sym_odd~    .word    FIR_Aso        ;address of sample by sample filter
  7023.     .word    FIR_Asoa        ;address of array filter routine
  7024. ~endif~~if asym_even~    .word    FIR_Aase        ;address of sample by sample filter
  7025.     .word    FIR_Aasea        ;address of array filter routine
  7026. ~endif~~if asym_odd~    .word    FIR_Aaso        ;address of sample by sample filter
  7027.     .word    FIR_Aasoa        ;address of array filter routine
  7028. ~endif~~if symetric~~else~    .word    FIR_A        ;address of sample by sample filter
  7029.     .word    FIR_Aa            ;address of array filter routine
  7030. ~endif~
  7031.     .if coef_ram = 0
  7032.     .sect    "C_~IDT~"
  7033. coef_m:
  7034.     .endif
  7035. ~if symetric~~do~    .float   ~coeff~     ; ~coef_name~ = ~esign~~coef_nameI~
  7036. ~looph~
  7037. ~else~~do~    .float   ~coeff~     ; ~coef_name~
  7038. ~loop~~endif~
  7039. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7040. ;                                                           ;
  7041. ;                Reserve Coefficients Space                 ;
  7042. ;                                                           ;
  7043. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7044.     .if coef_ram
  7045. coef_m    .usect    "C_~IDT~",~if symetric~(taps+1)/2~else~taps~endif~
  7046.     .endif
  7047. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7048. ;                                                           ;
  7049. ;              Reserve Space for Delay Memory               ;
  7050. ;                                                           ;
  7051. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7052.  
  7053. ;The following section must be unique in name and be aligned on
  7054. ;a ~align~ word address boundary.  This can be accomplished with a
  7055. ;LNK30 command file.  CGEN produces an example LNK30 command file
  7056. ;named "LINK.CMD".
  7057.  
  7058. delay_m    .usect    "D_~IDT~",taps+1
  7059.  
  7060.     .end
  7061. ~status~~end~
  7062. >>>>
  7063. >>>
  7064. 1
  7065. 8
  7066. ~
  7067. TMS320C30; 'C' interface; Optimized Filter Routine
  7068. >>>
  7069. ~set_C~~order_coef~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7070. ;                                                           ;
  7071. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  7072. ;                                                           ;
  7073. ;               TMS320C30 IIR filter realization            ;
  7074. ;                                                           ;
  7075. ;                   'C' compiler interface                  ;
  7076. ;                                                           ;
  7077. ;                    Super Time Optimized                   ;
  7078. ;                                                           ;
  7079. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7080. ;
  7081. ~filter_file~
  7082.  
  7083.     .copy "model.inc"    ;This include file determines the
  7084.                 ;the compiler memory model.  By default
  7085.                 ;it is set to the small model.
  7086.  
  7087. ;The following structure defines the 'C' structure that the Init routine
  7088. ;initializes.  This structure is passed, along with x(n) to the filter
  7089. ;routines.
  7090. ;
  7091. ;struct IIR {
  7092. ;    float *filter;        ;address of sample by sample filter rout.
  7093. ;    float *filtera;        ;address of array filter routine
  7094. ;    float *coef;        ;address of coeficients
  7095. ;    float *delay;        ;address of Z-1 delays
  7096. ;    float BK2;        ;size of circular buffer/2
  7097. ;    int BK;            ;size of circular buffer
  7098. ;    int nRPTB;        ;number for RPTB instruction
  7099. ;       int coef_size        ;size of coef. buffer
  7100. ~if one~~else~
  7101. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7102. ;                                                           ;
  7103. ;                    IIR Filter Routine                     ;
  7104. ;                                                           ;
  7105. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7106.  
  7107. FP    .set    AR3
  7108.  
  7109. ; y(n) = (*param->filter)(x(n),param)
  7110. ;
  7111. ; float filter(xn,param)
  7112. ; float xn;
  7113. ; struct IIR *param;
  7114. ;
  7115.     .global    _F_~IDT~
  7116. _F_~IDT~:
  7117.     .if s_by_s_filter
  7118.     PUSH    FP
  7119.     LDI    SP,FP
  7120.     PUSH    AR7
  7121.  
  7122.     LDI    *-FP(3),AR7    ;address of param -> AR7
  7123.     LDF    *-FP(2),R2    ;Y0(n) = x(n) -> R2
  7124.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  7125.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  7126.     LDI    AR1,AR2        ;Copy into AR2
  7127.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  7128.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  7129.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  7130.  
  7131.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0 (for first sample)
  7132. ~do~;section ~section_n~
  7133. ~if !first~    MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  7134. ~if l_b0=mb2~||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  7135. ~else~||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  7136. ~endif~                ;from last iteration
  7137. ~endif~~if s_b0=b2~;4 cycle section b0=b2
  7138.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7139. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7140.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7141. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7142.     ADDF3    *AR2,R2,R2    ;Z + Z-2 -> R2
  7143. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  7144. ~endif~~if s_b0=mb2~;4 cycle section b0=-b2
  7145.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7146. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7147.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7148. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7149.     SUBF3    R2,*AR2,R2    ;-(Z + Z-2) -> R2
  7150. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  7151. ~endif~~if s_2sa~;9 cycle 2 sections (section a)
  7152.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7153. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7154.     MPYF3    *AR0++,*AR2~if last2s~~else~++%~endif~,R0;B2' * Z-2 -> R0
  7155. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  7156.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7157. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  7158. ~endif~~if s_2sb~;9 cycle 2 sections (section b)
  7159.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7160. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7161.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  7162. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7163.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  7164. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  7165.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7166. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  7167. ~endif~~if s_half~;half section
  7168.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7169. ||    ADDF3    R0,R2,R2    ;Z = A1 * Z-1 + Yi(n) -> R2
  7170. ~if firsthalf~~if l_2sa~    STF    R3,*AR2++%    ;save Z for next sample
  7171. ~endif~~endif~~if lasthalf~~else~    STF    R2,*AR2++%    ;save Z for next sample
  7172. ~endif~~endif~~loop~
  7173.  
  7174. ~if l_b0=mb2~    SUBF    R2,R0        ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  7175. ~else~    ADDF    R2,R0        ;Z + B1' * Z-1 + b2' * Z-2 -> R2
  7176. ~endif~    MPYF3    *+AR0,R0,R0    ;Do final gain compensation
  7177. ~if l_half~||    STF    R2,*AR2++%    ;save Z for next sample
  7178. ~endif~~if l_2sa~||    STF    R3,*AR2++%    ;save Z for next sample
  7179. ~endif~    STI    AR1,*+AR7(3)    ;Update Z-1 address
  7180.  
  7181.     POP    AR7
  7182.     POP    FP
  7183.     RETS
  7184.     .else
  7185.     CALL    @40h        ;Call 40 hex to signal error
  7186.     .endif
  7187. ;        PERFORM ARRAY FILTERING
  7188. ;void (*param->filtera)(xy,xn,n,param)
  7189. ;float *xn, *yn
  7190. ;int n;
  7191. ;struct IIR *param;
  7192. ;
  7193. ; filter returns y(n) for input x(n)
  7194. ; xn and yn are pointers to arrays of size n+1 floats
  7195. ;
  7196. ; the filter routine must be called with x(0) thru x(n)
  7197. ; first then x(n+1) thru x(....) and so on.
  7198.  
  7199.     .global    _F_~IDT~a
  7200. _F_~IDT~a:
  7201.     .if    array_filter
  7202.     PUSH    FP
  7203.     LDI    SP,FP
  7204.     PUSH    AR7
  7205.     PUSH    AR6
  7206.     PUSH    AR5
  7207.     PUSH    AR4
  7208.  
  7209.     LDI    *-FP(2),AR5    ;Get address of y(n)
  7210.     LDI    *-FP(3),AR4    ;Get address of x(n)
  7211.     LDI    *-FP(5),AR7    ;address of param -> AR7
  7212.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  7213.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  7214.     LDI    AR1,AR2        ;Copy into AR2
  7215.     LDI    *-FP(4),RC    ;Get number of samples-1 to filter
  7216.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  7217.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  7218.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  7219.     LDF    *AR4++,R2    ;Get x(n)
  7220.     LDI    *+AR7(7),IR0    ;Get length of coef. buffer-2
  7221.     
  7222.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0 (for first sample)
  7223.  
  7224.     RPTB    loopa        ;do sections
  7225. ~do~;section ~section_n~
  7226. ~if !first~    MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  7227. ~if l_b0=mb2~||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  7228. ~else~||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  7229. ~endif~                ;from last iteration
  7230. ~endif~~if s_b0=b2~;4 cycle section b0=b2
  7231.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7232. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7233.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7234. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7235.     ADDF3    *AR2,R2,R2    ;Z + Z-2 -> R2
  7236. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  7237. ~endif~~if s_b0=mb2~;4 cycle section b0=-b2
  7238.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7239. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7240.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7241. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7242.     SUBF3    R2,*AR2,R2    ;-(Z + Z-2) -> R2
  7243. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  7244. ~endif~~if s_2sa~;9 cycle 2 sections (section a)
  7245.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7246. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7247.     MPYF3    *AR0++,*AR2~if last2s~~else~++%~endif~,R0;B2' * Z-2 -> R0
  7248. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  7249.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7250. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  7251. ~endif~~if s_2sb~;9 cycle 2 sections (section b)
  7252.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7253. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7254.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  7255. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7256.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  7257. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  7258.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7259. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  7260. ~endif~~if s_half~;half section
  7261.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7262. ||    ADDF3    R0,R2,~if lasthalf~R3~else~R2~endif~    ;Z = A1 * Z-1 + Yi(n) -> R2
  7263. ~if firsthalf~~if l_2sa~    STF    R3,*AR2++%    ;save Z for next sample
  7264. ~endif~~endif~~if lasthalf~~else~    STF    R2,*AR2++%    ;save Z for next sample
  7265. ~endif~~endif~~loop~
  7266.  
  7267.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0 (for next sample)
  7268. ~if l_b0=mb2~||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 + B1' * Z-2 -> R2
  7269. ~else~||    ADDF3    R0,~if l_half~R3~else~R2~endif~,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  7270. ~endif~    MPYF3    *AR0--(IR0),R2,R1;Do final gain compensation
  7271. ~if l_half~||    STF    R3,*AR2++%    ;save Z for next sample
  7272. ~endif~~if l_2sa~||    STF    R3,*AR2++%    ;save Z for next sample
  7273. ~endif~loopa    LDF    *AR4++,R2    ;Get y0(n+1) = x(n+1) -> R2
  7274. ||    STF    R1,*AR5++    ;Output filtered data to array
  7275.  
  7276.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  7277.  
  7278.     POP    AR4
  7279.     POP    AR5
  7280.     POP    AR6
  7281.     POP    AR7
  7282.     POP    FP
  7283.     RETS
  7284.     .else
  7285.     CALL    @40h        ;Call 40 hex to signal error
  7286.     .endif
  7287. ~endif~
  7288. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7289. ;                                                           ;
  7290. ;                 IIR Filter Init Routine                   ;
  7291. ;                                                           ;
  7292. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7293.  
  7294.     .text
  7295.  
  7296. sects    .set    ~sects~
  7297.  
  7298. ;        INITIALIZE THE FILTER memory and the IIR structure
  7299. ;
  7300. ;struct IIR initf()
  7301. ;
  7302. ;Calling sequence from 'C':
  7303. ;
  7304. ;    IIR = ~if option M~init_filter~else~I_~IDT~~endif~();
  7305. ;
  7306. ;      where IIR is a structure as defined above.
  7307. ;
  7308. ~if option M~    .globl    _I_FILTER
  7309. _I_FILTER:
  7310. ~else~    .globl    _I_~IDT~
  7311. _I_~IDT~:
  7312. ~endif~    
  7313.     .if    large_model
  7314.     LDP    fmema
  7315.     .endif
  7316.     LDI    @fmema,AR2    ;Get address of init memory
  7317.     LDI    *AR2++,AR1    ;Get address of delay memory Z-1
  7318.     STI    AR1,*+AR0(3)    ;Put in IIR structure
  7319.     
  7320.     LDF    0.0,R0
  7321.     RPTS    sects*2-1
  7322.     STF    R0,*AR1++    ;Zero the delay memory
  7323.  
  7324.     LDI    sects,R0    ;Get size of circular buffer/2
  7325.     STI    R0,*+AR0(4)    ;Put in IIR filter structure
  7326.     LDI    sects*2,R0    ;Get size of circular buffer
  7327.     STI    R0,*+AR0(5)    ;Put in IIR filter structure
  7328.     LDI    *AR2++,R0    ;Get address of coef.
  7329.     STI    R0,*+AR0(2)    ;Put address of coef. in IIR structure
  7330.     LDI    *AR2++,R0    ;Get address of sample by sample filter routine
  7331.     STI    R0,*+AR0(0)    ;Put in IIR filter structure
  7332.     LDI    *AR2++,R0    ;Get address of array filter routine
  7333.     STI    R0,*+AR0(1)    ;Put in IIR filter structure
  7334. ~if one~~else~    LDI    ~c_size~-2,R0        ;Get size of coef. buffer-2
  7335.     STI    R0,*+AR0(7)    ;Put in IIR filter structure
  7336. ~endif~    RETS
  7337.  
  7338. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7339. ;                                                           ;
  7340. ;              Build .bss and .cinit sections               ;
  7341. ;                                                           ;
  7342. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7343.  
  7344. ; The .cinit section exists to provide initialization data
  7345. ; for the .bss section.  The .bss section is where 'C'
  7346. ; keeps all of its static and global storage.
  7347.  
  7348.     .globl    ~if one~_IIR_C5~else~_F_~IDT~~endif~
  7349.     .globl    ~if one~_IIR_C5~else~_F_~IDT~~endif~a
  7350.  
  7351.     .sect    ".cinit"
  7352.     .word    1,fmema        ;init one word at location fmema
  7353.     .word    fmem        ;address of fmem to be put into fmema
  7354.     .bss    fmema,1        ;reserve fmema in .bss
  7355.  
  7356.     .word    4,fmem
  7357.     .word    delay_m        ;address of delay memory1
  7358.     .word    coef_m        ;address of coef_mem
  7359.     .word    ~if one~_IIR_C5~else~_F_~IDT~~endif~        ;address of sample by sample filter
  7360.     .word    ~if one~_IIR_C5~else~_F_~IDT~~endif~a    ;address of array filter
  7361.     .bss    fmem,4
  7362.  
  7363.     .if coef_ram
  7364.     .word    ~if one~5~else~~c_size~~endif~,coef_m
  7365.     .else
  7366.     .sect "coef"
  7367. coef_m:
  7368.     .endif
  7369. ~if one~~do~;    section 1
  7370.     .float    ~A1~    ;a1
  7371.     .float    ~A2~    ;a2
  7372.     .float    ~B2~    ;b2
  7373.     .float    ~B0~    ;b0
  7374.     .float    ~B1~    ;b1
  7375. ~else~~do~~if s_b0=+-b2~    ;section ~section_n~
  7376.     .float    ~A1~    ;a1
  7377.     .float    ~A2~    ;a2
  7378.     .float    ~B1'~    ;b1'
  7379. ~else~~if s_half~;    section ~section_n~
  7380.     .float    ~A1~    ;a1
  7381.     .float    ~B1'~    ;b1'
  7382. ~else~;    section ~section_n~
  7383.     .float    ~A1~    ;a1
  7384.     .float    ~A2~    ;a2
  7385.     .float    ~B2'~    ;b2'
  7386.     .float    ~B1'~    ;b1'
  7387. ~endif~~endif~~loop~
  7388.     .float    ~A11~    ;a1 of section 1
  7389.  
  7390.     .float    ~gain~    ;final gain
  7391. ~endif~
  7392.  
  7393. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7394. ;                                                           ;
  7395. ;              Reserve Space for Coefficients               ;
  7396. ;                                                           ;
  7397. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7398.     .if coef_ram
  7399. coef_m    .usect    "C_~IDT~",~if one~5~else~~c_size~~endif~
  7400.     .endif
  7401. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7402. ;                                                           ;
  7403. ;              Reserve Space for Delay Memory               ;
  7404. ;                                                           ;
  7405. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7406.  
  7407. ;The following section must be unique in name and be aligned on
  7408. ;a ~align~ word address boundary.  This can be accomplished with a
  7409. ;LNK30 command file.  CGEN produces an example LNK30 command file
  7410. ;named "LINK.CMD".
  7411.  
  7412. delay_m    .usect    "D_~IDT~",sects*2
  7413.  
  7414.     .end
  7415. ~end~
  7416. >>>>
  7417. >>>
  7418. 1
  7419. 8
  7420. ~
  7421. TMS320C30; 'C' interface
  7422. >>>
  7423. ~set_C~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7424. ;                                                           ;
  7425. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  7426. ;                                                           ;
  7427. ;               TMS320C30 IIR filter realization            ;
  7428. ;                                                           ;
  7429. ;                   'C' compiler interface                  ;
  7430. ;                                                           ;
  7431. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7432. ;
  7433. ~filter_file~
  7434.  
  7435.     .copy "model.inc"    ;This include file determines the
  7436.                 ;the compiler memory model.  By default
  7437.                 ;it is set to the small model.
  7438.  
  7439. ;The following structure defines the 'C' structure that the Init routine
  7440. ;initializes.  This structure is passed, along with x(n) to the filter
  7441. ;routines.
  7442. ;
  7443. ;struct IIR {
  7444. ;    float *filter;        ;address of sample by sample filter rout.
  7445. ;    float *filtera;        ;address of array filter routine
  7446. ;    float *coef;        ;address of coeficients
  7447. ;    float *delay;        ;address of Z-1 delays
  7448. ;    float BK2;        ;size of circular buffer/2
  7449. ;    int BK;            ;size of circular buffer
  7450. ;    int nRPTB;        ;number for RPTB instruction
  7451. ;       int coef_size        ;size of coef. buffer
  7452.  
  7453. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7454. ;                                                           ;
  7455. ;                 IIR Filter Init Routine                   ;
  7456. ;                                                           ;
  7457. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7458.  
  7459.     .text
  7460.  
  7461. FP    .set    AR3
  7462. sects    .set    ~sects~
  7463.  
  7464. ;        INITIALIZE THE FILTER memory and the IIR structure
  7465. ;
  7466. ;struct IIR initf()
  7467. ;
  7468. ;Calling sequence from 'C':
  7469. ;
  7470. ;    IIR = ~if option M~init_filter~else~I_~IDT~~endif~();
  7471. ;
  7472. ;      where IIR is a structure as defined above.
  7473. ;
  7474. ~if option M~    .globl    _I_FILTER
  7475. _I_FILTER:
  7476. ~else~    .globl    _I_~IDT~
  7477. _I_~IDT~:
  7478. ~endif~    
  7479.     .if    large_model
  7480.     LDP    fmema
  7481.     .endif
  7482.     LDI    @fmema,AR2    ;Get address of init memory
  7483.     LDI    *AR2++,AR1    ;Get address of delay memory Z-1
  7484.     STI    AR1,*+AR0(3)    ;Put in IIR structure
  7485.     
  7486.     LDF    0.0,R0
  7487.     RPTS    sects*2-1
  7488.     STF    R0,*AR1++    ;Zero the delay memory
  7489.  
  7490.     LDI    ~if one~sects-1~else~~if b0=+-b2~sects-1~else~(sects/2)-1~endif~~endif~,R0    ;Get number for RPTS instruction
  7491.     STI    R0,*+AR0(6)    ;Store in IIR filter structure
  7492.     LDI    sects,R0    ;Get size of circular buffer/2
  7493.     STI    R0,*+AR0(4)    ;Put in IIR filter structure
  7494.     LDI    sects*2,R0    ;Get size of circular buffer
  7495.     STI    R0,*+AR0(5)    ;Put in IIR filter structure
  7496.     LDI    *AR2++,R0    ;Get address of coef.
  7497.     STI    R0,*+AR0(2)    ;Put address of coef. in IIR structure
  7498.     LDI    *AR2++,R0    ;Get address of sample by sample filter routine
  7499.     STI    R0,*+AR0(0)    ;Put in IIR filter structure
  7500.     LDI    *AR2++,R0    ;Get address of array filter routine
  7501.     STI    R0,*+AR0(1)    ;Put in IIR filter structure
  7502.     LDI    sects*~if one~5-2~else~~if b0=+-b2~3~else~4~endif~~endif~,R0    ;Get size of coef. buffer-2
  7503.     STI    R0,*+AR0(7)    ;Put in IIR filter structure
  7504.     RETS
  7505.  
  7506. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7507. ;                                                           ;
  7508. ;              Build .bss and .cinit sections               ;
  7509. ;                                                           ;
  7510. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7511.  
  7512. ; The .cinit section exists to provide initialization data
  7513. ; for the .bss section.  The .bss section is where 'C'
  7514. ; keeps all of its static and global storage.
  7515.  
  7516.     .globl    _IIR_C~if one~5~else~~if b0=+-b2~4~if b0=-b2~m~endif~~else~45~if odd~o~endif~~endif~~endif~
  7517.     .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
  7518.  
  7519.     .sect    ".cinit"
  7520.     .word    1,fmema        ;init one word at location fmema
  7521.     .word    fmem        ;address of fmem to be put into fmema
  7522.     .bss    fmema,1        ;reserve fmema in .bss
  7523.  
  7524.     .word    4,fmem
  7525.     .word    delay_m        ;address of delay memory1
  7526.     .word    coef_m        ;address of coef_mem
  7527.     .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
  7528.     .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
  7529.     .bss    fmem,4
  7530.  
  7531.     .if coef_ram
  7532.     .word    ~if one~sects*5~else~~if b0=+-b2~sects*3+2~else~sects*4+2~endif~~endif~,coef_m
  7533.     .else
  7534.     .sect "coef"
  7535. coef_m:
  7536.     .endif
  7537. ~if one~~do~;    section 1
  7538.     .float    ~A1~    ;a1
  7539.     .float    ~A2~    ;a2
  7540.     .float    ~B2~    ;b2
  7541.     .float    ~B0~    ;b0
  7542.     .float    ~B1~    ;b1
  7543. ~else~~if b0=+-b2~~do~    ;section ~section_n~
  7544.     .float    ~A1~    ;a1
  7545.     .float    ~A2~    ;a2
  7546.     .float    ~B1'~    ;b1'
  7547. ~loop~
  7548.     .float    ~A11~    ;a1 of section 1
  7549.  
  7550.     .float    ~gain~    ;final gain
  7551. ~else~~do~;    section ~section_n~
  7552.     .float    ~A1~    ;a1
  7553.     .float    ~A2~    ;a2
  7554.     .float    ~B2'~    ;b2'
  7555.     .float    ~B1'~    ;b1'
  7556. ~loop~
  7557.     .float    ~A11~    ;a1 of section 1
  7558.  
  7559.     .float    ~gain~    ;final gain
  7560. ~endif~~endif~
  7561.  
  7562. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7563. ;                                                           ;
  7564. ;              Reserve Space for Coefficients               ;
  7565. ;                                                           ;
  7566. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7567.     .if coef_ram
  7568. coef_m    .usect    "C_~IDT~",~if one~sects*5~else~~if b0=+-b2~sects*3+2~else~sects*4+2~endif~~endif~
  7569.     .endif
  7570. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7571. ;                                                           ;
  7572. ;              Reserve Space for Delay Memory               ;
  7573. ;                                                           ;
  7574. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7575.  
  7576. ;The following section must be unique in name and be aligned on
  7577. ;a ~align~ word address boundary.  This can be accomplished with a
  7578. ;LNK30 command file.  CGEN produces an example LNK30 command file
  7579. ;named "LINK.CMD".
  7580.  
  7581. delay_m    .usect    "D_~IDT~",sects*2
  7582.  
  7583.     .end
  7584. ~end~
  7585. >>>>
  7586. >>>
  7587. 1
  7588. 8
  7589. ~
  7590. TMS320C30; ASM30 interface; Optimized Filter Routine
  7591. >>>
  7592. ~order_coef~~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7593. ;                                                           ;
  7594. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  7595. ;                                                           ;
  7596. ;               TMS320C30 IIR filter realization            ;
  7597. ;                                                           ;
  7598. ;                 Assembly Language Interface               ;
  7599. ;                                                           ;
  7600. ;                    Super Time Optimized                   ;
  7601. ;                                                           ;
  7602. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7603. ;
  7604. ~filter_file~
  7605.  
  7606.     .copy "model.inc"    ;This include file specifies different
  7607.                 ;memory models and ways of assembling
  7608.                 ;the code.
  7609.  
  7610. ;The following structure defines the data structure that the Init routine
  7611. ;initializes.  This structure is passed, along with x(n) to the filter
  7612. ;routines.
  7613. ;
  7614. ;struct IIR {
  7615. ;    float *filter;        ;address of sample by sample filter rout.
  7616. ;    float *filtera;        ;address of array filter routine
  7617. ;    float *coef;        ;address of coeficients
  7618. ;    float *delay;        ;address of Z-1 delays
  7619. ;    float BK2;        ;size of circular buffer/2
  7620. ;    int BK;            ;size of circular buffer
  7621. ;    int nRPTB;        ;number for RPTB instruction
  7622. ;       int coef_size        ;size of coef. buffer
  7623. ~if one~~else~
  7624. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7625. ;                                                           ;
  7626. ;                    IIR Filter Routine                     ;
  7627. ;                                                           ;
  7628. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7629.  
  7630.  
  7631. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  7632. ;Input:
  7633. ;    R0    x(n)
  7634. ;    AR7    pointer to FIR filter structure
  7635. ;Ouput:
  7636. ;    R0    y(n)
  7637. ;    R2, AR0, AR1, AR2, BK, RC, RS, RE destroyed
  7638.  
  7639.     .global    _F_~IDT~
  7640. _F_~IDT~:
  7641.     .if s_by_s_filter
  7642.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  7643.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  7644.     LDI    AR1,AR2        ;Copy into AR2
  7645.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  7646.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  7647.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  7648.  
  7649.     MPYF3    *AR0++,*AR1,R2    ;A1 * Z-1 -> R0 (for first sample)
  7650. ~do~;section ~section_n~
  7651. ~if !first~    MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  7652. ~if l_b0=mb2~||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  7653. ~else~||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  7654. ~endif~                ;from last iteration
  7655. ~endif~~if s_b0=b2~;4 cycle section b0=b2
  7656.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7657. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7658.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7659. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7660.     ADDF3    *AR2,R2,R2    ;Z + Z-2 -> R2
  7661. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  7662. ~endif~~if s_b0=mb2~;4 cycle section b0=-b2
  7663.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7664. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7665.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7666. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7667.     SUBF3    R2,*AR2,R2    ;-(Z + Z-2) -> R2
  7668. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  7669. ~endif~~if s_2sa~;9 cycle 2 sections (section a)
  7670.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7671. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7672.     MPYF3    *AR0++,*AR2~if last2s~~else~++%~endif~,R0;B2' * Z-2 -> R0
  7673. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  7674.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7675. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  7676. ~endif~~if s_2sb~;9 cycle 2 sections (section b)
  7677.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7678. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7679.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  7680. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7681.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  7682. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  7683.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7684. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  7685. ~endif~~if s_half~;half section
  7686.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7687. ||    ADDF3    R0,R2,R2    ;Z = A1 * Z-1 + Yi(n) -> R2
  7688. ~if firsthalf~~if l_2sa~    STF    R3,*AR2++%    ;save Z for next sample
  7689. ~endif~~endif~~if lasthalf~~else~    STF    R2,*AR2++%    ;save Z for next sample
  7690. ~endif~~endif~~loop~
  7691.  
  7692. ~if l_b0=mb2~    SUBF    R2,R0        ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  7693. ~else~    ADDF    R2,R0        ;Z + B1' * Z-1 + b2' * Z-2 -> R2
  7694. ~endif~    MPYF3    *+AR0,R0,R0    ;Do final gain compensation
  7695. ~if l_half~||    STF    R2,*AR2++%    ;save Z for next sample
  7696. ~endif~~if l_2sa~||    STF    R3,*AR2++%    ;save Z for next sample
  7697. ~endif~    STI    AR1,*+AR7(3)    ;Update Z-1 address
  7698.  
  7699.     RETS
  7700.     .else
  7701.     CALL    @40h        ;Call location 40 hex to signal error
  7702.     .endif
  7703.  
  7704. ;        PERFORM ARRAY FILTERING
  7705. ;Input:
  7706. ;    AR4    address of x(n) array
  7707. ;    AR5    address of y(n) array
  7708. ;    AR6    number of samples-1 in array
  7709. ;    AR7    address of FIR filter structure
  7710. ;Output:
  7711. ;    AR(0-2), AR(4-6), R(0-3), IR0, BK, RC, RS, RE, DP destroyed
  7712.  
  7713.     .global    _F_~IDT~a
  7714. _F_~IDT~a:
  7715.     .if    array_filter
  7716.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  7717.     LDI    AR1,AR2        ;Copy into AR2
  7718.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  7719.     LDI    AR6,RC        ;Get number of samples-1 to filter
  7720.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  7721.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  7722.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  7723.     LDF    *AR4++,R2    ;Get x(n)
  7724.     LDI    *+AR7(7),IR0    ;Get length of coef. buffer-2
  7725.     
  7726.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0 (for first sample)
  7727.  
  7728.     RPTB    loopa        ;do sections
  7729. ~do~;section ~section_n~
  7730. ~if !first~    MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  7731. ~if l_b0=mb2~||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  7732. ~else~||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  7733. ~endif~                ;from last iteration
  7734. ~endif~~if s_b0=b2~;4 cycle section b0=b2
  7735.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7736. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7737.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7738. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7739.     ADDF3    *AR2,R2,R2    ;Z + Z-2 -> R2
  7740. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  7741. ~endif~~if s_b0=mb2~;4 cycle section b0=-b2
  7742.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7743. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7744.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7745. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7746.     SUBF3    R2,*AR2,R2    ;-(Z + Z-2) -> R2
  7747. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  7748. ~endif~~if s_2sa~;9 cycle 2 sections (section a)
  7749.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7750. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7751.     MPYF3    *AR0++,*AR2~if last2s~~else~++%~endif~,R0;B2' * Z-2 -> R0
  7752. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  7753.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7754. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  7755. ~endif~~if s_2sb~;9 cycle 2 sections (section b)
  7756.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  7757. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  7758.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  7759. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  7760.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  7761. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  7762.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7763. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  7764. ~endif~~if s_half~;half section
  7765.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  7766. ||    ADDF3    R0,R2,~if lasthalf~R3~else~R2~endif~    ;Z = A1 * Z-1 + Yi(n) -> R2
  7767. ~if firsthalf~~if l_2sa~    STF    R3,*AR2++%    ;save Z for next sample
  7768. ~endif~~endif~~if lasthalf~~else~    STF    R2,*AR2++%    ;save Z for next sample
  7769. ~endif~~endif~~loop~
  7770.  
  7771.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0 (for next sample)
  7772. ~if l_b0=mb2~||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 + B1' * Z-2 -> R2
  7773. ~else~||    ADDF3    R0,~if l_half~R3~else~R2~endif~,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  7774. ~endif~    MPYF3    *AR0--(IR0),R2,R1;Do final gain compensation
  7775. ~if l_half~||    STF    R3,*AR2++%    ;save Z for next sample
  7776. ~endif~~if l_2sa~||    STF    R3,*AR2++%    ;save Z for next sample
  7777. ~endif~loopa    LDF    *AR4++,R2    ;Get y0(n+1) = x(n+1) -> R2
  7778. ||    STF    R1,*AR5++    ;Output filtered data to array
  7779.  
  7780.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  7781.  
  7782.     RETS
  7783.     .else
  7784.     CALL    @40h        ;Call location 40 hex to signal error
  7785.     .endif
  7786. ~endif~
  7787. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7788. ;                                                           ;
  7789. ;                 IIR Filter Init Routine                   ;
  7790. ;                                                           ;
  7791. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7792.  
  7793.     .text
  7794.  
  7795. sects    .set    ~sects~
  7796.  
  7797. ;        INITIALIZE THE FILTER memory and the FIR structure
  7798. ;
  7799. ;Calling sequence:
  7800. ;    CALL    ~if option M~init_filter~else~I_~IDT~~endif~
  7801. ;
  7802. ;Input:
  7803. ;    AR7    pointer to FIR filter structure
  7804. ;Output:
  7805. ;    AR1, AR2, R0, DP, BK, RC, RS, RE destroyed
  7806. ;
  7807. ;
  7808. ~if option M~    .globl    I_FILTER
  7809. I_FILTER:
  7810. ~else~    .globl    I_~IDT~
  7811. I_~IDT~:
  7812. ~endif~    
  7813.     LDP    fmema
  7814.     LDI    @fmema,AR2    ;Get address of init memory
  7815.     LDI    *AR2++,AR1    ;Get address of delay memory Z-1
  7816.     STI    AR1,*+AR7(3)    ;Put in IIR structure
  7817.     
  7818.     LDF    0.0,R0
  7819.     RPTS    sects*2-1
  7820.     STF    R0,*AR1++    ;Zero the delay memory
  7821.  
  7822.     LDI    sects,R0    ;Get size of circular buffer/2
  7823.     STI    R0,*+AR7(4)    ;Put in IIR filter structure
  7824.     LDI    sects*2,R0    ;Get size of circular buffer
  7825.     STI    R0,*+AR7(5)    ;Put in IIR filter structure
  7826.     LDI    *AR2++,R0    ;Get address of coef.
  7827.     STI    R0,*+AR7(2)    ;Put address of coef. in IIR structure
  7828.     LDI    *AR2++,R0    ;Get address of sample by sample filter routine
  7829.     STI    R0,*+AR7(0)    ;Put in IIR filter structure
  7830.     LDI    *AR2++,R0    ;Get address of array filter routine
  7831.     STI    R0,*+AR7(1)    ;Put in IIR filter structure
  7832. ~if one~~else~    LDI    ~c_size~-2,R0        ;Get size of coef. buffer-2
  7833.     STI    R0,*+AR7(7)    ;Put in IIR filter structure
  7834. ~endif~
  7835.     .if coef_ram
  7836.     LDI    *+AR7(2),AR1    ;get address of RAM coef
  7837.     LDI    *AR2++,R0    ;Get first ROM coef
  7838.     RPTS    ~if one~4~else~~c_size~-1~endif~
  7839.     LDI    *AR2++,R0
  7840. ||    STI    R0,*AR1++    ;copy ROM coef to RAM coef
  7841.     .endif
  7842.  
  7843.     RETS
  7844.  
  7845. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7846. ;                                                           ;
  7847. ;              Build Constant Data                          ;
  7848. ;                                                           ;
  7849. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7850.  
  7851.     .globl    ~if one~IIR_A5~else~_F_~IDT~~endif~        ;address of sample by sample filter
  7852.     .globl    ~if one~IIR_A5~else~_F_~IDT~~endif~a    ;address of array filter
  7853.  
  7854. fmema:    .word    fmem        ;address of fmem to be put into fmema
  7855.  
  7856. fmem:    .word    delay_m        ;address of delay memory1
  7857.     .word    coef_m        ;address of coef_mem
  7858.     .word    ~if one~IIR_A5~else~_F_~IDT~~endif~        ;address of sample by sample filter
  7859.     .word    ~if one~IIR_A5~else~_F_~IDT~~endif~a    ;address of array filter
  7860.  
  7861.     .if coef_ram = 0
  7862.     .sect "coef"
  7863. coef_m:
  7864.     .endif
  7865. ~if one~~do~;    section 1
  7866.     .float    ~A1~    ;a1
  7867.     .float    ~A2~    ;a2
  7868.     .float    ~B2~    ;b2
  7869.     .float    ~B0~    ;b0
  7870.     .float    ~B1~    ;b1
  7871. ~else~~do~~if s_b0=+-b2~    ;section ~section_n~
  7872.     .float    ~A1~    ;a1
  7873.     .float    ~A2~    ;a2
  7874.     .float    ~B1'~    ;b1'
  7875. ~else~~if s_half~;    section ~section_n~
  7876.     .float    ~A1~    ;a1
  7877.     .float    ~B1'~    ;b1'
  7878. ~else~;    section ~section_n~
  7879.     .float    ~A1~    ;a1
  7880.     .float    ~A2~    ;a2
  7881.     .float    ~B2'~    ;b2'
  7882.     .float    ~B1'~    ;b1'
  7883. ~endif~~endif~~loop~
  7884.     .float    ~A11~    ;a1 of section 1
  7885.  
  7886.     .float    ~gain~    ;final gain
  7887. ~endif~
  7888.  
  7889. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7890. ;                                                           ;
  7891. ;              Reserve Space for Coefficients               ;
  7892. ;                                                           ;
  7893. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7894.     .if coef_ram
  7895. coef_m    .usect    "C_~IDT~",~if one~5~else~~c_size~~endif~
  7896.     .endif
  7897. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7898. ;                                                           ;
  7899. ;              Reserve Space for Delay Memory               ;
  7900. ;                                                           ;
  7901. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7902.  
  7903. ;The following section must be unique in name and be aligned on
  7904. ;a ~align~ word address boundary.  This can be accomplished with a
  7905. ;LNK30 command file.  CGEN produces an example LNK30 command file
  7906. ;named "LINK.CMD".
  7907.  
  7908. delay_m    .usect    "D_~IDT~",sects*2
  7909.  
  7910.     .end
  7911. ~end~
  7912. >>>>
  7913. >>>
  7914. 1
  7915. 8
  7916. ~
  7917. TMS320C30; ASM30 interface
  7918. >>>
  7919. ~batch_files~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7920. ;                                                           ;
  7921. ;               ATLANTA SIGNAL PROCESSORS, INC.             ;
  7922. ;                                                           ;
  7923. ;               TMS320C30 IIR filter realization            ;
  7924. ;                                                           ;
  7925. ;                 Assembly Language Interface               ;
  7926. ;                                                           ;
  7927. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7928. ;
  7929. ~filter_file~
  7930.  
  7931.     .copy "model.inc"    ;This include file specifies different
  7932.                 ;memory models and ways of assembling
  7933.                 ;the code.
  7934.  
  7935. ;The following structure defines the data structure that the Init routine
  7936. ;initializes.  This structure is passed, along with x(n) to the filter
  7937. ;routines.
  7938. ;
  7939. ;struct IIR {
  7940. ;    float *filter;        ;address of sample by sample filter rout.
  7941. ;    float *filtera;        ;address of array filter routine
  7942. ;    float *coef;        ;address of coeficients
  7943. ;    float *delay;        ;address of Z-1 delays
  7944. ;    float BK2;        ;size of circular buffer/2
  7945. ;    int BK;            ;size of circular buffer
  7946. ;    int nRPTB;        ;number for RPTB instruction
  7947. ;       int coef_size        ;size of coef. buffer
  7948.  
  7949. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7950. ;                                                           ;
  7951. ;                 IIR Filter Init Routine                   ;
  7952. ;                                                           ;
  7953. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7954.  
  7955.     .text
  7956.  
  7957. sects    .set    ~sects~
  7958.  
  7959. ;        INITIALIZE THE FILTER memory and the FIR structure
  7960. ;
  7961. ;Calling sequence:
  7962. ;    CALL    ~if option M~init_filter~else~I_~IDT~~endif~
  7963. ;
  7964. ;Input:
  7965. ;    AR7    pointer to FIR filter structure
  7966. ;Output:
  7967. ;    AR1, AR2, R0, DP, BK, RC, RS, RE destroyed
  7968. ;
  7969. ;
  7970. ~if option M~    .globl    I_FILTER
  7971. I_FILTER:
  7972. ~else~    .globl    I_~IDT~
  7973. I_~IDT~:
  7974. ~endif~    
  7975.     LDP    fmema
  7976.     LDI    @fmema,AR2    ;Get address of init memory
  7977.     LDI    *AR2++,AR1    ;Get address of delay memory Z-1
  7978.     STI    AR1,*+AR7(3)    ;Put in IIR structure
  7979.     
  7980.     LDF    0.0,R0
  7981.     RPTS    sects*2-1
  7982.     STF    R0,*AR1++    ;Zero the delay memory
  7983.  
  7984.     LDI    ~if one~sects-1~else~~if b0=+-b2~sects-1~else~(sects/2)-1~endif~~endif~,R0    ;Get number for RPTS instruction
  7985.     STI    R0,*+AR7(6)    ;Store in IIR filter structure
  7986.     LDI    sects,R0    ;Get size of circular buffer/2
  7987.     STI    R0,*+AR7(4)    ;Put in IIR filter structure
  7988.     LDI    sects*2,R0    ;Get size of circular buffer
  7989.     STI    R0,*+AR7(5)    ;Put in IIR filter structure
  7990.     LDI    *AR2++,R0    ;Get address of coef.
  7991.     STI    R0,*+AR7(2)    ;Put address of coef. in IIR structure
  7992.     LDI    *AR2++,R0    ;Get address of sample by sample filter routine
  7993.     STI    R0,*+AR7(0)    ;Put in IIR filter structure
  7994.     LDI    *AR2++,R0    ;Get address of array filter routine
  7995.     STI    R0,*+AR7(1)    ;Put in IIR filter structure
  7996.     LDI    sects*~if one~5-2~else~~if b0=+-b2~3~else~4~endif~~endif~,R0    ;Get size of coef. buffer-2
  7997.     STI    R0,*+AR7(7)    ;Put in IIR filter structure
  7998.  
  7999.     .if coef_ram
  8000.     LDI    *+AR7(2),AR1    ;get address of RAM coef
  8001.     LDI    *AR2++,R0    ;Get first ROM coef
  8002.     RPTS    ~if one~sects*5~else~~if b0=+-b2~sects*3+2~else~sects*4+2~endif~~endif~-1
  8003.     LDI    *AR2++,R0
  8004. ||    STI    R0,*AR1++    ;copy ROM coef to RAM coef
  8005.     .endif
  8006.  
  8007.     RETS
  8008.  
  8009. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8010. ;                                                           ;
  8011. ;              Build Constant Data                          ;
  8012. ;                                                           ;
  8013. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8014.  
  8015.     .globl    IIR_A~if one~5~else~~if b0=+-b2~4~if b0=-b2~m~endif~~else~45~if odd~o~endif~~endif~~endif~
  8016.     .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
  8017.  
  8018. fmema:    .word    fmem        ;address of fmem to be put into fmema
  8019.  
  8020. fmem:    .word    delay_m        ;address of delay memory1
  8021.     .word    coef_m        ;address of coef_mem
  8022.     .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
  8023.     .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
  8024.  
  8025.     .if coef_ram = 0
  8026.     .sect "coef"
  8027. coef_m:
  8028.     .endif
  8029. ~if one~~do~;    section 1
  8030.     .float    ~A1~    ;a1
  8031.     .float    ~A2~    ;a2
  8032.     .float    ~B2~    ;b2
  8033.     .float    ~B0~    ;b0
  8034.     .float    ~B1~    ;b1
  8035. ~else~~if b0=+-b2~~do~    ;section ~section_n~
  8036.     .float    ~A1~    ;a1
  8037.     .float    ~A2~    ;a2
  8038.     .float    ~B1'~    ;b1'
  8039. ~loop~
  8040.     .float    ~A11~    ;a1 of section 1
  8041.  
  8042.     .float    ~gain~    ;final gain
  8043. ~else~~do~;    section ~section_n~
  8044.     .float    ~A1~    ;a1
  8045.     .float    ~A2~    ;a2
  8046.     .float    ~B2'~    ;b2'
  8047.     .float    ~B1'~    ;b1'
  8048. ~loop~
  8049.     .float    ~A11~    ;a1 of section 1
  8050.  
  8051.     .float    ~gain~    ;final gain
  8052. ~endif~~endif~
  8053.  
  8054. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8055. ;                                                           ;
  8056. ;              Reserve Space for Coefficients               ;
  8057. ;                                                           ;
  8058. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8059.     .if coef_ram
  8060. coef_m    .usect    "C_~IDT~",~if one~sects*5~else~~if b0=+-b2~sects*3+2~else~sects*4+2~endif~~endif~
  8061.     .endif
  8062. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8063. ;                                                           ;
  8064. ;              Reserve Space for Delay Memory               ;
  8065. ;                                                           ;
  8066. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8067.  
  8068. ;The following section must be unique in name and be aligned on
  8069. ;a ~align~ word address boundary.  This can be accomplished with a
  8070. ;LNK30 command file.  CGEN produces an example LNK30 command file
  8071. ;named "LINK.CMD".
  8072.  
  8073. delay_m    .usect    "D_~IDT~",sects*2
  8074.  
  8075.     .end
  8076. ~end~
  8077. >>>>
  8078.