Table 8.1 Implementation of adaptive filter using the C55x assemblycode
; AR0 -> in []is input signal buffer
; AR1 -> d []is desired signal buffer
; AR3 -> x []is circular buffer
; AR4 -> w []is circular buffer
rptblocal loop-1
; for(n 0; n < Ns; n)
mov *AR0, *AR3
; x [n] in [n]
mpym *AR3, *AR4,AC0
; temp w [0]*x [0]
j j
rpt CSR
; for(i 0; i < NÀ1; i)
macm *AR3, *AR4,AC0
;
y w [i]*x [i]
sub *AR1 ( #16, AC0
; AC0 Àe yÀd [n], AR1 -> d [n]
mpyk #ÀTWOMU, AC0
; AC0 mu*e [n]
mov rnd(hi(AC0)), mmap(T1) ; T1 uen mu*e [n]
rptblocal lms_loop-1
; for(j 0; i < NÀ2; i)
mpym *AR3,T1, AC0
;
AC0 uen*x [i]
add *AR4 ( #16, AC0
;
w [i] uen*x [i]
mov rnd(hi(AC0)),*AR4
lms_loop
mpym *AR3,T1, AC0
; w [NÀ1] uen*x [NÀ1]
add *AR4 ( #16, AC0
mov rnd(hi(AC0)), *AR4
; Store the last w [NÀ1]
loop
block-repeat loop controls the process of signal samples in blocks, while the two inner
repeat loops perform the adaptive filtering sample-by-sample. The repeat instruction
rpt
CSR
macm *AR3, *AR4, AC0
; y w [i]*x [i]
performs the FIR filtering, and the inner block-repeat loop, lms_loop, updates the
adaptive filter coefficients.
The zero-mean random noise generator given in Table 8.2 is used to generate testing
data for both the unknown system and the adaptive filter. The function rand()will
generate a 16-bit unsigned integer number between 0 and 65 536. We subtract 0x4000
from it to obtain the zero-mean pseudo-random number from À32 768 to 32 767.
The signal buffers and the adaptive filter coefficient buffer are initialized to 0 bythe
function init.c listed in Table 8.3. For assemblylanguage implementation, we apply
the block processing structure as we did for the FIR filter experiments in Chapter 5. To
use the circular buffer scheme, we pass the signal buffer index as an argument to the
adaptive filter subroutine. After a block of samples are processed, the subroutine
returns the index for the adaptive filter to use in the next iteration.
The adaptive system identification is tested by the C function exp8a.c given by
Table 8.4. The signal and coefficient buffers are initialized to 0 first. The random signal
generator is then used to generate Ns samples of white noise. The FIR filter used to
EXPERIMENTS USING THE TMS320C55X
387