Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Scrambler - simulating a modem in Matlab

Status
Not open for further replies.

DimaA

Member level 3
Joined
Jan 19, 2004
Messages
66
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
563
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:
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!
 

scrambler descrambler ber

DimaA said:
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?

Yes, scrambler/descrambler multiply errors ....
 

Re: Scrambler

I see this problem like this:

every tap (in your case x**14 and x**15) in LFSR (linear-feedback shift register) of your polynomial adds one additional error in the receiver. So the sum of all errors is three since original error plus two tap errors equals three.

I'm not sure about your code since I don't understand the programming syntax.

Hope this helps,
rfmw
 

Re: Scrambler

So what's the solution? Is there any way to bypass this problem? It seems useless to use scrambler that take 2dB of overall performance.
 

Re: Scrambler

Simply divide the number of the received errors by three which will give you the number of error bits in the transmission ;)
 

Re: Scrambler

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:1)=[y(14:-1:1),x(i)]; % shift register
%y(1)=output(i);

end;
out=output;
this works good. and apfter descrambling introduces no error to sytem..
now think for 30 points
ur error is due to this statment
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(10)=xor(out_scr(i),1); %adding error at bit numer 10
here i is considered as imaginary part so it is giving error
make it like )=xor(out_scr(10),1); %adding error at bit numer 10
then 1 bit error corresponds to exactly 1 error is system performance
 
Last edited:

Re: Scrambler

So what's the solution? Is there any way to bypass this problem? It seems useless to use scrambler that take 2dB of overall performance.
Hi DimaA,

In the region of interest, the loss caused by scrambling/descrambling the data is less than what you mention.
For example, suppose that we are using a binary antipodal system (like polar binary NRZ or BPSK) and the goal is BER=1e-6. Then, the required Eb/No is 10.5 dB without scrambling.
If we use scrambling, as it multiplies by 3 the BER we would need a BER of 1/3*1e-6 before the descrambler (at the output of the channel). That means that the required Eb/No is now 10.9 dB (please see the corresponding curve).
The loss in this case is 0.4 dB. It would be lower if the required BER is less (for example if you repeat the calculation for 1e-9 instead of 1e-6). It is true that the loss is higher at more BER (it could be 2 dB maybe at BER=1e-2 or so) but normally that is not a case of interest.

The benefits of scrambling are worth a loss of a few tenths of dB.

Regards

Z
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top