www.pudn.com > wcdma_simulink.rar > utra.m


%
% Project:     WCDMA simulation environment
% Module:      
% Author:      
% Date:        February, 1999
%
% History:
% 
%              April 22,  1999 Maarit Melvasalo 
%              This file was rewritten to it's current format
%
% Description: 
%              This file is a initialsation file for the UTRA model.
%              All the parameters are defined here. 
%
%              Most of the parameters can be changed directly from 
%              Simulink. 
%
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% NOTE: If you change anything inhere remember to call this file once from the
%       main matlab workspace to update it for simulink!!!!! 
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                % these are define here so that they would be the same for all
                % the blocks
                % THIS CAN BE CHANGED (but be careful):
%___________________________________________________________________________
if (exist('link','var')>0)
link

%if link ==  1  %downlink = 1 / uplink = 2  parametrit muuttuvat

end;

%kana =[1 0; 0.9 0.1];
%viive=[0 1];
%aika =10;
%___________________________________________________________________________
% GENERAL


N = 80 ;        % Number of bits in one packet
nPackets = 3;    % Number of packets send during simulation (=simulation duration)
% Tama ei onnistu silla ei vality muihin muuttujiin if (exist('N','var')<1)end;

%___________________________________________________________________________
% SPREADING CODE
                % used by discrete modulation and rake blocks
if (exist('C','var')<1) % if the code  has been defined in workspace do not change
% C=[1 1 1 ]
     C = [ 1 -1 1 -1 1 -1 1 1 -1 1 -1 1 1 -1 1 -1]; 
 end;


%___________________________________________________________________________
% ENCODER AND DECODER GENERATOR POLYNOMIALS

if (exist('p1_o','var')<1) % if the gnerator polynomials have been defined in workspace do not change
     Base = 8;  % indicates the base in which the numbers are given/**/
     p1_o = '557';  % desimal: 367;
     p2_o = '663';  % desimal: 435;
     p3_o = '711';  % desimal: 457; 
end

%___________________________________________________________________________

%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% CONSTANTS DO NOT CHANGE!!!!!
                % DO NOT CHANGE unless the c-code are updated!!!
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

K = 3;          % Channel coding ratio   
tail_len = 8;   % =  #define CONVOLUTION_TAIL_LEN  Number of tail bits 



var = 0; %noise variance /**/



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% DON'T CHANGE ANYTHING BELOW THIS LINE UNLESS YOU ARE
% ABSOLUTELY SURE WHAT YOU ARE DOING
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%        MODE DEFINITION FOR THIS FILE
%        - Some of the parameters only affect some model blocks.
%          Users can adjsut this parameters from simulink blocks directly.  
%        
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

if (exist('job','var')<1) job = 0; end;

job  ;
init = 0;        % job:  0 = Initialization
chcoding = 2;    % job:  2 = channel coding 
chdecoding = 3;  %       3 = channel decoding 
discmod = 4;     %       4 = discrete modulation
discdemod = 5;   %       5 = discrete demodulation
channel = 6;     %       6 = channel
rake = 7;        %       7 = rake




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%     INITIALIZATION
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% Initialization, only called at the main workspace of matlab
if ( (job == 0) )

%    chcoding: 

     ST = nPackets ;         % SIMULATION TIME

end;




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%     CHANNEL CODING  OR DECODING
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

if ( (job == chcoding) | (job == chdecoding) )

          % if the polynomials have been defined already.
     p1 = base2dec(p1_o,Base);
     p2 = base2dec(p2_o,Base);
     p3 = base2dec(p3_o,Base);

          % if probabilites for bits are not given or is plain 0
     if (exist('sp0','var')<1 | sp0 == 0)
          sp0 = [1 0];  % soft probabilities for value 0
          sp1 = [0 1]  % soft probabilities for value 1
     end; 

          % If the number of rows and colums given to interleaver is not acceptalbe
          % redifine them
     if ((rows * cols) ~= (K * N)) 
          rows = 12 ;              % for interleaver
          cols = (K *N) /rows;    % for interleaver
     end;

          % Size of input vector for decoder
     deInputs = K*N;

end; 

%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%     DISCRETE MODULATIO (DOWNLINK)
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

if ( (job == discmod) | (job == discdemod) )

          % Size of input vector for modulator
     nInputs = N * K;
     deInputs = 10;
end;

%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%     CHANNEL 
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

if ( job == channel) 

%    channel :

     HR=HR' ; % This is only to simplify the c-code 
     HD=HD' ;
          % Size of the input vector given to channel block
    nInputs = K*N*length(C) / 2;
end;

%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%     RAKE
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

if (job == rake) 
    nInputs = K*N*length(C) / 2;
end;


% HUOM LAITA TARKISTUS ETTA SF <= LENGTH(C) MUUTEN KAATUU!!!!!!!!!!! (10.5.)






%___________________________________________________________________________