# EE445S Real-Time Digital Signal Processing Lab - Homework 7 Hints

Homework #7: Assignment in Word and PDF formats.
• Please keep all of the work for each problem together. Please don't put the writeup in one place and plots in another. That makes it much more difficult for the grader to grade them.
• Problems 7.1 & 7.2: Please note that there are additional suggestions for problem 7.2 below.

The channel equalizer compensates for frequency selectivity in the communication channel as well as in the analog front ends of the transmitter and receiver.

Please be aware that the "best" equalizer may be of any length. In fact, the "best" equalizer length may be much longer than the length of the channel impulse response. To reduce the computational complexity of your simulations, I'd recommend limiting your search to equalizers of length 4 to 41 coefficients.

The bit error rate may appear to be zero if enough bits aren't used in the simulation. For example, if one expects a bit error rate (BER) of 10-2, i.e. one bit error every 100 bits on average, then one would generally have to run 100/BER bits (i.e. 10,000 bits) to have confidence in the measurement of this bit error rate.

It is okay if you cannot drive the number of bit errors to zero.

For this problem, please adapt the Matlab/Mathscript code provided by the book as follows:

• In the first part of the code, generate a maximal length pseudo-noise sequence of length 1023 (i.e. 210 - 1) with entries +1 and -1. New Wave Instruments recommends a connection polynomial with connections at stages 7 and 10. Here's the Matlab code using comsrc.pn to generate a PN sequence for connections at stages 7 and 10:
```pn1023gen = commsrc.pn('GenPoly',       [10 7 0], ...
'InitialStates', [0 0 0 0 0 1 0 0 0 0], ...
'CurrentStates', [0 0 0 0 0 1 0 0 0 0], ...
'Mask',          [0 0 0 0 0 1 0 0 0 0], ...
'NumBitsOut',    1023);
pn1023seq = round(2 * generate(pn1023gen) - 1);
```
Then, concatenate 10 of these length-1023 sequences to create a training signal of length 10230 entries; alternately, one could set NumBitsOut to 10230. (In version 3.5 of the Communications Toolbox, commsrc.pn is called seqgen.pn, which takes the same arguments.) Use the same training signal in problems 7.1 and 7.2.

If you don't have the Communication Toolbox on your machine, then could run Matlab on one of the ECE Learning Resource Center machines that has the Communications toolbox, generate the 1023 values for the PN sequence as +1 and -1 values, save the values to a file, move the file to your computer, and read it into Matlab.

• Next, initialize the counter for the minimum number of bit errors, errmin, to be large, e.g. equal to twice the number of bits in the training signal.
• Next, set up a nested for loop. The outer loop will enumerate values of n from 3 to 40, where n is the equalizer length minus one. The inner loop will enumerate the possible transmission delays delta from 1 to n, inclusive.
• In the nested for loop, compute the number of errors for every combination of n and delta within the inner loop. If one finds an error smaller than the previously found error, one updates errmin, the corresponding nmin and deltamin, and associated values of Jmin and the equalizer coefficients.

When you plot the frequency response of the equalized channel, please plot the magnitude and phase responses, e.g. by using the `freqz` command.

• Problem 7.2: Please read the hints above for problems 7.1 & 7.2.

In the course reader, please see problem 2.2 on Midterm #2 in fall 2012 on page 282 (K-126) and problem 2.1 on Midterm #2 in spring 2013 on page 286 (K-130). Both problems derive the adaptive equalizer for a two-tap FIR filter. For problem 2.2, the first coefficient is set to one and the second coefficient is adapted. For problem 2.1, both coefficients are adapted.

Please reduce the step size parameter, mu, to be on the order of 0.001 so that the iterations will converge to a reasonable error value.

Please augment the code for problem 7.2 by copying the code to calculate and track the minimum error (errmin) from the code for problem 7.1.

There are two different error calculations in this problem, and they are easy to confuse.

Please estimate the computational complexity in terms of multiplication-accumulation (MAC) operations for the two equalizer design methods. Given m training samples, n equalizer coefficients and fixed delay delta, estimate the computational complexity of the LS squares equalizer design formula

```f=inv(R'*R)*R'*S
```
for vector f, matrix R and vector S. Estimate the computational complexity of the adaptive LMS equalizer design formula
```f=f+mu*e*rr
```
for vector f, scalar mu, scalar e and vector rr. The adaptive LMS design formula is run for each training sample. The following facts may be useful:
• A scalar times a vector of N elements takes N MAC operations.
• The dot/inner product of two vectors of length N takes N multiplications and N-1 additions, or equivalently N MAC operations.
• The product of an N by M matrix and a column vector of M elements (i.e. an M x 1 matrix) requires N dot/inner products of two vectors of length M, which requires N M MAC operations.
• The product of an N by M matrix with an M by N matrix produces an N by N matrix with N2 entries. Each entry in the resulting matrix involves a dot/inner product of two vectors of length M. Therefore, the product of the two matrices requires M N2 MAC operations.
• In the case of problem 7.1, the matrix inverse is really used to solve a linear system of equations. That is, with vector x known, we can rewrite
```y = A-1 x
```
as solving the following linear system of equations for y:
```A y = x
```
An N by N system of linear equations can be solved with 2 N3 MAC operations, as described by the article "Gaussian elimination".

Also, please estimate the total memory usage for the calculations in terms of words.

In the course reader, please see problem 2.4 on Midterm #2 in fall 2011 on page 274 (K-118) for a qualitative comparison between the least squares method and the adaptive least mean squared method.

• Problem 7.3: Please see slide 16-5 on automatic gain control.

In the course reader, please see problem 2.3 on Midterm #2 in fall 2011 on page 273 (K-117).

Last updated 04/19/14. Send comments to bevans@ece.utexas.edu