home *** CD-ROM | disk | FTP | other *** search
/ Peanuts NeXT Software Archives / Peanuts-2.iso / Developer / hardware / dsp / drbub / lms.help < prev    next >
Encoding:
Text File  |  1991-09-07  |  5.7 KB  |  150 lines

  1. This file came from Motorola's Dr. BuB DSP board.
  2.  
  3. LMS ADAPTIVE FILTER
  4.  
  5.  
  6.                   x(0) |----| x(n-1)|----| x(n-2)|----| x(n-3)
  7.      x(n) -------------| 1/z|-------| 1/z|-------| 1/z|----
  8.                    |   |----|   |   |----|   |   |----|   |
  9.                    h0           h1           h2           h3
  10.                      \________  |____   _____|  _________/
  11.                               \______(+)_______/
  12.                                       |
  13.                                       |--------->f(n)
  14.                                       v
  15.            d(n) -------------------->(+)-------->e(n)
  16.                                     -
  17.  
  18.  
  19. Notation and symbols:
  20.   x(n)  - Input sample at time n.
  21.   d(n)  - Desired signal at time n.
  22.   f(n)  - FIR filter output at time n.
  23.   H(n)  - Filter coefficient vector at time n.  H={h0,h1,h2,h3}
  24.   X(n)  - Filter state variable vector at time N.
  25.           X={x(0),x(n-1),x(n-2),x(n-3)}
  26.   u     - Adaptation gain.
  27.   ntaps - Number of coefficient taps in the filter. For this
  28.           example, ntaps=4.
  29.  
  30.  
  31.       True LMS Algorithm        Delayed LMS Algorithm
  32.       ------------------        ---------------------
  33.       Get input sample          Get input sample
  34.       Save input sample         Save input sample
  35.       Do FIR                    Do FIR
  36.       Get d(n), find e(n)       Update coefficients
  37.       Update coefficients       Get d(n), find e(n)
  38.       Output f(n)               Output f(n)
  39.       Shift vector X            Shift vector X
  40.  
  41. System equations:
  42.  e(n)=d(n)-H(n)X(n)    e(n)=d(n)-H(n)X(n)        (FIR filter and error)
  43.  H(n+1)=H(n)+uX(n)e(n) H(n+1)=H(n)+uX(n-1)e(n-1) (Coefficient update)
  44.  
  45. References:
  46.   "Adaptive Digital Filters and Signal Analysis", Maurice G. Bellanger
  47.       Marcel Dekker, Inc. New York and Basel
  48.  
  49.   "The DLMS Algorithm Suitable for the Pipelined Realization of Adaptive
  50.       Filters", Proc. IEEE ASSP Workshop, Academia Sinica, Beijing, 1986
  51.  
  52. Note: The sections of code shown describe how to initialize all
  53.       registers, filter an input sample and do the coefficient update.
  54.       Only the instructions relating to the filtering and coefficient
  55.       update are shown as part of the benchmark.  Instructions executed
  56.       only once (for intialization) or instructions that may be user
  57.       application dependent are not included in the benchmark.
  58.  
  59.  
  60.  
  61.  
  62.             Implementation of the true LMS on the DSP56000
  63.  
  64.  
  65. Memory map:
  66.  
  67.     Initial X                           H
  68.   x(0) x(n-1) x(n-2) x(n-3)       h0   h1   h2   h3
  69.    |                              |
  70.    r0                             r4
  71.                                   r5
  72.  
  73.                                                         Program  Icycles
  74.                                                         Words
  75.  
  76.     move    #XM,r0              ;start of X
  77.     move    #ntaps-1,m0         ;mod 4
  78.     move    #-2,n0              ;adjustment for filtering
  79.     move    #H,r4               ;coefficients
  80.     move    m0,m4               ;mod 4
  81.     move    r4,r5               ;coefficients
  82.     move    m0,m5               ;mod 4
  83.  
  84. _getsmp
  85.     movep   y:input,x0          ;get input sample
  86.  
  87.     clr  a        x0,x:(r0)+ y:(r4)+,y0  ;save x(0), get h0    1      1
  88.     rep  #ntaps-1                        ;do fir               1      2
  89.     mac  x0,y0,a  x:(r0)+,x0 y:(r4)+,y0  ;do taps              1      1
  90.     macr x0,y0,a                         ;last tap             1      1
  91.  
  92.     movep  a,y:output     ;output fir if desired
  93.  
  94.     (Get d(n), subtract fir output, multiply by "u", put
  95.      the result in x1. This section is application dependent.)
  96.  
  97.     move          x:(r0)+,x0 y:(r4)+,a   ;get x(0), h0         1      1
  98.     do   #ntaps,_coefupdate              ;update coefficients  2      3
  99.     macr x0,x1,a  x:(r0)+,x0 y:(r4)+,y0  ;(u e(n) *x(n))+h     1      1
  100.     tfr  y0,a                a,y:(r5)+   ;copy h, save new h   1      1
  101. _coefupdate
  102.     move   x:(r0)+n0,x0  y:(r4)-,y0      ;update r0,r4         1      1
  103.  
  104.     jmp    _getsmp                       ;continue looping
  105.                                                          ------   ------
  106.                                                             10     3N+9
  107.  
  108.  
  109.           Implementation of the delayed LMS on the DSP56000 Revision C
  110.  
  111. Memory map:
  112.  
  113.     Initial X                           H
  114.   x(0) x(n-1) x(n-2) x(n-3)       hx  h0   h1   h2   h3
  115.    |                              |   |
  116.    r0                             r5  r4
  117. hx is an unused value to make the calculations faster.
  118.  
  119.  
  120.                                                        Program  Icycles
  121.                                                        Words
  122.  
  123.     move    #XM,r0              ;start of X
  124.     move    #ntaps-1,m0         ;mod 4
  125.     move    #-2,n0              ;adjustment for filtering
  126.     move    #H+1,r4             ;coefficients
  127.     move    #ntaps,m4           ;mod 5
  128.     move    #H,r5               ;coefficients
  129.     move    m4,m5               ;mod 5
  130.  
  131. _smploop
  132.   movep   y:input,a           ;get input sample
  133.  
  134.   move            a,x:(r0)    ;save input sample                   1  1
  135.   ;error signal is in y1
  136.   clr   a         x:(r0)+,x0  y:(r4)+,y0  ;get x(0), h0            1  1
  137.   do    #ntaps,_fir_cupdate   ;do fir and coefficient update       2  3
  138.   mac   x0,y0,a   y0,b        b,y:(r5)+   ;fir, copy h, save new h 1  1
  139.   macr  x0,y1,b   x:(r0)+,x0  y:(r4)+,y0  ;update h, new x, new h  1  1
  140. _fir_cupdate
  141.   rnd   a       x:(r0)+n0,x0  b,y:(r5)+   ;update r0, save last h  1  1
  142.  
  143.   (Get d(n), subtract fir output (reg a), multiply by "u", put
  144.    the result in y1. This section is application dependent.)
  145.  
  146.   movep         a,y:output         ;output fir if desired
  147.   jmp           _smploop
  148.                                                              ----- -----
  149.                                                               7    2N+6
  150.