DC Exps
DC Exps
import math
msg_list = []
len_list = []
# Calculation of entropy
entropy = 0
for i in range(no_of_msgs):
entropy += msg_list[i] * (math.log((1 / msg_list[i]), 2))
# Calculation of efficiency
efficiency = (entropy / length) * 100
print(f"Entropy: {entropy}")
print(f"Total Length: {length}")
print(f"Efficiency: {efficiency:.2f}%")
Exp 2
#transmission
#inputs
x1 = [1,1,0,0,0,0,1]
x2 = [1,1,1,1,0,0,1]
x3 = [1,0,1,1,0,0,1]
x4 = [0,0,0,0,1,0,1]
x5 = [0,0,1,0,1,0,1]
x6 = [0,0,1,0,1,0,1]
x7 = [1,0,1,0,0,0,1]
x8 = [0,1,0,0,1,0,1]
vrc = []
realvrc = []
x = [x1,x2,x3,x4,x5,x6,x7,x8]
for j in range (0,8):
b = sum(x[j])
if b % 2 == 0:
realvrc.append(0)
else:
realvrc.append(1)
print("VRC = ",realvrc)
for i in range (0,7):
a = x1[i]+x2[i]+x3[i]+x4[i]+x5[i]+x6[i]+x7[i]+x8[i]
if a % 2 == 0:
vrc.append(0)
else :
vrc.append(1)
print("LRC = ",vrc)
#reception
#outputs
y1 = [1,1,0,0,0,0,1,1]
y2 = [1,1,1,1,0,0,1,1]
y3 = [1,0,1,1,0,0,1,0]
y4 = [0,0,0,0,1,0,1,0]
y5 = [0,0,1,0,1,0,1,0]
y6 = [0,0,1,0,1,0,1,1]
y7 = [1,0,1,0,0,0,1,1]
y8 = [0,1,0,0,1,0,1,1]
y9 = [1,1,1,0,0,0,0,1]
for k in range(0,6):
if(vrc[k] == y9[k]):
continue
else:
c = k + 1
y = [y1[7],y2[7],y3[7],y4[7],y5[7],y6[7],y7[7],y8[7]]
for m in range(0,7):
if(realvrc[m] == y[m]):
continue
else:
print("Even Parity not satisfied at", m+1,"th column of VRC")
print("Even Parity not satisfied at", k+1,"th row of LRC")
print( 'bit',c ,'of',x[m+1])
Exp 3
clc ;
clear all ;
P = input ( "enter the parity matrix " )
disp ( P )
k = input ( "enter the value of k " )
n = input ( "enter the value of n " )
I = eye ( 3 , 3 ) ;
disp ( I )
G=[IP]
disp ( G )
M = input ( "enter the message matrix " )
C=M*G
c1 = modulo ( C, 2 )
disp ( c1 )
disp ( P ' )
H = [ P'I ] ;
disp ( H ' )
disp ( "enter the vector to be checked " )
X = input ( "enter the code for error detection " )
E = modulo ( X * H ' , 2 )
disp ( "error = " ) ;
disp ( E ) ;
if E == [ 0 , 0 , 0 ] then
disp ( "the code vector does not have any error" ) ;
else
disp ( "the code vector has an error" )
end
for t = 1 : k
if H ( : ,t ) == E ' then
disp ( "error bit of code vector=" ) ;
disp ( t ) ;
X ( 1 ,t ) = bitcmp ( X ( 1 ,t ) , 1 ) ;
disp ( "corrected code vector is " ) ;
disp ( X ) ;
end
end
Exp 4
clc;
clear all;
n=input("Enter the value of n:");
k=input("Enter the value of k:") ;
for i = 1 : n - k + 1
x(i)=input("Enter the coefficients of Generator Polynomial:");
end
x1=poly(x,"p","coeff");
X=pol2str(x1);
disp("The Generator Polynomial is ");
disp("x(p)");
disp(X);
for j = 1 : k
m(j)=input("Enter the coefficients of message polynomial:");
end
ml = poly(m,"p","coeff");
M = pol2str(ml);
disp("The message Polynomial:");
disp("m(p)");
disp(M);
ul=x1*ml;
u=coeff(ul);
u2 = modulo(u,2);
u3=poly(u2,"p","coeff");
U=pol2str(u3);
disp("The Codeword polynomial is: ");
disp("u(p)");
disp(U);
l=length(u2);
if l<n then
for r = (l + 1) : n
u2(r) = 0;
end
end
disp("The Non-systematic Codeword");
disp("U(Non-systematic)");
z=n;
for t = 1 : n
g(t) = u2(z);
z = z - 1;
end
disp(g');
p=poly(0,"p");
p2=(p ^(n-k));
p3=pol2str(p2);
disp("Multiplication Polynomial");
disp(p3);
q=p2*ml;
q2=pol2str(q);
disp("Shifted Message=") ;
disp(q2);
[rem,quo]=pdiv(q,x1);
reml=coeff(abs(rem));
disp("Remainder Code: ");
disp(reml);
rem2=modulo(reml,2);
R=poly(rem2,"p","coeff");
P=pol2str(R);
disp("Remainder Polynomial =");
disp(P);
Q=q+R;
Q1=coeff(Q);
Q2=modulo(Q1,2);
Q3=poly(Q2,"p","coeff");
Q4=pol2str(Q3);
disp("The Systematic Polynomial:");
disp(Q4)
l1 =length(Q2);
if l1<n then
for v=(l1+1):n
Q2(v)=0;
end
end
NRZ L
NRZ M
NRZ S
BI PHASE L
BI PHASE M
BI Phase S
AMI Encoding
Decoding NRZ L
Decoding NRZ M
Decoding NRZ S
Decoding BI L
Line Encoding
Settings:
GP4
128Khz
Even
Line Decoding:
Change IN 16 to IN 17
AMI :
Change Out 10 to Out 11
Exp 6
ASK mod:
BPSK Mod
BPSK Demod
Exp 9