%%%%这个函数用SCL的译码算法进行译码
%%y0是从信道来的接收向量
%%z用来指示信息位和固定位的位置
%%no_of_L是保留的路径个数 只可以取2的幂次 比如4 8 16
%%ccitt是CRC校验多项式
%%layer_number是把码树分的层数
function y=SCL_CRC_decoder(y0,z,no_of_L,ccitt,layer_number)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%初始化
[L xx]=size(y0); %%z用来指示自由位和固定位的位置,y0是从信道接收的列向量,L是码长
Lo=no_of_L; %%Lo是SCL中L的值
Flag=log2(Lo); %%Flag用于指示Lo条路径的选取方法的切换
u_matrix=zeros(Lo,L+1); %%是一个Lo*(L+1)的矩阵,每一行对应一串码字,最后一位是码串的概率
u_temp=zeros(2*Lo,2); %%存放2Lo个码字串的判断位置,用于选出Lo个码字串的临时矩阵
u_temp(1:2:2*Lo,1)=ones(Lo,1)
reserve_all=travel(Lo)
flag=0; %%表示当前还没有遇到第一个信息位
free_position=find(z==1); %%这个矩阵用来存放信息位的位置索引
free_length=length(free_position)%%信息位的长度
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% SCL译码
for i=1:L %%i表示已经判决了(i-1)个bit
% i
% u_matrix
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%矩阵初始化
% if i==1 %%此时是初始化u_matrix 既然码率不能达到1,那么第一位必然是固定位
% u_matrix(:,1)=zeros(Lo,1); %%第一位全部赋0
% %u_matrix(:,L+1)=ones(Lo,1); %%概率位置全部赋1
% continue;
% end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%i表示当前要判断码字中的第i位 flag表示要判断当前的第flag个信息
if z(i)==0 %%对于固定位置 在该位置为0的概率赋值1
u_matrix(:,i)=zeros(Lo,1);
else %%对于自由位 要分两种情况 1.需要全部保留路径 2.选取最优路径
flag=flag+1; %%此时的flag表示正在判断第几个信息位
% flag
if flag<=Flag %%此时要保留所有路径 并算概率
u_matrix(:,i)=reserve_all(:,flag);
if flag==Flag
for j=1:Lo %%j循环表示遍历Lo个码串
u_matrix(j,L+1)=channel_transfer(L,i,y0,u_matrix(j,1:i-1),u_matrix(j,i));
end
end
% u_matrix
else %%此时要选取最优路径
for j=1:Lo %%j循环表示遍历Lo个码串
u_temp(2*j-1,2)=channel_transfer(L,i,y0,u_matrix(j,1:i-1),1);
u_temp(2*j,2) =channel_transfer(L,i,y0,u_matrix(j,1:i-1),0); %%上两行计算了在当前条件下分别下一位取0和1的总路径概率
[vals,inds] =sort(u_temp(:,2),'descend'); %%将概率值降序排列
temp=[];
for k=1:Lo %%%这个循坏用于从2Lo个概率值中选取最优
if mod(inds(k),2)==1 %%奇数索引值表示最后一位是1,tempcode最后一位是该路径的概率
tempcode=[u_matrix((inds(k)+1)/2,1:i-1),1,vals(k)];
temp=[temp;tempcode];
else %%偶数索引表示最后一位是0 ,tempcode最后一位是该路径的概率
tempcode=[u_matrix(inds(k)/2,1:i-1),0,vals(k)];
temp=[temp;tempcode];
end
end %%end of k_cycle
end %%end of j_cycle
% temp
u_matrix(:,1:i)=temp(:,1:i);
u_matrix(:,L+1)=temp(:,i+1);
end %%end of if
if mod(flag,free_length./layer_number)==0 %%当判断的当前位置正好是层的边界时 进行CRC校验 并选择最大概率的输出
no_of_rank=flag./(free_length./layer_number); %%no_of_rank用来存放当前的层数
for ii=1:Lo
[values,index]=sort(u_matrix(:,L+1),'descend');
err=cyclic_redundancy_decode( u_matrix(index(ii),free_position((no_of_rank-1).*free_length./layer_number+1:no_of_rank.*free_length./layer_number)),ccitt );
if err == 0 %%校验式通过CRC
for jj=1:Lo
u_matrix(jj,free_position((no_of_rank-1).*free_length./layer_number+1:no_of_rank.*free_length./layer_number))=u_matrix(index(ii),free_position((no_of_rank-1).*free_length./layer_number+1:no_of_rank.*free_length./layer_number));
end
u_matrix(:,L+1)=ones(Lo,1);
break;
else %%此时err=1 码式没有通过CRC
continue;
end
end
end
end %%end of if
end %%end of i_cycle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%最后从Lo条路径中选取最大的一条输出
y=u_matrix(1,1:L)';
end
没有合适的资源?快使用搜索试试~ 我知道了~
polarcode_SCLscheme.rar
共19个文件
m:19个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 124 浏览量
2022-04-12
21:25:58
上传
评论
收藏 10KB RAR 举报
温馨提示
这个压缩包里面是极化码的SCL方案的仿真 可以设置不同的码长和信噪比 并且可以选择高斯信道和擦除信道这两种信道(This program simulate the performance of SC-list scheme of polar code. You can choose different SNR and code length.You also can choose two type of channels.)
资源推荐
资源详情
资源评论
收起资源包目录
polarcode_SCLscheme.rar (19个子文件)
add_noise.m 322B
encode.m 261B
cal_llr.m 1KB
BERperformance.m 528B
get_bec_erasure_rates.m 255B
W_base.m 180B
polarcodemain.m 3KB
cal_llr1.m 2KB
info_gen_CRC.m 560B
cyclic_redundancy_code.m 2KB
SCL_CRC_decoder.m 5KB
channel_transfer.m 1KB
add_noise_on_y.m 227B
info_gen.m 58B
rvsl.m 128B
cal_l.m 426B
cyclic_redundancy_decode.m 2KB
decoder.m 1KB
travel.m 258B
共 19 条
- 1
资源评论
zwl2022
- 粉丝: 9
- 资源: 225
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功