DimaA
Member level 3
scrambler and descrambler ber
I'm simulating a modem in Matlab.
The design has a data scrambler, I've noticed that introduces errors to the system.
If one bit in data stream in descrambler input is wrong ('0' instead of '1' or vice versa), there are 3 error bits at the output of descrambler.It means that scrambler adds two error bits to the system. Because of this, there is serious degradation in system's performance, about 2 dB. No error correction code is used.
Is this okey situation? Does it really should add error bits if there is an error at the input?
these are my code for scrambler and descrambler:
scrambler:
descrambler:
procedure to check the scrambler's performance:
Any help would be appreciated
I'm going to contribute 30 points to person who will solve this problem!
I'm simulating a modem in Matlab.
The design has a data scrambler, I've noticed that introduces errors to the system.
If one bit in data stream in descrambler input is wrong ('0' instead of '1' or vice versa), there are 3 error bits at the output of descrambler.It means that scrambler adds two error bits to the system. Because of this, there is serious degradation in system's performance, about 2 dB. No error correction code is used.
Is this okey situation? Does it really should add error bits if there is an error at the input?
these are my code for scrambler and descrambler:
scrambler:
Code:
%scramler based on primitive polynome 1+x^14+x^15
function out=scrambler(x)
N=length(x);
%Scrambler initialization section
if x(1:2)==[0 0], y(1:15)=[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]; end;
if x(1:2)==[0 1], y(1:15)=[0 1 1 1 0 0 0 0 1 1 1 1 1 1 1]; end;
if x(1:2)==[1 0], y(1:15)=[0 1 1 1 1 1 1 1 0 0 0 0 0 0 0]; end;
if x(1:2)==[1 1], y(1:15)=[0 1 1 1 1 0 0 0 0 0 0 0 1 1 1]; end;
output(1:N)=0;
for i=1:N
output(i)=xor(x(i),xor( y(15) ,y(14)));
y(15:-1:2)=y(14:-1:1); % shift register
y(1)=output(i);
end;
out=output;
descrambler:
Code:
function out=descrambler(x)
N=length(x);
if x(1:2)==[0 0], y(1:15)=[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]; end;
if x(1:2)==[0 1], y(1:15)=[0 1 1 1 0 0 0 0 1 1 1 1 1 1 1]; end;
if x(1:2)==[1 0], y(1:15)=[0 1 1 1 1 1 1 1 0 0 0 0 0 0 0]; end;
if x(1:2)==[1 1], y(1:15)=[0 1 1 1 1 0 0 0 0 0 0 0 1 1 1]; end;
for i=1:N
out(i)=xor(x(i),xor( y(15) ,y(14)));
y(15:-1:2)=y(14:-1:1);
y(1)=x(i);
end;
procedure to check the scrambler's performance:
Code:
N=1e4;
x=randsrc(1,N,[0 1; 0.25 0.75]);% Generating random numbers with probability 0.25 for '0' and 0.75 for '1'
% This is done deliberately to get equal probability stream after scramble
out_scr=scrambler(x);
out_scr(10)=xor(out_scr(i),1); %adding error at bit numer 10
y=descrambler(out_scr);
err=sum(abs(x-y)) %counting number of errors
BER=err/N
Any help would be appreciated
I'm going to contribute 30 points to person who will solve this problem!