forked from fantasua/PolarCodesMatLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathharq_decoder_sc.m
More file actions
44 lines (31 loc) · 835 Bytes
/
Copy pathharq_decoder_sc.m
File metadata and controls
44 lines (31 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function [u_hat,crc_checked]=harq_decoder_sc(y,L_recev,var,repeatPos,u_hat,free_index,frozen_index,G)
%译码函数
%输入y为信道输出,Z为信道Bhattacharyya矩阵,k为信息长度,b为frozenbit的值,var为噪声方差/功率
N = length(y);
u_lr = sqrt(L_recev*lr_new(y,u_hat,N,repeatPos,var));
if(u_lr >=1)
u_hat(repeatPos) = 0;
else
u_hat(repeatPos) = 1;
end
isfrozen(free_index)=0;
isfrozen(frozen_index)=1;
for i=repeatPos+1:N
if isfrozen(i)==1;
u_hat(i)=0;
else
M0=logAPP1(y,u_hat,0,N,i,var);
M1=logAPP1(y,u_hat,1,N,i,var);
if M0>=M1
u_hat(i)=0;
else
u_hat(i)=1;
end
end
end
result=crc_check(u_hat(free_index),G);
if result==0
crc_checked = 1; %CRC校验通过
else
crc_checked=0;
end