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

📄 dl_2_start.m

📁 一个WCDMA接收机的matlab程序
💻 M
字号:
function [size, crc, chCode, C, control,ratem_flag] = dl_start(nCode, c_type, Kindex, nFrames,tx_ch)%%%%% MIGHT WANNA ADD LATER tx_ch_type%% nCode = spreading factor% 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 transport channel			  %         3 = Secondary common control physical channel (FACH or PCH)			  %         2 = Primarly common control physical cahnnel (NO CRC)% OUTPUTS: % size = [N b_frame nFrames N_offset nSlot]% crc = [nCRC poly]% chCode = [c_type K tail poly]% control = [nPilot TPC TFI] % code = [nCode C]% %% N = User input block size% N_frame = number of coded bits in one frame% K = Coding ratio  (output values: 2 or 3)% nTail = tail length% nPilot  = number of Pilot bits per slot% TPC  = number of power bits per slot% TFI = number of TFI bits per slot% ratem_flag = 0 or 1 depending if ratematching is used or not%% ***************************************************************% Common parameters to all Downlink transport channelsR = 4096000;        % chips /snSlot = 16;         % Number of slots per frame same as wcdma_config.h = SLOTS_IN_FRAMEtFrame = 1/100;     % 10 ms = frame time                     % Simulink s-functions use TD_FRAME = 1 defined in wcdma_config.h    nCRC = 16 ;                     % Number of CRC bits;      crc_q ='1321';                  % CRC polynomial     CRCQ = base2dec(crc_q,16);      % same in decimal representation    crc = [nCRC CRCQ];% ***************************************************************% IF CONVOLUTIONAL CODING IS USED% *************************************************************** if (c_type == 1)% The Generator polynomials for convolutional coding and decoding     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;      poly = [base2dec(p1_o,Base) base2dec(p2_o,Base) base2dec(p3_o,Base)];     %*****************************************     % CODING RATIO     if (Kindex ~= 2)         disp('Only coding ratio 3 is implemented currently.');         disp('K = 3 will be used in the simulations'); 	end;      K = 3 ;  tail = 8;       nPilot = 8;  TPC = 3;    TFI = 2;     % If not Dedicated transport channel update the following parameters:     if(tx_ch == 3)          TPC = 0;    TFI = 0;                 % Secondary common control     elseif(tx_ch == 2)          TPC = 0;    TFI = 0;  nCRC = 0;       % Primary common control	  crc = [nCRC CRCQ];     end;     chCode = [c_type  K tail poly];     control = [nPilot TPC TFI];     %*****************************************     % SPREADING CODE  FOR SECOND CHANNEL     % if the spreading code has not been assigned     if length(nCode) < 2           C = [ones(1,nCode / 2) -ones(1,nCode/2)];		% for(i = 1:nCode)  C(i) = (-1)^i; end;      else  % if the spreading code has already been assigned            C = nCode;           nCode = length(C);     end;     %*****************************************     % NUMBER OF BITS IN FRAME AND SLOT ETC     total_bits = R/nCode * 2 ;     bits_slot = total_bits * tFrame / nSlot ;      coded_bits_frame = (bits_slot - nPilot -TPC - TFI) * 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];     %*****************************************     % NUMBER OF BITS IN FRAME AND SLOT ETC     ratem_flag = 0;     return;end;% ***************************************************************% IF Turbo coding is used NOT IMPLEMENTED YETif (c_type > 1)    disp('Only the convolutiona channel coding (1/3, 9) is implemented currently');size = 0;crc =0;ratem_flag = 0; C = 0;chCode = 0;control =0;    return;end;

⌨️ 快捷键说明

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