Experiment No 9 (A) Experimental Study of Cyclic Encoder and Decoder
Experiment No 9 (A) Experimental Study of Cyclic Encoder and Decoder
9.1 Theory
Cyclic codes are known to be a crucial subcategory of linear coding technique because these
offers efficient encoding and decoding schemes using a shift register. These are used in error
correction as they can check for double or burst errors. Various other important codes like,
Reed Solomon, Golay, Hamming, BCH, etc. can be represented using cyclic codes.Basically,
a shift register and a modulo-2 adder are the two crucial elements considered as building blocks
of cyclic encoding. Using a shift register, encoding can be efficiently performed. The
fundamental elements of shift registers are flip flops (that acts as a storage unit) and input-
output. While the other i.e., a binary adder has two inputs and one output.
According to this property, after a right or left shift in the bits of codewords the resultant code
generated must be another codeword.
1
For non-systematic code, the codeword is given as:
𝐶(𝑥) = (𝑋 2 + 𝑋 + 1)(𝑋 3 + 𝑋 + 1)
𝐶(𝑥) = (𝑋 5 + 𝑋 3 + 𝑋 2 + 𝑋 4 + 𝑋 2 + 𝑋 + 𝑋 3 + 𝑋 + 1)
Here modulo 2 addition will be performed and in modulo 2 addition, the sum of 2 similar bits
results in 0.
𝐶(𝑥) = (𝑋 5 + 𝑋 4 + 1)
Hence, from the above codeword polynomial, the codeword will be:
C = [1000110]
From the codeword bits, we can clearly interpret that the encoded codeword contains the
message and parity bits in an intermixed pattern. Thus, is a non- stematic codeword and direct
determination of message bits is not possible.
The equation for determining 7 bits codeword for systematic code is given as:
𝑋 𝑛−𝑘 𝑀(𝑋)
𝑃(𝑋) = 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 { }……………………..(9.3)
𝐺(𝑥)
Since n= 7 and k = 4.
2
𝑋 𝑛−𝑘 𝑀(𝑋) 𝑋 3 (𝑥 3 +𝑥 2 +1
𝑃(𝑋) = 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 { } ={ }
𝐺(𝑥) 𝑥 3 +𝑥+1
𝑋 𝑛−𝑘 𝑀(𝑋) (𝑥 6 +𝑥 5 +𝑥 3
𝑃(𝑋) = 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 𝑜𝑓 { } ={ }
𝐺(𝑥) 𝑥 3 +𝑥+1
C(X) = X3 (X3 + X2 + 1) + 1
C(X) = 1 + X3 + X5 + X6
So, the codeword for the above code polynomial will be: C = [1001011].
So, here the first 3 bits are parity bits and the last four bits are message bits. And we can
cross-check that we have considered [1011] as the message bits and parity polynomial
remainder was 1 i.e., code [100].Hence, in this way encoding of non-systematic and
systematic codewords is performed.
MATLAB software
9.3.1 Write code for enoding of systematic cyclic code with using MATLAB.
Solution:
Code:
clc; Parity = [];
clear all; s0 = [0];
close all; s1 = [0 0];
syms x; for l=1:k
in = input('Enter the order of cyclic code: '); d=zeros(1,k);
n = in(1); d(1,l) = 1;
k = in(2);
q = n-k; D= poly2sym(d);
g = input('Enter the generator polynomial of N=(x^q)*D;
order (n-k): '); Nr = sym2poly(N);
G = poly2sym(g); Num = fliplr(Nr);
disp('The Generator Polynomial: '); [Q,p] = gfdeconv(Num,Den);
disp(G); P=fliplr(p);
Den = fliplr(g); s=size(P);
Gen = []; if (size(P)==size(s1))
b = xor(b,(D(i,l)*Gen(l,j))); P=horzcat(s0,P);
end else if(size(P)==size(s0))
c(i,j)=b; P=horzcat(s1,P);
b=0; end
3
end end
end C =[d,P];
disp('All the generated codewords: '); Gen = vertcat(Gen,C);
disp(c); Parity = vertcat(Parity,P);
In = eye(n); end
disp('Error Vector disp('Generator Matrix: ');
Syndrome'); disp(Gen);
syn = [In, Ht]; disp('Parity Matrix: ');
disp(syn); disp(Parity);
Y = input('Enter the message polynomial of
length n: '); Pt = (Parity)';
y = fliplr(Y); Iq = eye(q);
[Qu,s]=gfdeconv(y,Den); H = [Pt, Iq];
if (size(s)==size(s1)) disp('Parity Check matrix is: ');
s = horzcat(s,s0); disp(H);
else if (size(s)==size(s0)) Ht = H';
s = horzcat(s,s1); D = 0:power(2,k)-1;
end D = dec2bin(D)-48;
end b= 0;
disp('Syndrom is: '); for i=1:2^k
S = fliplr(s); for j=1:n
disp(S); for l=1:k
e=zeros(1,n);
for i=1:1:size(Ht)
if(Ht(i,1:q)==S)
e(i) = 1;
break;
end
end
disp('The Error is in bit:')
disp(i);
disp('The Error Vector corresponding to
Syndrome is:');
disp(e);
disp('The corrected Codeword is:');
Codeword=xor(Y,e);
disp(Codeword);
Output:
4
Generator Matrix: All the generated codewords:
1 0 0 0 0 0 1 0 0 0 0 0 0 0
0 1 0 0 0 1 1 0 0 0 1 0 0 1
0 0 1 0 0 1 0 0 0 1 0 0 1 0
0 0 0 1 0 0 1 0 0 1 1 0 1 1
0 1 0 0 0 1 1
Parity Matrix: 0 1 0 1 0 1 0
0 0 1 0 1 1 0 0 0 1
0 1 1 0 1 1 1 0 0 0
0 1 0 1 0 0 0 0 0 1
0 0 1 1 0 0 1 0 0 0
1 0 1 0 0 1 1
0 0 0 0 1 0 0 1 1 0 0 0 1 0
0 1 1 0 0 1 0 1 1 0 1 0 1 1
1 1 0 1 0 0 1 1 1 1 0 0 0 0
1 1 1 1 0 0 1
5
Error Vector Syndrome
1 0 0 0 0 0 0 0 0 1
0 1 0 0 0 0 0 0 1 1
0 0 1 0 0 0 0 0 1 0
0 0 0 1 0 0 0 0 0 1
0 0 0 0 1 0 0 1 0 0
0 0 0 0 0 1 0 0 1 0
0 0 0 0 0 0 1 0 0 1