没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
1
%------Jzobel----------------------------------------------------------------Jzobel--------------
%-------------------------------------TurboMatlab------------------------------
%------------------------------------------------------------------------------------------------
%This script simulates the classical turbo encoding-decoding system.
% It simulates parallel concatenated convolutional codes.
% Two component rate 1/2 RSC (Recursive Systematic Convolutional) component encoders are assumed.
% First encoder is terminated with tails bits. (Info + tail) bits are scrambled and passed to
% the second encoder, while second encoder is left open without tail bits of itself.
% -----------------------------------------------------------------------------------------------
% Random information bits are modulated into +1/-1, and transmitted through a AWGN channel.
% Interleavers are randomly generated for each frame.
%------------------------------------------------------------------------------------------------
% Log-MAP algorithm without quantization or approximation is used.
% By making use of ln(e^x+e^y) = max(x,y) + ln(1+e^(-abs(x-y))),
% the Log-MAP can be simplified with a look-up table for the correction function.
% If use approximation ln(e^x+e^y) = max(x,y), it becomes MAX-Log-MAP.
%------------------------------------------------------------------------------------------------
clear all
% Write display messages to a text file
diary turbo_logmap.txt
% Choose decoding algorithm
dec_alg = input(' Please enter the decoding algorithm. (0:Log-MAP, 1:SOVA) default 0 ');
if isempty(dec_alg)
dec_alg = 0;
end
% Frame size
L_total = input(' Please enter the frame size (= info + tail, default: 80) ');
if isempty(L_total)
L_total = 80; % infomation bits plus tail bits
end
% Code generator
g = input(' Please enter code generator: ( default: g = [1 1 1; 1 0 1 ] ) ');
if isempty(g)
g = [ 1 1 1;1 0 1 ];
end
% For example g = [1 1 0 1; 1 1 1 1];or g = [1 1 1 1 1; 1 0 0 0 1];
[n,K] = size(g); %g
m = K - 1; %
nstates = 2^m;
%puncture = 0, puncturing into rate 1/2;
%puncture = 1, no puncturing
2
puncture = input(' Please choose punctured / unpunctured (0/1): default 0 ');
if isempty(puncture)
puncture = 0;
end
% Code rate
rate = 1/(2+puncture);
% Fading amplitude; a=1 in AWGN channel
a = 1;
% Number of iterations
niter = input(' Please enter number of iterations for each frame: default 8 ');
if isempty(niter)
niter = 8;
end
% Number of frame errors to count as a stop criterior
ferrlim = input(' Please enter number of frame errors to terminate: default 2 ');
if isempty(ferrlim)
ferrlim = 2;
end
% Value of SNR db
EbN0db = input(' Please enter Eb/N0 in dB : default [2.0] ');
if isempty(EbN0db)
EbN0db = [2.0];
end
fprintf('\n\n----------------------------------------------------\n');
if dec_alg == 0
fprintf(' ======== Log-MAP decoder ======== \n');
else
fprintf(' ========= SOVA decoder ========= \n');
end
fprintf(' Frame size = %6d\n',L_total);
fprintf(' code generator: \n');
for i = 1:n
for j = 1:K
fprintf( '%6d', g(i,j));
end
fprintf('\n');
end
if puncture==0
fprintf(' Punctured, code rate = 1/2 \n');
else
fprintf(' Unpunctured, code rate = 1/3 \n');
end
fprintf(' iteration number = %6d\n', niter);
fprintf(' terminate frame errors = %d\n', ferrlim);
fprintf(' Eb / N0 (dB) = ');
3
for i = 1:length(EbN0db)
fprintf('%10.2f',EbN0db(i));
end
fprintf('\n----------------------------------------------------\n\n');
fprintf('+ + + + Please be patient. Wait a while to get the result. + + + +\n\n');
for nEN = 1:length(EbN0db)
en = 10^(EbN0db(nEN)/10); % convert Eb/N0 from unit db to normal numbers
L_c = 4*a*en*rate; % reliability value of the channel
sigma = 1/sqrt(2*rate*en); % standard deviation of AWGN noise
% Clear bit error counter and frame error counter
errs(nEN,1:niter) = zeros(1,niter);
nferr(nEN,1:niter) = zeros(1,niter);
nframe = 0; % clear counter of transmitted frames
while nferr(nEN, niter)<ferrlim
nframe = nframe + 1;
x = round(rand(1, L_total-m));
% info. bits
[temp, alpha] = sort(rand(1,L_total)); % random interleaver mapping-alpha
en_output = encoderm( x, g, alpha, puncture ) ; % encoder output (+1/-1)
r = en_output+sigma*randn(1,L_total*(2+puncture)); % received bits
yk = demultiplex(r,alpha,puncture); % demultiplex to get input for decoder 1 and 2
% Scale the received bits
rec_s = 0.5*L_c*yk;
% Initialize extrinsic information
L_e(1:L_total) = zeros(1,L_total);
for iter = 1:niter
% Decoder one
% deinterleave the extrinsic information for first decoder
L_a(alpha) = L_e; % a priori info.
if dec_alg == 0
L_all = log_map(rec_s(1,:), g, L_a, 1); % complete info.
else
L_all = sova(rec_s(1,:), g, 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 = log_map(rec_s(2,:), g, L_a, 2); % complete info.
剩余12页未读,继续阅读
资源评论
纸上谈芯
- 粉丝: 782
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- NetOps-py通过sftp替换网络设备启动文件
- STM32单片机FPGA毕设电路原理论文报告任务驱动教学法在单片机课程教学中的应用
- STM32单片机FPGA毕设电路原理论文报告任务驱动法在单片机教学中的应用
- STM32单片机FPGA毕设电路原理论文报告人造金刚石压机智能化压力测控系统设计
- 以某列为依据匹配多项(Excel版)
- STM32单片机FPGA毕设电路原理论文报告人体短臂离心机实验台的显示控制系统
- STM32单片机FPGA毕设电路原理论文报告人工气候室监控系统的环境控制器研究
- STM32单片机FPGA毕设电路原理论文报告染整自动线张力控制系统的设计
- 数据挖掘与机器学习-实验
- 基于Linux系统Nginx的动态网站的LNMP环境源码包
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功