channel_decoding.m
资源名称:MIMO-OFDM.rar [点击查看]
上传用户:look542
上传日期:2009-06-04
资源大小:784k
文件大小:3k
源码类别:
传真(Fax)编程
开发平台:
Matlab
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 根据不同用户的信道编码参数,进行信道解码
- function decoded_user_bit = channel_decoding ( demod_user_bit ,ChCodingMethod,Dec_alg,L_total,Generator,Puncture,...
- N_iter,RateChCoding,Alpha,Turbo_frame,N_Turbo_frame, UserRS_Coding , UserTrellis,TraceBackLen, user_bit_cnt,...
- turn_on )
- if turn_on
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 使用Turbo码 + 交织
- if ChCodingMethod == 1
- % 先假设单用户情况
- soft_bits = demod_user_bit.';
- turbo_decoded = zeros(1,Turbo_frame*N_Turbo_frame);
- for n = 1:N_Turbo_frame
- soft_bits_frame = soft_bits(1,(n-1)*L_total/RateChCoding + 1:n*L_total/RateChCoding );
- yk = demultiplex(soft_bits_frame,Alpha,Puncture);
- % Scale the received bits
- % rec_s = 0.5*L_c*yk;
- rec_s = yk;
- % Initialize extrinsic information
- L_e(1:L_total) = zeros(1,L_total);
- for iter = 1:N_iter
- % Decoder one
- L_a(Alpha) = L_e; % a priori info.
- if Dec_alg == 0
- L_all = logmapo(rec_s(1,:), Generator, L_a, 1); % complete info.
- else
- L_all = sova0(rec_s(1,:), Generator, L_a, 1); % complete info.
- end
- L_e = L_all - 2*rec_s(1,1:2:2*L_total) - L_a; % extrinsic info.
- % Decoder two
- L_a = L_e(Alpha); % a priori info.
- if Dec_alg == 0
- L_all = logmapo(rec_s(2,:), Generator, L_a, 2); % complete info.
- else
- L_all = sova0(rec_s(2,:), Generator, L_a, 2); % complete info.
- end
- L_e = L_all - 2*rec_s(2,1:2:2*L_total) - L_a; % extrinsic info.
- end %iter
- % Estimate the info. bits
- xhat(Alpha) = (sign(L_all)+1)/2; % 硬判决
- turbo_decoded(1,(n-1)*Turbo_frame + 1:n*Turbo_frame ) = xhat(1:Turbo_frame);
- end
- decoded_user_bit = turbo_decoded';
- %err_bits = length(find(bits ~= turbo_decoded)) ;
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 使用卷积 + RS + 交织
- elseif ChCodingMethod == 2
- user_convdecode = vitdec(demod_user_bit,UserTrellis,TraceBackLen ,'cont','hard');
- user_convdecode = user_convdecode(TraceBackLen + 1:end);
- user_rsdecode = rsdeco(user_convdecode,UserRS_Coding(1),UserRS_Coding(2));
- decoded_user_bit = user_rsdecode(1:user_bit_cnt);
- end
- else
- decoded_user_bit = demod_user_bit > 0;
- end