Vous êtes sur la page 1sur 4

Channel Coding:

Repetition Codes: Repetition code is generally a very naive method of encoding data across a channel, and it is not preferred for Additive White Gaussian Noise Channels (AWGN), due to its worse-than-the-present error performance. Repetition codes generally offer a poor compromise between data rate and bit error rate, and other forms of error correcting codes can provide superior performance in these areas. The chief attraction of the repetition code is the ease of implementation. The encoder is a simple device that repeats, r times, a particular bit to the waveform modulator when the bit is received from the source stream. For example, if we have a (3,1) repetition code, then encoding the signal m = 101001 yields a code c = 111000111000000111. Repetition decoding is usually done using Majority logic detection. To determine the value of a particular bit, we look at the received copies of the bit in the stream and choose the value that occurs more frequently. For example, suppose we have a (3,1) repetition code and we are decoding the signal c = 110001111. The decoded message is m = 101, as we have most occurrence of 1's (two to one), 0's (two to one), and 1's (three to zero) in the first, second, and third code sequences, respectively. In Matlab we can easily generate the repetition codes. Example: x = [1 0 1 1]; y = repmat(x,3,1); % to repeat the matrix z = reshape(y, 1, 3*(length(x)); % to resize the matrix The outputs are following: x= 1 y= 1 1 1 0 0 0 1 1 1 1 1 1 0 1 1

z= 1 1 1 0 0 0 1 1 1 1 1 1

Task: Encode the original binary message by (3, 1) or (5,1) repetition code and do the BPSK modulation. In the receiver side after demodulating decode the binary message by Majority logic detection. See the error performance of repetition codes in BSC and AWGN channel. Linear Block Codes Linear block codes are the most important and widely used class of block codes. Each code word can be written in the following form: c = uG Where u is the binary data sequence of length k. The minimum distance of the code is an important parameter in linear block code, which is defined as the minimum Hamming distance between any two codewords. It determines the error-correcting capabilities: dMIN = min dH(ci, cj), where i j For linear block codes, the minimum distance is equal to the minimum number of 1s in any nonzero codeword: Example of linear block code: The generator matrix for a (10,4) linear block code is given by: 1001111011 1 0 10 1 1 0 1 1 0 0111000111 1110111001 Determine all the codewords and the minimum weight of the code. %Matlab script for (10,4) linear block code % Generate U, denoting all information sequences. k=4; u=dec2bin(0:2^k 1)==1;% To generate binary combinations %Define G, the generator matrix g=[1 0 0 1 1 1 0 1 1 1; 1 1 1 0 0 0 1 1 1 0; 0 1 1 0 1 1 0 1 0 1; 1 1 0 1 1 1 1 0 0 1]; %Generate codewords c=rem(u*g,2);

%Find the minimum distance w_min=min(sum((c(2:2^k,:))')); Example of systematic Hamming code: Find all the codewords of the (15,11) Hamming code, and verify that its minimum distance is equal to 3. %Matlab script for hamming code k=11; % Generate all binary combinations of message bits u=dec2bin(0:2^k 1)==1; %Define G, the generator matrix I=eye(k); % Identity Matrix P=[1 1 0 0; 0 1 1 0; 0 0 1 1; 1 0 1 0; 1 0 0 1; 0 1 0 1; 1 1 1 0; 0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 1;]; g=[P,I]; %Generate codewords c=rem(u*g,2); %Find the minimum distance w_min=min(sum((c(2:2^k,:))')); Question:What is the minimum number of errors this code can correct? We can generate the generator matrix and parity check matrix of hamming code by Matlab function hammgen(). For example to create the generator and parity check matrix of (15,11) you can write [h,g,n,k] = hammgen(4) Where 2^4 1 = 15 is the codeword length and 15 4 = 11 message length.

Decoding of hamming codes: You cannot use any Matlab function to implement decoder. You have to follow decoder circuit to create decoder. But for checking that you decoder is working correctly you can use Matlab functions. For example, you can generate syndrome lookup table for correctable error patterns using syndtable() function. % generate generator matrix and parity check matrix [h,g,n,k] = hammgen(3); % generate Syndrom Table for all error patterns t = syndtable(h); The outputs are following: h= 1 0 0 g= 1 0 1 1 n= 7 k= 4 t= 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 For syndrome 0 0 0 For syndrome 0 0 1 For syndrome 0 1 0 .. .. .. For syndrome 1 1 0 For syndrome 1 1 1 0 1 0 1 1 1 0 0 0 1 0 1 1 1 1 1 0 1 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 1 0 1 0 1 0 0 0 1

Now after demodulation and detection you can calculate the syndrome for each codeword and use syndrome lookup table to find specific error pattern (coset leader) and correct the error.