Skip to content

Commit e6b553b

Browse files
xavierarteagacodebot
authored andcommitted
phy: remove resource grid coordinate put
1 parent ac872f4 commit e6b553b

File tree

10 files changed

+54
-219
lines changed

10 files changed

+54
-219
lines changed

include/srsran/phy/support/resource_grid_writer.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,6 @@
1717

1818
namespace srsran {
1919

20-
/// Describes a resource grid coordinate as symbol index and carrier.
21-
struct resource_grid_coordinate {
22-
/// Symbol index (0...13).
23-
uint8_t symbol = 0;
24-
/// Subcarrier index (0...3299).
25-
uint16_t subcarrier = 0;
26-
27-
/// Default destructor
28-
resource_grid_coordinate() = default;
29-
30-
/// \brief Constructor from \c unsigned values.
31-
/// \param[in] symbol_ Provides the \c symbol value.
32-
/// \param[in] subcarrier_ Provides the \c subcarrier value.
33-
resource_grid_coordinate(unsigned symbol_, unsigned subcarrier_) :
34-
symbol(static_cast<uint8_t>(symbol_)), subcarrier(static_cast<uint16_t>(subcarrier_))
35-
{
36-
}
37-
38-
/// \brief Overloads equal comparison operator.
39-
///
40-
/// Two resource grid coordinates are equal when symbol and subcarrier indexes are equal.
41-
/// \param[in] other The comparing coordinate.
42-
bool operator==(const resource_grid_coordinate& other) const
43-
{
44-
return (other.symbol == symbol) && (subcarrier == other.subcarrier);
45-
}
46-
};
47-
4820
/// \brief Resource grid writer interface.
4921
///
5022
/// Contains the necessary functions to write resource elements in a resource grid.
@@ -56,14 +28,6 @@ class resource_grid_writer : public resource_grid_base
5628
/// Default destructor
5729
virtual ~resource_grid_writer() = default;
5830

59-
/// \brief Puts a number of elements in the grid for a given port according to a list of coordinates.
60-
///
61-
/// \param[in] port Port index.
62-
/// \param[in] coordinates List of grid symbol&ndash;subcarrier coordinates.
63-
/// \param[in] symbols List of symbols to written at the specified coordinates.
64-
/// \note The number of elements in \c coordinates and \c symbols shall be the same.
65-
virtual void put(unsigned port, span<const resource_grid_coordinate> coordinates, span<const cf_t> symbols) = 0;
66-
6731
/// \brief Puts a number of resource elements in the resource grid at the given port and symbol using a mask to
6832
/// indicate which subcarriers are allocated and which are not.
6933
///

lib/phy/support/resource_grid_writer_impl.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,6 @@ unsigned resource_grid_writer_impl::get_nof_symbols() const
2929
return data.get_dimension_size(resource_grid_dimensions::symbol);
3030
}
3131

