Commit 1a04ebaa authored by francescomani's avatar francescomani

cleanup of gNB PHY procedures and removal of global PBCH structure

parent d04a83ea
...@@ -47,12 +47,13 @@ const uint8_t nr_pbch_payload_interleaving_pattern[32] = {16, 23, 18, 17, 8, 30, ...@@ -47,12 +47,13 @@ const uint8_t nr_pbch_payload_interleaving_pattern[32] = {16, 23, 18, 17, 8, 30,
9, 11, 12, 13, 14, 15, 19, 20, 21, 22, 25, 26, 27, 28, 29, 31 9, 11, 12, 13, 14, 15, 19, 20, 21, 22, 25, 26, 27, 28, 29, 31
}; };
int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, void nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
c16_t *txdataF, c16_t *txdataF,
int16_t amp, int16_t amp,
uint8_t ssb_start_symbol, uint8_t ssb_start_symbol,
nfapi_nr_config_request_scf_t *config, nfapi_nr_config_request_scf_t *config,
NR_DL_FRAME_PARMS *frame_parms) { NR_DL_FRAME_PARMS *frame_parms)
{
int k,l; int k,l;
//int16_t a; //int16_t a;
int16_t mod_dmrs[NR_PBCH_DMRS_LENGTH<<1]; int16_t mod_dmrs[NR_PBCH_DMRS_LENGTH<<1];
...@@ -139,186 +140,220 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, ...@@ -139,186 +140,220 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
#ifdef DEBUG_PBCH_DMRS #ifdef DEBUG_PBCH_DMRS
write_output("txdataF_pbch_dmrs.m", "txdataF_pbch_dmrs", txdataF[0], frame_parms->samples_per_frame_wCP>>1, 1, 1); write_output("txdataF_pbch_dmrs.m", "txdataF_pbch_dmrs", txdataF[0], frame_parms->samples_per_frame_wCP>>1, 1, 1);
#endif #endif
return 0;
} }
static void nr_pbch_scrambling(NR_gNB_PBCH *pbch, typedef struct {
uint32_t Nid, int len;
uint8_t nushift, int goldIdx;
uint16_t M, int offset;
uint16_t length, } NR_PBCH_scramb_info_t;
uint8_t encoded,
uint32_t unscrambling_mask)
{
uint32_t *pbch_e = pbch->pbch_e;
// x1 is set in lte_gold_generic
const int len = (nushift * M + 31) / 32 + (length + 31) / 32; static NR_PBCH_scramb_info_t get_scrambling_info(uint8_t nushift,
uint32_t *s = gold_cache(Nid, len); uint16_t M,
uint16_t length)
{
NR_PBCH_scramb_info_t info;
info.len = (nushift * M + 31) / 32 + (length + 31) / 32;
// The Gold sequence is shifted by nushift* M, so we skip (nushift*M /32) double words // The Gold sequence is shifted by nushift* M, so we skip (nushift*M /32) double words
int goldIdx = (nushift * M + 31) / 32 - 1; info.goldIdx = (nushift * M + 31) / 32 - 1;
// Scrambling is now done with offset (nushift*M)%32 // Scrambling is now done with offset (nushift*M)%32
uint8_t offset = (nushift * M) & 0x1f; info.offset = (nushift * M) & 0x1f;
return info;
}
static void nr_pbch_encoded_scrambling(uint32_t *pbch_e,
uint32_t Nid,
uint8_t nushift,
uint16_t M,
uint16_t length)
{
NR_PBCH_scramb_info_t info = get_scrambling_info(nushift, M, length);
uint32_t *s = gold_cache(Nid, info.len);
int goldIdx = info.goldIdx;
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("Scrambling params: nushift %d M %d length %d encoded %d offset %d\n", nushift, M, length, encoded, offset); printf("Scrambling params: nushift %d M %d length %d offset %d\n", nushift, M, length, info.offset);
#endif #endif
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("s: %04x\t", s); printf("s: %04x\t", s);
#endif #endif
int k = 0;
if (!encoded) { for (int i = 0; i < length; ++i) {
/// 1st Scrambling if (((i + info.offset) & 0x1f) == 0)
for (int i = 0; i < length; ++i) { goldIdx++;
if ((unscrambling_mask>>i)&1) pbch_e[i >> 5] ^= (((s[goldIdx] >> ((i + info.offset) & 0x1f)) & 1) << (i & 0x1f));
pbch->pbch_a_prime ^= ((pbch->pbch_a_interleaved>>i)&1)<<i; }
else { }
if (((k + offset) & 0x1f) == 0)
goldIdx++; static uint32_t nr_pbch_scrambling(uint32_t pbch_a_interleaved,
pbch->pbch_a_prime ^= (((pbch->pbch_a_interleaved >> i) & 1) ^ ((s[goldIdx] >> ((k + offset) & 0x1f)) & 1)) << i; uint32_t Nid,
k++; /// k increase only when payload bit is not special bit uint8_t nushift,
} uint16_t M,
} uint16_t length,
} else { uint32_t unscrambling_mask)
/// 2nd Scrambling {
for (int i = 0; i < length; ++i) { uint32_t pbch_a_prime = 0;
if (((i + offset) & 0x1f) == 0) int k = 0;
NR_PBCH_scramb_info_t info = get_scrambling_info(nushift, M, length);
uint32_t *s = gold_cache(Nid, info.len);
#ifdef DEBUG_PBCH_ENCODING
printf("Scrambling params: nushift %d M %d length %d offset %d\n", nushift, M, length, info.offset);
#endif
#ifdef DEBUG_PBCH_ENCODING
printf("s: %04x\t", s);
#endif
int goldIdx = info.goldIdx;
for (int i = 0; i < length; ++i) {
if ((unscrambling_mask >> i) & 1)
pbch_a_prime ^= ((pbch_a_interleaved >> i) & 1) << i;
else {
if (((k + info.offset) & 0x1f) == 0)
goldIdx++; goldIdx++;
pbch_e[i >> 5] ^= (((s[goldIdx] >> ((i + offset) & 0x1f)) & 1) << (i & 0x1f)); pbch_a_prime ^= (((pbch_a_interleaved >> i) & 1) ^ ((s[goldIdx] >> ((k + info.offset) & 0x1f)) & 1)) << i;
k++; /// k increase only when payload bit is not special bit
} }
} }
return pbch_a_prime;
} }
void nr_init_pbch_interleaver(uint8_t *interleaver) { void nr_init_pbch_interleaver(uint8_t *interleaver)
uint8_t j_sfn=0, j_hrf=10, j_ssb=11, j_other=14; {
uint8_t j_sfn = 0, j_hrf = 10, j_ssb = 11, j_other = 14;
memset((void *)interleaver,0, NR_POLAR_PBCH_PAYLOAD_BITS); memset((void *)interleaver,0, NR_POLAR_PBCH_PAYLOAD_BITS);
for (uint8_t i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++) for (int i = 0; i < NR_POLAR_PBCH_PAYLOAD_BITS; i++)
if (!i) // choice bit:1 if (!i) // choice bit:1
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_other++); *(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_other++);
else if (i<7) //Sfn bits:6 else if (i < 7) //Sfn bits:6
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_sfn++); *(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_sfn++);
else if (i<24) // other:17 else if (i < 24) // other:17
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_other++); *(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_other++);
else if (i<28) // Sfn:4 else if (i < 28) // Sfn:4
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_sfn++); *(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_sfn++);
else if (i==28) // Hrf bit:1 else if (i == 28) // Hrf bit:1
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_hrf); *(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_hrf);
else // Ssb bits:3 else // Ssb bits:3
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_ssb++); *(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_ssb++);
} }
int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, uint32_t nr_pbch_extra_byte_generation(int sfn, int n_hf, int ssb_index, int ssb_sc_offset, int Lmax)
uint8_t *interleaver, {
c16_t *txdataF, uint32_t extra_byte = 0;
int16_t amp, // Extra byte generation
uint8_t ssb_start_symbol, for (int i = 0; i < 4; i++)
uint8_t n_hf, extra_byte |= ((sfn >> (3 - i)) & 1) << i; // resp. 4th, 3rd, 2nd ans 1st lsb of sfn
int sfn,
nfapi_nr_config_request_scf_t *config, extra_byte |= n_hf << 4; // half frame index bit
NR_DL_FRAME_PARMS *frame_parms) {
int k,l,m; if (Lmax == 64)
//int16_t a; for (int i = 0; i < 3; i++)
int16_t mod_pbch_e[NR_POLAR_PBCH_E]; extra_byte |= (uint32_t)((ssb_index >> (5 - i)) & 1) << (5 + i); // resp. 6th, 5th and 4th bits of ssb_index
uint8_t idx=0; else
uint16_t M; extra_byte |= ((ssb_sc_offset >> 4) & 1) << 5; //MSB of k_SSB (bit index 4)
uint8_t nushift; return extra_byte;
uint32_t unscrambling_mask; }
void nr_generate_pbch(PHY_VARS_gNB *gNB,
const nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
c16_t *txdataF,
uint8_t ssb_start_symbol,
uint8_t n_hf,
int sfn,
nfapi_nr_config_request_scf_t *config,
NR_DL_FRAME_PARMS *frame_parms)
{
LOG_D(PHY, "PBCH generation started\n"); LOG_D(PHY, "PBCH generation started\n");
///Payload generation ///Payload generation
NR_gNB_PBCH m_pbch;
NR_gNB_PBCH *pbch = &m_pbch;
memset((void *)pbch, 0, sizeof(NR_gNB_PBCH));
pbch->pbch_a=0;
uint8_t ssb_index = ssb_pdu->ssb_pdu_rel15.SsbBlockIndex; uint8_t ssb_index = ssb_pdu->ssb_pdu_rel15.SsbBlockIndex;
uint8_t *pbch_pdu = (uint8_t*)&ssb_pdu->ssb_pdu_rel15.bchPayload; const uint8_t *pbch_pdu = (const uint8_t*)&ssb_pdu->ssb_pdu_rel15.bchPayload;
uint8_t Lmax = frame_parms->Lmax; uint8_t Lmax = frame_parms->Lmax;
for (int i=0; i<NR_PBCH_PDU_BITS; i++) uint32_t pbch_a = 0;
pbch->pbch_a |= ((pbch_pdu[i>>3]>>(7-(i&7)))&1)<<i; for (int i = 0; i < NR_PBCH_PDU_BITS; i++)
pbch_a |= ((pbch_pdu[i >> 3] >> (7 - (i & 7))) & 1) << i;
// NSA to signal no coreset0 // NSA to signal no coreset0
const int ssb_sc_offset = get_softmodem_params()->sa ? config->ssb_table.ssb_subcarrier_offset.value : 31; const int ssb_sc_offset = get_softmodem_params()->sa ? config->ssb_table.ssb_subcarrier_offset.value : 31;
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
for (int i=0; i<3; i++) for (int i = 0; i < 3; i++)
printf("pbch_pdu[%d]: 0x%02x\n", i, pbch_pdu[i]); printf("pbch_pdu[%d]: 0x%02x\n", i, pbch_pdu[i]);
printf("PBCH payload = 0x%08x\n", pbch_a);
printf("PBCH payload = 0x%08x\n",pbch->pbch_a);
#endif #endif
// Extra byte generation uint32_t extra_byte = nr_pbch_extra_byte_generation(sfn, n_hf, ssb_index, ssb_sc_offset, Lmax);
for (int i=0; i<4; i++) pbch_a |= extra_byte << 24;
pbch->pbch_a |= ((sfn>>(3-i))&1)<<(24+i); // resp. 4th, 3rd, 2nd ans 1st lsb of sfn LOG_D(PHY,"After extra byte: pbch_a = 0x%08x\n", pbch_a);
pbch->pbch_a |= n_hf<<28; // half frame index bit
if (Lmax == 64)
for (int i = 0; i < 3; i++)
pbch->pbch_a |= (uint32_t)((ssb_index >> (5 - i)) & 1) << (29 + i); // resp. 6th, 5th and 4th bits of ssb_index
else
pbch->pbch_a |= ((ssb_sc_offset >> 4) & 1) << 29; //MSB of k_SSB (bit index 4)
LOG_D(PHY,"After extra byte: pbch_a = 0x%08x\n",pbch->pbch_a);
// Payload interleaving // Payload interleaving
uint32_t pbch_a_interleaved = 0;
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++) { uint8_t *interleaver = gNB->nr_pbch_interleaver;
pbch->pbch_a_interleaved |= ((pbch->pbch_a>>i)&1)<<(*(interleaver+i)); for (int i = 0; i < NR_POLAR_PBCH_PAYLOAD_BITS; i++) {
pbch_a_interleaved |= ((pbch_a >> i) & 1) << (*(interleaver + i));
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("i %d out 0x%08x ilv %d (in>>i)&1) %d\n", i, pbch->pbch_a_interleaved, *(interleaver+i), (pbch->pbch_a>>i)&1); printf("i %d out 0x%08x ilv %d (in>>i)&1) %d\n", i, pbch_a_interleaved, *(interleaver+i), (pbch_a >> i) & 1);
#endif #endif
} }
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("Interleaving:\n"); printf("Interleaving:\n");
printf("pbch_a_interleaved: 0x%08x\n", pbch->pbch_a_interleaved); printf("pbch_a_interleaved: 0x%08x\n", pbch_a_interleaved);
#endif #endif
// Scrambling // Scrambling
unscrambling_mask = (Lmax ==64)? 0x100006D:0x1000041; uint32_t unscrambling_mask = (Lmax == 64) ? 0x100006D : 0x1000041;
M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3); uint16_t M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3);
nushift = (((sfn>>2)&1)<<1) ^ ((sfn>>1)&1); uint8_t nushift = (((sfn >> 2) & 1) << 1) ^ ((sfn >> 1) & 1);
pbch->pbch_a_prime = 0; uint32_t pbch_a_prime = nr_pbch_scrambling(pbch_a_interleaved,
nr_pbch_scrambling(pbch, (uint32_t)config->cell_config.phy_cell_id.value, nushift, M, NR_POLAR_PBCH_PAYLOAD_BITS, 0, unscrambling_mask); (uint32_t)config->cell_config.phy_cell_id.value,
nushift,
M,
NR_POLAR_PBCH_PAYLOAD_BITS,
unscrambling_mask);
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("Payload scrambling: nushift %d M %d sfn3 %d sfn2 %d\n", nushift, M, (sfn>>2)&1, (sfn>>1)&1); printf("Payload scrambling: nushift %d M %d sfn3 %d sfn2 %d\n", nushift, M, (sfn >> 2) & 1, (sfn >> 1) & 1);
printf("pbch_a_prime: 0x%08x\n", pbch->pbch_a_prime); printf("pbch_a_prime: 0x%08x\n", pbch_a_prime);
#endif #endif
// Encoder reversal // Encoder reversal
uint64_t a_reversed = reverse_bits((uint64_t)pbch->pbch_a_prime, NR_POLAR_PBCH_PAYLOAD_BITS); uint64_t a_reversed = reverse_bits((uint64_t)pbch_a_prime, NR_POLAR_PBCH_PAYLOAD_BITS);
uint32_t pbch_e[NR_POLAR_PBCH_E_DWORD];
/// CRC, coding and rate matching /// CRC, coding and rate matching
polar_encoder_fast (&a_reversed, (void*)pbch->pbch_e, 0, 0, polar_encoder_fast(&a_reversed,
NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL); pbch_e,
0,
0,
NR_POLAR_PBCH_MESSAGE_TYPE,
NR_POLAR_PBCH_PAYLOAD_BITS,
NR_POLAR_PBCH_AGGREGATION_LEVEL);
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("Channel coding:\n"); printf("Channel coding:\n");
for (int i = 0; i < NR_POLAR_PBCH_E_DWORD; i++)
for (int i=0; i<NR_POLAR_PBCH_E_DWORD; i++) printf("pbch_e[%d]: 0x%08x\t", i, pbch_e[i]);
printf("pbch_e[%d]: 0x%08x\t", i, pbch->pbch_e[i]);
printf("\n"); printf("\n");
#endif #endif
/// Scrambling /// Scrambling
M = NR_POLAR_PBCH_E; M = NR_POLAR_PBCH_E;
nushift = (Lmax==4)? ssb_index&3 : ssb_index&7; nushift = (Lmax == 4) ? ssb_index & 3 : ssb_index & 7;
nr_pbch_scrambling(pbch, (uint32_t)config->cell_config.phy_cell_id.value, nushift, M, NR_POLAR_PBCH_E, 1, 0); nr_pbch_encoded_scrambling(pbch_e,
(uint32_t)config->cell_config.phy_cell_id.value,
nushift,
M,
NR_POLAR_PBCH_E);
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("Scrambling:\n"); printf("Scrambling:\n");
for (int i = 0; i < NR_POLAR_PBCH_E_DWORD; i++)
for (int i=0; i<NR_POLAR_PBCH_E_DWORD; i++) printf("pbch_e[%d]: 0x%08x\t", i, pbch_e[i]);
printf("pbch_e[%d]: 0x%08x\t", i, pbch->pbch_e[i]);
printf("\n"); printf("\n");
#endif #endif
int16_t mod_pbch_e[NR_POLAR_PBCH_E];
/// QPSK modulation /// QPSK modulation
for (int i=0; i<NR_POLAR_PBCH_E>>1; i++) { for (int i=0; i<NR_POLAR_PBCH_E>>1; i++) {
idx = ((pbch->pbch_e[(i<<1)>>5]>>((i<<1)&0x1f))&3); int idx = ((pbch_e[(i << 1) >> 5] >> ((i << 1) & 0x1f)) & 3);
mod_pbch_e[i<<1] = nr_qpsk_mod_table[idx<<1]; mod_pbch_e[i<<1] = nr_qpsk_mod_table[idx << 1];
mod_pbch_e[(i<<1)+1] = nr_qpsk_mod_table[(idx<<1)+1]; mod_pbch_e[(i<<1)+1] = nr_qpsk_mod_table[(idx << 1) + 1];
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("i %d idx %d mod_pbch %d %d\n", i, idx, mod_pbch_e[2*i], mod_pbch_e[2*i+1]); printf("i %d idx %d mod_pbch %d %d\n", i, idx, mod_pbch_e[2 * i], mod_pbch_e[2 * i + 1]);
#endif #endif
} }
...@@ -326,9 +361,10 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, ...@@ -326,9 +361,10 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
nushift = config->cell_config.phy_cell_id.value &3; nushift = config->cell_config.phy_cell_id.value &3;
// PBCH modulated symbols are mapped within the SSB block on symbols 1, 2, 3 excluding the subcarriers used for the PBCH DMRS // PBCH modulated symbols are mapped within the SSB block on symbols 1, 2, 3 excluding the subcarriers used for the PBCH DMRS
///symbol 1 [0:239] -- 180 mod symbols ///symbol 1 [0:239] -- 180 mod symbols
k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier; int k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier;
l = ssb_start_symbol + 1; int l = ssb_start_symbol + 1;
m = 0; int m = 0;
int16_t amp = gNB->TX_AMP;
for (int ssb_sc_idx = 0; ssb_sc_idx < 240; ssb_sc_idx++) { for (int ssb_sc_idx = 0; ssb_sc_idx < 240; ssb_sc_idx++) {
if ((ssb_sc_idx&3) == nushift) { //skip DMRS if ((ssb_sc_idx&3) == nushift) { //skip DMRS
...@@ -419,7 +455,4 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, ...@@ -419,7 +455,4 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
if (k >= frame_parms->ofdm_symbol_size) if (k >= frame_parms->ofdm_symbol_size)
k-=frame_parms->ofdm_symbol_size; k-=frame_parms->ofdm_symbol_size;
} }
return 0;
} }
...@@ -72,33 +72,30 @@ int nr_generate_sss(c16_t *txdataF, ...@@ -72,33 +72,30 @@ int nr_generate_sss(c16_t *txdataF,
NR_DL_FRAME_PARMS *frame_parms); NR_DL_FRAME_PARMS *frame_parms);
/*! /*!
\fn int nr_generate_pbch_dmrs \fn void nr_generate_pbch_dmrs
\brief Generation of the DMRS for the PBCH \brief Generation of the DMRS for the PBCH
@param @param
@returns 0 on success
*/ */
int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, void nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
c16_t *txdataF, c16_t *txdataF,
int16_t amp, int16_t amp,
uint8_t ssb_start_symbol, uint8_t ssb_start_symbol,
nfapi_nr_config_request_scf_t *config, nfapi_nr_config_request_scf_t *config,
NR_DL_FRAME_PARMS *frame_parms); NR_DL_FRAME_PARMS *frame_parms);
/*! /*!
\fn int nr_generate_pbch \fn void nr_generate_pbch
\brief Generation of the PBCH \brief Generation of the PBCH
@param @param
@returns 0 on success
*/ */
int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, void nr_generate_pbch(PHY_VARS_gNB *gNB,
uint8_t *interleaver, const nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
c16_t *txdataF, c16_t *txdataF,
int16_t amp, uint8_t ssb_start_symbol,
uint8_t ssb_start_symbol, uint8_t n_hf,
uint8_t n_hf, int sfn,
int sfn, nfapi_nr_config_request_scf_t *config,
nfapi_nr_config_request_scf_t *config, NR_DL_FRAME_PARMS *frame_parms);
NR_DL_FRAME_PARMS *frame_parms);
/*! /*!
\fn int nr_generate_pbch \fn int nr_generate_pbch
...@@ -107,6 +104,7 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, ...@@ -107,6 +104,7 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
@returns the bit index of the output @returns the bit index of the output
*/ */
void nr_init_pbch_interleaver(uint8_t *interleaver); void nr_init_pbch_interleaver(uint8_t *interleaver);
uint32_t nr_pbch_extra_byte_generation(int sfn, int n_hf, int ssb_index, int ssb_sc_offset, int Lmax);
NR_gNB_DLSCH_t new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint16_t N_RB); NR_gNB_DLSCH_t new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint16_t N_RB);
......
...@@ -53,13 +53,6 @@ typedef struct { ...@@ -53,13 +53,6 @@ typedef struct {
int lut[MAX_PUCCH0_NID][160][14]; int lut[MAX_PUCCH0_NID][160][14];
} NR_gNB_PUCCH0_LUT_t; } NR_gNB_PUCCH0_LUT_t;
typedef struct {
uint32_t pbch_a;
uint32_t pbch_a_interleaved;
uint32_t pbch_a_prime;
uint32_t pbch_e[NR_POLAR_PBCH_E_DWORD];
} NR_gNB_PBCH;
typedef struct { typedef struct {
/// Nfapi DLSCH PDU /// Nfapi DLSCH PDU
nfapi_nr_dl_tti_pdsch_pdu pdsch_pdu; nfapi_nr_dl_tti_pdsch_pdu pdsch_pdu;
...@@ -469,7 +462,6 @@ typedef struct PHY_VARS_gNB_s { ...@@ -469,7 +462,6 @@ typedef struct PHY_VARS_gNB_s {
int max_nb_pdsch; int max_nb_pdsch;
int max_nb_pusch; int max_nb_pusch;
NR_gNB_PBCH pbch;
NR_gNB_COMMON common_vars; NR_gNB_COMMON common_vars;
NR_gNB_PRACH prach_vars; NR_gNB_PRACH prach_vars;
NR_gNB_PRS prs_vars; NR_gNB_PRS prs_vars;
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
extern uint8_t nfapi_mode; extern uint8_t nfapi_mode;
void nr_common_signal_procedures(PHY_VARS_gNB *gNB,int frame,int slot, nfapi_nr_dl_tti_ssb_pdu ssb_pdu) void nr_common_signal_procedures(PHY_VARS_gNB *gNB, int frame,int slot, nfapi_nr_dl_tti_ssb_pdu ssb_pdu)
{ {
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
...@@ -135,10 +135,9 @@ void nr_common_signal_procedures(PHY_VARS_gNB *gNB,int frame,int slot, nfapi_nr_ ...@@ -135,10 +135,9 @@ void nr_common_signal_procedures(PHY_VARS_gNB *gNB,int frame,int slot, nfapi_nr_
gNB->common_vars.beam_id[0][slot*fp->symbols_per_slot+j] = cfg->ssb_table.ssb_beam_id_list[ssb_index].beam_id.value; gNB->common_vars.beam_id[0][slot*fp->symbols_per_slot+j] = cfg->ssb_table.ssb_beam_id_list[ssb_index].beam_id.value;
} }
nr_generate_pbch(&ssb_pdu, nr_generate_pbch(gNB,
gNB->nr_pbch_interleaver, &ssb_pdu,
&txdataF[0][txdataF_offset], &txdataF[0][txdataF_offset],
gNB->TX_AMP,
ssb_start_symbol, ssb_start_symbol,
n_hf, n_hf,
frame, frame,
......
...@@ -204,6 +204,7 @@ int main(int argc, char **argv) ...@@ -204,6 +204,7 @@ int main(int argc, char **argv)
channel_desc_t *gNB2UE; channel_desc_t *gNB2UE;
get_softmodem_params()->sa = 1; get_softmodem_params()->sa = 1;
get_softmodem_params()->usim_test = 1;
//uint8_t extended_prefix_flag=0; //uint8_t extended_prefix_flag=0;
//int8_t interf1=-21,interf2=-21; //int8_t interf1=-21,interf2=-21;
...@@ -230,7 +231,7 @@ int main(int argc, char **argv) ...@@ -230,7 +231,7 @@ int main(int argc, char **argv)
int frame_length_complex_samples_no_prefix; int frame_length_complex_samples_no_prefix;
NR_DL_FRAME_PARMS *frame_parms; NR_DL_FRAME_PARMS *frame_parms;
int ret, payload_ret=0; int ret;
int run_initial_sync=0; int run_initial_sync=0;
int loglvl=OAILOG_WARNING; int loglvl=OAILOG_WARNING;
...@@ -835,17 +836,15 @@ int main(int argc, char **argv) ...@@ -835,17 +836,15 @@ int main(int argc, char **argv)
rxdataF); rxdataF);
if (ret == 0) { if (ret == 0) {
// UE->rx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically uint32_t xtra_byte = nr_pbch_extra_byte_generation(frame,
// UE->rx_ind.rx_indication_body->mib_pdu.ssb_length; //Lmax, not yet detected automatically n_hf,
uint8_t gNB_xtra_byte = 0; ssb_index,
for (int i = 0; i < 8; i++) gNB->gNB_config.ssb_table.ssb_subcarrier_offset.value,
gNB_xtra_byte |= ((gNB->pbch.pbch_a >> (31 - i)) & 1) << (7 - i); frame_parms->Lmax);
int payload_ret = (result.xtra_byte == xtra_byte);
payload_ret = (result.xtra_byte == gNB_xtra_byte); nfapi_nr_dl_tti_ssb_pdu_rel15_t *pdu = &msgDataTx.ssb[ssb_index].ssb_pdu.ssb_pdu_rel15;
for (i = 0; i < 3; i++) { for (int i = 0; i < 3; i++)
payload_ret += payload_ret += (result.decoded_output[i] == ((pdu->bchPayload >> (8 * i)) & 0xff));
(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++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment