⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ul_start.m

📁 MATLAB仿真WCDMA
💻 M
字号:
function [size, crc, chCode, CD, CC, control] = ul_start(d_Code, c_Code, c_type, Kindex, nFrames,tx_ch)%%% FUNCTION:     ul_start      % AUTHOR:       Maarit Melvasalo% DATE:         April 21, 1999%% DESC:         This fuction set values for downlink transport channels%               defined in Simulink library:  utra_lib %               These values have been obtained from ETSI UTRA %               for ITU-R RTT.  %% NOTE:         Parameter value may be changed, but be carefully!%               Do not change the calcutions.   %% HISTORY:      June 17,1999 Maarit Melvasalo%                   Comments added%% *******************************************************************%% INPUTS:%%  d_Code  = [code_length, index] = %            spreading factor and index for data channel %  c_Code  = [code_length, index] = %            spreading factor and index for control channel %  c_type  = mode indicating the channel coding scheme%       1  = Convolutional coding with   %       3  = Turbo coding (NOT YET)%  K_index = Coding ratio (input values: (1,2)%  nFrames = number of frames in each block interleaver%  tx_ch   = transport channel type%%         1 = Dedicated physical channel (both data and control channels)%         2 = Physical random acces channel (both data and control channels) %% OUTPUTS: %% size = [N = input_block_size bits_in_frame nFrames N_offset nSlot chips_in_slot]%             input_block_size= number of bits in each input block (calculated)%             bits_in_frame   = number of coded bits in one frame (calculated)%                               Note that this does not include contorl bits%             nFrames         = number of frames in each block (given by user) %             N_offset        = offset required to obtain correct blocksize (calculated)%                               after channel coding (and before interleaving)%             nSlot           = number of slots in frame (set by user)%             chips_in_slot   = number of slots in frame (constant for given bit bandwidth)%% crc = [nCRC poly] %             nCRC  = number of CRC bits  (set by user) different for different %                     physical channels%             poly  = generating polynomial for CRC (set by user)%% chCode = [c_type K tail poly]%             c_type  = channel type (given in function call = set by user) %             K       = Coding gain  (given in function call = set by user) %             tail    = Coding tail length  (set by user)%             poly    = Generating polynomials for channel coding (set by user)%% CD = spreading code for data channel%% CC = spreading code for control channel%% control = [nPilot TPC TFI] %             nPilot  = number of Pilot bits (given by user) %             TPC     = number of Power control bits (given by user) %             TFI     = number of Transport Format Indicator bits (given by user)  % %% ***************************************************************%% Common parameters to all Up and Downlink transport channels%% ***************************************************************      R = 4096000;        % chips /s      nSlot = 16;         % Number of slots per frame same as                           % wcdma_config.h = SLOTS_IN_FRAME      tFrame = 1/100;     % 10 ms = frame time                           % Simulink s-functions use TD_FRAME = 1                           % defined in wcdma_config.h      chips_in_slot = R/nSlot * tFrame;                            % Number of chips in each slot (constant) % ***************************************************************%%        CRC Basic settings  (for data channel)%% ***************************************************************     nCRC = 16 ;                     % Number of CRC bits;      crc_q = '1021';                  % ARIB  in decimal presentation  4129    CRCQ = base2dec(crc_q,16);      % same in decimal representation    crc = [nCRC CRCQ]; % ***************************************************************% ***************************************************************%%       CONVOLUTIONAL CODING PARAMETERS (for data channel)%% *************************************************************** if (c_type == 1)%*****************************************% CODING RATIO% Kindex == 1 -> K = 2; % Kindex == 2 -> K = 3;     K = Kindex + 1 ;  tail = 8;  % The Generator polynomials for convolutional coding and decoding% see UTRA specification chapter 5.2.1.1.1      Base = 8;  % indicates the base in which the numbers are given     if (K == 3)         p1_o = '557';  % desimal: 367;         p2_o = '663';  % desimal: 435;	 p3_o = '711';  % desimal: 457;      else          p1_o = '561';  % desimal: 367;	 p2_o = '753';  % desimal: 435;	 p3_o = '0';    % desimal: N/A;      end;     poly = [base2dec(p1_o,Base) base2dec(p2_o,Base) base2dec(p3_o,Base)];     chCode = [c_type  K tail poly];%*****************************************%%      SPREADING CODE FOR DATA CHANNEL %%*****************************************          % if the spreading code has not been assigned     if ( length(d_Code)  < 3)                % set the code index for a inital value            index = d_Code(1) / 2 ;           % If the code index has been defined by the function call           % check that is            if ((length(d_Code) == 2) & ((index <= d_Code) & (index >0) ))                 index = d_Code(2);     end;	   CD = get_ovsf_code(d_Code(1),index);                      end;      if ( length(d_Code) > 2) % if the spreading code has already been assigned            CD = d_Code;           d_Code = length(CD);     end;% *************************************************************** %%      NUMBER OF BITS IN DATA CHANNEL %      BLOCK, FRAME AND SLOT ETC %           %              DO NOT CHANGE!!!!!!!!%% ***************************************************************      total_bits = R/d_Code(1);     coded_bits_frame = total_bits * tFrame;      data_bits_in_slot = coded_bits_frame / nSlot ;      % Size of the inputblock to CRC must be * 8      N_total = nFrames * coded_bits_frame - tail  ;     N_tmp = floor(N_total / K);     if( nCRC > 0)         N_tmp = 8 * floor(N_tmp / 8)  ;     end;     N = N_tmp - nCRC ;     N_offset = N_total - N_tmp*K;     size =[N coded_bits_frame nFrames N_offset nSlot chips_in_slot];% ***************************************************************%%      CONTROL CHANNEL DEFINITONS (for control channel)%% *************************************************************** %*****************************************%%      SPREADING CODE FOR CONTROL CHANNEL %%*****************************************          % if the spreading code has not been assigned     if ( length(c_Code)  < 3)                % set the code index for a inital value            index = c_Code(1) / 2 + 1;           % If the code index has been defined by the function call           % check that is            if ((length(c_Code) == 2) & ((index <= c_Code) & (index >0) ))                 index = c_Code(2);     end;	   CC = get_ovsf_code(c_Code(1),index);                      end;      if ( length(c_Code) > 2) % if the spreading code has already been assigned            CC = c_Code;           c_Code = length(CC);     end;% ***************************************************************%%      NUMBER OF CONTROL BITS%% ***************************************************************      TPC = 3;    TFI = 2;     bits_in_slot = R/c_Code(1)* tFrame /nSlot; % =number of bits in slot     nPilot = bits_in_slot - TPC -TFI;     control = [nPilot TPC TFI];     return;end;  % ***************************************************************%       END of CONVOLUTIONAL CODING% ***************************************************************     % ***************************************************************%%       TURBO CODING PARAMETERS%%       NOT IMPLEMENTED YET%% *************************************************************** if (c_type > 1)    disp('Only the convolutiona channel coding is implemented currently');size = 0;crc =0;CC = 0;CD = 0;chCode = 0;control =0;    return;end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -