Vous êtes sur la page 1sur 6

1

Wireless Access Systems


Exercise Sheet 2: Coded OFDM Modem
I. GOALS OF THE EXERCISE
In this exercise, we simulate a complete coded OFDM (COFDM) modem. The implementation of channel
coding and OFDM is divided among different groups, which will then combine their code at the combination
task to obtain a complete system. Task 1 considers the simulation of channel coding, in this case, convolutional
coding. The aim is to get familiar with convolutional codes, channel encoding, Viterbi decoding and bit-interleaved
modulation. Task 2 considers the implementation of a basic OFDM transceiver. We will get familiar with OFDM
modulation/demodulation, cyclic prex, and frequency selective channels. Moreover, we will estimate the channel
matrix and use it for equalization after OFDM demodulation. In the following, we introduce the details of each
task.
II. TASK 1: CHANNEL CODING - CONVOLUTIONAL CODES
A. Introduction
Channel coding enables the correction and/or detection of bit errors introduced by transmission of a modulated
signal through a channel. Design of codes differ for AWGN and fading channels. For instance, codes designed for
AWGN can not deal with long burst errors which may be introduced by fading channels. Hence, codes for fading
channels incorporate AWGN-based channel codes and interleavers, which randomize the transmit bits. There are
basically two types of channel codes: block codes and convolutional codes. The convolutional codes differ from
block codes in that the encoder introduces memory, and the output at a given time depends not only on the current
input, but also on previous input bits. A rate R = k/n convolutional encoder with constraint length K is a k-input,
n-output linear sequential circuit with memory depth m = K 1. The information sequence is divided into blocks
of length k and the codeword is divided into blocks of length n.
Fig. 1. A rate 1/2 binary convolutional encoder with constraint length K = 4 and memory depth m = 3.
2
An example for a rate 1/2 convolutional encoder is given in Fig. 1. The encoder has k = 1 inputs, m = 3 delay
elements and n = 2 mod-2-adders. Since mod-2 addition is a linear operation, the encoder is a linear feedforward
shift register. The information sequence u = (u
0
, u
1
, u
2
, ...) enters the encoder one bit at a time. The two encoder
outputs v
(0)
= (v
(0)
0
, v
(0)
1
, v
(0)
2
, ...) and v
(1)
= (v
(1)
0
, v
(1)
1
, v
(1)
2
, ...) can be obtained as the convolution of u with the
encoder impulse response. The impulse response is obtained by letting u = (1, 0, 0, ...). After encoding, the two
streams are multiplexed and the codeword is obtained: v = (v
(0)
0
v
(1)
0
v
(0)
1
v
(1)
1
v
(0)
2
v
(1)
2
...).
The convolutional encoders have a natural trellis structure, and the Viterbi algorithm is the optimal decoding
algorithm which reduces the complexity of maximum likelihood decoding by systematically removing paths from
consideration that cannot achieve the highest path metric.
Channel codes are designed for good performance in AWGN channels. In fading channels, when the channel is in
deep fade, the errors usually occur in long bursts. To improve coding performance in fading channels, interleaving
has been introduced. The basic idea behind the use of an interleaver is to spread error bursts, which occur due to
deep fades, over many codewords. By doing so, the received codeword exhibits at most a few consecutive errors.
The size of the codewords should be large enough to randomize the symbols such that fading is independent in a
received codeword.
Fig. 2. A block N M (7 7) interleaver.
Combining coding and interleaving, we obtain the channel coding with interleaving structure for fading channels,
as shown in Fig. 3. The information bits from the source are encoded with a given convolutional encoder, and then
interleaved. The interleaved coded bits are mapped to modulated symbols and sent through a channel (e.g., AWGN,
binary symmetric channel, fading channel). The received symbols are demapped, de-interleaved and then decoded
by a Viterbi decoder.
Fig. 3. The block diagram of channel coding with interleaving for fading channels.
B. Task: Channel encoding/decoding
We simulate channel encoding/decoding for a given convolutional code. Basically, we will follow the blocks
given in Fig. 3. In the following, we present a detailed recipe for the simulator. Please follow each step and write
a MATLAB code to implement these steps.
3
Generate a bit sequence x, which consists of {0, 1} (use randint.m). Let us dene the following: N
b
is the
length of the input bit sequence, is the number of bits per symbol, N is the length of one block of symbols.
We x the length of a block of symbols to N = 256, and choose N
b
according to: N
b
= NR m. E.g., if
we use QPSK ( = 2), m = 5, and a rate R = 1/2 code, then N
b
= 251.
Encode x with one of the convolutional codes given in Table I. You need to implement a modular encoder
which takes the impulse responses of the encoder as input and produces the channel encoded bits.
For instance, let us focus on the m = 3 code. The g
(0)
is 13, which corresponds to [001011] in binary
form (i.e., the rst impulse response is g
(0)
= [1011]). Likewise, g
(1)
corresponds to [001111] (i.e., the
rst impulse response g
(1)
= [1111]). Using these polynomials we can draw the encoder as shown in
Fig. 4.
Conv g
(0)
Conv g
(1)
Mod 2
Mod 2
Fig. 4. The R = 1/2 convolutional code for [001011] and [001111].
Draw the encoder diagrams for the convolutional codes given in Table I for m = 2, 4, 5. (Similar to the
one for m = 3 in Fig. 4)
The length of the encoded bitstream must be N.
Design a 16 16 block interleaver and interleave the coded bits in every block.
Map the bits to a symbol sequence s (use BPSK/QPSK/16-/64-QAM from Exercise 1).
Add complex AWGN.
Calculate the average symbol energy:
E
s
=
1
N
N

