Skip to content

Commit 2fe529b

Browse files
committed
ran: add CSI Part 2 size calculator
ran: review UCI part 2 related ran: add missing new line apply clang-format
1 parent 4ea80bd commit 2fe529b

File tree

10 files changed

+304
-87
lines changed

10 files changed

+304
-87
lines changed

include/srsran/ran/csi_report/csi_report_configuration.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,10 @@ inline const char* to_string(csi_report_quantities quantities)
7979
switch (quantities) {
8080
case srsran::csi_report_quantities::cri_ri_pmi_cqi:
8181
return "cri-ri-pmi-cqi";
82-
break;
8382
case srsran::csi_report_quantities::cri_ri_cqi:
8483
return "cri-ri-cqi";
85-
break;
8684
case srsran::csi_report_quantities::cri_ri_li_pmi_cqi:
8785
return "cri-ri-li-pmi-cqi";
88-
break;
8986
case srsran::csi_report_quantities::other:
9087
default:
9188
return "other";
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
*
3+
* Copyright 2013-2022 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#pragma once
12+
#include "srsran/adt/span.h"
13+
#include "srsran/ran/uci/uci_part2_size_description.h"
14+
15+
namespace srsran {
16+
17+
/// \brief Calculates the UCI part 2 from UCI part 1.
18+
/// \param[in] part1 UCI part 1 decoded data.
19+
/// \param[in] descr UCI part 1 parameters correspondence to UCI part 2 size.
20+
/// \return The size of UCI part 2 payload.
21+
unsigned uci_part2_get_size(span<const uint8_t> part1, const uci_part2_size_description& descr);
22+
23+
} // namespace srsran
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
*
3+
* Copyright 2013-2022 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#pragma once
12+
#include "srsran/adt/static_vector.h"
13+
14+
namespace srsran {
15+
16+
/// Collects the parameters that describe the UCI Part 1 correspondence to Part 2 sizes.
17+
struct uci_part2_size_description {
18+
/// Maximum number of parameters.
19+
static constexpr unsigned max_nof_parameters = 2;
20+
/// Maximum number of Part 2 entries.
21+
static constexpr unsigned max_nof_entries = 2;
22+
/// Maximum number of aggregated bits per entry.
23+
static constexpr unsigned max_nof_entry_bits = 4;
24+
/// Maximum number of Part 2 sizes per entry.
25+
static constexpr unsigned max_size_table = 1U << max_nof_entry_bits;
26+
27+
/// Collects parameter attributes.
28+
struct parameter {
29+
/// Bit offset of the parameter from the beginning of the Part 1.
30+
uint16_t offset;
31+
/// CSI Part 1 parameter bit width.
32+
uint8_t width;
33+
};
34+
35+
/// Collects the parameters to determine a single CSI Part 2 report.
36+
struct entry {
37+
/// \brief Part 1 parameters that influence the size of this part 2.
38+
/// \remark The total accumulated width of the parameters must not exceed \ref max_nof_entry_bits bits.
39+
static_vector<parameter, max_nof_parameters> parameters;
40+
/// \brief Maps the concatenation of the parameters to Part 2 size.
41+
static_vector<uint16_t, max_size_table> map;
42+
};
43+
44+
/// CSI Part 2 entries.
45+
static_vector<entry, max_nof_entries> entries;
46+
};
47+
48+
} // namespace srsran

include/srsran/srsvec/bit.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ void bit_unpack(span<uint8_t> unpacked, const bit_buffer& packed);
5353
/// \remark After execution, \c bits will contain only the unused bits.
5454
unsigned bit_pack(span<const uint8_t>& bits, unsigned nof_bits);
5555

56+
/// \brief Packs the input bits into an integer value.
57+
///
58+
/// The first bit in the sequence corresponds to the bit of index <tt> bits.size() - 1 </tt> of the returned value. The
59+
/// last value in the sequence corresponds to LSB of the returned value.
60+
///
61+
/// \param[in] bits View of unpacked bits.
62+
/// \return An integer containing the packed bits.
63+
/// \remark The number of elements must not exceed 32 bits.
64+
unsigned bit_pack(span<const uint8_t> bits);
65+
5666
/// \brief Packs a number of bits into bytes.
5767
/// \param[out] packed View of packed bits.
5868
/// \param[in] unpacked View of unpacked bits.

lib/ran/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#
88

99
add_library(srsran_ran
10+
csi_report/csi_report_config_helpers.cpp
1011
csi_report/csi_report_unpacking.cpp
1112
csi_report/csi_report_unpacking_helpers.cpp
12-
csi_report/csi_report_config_helpers.cpp
1313
csi_rs/csi_rs_pattern.cpp
1414
csi_rs/csi_rs_config_helpers.cpp
1515
csi_rs/frequency_allocation_type.cpp
@@ -30,6 +30,7 @@ add_library(srsran_ran
3030
pusch/pusch_mcs.cpp
3131
pusch/pusch_uci_beta_offset.cpp
3232
pusch/ulsch_info.cpp
33+
uci/uci_part2_size_calculator.cpp
3334
band_helper.cpp
3435
resource_allocation/resource_allocation_frequency.cpp
3536
sch/sch_segmentation.cpp

lib/ran/csi_report/csi_report_wideband_cqi.cpp

Lines changed: 0 additions & 83 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
*
3+
* Copyright 2021-2023 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#include "srsran/ran/uci/uci_part2_size_calculator.h"
12+
#include "srsran/srsvec/bit.h"
13+
14+
using namespace srsran;
15+
16+
unsigned srsran::uci_part2_get_size(span<const uint8_t> part1, const uci_part2_size_description& descr)
17+
{
18+
unsigned result = 0;
19+
20+
// Iterate all entries.
21+
for (const uci_part2_size_description::entry& entry : descr.entries) {
22+
unsigned index = 0;
23+
unsigned index_bitwidth = 0;
24+
25+
for (const uci_part2_size_description::parameter& parameter : entry.parameters) {
26+
// Extract the value of the parameter.
27+
unsigned value = srsvec::bit_pack(part1.subspan(parameter.offset, parameter.width));
28+
29+
// Combine the parameter value with the current index.
30+
index = (index << parameter.width) | value;
31+
32+
// Accumulate the index bit width.
33+
index_bitwidth += parameter.width;
34+
}
35+
36+
// Verify the map size is according to the index bit width.
37+
srsran_assert(entry.map.size() == (1U << index_bitwidth),
38+
"Invalid map size (i.e., {}), expected {} entries.",
39+
entry.map.size(),
40+
(1U << index_bitwidth));
41+
42+
// Verify that the index is within the map size.
43+
srsran_assert(
44+
index < entry.map.size(), "Index value (i.e., {}) exceeds the map size (i.e., {}).", index, entry.map.size());
45+
46+
// Add the Part 2 size corresponding to this entry.
47+
result += entry.map[index];
48+
}
49+
50+
return result;
51+
}

lib/srsvec/bit.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,19 @@ unsigned srsran::srsvec::bit_pack(span<const uint8_t>& bits, unsigned nof_bits)
205205
return value;
206206
}
207207

208+
unsigned srsran::srsvec::bit_pack(span<const uint8_t> bits)
209+
{
210+
srsran_assert(bits.size() <= 32U, "Number of bits ({}) exceeds maximum (32).", bits.size());
211+
212+
unsigned value = 0;
213+
214+
for (unsigned i = 0, nof_bits = bits.size(); i != nof_bits; i++) {
215+
value |= (unsigned)bits[i] << (nof_bits - i - 1U);
216+
}
217+
218+
return value;
219+
}
220+
208221
void srsran::srsvec::bit_pack(span<uint8_t> packed, span<const uint8_t> unpacked)
209222
{
210223
srsran_assert(divide_ceil(unpacked.size(), 8) == packed.size(), "Inconsistent input sizes.");

tests/unittests/ran/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ add_executable(resource_allocation_frequency_test resource_allocation/resource_a
6969
target_link_libraries(resource_allocation_frequency_test srsran_support srsran_ran)
7070
add_test(resource_allocation_frequency_test resource_allocation_frequency_test)
7171

72+
add_executable(uci_part2_size_calculator_test uci/uci_part2_size_calculator_test.cpp)
73+
target_link_libraries(uci_part2_size_calculator_test srsran_support srsran_ran srsvec gtest gtest_main)
74+
add_test(uci_part2_size_calculator_test uci_part2_size_calculator_test)
75+
7276
add_executable(slot_point_test slot_point_test.cpp)
7377
target_link_libraries(slot_point_test srsran_support)
7478
add_test(slot_point_test slot_point_test)

0 commit comments

Comments
 (0)