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

📄 mrsc_encode.m

📁 OFDMA 物理层开发的matlab 源码.飞思卡尔提供.对物理层开发的工程师有帮助!
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Property of Freescale
%  Freescale Confidential Proprietary
%  Freescale Copyright (C) 2005 All rights reserved
%  ----------------------------------------------------------------------------
%  $RCSfile: mRSC_Encode.m.rca $
%  $Revision: 1.1 $
%  $Date: Mon Jan 22 10:37:34 2007 $
%  Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Double binary circular Turbo encoder
%
% y = mRSC_Encode(g, inputA, inputB) implements the double binary
% circular Turbo encoder defined in 8.4.9.2.3.1 CTC encoder
% IEEE Std 802.16 2004 P.594-P.595.
%
% Output:
% y => Each column of y is the output of one constituent encoder
%
% Inputs:
% g => Generator polynomial.
% inputA, inputB => Couples of original data A,B, refer to Figure 257
% in IEEE Std 802.16 2004 P.595
%


function y = mRSC_Encode(g, inputA, inputB)

[n,K] = size(g);
m = K - 1;

L_info = length(inputA);

%-- initialize the state vector
state = zeros(1,m);

%-- Two times encoder to get circular code
%-- 1st encoder
[n,k] = size(g);
m = k-1;

for i = 1:(L_info)
    d_k1 = inputA(i);
    d_k2 = inputB(i);
    a_k = rem( g(1,:)*[d_k1 state]', 2 );
    a_k = xor(a_k,d_k2);
    % New state vector
    state = xor(state,d_k2);
    state = [a_k, state(1:m-1)];
end

%-- Search circulation state in LUT table
look_up_table = [0 6 4 2 7 1 3 5;
    0 3 7 4 5 6 2 1;
    0 5 3 6 2 7 1 4;
    0 4 1 5 6 2 7 3;
    0 2 5 7 1 3 4 6;
    0 7 6 1 3 4 5 2];

i = mod (L_info,7);
j = state(1)*4 + state(2)*2 + state(3);
state_tmp = look_up_table(i,j+1);
% change decimal value to binary vector
state_2nd = mBin_state(state_tmp,3);



%-- 2nd encoder
for i = 1:L_info
    d_k1 = inputA(i);
    d_k2 = inputB(i);
    a_k = rem( g(1,:)*[d_k1 state_2nd]', 2 );
    a_k = xor(a_k,d_k2);
    [output_bits, state_2nd] = mTx_encode_bit(g, a_k, d_k2, state_2nd);

    % Since systematic, first output is input bits (inputA & inputB)
    output_bits(1) = d_k1;
    output_bits(2) = d_k2;
    y((n+1)*(i-1)+1:(n+1)*i) = output_bits;
end



% %proposed optimized for C code
% load CCenc_nible_LUT.mat
% state = zeros(1,m);
% current_state = bin2dec(num2str(state));
% Y =[];
% W =[];
% 
% for i = 0:((L_info/4)-1)
%     d_k1 = inputA(i*4+1:i*4+4);
%     d_k2 = inputB(i*4+1:i*4+4);
%     d_k1_num = bin2dec(num2str(d_k1));
%     d_k2_num = bin2dec(num2str(d_k2));
%     index    = 16*d_k1_num + d_k2_num;
%     outstate = CCenc_lut(current_state+1,2*index+1);
%     YW       = CCenc_lut(current_state+1,2*index+2);
%     current_state = outstate;
%     Y = [Y str2num(dec2bin(rem(YW,16),4)')'];
%     W = [W str2num(dec2bin(floor(YW/16),4)')'];    
% end
% 
% y(1,:) = inputA;
% y(2,:) = inputB;
% y(3,:) = Y;
% y(4,:) = W;






⌨️ 快捷键说明

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