l=1
|s[l]|
2
(1)
Use
Eb
N0

dB
= 10 log
10

Eb

2
n

, where E
b
= E
s
/, to calculate the noise variance
2
n
.
Demap the symbol sequence into a bit sequence.
Design a block de-interleaver and de-interleave the received bits.
Decode the de-interleaved bits with a Viterbi decoder. Use MATLABs built-in function vitdec.m. Use the
following code for the implementation of the decoder:
% Generate the trellis from the polynomials
tr = poly2trellis([m + 1], [g
(0)
g
(1)
]);
% Set the traceback length. If the code rate is 1/2, a typical value for tracebacklength is about ve times m.
tracebacklength = 5m;
% Call the vitdec function.
decoded = vitdec(coded, tr, tracebacklength,

term

,

hard

); % coded is the coded input bits.


% The output of vitdec is the decoded block of bits including the trailing bits.
4
TABLE I
OPTIMUM R = 1/2 CONVOLUTIONAL CODES (NOTE THAT THE NUMBERS ARE IN OCTAL FORM)
m g
(0)
g
(1)
2 5 7
3 13 17
4 27 31
5 53 75
6 117 155
When using other codes, you need to change m, g
(0)
, g
(1)
, and tracebacklength correspondingly.
Compute the bit error rate. Dont forget to exclude the trailing bits from the comparison. Note that to observe
small BERs, you need to simulate around 1000 blocks and average the error rates.
Repeat the same routine for different E
b
/N
0
|
dB
values and all modulation types. Plot BER versus E
b
/N
0
|
dB
curves.
Repeat the same routine for all convolutional codes given in Table I. And plot all BER vs E
b
/N
0
|
dB
curves
on one gure. Comment on the effect of m.
Compare your curves for coded transmission with those for uncoded transmission. You can either simulate
these curves or use the ones from Exercise 1. (Note: Take care that all curves are plotted against E
b
/N
0
|
dB
).
Now we will observe the relationship between interleaver length and burst errors. Burst errors occur in a fading
channel when the channel is in deep fade. In this case, the different contributions of the signal add destructively at
the receive antenna, and the received signal is many dBs weaker than the average received power. In practice, the
received signal is buried in noise. To simulate such an event, we set a part of the signal to zero before adding
noise at the receiver.
Choose a code from Table I and x a modulation scheme. Set a block of b
error
consecutive symbols of s
to zero (before the addition of AWGN). Vary the value of b
error
for a 16 16 interleaver and plot the BER
curves. Choose b
error
such that the burst error affects the BER.
Now, x some b
error
and try different sizes of interleavers. Plot the performance of different interleavers on
the same plot. Choose b
error
such that the performance for different interleaver sizes varies.
III. TASK 2: OFDM MODULATION/DEMODULATION
A. Introduction
Please refer to the lecture notes for an introduction to OFDM. The block diagram of a simple OFDM transceiver
is given in Fig. 5. The information bits are mapped to symbols by the modulator (mapper). Then, OFDM modulation
is applied, which consists of an IFFT operation and the addition of a cyclic prex (CP). The OFDM modulated
signal is sent through the channel. At the receiver, OFDM demodulation is applied to the received signal and the
estimated bits are obtained after demapping the symbols into bits.
Fig. 5. The block diagram OFDM transceiver.
5
B. Task: OFDM transceiver
We simulate the simple OFDM transceiver structure given in Fig. 5. In the following, we present a detailed recipe
for the simulator. Please follow each step and write a MATLAB code to implement these steps.
Set the number of carriers to N = 256 (i.e., the length of the block of the modulated symbols).
In general, the number of carriers and the FFT size does not need to be the same, but for this simulation
let us assume that FFT size is also equal to N.
Generate a block x of bits, which consists of {0, 1} (use randint.m). The length of the bit sequence is determined
by the chosen symbol mapping in the next step. For example, since we x N = 256, the bit sequence length
should be 256, 512, 1024, 1536 for BPSK, QPSK, 16-QAM, 64-QAM, respectively.
Map the bit sequence to BPSK/QPSK/16-/64-QAM symbols (use existing code from Exercise 1).
Apply N-point IFFT. Use the MATLAB function ifft.m.
Pay attention at the implementation of the IFFT and FFT functions in Matlab. Scale the IFFT and FFT
transformations properly such that the signal power is not modied.
Add a CP of length N
cp
= 6.
The length of the CP should be chosen according to the length of the channel impulse response, L. We
will set L = 5 in the next step, and we set the CP length to N
cp
= 6.
Send the OFDM signal through a multipath channel.
We model the multi-path channel with a nite impulse response (FIR) lter as
h =
L1

