Skip to content

Commit ab7a356

Browse files
committed
Added encoders and decoders for PDCCH and PUCCH. Still need to implement code block segmentation and RNTI scrambling. Also need to confirm PUCCH CRCs. These decisions will be made at the next 3GPP meeting.
1 parent c80e04f commit ab7a356

9 files changed

Lines changed: 405 additions & 23 deletions

PBCH_decoder.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
%
99
% f_tilde should be a real row vector comprising E number of Logarithmic
1010
% Likelihood Ratios (LLRS), each having a value obtained as LLR =
11-
% ln(P(bit=0)/P(bit=1).
11+
% ln(P(bit=0)/P(bit=1)).
1212
%
1313
% A should be an integer scalar. It specifies the number of bits in the
1414
% information bit sequence, where A should be less than E and should be

PDCCH_decoder.m

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
function a_hat = PDCCH_decoder(f_tilde, A, L, min_sum)
2+
% PDCCH_DECODER Physical Downlink Control Channel (PDCCH) polar decoder from 3GPP New
3+
% Radio, as specified in Section 7.3 of TS 38.212 v1.0.1...
4+
% http://www.3gpp.org/ftp/TSG_RAN/WG1_RL1/TSGR1_AH/NR_AH_1709/Docs/R1-1716928.zip
5+
% a_hat = PDCCH_DECODER(f_tilde, A, L, min_sum) decodes the encoded LLR sequence
6+
% f_tilde, in order to obtain the recovered information bit sequence
7+
% a_hat.
8+
%
9+
% f_tilde should be a real row vector comprising E number of Logarithmic
10+
% Likelihood Ratios (LLRS), each having a value obtained as LLR =
11+
% ln(P(bit=0)/P(bit=1)).
12+
%
13+
% A should be an integer scalar. It specifies the number of bits in the
14+
% information bit sequence, where A should be less than E and should be
15+
% no greater than 200.
16+
%
17+
% L should be a scalar integer. It specifies the list size to use during
18+
% Successive Cancellation List (SCL) decoding.
19+
%
20+
% min_sum shoular be a scalar logical. If it is true, then the SCL
21+
% decoding process will be completed using the min-sum approximation.
22+
% Otherwise, the log-sum-product will be used. The log-sum-product gives
23+
% better error correction capability than the min-sum, but it has higher
24+
% complexity.
25+
%
26+
% a_hat will be a binary row vector comprising A number of bits, each
27+
% having the value 0 or 1.
28+
%
29+
% See also PDCCH_ENCODER
30+
%
31+
% Copyright © 2017 Robert G. Maunder. This program is free software: you
32+
% can redistribute it and/or modify it under the terms of the GNU General
33+
% Public License as published by the Free Software Foundation, either
34+
% version 3 of the License, or (at your option) any later version. This
35+
% program is distributed in the hope that it will be useful, but WITHOUT
36+
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37+
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
38+
% more details.
39+
40+
addpath 'components'
41+
42+
E = length(f_tilde);
43+
44+
% The CRC polynomial used in 3GPP PBCH and PDCCH channel is
45+
% D^24 + D^23 + D^21 + D^20 + D^17 + D^15 + D^13 + D^12 + D^8 + D^4 + D^2 + D + 1
46+
crc_polynomial_pattern = [1 1 0 1 1 0 0 1 0 1 0 1 1 0 0 0 1 0 0 0 1 0 1 1 1];
47+
48+
% The CRC has P bits. P-min(P2,log2(L)) of these are used for error
49+
% detection, where L is the list size. Meanwhile, min(P2,log2(L)) of
50+
% them are used to improve error correction. So the CRC needs to be
51+
% min(P2,log2(L)) number of bits longer than CRCs used in other codes,
52+
% in order to achieve the same error detection capability.
53+
P = length(crc_polynomial_pattern)-1;
54+
P2 = 3;
55+
56+
% Determine the number of information and CRC bits.
57+
K = A+P;
58+
59+
% Determine the number of bits used at the input and output of the polar
60+
% encoder kernal.
61+
N = get_3GPP_N(K,E,9); % n_max = 9 is used in PBCH and PDCCH channels
62+
63+
% Get the 3GPP CRC interleaver pattern.
64+
crc_interleaver_pattern = get_3GPP_crc_interleaver_pattern(K);
65+
66+
% Get the 3GPP rate matching pattern.
67+
[rate_matching_pattern, mode] = get_3GPP_rate_matching_pattern(K,N,E);
68+
69+
% Get the 3GPP sequence pattern.
70+
Q_N = get_3GPP_sequence_pattern(N);
71+
72+
% Get the 3GPP information bit pattern.
73+
info_bit_pattern = get_3GPP_info_bit_pattern(K, Q_N, rate_matching_pattern, mode);
74+
75+
% NEED TO ADD RNTI SCRAMBLING
76+
77+
% Perform Distributed-CRC-Aided polar decoding.
78+
a_hat = DCA_polar_decoder(f_tilde,crc_polynomial_pattern,crc_interleaver_pattern,info_bit_pattern,rate_matching_pattern,mode,L,min_sum,P2);

PDCCH_encoder.m

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
function f = PDCCH_encoder(a, E)
2+
% PDCCH_ENCODER Physical Downlink Control Channel (PDCCH) polar encoder from 3GPP New
3+
% Radio, as specified in Section 7.3 of TS 38.212 v1.0.1...
4+
% http://www.3gpp.org/ftp/TSG_RAN/WG1_RL1/TSGR1_AH/NR_AH_1709/Docs/R1-1716928.zip
5+
% f = PDCCH_ENCODER(a, E) encodes the information bit sequence a, in
6+
% order to obtain the encoded bit sequence e.
7+
%
8+
% a should be a binary row vector comprising A number of bits, each
9+
% having the value 0 or 1. A should be in the range 1 to 200.
10+
%
11+
% E should be an integer scalar. It specifies the number of bits in the
12+
% encoded bit sequence, where E should greater than A.
13+
%
14+
% f will be a binary row vector comprising E number of bits, each having
15+
% the value 0 or 1.
16+
%
17+
% See also PDCCH_DECODER
18+
%
19+
% Copyright © 2017 Robert G. Maunder. This program is free software: you
20+
% can redistribute it and/or modify it under the terms of the GNU General
21+
% Public License as published by the Free Software Foundation, either
22+
% version 3 of the License, or (at your option) any later version. This
23+
% program is distributed in the hope that it will be useful, but WITHOUT
24+
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25+
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
26+
% more details.
27+
28+
addpath 'components'
29+
30+
A = length(a);
31+
32+
% The CRC polynomial used in 3GPP PBCH and PDCCH channel is
33+
% D^24 + D^23 + D^21 + D^20 + D^17 + D^15 + D^13 + D^12 + D^8 + D^4 + D^2 + D + 1
34+
crc_polynomial_pattern = [1 1 0 1 1 0 0 1 0 1 0 1 1 0 0 0 1 0 0 0 1 0 1 1 1];
35+
P = length(crc_polynomial_pattern)-1;
36+
37+
% Determine the number of information and CRC bits.
38+
K = A+P;
39+
40+
% Determine the number of bits used at the input and output of the polar
41+
% encoder kernal.
42+
N = get_3GPP_N(K,E,9); % n_max = 9 is used in PBCH and PDCCH channels
43+
44+
% Get the 3GPP CRC interleaver pattern.
45+
crc_interleaver_pattern = get_3GPP_crc_interleaver_pattern(K);
46+
47+
% Get the 3GPP rate matching pattern.
48+
[rate_matching_pattern, mode] = get_3GPP_rate_matching_pattern(K,N,E);
49+
50+
% Get the 3GPP sequence pattern.
51+
Q_N = get_3GPP_sequence_pattern(N);
52+
53+
% Get the 3GPP information bit pattern.
54+
info_bit_pattern = get_3GPP_info_bit_pattern(K, Q_N, rate_matching_pattern, mode);
55+
56+
% NEED TO ADD RNTI SCRAMBLING
57+
58+
% Perform Distributed-CRC-Aided polar encoding.
59+
f = DCA_polar_encoder(a,crc_polynomial_pattern,crc_interleaver_pattern,info_bit_pattern,rate_matching_pattern);

PUCCH_decoder.m

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
function a_hat = PUCCH_decoder(f_tilde, A, L, min_sum)
2+
% PUCCH_DECODER Physical Uplink Control Channel (PUCCH) polar decoder from 3GPP New
3+
% 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
6+
% a_hat.
7+
%
8+
% f_tilde should be a real row vector comprising E number of Logarithmic
9+
% Likelihood Ratios (LLRS), each having a value obtained as LLR =
10+
% ln(P(bit=0)/P(bit=1)).
11+
%
12+
% 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.
14+
%
15+
% L should be a scalar integer. It specifies the list size to use during
16+
% Successive Cancellation List (SCL) decoding.
17+
%
18+
% min_sum shoular be a scalar logical. If it is true, then the SCL
19+
% decoding process will be completed using the min-sum approximation.
20+
% Otherwise, the log-sum-product will be used. The log-sum-product gives
21+
% better error correction capability than the min-sum, but it has higher
22+
% complexity.
23+
%
24+
% a_hat will be a binary row vector comprising A number of bits, each
25+
% having the value 0 or 1.
26+
%
27+
% See also PUCCH_ENCODER
28+
%
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
36+
% more details.
37+
38+
addpath 'components'
39+
40+
E = length(f_tilde);
41+
42+
% NEED TO ADD SEGMENTATION
43+
44+
% NEED TO CONFIRM CRC
45+
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];
49+
50+
% The CRC has P bits. P-min(P2,log2(L)) of these are used for error
51+
% detection, where L is the list size. Meanwhile, min(P2,log2(L)) of
52+
% them are used to improve error correction. So the CRC needs to be
53+
% min(P2,log2(L)) number of bits longer than CRCs used in other codes,
54+
% in order to achieve the same error detection capability.
55+
P = length(crc_polynomial_pattern)-1;
56+
P2 = 3;
57+
58+
% 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
64+
65+
% Determine the number of bits used at the input and output of the polar
66+
% encoder kernal.
67+
N = get_3GPP_N(K,E,10); % n_max = 10 is used in PUCCH channels
68+
69+
% Get a rate matching pattern.
70+
[rate_matching_pattern, mode] = get_3GPP_rate_matching_pattern(K,N,E);
71+
72+
% Get a sequence pattern.
73+
Q_N = get_3GPP_sequence_pattern(N);
74+
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;
79+
80+
if K - 3 <= 22
81+
% Use PC-polar
82+
n_PC = 3;
83+
84+
% Get an information bit pattern.
85+
info_bit_pattern = get_3GPP_info_bit_pattern(K+n_PC, Q_N, rate_matching_pattern, mode);
86+
87+
% Get a PC bit pattern.
88+
if E-K+3 > 192
89+
PC_bit_pattern = get_PC_bit_pattern(info_bit_pattern, Q_N, n_PC, 1);
90+
else
91+
PC_bit_pattern = get_PC_bit_pattern(info_bit_pattern, Q_N, n_PC, 0);
92+
end
93+
94+
% Perform polar decoding.
95+
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+
99+
% Get an information bit pattern.
100+
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