32-
void resource_grid_writer_impl::put(unsigned port,
33-
span<const resource_grid_coordinate> coordinates,
34-
span<const cf_t> symbols)
35-
{
36-
srsran_assert(coordinates.size() == symbols.size(),
37-
"The number of coordinates {} is not equal to the number of symbols {}.",
38-
coordinates.size(),
39-
symbols.size());
40-
41-
srsran_assert(port < get_nof_ports(), "The port index {} is out of range (max {}).", port, get_nof_ports() - 1);
42-
43-
unsigned count = 0;
44-
for (const resource_grid_coordinate& coordinate : coordinates) {
45-
srsran_assert(coordinate.symbol < get_nof_symbols(),
46-
"Symbol index {} is out of range (max {}).",
47-
coordinate.symbol,
48-
get_nof_symbols());
49-
srsran_assert(coordinate.subcarrier < get_nof_subc(),
50-
"Subcarrier index {} is out of range (max {}).",
51-
coordinate.subcarrier,
52-
get_nof_subc());
53-
54-
// Select destination OFDM symbol from the resource grid.
55-
span<cf_t> rg_symbol = data.get_view({coordinate.symbol, port});
56-
57-
// Write into the desired resource element.
58-
rg_symbol[coordinate.subcarrier] = symbols[count++];
59-
}
60-
clear_empty(port);
61-
}
62-
6332
span<const cf_t> resource_grid_writer_impl::put(unsigned port,
6433
unsigned l,
6534
unsigned k_init,

lib/phy/support/resource_grid_writer_impl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ class resource_grid_writer_impl : public resource_grid_writer
3232
// See interface for documentation.
3333
unsigned get_nof_symbols() const override;
3434

35-
// See interface for documentation.
36-
void put(unsigned port, span<const resource_grid_coordinate> coordinates, span<const cf_t> symbols) override;
37-
3835
// See interface for documentation.
3936
span<const cf_t>
4037
put(unsigned port, unsigned l, unsigned k_init, span<const bool> mask, span<const cf_t> symbols) override;

lib/phy/upper/channel_processors/pbch_modulator_impl.cpp

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,48 +39,42 @@ void pbch_modulator_impl::modulate(span<const uint8_t> b_hat, span<cf_t> d_pbch)
3939

4040
void pbch_modulator_impl::map(span<const cf_t> d_pbch, resource_grid_writer& grid, const config_t& config)
4141
{
42-
unsigned count = 0;
43-
unsigned l0 = config.ssb_first_symbol;
44-
unsigned k0 = config.ssb_first_subcarrier;
42+
unsigned l0 = config.ssb_first_symbol;
43+
unsigned k0 = config.ssb_first_subcarrier;
4544

46-
// Calculate DMRS index shift
45+
// Calculate DM-RS index shift.
4746
uint32_t v = config.phys_cell_id % 4;
4847

49-
// Create resource grid coordinates
50-
std::array<resource_grid_coordinate, M_symb> coordinates;
48+
// Resource element mask within each resource block. Remove DM-RS from the mask.
49+
bounded_bitset<NRE> re_mask = ~bounded_bitset<NRE>(NRE);
50+
re_mask.reset(v);
51+
re_mask.reset(v + 4);
52+
re_mask.reset(v + 8);
5153

52-
// Put sequence in symbol 1 (0, 1, ..., 239) not reserved for PBCH DM-RS
53-
for (uint32_t k = 0; k < SSB_BW_RE; ++k) {
54-
if (k % 4 != v) {
55-
coordinates[count++] = {l0 + 1, k0 + k};
56-
}
57-
}
54+
// Full SS/PBCH block bandwidth resource blocks.
55+
bounded_bitset<MAX_RB> rb_full_mask = ~bounded_bitset<MAX_RB>(SSB_BW_RB);
56+
bounded_bitset<NRE* MAX_RB> full_mask = rb_full_mask.kronecker_product<NRE>(re_mask);
5857

59-
// Put sequence in symbol 2, lower section (0 + v , 4 + v , 8 + v ,..., 44 + v) not reserved for PBCH DM-RS
60-
for (uint32_t k = 0; k < 48; ++k) {
61-
if (k % 4 != v) {
62-
coordinates[count++] = {l0 + 2, k0 + k};
63-
}
64-
}
58+
// Edges SS/PBCH block bandwidth resource blocks.
59+
bounded_bitset<MAX_RB> rb_edge_mask = bounded_bitset<MAX_RB>(SSB_BW_RB);
60+
rb_edge_mask.fill(0, 4);
61+
rb_edge_mask.fill(16, 20);
62+
bounded_bitset<NRE* MAX_RB> edge_mask = rb_edge_mask.kronecker_product<NRE>(re_mask);
6563

66-
// Put sequence in symbol 2, upper section (192 + v , 196 + v ,..., 236 + v) not reserved for PBCH DM-RS
67-
for (uint32_t k = 192; k < SSB_BW_RE; ++k) {
68-
if (k % 4 != v) {
69-
coordinates[count++] = {l0 + 2, k0 + k};
70-
}
71-
}
64+
// Map symbols for each of the ports.
65+
for (unsigned port : config.ports) {
66+
span<const cf_t> symbols = d_pbch;
7267

73-
// Put sequence in symbol 3 (0, 1, ..., 239) not reserved for PBCH DM-RS
74-
for (uint32_t k = 0; k < SSB_BW_RE; ++k) {
75-
if (k % 4 != v) {
76-
coordinates[count++] = {l0 + 3, k0 + k};
77-
}
78-
}
68+
// Put sequence in symbol 1 (0, 1, ..., 239), skip the subcarriers reserved for PBCH DM-RS.
69+
symbols = grid.put(port, l0 + 1, k0, full_mask, symbols);
7970

80-
// For each port
81-
for (unsigned port : config.ports) {
82-
// write data in grid
83-
grid.put(port, coordinates, d_pbch);
71+
// Put sequence in symbol 2 (0, 1, ..., 41) and (192, 193, ..., 239), skip the subcarriers reserved for PBCH DM-RS.
72+
symbols = grid.put(port, l0 + 2, k0, edge_mask, symbols);
73+
74+
// Put sequence in symbol 3 (0, 1, ..., 239), skip the subcarriers reserved for PBCH DM-RS.
75+
symbols = grid.put(port, l0 + 3, k0, full_mask, symbols);
76+
77+
srsran_assert(symbols.empty(), "Symbols must be empty.");
8478
}
8579
}
8680

lib/phy/upper/signal_processors/dmrs_pbch_processor_impl.cpp

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,42 +40,31 @@ void dmrs_pbch_processor_impl::mapping(const std::array<cf_t, NOF_RE>& r,
4040
resource_grid_writer& grid,
4141
const config_t& args) const
4242
{
43-
// Calculate index shift
43+
// Calculate index shift.
4444
uint32_t v = args.phys_cell_id % 4;
4545

46-
// r sequence read index
47-
uint32_t r_idx = 0;
48-
49-
// Create resource grid coordinates
50-
std::array<resource_grid_coordinate, NOF_RE> coordinates;
51-
5246
const uint8_t l0 = args.ssb_first_symbol;
5347
const uint16_t k0 = args.ssb_first_subcarrier;
5448

55-
// Put sequence in symbol 1 (0 + v , 4 + v , 8 + v ,..., 236 + v)
56-
for (uint16_t k = v; k < SSB_BW_RE; k += 4) {
57-
coordinates[r_idx++] = resource_grid_coordinate(l0 + 1, k0 + k);
58-
}
49+
// For each port...
50+
for (unsigned port : args.ports) {
51+
// Create view with the symbols.
52+
span<const cf_t> symbols = r;
5953

60-
// Put sequence in symbol 2, lower section (0 + v , 4 + v , 8 + v ,..., 44 + v)
61-
for (uint16_t k = v; k < 48; k += 4) {
62-
coordinates[r_idx++] = resource_grid_coordinate(l0 + 2, k0 + k);
63-
}
54+
// Put sequence in symbol 1 (0 + v , 4 + v , 8 + v ,..., 236 + v).
55+
grid.put(port, l0 + 1, k0 + v, stride, symbols.first(nof_dmrs_full_symbol));
56+
symbols = symbols.last(symbols.size() - nof_dmrs_full_symbol);
6457

65-
// Put sequence in symbol 2, upper section
66-
for (uint32_t k = 192 + v; k < SSB_BW_RE; k += 4) {
67-
coordinates[r_idx++] = resource_grid_coordinate(l0 + 2, k0 + k);
68-
}
58+
// Put sequence in symbol 2, lower section (0 + v , 4 + v , 8 + v ,..., 44 + v).
59+
grid.put(port, l0 + 2, k0 + v, stride, symbols.first(nof_dmrs_edge_symbol));
60+
symbols = symbols.last(symbols.size() - nof_dmrs_edge_symbol);
6961

70-
// Put sequence in symbol 3
71-
for (uint32_t k = v; k < SSB_BW_RE; k += 4) {
72-
coordinates[r_idx++] = resource_grid_coordinate(l0 + 3, k0 + k);
73-
}
62+
// Put sequence in symbol 2, upper section (192 + v , 196 + v , 200 + v ,..., 236 + v).
63+
grid.put(port, l0 + 2, k0 + v + 192, stride, symbols.first(nof_dmrs_edge_symbol));
64+
symbols = symbols.last(symbols.size() - nof_dmrs_edge_symbol);
7465

75-
// For each port...
76-
for (unsigned port : args.ports) {
77-
// ... put data in grid using the generated coordinates
78-
grid.put(port, coordinates, r);
66+
// Put sequence in symbol 3 (0 + v , 4 + v , 8 + v ,..., 236 + v).
67+
grid.put(port, l0 + 3, k0 + v, stride, symbols.first(nof_dmrs_full_symbol));
7968
}
8069
}
8170

lib/phy/upper/signal_processors/dmrs_pbch_processor_impl.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,16 @@ namespace srsran {
2020
class dmrs_pbch_processor_impl : public dmrs_pbch_processor
2121
{
2222
private:
23-
/// DMRS PBCH Sequence length in the SSB
24-
static const unsigned NOF_RE = 144;
23+
/// PBCH DM-RS stride within a resource block.
24+
static constexpr unsigned stride = 4U;
25+
/// Number of PBCH DM-RS per resource block.
26+
static constexpr unsigned nof_dmrs_prb = NRE / stride;
27+
/// Number of PBCH DM-RS contained in a full SS/PBCH block OFDM symbol.
28+
static constexpr unsigned nof_dmrs_full_symbol = SSB_BW_RB * nof_dmrs_prb;
29+
/// Number of PBCH DM-RS contained in one edge SS/PBCH block OFDM symbol.
30+
static constexpr unsigned nof_dmrs_edge_symbol = 4 * nof_dmrs_prb;
31+
/// Total number of resource elements for PBCH DM-RS in a SS/PBCH block.
32+
static constexpr unsigned NOF_RE = 2 * nof_dmrs_full_symbol + 2 * nof_dmrs_edge_symbol;
2533

2634
std::unique_ptr<pseudo_random_generator> prg;
2735

tests/unittests/ofh/receiver/helpers.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ class resource_grid_writer_bool_spy : public resource_grid_writer
6969
unsigned get_nof_ports() const override { return 1; };
7070
unsigned get_nof_subc() const override { return 51 * NOF_SUBCARRIERS_PER_RB; };
7171
unsigned get_nof_symbols() const override { return MAX_NSYMB_PER_SLOT; };
72-
void put(unsigned port, span<const resource_grid_coordinate> coordinates, span<const cf_t> symbols) override
73-
{
74-
grid_written = true;
75-
nof_prbs_written += symbols.size() / NOF_SUBCARRIERS_PER_RB;
76-
}
7772

7873
span<const cf_t>
7974
put(unsigned port, unsigned l, unsigned k_init, span<const bool> mask, span<const cf_t> symbols) override

tests/unittests/ofh/transmitter/ofh_uplink_request_handler_impl_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class resource_grid_dummy : public resource_grid
9696
unsigned get_nof_ports() const override { return 1; }
9797
unsigned get_nof_subc() const override { return 1; }
9898
unsigned get_nof_symbols() const override { return 1; }
99-
void put(unsigned port, span<const resource_grid_coordinate> coordinates, span<const cf_t> symbols) override {}
10099
span<const cf_t>
101100
put(unsigned port, unsigned l, unsigned k_init, span<const bool> mask, span<const cf_t> symbols) override
102101
{

tests/unittests/phy/support/resource_grid_test.cpp

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -58,73 +58,6 @@ void test_all_zero(unsigned nof_ports, unsigned nof_symbols, unsigned nof_subc)
5858
}
5959
}
6060

61-
void test_coordinates(unsigned nof_ports, unsigned nof_symbols, unsigned nof_subc, unsigned nof_elements)
62-
{
63-
// Create grid and zero
64-
std::unique_ptr<resource_grid> grid = create_resource_grid(nof_ports, nof_symbols, nof_subc);
65-
grid->set_all_zero();
66-
67-
// Random distributions
68-
std::uniform_int_distribution<unsigned> port_dist(0, nof_ports - 1);
69-
std::uniform_int_distribution<uint8_t> symbol_dist(0, nof_symbols - 1);
70-
std::uniform_int_distribution<uint16_t> subc_dist(0, nof_subc - 1);
71-
std::uniform_real_distribution<float> value_dist(-1.0, +1.0);
72-
73-
std::vector<resource_grid_coordinate> coordinates(nof_elements);
74-
std::vector<cf_t> symbols_gold(nof_elements);
75-
76-
// Generate random elements
77-
unsigned port_gold = port_dist(rgen);
78-
for (unsigned i = 0; i != nof_elements; ++i) {
79-
// Generate coordinate, making sure there are no double entries
80-
bool doubled;
81-
do {
82-
doubled = false;
83-
coordinates[i] = {symbol_dist(rgen), subc_dist(rgen)};
84-
85-
// Check if the coordinate exists
86-
for (unsigned j = 0; j != i && !doubled; ++j) {
87-
doubled = (coordinates[i] == coordinates[j]);
88-
}
89-
} while (doubled);
90-
91-
// Create random value
92-
symbols_gold[i] = {value_dist(rgen), value_dist(rgen)};
93-
}
94-
95-
// Put elements in resource grid
96-
grid->get_writer().put(port_gold, coordinates, symbols_gold);
97-
98-
// Assert grid
99-
for (unsigned port = 0; port != nof_ports; ++port) {
100-
// Verify the grid for the port is NOT empty.
101-
TESTASSERT_EQ(port != port_gold, grid->get_reader().is_empty(port));
102-
103-
for (unsigned symbol = 0; symbol != nof_symbols; ++symbol) {
104-
// Get resource grid data for the given symbol
105-
std::vector<cf_t> rg_data(nof_subc);
106-
grid->get_reader().get(rg_data, port, symbol, 0);
107-
108-
for (unsigned subc = 0; subc != nof_subc; ++subc) {
109-
cf_t gold = {0.0, 0.0};
110-
cf_t value = rg_data[subc];
111-
112-
// Try to find the RE in coordinates
113-
resource_grid_coordinate coordinate = {symbol, subc};
114-
for (unsigned i = 0; i != nof_elements; ++i) {
115-
if (port == port_gold && coordinates[i] == coordinate) {
116-
gold = symbols_gold[i];
117-
break;
118-
}
119-
}
120-
121-
TESTASSERT_EQ(gold.real(), value.real());
122-
TESTASSERT_EQ(gold.imag(), value.imag());
123-
}
124-
}
125-
}
126-
}
127-
12861
void test_mask(unsigned nof_ports, unsigned nof_symbols, unsigned nof_subc, unsigned nof_elements)
12962
{
13063
// Create grid and zero
@@ -378,7 +311,6 @@ int main()
378311
test_all_zero(nof_ports, nof_symbols, nof_subc);
379312
// Test symbolic number of elements
380313
for (unsigned nof_elements : {1, 2, 4, 8, 16, 32}) {
381-
test_coordinates(nof_ports, nof_symbols, nof_subc, nof_elements);
382314
test_mask(nof_ports, nof_symbols, nof_subc, nof_elements);
383315
test_mask_bitset(nof_ports, nof_symbols, nof_subc, nof_elements);
384316
test_consecutive(nof_ports, nof_symbols, nof_subc, nof_elements);

tests/unittests/phy/support/resource_grid_test_doubles.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,6 @@ class resource_grid_writer_spy : public resource_grid_writer
6868
// See interface for documentation.
6969
unsigned get_nof_symbols() const override { return max_symb; }
7070

71-
// See interface for documentation.
72-
void put(unsigned port, span<const resource_grid_coordinate> coordinates, span<const cf_t> symbols) override
73-
{
74-
std::unique_lock<std::mutex> lock(entries_mutex);
75-
++count;
76-
const cf_t* symbol_ptr = symbols.begin();
77-
for (const resource_grid_coordinate& coordinate : coordinates) {
78-
put(port, coordinate.symbol, coordinate.subcarrier, *(symbol_ptr++));
79-
}
80-
fmt::print("entries.size()={}\n", entries.size());
81-
}
82-
8371
// See interface for documentation.
8472
span<const cf_t>
8573
put(unsigned port, unsigned l, unsigned k_init, span<const bool> mask, span<const cf_t> symbols) override

0 commit comments

Comments
 (0)