Script de simulation Scilab
fr - eng


Système à étalement de spectre en séquences directes


Contenu

Module

Script(s) de simulation


//shift_chip : shift circulate chip
// n : number of shift
function chip_out=shift_chip(chip_in,n)

  chip_out = chip_in;
  for i = 1:n
    chip_out = [ chip_out(2:$) ; chip_out(1) ]
  end

endfunction

sav_lines=lines();
lines(-1);

//Gold sequences generation
chip_i = gengold(5,[21;9],[13;15]);
chip_q = gengold(5,[21;9],[13;10]);

//shift sequence for receiver
chip_ir = shift_chip(chip_i,15);
chip_qr = shift_chip(chip_q,15);

//compute Root Raised Cosine impulse
//roll-off=0.35, length 128
pulse = filter_tap(1,128,8,0.35,1);

//number of symbols by step
Ns = 5000;

//power of white noise in the AWGN channel
sig_log=-12:1:-4;
Eb=cos(%pi*(1/(2^2)));
sig=[];
for i=1:size(sig_log,2)
  sig(i)=Eb/10^(sig_log(i)/10);
end

//initialize nb of ERROR
ERROR = zeros(size(sig,1),1);

//CDMA simulation function
//
//input : ERROR,sig,Ns
//output : ERROOR
function ERROR=CDMA_sim(ERROR,sig,Ns)
  for kk=1:3
    for k=1:size(sig,1)
      //y = genint(Ns,3,1,2);
      tic();
      
      //one vector of Ns symbols
      y = genint(Ns,1,1,2);

      //Q-PSK modulation
      [yi,yq] = modpsk(y,4);

      //spread
      yci = spread(yi,chip_i);
      ycq = spread(yq,chip_q);

      //up-sample by 8
      yi_s = upsmpl(yci,8,1);
      yq_s = upsmpl(ycq,8,1);

      //filtering vector of I/Q components
      i = nfilter(yi_s,pulse');
      q = nfilter(yq_s,pulse');

      //Additive wgn channel
      i_n = awgn(i,sig(k));
      q_n = awgn(q,sig(k));

      //filtering vector of I/Q components
      i_r = nfilter(i_n,pulse');
      q_r = nfilter(q_n,pulse');

      //first stage of receiver
      g_i = intsym(i_r,8,5);
      g_r = intsym(q_r,8,5);

      yi_s_r = sign(g_i);
      yq_s_r = sign(g_r);

      yci_r = downsmpl(yi_s_r,8);
      ycq_r = downsmpl(yq_s_r,8);

      //despread
      ycci_r = despread(yci_r,chip_ir);
      yccq_r = despread(ycq_r,chip_qr);

      //second stage of receiver
      gg_i = intsym(ycci_r,31,15);
      gg_r = intsym(yccq_r,31,15);

      yi_r = sign(gg_i);
      yq_r = sign(gg_r);

      y_ir = downsmpl(yi_r,31);
      y_qr = downsmpl(yq_r,31);

      //demodpsk
      yr=demodpsk(y_ir,y_qr,4);

      //compute number of error
      ERROR(k) = ERROR(k) + ...
                 size(find(double(y(1:size(yr(2:$-1),1)))-yr(2:$-1)<>0),'*');
      b=toc();
      printf("%f\n",b);
    end
  end
endfunction

//launch CDMA simulation function
ERROR=CDMA_sim(ERROR,sig)

//Compute teb and plot the trace
TEB=ERROR/(Ns*2);
plot_teb(49,sig_log,TEB,"1");

lines(sav_lines(2));
CDMA_sim.sce

Résultats des oscilloscopes

\begin{figure}\begin{center}
\epsfig{file=CDMA_sim_scope_1.eps,width=300.00pt}
\end{center}\end{figure}
Figure : Estimation du TEB pour une chaîne de transmission DS-CDMA simple utilisateur

Auteurs

A. Layec