Skip to content

Commit d529ff3

Browse files
committed
init
0 parents  commit d529ff3

File tree

93 files changed

+11067
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+11067
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function [T_frame, N_FRAME_slot, T_slot] = frame_structure()
2+
T_frame = 10e-3;
3+
N_FRAME_slot = 24;
4+
T_slot = T_frame/N_FRAME_slot;
5+
end
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
function [numerology] = numerologies(u, b)
2+
3+
if ~ismember(u,[1, 2, 4, 8])
4+
error('u is %d, but it must be 1, 2, 3 or 4.', u);
5+
end
6+
7+
if ~ismember(b,[1, 2, 4, 8, 12, 16])
8+
error('b is %d, but it must be 1, 2, 4, 8, 12 or 16.', b);
9+
end
10+
11+
% Table 4.3-1
12+
delta_u_f = u*27000;
13+
T_u_symb = 1/delta_u_f * (64+8)/64; % (64+8)/64 = (128+16)/128 = (256+32)/256 = ...
14+
N_SLOT_u_symb = u*10;
15+
N_SLOT_u_subslot = u*2;
16+
17+
switch u
18+
case 1
19+
GI_u = 4/9*T_u_symb; % Figure 5.1-1
20+
case {2,4}
21+
GI_u = T_u_symb; % Figure 5.1-2
22+
case 8
23+
GI_u = 2*T_u_symb; % Figure 5.1-3
24+
end
25+
26+
B_u_b_DFT = b*64*delta_u_f;
27+
T_u_b_s = 1/B_u_b_DFT;
28+
N_b_DFT = b*64;
29+
N_b_CP = b*8;
30+
N_b_OCC = b*56;
31+
B_u_b_TX = N_b_OCC*delta_u_f;
32+
33+
% add everything to output
34+
numerology.delta_u_f = delta_u_f;
35+
numerology.T_u_symb = T_u_symb;
36+
numerology.N_SLOT_u_symb = N_SLOT_u_symb;
37+
numerology.N_SLOT_u_subslot = N_SLOT_u_subslot;
38+
numerology.GI_u = GI_u;
39+
numerology.B_u_b_DFT = B_u_b_DFT;
40+
numerology.T_u_b_s = T_u_b_s;
41+
numerology.N_b_DFT = N_b_DFT;
42+
numerology.N_b_CP = N_b_CP;
43+
numerology.N_b_OCC = N_b_OCC;
44+
numerology.B_u_b_TX = B_u_b_TX;
45+
46+
% we add a few more useful parameters
47+
48+
% also calculate the guards
49+
numerology.n_guards_top = (N_b_DFT - N_b_OCC)/2 - 1;
50+
numerology.n_guards_bottom = numerology.n_guards_top + 1;
51+
52+
% sanity check
53+
assert(numerology.n_guards_bottom + N_b_OCC + numerology.n_guards_top + 1 == N_b_DFT);
54+
end
55+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function [k_b_OCC] = physical_resources(N_b_OCC)
2+
3+
% occupied subcarriers
4+
k_b_OCC = -N_b_OCC/2 : 1 : N_b_OCC/2;
5+
6+
% remove DC
7+
k_b_OCC(N_b_OCC/2+1) = [];
8+
end
9+
+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
%
2+
% DRS is mapped across all transmit streams, but the mapping is different for each stream.
3+
%
4+
% physical_resource_mapping_DRS_cell is always a cell(N_TS,4)
5+
%
6+
% N_TS is the number of transmit streams
7+
%
8+
% physical_resource_mapping_DRS_cell(x,1) contains the subcarrier indices for each ofdm symbol as described in 5.2.3
9+
%
10+
% physical_resource_mapping_DRS_cell(x,2) containes the ofdm symbol index where the DRS is placed
11+
%
12+
% physical_resource_mapping_DRS_cell(x,3) containes the values for each corresponding subcarriers
13+
% the values are the same for each ofdm symbol, but not for each transmit stream
14+
%
15+
% physical_resource_mapping_DRS_cell(x,4) containes the linear indices of each subcarrier/ofdm-symbol pair
16+
%
17+
%
18+
% example size (N_TS = 8):
19+
%
20+
% physical_resource_mapping_DRS_cell =
21+
%
22+
% 8×4 cell array
23+
%
24+
% {14×10 double} {1×10 double} {14×1 double} {14×10 double}
25+
% {14×10 double} {1×10 double} {14×1 double} {14×10 double}
26+
% {14×10 double} {1×10 double} {14×1 double} {14×10 double}
27+
% {14×10 double} {1×10 double} {14×1 double} {14×10 double}
28+
% {14×10 double} {1×10 double} {14×1 double} {14×10 double}
29+
% {14×10 double} {1×10 double} {14×1 double} {14×10 double}
30+
% {14×10 double} {1×10 double} {14×1 double} {14×10 double}
31+
% {14×10 double} {1×10 double} {14×1 double} {14×10 double}
32+
%
33+
%
34+
function [physical_resource_mapping_DRS_cell] = DRS(numerology, k_b_OCC, N_TS, N_eff_TX, N_PACKET_symb, b)
35+
36+
% Technical Specification assumes first index is 0, matlab 1
37+
MATLAB_INDEX_SHIFT = 1;
38+
39+
% copy all relevant variables
40+
N_b_DFT = numerology.N_b_DFT;
41+
N_b_OCC = numerology.N_b_OCC;
42+
43+
%% 5.2.3
44+
45+
if N_eff_TX <= 2
46+
N_step = 5;
47+
elseif N_eff_TX >= 4
48+
N_step = 10;
49+
else
50+
error('N_eff_TX is %d, cannot determine N_step according to 5.2.3.', N_eff_TX);
51+
end
52+
53+
i = 0 : 1 : N_b_OCC/4-1;
54+
55+
nof_OFDM_symbols_carying_DRS = floor(N_PACKET_symb/N_step);
56+
57+
% There's an error in the standard:
58+
% When using 4 TS and N_PACKET_symb is 15, 25, 35, 45, etc., the number of OFDM symbols carying DRS symbols is not floor(N_PACKET_symb/N_step).
59+
% It is one additional symbol, see figure 4.5-3 in part 3.
60+
if N_step == 10 && mod(N_PACKET_symb, 10) ~= 0
61+
62+
% sanity check
63+
if mod(N_PACKET_symb, 5) ~= 0
64+
error("N_PACKET_symb not a multiple of 5 or 10.");
65+
end
66+
67+
nof_OFDM_symbols_carying_DRS = nof_OFDM_symbols_carying_DRS + 1;
68+
end
69+
70+
n = 0 : 1 : (nof_OFDM_symbols_carying_DRS-1);
71+
72+
% we save data in cells
73+
physical_resource_mapping_DRS_cell = cell(N_TS,3);
74+
75+
% iterate over each transmit stream
76+
for t = 0:1:N_TS-1
77+
i_column = i';
78+
k_i = k_b_OCC(i_column*4 + mod( t + mod(n,2)*2 ,4) + MATLAB_INDEX_SHIFT);
79+
l = 1 + floor(t/4) + n*N_step;
80+
81+
% matlab related (if n ist a 1x1 vector, matlab create a row vector instead of a column vector)
82+
if numel(n) == 1
83+
k_i = k_i';
84+
end
85+
86+
physical_resource_mapping_DRS_cell(t + MATLAB_INDEX_SHIFT, 1) = {k_i};
87+
physical_resource_mapping_DRS_cell(t + MATLAB_INDEX_SHIFT, 2) = {l};
88+
89+
%% linear indices
90+
rows = lib_util.index_conversion_TS_matlab(N_b_DFT,k_i);
91+
cols = repmat(l + MATLAB_INDEX_SHIFT,size(rows,1),1);
92+
linear_indices_matlab = sub2ind([N_b_DFT (l(end) + MATLAB_INDEX_SHIFT)], rows, cols);
93+
physical_resource_mapping_DRS_cell(t + MATLAB_INDEX_SHIFT, 4) = {linear_indices_matlab};
94+
end
95+
96+
% base sequences
97+
y_b1 = [1,1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,-1,1,1,-1,1,-1,1,-1,1,1,1,1,1,-1,1,...
98+
-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1];
99+
100+
% !!!!!!!!!!! NOT STANDART COMPLIANT !!!!!!!!!!!
101+
% !!!!!!!!!!! NOT STANDART COMPLIANT !!!!!!!!!!!
102+
% !!!!!!!!!!! NOT STANDART COMPLIANT !!!!!!!!!!!
103+
% !!!!!!!!!!! NOT STANDART COMPLIANT !!!!!!!!!!!
104+
% increase power when using more antennas
105+
y_b1 = y_b1*sqrt(N_eff_TX);
106+
% !!!!!!!!!!! NOT STANDART COMPLIANT !!!!!!!!!!!
107+
% !!!!!!!!!!! NOT STANDART COMPLIANT !!!!!!!!!!!
108+
% !!!!!!!!!!! NOT STANDART COMPLIANT !!!!!!!!!!!
109+
% !!!!!!!!!!! NOT STANDART COMPLIANT !!!!!!!!!!!
110+
111+
y_b2 = [y_b1,y_b1];
112+
y_b4 = [y_b2, y_b2];
113+
y_b8 = [y_b4, y_b4];
114+
y_b12 = [y_b4, y_b4, y_b4];
115+
y_b16 = [y_b8, y_b8];
116+
117+
% iterate over each transmit stream
118+
% signal transmitted in DRS subcarrier
119+
for t = 0:1:N_TS-1
120+
121+
%i=0:1:N_b_DFT/4-1; error in ETSI TS 103 636-3 V1.1.1.1 (2020-07)
122+
i=0:1:N_b_DFT/4 - 1 - 2*b;
123+
i_column = i';
124+
125+
if t<4 % antenna indices 0,1,2,3, standard says t<=4, probably an error
126+
prefac = 1;
127+
elseif t>=4 % antenna indices 4,5,6,7, standard says t>4, probably an error
128+
prefac = -1;
129+
end
130+
131+
switch b
132+
case 1
133+
y_DRS_i = y_b1(4*i_column + mod(t,4) + MATLAB_INDEX_SHIFT);
134+
case 2
135+
y_DRS_i = y_b2(4*i_column + mod(t,4) + MATLAB_INDEX_SHIFT);
136+
case 4
137+
y_DRS_i = y_b4(4*i_column + mod(t,4) + MATLAB_INDEX_SHIFT);
138+
case 8
139+
y_DRS_i = y_b8(4*i_column + mod(t,4) + MATLAB_INDEX_SHIFT);
140+
case 12
141+
y_DRS_i = y_b12(4*i_column + mod(t,4) + MATLAB_INDEX_SHIFT);
142+
case 16
143+
y_DRS_i = y_b16(4*i_column + mod(t,4) + MATLAB_INDEX_SHIFT);
144+
end
145+
146+
y_DRS_i = prefac*y_DRS_i;
147+
148+
y_DRS_i = y_DRS_i';
149+
150+
physical_resource_mapping_DRS_cell(t + MATLAB_INDEX_SHIFT, 3) = {y_DRS_i};
151+
end
152+
end
153+
+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
%
2+
% PCC is mapped to spatial stream 0.
3+
%
4+
% physical_resource_mapping_PCC_cell is always a cell(1,x)
5+
%
6+
% physical_resource_mapping_PCC_cell(1,1)
7+
% physical_resource_mapping_PCC_cell(2,1)
8+
% physical_resource_mapping_PCC_cell(3,1)
9+
% ...
10+
% physical_resource_mapping_PCC_cell(x-1,1) contain subcarrier indices for all ofdm symbols where the PCC is placed
11+
%
12+
% physical_resource_mapping_PCC_cell(1,x) containes the corresponding ofdm symbol indices
13+
%
14+
% physical_resource_mapping_PCC_cell(1,x) contains linear indices for fast demapping
15+
%
16+
% example size for Figure 4.5-2 a):
17+
%
18+
% physical_resource_mapping_PCC_cell =
19+
%
20+
% 1×3 cell array
21+
%
22+
% {42×1 double} {56×1 double} {1×2 double}
23+
%
24+
%
25+
function [physical_resource_mapping_PCC_cell] = PCC(numerology, k_b_OCC, N_TS, N_PACKET_symb,...
26+
physical_resource_mapping_STF_cell,...
27+
physical_resource_mapping_DRS_cell)
28+
29+
% Technical Specification assumes first index is 0, matlab 1
30+
MATLAB_INDEX_SHIFT = 1;
31+
32+
% copy all relevant variables
33+
N_b_DFT = numerology.N_b_DFT;
34+
35+
% to use the algorithm for PCC, we write all STF and DRS into one matrix of the size of the frame
36+
[~, mat_STF_DRS_all_streams] = lib_util.matrix_STF_DRS_PCC_PDC(N_b_DFT, N_PACKET_symb, N_TS, [],...
37+
physical_resource_mapping_STF_cell,...
38+
physical_resource_mapping_DRS_cell,...
39+
[],...
40+
[]);
41+
42+
43+
%% 5.2.4
44+
45+
l=1;
46+
N_PCC_subc = 98;
47+
N_unalloc_subc = N_PCC_subc;
48+
U = 0;
49+
50+
% we save data in one cell
51+
%
52+
% PCC in mapped into first spatial stream
53+
%
54+
% number of rows: always 1
55+
% first cell: subcarrier indices for one ofdm symbol
56+
% second cell: subcarrier indices for one ofdm symbol
57+
% third cell: subcarrier indices for one ofdm symbol
58+
% ...
59+
% last cell: indices of all aforementioned ofdm symbols (see ofdm_symbol_indices)
60+
%
61+
physical_resource_mapping_PCC_cell = cell(0);
62+
ofdm_symbol_indices = [];
63+
64+
% counter for found PDC subcarriers
65+
cnt_PCC_subc = 0;
66+
67+
% matlab has no do-while-loop, see break condition at the end
68+
while 1
69+
70+
% find all indices of unused subcarriers in current OFDM-symbol
71+
[k_i_matlab, ~] = find(~mat_STF_DRS_all_streams(:,l + MATLAB_INDEX_SHIFT));
72+
73+
% convert to notation of technical specification
74+
k_i = lib_util.index_conversion_TS_matlab(N_b_DFT, k_i_matlab);
75+
76+
% remove any subcarriers not within k_b_OCC, namely guards and DC
77+
k_i = intersect(k_i, k_b_OCC);
78+
79+
U = numel(k_i);
80+
81+
% no free subcarriers in this symbol, move to next ofdm symbol
82+
if U == 0
83+
l = l + 1;
84+
continue;
85+
end
86+
87+
% sort from lowest subcarrier to highest
88+
k_i = sort(k_i);
89+
90+
% add to set of subcarriers
91+
k_PCC_l = k_i;
92+
93+
% Step 5)
94+
R_PCC = 7;
95+
96+
assert(mod(U,R_PCC)==0);
97+
98+
% Step 6)
99+
C_PCC = U/R_PCC;
100+
101+
% Step 7)
102+
R_PCC_x_C_PCC = reshape(k_PCC_l, C_PCC, R_PCC);
103+
R_PCC_x_C_PCC = R_PCC_x_C_PCC';
104+
105+
% Step 8)
106+
k_PCC_l = reshape(R_PCC_x_C_PCC, numel(R_PCC_x_C_PCC), 1);
107+
108+
% we either use as many subcarrieres as we can in this symbol (numel(k_PCC_l)) or as many as we still need (N_unalloc_subc)
109+
k_PCC_l = k_PCC_l(1 : min(numel(k_PCC_l), N_unalloc_subc));
110+
111+
% sort from lowest subcarrier to highest
112+
k_PCC_l = sort(k_PCC_l);
113+
114+
% append subcarriers for this ofdm symbol
115+
physical_resource_mapping_PCC_cell = [physical_resource_mapping_PCC_cell {k_PCC_l}];
116+
cnt_PCC_subc = cnt_PCC_subc + numel(k_PCC_l);
117+
118+
% remember current ofdm symbol
119+
ofdm_symbol_indices = [ofdm_symbol_indices, l];
120+
121+
% do while loop exit condition: we have found more subcariers in this symbol (U) than we still need (N_unalloc_subc)
122+
if U >= N_unalloc_subc
123+
break;
124+
end
125+
126+
% we have added some more subcarriers in this symbol, so we reduce the number of subcarriers required in the next ofdm symbol
127+
N_unalloc_subc = N_unalloc_subc - U;
128+
129+
% move to next of ofdm symbol
130+
l = l + 1;
131+
end
132+
133+
%% create a vector with linear indices
134+
linear_indices_matlab = zeros(cnt_PCC_subc, 1);
135+
idx = 1;
136+
for i=1:1:numel(ofdm_symbol_indices)
137+
138+
k_i = cell2mat(physical_resource_mapping_PCC_cell(i));
139+
n_k_i = numel(k_i);
140+
141+
% linear indices
142+
rows = lib_util.index_conversion_TS_matlab(N_b_DFT,k_i);
143+
cols = repmat(ofdm_symbol_indices(i) + MATLAB_INDEX_SHIFT, numel(k_i), 1);
144+
li_matlab = sub2ind([N_b_DFT N_PACKET_symb], rows, cols);
145+
146+
linear_indices_matlab(idx : idx + n_k_i - 1) = li_matlab;
147+
148+
idx = idx + n_k_i;
149+
end
150+
151+
% sanity check
152+
if idx-1 ~= cnt_PCC_subc || idx-1 ~= 98
153+
error('Incorrect number of linear indices.');
154+
end
155+
156+
% write result
157+
physical_resource_mapping_PCC_cell = [physical_resource_mapping_PCC_cell {ofdm_symbol_indices} {linear_indices_matlab}];
158+
end
159+

0 commit comments

Comments
 (0)