Skip to content

Commit 35203b7

Browse files
joaquim-srscodebot
authored andcommitted
phy: fix timestamp overflow
1 parent ffef9ef commit 35203b7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/phy/lower/processors/downlink/downlink_processor_baseband_impl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ void downlink_processor_baseband_impl::process(baseband_gateway_buffer_writer& b
5353
// Process all the input samples.
5454
while (nof_written_samples < nof_output_samples) {
5555
// Timestamp of the remaining samples to process.
56-
unsigned proc_timestamp = timestamp + nof_written_samples;
56+
baseband_gateway_timestamp proc_timestamp = timestamp + nof_written_samples;
5757

5858
// If there are no samples available in the temporary buffer, process a new symbol.
5959
if (temp_buffer.get_nof_available_samples(proc_timestamp) == 0) {
6060
// Calculate the subframe index.
61-
unsigned i_sf = proc_timestamp / nof_samples_per_subframe;
62-
61+
auto i_sf =
62+
static_cast<unsigned>((proc_timestamp / nof_samples_per_subframe) % (NOF_SFNS * NOF_SUBFRAMES_PER_FRAME));
6363
// Calculate the sample index within the subframe.
6464
unsigned i_sample_sf = proc_timestamp % nof_samples_per_subframe;
6565

@@ -76,7 +76,7 @@ void downlink_processor_baseband_impl::process(baseband_gateway_buffer_writer& b
7676
unsigned i_symbol = i_symbol_sf % nof_symbols_per_slot;
7777

7878
// Create slot point.
79-
slot_point slot(to_numerology_value(scs), i_slot % (NOF_SFNS * NOF_SUBFRAMES_PER_FRAME * nof_slots_per_subframe));
79+
slot_point slot(to_numerology_value(scs), i_slot);
8080

8181
// Detect slot boundary.
8282
if (i_symbol == 0) {
@@ -101,7 +101,7 @@ void downlink_processor_baseband_impl::process(baseband_gateway_buffer_writer& b
101101
temp_buffer.clear();
102102

103103
// Timestamp of the first sample of the current OFDM symbol.
104-
unsigned symbol_timestamp = proc_timestamp - i_sample_symbol;
104+
baseband_gateway_timestamp symbol_timestamp = proc_timestamp - i_sample_symbol;
105105

106106
// Write the symbol into the temporary buffer.
107107
baseband_gateway_buffer_writer& dest_buffer = temp_buffer.write_symbol(symbol_timestamp, symbol_nof_samples);

0 commit comments

Comments
 (0)