11function a_hat = PUCCH_decoder(f_tilde , A , L , min_sum )
22% PUCCH_DECODER Physical Uplink Control Channel (PUCCH) polar decoder from 3GPP New
33% Radio, as specified in Section 6.3.1 of TS 38.212 v1.1.1
4- % a_hat = PUCCH_DECODER(f_tilde, A, L, min_sum) decodes the encoded LLR sequence
5- % f_tilde, in order to obtain the recovered information bit sequence
4+ % a_hat = PUCCH_DECODER(f_tilde, A, L, min_sum) decodes the encoded LLR sequence
5+ % f_tilde, in order to obtain the recovered information bit sequence
66% a_hat.
77%
8- % f_tilde should be a real row vector comprising E number of Logarithmic
8+ % f_tilde should be a real row vector comprising G number of Logarithmic
99% Likelihood Ratios (LLRS), each having a value obtained as LLR =
1010% ln(P(bit=0)/P(bit=1)).
1111%
1212% A should be an integer scalar. It specifies the number of bits in the
13- % information bit sequence, where A should be less than E .
13+ % information bit sequence, where A should be less than G .
1414%
1515% L should be a scalar integer. It specifies the list size to use during
1616% Successive Cancellation List (SCL) decoding.
2121% better error correction capability than the min-sum, but it has higher
2222% complexity.
2323%
24- % a_hat will be a binary row vector comprising A number of bits, each
24+ % a_hat will be a binary row vector comprising A number of bits, each
2525% having the value 0 or 1.
2626%
2727% See also PUCCH_ENCODER
2828%
29- % Copyright © 2017 Robert G. Maunder. This program is free software: you
30- % can redistribute it and/or modify it under the terms of the GNU General
31- % Public License as published by the Free Software Foundation, either
32- % version 3 of the License, or (at your option) any later version. This
33- % program is distributed in the hope that it will be useful, but WITHOUT
34- % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35- % FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
29+ % Copyright © 2017 Robert G. Maunder. This program is free software: you
30+ % can redistribute it and/or modify it under the terms of the GNU General
31+ % Public License as published by the Free Software Foundation, either
32+ % version 3 of the License, or (at your option) any later version. This
33+ % program is distributed in the hope that it will be useful, but WITHOUT
34+ % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35+ % FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
3636% more details.
3737
3838addpath ' components'
3939
40- E = length(f_tilde );
40+ G = length(f_tilde );
4141
42- % NEED TO ADD SEGMENTATION
42+ if A < 12
43+ error(' polar_3gpp_matlab:UnsupportedBlockLength' ,' A should be no less than 12.' );
44+ elseif A <= 19 % Use PCCA-polar
45+ % The CRC polynomial used with PCCA-polar in 3GPP PUCCH channel is
46+ % D^6 + D^5 + 1
47+ crc_polynomial_pattern = [1 1 0 0 0 0 1 ];
48+
49+ % Use one segment
50+ C = 1 ;
51+ else % Use CA-polar
52+ % The CRC polynomial used with CA-polar in 3GPP PUCCH channel is
53+ % D^11 + D^10 + D^9 + D^5 + 1
54+ crc_polynomial_pattern = [1 1 1 0 0 0 1 0 0 0 0 1 ];
55+
56+ if A >= 360 && G >= 1088
57+ if mod(G ,2 ) ~= 0
58+ error(' polar_3gpp_matlab:UnsupportedBlockLength' ,' G should be divisible by 2 when code block segmentation is used.' );
59+ end
60+
61+ % Use two segments
62+ C = 2 ;
63+
64+ else
65+ % Use one segment
66+ C = 1 ;
67+ end
68+
69+ end
4370
44- % NEED TO CONFIRM CRC
71+ if G > 8192 * C
72+ error(' polar_3gpp_matlab:UnsupportedBlockLength' ,' G is too long.' );
73+ end
74+
4575
46- % The CRC polynomial used in 3GPP PUCCH channel is
47- % D^11 + D^10 + D^9 + D^5 + 1
48- crc_polynomial_pattern = [1 1 1 0 0 0 1 0 0 0 0 1 ];
4976
5077% The CRC has P bits. P-min(P2,log2(L)) of these are used for error
5178% detection, where L is the list size. Meanwhile, min(P2,log2(L)) of
5683P2 = 3 ;
5784
5885% Determine the number of information and CRC bits.
59- K = A + P ;
60-
61- if K - 3 < 12
62- error(' polar_3gpp_matlab:UnsupportedBlockLength' ,' K-3 should be no less than 12.' );
63- end
86+ K = ceil(A / C )+P ;
6487
6588% Determine the number of bits used at the input and output of the polar
6689% encoder kernal.
67- N = get_3GPP_N(K ,E ,10 ); % n_max = 10 is used in PUCCH channels
90+ N = get_3GPP_N(K ,G / C ,10 ); % n_max = 10 is used in PUCCH channels
6891
6992% Get a rate matching pattern.
70- [rate_matching_pattern , mode ] = get_3GPP_rate_matching_pattern(K ,N ,E );
93+ [rate_matching_pattern , mode ] = get_3GPP_rate_matching_pattern(K ,N ,G / C );
7194
7295% Get a sequence pattern.
7396Q_N = get_3GPP_sequence_pattern(N );
7497
75- % Perform channel deinterleaving
76- channel_interleaver_pattern = get_3GPP_channel_interleaver_pattern(E );
77- e_tilde = zeros(1 ,E );
78- e_tilde(channel_interleaver_pattern ) = f_tilde ;
98+ % Get the channel interleaving pattern
99+ channel_interleaver_pattern = get_3GPP_channel_interleaver_pattern(G / C );
100+
79101
80- if K - 3 <= 22
81- % Use PC-polar
82- n_PC = 3 ;
83102
103+ if A <= 19 % Use PCCA-polar
104+
105+ % Perform channel interleaving
106+ e_tilde = zeros(1 ,G );
107+ e_tilde(channel_interleaver_pattern ) = f_tilde ;
108+
109+ % We use 3 PC bits
110+ n_PC = 3 ;
111+
84112 % Get an information bit pattern.
85113 info_bit_pattern = get_3GPP_info_bit_pattern(K + n_PC , Q_N , rate_matching_pattern , mode );
86-
114+
87115 % Get a PC bit pattern.
88- if E - K + 3 > 192
116+ if G - K + 3 > 192
89117 PC_bit_pattern = get_PC_bit_pattern(info_bit_pattern , Q_N , n_PC , 1 );
90- else
118+ else
91119 PC_bit_pattern = get_PC_bit_pattern(info_bit_pattern , Q_N , n_PC , 0 );
92120 end
93121
94122 % Perform polar decoding.
95123 a_hat = PCCA_polar_decoder(e_tilde ,crc_polynomial_pattern ,info_bit_pattern ,PC_bit_pattern ,5 ,rate_matching_pattern ,mode ,L ,min_sum ,P2 );
96- else
97- % Use CA-polar
98-
124+ else % Use CA-polar
125+
99126 % Get an information bit pattern.
100127 info_bit_pattern = get_3GPP_info_bit_pattern(K , Q_N , rate_matching_pattern , mode );
101- % Perform polar decoding.
102- a_hat = CA_polar_decoder(e_tilde ,crc_polynomial_pattern ,info_bit_pattern ,rate_matching_pattern ,mode ,L ,min_sum ,P2 );
103- end
104-
105- % SEGMENTATION
128+
129+ if C == 2
130+ a_hat = zeros(1 ,A );
131+
132+ info_bit_pattern2 = info_bit_pattern ;
133+ if mod(A ,2 ) ~= 0 % If a zero was prepended to the first segment during encoding
134+ % Treat the first information bit as a frozen bit
135+ info_bit_pattern2(find(info_bit_pattern == 1 ,1 ,first )) = 0 ;
136+ end
137+
138+ % Perform channel interleaving for first segment.
139+ e_tilde = zeros(1 ,G / C );
140+ e_tilde(channel_interleaver_pattern ) = f_tilde(1 : G / C );
141+
142+ % Perform polar decoding for first segment.
143+ a_hat(1 : floor(A / C )) = CA_polar_decoder(e_tilde ,crc_polynomial_pattern ,info_bit_pattern2 ,rate_matching_pattern ,mode ,L ,min_sum ,P2 );
144+
145+ % Perform channel interleaving for second segment.
146+ e_tilde(channel_interleaver_pattern ) = f_tilde(G / C + 1 : G );
147+
148+ % Perform polar decoding for second segment.
149+ a_hat(floor(A / C )+1 : A ) = CA_polar_decoder(e_tilde ,crc_polynomial_pattern ,info_bit_pattern ,rate_matching_pattern ,mode ,L ,min_sum ,P2 );
150+ else
151+ % Perform channel interleaving
152+ e_tilde = zeros(1 ,G );
153+ e_tilde(channel_interleaver_pattern ) = f_tilde ;
154+
155+ % Perform polar decoding.
156+ a_hat = CA_polar_decoder(e_tilde ,crc_polynomial_pattern ,info_bit_pattern ,rate_matching_pattern ,mode ,L ,min_sum ,P2 );
157+
158+ end
159+ end
160+ end
0 commit comments