PUCCH_encoder.m

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
function f = PUCCH_encoder(a, E)
2+
% PUCCH_ENCODER Physical Uplink Control Channel (PUCCH) polar encoder from 3GPP New
3+
% Radio, as specified in Section 6.3.1 of TS 38.212 v1.1.1
4+
% f = PUCCH_ENCODER(a, E) encodes the information bit sequence a, in
5+
% order to obtain the encoded bit sequence f.
6+
%
7+
% a should be a binary row vector comprising A number of bits, each
8+
% having the value 0 or 1.
9+
%
10+
% E should be an integer scalar. It specifies the number of bits in the
11+
% encoded bit sequence, where E should be greater than A.
12+
%
13+
% f will be a binary row vector comprising E number of bits, each having
14+
% the value 0 or 1.
15+
%
16+
% See also PUCCH_DECODER
17+
%
18+
% Copyright © 2017 Robert G. Maunder. This program is free software: you
19+
% can redistribute it and/or modify it under the terms of the GNU General
20+
% Public License as published by the Free Software Foundation, either
21+
% version 3 of the License, or (at your option) any later version. This
22+
% program is distributed in the hope that it will be useful, but WITHOUT
23+
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24+
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
25+
% more details.
26+
27+
addpath 'components'
28+
29+
A = length(a);
30+
31+
% NEED TO ADD SEGMENTATION
32+
33+
% NEED TO CONFIRM CRC
34+
35+
% The CRC polynomial used in 3GPP PUCCH channel is
36+
% D^11 + D^10 + D^9 + D^5 + 1
37+
crc_polynomial_pattern = [1 1 1 0 0 0 1 0 0 0 0 1];
38+
P = length(crc_polynomial_pattern)-1;
39+
40+
41+
% Determine the number of information and CRC bits.
42+
K = A+P;
43+
44+
if K-3 < 12
45+
error('polar_3gpp_matlab:UnsupportedBlockLength','K-3 should be no less than 12.');
46+
end
47+
48+
49+
% Determine the number of bits used at the input and output of the polar
50+
% encoder kernal.
51+
N = get_3GPP_N(K,E,10); % n_max = 10 is used in PUCCH channels
52+
53+
% Get a rate matching pattern.
54+
[rate_matching_pattern, mode] = get_3GPP_rate_matching_pattern(K,N,E);
55+
56+
% Get a sequence pattern.
57+
Q_N = get_3GPP_sequence_pattern(N);
58+
59+
if K-3 <= 22
60+
61+
n_PC = 3;
62+
63+
% Get an information bit pattern.
64+
info_bit_pattern = get_3GPP_info_bit_pattern(K+n_PC, Q_N, rate_matching_pattern, mode);
65+
66+
% Get a PC bit pattern.
67+
if E-K+3 > 192
68+
PC_bit_pattern = get_PC_bit_pattern(info_bit_pattern, Q_N, n_PC, 1);
69+
else
70+
PC_bit_pattern = get_PC_bit_pattern(info_bit_pattern, Q_N, n_PC, 0);
71+
end
72+
73+
% Perform polar encoding.
74+
e = PCCA_polar_encoder(a, crc_polynomial_pattern, info_bit_pattern, PC_bit_pattern, 5, rate_matching_pattern);
75+
else
76+
% Get an information bit pattern.
77+
info_bit_pattern = get_3GPP_info_bit_pattern(K, Q_N, rate_matching_pattern, mode);
78+
79+
% Perform polar encoding.
80+
e = CA_polar_encoder(a,crc_polynomial_pattern,info_bit_pattern,rate_matching_pattern);
81+
end
82+
83+
% Perform channel interleaving.
84+
channel_interleaver_pattern = get_3GPP_channel_interleaver_pattern(E);
85+
f = e(channel_interleaver_pattern);
86+
87+
88+
% NEED TO ADD SEGMENTATION

components/get_3GPP_crc_interleaver_pattern.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
% K should be an integer scalar. It specifies the number of bits in the
1010
% information and CRC bit sequence.
1111
%
12-
% Pi will be an integer row vector, compring K unique elements in the
12+
% Pi will be an integer row vector, comprising K unique elements in the
1313
% range 1 to K. Each integer identifies which one of the K information or
1414
% CRC bits provides the corresponding interleaved bit. Interleaving
1515
% can be implemented according to c = b(Pi), while

0 commit comments

Comments
 (0)