diff --git a/executables/nr-ru.c b/executables/nr-ru.c index ea43ecdff1..ad4690c034 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -247,7 +247,7 @@ int connect_rau(RU_t *ru) { void fh_if5_south_out(RU_t *ru, int frame, int slot, uint64_t timestamp) { if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx & 0xffffffff); - int offset = ru->nr_frame_parms->get_samples_slot_timestamp(slot,ru->nr_frame_parms,0); + int offset = get_samples_slot_timestamp(ru->nr_frame_parms, slot); void *buffs[ru->nb_tx]; for (int aid = 0; aid < ru->nb_tx; aid++) buffs[aid] = (void*)&ru->common.txdata[aid][offset]; @@ -260,15 +260,9 @@ void fh_if5_south_out(RU_t *ru, int frame, int slot, uint64_t timestamp) { timestamp, buffs[0], buffs[1], - 10 * log10((double)signal_energy(buffs[0], ru->nr_frame_parms->get_samples_per_slot(slot, ru->nr_frame_parms))), + 10 * log10((double)signal_energy(buffs[0], get_samples_per_slot(slot, ru->nr_frame_parms))), (int)txmeas.tv_nsec); - ru->ifdevice.trx_write_func2(&ru->ifdevice, - timestamp, - buffs, - 0, - ru->nr_frame_parms->get_samples_per_slot(slot,ru->nr_frame_parms), - 0, - ru->nb_tx); + ru->ifdevice.trx_write_func2(&ru->ifdevice, timestamp, buffs, 0, get_samples_per_slot(slot, ru->nr_frame_parms), 0, ru->nb_tx); } // southbound IF4p5 fronthaul @@ -295,11 +289,11 @@ void fh_if5_south_in(RU_t *ru, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF5, 1 ); start_meas(&ru->rx_fhaul); - ru->ifdevice.trx_read_func2(&ru->ifdevice, &proc->timestamp_rx, NULL, fp->get_samples_per_slot(*tti, fp)); + ru->ifdevice.trx_read_func2(&ru->ifdevice, &proc->timestamp_rx, NULL, get_samples_per_slot(*tti, fp)); if (proc->first_rx == 1) ru->ts_offset = proc->timestamp_rx; proc->frame_rx = ((proc->timestamp_rx - ru->ts_offset) / (fp->samples_per_subframe * 10)) & 1023; - proc->tti_rx = fp->get_slot_from_timestamp(proc->timestamp_rx - ru->ts_offset, fp); + proc->tti_rx = get_slot_from_timestamp(proc->timestamp_rx - ru->ts_offset, fp); if (proc->first_rx == 0) { if (proc->tti_rx != *tti) { @@ -383,7 +377,7 @@ void fh_if4p5_south_in(RU_t *ru, //caculate timestamp_rx, timestamp_tx based on frame and subframe proc->tti_rx = sl; proc->frame_rx = f; - proc->timestamp_rx = (proc->frame_rx * fp->samples_per_subframe * 10) + fp->get_samples_slot_timestamp(proc->tti_rx, fp, 0); + proc->timestamp_rx = (proc->frame_rx * fp->samples_per_subframe * 10) + get_samples_slot_timestamp(fp, proc->tti_rx); // proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_subframe); proc->tti_tx = (sl+ru->sl_ahead)%fp->slots_per_frame; proc->frame_tx = (sl > (fp->slots_per_frame - 1 - (ru->sl_ahead))) ? (f + 1) & 1023 : f; @@ -528,7 +522,7 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *slot) { proc->frame_tx_unwrap += 1024; proc->timestamp_tx = - ((uint64_t)frame_tx + proc->frame_tx_unwrap) * fp->samples_per_subframe * 10 + fp->get_samples_slot_timestamp(slot_tx, fp, 0); + ((uint64_t)frame_tx + proc->frame_tx_unwrap) * fp->samples_per_subframe * 10 + get_samples_slot_timestamp(fp, slot_tx); LOG_D(PHY, "RU %d/%d TST %lu, frame %d, subframe %d\n", ru->idx, 0, proc->timestamp_tx, frame_tx, slot_tx); // dump VCD output for first RU in list @@ -566,14 +560,14 @@ static void rx_rf(RU_t *ru, int *frame, int *slot) RU_proc_t *proc = &ru->proc; NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; openair0_config_t *cfg = &ru->openair0_cfg; - uint32_t samples_per_slot = fp->get_samples_per_slot(*slot, fp); + uint32_t samples_per_slot = get_samples_per_slot(*slot, fp); AssertFatal(*slot < fp->slots_per_frame && *slot >= 0, "slot %d is illegal (%d)\n", *slot, fp->slots_per_frame); start_meas(&ru->rx_fhaul); int nb = ru->nb_rx * ru->num_beams_period; void *rxp[nb]; for (int i = 0; i < nb; i++) - rxp[i] = (void *)&ru->common.rxdata[i][fp->get_samples_slot_timestamp(*slot, fp, 0)]; + rxp[i] = (void *)&ru->common.rxdata[i][get_samples_slot_timestamp(fp, *slot)]; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1); openair0_timestamp old_ts = proc->timestamp_rx; @@ -590,7 +584,7 @@ static void rx_rf(RU_t *ru, int *frame, int *slot) LOG_E(PHY, "rx_rf: Asked for %d samples, got %d from USRP\n", samples_per_slot, rxs); if (proc->first_rx != 1) { - uint32_t samples_per_slot_prev = fp->get_samples_per_slot((*slot - 1) % fp->slots_per_frame, fp); + uint32_t samples_per_slot_prev = get_samples_per_slot((*slot - 1) % fp->slots_per_frame, fp); if (proc->timestamp_rx - old_ts != samples_per_slot_prev) { LOG_D(PHY, @@ -609,7 +603,7 @@ static void rx_rf(RU_t *ru, int *frame, int *slot) // in fact the following line is the same as long as the timestamp_rx is synchronized to GPS. proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023; - proc->tti_rx = fp->get_slot_from_timestamp(proc->timestamp_rx,fp); + proc->tti_rx = get_slot_from_timestamp(proc->timestamp_rx, fp); // synchronize first reception to frame 0 subframe 0 LOG_D(PHY, "RU %d/%d TS %ld, GPS %f, SR %f, frame %d, slot %d.%d / %d\n", @@ -725,9 +719,9 @@ void tx_rf(RU_t *ru, int frame,int slot, uint64_t timestamp) T_INT(frame), T_INT(slot), T_INT(0), - T_BUFFER(&ru->common.txdata[0][fp->get_samples_slot_timestamp(slot, fp, 0)], fp->get_samples_per_slot(slot, fp) * 4)); + T_BUFFER(&ru->common.txdata[0][get_samples_slot_timestamp(fp, slot)], get_samples_per_slot(slot, fp) * 4)); int sf_extension = 0; - int siglen=fp->get_samples_per_slot(slot,fp); + int siglen = get_samples_per_slot(slot, fp); radio_tx_burst_flag_t flags_burst = TX_BURST_INVALID; radio_tx_gpio_flag_t flags_gpio = 0; @@ -786,7 +780,7 @@ void tx_rf(RU_t *ru, int frame,int slot, uint64_t timestamp) int nt = ru->nb_tx * ru->num_beams_period; void *txp[nt]; for (int i = 0; i < nt; i++) - txp[i] = (void *)&ru->common.txdata[i][fp->get_samples_slot_timestamp(slot, fp, 0)] - sf_extension * sizeof(int32_t); + txp[i] = (void *)&ru->common.txdata[i][get_samples_slot_timestamp(fp, slot)] - sf_extension * sizeof(int32_t); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp + ru->ts_offset) & 0xffffffff); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1); @@ -1176,7 +1170,7 @@ void *ru_thread(void *param) } proc->timestamp_tx = proc->timestamp_rx; for (int i = proc->tti_rx; i < proc->tti_rx + ru->sl_ahead; i++) - proc->timestamp_tx += fp->get_samples_per_slot(i % fp->slots_per_frame, fp); + proc->timestamp_tx += get_samples_per_slot(i % fp->slots_per_frame, fp); proc->tti_tx = (proc->tti_rx + ru->sl_ahead) % fp->slots_per_frame; proc->frame_tx = proc->tti_rx > proc->tti_tx ? (proc->frame_rx + 1) & 1023 : proc->frame_rx; LOG_D(PHY, diff --git a/executables/nr-ue.c b/executables/nr-ue.c index de752f1513..f57b663f1e 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -19,6 +19,7 @@ * contact@openairinterface.org */ +#include "PHY/defs_nr_common.h" #define _GNU_SOURCE // For pthread_setname_np #include #include @@ -383,7 +384,7 @@ static void RU_write(nr_rxtx_thread_data_t *rxtxD, bool sl_tx_action, c16_t **tx openair0_timestamp writeTimestamp = proc->timestamp_tx; int writeBlockSize = rxtxD->writeBlockSize; // if writeBlockSize gets longer that slot size, fill with dummy - const int maxWriteBlockSize = fp->get_samples_per_slot(proc->nr_slot_tx, fp); + const int maxWriteBlockSize = get_samples_per_slot(proc->nr_slot_tx, fp); while (writeBlockSize > maxWriteBlockSize) { const int dummyBlockSize = min(writeBlockSize - maxWriteBlockSize, maxWriteBlockSize); int tmp = openair0_write_reorder(&UE->rfdevice, writeTimestamp, (void **)txp, dummyBlockSize, fp->nb_antennas_tx, flags); @@ -423,7 +424,7 @@ void processSlotTX(void *arg) NR_DL_FRAME_PARMS *fp = &UE->frame_parms; c16_t *txp[fp->nb_antennas_tx]; for (int i = 0; i < fp->nb_antennas_tx; i++) { - txp[i] = UE->common_vars.txData[i] + fp->get_samples_slot_timestamp(proc->nr_slot_tx, fp, 0); + txp[i] = UE->common_vars.txData[i] + get_samples_slot_timestamp(fp, proc->nr_slot_tx); } if (proc->tx_slot_type == NR_UPLINK_SLOT || proc->tx_slot_type == NR_MIXED_SLOT) { @@ -656,24 +657,25 @@ void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, int duration_r void *rxp[NB_ANTENNAS_RX]; if (toTrash) for (int i = 0; i < fp->nb_antennas_rx; i++) - rxp[i] = malloc16(fp->get_samples_per_slot(0, fp) * 4); + rxp[i] = malloc16(get_samples_per_slot(0, fp) * 4); for (int x = 0; x < num_frames * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; x++) { // two frames for initial sync for (int slot = 0; slot < fp->slots_per_subframe; slot++) { if (!toTrash) for (int i = 0; i < fp->nb_antennas_rx; i++) - rxp[i] = ((void *)&UE->common_vars.rxdata[i][0]) - + 4 * ((x * fp->samples_per_subframe) + fp->get_samples_slot_timestamp(slot, fp, 0)); + rxp[i] = + ((void *)&UE->common_vars.rxdata[i][0]) + 4 * ((x * fp->samples_per_subframe) + get_samples_slot_timestamp(fp, slot)); - int read_block_size = fp->get_samples_per_slot(slot, fp); + int read_block_size = get_samples_per_slot(slot, fp); int tmp = UE->rfdevice.trx_read_func(&UE->rfdevice, timestamp, rxp, read_block_size, fp->nb_antennas_rx); UEscopeCopy(UE, ueTimeDomainSamplesBeforeSync, rxp[0], sizeof(c16_t), 1, read_block_size, 0); AssertFatal(read_block_size == tmp, ""); if (IS_SOFTMODEM_RFSIM) { - const openair0_timestamp writeTimestamp = *timestamp + fp->get_samples_slot_timestamp(slot, fp, duration_rx_to_tx) - - UE->N_TA_offset - UE->timing_advance - UE->timing_advance_ntn; - dummyWrite(UE, writeTimestamp, fp->get_samples_per_slot(slot, fp)); + int ta = UE->timing_advance + UE->timing_advance_ntn; + const openair0_timestamp writeTimestamp = + *timestamp + get_samples_slot_duration(fp, slot, duration_rx_to_tx) - UE->N_TA_offset - ta; + dummyWrite(UE, writeTimestamp, get_samples_per_slot(slot, fp)); } } } @@ -694,12 +696,13 @@ static void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, int d int slot = 0; int size = rx_offset; while (size > 0) { - const int unitTransfer = min(fp->get_samples_per_slot(slot, fp), size); + const int unitTransfer = min(get_samples_per_slot(slot, fp), size); const int res = UE->rfdevice.trx_read_func(&UE->rfdevice, timestamp, (void **)UE->common_vars.rxdata, unitTransfer, fp->nb_antennas_rx); DevAssert(unitTransfer == res); if (IS_SOFTMODEM_RFSIM) { - const openair0_timestamp writeTimestamp = *timestamp + fp->get_samples_slot_timestamp(slot, fp, duration_rx_to_tx) - - UE->N_TA_offset - UE->timing_advance - UE->timing_advance_ntn; + int ta = UE->timing_advance + UE->timing_advance_ntn; + const openair0_timestamp writeTimestamp = + *timestamp + get_samples_slot_duration(fp, slot, duration_rx_to_tx) - UE->N_TA_offset - ta; dummyWrite(UE, writeTimestamp, unitTransfer); } slot = (slot + 1) % fp->slots_per_subframe; @@ -708,15 +711,11 @@ static void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, int d } static inline int get_firstSymSamp(uint16_t slot, NR_DL_FRAME_PARMS *fp) { - if (fp->numerology_index == 0) - return fp->nb_prefix_samples0 + fp->ofdm_symbol_size; - int num_samples = (slot%(fp->slots_per_subframe/2)) ? fp->nb_prefix_samples : fp->nb_prefix_samples0; - num_samples += fp->ofdm_symbol_size; - return num_samples; + return get_samples_symbol_duration(fp, slot, 0, 1); } static inline int get_readBlockSize(uint16_t slot, NR_DL_FRAME_PARMS *fp) { - int rem_samples = fp->get_samples_per_slot(slot, fp) - get_firstSymSamp(slot, fp); + int rem_samples = get_samples_per_slot(slot, fp) - get_firstSymSamp(slot, fp); int next_slot_first_symbol = 0; if (slot < (fp->slots_per_frame-1)) next_slot_first_symbol = get_firstSymSamp(slot+1, fp); @@ -792,9 +791,9 @@ static inline void apply_ntn_config(PHY_VARS_NR_UE *UE, *duration_rx_to_tx = NR_UE_CAPABILITY_SLOT_RX_TO_TX + (koffset << mu); if (koffset > *ntn_koffset) - *timing_advance += fp->get_samples_slot_timestamp(slot_rx, fp, (koffset - *ntn_koffset) << mu); + *timing_advance += get_samples_slot_duration(fp, slot_rx, (koffset - *ntn_koffset) << mu); else if (koffset < *ntn_koffset) - *timing_advance -= fp->get_samples_slot_timestamp(slot_rx, fp, (*ntn_koffset - koffset) << mu); + *timing_advance -= get_samples_slot_duration(fp, slot_rx, (*ntn_koffset - koffset) << mu); *ntn_koffset = koffset; const int abs_subframe_tx = 10240 * hfn_rx + 10 * frame_rx + ((slot_rx + *duration_rx_to_tx) >> mu); @@ -1015,7 +1014,7 @@ void *UE_thread(void *arg) int firstSymSamp = get_firstSymSamp(slot_nr, fp); for (int i = 0; i < fp->nb_antennas_rx; i++) - rxp[i] = (void *)&UE->common_vars.rxdata[i][firstSymSamp + fp->get_samples_slot_timestamp(slot_nr, fp, 0)]; + rxp[i] = (void *)&UE->common_vars.rxdata[i][firstSymSamp + get_samples_slot_timestamp(fp, slot_nr)]; int iq_shift_to_apply = 0; if (slot_nr == nb_slot_frame - 1) { @@ -1062,8 +1061,8 @@ void *UE_thread(void *arg) } // use previous timing_advance value to compute writeTimestamp - const openair0_timestamp writeTimestamp = rx_timestamp + fp->get_samples_slot_timestamp(slot_nr, fp, duration_rx_to_tx) - - firstSymSamp - UE->N_TA_offset - timing_advance; + const openair0_timestamp writeTimestamp = + rx_timestamp + get_samples_slot_duration(fp, slot_nr, duration_rx_to_tx) - firstSymSamp - UE->N_TA_offset - timing_advance; // Calculate TX deadline, approximately 1 symbol before the first sample should be written const uint64_t samples_diff = writeTimestamp - rx_timestamp - fp->ofdm_symbol_size; @@ -1071,7 +1070,7 @@ void *UE_thread(void *arg) const uint64_t absolute_deadline_us = current_time.tv_sec * 1e6 + current_time.tv_nsec / 1e3 + deadline_us; // but use current UE->timing_advance value to compute writeBlockSize - int writeBlockSize = fp->get_samples_per_slot((slot_nr + duration_rx_to_tx) % nb_slot_frame, fp) - iq_shift_to_apply; + int writeBlockSize = get_samples_per_slot((slot_nr + duration_rx_to_tx) % nb_slot_frame, fp) - iq_shift_to_apply; int new_timing_advance = UE->timing_advance + UE->timing_advance_ntn; if (new_timing_advance != timing_advance) { writeBlockSize -= new_timing_advance - timing_advance; diff --git a/openair1/PHY/CMakeLists.txt b/openair1/PHY/CMakeLists.txt index 83e7dc0530..34629fc1c7 100644 --- a/openair1/PHY/CMakeLists.txt +++ b/openair1/PHY/CMakeLists.txt @@ -3,3 +3,6 @@ add_subdirectory(TOOLS) add_subdirectory(NR_TRANSPORT) add_subdirectory(CODING) add_subdirectory(MODULATION) +if (ENABLE_TESTS) + add_subdirectory(INIT/tests) +endif() \ No newline at end of file diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index cc31dc173a..880d568ca6 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -259,33 +259,116 @@ uint32_t get_samples_per_slot(int slot, const NR_DL_FRAME_PARMS *fp) return samp_count; } -uint32_t get_slot_from_timestamp(openair0_timestamp timestamp_rx, const NR_DL_FRAME_PARMS *fp) +uint32_t get_samples_symbol_duration(const NR_DL_FRAME_PARMS *fp, int slot, int start_symbol, int num_symbols) { - uint32_t slot_idx = 0; - int samples_till_the_slot = fp->get_samples_per_slot(slot_idx,fp)-1; - timestamp_rx = timestamp_rx%fp->samples_per_frame; + int end_symbol = start_symbol + num_symbols - 1; + AssertFatal(start_symbol <= end_symbol && start_symbol >= 0 && end_symbol < fp->symbols_per_slot, + "Symbol range is invalid start_symbol %d, num_symbols %d symbols_per_slot %d\n", + start_symbol, + num_symbols, + fp->symbols_per_slot); + if (num_symbols == fp->symbols_per_slot) { + return get_samples_per_slot(slot, fp); + } + uint32_t num_samples = 0; + int num_symbols_added = 0; - while (timestamp_rx > samples_till_the_slot) { - slot_idx++; - samples_till_the_slot += fp->get_samples_per_slot(slot_idx,fp); - } - return slot_idx; + // Handle symbols with different nb_prefix_samples0 + if (fp->numerology_index == 0) { + // Add symbol 0 + if (start_symbol == 0) { + num_samples += fp->nb_prefix_samples0 + fp->ofdm_symbol_size; + num_symbols_added++; + } + // Add symbol 7 + if (start_symbol <= 7 && end_symbol >= 7) { + num_samples += fp->nb_prefix_samples0 + fp->ofdm_symbol_size; + num_symbols_added++; + } + } else { + // Add first symbol + if (start_symbol == 0) { + num_samples += (slot % (fp->slots_per_subframe / 2)) ? fp->nb_prefix_samples : fp->nb_prefix_samples0; + num_samples += fp->ofdm_symbol_size; + num_symbols_added++; + } + } + + int num_symbols_left = max(0, num_symbols - num_symbols_added); + num_samples += num_symbols_left * (fp->nb_prefix_samples + fp->ofdm_symbol_size); + return num_samples; } -uint32_t get_samples_slot_timestamp(int slot, const NR_DL_FRAME_PARMS *fp, unsigned int sl_ahead) +uint32_t get_samples_symbol_timestamp(const NR_DL_FRAME_PARMS *fp, int slot, int symbol) { - uint32_t samp_count = 0; - - if(!sl_ahead) { - for(unsigned int idx_slot = 0; idx_slot < slot; idx_slot++) - samp_count += fp->get_samples_per_slot(idx_slot, fp); - } else { - for (unsigned int idx_slot = slot; idx_slot < slot + sl_ahead; idx_slot++) - samp_count += fp->get_samples_per_slot(idx_slot, fp); + if (symbol == 0) { + return 0; } + + return get_samples_symbol_duration(fp, slot, 0, symbol); +} + +uint32_t get_slot_from_timestamp(openair0_timestamp timestamp_rx, const NR_DL_FRAME_PARMS *fp) +{ + timestamp_rx = timestamp_rx % fp->samples_per_frame; + if (timestamp_rx < fp->samples_per_slot0) + return 0; + + if (fp->numerology_index == 0) + return timestamp_rx / fp->samples_per_subframe; + + const unsigned int num_half_sf = timestamp_rx / (fp->samples_per_subframe / 2); + const unsigned int slot_per_half_sf = fp->slots_per_subframe / 2; + + uint32_t slot_count = num_half_sf * slot_per_half_sf; + int samp_idx = num_half_sf * (fp->samples_per_subframe / 2) - 1; + + // Remaining samples + if (samp_idx < timestamp_rx) { + slot_count++; + samp_idx += fp->samples_per_slot0; // First slot of half subframe + } + if (samp_idx < timestamp_rx) { + const unsigned int rem_samples = timestamp_rx - samp_idx; + const unsigned int num_slots = ceil((double)rem_samples / fp->samples_per_slotN0); + slot_count += num_slots; + } + + return slot_count - 1; +} + +uint32_t get_samples_slot_timestamp(const NR_DL_FRAME_PARMS *fp, unsigned int slot) +{ + if (slot == 0) + return 0; + + if (fp->numerology_index == 0) + return slot * fp->samples_per_subframe; + + uint32_t samp_count = 0; + // Number of half subframes + const unsigned int num_half_sf = slot / (fp->slots_per_subframe / 2); + samp_count += num_half_sf * fp->samples_per_subframe / 2; + + // Remaining slots + unsigned int rem_slots = slot % (fp->slots_per_subframe / 2); + if (rem_slots > 0) { + samp_count += fp->samples_per_slot0; // First slot of the last half subframe + rem_slots--; + } + samp_count += rem_slots * fp->samples_per_slotN0; // Remaining slots of the last half subframe + return samp_count; } +uint32_t get_samples_slot_duration(const NR_DL_FRAME_PARMS *fp, unsigned int start_slot, unsigned int num_slots) +{ + if (start_slot == 0 && num_slots == 0) + return 0; + + return (get_samples_slot_timestamp(fp, start_slot + num_slots) - get_samples_slot_timestamp(fp, start_slot)); +} + void nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg, NR_DL_FRAME_PARMS *fp) { @@ -319,12 +402,11 @@ void nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg, NR_DL_FRAME_PARMS * fp->samples_per_frame_wCP = 10 * fp->samples_per_subframe_wCP; fp->samples_per_slot_wCP = fp->symbols_per_slot*fp->ofdm_symbol_size; fp->samples_per_slotN0 = (fp->nb_prefix_samples + fp->ofdm_symbol_size) * fp->symbols_per_slot; - fp->samples_per_slot0 = fp->nb_prefix_samples0 + ((fp->symbols_per_slot-1)*fp->nb_prefix_samples) + (fp->symbols_per_slot*fp->ofdm_symbol_size); - fp->samples_per_subframe = (fp->nb_prefix_samples0 + fp->ofdm_symbol_size) * 2 + - (fp->nb_prefix_samples + fp->ofdm_symbol_size) * (fp->symbols_per_slot * fp->slots_per_subframe - 2); - fp->get_samples_per_slot = &get_samples_per_slot; - fp->get_samples_slot_timestamp = &get_samples_slot_timestamp; - fp->get_slot_from_timestamp = &get_slot_from_timestamp; + fp->samples_per_subframe = (fp->nb_prefix_samples0 + fp->ofdm_symbol_size) * 2 + + (fp->nb_prefix_samples + fp->ofdm_symbol_size) * (fp->symbols_per_slot * fp->slots_per_subframe - 2); + fp->samples_per_slot0 = fp->numerology_index == 0 ? fp->samples_per_subframe + : fp->nb_prefix_samples0 + ((fp->symbols_per_slot - 1) * fp->nb_prefix_samples) + + (fp->symbols_per_slot * fp->ofdm_symbol_size); fp->samples_per_frame = 10 * fp->samples_per_subframe; fp->freq_range = get_freq_range_from_freq(fp->dl_CarrierFreq); @@ -402,11 +484,11 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, fp->samples_per_frame_wCP = 10 * fp->samples_per_subframe_wCP; fp->samples_per_slot_wCP = fp->symbols_per_slot*fp->ofdm_symbol_size; fp->samples_per_slotN0 = (fp->nb_prefix_samples + fp->ofdm_symbol_size) * fp->symbols_per_slot; - fp->samples_per_slot0 = fp->nb_prefix_samples0 + ((fp->symbols_per_slot-1)*fp->nb_prefix_samples) + (fp->symbols_per_slot*fp->ofdm_symbol_size); - fp->samples_per_subframe = (fp->nb_prefix_samples0 + fp->ofdm_symbol_size) * 2 + - (fp->nb_prefix_samples + fp->ofdm_symbol_size) * (fp->symbols_per_slot * fp->slots_per_subframe - 2); - fp->get_samples_per_slot = &get_samples_per_slot; - fp->get_samples_slot_timestamp = &get_samples_slot_timestamp; + fp->samples_per_subframe = (fp->nb_prefix_samples0 + fp->ofdm_symbol_size) * 2 + + (fp->nb_prefix_samples + fp->ofdm_symbol_size) * (fp->symbols_per_slot * fp->slots_per_subframe - 2); + fp->samples_per_slot0 = fp->numerology_index == 0 ? fp->samples_per_subframe + : fp->nb_prefix_samples0 + ((fp->symbols_per_slot - 1) * fp->nb_prefix_samples) + + (fp->symbols_per_slot * fp->ofdm_symbol_size); fp->samples_per_frame = 10 * fp->samples_per_subframe; fp->freq_range = get_freq_range_from_freq(fp->dl_CarrierFreq); @@ -460,11 +542,14 @@ void nr_init_frame_parms_ue_sa(NR_DL_FRAME_PARMS *frame_parms, uint64_t downlink frame_parms->samples_per_frame_wCP = 10 * frame_parms->samples_per_subframe_wCP; frame_parms->samples_per_slot_wCP = frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size; frame_parms->samples_per_slotN0 = (frame_parms->nb_prefix_samples + frame_parms->ofdm_symbol_size) * frame_parms->symbols_per_slot; - frame_parms->samples_per_slot0 = frame_parms->nb_prefix_samples0 + ((frame_parms->symbols_per_slot-1)*frame_parms->nb_prefix_samples) + (frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size); - frame_parms->samples_per_subframe = (frame_parms->nb_prefix_samples0 + frame_parms->ofdm_symbol_size) * 2 + - (frame_parms->nb_prefix_samples + frame_parms->ofdm_symbol_size) * (frame_parms->symbols_per_slot * frame_parms->slots_per_subframe - 2); - frame_parms->get_samples_per_slot = &get_samples_per_slot; - frame_parms->get_samples_slot_timestamp = &get_samples_slot_timestamp; + frame_parms->samples_per_subframe = (frame_parms->nb_prefix_samples0 + frame_parms->ofdm_symbol_size) * 2 + + (frame_parms->nb_prefix_samples + frame_parms->ofdm_symbol_size) + * (frame_parms->symbols_per_slot * frame_parms->slots_per_subframe - 2); + frame_parms->samples_per_slot0 = frame_parms->numerology_index == 0 + ? frame_parms->samples_per_subframe + : frame_parms->nb_prefix_samples0 + + ((frame_parms->symbols_per_slot - 1) * frame_parms->nb_prefix_samples) + + (frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size); frame_parms->samples_per_frame = 10 * frame_parms->samples_per_subframe; LOG_W(PHY, "samples_per_subframe %d/per second %d, wCP %d\n", frame_parms->samples_per_subframe, 1000*frame_parms->samples_per_subframe, frame_parms->samples_per_subframe_wCP); @@ -560,12 +645,11 @@ int nr_init_frame_parms_ue_sl(NR_DL_FRAME_PARMS *fp, fp->samples_per_frame_wCP = 10 * fp->samples_per_subframe_wCP; fp->samples_per_slot_wCP = fp->symbols_per_slot * fp->ofdm_symbol_size; fp->samples_per_slotN0 = (fp->nb_prefix_samples + fp->ofdm_symbol_size) * fp->symbols_per_slot; - fp->samples_per_slot0 = - fp->nb_prefix_samples0 + ((fp->symbols_per_slot - 1) * fp->nb_prefix_samples) + (fp->symbols_per_slot * fp->ofdm_symbol_size); fp->samples_per_subframe = (fp->nb_prefix_samples0 + fp->ofdm_symbol_size) * 2 + (fp->nb_prefix_samples + fp->ofdm_symbol_size) * (fp->symbols_per_slot * fp->slots_per_subframe - 2); - fp->get_samples_per_slot = &get_samples_per_slot; - fp->get_samples_slot_timestamp = &get_samples_slot_timestamp; + fp->samples_per_slot0 = fp->numerology_index == 0 ? fp->samples_per_subframe + : fp->nb_prefix_samples0 + ((fp->symbols_per_slot - 1) * fp->nb_prefix_samples) + + (fp->symbols_per_slot * fp->ofdm_symbol_size); fp->samples_per_frame = 10 * fp->samples_per_subframe; fp->freq_range = get_freq_range_from_freq(fp->sl_CarrierFreq); diff --git a/openair1/PHY/INIT/nr_phy_init.h b/openair1/PHY/INIT/nr_phy_init.h index f556498f0f..bfe935d93f 100644 --- a/openair1/PHY/INIT/nr_phy_init.h +++ b/openair1/PHY/INIT/nr_phy_init.h @@ -55,10 +55,11 @@ void free_nr_ue_ul_harq(NR_UL_UE_HARQ_t harq_list[NR_MAX_ULSCH_HARQ_PROCESSES], void phy_init_nr_top(PHY_VARS_NR_UE *ue); void phy_term_nr_top(void); +#ifndef __cplusplus void init_delay_table(uint16_t ofdm_symbol_size, int max_delay_comp, int max_ofdm_symbol_size, c16_t delay_table[][max_ofdm_symbol_size]); - +#endif void sl_ue_phy_init(PHY_VARS_NR_UE *UE); #endif diff --git a/openair1/PHY/INIT/tests/CMakeLists.txt b/openair1/PHY/INIT/tests/CMakeLists.txt new file mode 100644 index 0000000000..9f41e0fec0 --- /dev/null +++ b/openair1/PHY/INIT/tests/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(test_nr_frame_params test_nr_frame_params.cpp) +target_link_libraries(test_nr_frame_params PRIVATE LOG minimal_lib PHY_NR -lm GTest::gtest) diff --git a/openair1/PHY/INIT/tests/test_nr_frame_params.cpp b/openair1/PHY/INIT/tests/test_nr_frame_params.cpp new file mode 100644 index 0000000000..e3e541f8ab --- /dev/null +++ b/openair1/PHY/INIT/tests/test_nr_frame_params.cpp @@ -0,0 +1,177 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "gtest/gtest.h" +extern "C" { +#include +#include "openair1/PHY/defs_nr_common.h" +#include "openair1/PHY/INIT/nr_phy_init.h" + +static softmodem_params_t softmodem_params; +softmodem_params_t *get_softmodem_params(void) +{ + return &softmodem_params; +} +} + +uint32_t ref_get_samples_slot_timestamp(NR_DL_FRAME_PARMS *fp, unsigned int slot) +{ + uint32_t samp_count = 0; + for (unsigned int i = 0; i < slot; i++) { + samp_count += get_samples_per_slot(i, fp); + } + return samp_count; +} + +uint32_t ref_get_slot_from_timestamp(openair0_timestamp ts, NR_DL_FRAME_PARMS *fp) +{ + uint32_t slot_idx = 0; + int samples_till_the_slot = get_samples_per_slot(slot_idx, fp) - 1; + ts = ts % fp->samples_per_frame; + + while (ts > samples_till_the_slot) { + slot_idx++; + samples_till_the_slot += get_samples_per_slot(slot_idx, fp); + } + return slot_idx; +} + +void test_coherence_symbol_api(NR_DL_FRAME_PARMS *fp) +{ + EXPECT_EQ(get_samples_symbol_timestamp(fp, 0, 0), get_samples_slot_timestamp(fp, 0)); + + for (int slot = 0; slot < 4; slot++) { + EXPECT_EQ(get_samples_symbol_duration(fp, slot, 0, fp->symbols_per_slot) + get_samples_slot_timestamp(fp, slot), + get_samples_slot_timestamp(fp, slot + 1)); + } + + for (int symbol = 0; symbol < fp->symbols_per_slot - 1; symbol++) { + EXPECT_EQ(get_samples_symbol_timestamp(fp, 0, symbol + 1) - get_samples_symbol_timestamp(fp, 0, symbol), + get_samples_symbol_duration(fp, 0, symbol, 1)); + } +} + +void test_coherence_slot_api(NR_DL_FRAME_PARMS *fp) +{ + for (unsigned int slot = 0; slot < fp->slots_per_frame; slot++) { + EXPECT_EQ(get_samples_slot_timestamp(fp, slot), ref_get_samples_slot_timestamp(fp, slot)); + } + + openair0_timestamp ts = get_samples_per_slot(0, fp); + // When timestamp is the last sample of the slot + EXPECT_EQ(get_slot_from_timestamp(ts - 1, fp), 0); + for (unsigned int slot = 0; slot < fp->slots_per_frame; slot++) { + // When timestamp is the first sample of the slot + ts = ref_get_samples_slot_timestamp(fp, slot); + EXPECT_EQ(get_slot_from_timestamp(ts, fp), slot); + // When timestamp is anywhere in the slot + ts += (rand() % fp->samples_per_slotN0); + EXPECT_EQ(get_slot_from_timestamp(ts, fp), slot); + } +} + +TEST(nr_frame_params, test_mu_3) +{ + NR_DL_FRAME_PARMS fp; + int mu = NR_MU_3; + memset(&fp, 0, sizeof(fp)); + nfapi_nr_config_request_scf_t cfg; + cfg.carrier_config.num_rx_ant.value = 4; + cfg.carrier_config.num_tx_ant.value = 4; + cfg.carrier_config.dl_grid_size[mu].value = 66; + cfg.carrier_config.ul_grid_size[mu].value = 66; + cfg.cell_config.frame_duplex_type.value = TDD; + cfg.ssb_config.scs_common.value = mu; + fp.dl_CarrierFreq = 27524520000; + fp.nr_band = 261; + nr_init_frame_parms(&cfg, &fp); + nr_dump_frame_parms(&fp); + test_coherence_symbol_api(&fp); + test_coherence_slot_api(&fp); +} + +TEST(nr_frame_params, test_mu_2) +{ + NR_DL_FRAME_PARMS fp; + int mu = NR_MU_2; + memset(&fp, 0, sizeof(fp)); + nfapi_nr_config_request_scf_t cfg; + cfg.carrier_config.num_rx_ant.value = 4; + cfg.carrier_config.num_tx_ant.value = 4; + cfg.carrier_config.dl_grid_size[mu].value = 51; + cfg.carrier_config.ul_grid_size[mu].value = 51; + cfg.cell_config.frame_duplex_type.value = TDD; + cfg.ssb_config.scs_common.value = mu; + fp.dl_CarrierFreq = 27524520000; + fp.nr_band = 261; + nr_init_frame_parms(&cfg, &fp); + nr_dump_frame_parms(&fp); + test_coherence_symbol_api(&fp); + test_coherence_slot_api(&fp); +} + +TEST(nr_frame_params, test_mu_1) +{ + NR_DL_FRAME_PARMS fp; + int mu = NR_MU_1; + memset(&fp, 0, sizeof(fp)); + nfapi_nr_config_request_scf_t cfg; + cfg.carrier_config.num_rx_ant.value = 4; + cfg.carrier_config.num_tx_ant.value = 4; + cfg.carrier_config.dl_grid_size[mu].value = 106; + cfg.carrier_config.ul_grid_size[mu].value = 106; + cfg.cell_config.frame_duplex_type.value = TDD; + cfg.ssb_config.scs_common.value = mu; + fp.dl_CarrierFreq = 3600000000; + fp.nr_band = 78; + nr_init_frame_parms(&cfg, &fp); + nr_dump_frame_parms(&fp); + test_coherence_symbol_api(&fp); + test_coherence_slot_api(&fp); +} + +TEST(nr_frame_params, test_mu_0) +{ + int mu = NR_MU_0; + NR_DL_FRAME_PARMS fp; + memset(&fp, 0, sizeof(fp)); + nfapi_nr_config_request_scf_t cfg; + cfg.carrier_config.num_rx_ant.value = 4; + cfg.carrier_config.num_tx_ant.value = 4; + cfg.carrier_config.dl_grid_size[mu].value = 216; + cfg.carrier_config.ul_grid_size[mu].value = 216; + cfg.cell_config.frame_duplex_type.value = TDD; + cfg.ssb_config.scs_common.value = mu; + fp.dl_CarrierFreq = 2600000000; + fp.nr_band = 38; + nr_init_frame_parms(&cfg, &fp); + nr_dump_frame_parms(&fp); + test_coherence_symbol_api(&fp); + test_coherence_slot_api(&fp); +} + +int main(int argc, char **argv) +{ + uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY); + logInit(); + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 50e19d8563..9045e50cb0 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -80,7 +80,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, // For Sidelink 16 frames worth of samples is processed to find SSB, for 5G-NR 2. const unsigned int total_samples = (is_sl) ? 16 * frame_parms->samples_per_frame : 2 * frame_parms->samples_per_frame; - unsigned int rx_offset = frame_parms->get_samples_slot_timestamp(slot, frame_parms, 0); + unsigned int rx_offset = get_samples_slot_timestamp(frame_parms, slot); const unsigned int abs_symbol = slot * frame_parms->symbols_per_slot + symbol; for (int idx_symb = slot * frame_parms->symbols_per_slot; idx_symb <= abs_symbol; idx_symb++) rx_offset += (idx_symb % (0x7 << frame_parms->numerology_index)) ? nb_prefix_samples : nb_prefix_samples0; @@ -150,7 +150,7 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, int32_t tmp_dft_in[8192] __attribute__ ((aligned (32))); // offset of first OFDM symbol - unsigned int rxdata_offset = frame_parms->get_samples_slot_timestamp(Ns,frame_parms,0); + unsigned int rxdata_offset = get_samples_slot_timestamp(frame_parms, Ns); unsigned int abs_symbol = Ns * frame_parms->symbols_per_slot + symbol; for (int idx_symb = Ns*frame_parms->symbols_per_slot; idx_symb <= abs_symbol; idx_symb++) rxdata_offset += (idx_symb%(0x7<numerology_index)) ? nb_prefix_samples : nb_prefix_samples0; diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach.c b/openair1/PHY/NR_TRANSPORT/nr_prach.c index 823af815d3..6ad39489d5 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach.c @@ -362,7 +362,7 @@ static void rx_nr_prach_ru_internal(prach_item_t *p, // Fixme: slot or slot makes no sense ??? int slot2 = p->prach_sequence_length ? p->slot : p->slot; int idx = aa + beam_id * p->nb_rx; - c16_t *prach = (c16_t *)&rxdata[idx][fp->get_samples_slot_timestamp(slot2, fp, 0) + sample_offset_slot - N_TA_offset]; + c16_t *prach = (c16_t *)&rxdata[idx][get_samples_slot_timestamp(fp, slot2) + sample_offset_slot - N_TA_offset]; // do DFT c16_t *prach2 = prach + Ncp; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 23972fc9f2..b9948eaf92 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -165,11 +165,6 @@ void init_prach_list(prach_list_t *); typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS; -typedef uint32_t (*get_samples_per_slot_t)(int slot, const NR_DL_FRAME_PARMS *fp); -typedef uint32_t (*get_slot_from_timestamp_t)(openair0_timestamp timestamp_rx, const NR_DL_FRAME_PARMS *fp); - -typedef uint32_t (*get_samples_slot_timestamp_t)(int slot, const NR_DL_FRAME_PARMS *fp, unsigned int sl_ahead); - struct NR_DL_FRAME_PARMS { /// frequency range frequency_range_t freq_range; @@ -225,12 +220,6 @@ struct NR_DL_FRAME_PARMS { uint16_t slots_per_frame; /// Number of samples in a subframe uint32_t samples_per_subframe; - /// Number of samples in current slot - get_samples_per_slot_t get_samples_per_slot; - /// slot calculation from timestamp - get_slot_from_timestamp_t get_slot_from_timestamp; - /// Number of samples before slot - get_samples_slot_timestamp_t get_samples_slot_timestamp; /// Number of samples in 0th and center slot of a subframe uint32_t samples_per_slot0; /// Number of samples in other slots of the subframe @@ -336,4 +325,17 @@ typedef struct { #define KHz (1000UL) #define MHz (1000*KHz) +// Get symbol duration within slot in samples +uint32_t get_samples_symbol_duration(const NR_DL_FRAME_PARMS *fp, int slot, int start_symbol, int num_symbols); +// Get timestamp of symbol within slot in samples +uint32_t get_samples_symbol_timestamp(const NR_DL_FRAME_PARMS *fp, int slot, int symbol); +// Get slot duration between two slot +uint32_t get_samples_slot_duration(const NR_DL_FRAME_PARMS *fp, unsigned int start_slot, unsigned int num_slots); +// Get timestamp of slot from start of frame +uint32_t get_samples_slot_timestamp(const NR_DL_FRAME_PARMS *fp, unsigned int slot); +// Get slot from timestamp +uint32_t get_slot_from_timestamp(openair0_timestamp timestamp_rx, const NR_DL_FRAME_PARMS *fp); +// Get number of samples in the slot +uint32_t get_samples_per_slot(int slot, const NR_DL_FRAME_PARMS *fp); + #endif diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index f121914f11..6bc7cb933a 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -58,7 +58,7 @@ void nr_feptx0(RU_t *ru, int tti_tx, int first_symbol, int num_symbols, int aa) if (aa == 0 && first_symbol == 0) start_meas(&ru->ofdm_mod_stats); - slot_offset = fp->get_samples_slot_timestamp(slot, fp, 0); + slot_offset = get_samples_slot_timestamp(fp, slot); slot_offsetF = first_symbol * fp->ofdm_symbol_size; int abs_first_symbol = slot * fp->symbols_per_slot; @@ -156,7 +156,7 @@ void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx) { int slot_sizeF = (fp->ofdm_symbol_size)* ((cyclic_prefix_type == 1) ? 12 : 14); int slot = tti_tx; - int *txdata = &ru->common.txdata[aa][fp->get_samples_slot_timestamp(slot,fp,0)]; + int *txdata = &ru->common.txdata[aa][get_samples_slot_timestamp(fp, slot)]; if (nr_slot_select(cfg,frame_tx,slot) == NR_UPLINK_SLOT) return; @@ -169,10 +169,13 @@ void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 0 ); - LOG_D(PHY,"feptx_ofdm (TXPATH): frame %d, slot %d: txp (time %p) %d dB, txp (freq) %d dB\n", - frame_tx,slot,txdata,dB_fixed(signal_energy((int32_t*)txdata,fp->get_samples_per_slot( - slot,fp))),dB_fixed(signal_energy_nodc((c16_t*)ru->common.txdataF_BF[aa],2*slot_sizeF))); - + LOG_D(PHY, + "feptx_ofdm (TXPATH): frame %d, slot %d: txp (time %p) %d dB, txp (freq) %d dB\n", + frame_tx, + slot, + txdata, + dB_fixed(signal_energy((int32_t *)txdata, get_samples_per_slot(slot, fp))), + dB_fixed(signal_energy_nodc((c16_t *)ru->common.txdataF_BF[aa], 2 * slot_sizeF))); } void nr_feptx_prec(RU_t *ru, int frame_tx, int slot_tx) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 6ea1a197e2..b1971d133f 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -969,17 +969,14 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, N buf[7] = (int16_t)ulsch->harq_pid; memcpy(&gNB->common_vars.debugBuff[gNB->common_vars.debugBuff_sample_offset + 4], &ru->common.rxdata[0][slot_offset], - frame_parms->get_samples_per_slot(slot_rx, frame_parms) * sizeof(int32_t)); - gNB->common_vars.debugBuff_sample_offset += (frame_parms->get_samples_per_slot(slot_rx, frame_parms) + 1000 + 4); - if (gNB->common_vars.debugBuff_sample_offset > ((frame_parms->get_samples_per_slot(slot_rx, frame_parms) + 1000 + 2) * 20)) { + get_samples_per_slot(slot_rx, frame_parms) * sizeof(int32_t)); + gNB->common_vars.debugBuff_sample_offset += (get_samples_per_slot(slot_rx, frame_parms) + 1000 + 4); + if (gNB->common_vars.debugBuff_sample_offset > ((get_samples_per_slot(slot_rx, frame_parms) + 1000 + 2) * 20)) { FILE *f; f = fopen("rxdata_buff.raw", "w"); if (f == NULL) exit(1); - fwrite((int16_t *)gNB->common_vars.debugBuff, - 2, - (frame_parms->get_samples_per_slot(slot_rx, frame_parms) + 1000 + 4) * 20 * 2, - f); + fwrite((int16_t *)gNB->common_vars.debugBuff, 2, (get_samples_per_slot(slot_rx, frame_parms) + 1000 + 4) * 20 * 2, f); fclose(f); exit(-1); } diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 8a89765e21..f7c8752c76 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -887,8 +887,8 @@ int main(int argc, char **argv) frame_length_complex_samples = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; - int slot_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0); - int slot_length = slot_offset - frame_parms->get_samples_slot_timestamp(slot-1,frame_parms,0); + int slot_offset = get_samples_slot_timestamp(frame_parms, slot); + int slot_length = slot_offset - get_samples_slot_timestamp(frame_parms, slot - 1); s_re = malloc(n_tx*sizeof(double*)); s_im = malloc(n_tx*sizeof(double*)); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 30905619a7..91d6a09569 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -527,7 +527,7 @@ int main(int argc, char **argv) nr_common_signal_procedures (gNB,frame,slot, &ssb_pdu[i]); - int samp = frame_parms->get_samples_slot_timestamp(slot, frame_parms, 0); + int samp = get_samples_slot_timestamp(frame_parms, slot); for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { if (cyclic_prefix_type == 1) { apply_nr_rotation_TX(frame_parms, diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 9fd9757f9d..f1a419d2a1 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -665,7 +665,7 @@ int main(int argc, char **argv){ UE->X_u); int prach_start = subframe * frame_parms->samples_per_subframe; - int slot_start = frame_parms->get_samples_slot_timestamp(slot, frame_parms, 0); + int slot_start = get_samples_slot_timestamp(frame_parms, slot); c16_t *tx[frame_parms->nb_antennas_rx]; for (int i = 0; i < frame_parms->nb_antennas_rx; i++) tx[i] = txdata[i] + slot_start; diff --git a/openair1/SIMULATION/NR_PHY/psbchsim.c b/openair1/SIMULATION/NR_PHY/psbchsim.c index fc5280559e..49d07616c4 100644 --- a/openair1/SIMULATION/NR_PHY/psbchsim.c +++ b/openair1/SIMULATION/NR_PHY/psbchsim.c @@ -574,7 +574,7 @@ int main(int argc, char **argv) proc.frame_rx, proc.nr_slot_rx, sl_uerx->sl_config.sl_sync_source.rx_slss_id); - int slot_start = frame_parms->get_samples_slot_timestamp(slot, frame_parms, 0); + int slot_start = get_samples_slot_timestamp(frame_parms, slot); c16_t *tx[frame_parms->nb_antennas_rx]; for (int i = 0; i < frame_parms->nb_antennas_rx; i++) tx[i] = UE_TX->common_vars.txData[i] + slot_start; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index a9a2ec3b76..f2452221d6 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -1061,8 +1061,8 @@ int main(int argc, char *argv[]) //for (int i=0;i<16;i++) printf("%f\n",gaussdouble(0.0,1.0)); int read_errors=0; - int slot_offset = gNB->frame_parms.get_samples_slot_timestamp(slot, &gNB->frame_parms, 0); - int slot_length = slot_offset - gNB->frame_parms.get_samples_slot_timestamp(slot - 1, &gNB->frame_parms, 0); + int slot_offset = get_samples_slot_timestamp(&gNB->frame_parms, slot); + int slot_length = slot_offset - get_samples_slot_timestamp(&gNB->frame_parms, slot - 1); if (input_fd != NULL) { // 800 samples is N_TA_OFFSET for FR1 @ 30.72 Ms/s, @@ -1382,7 +1382,7 @@ int main(int argc, char *argv[]) /////////////////////////phy_procedures_nr_ue_TX/////////////////////// /////////// - int slot_start = UE->frame_parms.get_samples_slot_timestamp(slot, &UE->frame_parms, 0); + int slot_start = get_samples_slot_timestamp(&UE->frame_parms, slot); c16_t *tx[UE->frame_parms.nb_antennas_tx]; for (int i = 0; i < UE->frame_parms.nb_antennas_tx; i++) tx[i] = UE->common_vars.txData[i] + slot_start; @@ -1400,7 +1400,7 @@ int main(int argc, char *argv[]) } /////////// //////////////////////////////////////////////////// - tx_offset = gNB->frame_parms.get_samples_slot_timestamp(slot, &gNB->frame_parms, 0); + tx_offset = get_samples_slot_timestamp(&gNB->frame_parms, slot); txlev_sum = 0; for (int aa = 0; aa < UE->frame_parms.nb_antennas_tx; aa++) { atxlev[aa] =