Your Ad Here

Sunday, June 8, 2008

Information on Cyclic Code

Cyclic codes are an important sub-class of linear block codes for error detection, where a new codeword in the code can be formed by shifting the elements along one place and taking one off the end and putting it on to the beginning. Instead of being generated by a matrix, a cyclic code is generated by a polynomial so that the codes are sometimes called polynomial codes. Importantly, cyclic codes have a structure that makes it possible for the encoding and decoding to be performed by simple feedback circuitry. Satellite communications systems commonly use cyclic codes.

Information on Convolutional Code

A convolutional code extends the concept of a block code to allow memory from block to block. Each encoded symbol is therefore a linear combination of information symbols in the current block and a selected number of preceding blocks. Therefore, for example, if the final output is a ‘1’ followed by a ‘0’, then these two digits could only have been arrived at by via a certain sequence of 0s and 1s preceding them. The longer the sequence, the easier it becomes for the receiver to detect where the received sequence deviates from a possible sequence and so correct one or more errors. Decoding of convolutional codes is based on the principle of the Viterbi decoding algorithm or sequential decoding.
Satellite communications systems commonly use a convolutional code to protect all data carried on the link.

Linear Block Code

% Aim: Implementation Of linear Block Code

clc;
clear all;

% Input Generator Matrix
g=input('Enter The Generator Matrix: ')
disp ('G = ')
disp ('The Order of Linear block Code for given Generator Matrix is:')
[n,k] = size(transpose(g))
for i = 1:2^k
for j = k:-1:1
if rem(i-1,2^(-j+k+1))>=2^(-j+k)
u(i,j)=1;
else
u(i,j)=0;
end
end
end
u;
disp('The Possible Codewords are :')
c = rem(u*g,2)
disp('The Minimum Hamming Distance dmin for given Block Code is= ')
d_min = min(sum((c(2:2^k,:))'))

% Code Word
r = input('Enter the Received Code Word:')
p = [g(:,n-k+2:n)];
h = [transpose(p),eye(n-k)];
disp('Hammimg Code')
ht = transpose(h)
disp('Syndrome of a Given Codeword is :')
s = rem(r*ht,2)
for i = 1:1:size(ht)
if(ht(i,1:3)==s)
r(i) = 1-r(i);
break;
end
end
disp('The Error is in bit:')
i
disp('The Corrected Codeword is :')
r

%******************** OUTPUT *******************
Enter The Generator Matrix: [1 0 0 0 1 0 1;0 1 0 0 1 1 1;0 0 1 0 1 1 0;0 0 0 1 0 1 1]
g =
1 0 0 0 1 0 1
0 1 0 0 1 1 1
0 0 1 0 1 1 0
0 0 0 1 0 1 1

G =
The Order of Linear block Code for given Generator Matrix is:
n =
7
k =
4

The Possible Codewords are :

c =
0 0 0 0 0 0 0
0 0 0 1 0 1 1
0 0 1 0 1 1 0
0 0 1 1 1 0 1
0 1 0 0 1 1 1
0 1 0 1 1 0 0
0 1 1 0 0 0 1
0 1 1 1 0 1 0
1 0 0 0 1 0 1
1 0 0 1 1 1 0
1 0 1 0 0 1 1
1 0 1 1 0 0 0
1 1 0 0 0 1 0
1 1 0 1 0 0 1
1 1 1 0 1 0 0
1 1 1 1 1 1 1

The Minimum Hamming Distance dmin for given Block Code is=

d_min =

3

Enter the Received Code Word:[1 0 0 0 1 0 0]

r =
1 0 0 0 1 0 0

Hammimg Code
ht =
1 0 1
1 1 1
1 1 0
0 1 1
1 0 0
0 1 0
0 0 1

Syndrome of a Given Codeword is :
s =
0 0 1

The Error is in bit:
i =
7

The Corrected Codeword is :
r =
1 0 0 0 1 0 1