0% found this document useful (0 votes)
67 views

%% Implementation of Generation and Decoding of Cyclic Codes

This document summarizes the implementation of cyclic code generation and decoding. It generates a (7,4) cyclic code with generator polynomial g=x^3+x+1. It calculates the generator matrix G and parity check matrix H. It then demonstrates the encoding and decoding of a received codeword r, finding the error location through syndrome calculation and correcting the codeword.

Uploaded by

Denise Nelson
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

%% Implementation of Generation and Decoding of Cyclic Codes

This document summarizes the implementation of cyclic code generation and decoding. It generates a (7,4) cyclic code with generator polynomial g=x^3+x+1. It calculates the generator matrix G and parity check matrix H. It then demonstrates the encoding and decoding of a received codeword r, finding the error location through syndrome calculation and correcting the codeword.

Uploaded by

Denise Nelson
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

%% Implementation of Generation and Decoding of Cyclic codes clc clear all n=input('enter the order of the code= ');

k=input('enter the order of the message= '); x=sym('x'); ik=eye(k) ink=eye(n-k); g=input('Enter the Generator Polynomial in terms of bits having the order of n-k ='); disp('Generator polynomial'); gp=poly2sym(g) % gp=1+x^2+x^3 jk=x^(n-k); for i=1:k xk=poly2sym(ik(i,:)); y=xk*jk;A [qp,remp]=quorem(y,gp); % z(i,:)=y+remp a(i,:)=mod(remp,2); end a p=input('enter the parity matrix='); disp('Generator Matrix:'); G=cat(2,ik,p) m=2^k; a=[0:m-1]; %Left MSB Return MSB to L.H.S d=de2bi(a); b=d*G; codewords=rem(b,2) dmin=gfweight(G) td=dmin-1 tc=td/2 H=[p' ink] Ht=H' z=zeros(1,n); e=eye(n); E=[z;e] a1=E*Ht; %% Decoding Table Dec=[E a1] %% checking Validity of the Received Codewor r=input('Enter the Received Code r='); rp=poly2sym(r) [qp,remp]=quorem(rp,gp); disp('Syndrome polynomial:'); % disp(remp); remp=mod(remp,2); s=sym2poly(remp); % s=mod(rem,2); disp('Syndrome :');disp(remp); s=input('enter the syndrome having size 1x3=') if (s == 0)

disp('The received code is correct'); else for j=1:1:length(E) m=xor(s,a1(j,:)); if (m==0) row = j; break; end end disp('The Corrected codeword is=') rc=xor(r,E(j,:)) end

enter the order of the code= 7 enter the order of the message= 4

ik =

1 0 0 0

0 1 0 0

0 0 1 0

0 0 0 1

Enter the Generator Polynomial in terms of bits having the order of n-k =[1 0 1 1] Generator polynomial

gp =

x^3 + x + 1

a=

x^2 + 1 x^2 + x + 1 x^2 + x x+1

enter the parity matrix=[1 0 1;1 1 1;1 1 0;0 1 1] Generator Matrix:

G=

1 0 0 0

0 1 0 0

0 0 1 0

0 0 0 1

1 1 1 0

0 1 1 1

1 1 0 1

codewords =

0 1 0 1 0 1

0 0 1 1 0 0

0 0 0 0 1 1

0 0 0 0 0 0

0 1 1 0 1 0

0 0 1 1 1 1

0 1 1 0 0 1

0 1 0 1 0 1 0 1 0 1

1 1 0 0 1 1 0 0 1 1

1 1 0 0 0 0 1 1 1 1

0 0 1 1 1 1 1 1 1 1

0 1 0 1 1 0 1 0 0 1

0 0 1 1 0 0 0 0 1 1

1 0 1 0 0 1 1 0 0 1

dmin =

td =

tc =

H=

1 0 1

1 1 1

1 1 0

0 1 1

1 0 0

0 1 0

0 0 1

Ht =

1 1 1 0 1 0 0

0 1 1 1 0 1 0

1 1 0 1 0 0 1

E=

0 1 0

0 0 1

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0 0 0

0 0 0 0 0

1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

0 0 0 1 0

0 0 0 0 1

Dec =

0 1 0 0 0 0 0 0

0 0 1 0 0 0 0 0

0 0 0 1 0 0 0 0

0 0 0 0 1 0 0 0

0 0 0 0 0 1 0 0

0 0 0 0 0 0 1 0

0 0 0 0 0 0 0 1

0 1 1 1 0 1 0 0

0 0 1 1 1 0 1 0

0 1 1 0 1 0 0 1

Enter the Received Code r=[1 1 0 1 1 0 1]

rp =

x^6 + x^5 + x^3 + x^2 + 1

Syndrome polynomial:

Syndrome : x^2

enter the syndrome having size 1x3=[1 0 0]

s=

The Corrected codeword is=

rc =

>>

You might also like