Skip to content

Commit 9a89bd1

Browse files
xavierarteagacodebot
authored andcommitted
phy: review PDSCH related constants
1 parent 184f18c commit 9a89bd1

File tree

12 files changed

+81
-37
lines changed

12 files changed

+81
-37
lines changed

include/srsran/adt/bit_buffer.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,12 @@ class static_bit_buffer : public bit_buffer
289289
static_bit_buffer(static_bit_buffer&& other) : bit_buffer(buffer, other.size()){};
290290

291291
/// Resizes the bit buffer.
292-
void resize(unsigned new_size) { set_buffer(buffer, new_size); }
292+
void resize(unsigned new_size)
293+
{
294+
srsran_assert(
295+
new_size <= SizeInBits, "The new size (i.e., {}) exceeds the memory size (i.e., {}).", new_size, SizeInBits);
296+
set_buffer(buffer, new_size);
297+
}
293298

294299
private:
295300
/// Static memory container.

include/srsran/phy/upper/channel_processors/pdsch_modulator.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ class resource_grid_mapper;
3232
class pdsch_modulator
3333
{
3434
public:
35-
/// Defines the maximum number of codewords per PDSCH transmission.
36-
static constexpr unsigned MAX_NOF_CODEWORDS = 2;
37-
38-
/// Defines the maximum number of RE per codeword in a PDSCH transmission.
39-
static constexpr unsigned MAX_CODEWORD_SIZE = MAX_RB * NRE * MAX_NSYMB_PER_SLOT * MAX_PORTS / 2;
40-
4135
/// Describes the necessary parameters to modulate a PDSCH transmission.
4236
struct config_t {
4337
/// Provides \f$n_{RNTI}\f$ from TS38.211 section 7.3.1.1 Scrambling.

include/srsran/phy/upper/channel_processors/pdsch_processor.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,8 @@ class resource_grid_mapper;
2929
class pdsch_processor
3030
{
3131
public:
32-
/// \brief Maximum number of resource elements per resource block in a shared channel transmission.
33-
/// As per TS 38.214 section 5.1.3.2 Transport block size determination.
34-
static constexpr unsigned MAX_NRE_PER_RB = 156;
3532
/// Defines the maximum number of codewords that can be encoded in a PDSCH transmission.
3633
static constexpr unsigned MAX_NOF_TRANSPORT_BLOCKS = 2;
37-
/// \brief Defines the maximum number of layers per codeword.
38-
/// As per TS 38.211 table Table 7.3.1.3-1: Codeword-to-layer mapping for spatial multiplexing.
39-
static constexpr unsigned MAX_LAYER_PER_CODEWORD = 4;
40-
/// Defines the maximum codeword size.
41-
static constexpr unsigned MAX_CODEWORD_SIZE =
42-
MAX_RB * MAX_NRE_PER_RB * MODULATION_MAX_BITS_PER_SYMBOL * MAX_LAYER_PER_CODEWORD;
4334

4435
/// \brief Describes a codeword configuration.
4536
/// \note The transport block size is given by the transport block data size.

include/srsran/ran/pdsch/pdsch_constants.h

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,62 @@
77
* the distribution.
88
*
99
*/
10+
///\file
11+
///\brief pdsch_constants - namespace containing constants related to PDSCH transmissions.
1012

1113
#pragma once
1214

15+
#include "srsran/ran/resource_block.h"
16+
#include "srsran/support/units.h"
1317
#include <cstddef>
1418

1519
namespace srsran {
1620

17-
/// \brief Maximum size in bytes of a PDSCH PDU for a given UE.
21+
namespace pdsch_constants {
22+
23+
/// \brief Maximum number of RE per resource block in a PDSCH transmission.
24+
///
25+
/// As per TS38.214 Section 5.1.3.2.
26+
static constexpr unsigned MAX_NRE_PER_RB = 156;
27+
28+
/// \brief Maximum modulation order supported on PDSCH transmissions.
29+
///
30+
/// As per TS38.214 Section 5.1.3.1 with \c mcs-Table set to \c qam256.
31+
static constexpr unsigned MAX_MODULATION_ORDER = 8;
32+
33+
/// \brief Maximum number of PDSCH transmission layers per codeword.
34+
///
35+
/// As per TS38.211 Table 7.3.1.3-1.
36+
static constexpr unsigned CODEWORD_MAX_NOF_LAYERS = 4;
37+
38+
/// \brief Maximuym number of codewords that can be contained in a PDSCH transmission.
39+
///
40+
/// As per TS38.211 Table 7.3.1.3-1.
41+
static constexpr unsigned MAX_NOF_CODEWORDS = 2;
42+
43+
/// \brief Maximum number of PDSCH transmission layers.
1844
///
19-
/// It is not given by the TS. It assumes 156 resource elements for a maximum of 275 PRB, four layers and 256-QAM.
20-
static constexpr size_t MAX_DL_PDU_LENGTH = (156 * 275 * 4 * 8) / 8;
45+
/// As per TS38.211 Table 7.3.1.3-1.
46+
static constexpr unsigned MAX_NOF_LAYERS = CODEWORD_MAX_NOF_LAYERS * MAX_NOF_CODEWORDS;
47+
48+
/// \brief Maximum number of resource elements that can be mapped into a single codeword.
49+
///
50+
/// Calculated as the product of maximum number or RE per PRB and the maximum number of PRB in the a resource grid.
51+
static constexpr unsigned CODEWORD_MAX_NOF_RE = MAX_NRE_PER_RB * MAX_NOF_PRBS;
52+
53+
/// \brief Maximum number of symbols that can be mapped into a single codeword.
54+
///
55+
/// Calculated as the product of the maximum number of resource elements and the maximum layers
56+
static constexpr unsigned CODEWORD_MAX_SYMBOLS = CODEWORD_MAX_NOF_RE * CODEWORD_MAX_NOF_LAYERS;
57+
58+
/// \brief Maximum number of bits that can be modulated into a single codeword.
59+
///
60+
/// Calculated as the product of the maximum number of resource elements and the maximum modulation order.
61+
static constexpr units::bits CODEWORD_MAX_SIZE{CODEWORD_MAX_SYMBOLS * MAX_MODULATION_ORDER};
62+
63+
} // namespace pdsch_constants
64+
65+
/// \brief Maximum size in bytes of a PDSCH PDU for a given UE.
66+
static constexpr size_t MAX_DL_PDU_LENGTH = pdsch_constants::CODEWORD_MAX_SIZE.round_up_to_bytes().value();
2167

2268
} // namespace srsran

include/srsran/ran/pusch/pusch_constants.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ static constexpr unsigned MAX_NRE_PER_RB = 156;
2828
/// As per TS38.214 Section 6.1.4.1 with \c mcs-Table set to \c qam256.
2929
static constexpr unsigned MAX_MODULATION_ORDER = 8;
3030

31-
/// Maximum number of PUSCH transmission layers, as per TS38.211 Section 6.3.1.3.
31+
/// \brief Maximum number of PUSCH transmission layers.
32+
///
33+
/// As per TS38.211 Section 6.3.1.3.
3234
static constexpr unsigned MAX_NOF_LAYERS = 4;
3335

3436
/// Maximum number of OFDM symbols carrying DM-RS in a slot is at most \f$4 \times 2\f$, being 4 the maximum

lib/phy/upper/channel_processors/pdsch_modulator_impl.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "srsran/phy/upper/channel_processors/pdsch_modulator.h"
1515
#include "srsran/phy/upper/sequence_generators/pseudo_random_generator.h"
1616
#include "srsran/ran/cyclic_prefix.h"
17+
#include "srsran/ran/pdsch/pdsch_constants.h"
1718

1819
namespace srsran {
1920

@@ -52,11 +53,11 @@ class pdsch_modulator_impl : public pdsch_modulator
5253
static void map(resource_grid_mapper& mapper, const re_buffer_reader& data_re, const config_t& config);
5354

5455
/// Temporary buffer for scrambled sequence.
55-
static_bit_buffer<MAX_CODEWORD_SIZE> temp_b_hat;
56+
static_bit_buffer<pdsch_constants::CODEWORD_MAX_SIZE.value()> temp_b_hat;
5657
/// Temporary buffer for the PDSCH modulated symbols.
57-
std::array<cf_t, MAX_CODEWORD_SIZE> temp_pdsch_symbols;
58+
std::array<cf_t, pdsch_constants::CODEWORD_MAX_SYMBOLS> temp_pdsch_symbols;
5859
/// Temporary buffer for the PDSCH layer-mapped RE.
59-
static_re_buffer<precoding_constants::MAX_NOF_LAYERS, MAX_RB * NRE * MAX_NSYMB_PER_SLOT> temp_re;
60+
static_re_buffer<pdsch_constants::MAX_NOF_LAYERS, pdsch_constants::CODEWORD_MAX_NOF_RE> temp_re;
6061

6162
public:
6263
/// \brief Generic PDSCH modulator instance constructor.

lib/phy/upper/channel_processors/pdsch_processor_concurrent_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void pdsch_processor_concurrent_impl::process(resource_grid_mapper&
168168
modulator_config.precoding = pdu.precoding;
169169

170170
// Prepare encoded codewords.
171-
static_vector<bit_buffer, pdsch_modulator::MAX_NOF_CODEWORDS> codewords = {temp_packed_codeword};
171+
static_vector<bit_buffer, pdsch_constants::MAX_NOF_CODEWORDS> codewords = {temp_packed_codeword};
172172

173173
// Actual modulation.
174174
modulator->modulate(mapper, codewords, modulator_config);

lib/phy/upper/channel_processors/pdsch_processor_concurrent_impl.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "srsran/phy/upper/channel_processors/pdsch_modulator.h"
1616
#include "srsran/phy/upper/channel_processors/pdsch_processor.h"
1717
#include "srsran/phy/upper/signal_processors/dmrs_pdsch_processor.h"
18+
#include "srsran/ran/pdsch/pdsch_constants.h"
1819
#include "srsran/srsvec/bit.h"
1920
#include "srsran/support/executors/task_executor.h"
2021
#include <condition_variable>
@@ -87,11 +88,11 @@ class pdsch_processor_concurrent_impl : public pdsch_processor
8788
std::mutex cb_count_mutex;
8889
std::condition_variable cb_count_cvar;
8990

90-
std::unique_ptr<pdsch_modulator> modulator;
91-
std::unique_ptr<dmrs_pdsch_processor> dmrs;
92-
std::array<uint8_t, MAX_CODEWORD_SIZE> temp_codeword;
93-
static_bit_buffer<pdsch_modulator::MAX_CODEWORD_SIZE> temp_packed_codeword;
94-
task_executor& executor;
91+
std::unique_ptr<pdsch_modulator> modulator;
92+
std::unique_ptr<dmrs_pdsch_processor> dmrs;
93+
std::array<uint8_t, pdsch_constants::CODEWORD_MAX_SIZE.value()> temp_codeword;
94+
static_bit_buffer<pdsch_constants::CODEWORD_MAX_SIZE.value()> temp_packed_codeword;
95+
task_executor& executor;
9596
};
9697

9798
} // namespace srsran

lib/phy/upper/channel_processors/pdsch_processor_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void pdsch_processor_impl::process(resource_grid_mapper&
116116
unsigned nof_re_pdsch = compute_nof_data_re(pdu);
117117

118118
// Prepare encoded codewords.
119-
static_vector<bit_buffer, pdsch_modulator::MAX_NOF_CODEWORDS> codewords;
119+
static_vector<bit_buffer, pdsch_constants::MAX_NOF_CODEWORDS> codewords;
120120

121121
// Encode each codeword.
122122
for (unsigned codeword_id = 0; codeword_id != nof_codewords; ++codeword_id) {
@@ -222,7 +222,7 @@ const bit_buffer& pdsch_processor_impl::encode(span<const uint8_t> data,
222222
// Select codeword specific parameters.
223223
unsigned rv = pdu.codewords[codeword_id].rv;
224224
modulation_scheme modulation = pdu.codewords[codeword_id].modulation;
225-
span<uint8_t> tmp_codeword = temp_codewords[codeword_id];
225+
span<uint8_t> tmp_codeword = temp_unpacked_codeword;
226226

227227
// Prepare encoder configuration.
228228
segmenter_config encoder_config;

lib/phy/upper/channel_processors/pdsch_processor_impl.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "srsran/phy/upper/channel_processors/pdsch_modulator.h"
1414
#include "srsran/phy/upper/channel_processors/pdsch_processor.h"
1515
#include "srsran/phy/upper/signal_processors/dmrs_pdsch_processor.h"
16+
#include "srsran/ran/pdsch/pdsch_constants.h"
1617

1718
namespace srsran {
1819

@@ -78,11 +79,12 @@ class pdsch_processor_impl : public pdsch_processor
7879
/// \param[in] pdu Provides the PDSCH processor PDU.
7980
void put_dmrs(resource_grid_mapper& mapper, const pdu_t& pdu);
8081

81-
std::unique_ptr<pdsch_encoder> encoder;
82-
std::unique_ptr<pdsch_modulator> modulator;
83-
std::unique_ptr<dmrs_pdsch_processor> dmrs;
84-
std::array<std::array<uint8_t, MAX_CODEWORD_SIZE>, MAX_NOF_TRANSPORT_BLOCKS> temp_codewords;
85-
std::array<static_bit_buffer<pdsch_modulator::MAX_CODEWORD_SIZE>, MAX_NOF_TRANSPORT_BLOCKS> temp_packed_codewords;
82+
std::unique_ptr<pdsch_encoder> encoder;
83+
std::unique_ptr<pdsch_modulator> modulator;
84+
std::unique_ptr<dmrs_pdsch_processor> dmrs;
85+
std::array<uint8_t, pdsch_constants::CODEWORD_MAX_SIZE.value()> temp_unpacked_codeword;
86+
std::array<static_bit_buffer<pdsch_constants::CODEWORD_MAX_SIZE.value()>, MAX_NOF_TRANSPORT_BLOCKS>
87+
temp_packed_codewords;
8688
};
8789

8890
} // namespace srsran

0 commit comments

Comments
 (0)