-
Notifications
You must be signed in to change notification settings - Fork 14
/
srsTBSCalculatorUnittest.m
187 lines (157 loc) · 7.17 KB
/
srsTBSCalculatorUnittest.m
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
%srsTBSCalculatorUnittest Unit tests for TBS calculation.
% This class implements unit tests for the TBS calculation. The simplest
% use consists in creating an object with
% testCase = srsTBSCalculatorUnittest
% and then running all the tests with
% testResults = testCase.run
%
% srsTBSCalculatorUnittest Properties (Constant):
%
% srsBlock - The tested block (i.e., 'tbs_calculator').
% srsBlockType - The type of the tested block, including layer
% (i.e., 'scheduler/support').
%
% srsTBSCalculatorUnittest Properties (ClassSetupParameter):
%
% outputPath - Path to the folder where the test results are stored.
%
% srsTBSCalculatorUnittest Properties (TestParameter):
%
% modOrder - Modulation order.
% nlayers - Number of transmission layers (1...4 for one codeword,
% 5...8 for two codewords).
% nprb - Number of physical resource blocks (PRBs) allocated for
% the physical shared channel.
% nsymb - Number of symbols allocated for the data transmission in
% the physical shared channel.
% ndmrsprb - Number of resource elements for DMRS allocated for the
% data transmission in the physical shared channel.
% tcr - Target code rate.
% xoh - Additional overhead.
% tbscaling - Scaling factor(s) for intermediate number of information
% bits.
%
% srsTBSCalculatorUnittest Methods (TestTags = {'testvector'}):
%
% testvectorGenerationCases - Generates a test vector according to the provided
% parameters.
%
% srsTBSCalculatorUnittest Methods (Access = protected):
%
% addTestIncludesToHeaderFile - Adds include directives to the test header file.
% addTestDefinitionToHeaderFile - Adds details (e.g., type/variable declarations)
% to the test header file.
%
% See also matlab.unittest, nrTBS.
% Copyright 2021-2024 Software Radio Systems Limited
%
% This file is part of srsRAN-matlab.
%
% srsRAN-matlab is free software: you can redistribute it and/or
% modify it under the terms of the BSD 2-Clause License.
%
% srsRAN-matlab is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% BSD 2-Clause License for more details.
%
% A copy of the BSD 2-Clause License can be found in the LICENSE
% file in the top-level directory of this distribution.
classdef srsTBSCalculatorUnittest < srsTest.srsBlockUnittest
properties (Constant)
%Name of the tested block.
srsBlock = 'tbs_calculator'
%Type of the tested block.
srsBlockType = 'ran/sch'
end
properties (ClassSetupParameter)
%Path to results folder (old 'pdccg_candidates_common' tests will be erased).
outputPath = {['testTBSCalculator', char(datetime('now', 'Format', 'yyyyMMdd''T''HHmmss'))]}
end
properties (TestParameter)
%It must be specified as one of (2, 4, 6, 8). They refer to QPSK,
%16-QAM, 64-QAM and 256-QAM respectively.
modOrder = {2, 4, 6, 8};
%The value must be a scalar nonnegative integer. The nominal value
%of NLAYERS is in the range of (1...8).
nlayers = {1, 4};
%The value must be a scalar nonnegative integer. The nominal value
%of NPRB is in the range of (1...275).
nprb = {6, 11};
%The value must be a scalar nonnegative integer. The nominal value
%of NSYMB is in the range of (1...14).
nsymb = {12};
%The value must be a scalar nonnegative integer. The nominal value
%depends on the number of CDM groups, the DMRS type density and
%the number of symbols udes for DMRS transmission.
%
%For example, for a Type1 DMRS has a density of six RE per PRB and
%symbol. With two additional positions and two CDM groups without
%data, it results in 36 RE per PRB.
ndmrsprb = {6, 36};
%Represented in floating point between 0 and 1.
tcr = {0.1, 0.9};
%Controls the number of REs available for the data transmission in
%the shared channel, within one PRB for one slot. It must be a
%scalar nonnegative integer. The nominal value of XOH is one of (0,
%6, 12, 18), provided by the higher-layer parameter xOverhead in
%PDSCH-ServingCellConfig IE or PUSCH-ServingCellConfig IE.
xoh = {0, 12};
%The nominal value of TBSCALING is one of (0.25, 0.5, 1), as
%defined in TS 38.214 Table 5.1.3.2-2.
tbscaling = {1, 0.25};
end
methods (Access = protected)
function addTestIncludesToHeaderFile(~, fileID)
%addTestIncludesToHeaderFile Adds include directives to the test header file.
fprintf(fileID, '#include "srsran/ran/sch/tbs_calculator.h"\n');
fprintf(fileID, '#include <vector>\n');
end
function addTestDefinitionToHeaderFile(~, fileID)
%addTestDetailsToHeaderFile Adds details (e.g., type/variable declarations) to the test header file.
fprintf(fileID, [...
'\n'...
'struct test_case_t {\n'...
' tbs_calculator_configuration config;\n'...
' unsigned tbs;\n'...
'};\n'
]);
end
end % of methods (Access = protected)
methods (Test, TestTags = {'testvector'})
function testvectorGenerationCases(testCase, modOrder, nlayers, nprb, nsymb, ndmrsprb, tcr, xoh, tbscaling)
%testvectorGenerationCases Generates a test vector for the
% modOrder, nlayers, nprb, ndmrsprb, tcr, xoh and tbscaling.
import srsLib.phy.helpers.srsGetModulation
import srsTest.helpers.cellarray2str
import srsTest.helpers.mcsDescription2Cell
NREPerPRB = nsymb * 12 - ndmrsprb;
modulation = srsGetModulation(modOrder);
tbs = nrTBS(modulation, nlayers, nprb, NREPerPRB, tcr, xoh, tbscaling);
tbs = tbs(1);
% generate a unique test ID
testID = testCase.generateTestID;
mcsDescrCell = mcsDescription2Cell(modulation, tcr);
% Prepare configuration cell.
configCell = {...
nsymb, ... % nof_symb_sh
ndmrsprb, ... % nof_dmrs_prb
xoh, ... % nof_oh_prb
mcsDescrCell, ... % mcs_descr
nlayers, ... % nof_layers
round(-log2(tbscaling)), ... % tb_scaling_field
nprb, ...
};
% Prepare test case cell.
testCaseCell = {
configCell, ... % config
tbs, ... % tbs
};
% generate the test case entry
testCaseString = testCase.testCaseToString(testID, testCaseCell,...
false);
% add the test to the file header
testCase.addTestToHeaderFile(testCase.headerFileID, testCaseString);
end % of function testvectorGenerationCases
end % of methods (Test, TestTags = {'testvector'})
end % of classdef srsTBSCalculatorUnittest< srsTest.srsBlockUnittest