You are on page 1of 6

The 5th International Conference on Electrical Engineering – Boumerdes (ICEE-B)

October 29-31, 2017, Boumerdes, Algeria.

A VHDL Implementation of NLMS and RLS


Adaptive Algorithms for Acoustic Echo Cancellation
Mohamed Djendi, Merouane Messini and Abderezak Guessoum
University Saad Dahlab of Blida, Signal Processing and Image Laboratory (LATSI), Route de Soumaa, B.P. 270, Blida 09000,
Algeria, Emails: m_djendi@yahoo.fr

Abstract—this paper gives details of our electrical engineering considered. The input of the adaptive filter 1 is ,
program efforts to introduce software/hardware design concepts and its output is . The noisy observation, with noise
and tools in senior-level and senior-design applications. In this at the output of the real echo path, is
paper we present a simple architecture for the very high
. The adaptive filter 1 is adapted at each new
development language (VHDL) implementation of a variant of
RLS algorithm where adaptive filter coefficients and filtering sample in order to minimize the power of the output filtering
error are both estimated block wise. The performance of the error, i.e.
VHDL RLS version, when tested under ModelSim software tools . (1)
and its fixed point Matlab versions are compared. The obtained
results show well the good proposed VHDL version of the RLS A. NLMS Adaptive Algorithm
algorithm in acoustic echo cancellation application.
The NLMS algorithm minimizes the mean-square error
Keywords-RLS, MSE, ALTERA,Quartus, Modelsim, Matlab. (MSE) between the filter output and a desired-response
signal . The updating equation of this algorithm and its
I. INTRODUCTION filtering error are given by [1-3]:
For the past ten years, adaptive filters design has been an 1 , is the echo estimation, (2)
active area of research and innovative implementations. An , is the error estimation, (3)
adaptive filter is a filter that self-adjusts its coefficients
according to an optimizing criterion [1-4]. Adaptive filters are 1 μ , is the filter update. (4)
needed in a wide range of signal processing, control, and
communications including [4-6]: signal detection; echo The impulse response is modeled by the vector of size
cancellation; noise cancellation, system identification, inverse L, is the estimated output signal, and is the a priori
modeling of unknown systems; forward and backward error computed before adaptation. The vector is given
predictions, adaptive tracking; and spectral analysis [7-9]. In by , ,…, 1 , and μ is the step
many of these applications, the hardware implementations are size which must be chosen between 0 and 2 to achieve
important when real-time execution is needed Technological convergence [1].
advances in VLSI fabrications have made Field- B. RLS Adaptive Algorithm
Programmable Gate arrays (FPGA) the platform of choice for
hardware implementations especially where timing In this section, we present the RLS algorithm that is generated
requirement is strict. Such hardware implementations can be by the combination of the RLS algorithm and the forward
realized using hardware description languages such as VHDL blind source separation structure as given by Fig. 3. The RLS
or Verilog. Modern FPGA chips contain many resources that algorithm is based on the minimization the least square
are essential for DSP applications such as embedded criterion .
multipliers, multiply-accumulate units, soft and hard processor ∑ (5)
cores, and embedded memory blocks [10-13]. The availability
of powerful integrated software and hardware design and where (0 1 is a forgetting factor that allows to the
synthesis packages, advanced FPGA boards, Intellectual RLS algorithm to forget the older samples and to track very
property (IP) designs, and tools that allow seamless integration quickly the non-stationary phenomenon that can present in the
between these software and hardware design packages has input signals. the output e is given as :
made software/hardware co-design the methodology of choice
for the implementations of many of real-time applications.
1 (6)
II. AEC BY ADAPTIVE ALGORITHMS
Along this paper, we assume that the acoustic echo paths is The minimization of J gives the following optimal
modelized by a FIR filter with a large number L of solutions:
coefficients. Only adaptive FIR transversal filters are (7)

978-1-5090-4508-2/17/$31.00 ©2017
Where is the cross-correlation vectors, and R(n) is the C. Initialisation of the RLS Adaptive Algorithm
autocorrelation matrixes, they are defined as follows:
The listing and the initialization of the RLS algorithm are
given in table 1.
∑ (8)
Table 1: The RLS algorithm.
∑ (9)

-Initialization: K , , 0 0.
where: , 1 … 1 . The
relations (8) and (9) can be calculated in recursive manner as - Kalman gains calculation:
follows:
1 (10)
1 (n) (11)
1 1

- Filtering part:
m n e n
1 ,
1 ,

w1 n
m̂ n Where is the identity matrix and is a small positive constant.

K n estimati III. VHDL IMPLEMENTATION OF NLMS AND RLS


ALGORITHM FOR ACOUSTIC ECHO CANCELLATION SYSTEM
A. FIR filters implementation
Figure 1. Proposed Dual forward RLS (DFRLS) algorithm.
In adaptive echo cancellation systems, the adaptive filter is
usually designed as a transversal FIR filter structure [1]. The
In order to simplify the RLS algorithm described above, we
transversal filter of RLS consists of three basic elements; unit
use the Lemma Matrix of [1], and by setting = delay elements, multipliers and adders as shown in Figure 2.
then , we get the following relation for The unit delay elements are designed using the unit delay
that is called the dual Kalman gain of the FRLS operator. The output of the unit-delay operator is a delayed
algorithm, i.e. copy of its input. The number of delay elements represents the
filter order.
(12)
m(n)
z-1 z-1 ... z-1 z-1
This last relation can be rewritten as follows:

1 1 (13) w0 w1 w1 wN-3 wN-2 wN-1

As we have derived the recursive formulas of the inverse y(n)


Σ Σ ... Σ Σ Σ
matrix of = , the next steps is the derivation of the
updating relation of the cross-filter . By inserting (13) in
Figure 2. Transversal FIR filter implementation.
(7), we get the following relation:
B. AEC implementation
1 (14)
The adaptive noise cancellation filter employing the NLMS or
RLS algorithm can be implemented as shown in Figure 3.
where e(n) is the a priori errors that is calculated by (6).

978-1-5090-4508-2/17/$31.
m(n) ...
when transitioning from a floating point to a fixed-point
z-1 z-1 z-1 z-1
representation is to keep a limited number of decimal digits.
Normally, two to three decimal places is adequate, but the
m(n) number required for a given algorithm to converge must be
w0 w1 w1 wNN-3 wNN-2 wN-1
found through experimentation. When performing software
simulations of a digital filter for example, it is determined that
y(n) e(n)
Σ Σ ... Σ Σ Σ Σ two decimal places is sufficient for accurate data processing.
B. Scale factor choise of the inputs/outputs signals
Adaptive Algorithm: NLMS or RLS The procedure described above can be easily carried out by
multiplying the filter’s coefficients by 100 and truncating to an
integer value. Dividing the output by 100 recovers the
Figure 3. AEC systems by NLMS or RLS algorithm. anticipated value. Since multiplying and dividing be powers of
two can be done easily in hardware by shifting bits, a power of
IV. ARCHITECTURE DESIGN two can be used to simplify the process. In this case, one
would multiply by 128, which would require seven extra bits
A fixed point implementation on FPGA or VHDL is in hardware. If it is determined that three decimal digits are
preferably suited for the implementation of adaptive filters. needed, then ten extra bits would be needed in hardware,
Nevertheless, there are several topics that need to be while one decimal digit requires only four bits.
discussed. When realizing software simulations of adaptive
filters, computations are normally carried out with floating C. Scale Factor procedure
point precision [10-11]. The described procedure of adjustment and choice of the
Unfortunately, the resources required of an FPGA/VHDL fixing point scale factor signals (i.e. the primary and the
to perform floating point arithmetic is normally too large to be reference signals as given by Figure 1) are listed as follows in
justified, and measures must be taken to account for this. the following Table 1. This Tables contains the most
Another concern is the filter tap itself. Numerous techniques important process that we have to follow in the
have been devised to efficiently calculate the convolution implementation of both algorithms, NLMS and RLS.
operation when the filter’s coefficients are fixed in advance.
For an adaptive filter whose coefficients change over time, TABLE I. FIXED POINT CONVERSION
these methods will not work or need to be modified
significantly [12-13].
x Determine Scale:
In this paper, we aim to implement NLMS and RLS
Through simulations, find the needed accuracy (decimal
algorithm on VHDL software and the inputs/outputs signals
places).
precision must be well studied before implantation on VHDL.
Multiply all constants by scale.
A block diagram that describes the inputs/outputs signals of
Divide by scale when two scaled values are multiplied.
NLMS and RLS when implemented on VHDL is given by the
Multiply by scale when two scaled values are divided.
following figure 4.
x Replace:
For multiplication by values less than 1 Î replace with
division by the reciprocal value.
Primary input Echo signal For division by values less than 1 Î replace with
multiplication by the reciprocal value.
Adaptive x The outputs of the algorithm will then need to be divided by
algorithmes : the scale to obtain the true output.
NLMS / RLS
Reference input Filtering error output

V. AVAILABLE RESOURCES OF ADAPTIVE FILTERING


The following software and hardware resources, available at
Adaptive filter our Laboratory (LATSI), will be used to introduce adaptive
Clock coefficients filtering in VHDL implementation:

- The latest versions of the system edition of the Quartus II®


design suite including the Altera system generator and the
Figure 4. Inputs/outputs signals of NLMS and RLS algorithms.
embedded design kit (EDK) tools.

A. Scale Factor Adjustment of the inputs/outputs signals - The latest compatible version of the MathWorks® design
A suitable compromise for dealing with the loss of precision tool packages including the signal processing, DSP, fixed-
of the input signals (i.e. the primary and reference signals)

978-1-5090-4508-2/17/$31.
point, communications, image acquisition tool boxes and the mean square error (MSE), the echo ratio lost error (ERLE)
HDL coder, HDL verifier, and the filter design HDL coder. and the temporal evolution of the normal filtering error. We
- The latest version of ModelSim® recall here that the entire used signal are sampled at 8 kHz and
The following block scheme of figure 5 describes the different coded on 16. The ModelSim simulation results are compared
step that we have followed to compare the RLS and NLMS with MATLAB ones. We observe that the algorithms
algorithms on Matlab and VHDL implementations software. performances are comparable in both environments. In
To carry out the simulation in VHDL language, the MATLAB input signals are passed through a 24 taps acoustic
operations of RLS and NLMS algorithms are taken as a impulse response, which represents the desired signal d(n).
process. The execution of each process will be enabled after Same length has been used in VHDL code. The input and the
the execution of the prior one, Table I, shows the process, the desired signals are processed in MATLAB. The data referring
corresponding list of sensibility (enable value) and the result to these signals was transformed into specific file through a
provided by the process. The obtained results of this special call function. This file contains integer values of data.
implementation are given in next sections. On the other hand the output results are transformed into
specific file in order to read this data in MATLAB. In the
second experiment that we have evaluated the performance of
Primary input Reference input the adaptive algorithms (NLMS and RLS) iunder Matlab and
ModelSim software, we have used the MSE (Mean Square
Error) criterion. The expectation of the norms square error is
Fixed point implantation plus scaling according to Table 1. given as follows:

10 ‖ ‖ .

NLMS/RLS ModelSim NLMS / RLS where e(n) is the filtering errors of NLMS or RLS algorithms
on VHDL Tests On Matlab and E is the statistic expectation . The obtained results by
Matlab and ModelSim implementation of both algorithms (i.e.
NLMs and RLS) are given as follows. In the first experiment
both NLMS and RLS adaptive algorithms are tested with
USASI (United state of America standard institute now ANSI)
Save the outputs (filtering error)
to test the convergence speed performance. The second
experiment uses a speech signal to test the two algorithms in
acoustic echo cancellation application. These two experiments
Criteria evaluation: are carried out by two software, i.e. Matlab and ModelSim.
Linear error, and MSE (Mean square error).
A. Matlab simulation results of NLMS and RLS algorithms
with USASI noise at the input
The output error obtained with NLMS and RLS under Matlab
Plot by Matlab the linear error and MSE software are given by figures 6 (linear error) and 7 (MSE).
evolution. From these figures, we see well the good performance of RLS
versus NLMS algorithm under Matlab software.

Figure 5. Block scheme of NLMS and RLS implementation on Matlab and 3000
NLMS
VHDL/ModelSim.
2000 RLS

VI. SIMULATIONS RESULTS 1000


Amplitude

In this section, we show the carried out experiments results 0


on Matlab and ModelSim software where NLMS and RLS
algorithms are simulated. The detailed processes of the -1000
implementation of each algorithm are explained before. Two
kinds of experiments are carried out with NLMS and RLS -2000
algorithms.
-3000
In the first experiment we use a USASI (United State of 0 0.5 1 1.5 2 2.5 3
America Signal Institute, now called ANSI) noise at the input Samples x 10
4

to test the convergence speed performance of each algorithm.


In the second experiment, a speech signal is used at the input. Figure 6. Ouput error of NLMS and RLS algorithms under Matlab softwate
In this experiment, three criteria are performed: (i) the output with USASI noise at the input.

978-1-5090-4508-2/17/$31.
60 C. Matlab simulation results of NLMS and RLS algorithms
NLMS with speech signal at the input
RLS
40
In this experiment, the speech signal is used as the input and
we want to cancel the echo by the both algorithms, NLMS and
MSE in (dB)

RLS. The obtained results of the linear error and the MSE are
20 given respectively by figures 10 and 11.
We can well see the good performance of RLS algorithms to
cancel the acoustic echo even in real situation when the speech
0 signal is used at the input of the AEC process.
This is not a new results but a much known behavior under
-20 Matlab software, but here we confirm that under the same
0 50 100 150 200 250 software when fixed floating point representation is used, the
Bloc of 128 samples two algorithms keep the same behavior with the same
superiority of RLS versus NLMS.
Figure 7. MSE obtained by NLMS and RLS algorithms under Matlab
softwate with USASI noise at the input.
500
B. ModelSim simulation results of NLMS and RLS algorithms NLMS
with USASI noise at the input RLS

A m plitude
The same experiment as in (A) is repeated but we use here the
ModelSim software to carry out this experiment. The obtained 0
results are given by figures 8 (linear error) and 9 (MSE).
Again, we confirm the superiority of RLS algorithm against
NLMS performances.

3000
NLMS -500
2000 RLS 0 0.5 1 1.5 2 2.5 3
Samples x 10
4

1000 .
Amplitude

0 Figure 10. Ouput error of NLMS and RLS algorithms under Matlab softwate
with speech signal a the input.
-1000
60
-2000
NLMS
-3000 40
0 0.5 1 1.5 2 2.5 3 RLS
MSE in (dB)

Samples x 10
4

Figure 8. Ouput error of NLMS and RLS algorithms under ModelSim


20
softwate with USASI noise at the input.
0
60
NLMS
-20
RLS
40
MSE in (dB)

-40
0 50 100 150 200 250
20 Bloc of 128 samples

Figure 11. MSE obtained by NLMS and RLS algorithms under Matlab
0 softwate with speech signal a the input.

-20 D. ModelSim simulation results of NLMS and RLS algorithms


0 50 100 150 200 250 with speech signaal at the input
Bloc of 128 samples
In this last experiment, we will see the performance of NLMS
Figure 9. MSE obtained by NLMS and RLS algorithms under ModelSim and RLS when implemented on VHDL and tested with
softwate with USASI noise at the input. ModelSim software. In this experiment we have used the same

978-1-5090-4508-2/17/$31.
signals as in the experiment above. However, the software is minimize at the output the expectation of the mean square or
changed to ModelSim. The obtained results of the linear error the smoothed men square of the filtering error. The proposed
and its MSE are given respectively by figures 12 and 13. implantations in VHDL software are given of the two
algorithms NLMS and RLS. We have used Matlab and
500 ModelSim software to carry out the simulation of both
NLMS algorithms in fixing and floating point representation of the
RLS data that are used by both algorithms in acoustic echo
cancellation applications. We have used two criterions to
Amplitude

compare NLMS and RLS algorithms under Matlab and


0 ModelSim software, the linear filtering error and the mean
square error (MSE) expressed in decibels to see well the
behavior in the steady state regime. All the performed
experiments have shown the good performances of the two
algorithms in cancelling the acoustic echo. However, the
-500 superiority of RLS is confirmed under both software, i.e.
0 0.5 1 1.5 2 2.5 3 Matlab and ModelSim. In this paper, the proposed process of
Samples x 10
4
implementing NLMS and RLS in VHDL have given a good
results and prove again that the variables and parameters
Figure 12. Ouput error of NLMS and RLS algorithms under ModelSim dynamic of each algorithm have to be carefully taken into
softwate with speech signal a the input. account when real time implantation of each algorithm is
performed. We recall here that all the used signals in
60 simulations are real and measured under real conditions. The
NLMS next step of this work is to test the low complexity versions of
40 RLS algorithm under VHDL environment and to well see their
RLS
performances in comparison with the proposed one in this
MSE in (dB)

paper.
20 References

0 [1] Sayed AH. Fundamentals of Adaptive Filtering. New York: Wiley; 2003.
[2] J.R. Treichler, C.R. Johnson, JR., M.G. Larimore, Theory and Design of
the Adaptive Filters, Prentice Hall, 2001.
-20
[3] J. Cioffi and T. Kailath, Fast recursive least squares transversal filters
for adaptive filtering, IEEE Trans. Acoust,Speech, Signal Processing,
-40 vol. ASSP-32, pp. 304-337, Apr. 1984.
0 50 100 150 200 250 [4] P. Mavridis, and G. Moustakides, Simplified Newton-Type Adaptive
Bloc of 128 samples Estimation Algorithms, IEEE Trans. Signal Process, 1996, 44, (8).
[5] D.T.M.Slock , On the convergence behaviour of the LMSand the
Figure 13. MSE obtained by NLMS and RLS algorithms under ModelSim normalized LMS algorithms, IEEE Trans. Signal Processing, vol. 42, pp.
softwate with speech signal a the input. 2811-2825, Mar. 1993.
[6] M. Rupp, A family of adaptive algorithms with decorrelating proprieties,
IEEE Trans. Signal Processing, Vol. 46, NO. 3, 1998
From these results, we can easily see that the RLS algorithm
[7] M. Djendi, M. Bouchard, A. Guessoum, A. Benallal, D. Berkani.
has kept the same good performance as given in the previous Improvement of the convergence speed and the tracking ability of the
sections when Matlab software is used in simulation. We have fast Newton type adaptive filtering (FNTF) algorithm. Signal Process.
also noted that the RLS algorithm, when implemented under 2006;86(7):1704̄1719.
ModelSim software, its performance in cancelling the acoustic [8] M. Djendi, P. Scalart, A. Gilloire. Analysis of two-sensors forward BSS
echo still good and all the echo will be cancelled when RLS structure with post́filters in the presence of coherent and incoherent
noise. Speech Comm. 2013;55(10):975̄987.
algorithm is used with the good parameters. Also, and under
[9] M. Djendi, A. Gilloire, P. Scalart. New frequency domain post-filters for
ModelSim software, RLS algorithms performs well in noise cancellation using two closely spaced microphones, Proc.
comparsion with the NLMS one in the situation when the EUSIPCO, Poznan, 3́8 Sep. 2007, vol. 1, pp. 218́221.
speech signal is used at the input of both algorithms, i.e. [10] H. Ioana, M. Irina, T. Marina. FPGA implementation of LMS and
NLMS and RLS. NLMS adaptive filters for acoustic echo cancellation. Acta Technica
Napocensis, 2011, vol. 52, no 4, p. 13.
[11] K. R. Rekha, B. S. Nagabishan and N. R. Natary, “FPGA
VII. CONCLUSION implementation of NLMS algorithm for the identification of unknown
system”, International ournal of engineering, science and technology,
In this paper, we have presented a new implementation Vol. 2 (11) 2010
process and method of the normalized least mean square [12] Z. J. Mou and P. Duhamel “Fast FIR Filtering: Algorithms and
(NLMS) and the recursive least square (RLS) adaptive Implementation” Signal Processing Vol. 13 N° 4 pp. 377-384 Dec. 1987.
algorithms. These two algorithms are very known ad used in [13] FPGA, DSP48A1 user Guide, www.datasheets.org.uk/250-DSP,
[Retrieved:August 13, 2009].
acoustic echo cancellation and others applications that aim to

978-1-5090-4508-2/17/$31.

You might also like