i=0
h
i
(n i) (2)
where h
i
is the gain of the ith path. Note that the delay of each path is a symbol wide. We set L = 5
and model h
i
as zero mean complex Gaussian random variable. We need to scale the variance of h
i
such
that

L1
i=0
|h
i
|
2
= 1. Use the following deterministic channel in your simulations:
h = [0.1641 j0.6395, 0.4582 + j0.3840, 0.0916 + j0.3695, 0.2131 + j0.0902, 0.0796 j0.0433]
T
Compute the frequency response of the channel and comment on the results. How is this channel characterized?
Add complex noise.
Calculate the average symbol energy:
E
s
=
1
M
M

l=1
|r[l]|
2
(3)
where M = N + N
cp
is the length of your OFDM signal, and r is the channel output signal. Use SNR
= 10 log
10
E
s
/
2
n
expression to calculate
2
n
.
Remove the CP.
Apply N-point FFT. Use the MATLAB function fft.m.
After applying the FFT, we need to equalize the output in order to remove the effect of different frequency
bin gains on the symbols. Consider the nth symbol y
n
after the FFT operation. You should equalize y
n
such that you obtain
y
n
= H

n
y
n
/|H
n
|
2
, (4)
6
where H
n
is the corresponding channel coefcient of the nth symbol in the frequency domain. Hence,
the receiver must estimate the values of H
n
.
Estimate the frequency domain channel coefcients, H
n
. In order to estimate the channel, use a pilot sequence
containing only 1s, which triggers all frequency bins of the channel impulse response. Repeat such pilot
transmission for 1, 2, 5 and 10 times, and estimate the channel by averaging the received symbols. Is this pilot
the best choice for estimating the channel coefcients? How could you improve the efciency of the system?
After estimating the channel coefcients and equalizing the symbols, map the symbol sequence to bits.
Compute the bit error probability. Note that to observe low BERs, you need to simulate around 1000 blocks
and take the average of these results.
Repeat the routine for different SNR values and for other modulation types (e.g., BPSK, QPSK, 16/64 QAM).
Plot BER versus SNR gures.
Compute the BER for QPSK with different cyclic prex lengths, N
cp
= 1, . . . , 6. What do you observe?
IV. COMBINATION TASKS: COFDM MODEM
The block diagram of the complete COFDM transceiver is given in Fig. 6. Combine channel coding with OFDM
and implement the blocks in Fig. 6.
Channel: You will simulate a block frequency-selective fading channel. Use L = 10 taps for the channel
impulse response. The channel is given by
h =
L1

i=0
a
i
h
i
(n i). (5)
The channel coefcients h
i
are i.i.d., drawn from a complex Gaussian distribution, with zero mean and variance
equal to 1. Compute the coefcients a
i
such that the power delay prole of the channel follows an exponential
decay function, with parameter = 1/5 and the average total power of the channel impulse response equals
1 (Hint: Place the rst tap at t = 0).
We assume a block fading channel model. This implies that the channel remains constant during a burst, and
changes to an independent realization in the following burst. Use blocks of 10 OFDM symbols. During this
burst, use 2 pilot symbols in order to estimate the channel, and transmit data with the remaining 8 symbols.
Repeat BER simulations for all possible symbol modulation types (e.g., BPSK/QPSK/16-/64-QAM).
Plot the channel-coded and uncoded BER results against E
b
/N
0
|
dB
and compare/observe the effect of coding.
How does the interleaver help the transmission in coded OFDM system?
Mapper IFFT CP
Demapper
FFT
CP
Removal
Channel
input
bits
Estimated
bits
Convolutional
Encoder
Interleaver
Viterbi
Decoder
De-
Interleaver
Fig. 6. The block diagram COFDM transceiver.

Vous aimerez peut-être aussi