📄 ctc_rscdec.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Property of Freescale
% Freescale Confidential Proprietary
% Freescale Copyright (C) 2005 All rights reserved
% ----------------------------------------------------------------------------
% $RCSfile: CTC_RSCDec.m.rca $
% $Revision: 1.1 $
% $Date: Mon Jan 29 18:11:35 2007 $
% Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Double binary circular Turbo decoder FIXED POINT VERSION
%
% msg_dec = CTC_RSCDec(yk, Nep, niter, g) implements the decoder
% of double binary circular Turbo encoder defined in 8.4.9.2.3
% Convolutional turbo codes IEEE Std 802.16 2004 P.594
%
% Output:
% msg_dec => Decoded bits stream
%
% Inputs:
% yk => Rearranged signal
% Nep => Size of one block.
% niter => No. of iterations
% g => Generator polynomial.
function msg_dec = CTC_RSCDec(yk, Nep, niter, g)
% Turbo code generator polynomials
% 8.4.9.2.3.1 CTC encoder IEEE Std 802.16-2004 P.594
g = [1 1 0 1;1 0 1 1;1 0 0 1];
% Temporary
L_c = 2;
% Calculation No. of couples in transmitted block
L_total = Nep/2;
% Interleaved address for CTC interleaver
alpha = mTx_add_inter (L_total);
% Initialize extrinsic information
%Infty = 1.4;
Infty = 0;
ln_p00(1:L_total) = -Infty*ones(1,L_total);
ln_p01(1:L_total) = -Infty*ones(1,L_total);
ln_p10(1:L_total) = -Infty*ones(1,L_total);
ln_p11(1:L_total) = -Infty*ones(1,L_total);
% Initialize Alpha and Beta
Alpha_in1(1:8) = zeros(1,8);
Beta_in1(1:8) = zeros(1,8);
Alpha_in2(1:8) = zeros(1,8);
Beta_in2(1:8) = zeros(1,8);
for iter = 1:niter
% First decoder (need to be deinterleaved)
% Deinterleaving the priori info. from 2nd decoder
for j = 1:L_total % updated for std compliancy
L_a_p00(alpha(j)+1) = ln_p00(j)*0.75; % a priori info. for couple 00.
L_a_p01(alpha(j)+1) = ln_p01(j)*0.75; % a priori info. for couple 01.
L_a_p10(alpha(j)+1) = ln_p10(j)*0.75; % a priori info. for couple 10.
L_a_p11(alpha(j)+1) = ln_p11(j)*0.75; % a priori info. for couple 11.
end
for j = 1:L_total
if (mod(j,2) == 0) % updated for std compliancy
tmp_L = L_a_p10(j);
L_a_p10(j) = L_a_p01(j);
L_a_p01(j) = tmp_L;
end
end
%-- CTC_MAPDec
[L_00, L_01, L_10, L_11, ln_p00, ln_p01, ln_p10, ln_p11, Alpha_out1, Beta_out1] = ...
CTC_MAPDec (yk(1,:), g, L_a_p00, L_a_p01, L_a_p10, L_a_p11, Alpha_in1, Beta_in1);
%Update Alpha_in and Beta_in
Alpha_in1(1:8) = Alpha_out1(1:8);
Beta_in1(1:8) = Beta_out1(1:8);
% Second Decoder
% Interleaving the priori info. from 1st decoder
for j = 1:L_total
if (mod(j,2) == 0) % updated for std compliancy
tmp_L = ln_p10(j);
ln_p10(j) = ln_p01(j);
ln_p01(j) = tmp_L;
end
end
for j = 1:L_total % updated for std compliancy
L_a_p00(j) = ln_p00(alpha(j)+1); % a priori info. for couple 00.
L_a_p01(j) = ln_p01(alpha(j)+1); % a priori info. for couple 01.
L_a_p10(j) = ln_p10(alpha(j)+1); % a priori info. for couple 10.
L_a_p11(j) = ln_p11(alpha(j)+1); % a priori info. for couple 11.
end
%-- mCTC_MAPDec
[L_00, L_01, L_10, L_11, ln_p00, ln_p01, ln_p10, ln_p11, Alpha_out2, Beta_out2] = ...
CTC_MAPDec (yk(2,:), g, L_a_p00, L_a_p01, L_a_p10, L_a_p11, Alpha_in2, Beta_in2);
Alpha_in2 = Alpha_out2;
Beta_in2 = Beta_out2;
end %iter
% Deinterleaving posteriori info.
for j = 1:L_total % updated for std compliancy
L_final_00(alpha(j)+1) = L_00(j);
L_final_01(alpha(j)+1) = L_01(j);
L_final_10(alpha(j)+1) = L_10(j);
L_final_11(alpha(j)+1) = L_11(j);
end
for j = 1:L_total
if (mod(j,2) == 0) % updated for std compliancy
tmp_L = L_final_10(j);
L_final_10(j) = L_final_01(j);
L_final_01(j) = tmp_L;
end
end
% Hard Decision (pick the maximum one as the decoded pair)
for i = 1:L_total
tmp = max(max(L_final_00(i),L_final_01(i)), max(L_final_10(i),L_final_11(i)));
if tmp == L_final_00(i)
y(1,i) = 0;
y(2,i) = 0;
elseif tmp == L_final_01(i)
y(1,i) = 0;
y(2,i) = 1;
elseif tmp == L_final_10(i)
y(1,i) = 1;
y(2,i) = 0;
elseif tmp == L_final_11(i)
y(1,i) = 1;
y(2,i) = 1;
end
end
% Parallel to Serial Convert
% for i = 1:L_total
% msg_dec(1,2*i-1) = y(1,i);
% msg_dec(1,2*i) = y(2,i);
% end
msg_dec = reshape(y,1,L_total*2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -