Apply clang-format

This commit is contained in:
Robert Schmidt
2024-04-13 08:54:15 +02:00
parent 94b23d1eb0
commit 9a2e080f77
29 changed files with 1095 additions and 1149 deletions
+4 -1
View File
@@ -204,7 +204,10 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui
newPolarInitNode->encoderLength = SL_NR_POLAR_PSBCH_E_NORMAL_CP + 2; newPolarInitNode->encoderLength = SL_NR_POLAR_PSBCH_E_NORMAL_CP + 2;
newPolarInitNode->crcCorrectionBits = SL_NR_POLAR_PSBCH_CRC_ERROR_CORRECTION_BITS; newPolarInitNode->crcCorrectionBits = SL_NR_POLAR_PSBCH_CRC_ERROR_CORRECTION_BITS;
newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits); // G_P newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits); // G_P
LOG_D(PHY,"SIDELINK: Initializing polar parameters for PSBCH (K %d, E %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength); LOG_D(PHY,
"SIDELINK: Initializing polar parameters for PSBCH (K %d, E %d)\n",
newPolarInitNode->payloadBits,
newPolarInitNode->encoderLength);
} else { } else {
AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType); AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType);
} }
+3 -6
View File
@@ -385,7 +385,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
static void sl_ue_free(PHY_VARS_NR_UE *UE) static void sl_ue_free(PHY_VARS_NR_UE *UE)
{ {
if (UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation) { if (UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation) {
free_and_zero(UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation[0]); free_and_zero(UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation[0]);
free_and_zero(UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation[1]); free_and_zero(UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation[1]);
@@ -716,15 +715,14 @@ void phy_term_nr_top(void)
void sl_ue_phy_init(PHY_VARS_NR_UE *UE) void sl_ue_phy_init(PHY_VARS_NR_UE *UE)
{ {
uint16_t scaling_value = ONE_OVER_SQRT2_Q15; uint16_t scaling_value = ONE_OVER_SQRT2_Q15;
NR_DL_FRAME_PARMS *sl_fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params; NR_DL_FRAME_PARMS *sl_fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params;
if (!UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation) { if (!UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation) {
UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation = (int32_t **)malloc16_clear(SL_NR_NUM_IDs_IN_PSS *sizeof(int32_t *) ); UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation = malloc16_clear(SL_NR_NUM_IDs_IN_PSS * sizeof(int32_t *));
UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation[0] = (int32_t *)malloc16_clear( sizeof(int32_t)*sl_fp->ofdm_symbol_size); UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation[0] = malloc16_clear(sizeof(int32_t) * sl_fp->ofdm_symbol_size);
UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation[1] = (int32_t *)malloc16_clear( sizeof(int32_t)*sl_fp->ofdm_symbol_size); UE->SL_UE_PHY_PARAMS.init_params.sl_pss_for_correlation[1] = malloc16_clear(sizeof(int32_t) * sl_fp->ofdm_symbol_size);
} }
LOG_I(PHY, "SIDELINK INIT: GENERATE PSS, SSS, GOLD SEQUENCES AND PSBCH DMRS SEQUENCES FOR ALL possible SLSS IDs 0- 671\n"); LOG_I(PHY, "SIDELINK INIT: GENERATE PSS, SSS, GOLD SEQUENCES AND PSBCH DMRS SEQUENCES FOR ALL possible SLSS IDs 0- 671\n");
@@ -745,4 +743,3 @@ void sl_ue_phy_init(PHY_VARS_NR_UE *UE)
init_symbol_rotation(sl_fp); init_symbol_rotation(sl_fp);
init_timeshift_rotation(sl_fp); init_timeshift_rotation(sl_fp);
} }
-1
View File
@@ -429,4 +429,3 @@ void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp)
LOG_I(PHY, "fp->first_carrier_offset=%d\n", fp->first_carrier_offset); LOG_I(PHY, "fp->first_carrier_offset=%d\n", fp->first_carrier_offset);
LOG_I(PHY, "fp->ssb_start_subcarrier=%d\n", fp->ssb_start_subcarrier); LOG_I(PHY, "fp->ssb_start_subcarrier=%d\n", fp->ssb_start_subcarrier);
} }
+21 -25
View File
@@ -44,13 +44,14 @@ int sl_nr_slot_fep(PHY_VARS_NR_UE *ue,
NR_DL_FRAME_PARMS *frame_params = &ue->SL_UE_PHY_PARAMS.sl_frame_params; NR_DL_FRAME_PARMS *frame_params = &ue->SL_UE_PHY_PARAMS.sl_frame_params;
NR_UE_COMMON *common_vars = &ue->common_vars; NR_UE_COMMON *common_vars = &ue->common_vars;
AssertFatal(symbol < frame_params->symbols_per_slot, "slot_fep: symbol must be between 0 and %d\n", frame_params->symbols_per_slot-1); AssertFatal(symbol < frame_params->symbols_per_slot,
"slot_fep: symbol must be between 0 and %d\n",
frame_params->symbols_per_slot - 1);
AssertFatal(Ns < frame_params->slots_per_frame, "slot_fep: Ns must be between 0 and %d\n", frame_params->slots_per_frame - 1); AssertFatal(Ns < frame_params->slots_per_frame, "slot_fep: Ns must be between 0 and %d\n", frame_params->slots_per_frame - 1);
unsigned int nb_prefix_samples = frame_params->nb_prefix_samples; unsigned int nb_prefix_samples = frame_params->nb_prefix_samples;
unsigned int nb_prefix_samples0 = frame_params->nb_prefix_samples0; unsigned int nb_prefix_samples0 = frame_params->nb_prefix_samples0;
dft_size_idx_t dftsize = get_dft(frame_params->ofdm_symbol_size); dft_size_idx_t dftsize = get_dft(frame_params->ofdm_symbol_size);
// This is for misalignment issues // This is for misalignment issues
int32_t tmp_dft_in[8192] __attribute__((aligned(32))); int32_t tmp_dft_in[8192] __attribute__((aligned(32)));
@@ -69,8 +70,13 @@ int sl_nr_slot_fep(PHY_VARS_NR_UE *ue,
#ifdef SL_DEBUG_SLOT_FEP #ifdef SL_DEBUG_SLOT_FEP
// if (ue->frame <100) // if (ue->frame <100)
LOG_I(PHY, "slot_fep: slot %d, symbol %d, nb_prefix_samples %u, nb_prefix_samples0 %u, rx_offset %u\n", LOG_I(PHY,
Ns, symbol, nb_prefix_samples, nb_prefix_samples0, rx_offset); "slot_fep: slot %d, symbol %d, nb_prefix_samples %u, nb_prefix_samples0 %u, rx_offset %u\n",
Ns,
symbol,
nb_prefix_samples,
nb_prefix_samples0,
rx_offset);
#endif #endif
for (unsigned char aa = 0; aa < frame_params->nb_antennas_rx; aa++) { for (unsigned char aa = 0; aa < frame_params->nb_antennas_rx; aa++) {
@@ -80,18 +86,12 @@ int sl_nr_slot_fep(PHY_VARS_NR_UE *ue,
// if input to dft is not 256-bit aligned // if input to dft is not 256-bit aligned
if ((rx_offset & 7) != 0) { if ((rx_offset & 7) != 0) {
memcpy((void *)&tmp_dft_in[0], memcpy((void *)&tmp_dft_in[0], (void *)&common_vars->rxdata[aa][rx_offset], frame_params->ofdm_symbol_size * sizeof(int32_t));
(void *)&common_vars->rxdata[aa][rx_offset],
frame_params->ofdm_symbol_size * sizeof(int32_t));
rxdata_ptr = (int16_t *)tmp_dft_in; rxdata_ptr = (int16_t *)tmp_dft_in;
} }
dft(dftsize, dft(dftsize, rxdata_ptr, (int16_t *)&rxdataF[aa][frame_params->ofdm_symbol_size * symbol], 1);
rxdata_ptr,
(int16_t *)&rxdataF[aa][frame_params->ofdm_symbol_size*symbol],
1);
int symb_offset = (Ns % frame_params->slots_per_subframe) * frame_params->symbols_per_slot; int symb_offset = (Ns % frame_params->slots_per_subframe) * frame_params->symbols_per_slot;
int32_t rot2 = ((uint32_t *)frame_params->symbol_rotation[1])[symbol + symb_offset]; int32_t rot2 = ((uint32_t *)frame_params->symbol_rotation[1])[symbol + symb_offset];
@@ -99,8 +99,14 @@ int sl_nr_slot_fep(PHY_VARS_NR_UE *ue,
#ifdef SL_DEBUG_SLOT_FEP #ifdef SL_DEBUG_SLOT_FEP
// if (ue->frame <100) // if (ue->frame <100)
LOG_I(PHY, "slot_fep: slot %d, symbol %d rx_offset %u, rotation symbol %d %d.%d\n", Ns,symbol, rx_offset, LOG_I(PHY,
symbol+symb_offset,((int16_t*)&rot2)[0],((int16_t*)&rot2)[1]); "slot_fep: slot %d, symbol %d rx_offset %u, rotation symbol %d %d.%d\n",
Ns,
symbol,
rx_offset,
symbol + symb_offset,
((int16_t *)&rot2)[0],
((int16_t *)&rot2)[1]);
#endif #endif
rotate_cpx_vector((c16_t *)&rxdataF[aa][frame_params->ofdm_symbol_size * symbol], rotate_cpx_vector((c16_t *)&rxdataF[aa][frame_params->ofdm_symbol_size * symbol],
@@ -119,8 +125,6 @@ int sl_nr_slot_fep(PHY_VARS_NR_UE *ue,
15); 15);
} }
LOG_D(PHY, "SIDELINK RX: Slot FEP: done for symbol:%d\n", symbol); LOG_D(PHY, "SIDELINK RX: Slot FEP: done for symbol:%d\n", symbol);
return 0; return 0;
@@ -133,7 +137,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
c16_t rxdataF[][frame_parms->samples_per_slot_wCP], c16_t rxdataF[][frame_parms->samples_per_slot_wCP],
uint32_t linktype) uint32_t linktype)
{ {
NR_UE_COMMON *common_vars = &ue->common_vars; NR_UE_COMMON *common_vars = &ue->common_vars;
int Ns = proc->nr_slot_rx; int Ns = proc->nr_slot_rx;
@@ -190,14 +193,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
stop_meas(&ue->rx_dft_stats); stop_meas(&ue->rx_dft_stats);
apply_nr_rotation_RX(frame_parms, apply_nr_rotation_RX(frame_parms, rxdataF[aa], frame_parms->symbol_rotation[linktype], Ns, frame_parms->N_RB_DL, 0, symbol, 1);
rxdataF[aa],
frame_parms->symbol_rotation[linktype],
Ns,
frame_parms->N_RB_DL,
0,
symbol,
1);
} }
#ifdef DEBUG_FEP #ifdef DEBUG_FEP
+3 -8
View File
@@ -202,10 +202,7 @@ int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue,
return(0); return(0);
} }
void nr_pbch_dmrs_rx(int symbol, void nr_pbch_dmrs_rx(int symbol, unsigned int *nr_gold_pbch, c16_t *output, bool sidelink)
unsigned int *nr_gold_pbch,
c16_t *output,
bool sidelink)
{ {
int m,m0,m1; int m,m0,m1;
uint8_t idx=0; uint8_t idx=0;
@@ -219,12 +216,10 @@ void nr_pbch_dmrs_rx(int symbol,
if (symbol == 0) { if (symbol == 0) {
m0 = 0; m0 = 0;
m1 = 60; m1 = 60;
} } else if (symbol == 1) {
else if (symbol == 1) {
m0 = 60; m0 = 60;
m1 = 84; m1 = 84;
} } else {
else {
m0 = 84; m0 = 84;
m1 = 144; m1 = 144;
} }
+8 -10
View File
@@ -157,7 +157,6 @@ void sl_init_psbch_dmrs_gold_sequences(PHY_VARS_NR_UE *UE)
uint8_t reset; uint8_t reset;
for (slss_id = 0; slss_id < SL_NR_NUM_SLSS_IDs; slss_id++) { for (slss_id = 0; slss_id < SL_NR_NUM_SLSS_IDs; slss_id++) {
reset = 1; reset = 1;
x2 = slss_id; x2 = slss_id;
@@ -172,16 +171,12 @@ void sl_init_psbch_dmrs_gold_sequences(PHY_VARS_NR_UE *UE)
#ifdef SL_DEBUG_INIT_DATA #ifdef SL_DEBUG_INIT_DATA
printf("%x\n", SL_UE_INIT_PARAMS.sl_psbch_dmrs_gold_sequences[slss_id][n]); printf("%x\n", SL_UE_INIT_PARAMS.sl_psbch_dmrs_gold_sequences[slss_id][n]);
#endif #endif
} }
} }
} }
void sl_generate_psbch_dmrs_qpsk_sequences(PHY_VARS_NR_UE *UE, void sl_generate_psbch_dmrs_qpsk_sequences(PHY_VARS_NR_UE *UE, struct complex16 *modulated_dmrs_sym, uint16_t slss_id)
struct complex16 *modulated_dmrs_sym,
uint16_t slss_id)
{ {
uint8_t idx = 0; uint8_t idx = 0;
uint32_t *sl_dmrs_sequence = UE->SL_UE_PHY_PARAMS.init_params.psbch_dmrs_gold_sequences[slss_id]; uint32_t *sl_dmrs_sequence = UE->SL_UE_PHY_PARAMS.init_params.psbch_dmrs_gold_sequences[slss_id];
c16_t *mod_table = (c16_t *)nr_qpsk_mod_table; c16_t *mod_table = (c16_t *)nr_qpsk_mod_table;
@@ -192,14 +187,18 @@ void sl_generate_psbch_dmrs_qpsk_sequences(PHY_VARS_NR_UE *UE,
/// QPSK modulation /// QPSK modulation
for (int m = 0; m < SL_NR_NUM_PSBCH_DMRS_RE; m++) { for (int m = 0; m < SL_NR_NUM_PSBCH_DMRS_RE; m++) {
idx = (((sl_dmrs_sequence[(m << 1) >> 5]) >> ((m << 1) & 0x1f)) & 3); idx = (((sl_dmrs_sequence[(m << 1) >> 5]) >> ((m << 1) & 0x1f)) & 3);
modulated_dmrs_sym[m].r = mod_table[idx].r; modulated_dmrs_sym[m].r = mod_table[idx].r;
modulated_dmrs_sym[m].i = mod_table[idx].i; modulated_dmrs_sym[m].i = mod_table[idx].i;
#ifdef SL_DEBUG_INIT_DATA #ifdef SL_DEBUG_INIT_DATA
printf("m:%d gold seq: %d b0-b1: %d-%d DMRS Symbols: %d %d\n", m, sl_dmrs_sequence[(m<<1)>>5], (((sl_dmrs_sequence[(m<<1)>>5])>>((m<<1)&0x1f))&1), printf("m:%d gold seq: %d b0-b1: %d-%d DMRS Symbols: %d %d\n",
(((sl_dmrs_sequence[((m<<1)+1)>>5])>>(((m<<1)+1)&0x1f))&1), modulated_dmrs_sym[m].r, modulated_dmrs_sym[m].i); m,
sl_dmrs_sequence[(m << 1) >> 5],
(((sl_dmrs_sequence[(m << 1) >> 5]) >> ((m << 1) & 0x1f)) & 1),
(((sl_dmrs_sequence[((m << 1) + 1) >> 5]) >> (((m << 1) + 1) & 0x1f)) & 1),
modulated_dmrs_sym[m].r,
modulated_dmrs_sym[m].i);
printf("idx:%d, qpsk_table.r:%d, qpsk_table.i:%d\n", idx, mod_table[idx].r, mod_table[idx].i); printf("idx:%d, qpsk_table.r:%d, qpsk_table.i:%d\n", idx, mod_table[idx].r, mod_table[idx].i);
#endif #endif
} }
@@ -210,5 +209,4 @@ void sl_generate_psbch_dmrs_qpsk_sequences(PHY_VARS_NR_UE *UE,
sprintf(varname, "sl_dmrs_id_%d.m", slss_id); sprintf(varname, "sl_dmrs_id_%d.m", slss_id);
LOG_M(filename, varname, (void *)modulated_dmrs_sym, SL_NR_NUM_PSBCH_DMRS_RE, 1, 1); LOG_M(filename, varname, (void *)modulated_dmrs_sym, SL_NR_NUM_PSBCH_DMRS_RE, 1, 1);
#endif #endif
} }
+2 -7
View File
@@ -30,10 +30,7 @@
/*!\brief This function generates the NR Gold sequence (38-211, Sec 5.2.1) for the PBCH DMRS. /*!\brief This function generates the NR Gold sequence (38-211, Sec 5.2.1) for the PBCH DMRS.
@param PHY_VARS_NR_UE* ue structure provides configuration, frame parameters and the pointers to the 32 bits sequence storage tables @param PHY_VARS_NR_UE* ue structure provides configuration, frame parameters and the pointers to the 32 bits sequence storage tables
*/ */
void nr_pbch_dmrs_rx(int dmrss, void nr_pbch_dmrs_rx(int dmrss, unsigned int *nr_gold_pbch, c16_t *output, bool sidelink);
unsigned int *nr_gold_pbch,
c16_t *output,
bool sidelink);
/*!\brief This function generates the NR Gold sequence (38-211, Sec 5.2.1) for the PDCCH DMRS. /*!\brief This function generates the NR Gold sequence (38-211, Sec 5.2.1) for the PDCCH DMRS.
@param PHY_VARS_NR_UE* ue structure provides configuration, frame parameters and the pointers to the 32 bits sequence storage tables @param PHY_VARS_NR_UE* ue structure provides configuration, frame parameters and the pointers to the 32 bits sequence storage tables
@@ -73,7 +70,5 @@ void sl_generate_pss(SL_NR_UE_INIT_PARAMS_t *sl_init_params, uint8_t n_sl_id2, u
void sl_generate_pss_ifft_samples(sl_nr_ue_phy_params_t *sl_ue_params, SL_NR_UE_INIT_PARAMS_t *sl_init_params); void sl_generate_pss_ifft_samples(sl_nr_ue_phy_params_t *sl_ue_params, SL_NR_UE_INIT_PARAMS_t *sl_init_params);
void sl_generate_sss(SL_NR_UE_INIT_PARAMS_t *sl_init_params, uint16_t slss_id, uint16_t scaling); void sl_generate_sss(SL_NR_UE_INIT_PARAMS_t *sl_init_params, uint16_t slss_id, uint16_t scaling);
void sl_init_psbch_dmrs_gold_sequences(PHY_VARS_NR_UE *UE); void sl_init_psbch_dmrs_gold_sequences(PHY_VARS_NR_UE *UE);
void sl_generate_psbch_dmrs_qpsk_sequences(PHY_VARS_NR_UE *UE, void sl_generate_psbch_dmrs_qpsk_sequences(PHY_VARS_NR_UE *UE, struct complex16 *modulated_dmrs_sym, uint16_t slss_id);
struct complex16 *modulated_dmrs_sym,
uint16_t slss_id);
#endif #endif
+16 -5
View File
@@ -72,11 +72,22 @@
static const c16_t phase_nr[PHASE_HYPOTHESIS_NUMBER] = { static const c16_t phase_nr[PHASE_HYPOTHESIS_NUMBER] = {
// {pi/3 ---- pi/3, -pi/3 ---- pi/3} // {pi/3 ---- pi/3, -pi/3 ---- pi/3}
{16384, -28377}, {20173, -25821}, {23571, -22762}, {26509, -19260}, {16384, -28377},
{28932, -15383}, {30791, -11207}, {32051, -6813}, {32687, -2286}, {20173, -25821},
{32687, 2286}, {32051, 6813}, {30791, 11207}, {28932, 15383}, {23571, -22762},
{26509, 19260}, {23571, 22762}, {20173, 25821}, {16384, 28377} {26509, -19260},
}; {28932, -15383},
{30791, -11207},
{32051, -6813},
{32687, -2286},
{32687, 2286},
{32051, 6813},
{30791, 11207},
{28932, 15383},
{26509, 19260},
{23571, 22762},
{20173, 25821},
{16384, 28377}};
void init_context_sss_nr(int amp); void init_context_sss_nr(int amp);
void free_context_sss_nr(void); void free_context_sss_nr(void);
@@ -738,10 +738,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
uint32_t *gold_seq = NULL; uint32_t *gold_seq = NULL;
if (sidelink) { if (sidelink) {
AssertFatal(dmrss == 0 || (dmrss >= 5 && dmrss <= 12), "symbol %d is illegal for PSBCH DM-RS \n", dmrss);
AssertFatal(dmrss == 0 || (dmrss >= 5 && dmrss <= 12),
"symbol %d is illegal for PSBCH DM-RS \n",
dmrss);
sl_nr_ue_phy_params_t *sl_phy_params = &ue->SL_UE_PHY_PARAMS; sl_nr_ue_phy_params_t *sl_phy_params = &ue->SL_UE_PHY_PARAMS;
@@ -752,12 +749,9 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
num_rbs = SL_NR_NUM_PSBCH_RBS_IN_ONE_SYMBOL; num_rbs = SL_NR_NUM_PSBCH_RBS_IN_ONE_SYMBOL;
} else { } else {
nushift = fp->Nid_cell % 4; nushift = fp->Nid_cell % 4;
AssertFatal(dmrss >= 0 && dmrss < 3, AssertFatal(dmrss >= 0 && dmrss < 3, "symbol %d is illegal for PBCH DM-RS \n", dmrss);
"symbol %d is illegal for PBCH DM-RS \n",
dmrss);
gold_seq = ue->nr_gold_pbch[n_hf][ssb_index]; gold_seq = ue->nr_gold_pbch[n_hf][ssb_index];
lastsymbol = 2; lastsymbol = 2;
@@ -765,7 +759,8 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
} }
unsigned int ssb_offset = fp->first_carrier_offset + fp->ssb_start_subcarrier; unsigned int ssb_offset = fp->first_carrier_offset + fp->ssb_start_subcarrier;
if (ssb_offset>= fp->ofdm_symbol_size) ssb_offset-= fp->ofdm_symbol_size; if (ssb_offset >= fp->ofdm_symbol_size)
ssb_offset -= fp->ofdm_symbol_size;
const int ch_offset = fp->ofdm_symbol_size * symbol; const int ch_offset = fp->ofdm_symbol_size * symbol;
const int symbol_offset = fp->ofdm_symbol_size * symbol; const int symbol_offset = fp->ofdm_symbol_size * symbol;
@@ -866,7 +861,6 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
nr_pbch_dmrs_rx(dmrss, gold_seq, &pilot[0], sidelink); nr_pbch_dmrs_rx(dmrss, gold_seq, &pilot[0], sidelink);
for (int aarx = 0; aarx < fp->nb_antennas_rx; aarx++) { for (int aarx = 0; aarx < fp->nb_antennas_rx; aarx++) {
int re_offset = ssb_offset; int re_offset = ssb_offset;
c16_t *pil = pilot; c16_t *pil = pilot;
c16_t *rxF = &rxdataF[aarx][symbol_offset + k]; c16_t *rxF = &rxdataF[aarx][symbol_offset + k];
@@ -962,13 +956,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
} }
if (!sidelink && dmrss == lastsymbol) if (!sidelink && dmrss == lastsymbol)
UEscopeCopy(ue, UEscopeCopy(ue, pbchDlChEstimateTime, (void *)dl_ch_estimates_time, sizeof(c16_t), fp->nb_antennas_rx, fp->ofdm_symbol_size, 0);
pbchDlChEstimateTime,
(void *)dl_ch_estimates_time,
sizeof(c16_t),
fp->nb_antennas_rx,
fp->ofdm_symbol_size,
0);
return(0); return(0);
} }
@@ -316,24 +316,19 @@ void nr_sl_psbch_rsrp_measurements(sl_nr_ue_phy_params_t *sl_phy_params,
c16_t rxdataF[][fp->samples_per_slot_wCP], c16_t rxdataF[][fp->samples_per_slot_wCP],
bool use_SSS) bool use_SSS)
{ {
SL_NR_UE_PSBCH_t *psbch_rx = &sl_phy_params->psbch; SL_NR_UE_PSBCH_t *psbch_rx = &sl_phy_params->psbch;
uint8_t numsym = (fp->Ncp) ? SL_NR_NUM_SYMBOLS_SSB_EXT_CP uint8_t numsym = (fp->Ncp) ? SL_NR_NUM_SYMBOLS_SSB_EXT_CP : SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP;
: SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP;
uint32_t re_offset = fp->first_carrier_offset + fp->ssb_start_subcarrier; uint32_t re_offset = fp->first_carrier_offset + fp->ssb_start_subcarrier;
uint32_t rsrp = 0, num_re = 0; uint32_t rsrp = 0, num_re = 0;
LOG_D(PHY, "PSBCH RSRP MEAS: numsym:%d, re_offset:%d\n", numsym, re_offset); LOG_D(PHY, "PSBCH RSRP MEAS: numsym:%d, re_offset:%d\n", numsym, re_offset);
for (int aarx = 0; aarx < fp->nb_antennas_rx; aarx++) { for (int aarx = 0; aarx < fp->nb_antennas_rx; aarx++) {
// Calculate PSBCH RSRP based from DMRS REs // Calculate PSBCH RSRP based from DMRS REs
for (uint8_t symbol = 0; symbol < numsym;) { for (uint8_t symbol = 0; symbol < numsym;) {
struct complex16 *rxF = &rxdataF[aarx][symbol * fp->ofdm_symbol_size]; struct complex16 *rxF = &rxdataF[aarx][symbol * fp->ofdm_symbol_size];
for (int re = 0; re < SL_NR_NUM_PSBCH_RE_IN_ONE_SYMBOL; re++) { for (int re = 0; re < SL_NR_NUM_PSBCH_RE_IN_ONE_SYMBOL; re++) {
if (re % 4 == 0) { // DMRS RE if (re % 4 == 0) { // DMRS RE
uint16_t offset = (re_offset + re) % fp->ofdm_symbol_size; uint16_t offset = (re_offset + re) % fp->ofdm_symbol_size;
@@ -352,14 +347,13 @@ void nr_sl_psbch_rsrp_measurements(sl_nr_ue_phy_params_t *sl_phy_params,
} }
psbch_rx->rsrp_dB_per_RE = 10 * log10(rsrp / num_re); psbch_rx->rsrp_dB_per_RE = 10 * log10(rsrp / num_re);
psbch_rx->rsrp_dBm_per_RE = psbch_rx->rsrp_dB_per_RE + psbch_rx->rsrp_dBm_per_RE = psbch_rx->rsrp_dB_per_RE + 30 - 10 * log10(pow(2, 30))
30 - 10*log10(pow(2,30)) - - ((int)openair0_cfg[0].rx_gain[0] - (int)openair0_cfg[0].rx_gain_offset[0])
((int)openair0_cfg[0].rx_gain[0] - (int)openair0_cfg[0].rx_gain_offset[0]) - - dB_fixed(fp->ofdm_symbol_size);
dB_fixed(fp->ofdm_symbol_size);
LOG_I(PHY, "PSBCH RSRP (DMRS REs): numREs:%d RSRP :%d dB/RE ,RSRP:%d dBm/RE\n",
num_re, psbch_rx->rsrp_dB_per_RE, psbch_rx->rsrp_dBm_per_RE);
LOG_I(PHY,
"PSBCH RSRP (DMRS REs): numREs:%d RSRP :%d dB/RE ,RSRP:%d dBm/RE\n",
num_re,
psbch_rx->rsrp_dB_per_RE,
psbch_rx->rsrp_dBm_per_RE);
} }
@@ -17,7 +17,6 @@
static int sl_nr_pss_correlation(PHY_VARS_NR_UE *UE, int frame_index) static int sl_nr_pss_correlation(PHY_VARS_NR_UE *UE, int frame_index)
{ {
sl_nr_ue_phy_params_t *sl_ue = &UE->SL_UE_PHY_PARAMS; sl_nr_ue_phy_params_t *sl_ue = &UE->SL_UE_PHY_PARAMS;
SL_NR_SYNC_PARAMS_t *sync_params = &sl_ue->sync_params; SL_NR_SYNC_PARAMS_t *sync_params = &sl_ue->sync_params;
NR_DL_FRAME_PARMS *sl_fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params; NR_DL_FRAME_PARMS *sl_fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params;
@@ -52,7 +51,6 @@ static int sl_nr_pss_correlation(PHY_VARS_NR_UE *UE, int frame_index)
LOG_I(PHY, "maxval:%d, shift:%d\n", maxval, shift); LOG_I(PHY, "maxval:%d, shift:%d\n", maxval, shift);
#endif #endif
int64_t avg[SL_NR_NUM_IDs_IN_PSS] = {0}; int64_t avg[SL_NR_NUM_IDs_IN_PSS] = {0};
int64_t peak_value = 0, psss_corr_value = 0; int64_t peak_value = 0, psss_corr_value = 0;
unsigned int peak_position = 0, pss_source = 0; unsigned int peak_position = 0, pss_source = 0;
@@ -70,10 +68,8 @@ static int sl_nr_pss_correlation(PHY_VARS_NR_UE *UE, int frame_index)
for (int pss_index = 0; pss_index < SL_NR_NUM_IDs_IN_PSS; pss_index++) { for (int pss_index = 0; pss_index < SL_NR_NUM_IDs_IN_PSS; pss_index++) {
psss_corr_value = 0; psss_corr_value = 0;
// calculate dot product of primary_synchro_time_nr and rxdata[ar][n] (ar=0..nb_ant_rx) and store the sum in temp[n]; // calculate dot product of primary_synchro_time_nr and rxdata[ar][n] (ar=0..nb_ant_rx) and store the sum in temp[n];
for (int ar = 0; ar < sl_fp->nb_antennas_rx; ar++) { for (int ar = 0; ar < sl_fp->nb_antennas_rx; ar++) {
/* perform correlation of rx data and pss sequence ie it is a dot product */ /* perform correlation of rx data and pss sequence ie it is a dot product */
const c32_t result = dot_product((c16_t *)pss_for_correlation[pss_index], const c32_t result = dot_product((c16_t *)pss_for_correlation[pss_index],
(c16_t *)&(rxdata[ar][n + frame_index * sl_fp->samples_per_frame]), (c16_t *)&(rxdata[ar][n + frame_index * sl_fp->samples_per_frame]),
@@ -86,7 +82,11 @@ static int sl_nr_pss_correlation(PHY_VARS_NR_UE *UE, int frame_index)
#ifdef SL_DEBUG #ifdef SL_DEBUG
pss_corr_debug_values[pss_index][n] = psss_corr_value; pss_corr_debug_values[pss_index][n] = psss_corr_value;
printf("frame:%d n:%d, pss_index:%d, pss_for_correlation[pss_index][0]:%x, rxdata[n]:%x\n", printf("frame:%d n:%d, pss_index:%d, pss_for_correlation[pss_index][0]:%x, rxdata[n]:%x\n",
frame_index, n, pss_index, pss_for_correlation[pss_index][0], rxdata[ar][n + frame_index * sl_fp->samples_per_frame]); frame_index,
n,
pss_index,
pss_for_correlation[pss_index][0],
rxdata[ar][n + frame_index * sl_fp->samples_per_frame]);
printf("result %lld, pss_corr_values[%d][%d]:%ld\n", result, pss_index, n, pss_corr_debug_values[pss_index][n]); printf("result %lld, pss_corr_values[%d][%d]:%ld\n", result, pss_index, n, pss_corr_debug_values[pss_index][n]);
printf("pss_index %d: n %6u peak_value %15llu\n", pss_index, n, (unsigned long long)pss_corr_debug_values[pss_index][n]); printf("pss_index %d: n %6u peak_value %15llu\n", pss_index, n, (unsigned long long)pss_corr_debug_values[pss_index][n]);
printf("peak_value:%ld, peak_position:%d, pss_source:%d\n", peak_value, peak_position, pss_source); printf("peak_value:%ld, peak_position:%d, pss_source:%d\n", peak_value, peak_position, pss_source);
@@ -120,7 +120,8 @@ static int sl_nr_pss_correlation(PHY_VARS_NR_UE *UE, int frame_index)
if (UE->UE_fo_compensation) { // Not tested if (UE->UE_fo_compensation) { // Not tested
// fractional frequency offset computation according to Cross-correlation Synchronization Algorithm Using PSS // fractional frequency offset computation according to Cross-correlation Synchronization Algorithm Using PSS
// Shoujun Huang, Yongtao Su, Ying He and Shan Tang, "Joint time and frequency offset estimation in LTE downlink," 7th International Conference on Communications and Networking in China, 2012. // Shoujun Huang, Yongtao Su, Ying He and Shan Tang, "Joint time and frequency offset estimation in LTE downlink," 7th
// International Conference on Communications and Networking in China, 2012.
c16_t *pss = (c16_t *)pss_for_correlation[pss_source]; c16_t *pss = (c16_t *)pss_for_correlation[pss_source];
c16_t *rxd = (c16_t *)&(rxdata[0][peak_position + frame_index * sl_fp->samples_per_frame]); c16_t *rxd = (c16_t *)&(rxdata[0][peak_position + frame_index * sl_fp->samples_per_frame]);
@@ -142,16 +143,23 @@ static int sl_nr_pss_correlation(PHY_VARS_NR_UE *UE, int frame_index)
#endif #endif
} }
// computing absolute value of frequency offset // computing absolute value of frequency offset
sync_params->freq_offset = ffo_est * sl_fp->subcarrier_spacing; sync_params->freq_offset = ffo_est * sl_fp->subcarrier_spacing;
for (int pss_index = 0; pss_index < SL_NR_NUM_IDs_IN_PSS; pss_index++) avg[pss_index]/=(length/4); for (int pss_index = 0; pss_index < SL_NR_NUM_IDs_IN_PSS; pss_index++)
avg[pss_index] /= (length / 4);
sync_params->N_sl_id2 = pss_source; sync_params->N_sl_id2 = pss_source;
LOG_I(PHY,"PSS Source = %d, Peak found at pos %d, val = %llu (%d dB) avg %d dB, ffo %lf, freq offset:%d Hz\n", LOG_I(PHY,
pss_source, peak_position, (unsigned long long)peak_value, dB_fixed64(peak_value),dB_fixed64(avg[pss_source]),ffo_est, sync_params->freq_offset); "PSS Source = %d, Peak found at pos %d, val = %llu (%d dB) avg %d dB, ffo %lf, freq offset:%d Hz\n",
pss_source,
peak_position,
(unsigned long long)peak_value,
dB_fixed64(peak_value),
dB_fixed64(avg[pss_source]),
ffo_est,
sync_params->freq_offset);
if (peak_value < 5 * avg[pss_source]) if (peak_value < 5 * avg[pss_source])
return (-1); return (-1);
@@ -159,11 +167,12 @@ static int sl_nr_pss_correlation(PHY_VARS_NR_UE *UE, int frame_index)
return peak_position; return peak_position;
} }
static void sl_nr_extract_sss(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, static void sl_nr_extract_sss(PHY_VARS_NR_UE *ue,
int32_t *tot_metric, uint8_t *phase_max, UE_nr_rxtx_proc_t *proc,
int32_t *tot_metric,
uint8_t *phase_max,
c16_t rxdataF[][ue->SL_UE_PHY_PARAMS.sl_frame_params.samples_per_slot_wCP]) c16_t rxdataF[][ue->SL_UE_PHY_PARAMS.sl_frame_params.samples_per_slot_wCP])
{ {
c16_t pss_ext[SL_NR_MAX_RX_ANTENNA][SL_NR_NUM_PSS_SYMBOLS][SL_NR_PSS_SEQUENCE_LENGTH]; c16_t pss_ext[SL_NR_MAX_RX_ANTENNA][SL_NR_NUM_PSS_SYMBOLS][SL_NR_PSS_SEQUENCE_LENGTH];
c16_t sss_ext[SL_NR_MAX_RX_ANTENNA][SL_NR_NUM_SSS_SYMBOLS][SL_NR_PSS_SEQUENCE_LENGTH]; c16_t sss_ext[SL_NR_MAX_RX_ANTENNA][SL_NR_NUM_SSS_SYMBOLS][SL_NR_PSS_SEQUENCE_LENGTH];
uint8_t Nid2 = ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id2; uint8_t Nid2 = ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id2;
@@ -174,12 +183,10 @@ static void sl_nr_extract_sss(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc,
c16_t *rxF_ext; c16_t *rxF_ext;
for (int aarx = 0; aarx < sl_fp->nb_antennas_rx; aarx++) { for (int aarx = 0; aarx < sl_fp->nb_antennas_rx; aarx++) {
unsigned int ofdm_symbol_size = sl_fp->ofdm_symbol_size; unsigned int ofdm_symbol_size = sl_fp->ofdm_symbol_size;
// pss, sss extraction // pss, sss extraction
for (int sym = SL_NR_FIRST_PSS_SYMBOL; sym < SL_NR_FIRST_PSS_SYMBOL + SL_NR_NUM_PSS_SSS_SYMBOLS; sym++) { for (int sym = SL_NR_FIRST_PSS_SYMBOL; sym < SL_NR_FIRST_PSS_SYMBOL + SL_NR_NUM_PSS_SSS_SYMBOLS; sym++) {
if (sym < SL_NR_FIRST_PSS_SYMBOL + SL_NR_NUM_PSS_SYMBOLS) { if (sym < SL_NR_FIRST_PSS_SYMBOL + SL_NR_NUM_PSS_SYMBOLS) {
rxF_ext = &pss_ext[aarx][sym - SL_NR_FIRST_PSS_SYMBOL][0]; rxF_ext = &pss_ext[aarx][sym - SL_NR_FIRST_PSS_SYMBOL][0];
} else { } else {
@@ -187,16 +194,22 @@ static void sl_nr_extract_sss(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc,
} }
unsigned int k = sl_fp->first_carrier_offset + sl_fp->ssb_start_subcarrier + 2; unsigned int k = sl_fp->first_carrier_offset + sl_fp->ssb_start_subcarrier + 2;
if (k >= ofdm_symbol_size) k -= ofdm_symbol_size; if (k >= ofdm_symbol_size)
k -= ofdm_symbol_size;
LOG_D(PHY, "firstcarrieroffset:%d, ssb_sc:%d, k:%d, symbol:%d\n",sl_fp->first_carrier_offset, sl_fp->ssb_start_subcarrier, k, sym); LOG_D(PHY,
"firstcarrieroffset:%d, ssb_sc:%d, k:%d, symbol:%d\n",
sl_fp->first_carrier_offset,
sl_fp->ssb_start_subcarrier,
k,
sym);
for (int i = 0; i < SL_NR_PSS_SEQUENCE_LENGTH; i++) { for (int i = 0; i < SL_NR_PSS_SEQUENCE_LENGTH; i++) {
rxF_ext[i] = rxdataF[aarx][sym * ofdm_symbol_size + k]; rxF_ext[i] = rxdataF[aarx][sym * ofdm_symbol_size + k];
k++; k++;
if (k == ofdm_symbol_size) k=0; if (k == ofdm_symbol_size)
k = 0;
} }
} }
LOG_D(PHY, "SIDELINK SLSS SEARCH: EXTRACTION OF PSS, SSS done\n"); LOG_D(PHY, "SIDELINK SLSS SEARCH: EXTRACTION OF PSS, SSS done\n");
@@ -215,12 +228,10 @@ static void sl_nr_extract_sss(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc,
// 2 Symbols each for PSS and SSS // 2 Symbols each for PSS and SSS
for (int j = 0; j < SL_NR_NUM_PSS_OR_SSS_SYMBOLS; j++) { for (int j = 0; j < SL_NR_NUM_PSS_OR_SSS_SYMBOLS; j++) {
sss_ext2 = &sss_ext[aarx][j][0]; sss_ext2 = &sss_ext[aarx][j][0];
pss_ext2 = &pss_ext[aarx][j][0]; pss_ext2 = &pss_ext[aarx][j][0];
for (int i = 0; i < SL_NR_PSS_SEQUENCE_LENGTH; i++) { for (int i = 0; i < SL_NR_PSS_SEQUENCE_LENGTH; i++) {
// This is H*(PSS) = R* \cdot PSS // This is H*(PSS) = R* \cdot PSS
c16_t tmp = {.r = (pss_ext2[i].r * pss[i]), .i = (-pss_ext2[i].i * pss[i])}; c16_t tmp = {.r = (pss_ext2[i].r * pss[i]), .i = (-pss_ext2[i].i * pss[i])};
@@ -242,10 +253,8 @@ static void sl_nr_extract_sss(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc,
} }
LOG_D(PHY, "SIDELINK SLSS SEARCH: Ch. estimation SSS done\n"); LOG_D(PHY, "SIDELINK SLSS SEARCH: Ch. estimation SSS done\n");
} }
/* /*
#ifdef SL_DEBUG #ifdef SL_DEBUG
@@ -288,21 +297,27 @@ static void sl_nr_extract_sss(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc,
Nid1 = id1; Nid1 = id1;
*phase_max = phase; *phase_max = phase;
LOG_D(PHY, "(phase,Nid1) (%d,%d), metric_phase %d tot_metric %d, phase_max %d \n", LOG_D(PHY,
phase, Nid1, metric, *tot_metric, *phase_max); "(phase,Nid1) (%d,%d), metric_phase %d tot_metric %d, phase_max %d \n",
phase,
Nid1,
metric,
*tot_metric,
*phase_max);
} }
} }
} }
ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id1 = Nid1; ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id1 = Nid1;
ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id = ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id1 + ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id =
SL_NR_NUM_IDs_IN_SSS * ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id2; ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id1 + SL_NR_NUM_IDs_IN_SSS * ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id2;
LOG_I(PHY, "UE[%d]NR-SL SLSS SEARCH: SSS Processing over. id2 from SSS:%d, id1 from PSS:%d, SLSS id:%d\n", LOG_I(PHY,
ue->Mod_id, ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id1, ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id2, "UE[%d]NR-SL SLSS SEARCH: SSS Processing over. id2 from SSS:%d, id1 from PSS:%d, SLSS id:%d\n",
ue->Mod_id,
ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id1,
ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id2,
ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id); ue->SL_UE_PHY_PARAMS.sync_params.N_sl_id);
#ifdef SL_DEBUG #ifdef SL_DEBUG
#define SSS_METRIC_FLOOR_NR (30000) #define SSS_METRIC_FLOOR_NR (30000)
if (*tot_metric > SSS_METRIC_FLOOR_NR) { if (*tot_metric > SSS_METRIC_FLOOR_NR) {
@@ -315,13 +330,11 @@ static void sl_nr_extract_sss(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc,
return; return;
} }
// Right now 2 frames worth of samples get processed for PSS in OAI. // Right now 2 frames worth of samples get processed for PSS in OAI.
// For PSS in Sidelink, worst case 1 SSB in 16 frames can be present // For PSS in Sidelink, worst case 1 SSB in 16 frames can be present
// Hence 16 frames worth of samples needs to be correlated to find the PSS. // Hence 16 frames worth of samples needs to be correlated to find the PSS.
nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc, int num_frames) nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc, int num_frames)
{ {
sl_nr_ue_phy_params_t *sl_ue = &UE->SL_UE_PHY_PARAMS; sl_nr_ue_phy_params_t *sl_ue = &UE->SL_UE_PHY_PARAMS;
SL_NR_SYNC_PARAMS_t *sync_params = &sl_ue->sync_params; SL_NR_SYNC_PARAMS_t *sync_params = &sl_ue->sync_params;
NR_DL_FRAME_PARMS *sl_fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params; NR_DL_FRAME_PARMS *sl_fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params;
@@ -355,7 +368,6 @@ nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc,
// --------- SSB can be on the boundary between frames. In this case if only 1 SSB is sent we will miss it. // --------- SSB can be on the boundary between frames. In this case if only 1 SSB is sent we will miss it.
// rxdata will hold 16 frames + slot worth of samples. This needs to be processed to find the best SSB // rxdata will hold 16 frames + slot worth of samples. This needs to be processed to find the best SSB
for (int frame_index = 0; frame_index < num_frames; frame_index++) { for (int frame_index = 0; frame_index < num_frames; frame_index++) {
/* process pss search on received buffer */ /* process pss search on received buffer */
sync_pos = sl_nr_pss_correlation(UE, frame_index); sync_pos = sl_nr_pss_correlation(UE, frame_index);
@@ -374,28 +386,37 @@ nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc,
if (sync_pos > sl_fp->nb_prefix_samples0 + sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples) if (sync_pos > sl_fp->nb_prefix_samples0 + sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples)
sync_params->ssb_offset = sync_pos - (sl_fp->nb_prefix_samples0 + sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples); sync_params->ssb_offset = sync_pos - (sl_fp->nb_prefix_samples0 + sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples);
else else
sync_params->ssb_offset = sync_pos + sl_fp->samples_per_frame - (sl_fp->nb_prefix_samples0 + sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples); sync_params->ssb_offset = sync_pos + sl_fp->samples_per_frame
- (sl_fp->nb_prefix_samples0 + sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples);
} else { // Check if sync pos points to SYMBOL2 - second symbol of PSS location } else { // Check if sync pos points to SYMBOL2 - second symbol of PSS location
if (sync_pos >= sl_fp->nb_prefix_samples0 + 2 * (sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples)) if (sync_pos >= sl_fp->nb_prefix_samples0 + 2 * (sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples))
sync_params->ssb_offset = sync_pos - (sl_fp->nb_prefix_samples0 + 2*(sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples)); sync_params->ssb_offset =
sync_pos - (sl_fp->nb_prefix_samples0 + 2 * (sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples));
else else
sync_params->ssb_offset = sync_pos + sl_fp->samples_per_frame - (sl_fp->nb_prefix_samples0 + 2*(sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples)); sync_params->ssb_offset = sync_pos + sl_fp->samples_per_frame
- (sl_fp->nb_prefix_samples0 + 2 * (sl_fp->ofdm_symbol_size + sl_fp->nb_prefix_samples));
} }
LOG_I(PHY,"UE[%d]SIDELINK SEARCH SLSS: PSS Peak at %d, PSS sym:%d, Estimated PSS position %d\n", LOG_I(PHY,
UE->Mod_id,sync_pos,pss_sym,sync_params->ssb_offset); "UE[%d]SIDELINK SEARCH SLSS: PSS Peak at %d, PSS sym:%d, Estimated PSS position %d\n",
UE->Mod_id,
sync_pos,
pss_sym,
sync_params->ssb_offset);
int slss_block_samples = (SL_NR_NUMSYM_SLSS_NORMAL_CP * sl_fp->ofdm_symbol_size) + int slss_block_samples = (SL_NR_NUMSYM_SLSS_NORMAL_CP * sl_fp->ofdm_symbol_size)
(SL_NR_NUMSYM_SLSS_NORMAL_CP -1) * sl_fp->nb_prefix_samples + sl_fp->nb_prefix_samples0; + (SL_NR_NUMSYM_SLSS_NORMAL_CP - 1) * sl_fp->nb_prefix_samples + sl_fp->nb_prefix_samples0;
int ssb_end_position = sync_params->ssb_offset + slss_block_samples; int ssb_end_position = sync_params->ssb_offset + slss_block_samples;
LOG_D(PHY, "ssb_end:%d ssb block samples:%d total samples: %d\n", ssb_end_position, slss_block_samples, num_frames * sl_fp->samples_per_frame); LOG_D(PHY,
"ssb_end:%d ssb block samples:%d total samples: %d\n",
ssb_end_position,
slss_block_samples,
num_frames * sl_fp->samples_per_frame);
/* check that SSS/PBCH block is continuous inside the received buffer */ /* check that SSS/PBCH block is continuous inside the received buffer */
if (ssb_end_position < num_frames * sl_fp->samples_per_frame) { if (ssb_end_position < num_frames * sl_fp->samples_per_frame) {
// digital compensation of FFO for SSB symbols // digital compensation of FFO for SSB symbols
if (UE->UE_fo_compensation) { // This code to be checked. Why do we do this before PSS detection is successful? if (UE->UE_fo_compensation) { // This code to be checked. Why do we do this before PSS detection is successful?
double s_time = 1 / (1.0e3 * sl_fp->samples_per_subframe); // sampling time double s_time = 1 / (1.0e3 * sl_fp->samples_per_subframe); // sampling time
@@ -405,9 +426,11 @@ nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc,
// Adapt this for other numerologies number of symbols with larger cp increases TBD // Adapt this for other numerologies number of symbols with larger cp increases TBD
int end = ssb_end_position; // loop over samples in all symbols (ssb size), including prefix int end = ssb_end_position; // loop over samples in all symbols (ssb size), including prefix
LOG_I(PHY,
LOG_I(PHY,"SLSS SEARCH: FREQ comp of SLSS samples. Freq_OFSET:%d, startpos:%d, end_pos:%d\n", "SLSS SEARCH: FREQ comp of SLSS samples. Freq_OFSET:%d, startpos:%d, end_pos:%d\n",
sync_params->freq_offset, start, end); sync_params->freq_offset,
start,
end);
for (int n = start; n < end; n++) { for (int n = start; n < end; n++) {
for (int ar = 0; ar < sl_fp->nb_antennas_rx; ar++) { for (int ar = 0; ar < sl_fp->nb_antennas_rx; ar++) {
re = ((double)(((short *)UE->common_vars.rxdata[ar]))[2 * n]); re = ((double)(((short *)UE->common_vars.rxdata[ar]))[2 * n]);
@@ -424,12 +447,7 @@ nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc,
/* In order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */ /* In order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */
for (int symbol = 0; symbol < SL_NR_NUMSYM_SLSS_NORMAL_CP; symbol++) { for (int symbol = 0; symbol < SL_NR_NUMSYM_SLSS_NORMAL_CP; symbol++) {
sl_nr_slot_fep(UE, sl_nr_slot_fep(UE, NULL, symbol, 0, sync_params->ssb_offset, rxdataF);
NULL,
symbol,
0,
sync_params->ssb_offset,
rxdataF);
} }
sl_nr_extract_sss(UE, NULL, &metric_tdd_ncp, &phase_tdd_ncp, rxdataF); sl_nr_extract_sss(UE, NULL, &metric_tdd_ncp, &phase_tdd_ncp, rxdataF);
@@ -438,7 +456,8 @@ nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc,
rx_slss_id = UE->SL_UE_PHY_PARAMS.sync_params.N_sl_id; rx_slss_id = UE->SL_UE_PHY_PARAMS.sync_params.N_sl_id;
__attribute__((aligned(32))) struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][rxdataF_sz]; __attribute__((aligned(32))) struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][rxdataF_sz];
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size]; __attribute__((
aligned(32))) struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size];
uint8_t decoded_output[4]; uint8_t decoded_output[4];
@@ -460,13 +479,7 @@ nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc,
symbol = (symbol == 0) ? 5 : symbol + 1; symbol = (symbol == 0) ? 5 : symbol + 1;
} }
ret = nr_rx_psbch(UE,proc, ret = nr_rx_psbch(UE, proc, rxdataF_sz, dl_ch_estimates, frame_parms, decoded_output, rxdataF, rx_slss_id);
rxdataF_sz,
dl_ch_estimates,
frame_parms,
decoded_output,
rxdataF,
rx_slss_id);
result.cell_detected = (ret == 0) ? true : false; result.cell_detected = (ret == 0) ? true : false;
@@ -474,21 +487,28 @@ nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc,
// sync at symbol ue->symbol_offset // sync at symbol ue->symbol_offset
// computing the offset wrt the beginning of the frame // computing the offset wrt the beginning of the frame
// SSB located at symbol 0 // SSB located at symbol 0
sync_params->remaining_frames = (num_frames * sl_fp->samples_per_frame - sync_params->ssb_offset)/sl_fp->samples_per_frame; sync_params->remaining_frames =
(num_frames * sl_fp->samples_per_frame - sync_params->ssb_offset) / sl_fp->samples_per_frame;
// ssb_offset points to start of sl-ssb // ssb_offset points to start of sl-ssb
// rx_offset points to remaining samples needed to fill a frame // rx_offset points to remaining samples needed to fill a frame
sync_params->rx_offset = sync_params->ssb_offset % sl_fp->samples_per_frame; sync_params->rx_offset = sync_params->ssb_offset % sl_fp->samples_per_frame;
LOG_I(PHY,"UE[%d]SIDELINK SLSS SEARCH: PSBCH RX OK. Remainingframes:%d, rx_offset:%d\n", LOG_I(PHY,
UE->Mod_id,sync_params->remaining_frames, sync_params->rx_offset); "UE[%d]SIDELINK SLSS SEARCH: PSBCH RX OK. Remainingframes:%d, rx_offset:%d\n",
UE->Mod_id,
sync_params->remaining_frames,
sync_params->rx_offset);
uint32_t psbch_payload = (*(uint32_t *)decoded_output); uint32_t psbch_payload = (*(uint32_t *)decoded_output);
// retrieve DFN and slot number from SL-MIB // retrieve DFN and slot number from SL-MIB
sync_params->DFN = (((psbch_payload & 0x0700) >> 1) | ((psbch_payload & 0xFE0000) >> 17)); sync_params->DFN = (((psbch_payload & 0x0700) >> 1) | ((psbch_payload & 0xFE0000) >> 17));
sync_params->slot_offset = (((psbch_payload & 0x010000) >> 10) | ((psbch_payload & 0xFC000000) >> 26)); sync_params->slot_offset = (((psbch_payload & 0x010000) >> 10) | ((psbch_payload & 0xFC000000) >> 26));
LOG_I(PHY, "UE[%d]SIDELINK SLSS SEARCH: SL-MIB: DFN:%d, slot:%d.\n", LOG_I(PHY,
UE->Mod_id, sync_params->DFN, sync_params->slot_offset); "UE[%d]SIDELINK SLSS SEARCH: SL-MIB: DFN:%d, slot:%d.\n",
UE->Mod_id,
sync_params->DFN,
sync_params->slot_offset);
nr_sl_psbch_rsrp_measurements(sl_ue, frame_parms, rxdataF, false); nr_sl_psbch_rsrp_measurements(sl_ue, frame_parms, rxdataF, false);
@@ -501,24 +521,27 @@ nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc,
nr_fill_sl_indication(&sl_indication, &rx_ind, NULL, proc, UE, NULL); nr_fill_sl_indication(&sl_indication, &rx_ind, NULL, proc, UE, NULL);
nr_fill_sl_rx_indication(&rx_ind, SL_NR_RX_PDU_TYPE_SSB, UE, number_pdus, proc, (void *)decoded_output, rx_slss_id); nr_fill_sl_rx_indication(&rx_ind, SL_NR_RX_PDU_TYPE_SSB, UE, number_pdus, proc, (void *)decoded_output, rx_slss_id);
LOG_D(PHY, "Sidelink SLSS SEARCH PSBCH RX OK. Send SL-SSB TO MAC\n"); LOG_D(PHY, "Sidelink SLSS SEARCH PSBCH RX OK. Send SL-SSB TO MAC\n");
if (UE->if_inst && UE->if_inst->sl_indication) if (UE->if_inst && UE->if_inst->sl_indication)
UE->if_inst->sl_indication(&sl_indication); UE->if_inst->sl_indication(&sl_indication);
break; break;
} }
LOG_I(PHY,"SIDELINK SLSS SEARCH: SLSS ID: %d metric %d, phase %d, psbch CRC %s\n", LOG_I(PHY,
sl_ue->sync_params.N_sl_id,metric_tdd_ncp,phase_tdd_ncp,(ret == 0) ? "OK" : "NOT OK"); "SIDELINK SLSS SEARCH: SLSS ID: %d metric %d, phase %d, psbch CRC %s\n",
sl_ue->sync_params.N_sl_id,
metric_tdd_ncp,
phase_tdd_ncp,
(ret == 0) ? "OK" : "NOT OK");
} else { } else {
LOG_W(PHY, "SIDELINK SLSS SEARCH: Error: Not enough samples to process PSBCH. sync_pos %d\n", sync_pos); LOG_W(PHY, "SIDELINK SLSS SEARCH: Error: Not enough samples to process PSBCH. sync_pos %d\n", sync_pos);
} }
} }
if (result.cell_detected) break; if (result.cell_detected)
break;
} }
if (!result.cell_detected) { // PSBCH not found so indicate sync to higher layers and configure frame parameters if (!result.cell_detected) { // PSBCH not found so indicate sync to higher layers and configure frame parameters
+2 -3
View File
@@ -332,9 +332,8 @@ void nr_pbch_unscrambling(int16_t *demod_pbch_e,
} }
} }
void nr_pbch_quantize(int16_t *pbch_llr8, void nr_pbch_quantize(int16_t *pbch_llr8, int16_t *pbch_llr, uint16_t len)
int16_t *pbch_llr, {
uint16_t len) {
for (int i=0; i<len; i++) { for (int i=0; i<len; i++) {
if (pbch_llr[i]>31) if (pbch_llr[i]>31)
pbch_llr8[i]=32; pbch_llr8[i]=32;
+32 -28
View File
@@ -25,7 +25,6 @@
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
// #define DEBUG_PSBCH // #define DEBUG_PSBCH
static void nr_psbch_extract(uint32_t rxdataF_sz, static void nr_psbch_extract(uint32_t rxdataF_sz,
@@ -68,12 +67,22 @@ static void nr_psbch_extract(uint32_t rxdataF_sz,
#ifdef DEBUG_PSBCH #ifdef DEBUG_PSBCH
LOG_I(PHY,"rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n", LOG_I(PHY,
(9*rb) + j,rxF_ext[j].r,rxF_ext[j].i, "rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",
rx_offset,rxF[rx_offset].r,rxF[rx_offset].i); (9 * rb) + j,
LOG_I(PHY,"dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n", rxF_ext[j].r,
(9*rb) + j,dl_ch0_ext[j].r,dl_ch0_ext[j].i, rxF_ext[j].i,
i, dl_ch0[i].r,dl_ch0[i].i); rx_offset,
rxF[rx_offset].r,
rxF[rx_offset].i);
LOG_I(PHY,
"dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n",
(9 * rb) + j,
dl_ch0_ext[j].r,
dl_ch0_ext[j].i,
i,
dl_ch0[i].r,
dl_ch0[i].i);
#endif #endif
j++; j++;
} }
@@ -94,11 +103,9 @@ static void nr_psbch_extract(uint32_t rxdataF_sz,
sprintf(varname, "psbch_dlchext%d.m", symbol); sprintf(varname, "psbch_dlchext%d.m", symbol);
LOG_M(filename, varname, (void *)&dl_ch_estimates_ext[0][0], SL_NR_NUM_PSBCH_DATA_RE_IN_ONE_SYMBOL, 1, 1); LOG_M(filename, varname, (void *)&dl_ch_estimates_ext[0][0], SL_NR_NUM_PSBCH_DATA_RE_IN_ONE_SYMBOL, 1, 1);
#endif #endif
} }
return; return;
} }
int nr_rx_psbch(PHY_VARS_NR_UE *ue, int nr_rx_psbch(PHY_VARS_NR_UE *ue,
@@ -110,7 +117,6 @@ int nr_rx_psbch(PHY_VARS_NR_UE *ue,
c16_t rxdataF[][frame_parms->samples_per_slot_wCP], c16_t rxdataF[][frame_parms->samples_per_slot_wCP],
uint16_t slss_id) uint16_t slss_id)
{ {
uint32_t decoderState = 0; uint32_t decoderState = 0;
int psbch_e_rx_idx = 0; int psbch_e_rx_idx = 0;
// Extra 2 bits needed as polar decoder expects a multiple of 4 as encoder length // Extra 2 bits needed as polar decoder expects a multiple of 4 as encoder length
@@ -118,15 +124,18 @@ int nr_rx_psbch(PHY_VARS_NR_UE *ue,
int16_t psbch_e_rx[SL_NR_POLAR_PSBCH_E_NORMAL_CP + 2] = {0}; int16_t psbch_e_rx[SL_NR_POLAR_PSBCH_E_NORMAL_CP + 2] = {0};
#ifdef DEBUG_PSBCH #ifdef DEBUG_PSBCH
write_output("psbch_rxdataF.m","psbchrxF", write_output("psbch_rxdataF.m",
&rxdataF[0][0],frame_parms->ofdm_symbol_size*SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP,1,1); "psbchrxF",
&rxdataF[0][0],
frame_parms->ofdm_symbol_size * SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP,
1,
1);
#endif #endif
// symbol refers to symbol within SSB. symbol_offset is the offset of the SSB wrt start of slot // symbol refers to symbol within SSB. symbol_offset is the offset of the SSB wrt start of slot
double log2_maxh = 0; double log2_maxh = 0;
// 0 for Normal Cyclic Prefix and 1 for EXT CyclicPrefix // 0 for Normal Cyclic Prefix and 1 for EXT CyclicPrefix
const int numsym = (frame_parms->Ncp) ? SL_NR_NUM_SYMBOLS_SSB_EXT_CP const int numsym = (frame_parms->Ncp) ? SL_NR_NUM_SYMBOLS_SSB_EXT_CP : SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP;
: SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP;
for (int symbol = 0; symbol < numsym;) { for (int symbol = 0; symbol < numsym;) {
const uint16_t nb_re = SL_NR_NUM_PSBCH_DATA_RE_IN_ONE_SYMBOL; const uint16_t nb_re = SL_NR_NUM_PSBCH_DATA_RE_IN_ONE_SYMBOL;
@@ -147,12 +156,9 @@ int nr_rx_psbch(PHY_VARS_NR_UE *ue,
int max_h = 0; int max_h = 0;
if (symbol == 0) { if (symbol == 0) {
max_h = nr_pbch_channel_level(dl_ch_estimates_ext, max_h = nr_pbch_channel_level(dl_ch_estimates_ext, frame_parms, nb_re);
frame_parms,
nb_re);
// log2_maxh = 3+(log2_approx(max_h)/2); // log2_maxh = 3+(log2_approx(max_h)/2);
log2_maxh = 5 + (log2_approx(max_h) / 2); // LLR32 crc error. LLR 16 CRC works log2_maxh = 5 + (log2_approx(max_h) / 2); // LLR32 crc error. LLR 16 CRC works
} }
#ifdef DEBUG_PSBCH #ifdef DEBUG_PSBCH
LOG_I(PHY, "PSBCH RX log2_maxh = %f (%d)\n", log2_maxh, max_h); LOG_I(PHY, "PSBCH RX log2_maxh = %f (%d)\n", log2_maxh, max_h);
@@ -166,9 +172,7 @@ int nr_rx_psbch(PHY_VARS_NR_UE *ue,
frame_parms, frame_parms,
log2_maxh); // log2_maxh+I0_shift log2_maxh); // log2_maxh+I0_shift
nr_pbch_quantize(psbch_e_rx + psbch_e_rx_idx, nr_pbch_quantize(psbch_e_rx + psbch_e_rx_idx, (short *)rxdataF_comp[0], SL_NR_NUM_PSBCH_DATA_BITS_IN_ONE_SYMBOL);
(short *)rxdataF_comp[0],
SL_NR_NUM_PSBCH_DATA_BITS_IN_ONE_SYMBOL);
psbch_e_rx_idx += SL_NR_NUM_PSBCH_DATA_BITS_IN_ONE_SYMBOL; psbch_e_rx_idx += SL_NR_NUM_PSBCH_DATA_BITS_IN_ONE_SYMBOL;
@@ -177,8 +181,6 @@ int nr_rx_psbch(PHY_VARS_NR_UE *ue,
symbol = (symbol == 0) ? 5 : symbol + 1; symbol = (symbol == 0) ? 5 : symbol + 1;
} }
#if 0 // ENABLE SCOPE LATER #if 0 // ENABLE SCOPE LATER
UEscopeCopy(ue, psbchRxdataF_comp, psbch_unClipped, sizeof(struct complex16), frame_parms->nb_antennas_rx, psbch_e_rx_idx/2); UEscopeCopy(ue, psbchRxdataF_comp, psbch_unClipped, sizeof(struct complex16), frame_parms->nb_antennas_rx, psbch_e_rx_idx/2);
UEscopeCopy(ue, psbchLlr, psbch_e_rx, sizeof(int16_t), frame_parms->nb_antennas_rx, psbch_e_rx_idx); UEscopeCopy(ue, psbchLlr, psbch_e_rx, sizeof(int16_t), frame_parms->nb_antennas_rx, psbch_e_rx_idx);
@@ -191,13 +193,15 @@ int nr_rx_psbch(PHY_VARS_NR_UE *ue,
// un-scrambling // un-scrambling
LOG_D(PHY, "PSBCH RX POLAR DECODING: total PSBCH bits:%d, rx_slss_id:%d\n", psbch_e_rx_idx, slss_id); LOG_D(PHY, "PSBCH RX POLAR DECODING: total PSBCH bits:%d, rx_slss_id:%d\n", psbch_e_rx_idx, slss_id);
nr_pbch_unscrambling(psbch_e_rx, slss_id, 0, 0, psbch_e_rx_idx, nr_pbch_unscrambling(psbch_e_rx, slss_id, 0, 0, psbch_e_rx_idx, 0, 0, 0, NULL);
0, 0, 0, NULL);
// polar decoding de-rate matching // polar decoding de-rate matching
uint64_t tmp = 0; uint64_t tmp = 0;
decoderState = polar_decoder_int16(psbch_e_rx,(uint64_t *)&tmp,0, decoderState = polar_decoder_int16(psbch_e_rx,
SL_NR_POLAR_PSBCH_MESSAGE_TYPE, SL_NR_POLAR_PSBCH_PAYLOAD_BITS, SL_NR_POLAR_PSBCH_AGGREGATION_LEVEL); (uint64_t *)&tmp,
0,
SL_NR_POLAR_PSBCH_MESSAGE_TYPE,
SL_NR_POLAR_PSBCH_PAYLOAD_BITS,
SL_NR_POLAR_PSBCH_AGGREGATION_LEVEL);
uint32_t psbch_payload = tmp; uint32_t psbch_payload = tmp;
+69 -59
View File
@@ -60,7 +60,6 @@ void sl_psbch_scrambling(uint32_t *output, uint32_t id, uint16_t length)
// scramble in 32bit chunks // scramble in 32bit chunks
int i = 0; int i = 0;
while (i + 32 <= length) { while (i + 32 <= length) {
output[i >> 5] ^= s; output[i >> 5] ^= s;
i += 32; i += 32;
@@ -80,10 +79,8 @@ void sl_psbch_scrambling(uint32_t *output, uint32_t id, uint16_t length)
printf("\nAFTER SCRAMBLING output[%d]:0x%x\n", i, output[i]); printf("\nAFTER SCRAMBLING output[%d]:0x%x\n", i, output[i]);
} }
#endif #endif
} }
/** /**
*This function RE MAPS PSS, SSS sequences as described in 38.211. *This function RE MAPS PSS, SSS sequences as described in 38.211.
*txF is the data in frequency domain, sync_seq = PSS or SSS seq *txF is the data in frequency domain, sync_seq = PSS or SSS seq
@@ -92,26 +89,30 @@ void sl_psbch_scrambling(uint32_t *output, uint32_t id, uint16_t length)
*scaling factor = scaling factor used for PSS, SSS (determined according to PSBCH pwr) *scaling factor = scaling factor used for PSS, SSS (determined according to PSBCH pwr)
*symbol size = OFDM symbol size used for RE Mapping *symbol size = OFDM symbol size used for RE Mapping
*/ */
void sl_map_pss_or_sss(c16_t *txF, int16_t *sync_seq, uint16_t startsym, void sl_map_pss_or_sss(c16_t *txF,
uint16_t re_offset, uint16_t scaling_factor, int16_t *sync_seq,
uint16_t startsym,
uint16_t re_offset,
uint16_t scaling_factor,
uint16_t symbol_size) uint16_t symbol_size)
{ {
#ifdef SL_DEBUG #ifdef SL_DEBUG
printf("%s. DEBUG PSBCH TX: RE MAPPING of PSS/SSS \n", __func__); printf("%s. DEBUG PSBCH TX: RE MAPPING of PSS/SSS \n", __func__);
printf("Input Params - StartSYM:%d, NUMSYM:%d, RE_OFFSET:%d, num_REs:%d, scaling_factor:%d, symbol_size:%d\n", printf("Input Params - StartSYM:%d, NUMSYM:%d, RE_OFFSET:%d, num_REs:%d, scaling_factor:%d, symbol_size:%d\n",
startsym, SL_NR_NUM_PSS_OR_SSS_SYMBOLS,re_offset, SL_NR_NUM_PSBCH_RE_IN_ONE_SYMBOL, scaling_factor, symbol_size); startsym,
SL_NR_NUM_PSS_OR_SSS_SYMBOLS,
re_offset,
SL_NR_NUM_PSBCH_RE_IN_ONE_SYMBOL,
scaling_factor,
symbol_size);
#endif #endif
// RE Mapping of SL-PSS, SL-SSS // RE Mapping of SL-PSS, SL-SSS
for (int l = startsym; l < (startsym + SL_NR_NUM_PSS_OR_SSS_SYMBOLS); l++) { for (int l = startsym; l < (startsym + SL_NR_NUM_PSS_OR_SSS_SYMBOLS); l++) {
int k = re_offset % symbol_size; int k = re_offset % symbol_size;
int index = 0, offset = 0; int index = 0, offset = 0;
for (int m = 0; m < SL_NR_NUM_PSBCH_RE_IN_ONE_SYMBOL; m++) { for (int m = 0; m < SL_NR_NUM_PSBCH_RE_IN_ONE_SYMBOL; m++) {
offset = l * symbol_size + k; offset = l * symbol_size + k;
if ((m < 2) || (m >= (SL_NR_NUM_PSBCH_RE_IN_ONE_SYMBOL - 3))) { if ((m < 2) || (m >= (SL_NR_NUM_PSBCH_RE_IN_ONE_SYMBOL - 3))) {
txF[offset].r = 0; // Set REs 0,1,129,130,131 = 0 txF[offset].r = 0; // Set REs 0,1,129,130,131 = 0
@@ -124,7 +125,14 @@ void sl_map_pss_or_sss(c16_t *txF, int16_t *sync_seq, uint16_t startsym,
txF[offset].r = (sync_seq[index] * scaling_factor) >> 15; txF[offset].r = (sync_seq[index] * scaling_factor) >> 15;
#ifdef SL_DEBUG #ifdef SL_DEBUG
printf("sym:%d, RE:%d, txF[%d]:%d.%d, syncseq[%d]:%d \n", l, m, offset, txF[offset].r,txF[offset].i, index, sync_seq[index]); printf("sym:%d, RE:%d, txF[%d]:%d.%d, syncseq[%d]:%d \n",
l,
m,
offset,
txF[offset].r,
txF[offset].i,
index,
sync_seq[index]);
#endif #endif
index++; index++;
@@ -133,10 +141,8 @@ void sl_map_pss_or_sss(c16_t *txF, int16_t *sync_seq, uint16_t startsym,
k = (k + 1) % symbol_size; k = (k + 1) % symbol_size;
} }
} }
} }
/** /**
* This function Generates the PSBCH DATA Modulation symbols and RE MAPS PSBCH Modulated symbols * This function Generates the PSBCH DATA Modulation symbols and RE MAPS PSBCH Modulated symbols
* and PSBCH DMRS sequences as described in 38.211. * and PSBCH DMRS sequences as described in 38.211.
@@ -150,12 +156,15 @@ void sl_map_pss_or_sss(c16_t *txF, int16_t *sync_seq, uint16_t startsym,
* symbol size = OFDM symbol size used for RE Mapping * symbol size = OFDM symbol size used for RE Mapping
*/ */
void sl_generate_and_map_psbch(c16_t *txF, uint32_t *payload, uint16_t id, void sl_generate_and_map_psbch(c16_t *txF,
uint16_t cp, uint16_t re_offset, uint32_t *payload,
uint16_t scaling_factor, uint16_t symbol_size, uint16_t id,
uint16_t cp,
uint16_t re_offset,
uint16_t scaling_factor,
uint16_t symbol_size,
c16_t *psbch_dmrs) c16_t *psbch_dmrs)
{ {
uint64_t psbch_a_reversed = 0; uint64_t psbch_a_reversed = 0;
uint16_t num_psbch_modsym = 0, numsym = 0; uint16_t num_psbch_modsym = 0, numsym = 0;
const int mod_order = 2; // QPSK const int mod_order = 2; // QPSK
@@ -174,7 +183,10 @@ void sl_generate_and_map_psbch(c16_t *txF, uint32_t *payload, uint16_t id,
#endif #endif
/// CRC, coding and rate matching /// CRC, coding and rate matching
polar_encoder_fast(&psbch_a_reversed, (void*)encoder_output, 0, 0, polar_encoder_fast(&psbch_a_reversed,
(void *)encoder_output,
0,
0,
SL_NR_POLAR_PSBCH_MESSAGE_TYPE, SL_NR_POLAR_PSBCH_MESSAGE_TYPE,
SL_NR_POLAR_PSBCH_PAYLOAD_BITS, SL_NR_POLAR_PSBCH_PAYLOAD_BITS,
SL_NR_POLAR_PSBCH_AGGREGATION_LEVEL); SL_NR_POLAR_PSBCH_AGGREGATION_LEVEL);
@@ -191,15 +203,13 @@ void sl_generate_and_map_psbch(c16_t *txF, uint32_t *payload, uint16_t id,
num_psbch_modsym = SL_NR_POLAR_PSBCH_E_EXT_CP / mod_order; num_psbch_modsym = SL_NR_POLAR_PSBCH_E_EXT_CP / mod_order;
numsym = SL_NR_NUM_SYMBOLS_SSB_EXT_CP; numsym = SL_NR_NUM_SYMBOLS_SSB_EXT_CP;
AssertFatal(1 == 0, "EXT CP is not yet supported\n"); AssertFatal(1 == 0, "EXT CP is not yet supported\n");
} } else { // Normal CP
else { // Normal CP
sl_psbch_scrambling(encoder_output, id, SL_NR_POLAR_PSBCH_E_NORMAL_CP); // for Cyclic prefix sl_psbch_scrambling(encoder_output, id, SL_NR_POLAR_PSBCH_E_NORMAL_CP); // for Cyclic prefix
num_psbch_modsym = SL_NR_POLAR_PSBCH_E_NORMAL_CP / mod_order; num_psbch_modsym = SL_NR_POLAR_PSBCH_E_NORMAL_CP / mod_order;
numsym = SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP; numsym = SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP;
} }
LOG_D(PHY,"PSBCH TX: 38.211 Scrambling done. Number of bits:%d \n", LOG_D(PHY, "PSBCH TX: 38.211 Scrambling done. Number of bits:%d \n", SL_NR_POLAR_PSBCH_E_NORMAL_CP);
SL_NR_POLAR_PSBCH_E_NORMAL_CP);
#ifdef SL_DEBUG #ifdef SL_DEBUG
printf("38211 STEP: PSBCH Scrambling \n"); printf("38211 STEP: PSBCH Scrambling \n");
@@ -231,17 +241,20 @@ void sl_generate_and_map_psbch(c16_t *txF, uint32_t *payload, uint16_t id,
#ifdef SL_DEBUG #ifdef SL_DEBUG
printf("%s. DEBUG PSBCH TX: RE MAPPING of PSBCH DATA AND DMRS \n", __func__); printf("%s. DEBUG PSBCH TX: RE MAPPING of PSBCH DATA AND DMRS \n", __func__);
printf("Input Params - StartSYM:%d, NUMSYM:%d, RE_OFFSET:%d, num_REs:%d, scaling_factor:%d, symbol_size:%d\n", printf("Input Params - StartSYM:%d, NUMSYM:%d, RE_OFFSET:%d, num_REs:%d, scaling_factor:%d, symbol_size:%d\n",
0, numsym,re_offset, numre, scaling_factor, symbol_size); 0,
numsym,
re_offset,
numre,
scaling_factor,
symbol_size);
#endif #endif
for (int l = 0; l < numsym;) { for (int l = 0; l < numsym;) {
int k = re_offset % symbol_size; int k = re_offset % symbol_size;
int symbol_offset = l * symbol_size; int symbol_offset = l * symbol_size;
int offset = 0; int offset = 0;
for (int m = 0; m < numre; m++) { for (int m = 0; m < numre; m++) {
// Maps PSBCH DMRS in every 4th RE ex:0,4,....128 // Maps PSBCH DMRS in every 4th RE ex:0,4,....128
// Maps PSBCH in all other REs ex: 1,2,3,5,6,...127,129,130,131 // Maps PSBCH in all other REs ex: 1,2,3,5,6,...127,129,130,131
@@ -252,12 +265,16 @@ void sl_generate_and_map_psbch(c16_t *txF, uint32_t *payload, uint16_t id,
#endif #endif
if (m % 4 == 0) { if (m % 4 == 0) {
txF[offset] = c16xmulConstShift(psbch_dmrs[dmrs_index], scaling_factor, 15); txF[offset] = c16xmulConstShift(psbch_dmrs[dmrs_index], scaling_factor, 15);
#ifdef SL_DEBUG #ifdef SL_DEBUG
printf("txF[%d]:%d,%d, psbch_dmrs[%d]:%d,%d ", offset, txF[offset].r, printf("txF[%d]:%d,%d, psbch_dmrs[%d]:%d,%d ",
txF[offset].i, dmrs_index, psbch_dmrs[dmrs_index].r, psbch_dmrs[dmrs_index].i); offset,
txF[offset].r,
txF[offset].i,
dmrs_index,
psbch_dmrs[dmrs_index].r,
psbch_dmrs[dmrs_index].i);
#endif #endif
dmrs_index++; dmrs_index++;
@@ -266,8 +283,13 @@ void sl_generate_and_map_psbch(c16_t *txF, uint32_t *payload, uint16_t id,
txF[offset] = c16xmulConstShift(psbch_modsym[index], scaling_factor, 15); txF[offset] = c16xmulConstShift(psbch_modsym[index], scaling_factor, 15);
#ifdef SL_DEBUG #ifdef SL_DEBUG
printf("txF[%d]:%d,%d, psbch_modsym[%d]:%d,%d\n", offset, txF[offset].r, printf("txF[%d]:%d,%d, psbch_modsym[%d]:%d,%d\n",
txF[offset].i, index ,psbch_modsym[index].r, psbch_modsym[index].i); offset,
txF[offset].r,
txF[offset].i,
index,
psbch_modsym[index].r,
psbch_modsym[index].i);
#endif #endif
index++; index++;
@@ -276,28 +298,27 @@ void sl_generate_and_map_psbch(c16_t *txF, uint32_t *payload, uint16_t id,
k = (k + 1) % symbol_size; k = (k + 1) % symbol_size;
} }
LOG_D(PHY, "PSBCH TX: 38211 STEP: RE MAPPING OF PSBCH, PSBCH DMRS DONE. symbol:%d, first RE offset:%d, Last RE offset:%d, Num PSBCH DATA REs:%d, Num PSBCH DMRS REs:%d\n", LOG_D(PHY,
l, symbol_offset+re_offset, offset, index, dmrs_index); "PSBCH TX: 38211 STEP: RE MAPPING OF PSBCH, PSBCH DMRS DONE. symbol:%d, first RE offset:%d, Last RE offset:%d, Num PSBCH "
"DATA REs:%d, Num PSBCH DMRS REs:%d\n",
l,
symbol_offset + re_offset,
offset,
index,
dmrs_index);
l = (l == 0) ? 5 : l + 1; l = (l == 0) ? 5 : l + 1;
} }
} }
/** /**
*This function prepares the PSBCH block and RE MAPS PSS, SSS, PSBCH DATA, PSBCH DMRS into buffer txF. *This function prepares the PSBCH block and RE MAPS PSS, SSS, PSBCH DATA, PSBCH DMRS into buffer txF.
*Called by the L1 Scheduler when MAC triggers PHY to send PSBCH *Called by the L1 Scheduler when MAC triggers PHY to send PSBCH
*UE is the UE context. *UE is the UE context.
*frame, slot points to the TTI in which PSBCH TX will be transmitted *frame, slot points to the TTI in which PSBCH TX will be transmitted
*/ */
void nr_tx_psbch(PHY_VARS_NR_UE *UE, uint32_t frame_tx, void nr_tx_psbch(PHY_VARS_NR_UE *UE, uint32_t frame_tx, uint32_t slot_tx, sl_nr_tx_config_psbch_pdu_t *psbch_vars, c16_t **txdataF)
uint32_t slot_tx,
sl_nr_tx_config_psbch_pdu_t *psbch_vars,
c16_t **txdataF)
{ {
sl_nr_ue_phy_params_t *sl_ue_phy_params = &UE->SL_UE_PHY_PARAMS; sl_nr_ue_phy_params_t *sl_ue_phy_params = &UE->SL_UE_PHY_PARAMS;
uint16_t slss_id = psbch_vars->tx_slss_id; uint16_t slss_id = psbch_vars->tx_slss_id;
NR_DL_FRAME_PARMS *sl_fp = &sl_ue_phy_params->sl_frame_params; NR_DL_FRAME_PARMS *sl_fp = &sl_ue_phy_params->sl_frame_params;
@@ -314,12 +335,10 @@ void nr_tx_psbch(PHY_VARS_NR_UE *UE, uint32_t frame_tx,
psbch_payload |= (slot_tx << 26) & 0xFC000000; psbch_payload |= (slot_tx << 26) & 0xFC000000;
#ifdef SL_DEBUG #ifdef SL_DEBUG
printf("DEBUG PSBCH TX: DFN, SLOT included. psbch_a :0x%08x, frame:%d, slot:%d\n", printf("DEBUG PSBCH TX: DFN, SLOT included. psbch_a :0x%08x, frame:%d, slot:%d\n", psbch_payload, frame_tx, slot_tx);
psbch_payload, frame_tx, slot_tx);
#endif #endif
LOG_D(PHY,"PSBCH TX: Frame.Slot %d.%d. Payload::0x%08x, slssid:%d\n", LOG_D(PHY, "PSBCH TX: Frame.Slot %d.%d. Payload::0x%08x, slssid:%d\n", frame_tx, slot_tx, psbch_payload, slss_id);
frame_tx, slot_tx, psbch_payload, slss_id);
// GENERATE Sidelink PSS,SSS Sequences, PSBCH DMRS Symbols, PSBCH Symbols // GENERATE Sidelink PSS,SSS Sequences, PSBCH DMRS Symbols, PSBCH Symbols
int16_t *sl_pss = &sl_ue_phy_params->init_params.sl_pss[slss_id / 336][0]; int16_t *sl_pss = &sl_ue_phy_params->init_params.sl_pss[slss_id / 336][0];
@@ -333,32 +352,27 @@ void nr_tx_psbch(PHY_VARS_NR_UE *UE, uint32_t frame_tx,
struct complex16 *txF = &txdataF[0][0]; struct complex16 *txF = &txdataF[0][0];
uint16_t startsym = SL_NR_PSS_START_SYMBOL; uint16_t startsym = SL_NR_PSS_START_SYMBOL;
#ifdef SL_DEBUG #ifdef SL_DEBUG
printf("DEBUG PSBCH TX: MAP PSS. startsym:%d, PSS RE START:%d, scaling factor:%d\n", printf("DEBUG PSBCH TX: MAP PSS. startsym:%d, PSS RE START:%d, scaling factor:%d\n", startsym, re_offset, scaling_factor);
startsym, re_offset, scaling_factor);
#endif #endif
sl_map_pss_or_sss(txF, sl_pss, startsym, re_offset, scaling_factor, symbol_size); // PSS sl_map_pss_or_sss(txF, sl_pss, startsym, re_offset, scaling_factor, symbol_size); // PSS
startsym += SL_NR_NUM_PSS_SYMBOLS; startsym += SL_NR_NUM_PSS_SYMBOLS;
#ifdef SL_DEBUG #ifdef SL_DEBUG
printf("DEBUG PSBCH TX: MAP SSS. startsym:%d, SSS RE START:%d, scaling factor:%d\n", printf("DEBUG PSBCH TX: MAP SSS. startsym:%d, SSS RE START:%d, scaling factor:%d\n", startsym, re_offset, scaling_factor);
startsym, re_offset, scaling_factor);
#endif #endif
sl_map_pss_or_sss(txF, sl_sss, startsym, re_offset, scaling_factor, symbol_size); // SSS sl_map_pss_or_sss(txF, sl_sss, startsym, re_offset, scaling_factor, symbol_size); // SSS
#ifdef SL_DEBUG #ifdef SL_DEBUG
printf("DEBUG PSBCH TX: MAP PSBCH DATA AND DMRS. cyclicPrefix:%d, PSS RE START:%d, scaling factor:%d\n", printf("DEBUG PSBCH TX: MAP PSBCH DATA AND DMRS. cyclicPrefix:%d, PSS RE START:%d, scaling factor:%d\n",
sl_fp->Ncp, re_offset, scaling_factor); sl_fp->Ncp,
re_offset,
scaling_factor);
#endif #endif
struct complex16 *psbch_dmrs = &sl_ue_phy_params->init_params.psbch_dmrs_modsym[slss_id][0]; struct complex16 *psbch_dmrs = &sl_ue_phy_params->init_params.psbch_dmrs_modsym[slss_id][0];
sl_generate_and_map_psbch(txF, &psbch_payload, slss_id, sl_generate_and_map_psbch(txF, &psbch_payload, slss_id, sl_fp->Ncp, re_offset, scaling_factor, symbol_size, psbch_dmrs);
sl_fp->Ncp, re_offset, scaling_factor, symbol_size,
psbch_dmrs);
#ifdef SL_DEBUG #ifdef SL_DEBUG
printf("DEBUG PSBCH TX: txdataF Prepared\n"); printf("DEBUG PSBCH TX: txdataF Prepared\n");
@@ -367,8 +381,4 @@ void nr_tx_psbch(PHY_VARS_NR_UE *UE, uint32_t frame_tx,
#ifdef SL_DEBUG #ifdef SL_DEBUG
LOG_M("sl_psbch_block.m", "sl_txF", (void *)txdataF[0], symbol_size * 14, 1, 1); LOG_M("sl_psbch_block.m", "sl_txF", (void *)txdataF[0], symbol_size * 14, 1, 1);
#endif #endif
} }
@@ -428,9 +428,7 @@ int nr_rx_psbch(PHY_VARS_NR_UE *ue,
c16_t rxdataF[][frame_parms->samples_per_slot_wCP], c16_t rxdataF[][frame_parms->samples_per_slot_wCP],
uint16_t slss_id); uint16_t slss_id);
void nr_tx_psbch(PHY_VARS_NR_UE *UE, uint32_t frame_tx, uint32_t slot_tx, void nr_tx_psbch(PHY_VARS_NR_UE *UE, uint32_t frame_tx, uint32_t slot_tx, sl_nr_tx_config_psbch_pdu_t *psbch_vars, c16_t **txdataF);
sl_nr_tx_config_psbch_pdu_t *psbch_vars,
c16_t **txdataF);
nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc, int num_frames); nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc, int num_frames);
+4 -14
View File
@@ -706,7 +706,6 @@ static int pss_search_time_nr(c16_t **rxdata, PHY_VARS_NR_UE *ue, int fo_flag, i
void sl_generate_pss(SL_NR_UE_INIT_PARAMS_t *sl_init_params, uint8_t n_sl_id2, uint16_t scaling) void sl_generate_pss(SL_NR_UE_INIT_PARAMS_t *sl_init_params, uint8_t n_sl_id2, uint16_t scaling)
{ {
int i = 0, m = 0; int i = 0, m = 0;
int16_t x[SL_NR_PSS_SEQUENCE_LENGTH]; int16_t x[SL_NR_PSS_SEQUENCE_LENGTH];
const int x_initial[7] = {0, 1, 1, 0, 1, 1, 1}; const int x_initial[7] = {0, 1, 1, 0, 1, 1, 1};
@@ -735,22 +734,17 @@ void sl_generate_pss(SL_NR_UE_INIT_PARAMS_t *sl_init_params, uint8_t n_sl_id2, u
#ifdef SL_DEBUG_INIT_DATA #ifdef SL_DEBUG_INIT_DATA
printf("m:%d, sl_pss[%d]:%d\n", m, i, sl_pss[i]); printf("m:%d, sl_pss[%d]:%d\n", m, i, sl_pss[i]);
#endif #endif
} }
#ifdef SL_DUMP_INIT_SAMPLES #ifdef SL_DUMP_INIT_SAMPLES
LOG_M("sl_pss_seq.m", "sl_pss", (void *)sl_pss, SL_NR_PSS_SEQUENCE_LENGTH, 1, 0); LOG_M("sl_pss_seq.m", "sl_pss", (void *)sl_pss, SL_NR_PSS_SEQUENCE_LENGTH, 1, 0);
#endif #endif
} }
// This cannot be done at init time as ofdm symbol size, ssb start subcarrier depends on configuration // This cannot be done at init time as ofdm symbol size, ssb start subcarrier depends on configuration
// done at SLSS read time. // done at SLSS read time.
void sl_generate_pss_ifft_samples(sl_nr_ue_phy_params_t *sl_ue_params, SL_NR_UE_INIT_PARAMS_t *sl_init_params) void sl_generate_pss_ifft_samples(sl_nr_ue_phy_params_t *sl_ue_params, SL_NR_UE_INIT_PARAMS_t *sl_init_params)
{ {
uint8_t id2 = 0; uint8_t id2 = 0;
int16_t *sl_pss = NULL; int16_t *sl_pss = NULL;
NR_DL_FRAME_PARMS *sl_fp = &sl_ue_params->sl_frame_params; NR_DL_FRAME_PARMS *sl_fp = &sl_ue_params->sl_frame_params;
@@ -765,9 +759,9 @@ void sl_generate_pss_ifft_samples(sl_nr_ue_phy_params_t *sl_ue_params, SL_NR_UE_
LOG_I(PHY, "SIDELINK INIT: Generation of PSS time domain samples. scaling_factor:%d\n", scaling_factor); LOG_I(PHY, "SIDELINK INIT: Generation of PSS time domain samples. scaling_factor:%d\n", scaling_factor);
for (id2 = 0; id2 < SL_NR_NUM_IDs_IN_PSS; id2++) { for (id2 = 0; id2 < SL_NR_NUM_IDs_IN_PSS; id2++) {
k = sl_fp->first_carrier_offset + sl_fp->ssb_start_subcarrier + 2; // PSS in from REs 2-129 k = sl_fp->first_carrier_offset + sl_fp->ssb_start_subcarrier + 2; // PSS in from REs 2-129
if (k >= sl_fp->ofdm_symbol_size) k -= sl_fp->ofdm_symbol_size; if (k >= sl_fp->ofdm_symbol_size)
k -= sl_fp->ofdm_symbol_size;
pss_T = &sl_init_params->sl_pss_for_correlation[id2][0]; pss_T = &sl_init_params->sl_pss_for_correlation[id2][0];
sl_pss = sl_init_params->sl_pss[id2]; sl_pss = sl_init_params->sl_pss[id2];
@@ -776,7 +770,6 @@ void sl_generate_pss_ifft_samples(sl_nr_ue_phy_params_t *sl_ue_params, SL_NR_UE_
memset(pss_F, 0, sl_fp->ofdm_symbol_size * sizeof(c16_t)); memset(pss_F, 0, sl_fp->ofdm_symbol_size * sizeof(c16_t));
for (int i = 0; i < SL_NR_PSS_SEQUENCE_LENGTH; i++) { for (int i = 0; i < SL_NR_PSS_SEQUENCE_LENGTH; i++) {
pss_F[k].r = (sl_pss[i] * scaling_factor) >> 15; pss_F[k].r = (sl_pss[i] * scaling_factor) >> 15;
// pss_F[2*k] = (sl_pss[i]/23170) * 4192; // pss_F[2*k] = (sl_pss[i]/23170) * 4192;
// pss_F[2*k+1] = 0; // pss_F[2*k+1] = 0;
@@ -786,21 +779,18 @@ void sl_generate_pss_ifft_samples(sl_nr_ue_phy_params_t *sl_ue_params, SL_NR_UE_
#endif #endif
k++; k++;
if (k == sl_fp->ofdm_symbol_size) k=0; if (k == sl_fp->ofdm_symbol_size)
k = 0;
} }
idft((int16_t)get_idft(sl_fp->ofdm_symbol_size), idft((int16_t)get_idft(sl_fp->ofdm_symbol_size),
(int16_t *)&pss_F[0], /* complex input */ (int16_t *)&pss_F[0], /* complex input */
(int16_t *)&pss_T[0], /* complex output */ (int16_t *)&pss_T[0], /* complex output */
1); /* scaling factor */ 1); /* scaling factor */
} }
#ifdef SL_DUMP_PSBCH_TX_SAMPLES #ifdef SL_DUMP_PSBCH_TX_SAMPLES
LOG_M("sl_pss_TD_id0.m", "pss_TD_0", (void *)sl_init_params->sl_pss_for_correlation[0], sl_fp->ofdm_symbol_size, 1, 1); LOG_M("sl_pss_TD_id0.m", "pss_TD_0", (void *)sl_init_params->sl_pss_for_correlation[0], sl_fp->ofdm_symbol_size, 1, 1);
LOG_M("sl_pss_TD_id1.m", "pss_TD_1", (void *)sl_init_params->sl_pss_for_correlation[1], sl_fp->ofdm_symbol_size, 1, 1); LOG_M("sl_pss_TD_id1.m", "pss_TD_1", (void *)sl_init_params->sl_pss_for_correlation[1], sl_fp->ofdm_symbol_size, 1, 1);
#endif #endif
} }
-3
View File
@@ -533,7 +533,6 @@ bool rx_sss_nr(PHY_VARS_NR_UE *ue,
void sl_generate_sss(SL_NR_UE_INIT_PARAMS_t *sl_init_params, uint16_t slss_id, uint16_t scaling) void sl_generate_sss(SL_NR_UE_INIT_PARAMS_t *sl_init_params, uint16_t slss_id, uint16_t scaling)
{ {
int i = 0; int i = 0;
int m0, m1; int m0, m1;
int n_sl_id1, n_sl_id2; int n_sl_id1, n_sl_id2;
@@ -572,12 +571,10 @@ void sl_generate_sss(SL_NR_UE_INIT_PARAMS_t *sl_init_params, uint16_t slss_id, u
#ifdef SL_DEBUG_INIT_DATA #ifdef SL_DEBUG_INIT_DATA
printf("m0:%d, m1:%d, sl_sss_for_sync[%d]:%d, sl_sss[%d]:%d\n", m0, m1, i, sl_sss_for_sync[i], i, sl_sss[i]); printf("m0:%d, m1:%d, sl_sss_for_sync[%d]:%d, sl_sss[%d]:%d\n", m0, m1, i, sl_sss_for_sync[i], i, sl_sss[i]);
#endif #endif
} }
#ifdef SL_DUMP_PSBCH_TX_SAMPLES #ifdef SL_DUMP_PSBCH_TX_SAMPLES
LOG_M("sl_sss_seq.m", "sl_sss", (void *)sl_sss, SL_NR_SSS_SEQUENCE_LENGTH, 1, 0); LOG_M("sl_sss_seq.m", "sl_sss", (void *)sl_sss, SL_NR_SSS_SEQUENCE_LENGTH, 1, 0);
LOG_M("sl_sss_forsync_seq.m", "sl_sss_for_sync", (void *)sl_sss_for_sync, SL_NR_SSS_SEQUENCE_LENGTH, 1, 0); LOG_M("sl_sss_forsync_seq.m", "sl_sss_for_sync", (void *)sl_sss_for_sync, SL_NR_SSS_SEQUENCE_LENGTH, 1, 0);
#endif #endif
} }
+3 -5
View File
@@ -242,11 +242,9 @@ extern "C" {
}; };
} }
__attribute__((always_inline)) inline c16_t c16xmulConstShift(const c16_t a, const int b, const int Shift) { __attribute__((always_inline)) inline c16_t c16xmulConstShift(const c16_t a, const int b, const int Shift)
return (c16_t) { {
.r = (int16_t)((a.r * b) >> Shift), return (c16_t){.r = (int16_t)((a.r * b) >> Shift), .i = (int16_t)((a.i * b) >> Shift)};
.i = (int16_t)((a.i * b) >> Shift)
};
} }
__attribute__((always_inline)) inline c32_t c32x16maddShift(const c16_t a, const c16_t b, const c32_t c, const int Shift) { __attribute__((always_inline)) inline c32_t c32x16maddShift(const c16_t a, const c16_t b, const c32_t c, const int Shift) {
+1 -15
View File
@@ -33,14 +33,11 @@
#ifndef _DEFS_NR_SL_UE_H_ #ifndef _DEFS_NR_SL_UE_H_
#define _DEFS_NR_SL_UE_H_ #define _DEFS_NR_SL_UE_H_
#include "PHY/types.h" #include "PHY/types.h"
#include "PHY/defs_nr_common.h" #include "PHY/defs_nr_common.h"
#include "nfapi/open-nFAPI/nfapi/public_inc/sidelink_nr_ue_interface.h" #include "nfapi/open-nFAPI/nfapi/public_inc/sidelink_nr_ue_interface.h"
#include "common/utils/time_meas.h" #include "common/utils/time_meas.h"
// (33*(13-4)) // (33*(13-4))
// Normal CP - NUM_SSB_Symbols = 13. 4 symbols for PSS, SSS // Normal CP - NUM_SSB_Symbols = 13. 4 symbols for PSS, SSS
#define SL_NR_NUM_PSBCH_DMRS_RE 297 #define SL_NR_NUM_PSBCH_DMRS_RE 297
@@ -61,8 +58,6 @@
// 11 * (12-3 DMRS REs) * 9 symbols for PSBCH // 11 * (12-3 DMRS REs) * 9 symbols for PSBCH
#define SL_NR_NUM_PSBCH_DATA_RE_IN_ALL_SYMBOLS 891 #define SL_NR_NUM_PSBCH_DATA_RE_IN_ALL_SYMBOLS 891
#define SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP 13 #define SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP 13
#define SL_NR_NUM_SYMBOLS_SSB_EXT_CP 11 #define SL_NR_NUM_SYMBOLS_SSB_EXT_CP 11
#define SL_NR_NUM_PSS_SYMBOLS 2 #define SL_NR_NUM_PSS_SYMBOLS 2
@@ -76,17 +71,12 @@
#define SL_NR_NUM_IDs_IN_SSS 336 #define SL_NR_NUM_IDs_IN_SSS 336
#define SL_NR_NUM_SLSS_IDs 672 #define SL_NR_NUM_SLSS_IDs 672
typedef enum sl_nr_sidelink_mode { typedef enum sl_nr_sidelink_mode { SL_NOT_SUPPORTED = 0, SL_MODE1_SUPPORTED, SL_MODE2_SUPPORTED } sl_nr_sidelink_mode_t;
SL_NOT_SUPPORTED = 0,
SL_MODE1_SUPPORTED,
SL_MODE2_SUPPORTED
} sl_nr_sidelink_mode_t;
//(11*(12-3 DMRS REs) * 2 (QPSK used) //(11*(12-3 DMRS REs) * 2 (QPSK used)
#define SL_NR_NUM_PSBCH_DATA_BITS_IN_ONE_SYMBOL 198 #define SL_NR_NUM_PSBCH_DATA_BITS_IN_ONE_SYMBOL 198
typedef struct SL_NR_UE_INIT_PARAMS { typedef struct SL_NR_UE_INIT_PARAMS {
// gold sequences for PSBCH DMRS // gold sequences for PSBCH DMRS
uint32_t psbch_dmrs_gold_sequences[SL_NR_NUM_SLSS_IDs][SL_NR_NUM_PSBCH_DMRS_RE_DWORD]; // Gold sequences for PSBCH DMRS uint32_t psbch_dmrs_gold_sequences[SL_NR_NUM_SLSS_IDs][SL_NR_NUM_PSBCH_DMRS_RE_DWORD]; // Gold sequences for PSBCH DMRS
@@ -106,7 +96,6 @@ typedef struct SL_NR_UE_INIT_PARAMS {
} SL_NR_UE_INIT_PARAMS_t; } SL_NR_UE_INIT_PARAMS_t;
typedef struct SL_NR_SYNC_PARAMS { typedef struct SL_NR_SYNC_PARAMS {
// Indicating start of SSB block in the initial set of samples // Indicating start of SSB block in the initial set of samples
uint32_t ssb_offset; uint32_t ssb_offset;
// Freq Offset calculated // Freq Offset calculated
@@ -124,7 +113,6 @@ typedef struct SL_NR_SYNC_PARAMS {
} SL_NR_SYNC_PARAMS_t; } SL_NR_SYNC_PARAMS_t;
typedef struct SL_NR_UE_PSBCH { typedef struct SL_NR_UE_PSBCH {
// AVG POWER OF PSBCH DMRS in dB/RE // AVG POWER OF PSBCH DMRS in dB/RE
int16_t rsrp_dB_per_RE; int16_t rsrp_dB_per_RE;
// AVG POWER OF PSBCH DMRS in dBm/RE // AVG POWER OF PSBCH DMRS in dBm/RE
@@ -142,7 +130,6 @@ typedef struct SL_NR_UE_PSBCH {
} SL_NR_UE_PSBCH_t; } SL_NR_UE_PSBCH_t;
typedef struct sl_nr_ue_phy_params { typedef struct sl_nr_ue_phy_params {
SL_NR_UE_INIT_PARAMS_t init_params; SL_NR_UE_INIT_PARAMS_t init_params;
SL_NR_SYNC_PARAMS_t sync_params; SL_NR_SYNC_PARAMS_t sync_params;
@@ -162,5 +149,4 @@ typedef struct sl_nr_ue_phy_params {
} sl_nr_ue_phy_params_t; } sl_nr_ue_phy_params_t;
#endif #endif
+2 -7
View File
@@ -165,13 +165,8 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue,
const UE_nr_rxtx_proc_t *proc, const UE_nr_rxtx_proc_t *proc,
c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]);
int psbch_pscch_processing(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, nr_phy_data_t *phy_data);
int psbch_pscch_processing(PHY_VARS_NR_UE *ue, int phy_procedures_nrUE_SL_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, nr_phy_data_tx_t *phy_data);
UE_nr_rxtx_proc_t *proc,
nr_phy_data_t *phy_data);
int phy_procedures_nrUE_SL_TX(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
nr_phy_data_tx_t *phy_data);
/*! \brief This function prepares the sl indication to pass to the MAC /*! \brief This function prepares the sl indication to pass to the MAC
*/ */
void nr_fill_sl_indication(nr_sidelink_indication_t *sl_ind, void nr_fill_sl_indication(nr_sidelink_indication_t *sl_ind,
+3 -18
View File
@@ -865,12 +865,7 @@ int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size]; __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size];
for (int i=1; i<4; i++) { for (int i=1; i<4; i++) {
nr_slot_fep(ue, nr_slot_fep(ue, fp, proc, (ssb_start_symbol + i) % (fp->symbols_per_slot), rxdataF, link_type_dl);
fp,
proc,
(ssb_start_symbol+i)%(fp->symbols_per_slot),
rxdataF,
link_type_dl);
start_meas(&ue->dlsch_channel_estimation_stats); start_meas(&ue->dlsch_channel_estimation_stats);
nr_pbch_channel_estimation(ue, nr_pbch_channel_estimation(ue,
@@ -926,12 +921,7 @@ int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_
{ {
for(int j = prs_config->SymbolStart; j < (prs_config->SymbolStart+prs_config->NumPRSSymbols); j++) for(int j = prs_config->SymbolStart; j < (prs_config->SymbolStart+prs_config->NumPRSSymbols); j++)
{ {
nr_slot_fep(ue, nr_slot_fep(ue, fp, proc, (j % fp->symbols_per_slot), rxdataF, link_type_dl);
fp,
proc,
(j%fp->symbols_per_slot),
rxdataF,
link_type_dl);
} }
nr_prs_channel_estimation(gNB_id, rsc_id, i, ue, proc, fp, rxdataF); nr_prs_channel_estimation(gNB_id, rsc_id, i, ue, proc, fp, rxdataF);
} }
@@ -962,12 +952,7 @@ int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_
for (uint16_t l=0; l<nb_symb_pdcch; l++) { for (uint16_t l=0; l<nb_symb_pdcch; l++) {
start_meas(&ue->ofdm_demod_stats); start_meas(&ue->ofdm_demod_stats);
nr_slot_fep(ue, nr_slot_fep(ue, fp, proc, l, rxdataF, link_type_dl);
fp,
proc,
l,
rxdataF,
link_type_dl);
} }
// Hold the channel estimates in frequency domain. // Hold the channel estimates in frequency domain.
+34 -53
View File
@@ -68,7 +68,6 @@ void nr_fill_sl_rx_indication(sl_nr_rx_indication_t *rx_ind,
void *typeSpecific, void *typeSpecific,
uint16_t rx_slss_id) uint16_t rx_slss_id)
{ {
if (n_pdus > 1) { if (n_pdus > 1) {
LOG_E(PHY, "In %s: multiple number of SL PDUs not supported yet...\n", __FUNCTION__); LOG_E(PHY, "In %s: multiple number of SL PDUs not supported yet...\n", __FUNCTION__);
} }
@@ -86,21 +85,20 @@ void nr_fill_sl_rx_indication(sl_nr_rx_indication_t *rx_ind,
ssb_pdu->rsrp_dbm = sl_phy_params->psbch.rsrp_dBm_per_RE; ssb_pdu->rsrp_dbm = sl_phy_params->psbch.rsrp_dBm_per_RE;
ssb_pdu->rx_slss_id = rx_slss_id; ssb_pdu->rx_slss_id = rx_slss_id;
ssb_pdu->decode_status = true; ssb_pdu->decode_status = true;
LOG_D(PHY, "SL-IND: SSB to MAC. rsrp:%d, slssid:%d, payload:%x\n", LOG_D(PHY,
ssb_pdu->rsrp_dbm,ssb_pdu->rx_slss_id, "SL-IND: SSB to MAC. rsrp:%d, slssid:%d, payload:%x\n",
ssb_pdu->rsrp_dbm,
ssb_pdu->rx_slss_id,
*((uint32_t *)(ssb_pdu->psbch_payload))); *((uint32_t *)(ssb_pdu->psbch_payload)));
} } else
else
ssb_pdu->decode_status = false; ssb_pdu->decode_status = false;
} } break;
break;
default: default:
break; break;
} }
rx_ind->rx_indication_body[n_pdus - 1].pdu_type = pdu_type; rx_ind->rx_indication_body[n_pdus - 1].pdu_type = pdu_type;
rx_ind->number_pdus = n_pdus; rx_ind->number_pdus = n_pdus;
} }
static int nr_ue_psbch_procedures(PHY_VARS_NR_UE *ue, static int nr_ue_psbch_procedures(PHY_VARS_NR_UE *ue,
@@ -111,7 +109,6 @@ static int nr_ue_psbch_procedures(PHY_VARS_NR_UE *ue,
nr_phy_data_t *phy_data, nr_phy_data_t *phy_data,
c16_t rxdataF[][fp->samples_per_slot_wCP]) c16_t rxdataF[][fp->samples_per_slot_wCP])
{ {
int ret = 0; int ret = 0;
DevAssert(ue); DevAssert(ue);
@@ -123,8 +120,11 @@ static int nr_ue_psbch_procedures(PHY_VARS_NR_UE *ue,
// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PSBCH_PROCEDURES, VCD_FUNCTION_IN); // VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PSBCH_PROCEDURES, VCD_FUNCTION_IN);
LOG_D(PHY,"[UE %d] Frame %d Slot %d, Trying PSBCH (SLSS ID %d)\n", LOG_D(PHY,
ue->Mod_id,frame_rx,nr_slot_rx, "[UE %d] Frame %d Slot %d, Trying PSBCH (SLSS ID %d)\n",
ue->Mod_id,
frame_rx,
nr_slot_rx,
sl_phy_params->sl_config.sl_sync_source.rx_slss_id); sl_phy_params->sl_config.sl_sync_source.rx_slss_id);
uint8_t decoded_pdu[4] = {0}; uint8_t decoded_pdu[4] = {0};
@@ -161,13 +161,8 @@ static int nr_ue_psbch_procedures(PHY_VARS_NR_UE *ue,
return ret; return ret;
} }
int psbch_pscch_processing(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, nr_phy_data_t *phy_data)
int psbch_pscch_processing(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
nr_phy_data_t *phy_data)
{ {
int frame_rx = proc->frame_rx; int frame_rx = proc->frame_rx;
int nr_slot_rx = proc->nr_slot_rx; int nr_slot_rx = proc->nr_slot_rx;
sl_nr_ue_phy_params_t *sl_phy_params = &ue->SL_UE_PHY_PARAMS; sl_nr_ue_phy_params_t *sl_phy_params = &ue->SL_UE_PHY_PARAMS;
@@ -177,34 +172,25 @@ int psbch_pscch_processing(PHY_VARS_NR_UE *ue,
// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX_SL, VCD_FUNCTION_IN); // VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX_SL, VCD_FUNCTION_IN);
start_meas(&sl_phy_params->phy_proc_sl_rx); start_meas(&sl_phy_params->phy_proc_sl_rx);
LOG_D(PHY," ****** Sidelink RX-Chain for Frame.Slot %d.%d ****** \n", LOG_D(PHY, " ****** Sidelink RX-Chain for Frame.Slot %d.%d ****** \n", frame_rx % 1024, nr_slot_rx);
frame_rx%1024, nr_slot_rx);
const uint32_t rxdataF_sz = fp->samples_per_slot_wCP; const uint32_t rxdataF_sz = fp->samples_per_slot_wCP;
__attribute__((aligned(32))) c16_t rxdataF[fp->nb_antennas_rx][rxdataF_sz]; __attribute__((aligned(32))) c16_t rxdataF[fp->nb_antennas_rx][rxdataF_sz];
if (phy_data->sl_rx_action == SL_NR_CONFIG_TYPE_RX_PSBCH) { if (phy_data->sl_rx_action == SL_NR_CONFIG_TYPE_RX_PSBCH) {
const int estimateSz = fp->symbols_per_slot * fp->ofdm_symbol_size; const int estimateSz = fp->symbols_per_slot * fp->ofdm_symbol_size;
// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PSBCH, VCD_FUNCTION_IN); // VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PSBCH, VCD_FUNCTION_IN);
LOG_D(PHY," ----- PSBCH RX TTI: frame.slot %d.%d ------ \n", LOG_D(PHY, " ----- PSBCH RX TTI: frame.slot %d.%d ------ \n", frame_rx % 1024, nr_slot_rx);
frame_rx%1024, nr_slot_rx);
__attribute__((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz]; __attribute__((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz];
__attribute__((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size]; __attribute__((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size];
// 0 for Normal Cyclic Prefix and 1 for EXT CyclicPrefix // 0 for Normal Cyclic Prefix and 1 for EXT CyclicPrefix
const int numsym = (fp->Ncp) ? SL_NR_NUM_SYMBOLS_SSB_EXT_CP const int numsym = (fp->Ncp) ? SL_NR_NUM_SYMBOLS_SSB_EXT_CP : SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP;
: SL_NR_NUM_SYMBOLS_SSB_NORMAL_CP;
for (int sym = 0; sym < numsym;) { for (int sym = 0; sym < numsym;) {
nr_slot_fep(ue, nr_slot_fep(ue, fp, proc, sym, rxdataF, link_type_ul);
fp,
proc,
sym,
rxdataF,
link_type_ul);
start_meas(&sl_phy_params->channel_estimation_stats); start_meas(&sl_phy_params->channel_estimation_stats);
nr_pbch_channel_estimation(ue, nr_pbch_channel_estimation(ue,
@@ -228,16 +214,14 @@ int psbch_pscch_processing(PHY_VARS_NR_UE *ue,
nr_sl_psbch_rsrp_measurements(sl_phy_params, fp, rxdataF, false); nr_sl_psbch_rsrp_measurements(sl_phy_params, fp, rxdataF, false);
LOG_D(PHY," ------ Decode SL-MIB: frame.slot %d.%d ------ \n", LOG_D(PHY, " ------ Decode SL-MIB: frame.slot %d.%d ------ \n", frame_rx % 1024, nr_slot_rx);
frame_rx%1024, nr_slot_rx);
const int psbchSuccess = nr_ue_psbch_procedures(ue, fp, proc, estimateSz, const int psbchSuccess = nr_ue_psbch_procedures(ue, fp, proc, estimateSz, dl_ch_estimates, phy_data, rxdataF);
dl_ch_estimates, phy_data, rxdataF);
if (ue->no_timing_correction == 0 && psbchSuccess == 0) { if (ue->no_timing_correction == 0 && psbchSuccess == 0) {
LOG_D(PHY, "start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction); LOG_D(PHY, "start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction);
sampleShift = nr_adjust_synch_ue(fp, ue, proc->gNB_id, fp->ofdm_symbol_size, sampleShift =
dl_ch_estimates_time, frame_rx, nr_slot_rx, 16384); nr_adjust_synch_ue(fp, ue, proc->gNB_id, fp->ofdm_symbol_size, dl_ch_estimates_time, frame_rx, nr_slot_rx, 16384);
} }
LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__); LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__);
@@ -247,8 +231,11 @@ int psbch_pscch_processing(PHY_VARS_NR_UE *ue,
if (frame_rx % 64 == 0) { if (frame_rx % 64 == 0) {
LOG_I(NR_PHY, "============================================\n"); LOG_I(NR_PHY, "============================================\n");
LOG_I(NR_PHY,"[UE%d] %d:%d PSBCH Stats: TX %d, RX ok %d, RX not ok %d\n", LOG_I(NR_PHY,
ue->Mod_id, frame_rx, nr_slot_rx, "[UE%d] %d:%d PSBCH Stats: TX %d, RX ok %d, RX not ok %d\n",
ue->Mod_id,
frame_rx,
nr_slot_rx,
sl_phy_params->psbch.num_psbch_tx, sl_phy_params->psbch.num_psbch_tx,
sl_phy_params->psbch.rx_ok, sl_phy_params->psbch.rx_ok,
sl_phy_params->psbch.rx_errors); sl_phy_params->psbch.rx_errors);
@@ -260,11 +247,8 @@ int psbch_pscch_processing(PHY_VARS_NR_UE *ue,
return sampleShift; return sampleShift;
} }
int phy_procedures_nrUE_SL_TX(PHY_VARS_NR_UE *ue, int phy_procedures_nrUE_SL_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, nr_phy_data_tx_t *phy_data)
UE_nr_rxtx_proc_t *proc,
nr_phy_data_tx_t *phy_data)
{ {
int slot_tx = proc->nr_slot_tx; int slot_tx = proc->nr_slot_tx;
int frame_tx = proc->frame_tx; int frame_tx = proc->frame_tx;
int tx_action = 0; int tx_action = 0;
@@ -281,8 +265,7 @@ int phy_procedures_nrUE_SL_TX(PHY_VARS_NR_UE *ue,
for (int i = 0; i < fp->nb_antennas_tx; ++i) for (int i = 0; i < fp->nb_antennas_tx; ++i)
txdataF[i] = &txdataF_buf[i * samplesF_per_slot]; txdataF[i] = &txdataF_buf[i * samplesF_per_slot];
LOG_D(PHY,"****** start Sidelink TX-Chain for AbsSubframe %d.%d ******\n", LOG_D(PHY, "****** start Sidelink TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx);
frame_tx, slot_tx);
start_meas(&sl_phy_params->phy_proc_sl_tx); start_meas(&sl_phy_params->phy_proc_sl_tx);
@@ -294,8 +277,11 @@ int phy_procedures_nrUE_SL_TX(PHY_VARS_NR_UE *ue,
if (frame_tx % 64 == 0) { if (frame_tx % 64 == 0) {
LOG_I(NR_PHY, "============================================\n"); LOG_I(NR_PHY, "============================================\n");
LOG_I(NR_PHY,"[UE%d] %d:%d PSBCH Stats: TX %d, RX ok %d, RX not ok %d\n", LOG_I(NR_PHY,
ue->Mod_id, frame_tx, slot_tx, "[UE%d] %d:%d PSBCH Stats: TX %d, RX ok %d, RX not ok %d\n",
ue->Mod_id,
frame_tx,
slot_tx,
sl_phy_params->psbch.num_psbch_tx, sl_phy_params->psbch.num_psbch_tx,
sl_phy_params->psbch.rx_ok, sl_phy_params->psbch.rx_ok,
sl_phy_params->psbch.rx_errors); sl_phy_params->psbch.rx_errors);
@@ -307,15 +293,10 @@ int phy_procedures_nrUE_SL_TX(PHY_VARS_NR_UE *ue,
if (tx_action) { if (tx_action) {
LOG_D(PHY, "Sending Uplink data \n"); LOG_D(PHY, "Sending Uplink data \n");
nr_ue_pusch_common_procedures(ue, nr_ue_pusch_common_procedures(ue, proc->nr_slot_tx, fp, fp->nb_antennas_tx, txdataF);
proc->nr_slot_tx,
fp,
fp->nb_antennas_tx,
txdataF);
} }
LOG_D(PHY,"****** end Sidelink TX-Chain for AbsSubframe %d.%d ******\n", LOG_D(PHY, "****** end Sidelink TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx);
frame_tx, slot_tx);
// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_SL, VCD_FUNCTION_OUT); // VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_SL, VCD_FUNCTION_OUT);
stop_meas(&sl_phy_params->phy_proc_sl_tx); stop_meas(&sl_phy_params->phy_proc_sl_tx);
+17 -10
View File
@@ -787,16 +787,21 @@ int main(int argc, char **argv)
proc.nr_slot_rx = ssb_slot; proc.nr_slot_rx = ssb_slot;
proc.gNB_id = 0; proc.gNB_id = 0;
for (int i = UE->symbol_offset + 1; i < UE->symbol_offset + 4; i++) { for (int i = UE->symbol_offset + 1; i < UE->symbol_offset + 4; i++) {
nr_slot_fep(UE, nr_slot_fep(UE, frame_parms, &proc, i % frame_parms->symbols_per_slot, rxdataF, link_type_dl);
frame_parms,
nr_pbch_channel_estimation(UE,
&UE->frame_parms,
estimateSz,
dl_ch_estimates,
dl_ch_estimates_time,
&proc, &proc,
i % frame_parms->symbols_per_slot, i % frame_parms->symbols_per_slot,
rxdataF, link_type_dl); i - (UE->symbol_offset + 1),
ssb_index % 8,
nr_pbch_channel_estimation(UE,&UE->frame_parms, estimateSz, dl_ch_estimates, dl_ch_estimates_time, &proc, n_hf,
i%frame_parms->symbols_per_slot,i-(UE->symbol_offset+1), rxdataF,
ssb_index%8,n_hf,rxdataF,false,frame_parms->Nid_cell); false,
frame_parms->Nid_cell);
} }
fapiPbch_t result; fapiPbch_t result;
ret = nr_rx_pbch(UE, &proc, estimateSz, dl_ch_estimates, frame_parms, ssb_index % 8, &result, rxdataF); ret = nr_rx_pbch(UE, &proc, estimateSz, dl_ch_estimates, frame_parms, ssb_index % 8, &result, rxdataF);
@@ -810,14 +815,16 @@ int main(int argc, char **argv)
payload_ret = (result.xtra_byte == gNB_xtra_byte); payload_ret = (result.xtra_byte == gNB_xtra_byte);
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
payload_ret += (result.decoded_output[i] == ((msgDataTx.ssb[ssb_index].ssb_pdu.ssb_pdu_rel15.bchPayload>>(8*i)) & 0xff)); payload_ret +=
(result.decoded_output[i] == ((msgDataTx.ssb[ssb_index].ssb_pdu.ssb_pdu_rel15.bchPayload >> (8 * i)) & 0xff));
} }
// printf("ret %d\n", payload_ret); // printf("ret %d\n", payload_ret);
if (payload_ret != 4) if (payload_ret != 4)
n_errors_payload++; n_errors_payload++;
} }
if (ret!=0) n_errors++; if (ret != 0)
n_errors++;
} }
} //noise trials } //noise trials
printf("SNR %f: trials %d, n_errors_crc = %d, n_errors_payload %d\n", SNR,n_trials,n_errors,n_errors_payload); printf("SNR %f: trials %d, n_errors_crc = %d, n_errors_payload %d\n", SNR,n_trials,n_errors,n_errors_payload);
+78 -81
View File
@@ -26,21 +26,34 @@
#include "PHY/MODULATION/nr_modulation.h" #include "PHY/MODULATION/nr_modulation.h"
#include "NR_SL-SSB-TimeAllocation-r16.h" #include "NR_SL-SSB-TimeAllocation-r16.h"
void e1_bearer_context_setup(const e1ap_bearer_setup_req_t *req) { abort(); } void e1_bearer_context_setup(const e1ap_bearer_setup_req_t *req)
void e1_bearer_context_modif(const e1ap_bearer_setup_req_t *req) { abort(); } {
void e1_bearer_release_cmd(const e1ap_bearer_release_cmd_t *cmd) { abort(); } abort();
void exit_function(const char* file, const char* function, const int line, const char* s, const int assert) { }
void e1_bearer_context_modif(const e1ap_bearer_setup_req_t *req)
{
abort();
}
void e1_bearer_release_cmd(const e1ap_bearer_release_cmd_t *cmd)
{
abort();
}
void exit_function(const char *file, const char *function, const int line, const char *s, const int assert)
{
const char *msg = s == NULL ? "no comment" : s; const char *msg = s == NULL ? "no comment" : s;
printf("Exiting at: %s:%d %s(), %s\n", file, line, function, msg); printf("Exiting at: %s:%d %s(), %s\n", file, line, function, msg);
exit(-1); exit(-1);
} }
int8_t nr_rrc_RA_succeeded(const module_id_t mod_id, const uint8_t gNB_index) { return 1; } int8_t nr_rrc_RA_succeeded(const module_id_t mod_id, const uint8_t gNB_index)
{
return 1;
}
// to solve link errors // to solve link errors
double cpuf; double cpuf;
// void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {} // void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu, void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu, uint8_t *nb_dmrs_re_per_rb, uint16_t *number_dmrs_symbols)
uint8_t *nb_dmrs_re_per_rb, {
uint16_t *number_dmrs_symbols){} }
uint64_t downlink_frequency[1][1]; uint64_t downlink_frequency[1][1];
int32_t uplink_frequency_offset[1][1]; int32_t uplink_frequency_offset[1][1];
THREAD_STRUCT thread_struct; THREAD_STRUCT thread_struct;
@@ -68,11 +81,17 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
} }
nr_bler_struct nr_bler_data[NR_NUM_MCS]; nr_bler_struct nr_bler_data[NR_NUM_MCS];
void get_nrUE_params(void) { return;} void get_nrUE_params(void)
uint8_t check_if_ue_is_sl_syncsource() {return 0;} {
return;
}
uint8_t check_if_ue_is_sl_syncsource()
{
return 0;
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
static void prepare_mib_bits(uint8_t *buf, uint32_t frame_tx, uint32_t slot_tx) { static void prepare_mib_bits(uint8_t *buf, uint32_t frame_tx, uint32_t slot_tx)
{
NR_MasterInformationBlockSidelink_t *sl_mib; NR_MasterInformationBlockSidelink_t *sl_mib;
asn_enc_rval_t enc_rval; asn_enc_rval_t enc_rval;
@@ -94,29 +113,24 @@ static void prepare_mib_bits(uint8_t *buf, uint32_t frame_tx, uint32_t slot_tx)
sl_mib->directFrameNumber_r16.buf[0] = frame_tx >> (8 - sl_mib->directFrameNumber_r16.bits_unused); sl_mib->directFrameNumber_r16.buf[0] = frame_tx >> (8 - sl_mib->directFrameNumber_r16.bits_unused);
sl_mib->directFrameNumber_r16.buf[1] = frame_tx << sl_mib->directFrameNumber_r16.bits_unused; sl_mib->directFrameNumber_r16.buf[1] = frame_tx << sl_mib->directFrameNumber_r16.bits_unused;
enc_rval = uper_encode_to_buffer(&asn_DEF_NR_MasterInformationBlockSidelink, enc_rval = uper_encode_to_buffer(&asn_DEF_NR_MasterInformationBlockSidelink, NULL, (void *)sl_mib, buffer, 100);
NULL,
(void *)sl_mib,
buffer,
100);
AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", AssertFatal(enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded);
enc_rval.failed_type->name, enc_rval.encoded);
asn_DEF_NR_MasterInformationBlockSidelink.op->free_struct(&asn_DEF_NR_MasterInformationBlockSidelink, sl_mib, ASFM_FREE_EVERYTHING);
asn_DEF_NR_MasterInformationBlockSidelink.op->free_struct(&asn_DEF_NR_MasterInformationBlockSidelink,
sl_mib,
ASFM_FREE_EVERYTHING);
} }
static int test_rx_mib(uint8_t *decoded_output, uint16_t frame, uint16_t slot) { static int test_rx_mib(uint8_t *decoded_output, uint16_t frame, uint16_t slot)
{
uint32_t sl_mib = *(uint32_t *)decoded_output; uint32_t sl_mib = *(uint32_t *)decoded_output;
uint32_t fn = 0, sl = 0; uint32_t fn = 0, sl = 0;
fn = (((sl_mib & 0x0700) >> 1) | ((sl_mib & 0xFE0000) >> 17)); fn = (((sl_mib & 0x0700) >> 1) | ((sl_mib & 0xFE0000) >> 17));
sl = (((sl_mib & 0x010000) >> 10) | ((sl_mib & 0xFC000000) >> 26)); sl = (((sl_mib & 0x010000) >> 10) | ((sl_mib & 0xFC000000) >> 26));
printf("decoded output:%x, TX %d:%d, timing decoded from sl-MIB %d:%d\n", printf("decoded output:%x, TX %d:%d, timing decoded from sl-MIB %d:%d\n", *(uint32_t *)decoded_output, frame, slot, fn, sl);
*(uint32_t *)decoded_output, frame, slot, fn, sl);
if (frame == fn && slot == sl) if (frame == fn && slot == sl)
return 0; return 0;
@@ -126,8 +140,8 @@ static int test_rx_mib(uint8_t *decoded_output, uint16_t frame, uint16_t slot) {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
static void configure_NR_UE(PHY_VARS_NR_UE *UE, int mu, int N_RB) { static void configure_NR_UE(PHY_VARS_NR_UE *UE, int mu, int N_RB)
{
fapi_nr_config_request_t config; fapi_nr_config_request_t config;
NR_DL_FRAME_PARMS *fp = &UE->frame_parms; NR_DL_FRAME_PARMS *fp = &UE->frame_parms;
@@ -139,8 +153,10 @@ static void configure_NR_UE(PHY_VARS_NR_UE *UE, int mu, int N_RB) {
config.carrier_config.uplink_frequency = 0; config.carrier_config.uplink_frequency = 0;
int band; int band;
if (mu == 1) band = 78; if (mu == 1)
if (mu == 0) band = 34; band = 78;
if (mu == 0)
band = 34;
nr_init_frame_parms_ue(fp, &config, band); nr_init_frame_parms_ue(fp, &config, band);
fp->ofdm_offset_divisor = 8; fp->ofdm_offset_divisor = 8;
nr_dump_frame_parms(fp); nr_dump_frame_parms(fp);
@@ -151,8 +167,8 @@ static void configure_NR_UE(PHY_VARS_NR_UE *UE, int mu, int N_RB) {
} }
} }
static void sl_init_frame_parameters(PHY_VARS_NR_UE *UE) { static void sl_init_frame_parameters(PHY_VARS_NR_UE *UE)
{
NR_DL_FRAME_PARMS *nr_fp = &UE->frame_parms; NR_DL_FRAME_PARMS *nr_fp = &UE->frame_parms;
NR_DL_FRAME_PARMS *sl_fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params; NR_DL_FRAME_PARMS *sl_fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params;
@@ -171,11 +187,10 @@ static void sl_init_frame_parameters(PHY_VARS_NR_UE *UE) {
LOG_I(PHY, "Dumping Sidelink Frame Parameters\n"); LOG_I(PHY, "Dumping Sidelink Frame Parameters\n");
nr_dump_frame_parms(sl_fp); nr_dump_frame_parms(sl_fp);
#endif #endif
} }
static void configure_SL_UE(PHY_VARS_NR_UE *UE, int mu, int N_RB, int ssb_offset, int slss_id) { static void configure_SL_UE(PHY_VARS_NR_UE *UE, int mu, int N_RB, int ssb_offset, int slss_id)
{
sl_nr_phy_config_request_t *config = &UE->SL_UE_PHY_PARAMS.sl_config; sl_nr_phy_config_request_t *config = &UE->SL_UE_PHY_PARAMS.sl_config;
NR_DL_FRAME_PARMS *fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params; NR_DL_FRAME_PARMS *fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params;
@@ -193,15 +208,15 @@ static void configure_SL_UE(PHY_VARS_NR_UE *UE, int mu, int N_RB, int ssb_offset
nr_dump_frame_parms(fp); nr_dump_frame_parms(fp);
} }
static int freq_domain_loopback(PHY_VARS_NR_UE *UE_tx, PHY_VARS_NR_UE *UE_rx, static int freq_domain_loopback(PHY_VARS_NR_UE *UE_tx, PHY_VARS_NR_UE *UE_rx, int frame, int slot, nr_phy_data_tx_t *phy_data)
int frame, int slot, {
nr_phy_data_tx_t *phy_data) {
sl_nr_ue_phy_params_t *sl_ue1 = &UE_tx->SL_UE_PHY_PARAMS; sl_nr_ue_phy_params_t *sl_ue1 = &UE_tx->SL_UE_PHY_PARAMS;
sl_nr_ue_phy_params_t *sl_ue2 = &UE_rx->SL_UE_PHY_PARAMS; sl_nr_ue_phy_params_t *sl_ue2 = &UE_rx->SL_UE_PHY_PARAMS;
printf("\nPSBCH SIM -F: %d:%d slss id TX UE:%d, RX UE:%d\n", printf("\nPSBCH SIM -F: %d:%d slss id TX UE:%d, RX UE:%d\n",
frame, slot,phy_data->psbch_vars.tx_slss_id, frame,
slot,
phy_data->psbch_vars.tx_slss_id,
sl_ue2->sl_config.sl_sync_source.rx_slss_id); sl_ue2->sl_config.sl_sync_source.rx_slss_id);
NR_DL_FRAME_PARMS *fp = &sl_ue1->sl_frame_params; NR_DL_FRAME_PARMS *fp = &sl_ue1->sl_frame_params;
@@ -252,7 +267,6 @@ static int freq_domain_loopback(PHY_VARS_NR_UE *UE_tx, PHY_VARS_NR_UE *UE_rx,
rxdataF, rxdataF,
sl_ue2->sl_config.sl_sync_source.rx_slss_id); sl_ue2->sl_config.sl_sync_source.rx_slss_id);
int error_payload = 0; int error_payload = 0;
error_payload = test_rx_mib(decoded_output, frame, slot); error_payload = test_rx_mib(decoded_output, frame, slot);
@@ -264,14 +278,13 @@ static int freq_domain_loopback(PHY_VARS_NR_UE *UE_tx, PHY_VARS_NR_UE *UE_rx,
return -1; return -1;
} }
PHY_VARS_NR_UE *UE_TX; // for tx PHY_VARS_NR_UE *UE_TX; // for tx
PHY_VARS_NR_UE *UE_RX; // for rx PHY_VARS_NR_UE *UE_RX; // for rx
double cpuf; double cpuf;
configmodule_interface_t *uniqCfg = NULL; configmodule_interface_t *uniqCfg = NULL;
int main(int argc, char **argv) { int main(int argc, char **argv)
{
char c; char c;
int test_freqdomain_loopback = 0, test_slss_search = 0; int test_freqdomain_loopback = 0, test_slss_search = 0;
int frame = 5, slot = 10, frame_tx = 0, slot_tx = 0; int frame = 5, slot = 10, frame_tx = 0, slot_tx = 0;
@@ -301,10 +314,8 @@ int main(int argc, char **argv) {
randominit(0); randominit(0);
while ((c = getopt(argc, argv, "c:hn:o:s:FIL:N:R:S:T:")) != -1) { while ((c = getopt(argc, argv, "c:hn:o:s:FIL:N:R:S:T:")) != -1) {
printf("SIDELINK PSBCH SIM: handling optarg %c\n", c); printf("SIDELINK PSBCH SIM: handling optarg %c\n", c);
switch (c) { switch (c) {
case 'c': case 'c':
cfo = atof(optarg); cfo = atof(optarg);
printf("Setting CFO to %f Hz\n", cfo); printf("Setting CFO to %f Hz\n", cfo);
@@ -413,7 +424,6 @@ int main(int argc, char **argv) {
printf("-S Ending SNR, runs from SNR0 to SNR1\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n");
printf("-T: Frame,Slot to be sent in sl-MIB eg -T 4 2\n"); printf("-T: Frame,Slot to be sent in sl-MIB eg -T 4 2\n");
return 1; return 1;
} }
} }
@@ -432,28 +442,25 @@ int main(int argc, char **argv) {
if (N_RB_DL == 217) { if (N_RB_DL == 217) {
fs = 122.88e6; fs = 122.88e6;
bw = 80e6; bw = 80e6;
} } else if (N_RB_DL == 245) {
else if (N_RB_DL == 245) {
fs = 122.88e6; fs = 122.88e6;
bw = 90e6; bw = 90e6;
} } else if (N_RB_DL == 273) {
else if (N_RB_DL == 273) {
fs = 122.88e6; fs = 122.88e6;
bw = 100e6; bw = 100e6;
} } else if (N_RB_DL == 106) {
else if (N_RB_DL == 106) {
fs = 61.44e6; fs = 61.44e6;
bw = 40e6; bw = 40e6;
} } else
else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL); AssertFatal(1 == 0, "Unsupported numerology for mu %d, N_RB %d\n", mu, N_RB_DL);
break; break;
case 3: case 3:
scs = 120000; scs = 120000;
if (N_RB_DL == 66) { if (N_RB_DL == 66) {
fs = 122.88e6; fs = 122.88e6;
bw = 100e6; bw = 100e6;
} } else
else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL); AssertFatal(1 == 0, "Unsupported numerology for mu %d, N_RB %d\n", mu, N_RB_DL);
break; break;
} }
@@ -473,19 +480,7 @@ int main(int argc, char **argv) {
channel_desc_t *UE2UE; channel_desc_t *UE2UE;
int n_tx = 1, n_rx = 1; int n_tx = 1, n_rx = 1;
UE2UE = new_channel_desc_scm(n_tx, UE2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, fs, 0, bw, 300e-9, 0.0, CORR_LEVEL_LOW, 0, 0, 0, 0);
n_rx,
channel_model,
fs,
0,
bw,
300e-9,
0.0,
CORR_LEVEL_LOW,
0,
0,
0,
0);
if (UE2UE == NULL) { if (UE2UE == NULL) {
printf("Problem generating channel model. Exiting.\n"); printf("Problem generating channel model. Exiting.\n");
@@ -547,18 +542,16 @@ int main(int argc, char **argv) {
errors += freq_domain_loopback(UE_TX, UE_RX, frame_tx, slot_tx, &phy_data_tx); errors += freq_domain_loopback(UE_TX, UE_RX, frame_tx, slot_tx, &phy_data_tx);
} }
printf("\nSidelink TX UE - Frame.Slot %d.%d SLSS id:%d\n", printf("\nSidelink TX UE - Frame.Slot %d.%d SLSS id:%d\n", frame, slot, phy_data_tx.psbch_vars.tx_slss_id);
frame, slot,phy_data_tx.psbch_vars.tx_slss_id);
printf("Sidelink RX UE - Frame.Slot %d.%d SLSS id:%d\n", printf("Sidelink RX UE - Frame.Slot %d.%d SLSS id:%d\n",
proc.frame_rx, proc.nr_slot_rx, proc.frame_rx,
proc.nr_slot_rx,
sl_uerx->sl_config.sl_sync_source.rx_slss_id); sl_uerx->sl_config.sl_sync_source.rx_slss_id);
phy_procedures_nrUE_SL_TX(UE_TX, &proc, &phy_data_tx); phy_procedures_nrUE_SL_TX(UE_TX, &proc, &phy_data_tx);
for (SNR = snr0; SNR >= snr1; SNR -= 1) { for (SNR = snr0; SNR >= snr1; SNR -= 1) {
for (int trial = 0; trial < n_trials; trial++) { for (int trial = 0; trial < n_trials; trial++) {
for (int i = 0; i < frame_length_complex_samples; i++) { for (int i = 0; i < frame_length_complex_samples; i++) {
for (int aa = 0; aa < frame_parms->nb_antennas_tx; aa++) { for (int aa = 0; aa < frame_parms->nb_antennas_tx; aa++) {
struct complex16 *txdata_ptr = (struct complex16 *)&UE_TX->common_vars.txData[aa][i]; struct complex16 *txdata_ptr = (struct complex16 *)&UE_TX->common_vars.txData[aa][i];
@@ -609,19 +602,25 @@ int main(int argc, char **argv) {
UE_RX->SL_UE_PHY_PARAMS.sl_config.sl_sync_source.rx_slss_id = 0xFFFF; UE_RX->SL_UE_PHY_PARAMS.sl_config.sl_sync_source.rx_slss_id = 0xFFFF;
ret = sl_nr_slss_search(UE_RX, &proc, 1); ret = sl_nr_slss_search(UE_RX, &proc, 1);
printf("Sidelink SLSS search returns status:%d, rx_offset:%d\n", ret.cell_detected, ret.rx_offset); printf("Sidelink SLSS search returns status:%d, rx_offset:%d\n", ret.cell_detected, ret.rx_offset);
if (!ret.cell_detected) sl_uerx->psbch.rx_errors = 1; if (!ret.cell_detected)
sl_uerx->psbch.rx_errors = 1;
else { else {
AssertFatal(UE_RX->SL_UE_PHY_PARAMS.sync_params.N_sl_id == slss_id, AssertFatal(UE_RX->SL_UE_PHY_PARAMS.sync_params.N_sl_id == slss_id,
"DETECTED INCORRECT SLSS ID in SEARCH.CHECK id:%d\n", UE_RX->SL_UE_PHY_PARAMS.sync_params.N_sl_id); "DETECTED INCORRECT SLSS ID in SEARCH.CHECK id:%d\n",
UE_RX->SL_UE_PHY_PARAMS.sync_params.N_sl_id);
sl_uerx->psbch.rx_ok = 1; sl_uerx->psbch.rx_ok = 1;
} }
} else psbch_pscch_processing(UE_RX,&proc,&phy_data_rx); } else
psbch_pscch_processing(UE_RX, &proc, &phy_data_rx);
} // noise trials } // noise trials
printf("Runs:%d SNR %f: SLSS Search:%d crc ERRORs = %d, OK = %d\n", printf("Runs:%d SNR %f: SLSS Search:%d crc ERRORs = %d, OK = %d\n",
n_trials, SNR, !UE_RX->is_synchronized, n_trials,
sl_uerx->psbch.rx_errors, sl_uerx->psbch.rx_ok); SNR,
!UE_RX->is_synchronized,
sl_uerx->psbch.rx_errors,
sl_uerx->psbch.rx_ok);
errors += sl_uerx->psbch.rx_errors; errors += sl_uerx->psbch.rx_errors;
sl_uerx->psbch.rx_errors = 0; sl_uerx->psbch.rx_errors = 0;
sl_uerx->psbch.rx_ok = 0; sl_uerx->psbch.rx_ok = 0;
@@ -654,5 +653,3 @@ int main(int argc, char **argv) {
return errors; return errors;
} }