cleanup of gNB PHY procedures and removal of global PBCH structure
This commit is contained in:
+167
-134
@@ -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
|
||||
};
|
||||
|
||||
int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
|
||||
c16_t *txdataF,
|
||||
int16_t amp,
|
||||
uint8_t ssb_start_symbol,
|
||||
nfapi_nr_config_request_scf_t *config,
|
||||
NR_DL_FRAME_PARMS *frame_parms) {
|
||||
void nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
|
||||
c16_t *txdataF,
|
||||
int16_t amp,
|
||||
uint8_t ssb_start_symbol,
|
||||
nfapi_nr_config_request_scf_t *config,
|
||||
NR_DL_FRAME_PARMS *frame_parms)
|
||||
{
|
||||
int k,l;
|
||||
//int16_t a;
|
||||
int16_t mod_dmrs[NR_PBCH_DMRS_LENGTH<<1];
|
||||
@@ -139,186 +140,220 @@ int nr_generate_pbch_dmrs(uint32_t *gold_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);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void nr_pbch_scrambling(NR_gNB_PBCH *pbch,
|
||||
uint32_t Nid,
|
||||
uint8_t nushift,
|
||||
uint16_t M,
|
||||
uint16_t length,
|
||||
uint8_t encoded,
|
||||
uint32_t unscrambling_mask)
|
||||
{
|
||||
uint32_t *pbch_e = pbch->pbch_e;
|
||||
// x1 is set in lte_gold_generic
|
||||
typedef struct {
|
||||
int len;
|
||||
int goldIdx;
|
||||
int offset;
|
||||
} NR_PBCH_scramb_info_t;
|
||||
|
||||
const int len = (nushift * M + 31) / 32 + (length + 31) / 32;
|
||||
uint32_t *s = gold_cache(Nid, len);
|
||||
static NR_PBCH_scramb_info_t get_scrambling_info(uint8_t nushift,
|
||||
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
|
||||
int goldIdx = (nushift * M + 31) / 32 - 1;
|
||||
info.goldIdx = (nushift * M + 31) / 32 - 1;
|
||||
// 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
|
||||
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
|
||||
#ifdef DEBUG_PBCH_ENCODING
|
||||
printf("s: %04x\t", s);
|
||||
#endif
|
||||
int k = 0;
|
||||
|
||||
if (!encoded) {
|
||||
/// 1st Scrambling
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if ((unscrambling_mask>>i)&1)
|
||||
pbch->pbch_a_prime ^= ((pbch->pbch_a_interleaved>>i)&1)<<i;
|
||||
else {
|
||||
if (((k + offset) & 0x1f) == 0)
|
||||
goldIdx++;
|
||||
pbch->pbch_a_prime ^= (((pbch->pbch_a_interleaved >> i) & 1) ^ ((s[goldIdx] >> ((k + offset) & 0x1f)) & 1)) << i;
|
||||
k++; /// k increase only when payload bit is not special bit
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/// 2nd Scrambling
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (((i + offset) & 0x1f) == 0)
|
||||
goldIdx++;
|
||||
pbch_e[i >> 5] ^= (((s[goldIdx] >> ((i + offset) & 0x1f)) & 1) << (i & 0x1f));
|
||||
}
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (((i + info.offset) & 0x1f) == 0)
|
||||
goldIdx++;
|
||||
pbch_e[i >> 5] ^= (((s[goldIdx] >> ((i + info.offset) & 0x1f)) & 1) << (i & 0x1f));
|
||||
}
|
||||
}
|
||||
|
||||
void nr_init_pbch_interleaver(uint8_t *interleaver) {
|
||||
uint8_t j_sfn=0, j_hrf=10, j_ssb=11, j_other=14;
|
||||
memset((void *)interleaver,0, NR_POLAR_PBCH_PAYLOAD_BITS);
|
||||
|
||||
for (uint8_t i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++)
|
||||
if (!i) // choice bit:1
|
||||
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_other++);
|
||||
else if (i<7) //Sfn bits:6
|
||||
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_sfn++);
|
||||
else if (i<24) // other:17
|
||||
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_other++);
|
||||
else if (i<28) // Sfn:4
|
||||
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_sfn++);
|
||||
else if (i==28) // Hrf bit:1
|
||||
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_hrf);
|
||||
else // Ssb bits:3
|
||||
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_ssb++);
|
||||
static uint32_t nr_pbch_scrambling(uint32_t pbch_a_interleaved,
|
||||
uint32_t Nid,
|
||||
uint8_t nushift,
|
||||
uint16_t M,
|
||||
uint16_t length,
|
||||
uint32_t unscrambling_mask)
|
||||
{
|
||||
uint32_t pbch_a_prime = 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++;
|
||||
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;
|
||||
}
|
||||
|
||||
int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
|
||||
uint8_t *interleaver,
|
||||
c16_t *txdataF,
|
||||
int16_t amp,
|
||||
uint8_t ssb_start_symbol,
|
||||
uint8_t n_hf,
|
||||
int sfn,
|
||||
nfapi_nr_config_request_scf_t *config,
|
||||
NR_DL_FRAME_PARMS *frame_parms) {
|
||||
int k,l,m;
|
||||
//int16_t a;
|
||||
int16_t mod_pbch_e[NR_POLAR_PBCH_E];
|
||||
uint8_t idx=0;
|
||||
uint16_t M;
|
||||
uint8_t nushift;
|
||||
uint32_t unscrambling_mask;
|
||||
void nr_init_pbch_interleaver(uint8_t *interleaver)
|
||||
{
|
||||
uint8_t j_sfn = 0, j_hrf = 10, j_ssb = 11, j_other = 14;
|
||||
memset((void *)interleaver,0, NR_POLAR_PBCH_PAYLOAD_BITS);
|
||||
|
||||
for (int i = 0; i < NR_POLAR_PBCH_PAYLOAD_BITS; i++)
|
||||
if (!i) // choice bit:1
|
||||
*(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_other++);
|
||||
else if (i < 7) //Sfn bits:6
|
||||
*(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_sfn++);
|
||||
else if (i < 24) // other:17
|
||||
*(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_other++);
|
||||
else if (i < 28) // Sfn:4
|
||||
*(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_sfn++);
|
||||
else if (i == 28) // Hrf bit:1
|
||||
*(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_hrf);
|
||||
else // Ssb bits:3
|
||||
*(interleaver + i) = *(nr_pbch_payload_interleaving_pattern + j_ssb++);
|
||||
}
|
||||
|
||||
uint32_t nr_pbch_extra_byte_generation(int sfn, int n_hf, int ssb_index, int ssb_sc_offset, int Lmax)
|
||||
{
|
||||
uint32_t extra_byte = 0;
|
||||
// Extra byte generation
|
||||
for (int i = 0; i < 4; i++)
|
||||
extra_byte |= ((sfn >> (3 - i)) & 1) << i; // resp. 4th, 3rd, 2nd ans 1st lsb of sfn
|
||||
|
||||
extra_byte |= n_hf << 4; // half frame index bit
|
||||
|
||||
if (Lmax == 64)
|
||||
for (int i = 0; i < 3; i++)
|
||||
extra_byte |= (uint32_t)((ssb_index >> (5 - i)) & 1) << (5 + i); // resp. 6th, 5th and 4th bits of ssb_index
|
||||
else
|
||||
extra_byte |= ((ssb_sc_offset >> 4) & 1) << 5; //MSB of k_SSB (bit index 4)
|
||||
return extra_byte;
|
||||
}
|
||||
|
||||
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");
|
||||
///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 *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;
|
||||
for (int i=0; i<NR_PBCH_PDU_BITS; i++)
|
||||
pbch->pbch_a |= ((pbch_pdu[i>>3]>>(7-(i&7)))&1)<<i;
|
||||
uint32_t pbch_a = 0;
|
||||
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
|
||||
const int ssb_sc_offset = get_softmodem_params()->sa ? config->ssb_table.ssb_subcarrier_offset.value : 31;
|
||||
|
||||
#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 payload = 0x%08x\n",pbch->pbch_a);
|
||||
printf("PBCH payload = 0x%08x\n", pbch_a);
|
||||
#endif
|
||||
|
||||
// Extra byte generation
|
||||
for (int i=0; i<4; i++)
|
||||
pbch->pbch_a |= ((sfn>>(3-i))&1)<<(24+i); // resp. 4th, 3rd, 2nd ans 1st lsb of sfn
|
||||
|
||||
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);
|
||||
uint32_t extra_byte = nr_pbch_extra_byte_generation(sfn, n_hf, ssb_index, ssb_sc_offset, Lmax);
|
||||
pbch_a |= extra_byte << 24;
|
||||
LOG_D(PHY,"After extra byte: pbch_a = 0x%08x\n", pbch_a);
|
||||
|
||||
// Payload interleaving
|
||||
|
||||
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++) {
|
||||
pbch->pbch_a_interleaved |= ((pbch->pbch_a>>i)&1)<<(*(interleaver+i));
|
||||
uint32_t pbch_a_interleaved = 0;
|
||||
uint8_t *interleaver = gNB->nr_pbch_interleaver;
|
||||
for (int i = 0; i < NR_POLAR_PBCH_PAYLOAD_BITS; i++) {
|
||||
pbch_a_interleaved |= ((pbch_a >> i) & 1) << (*(interleaver + i));
|
||||
#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
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PBCH_ENCODING
|
||||
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
|
||||
// Scrambling
|
||||
unscrambling_mask = (Lmax ==64)? 0x100006D:0x1000041;
|
||||
M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3);
|
||||
nushift = (((sfn>>2)&1)<<1) ^ ((sfn>>1)&1);
|
||||
pbch->pbch_a_prime = 0;
|
||||
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 unscrambling_mask = (Lmax == 64) ? 0x100006D : 0x1000041;
|
||||
uint16_t M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3);
|
||||
uint8_t nushift = (((sfn >> 2) & 1) << 1) ^ ((sfn >> 1) & 1);
|
||||
uint32_t pbch_a_prime = nr_pbch_scrambling(pbch_a_interleaved,
|
||||
(uint32_t)config->cell_config.phy_cell_id.value,
|
||||
nushift,
|
||||
M,
|
||||
NR_POLAR_PBCH_PAYLOAD_BITS,
|
||||
unscrambling_mask);
|
||||
#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("pbch_a_prime: 0x%08x\n", pbch->pbch_a_prime);
|
||||
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_a_prime);
|
||||
#endif
|
||||
|
||||
// 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
|
||||
polar_encoder_fast (&a_reversed, (void*)pbch->pbch_e, 0, 0,
|
||||
NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
|
||||
polar_encoder_fast(&a_reversed,
|
||||
pbch_e,
|
||||
0,
|
||||
0,
|
||||
NR_POLAR_PBCH_MESSAGE_TYPE,
|
||||
NR_POLAR_PBCH_PAYLOAD_BITS,
|
||||
NR_POLAR_PBCH_AGGREGATION_LEVEL);
|
||||
|
||||
#ifdef DEBUG_PBCH_ENCODING
|
||||
printf("Channel coding:\n");
|
||||
|
||||
for (int i=0; i<NR_POLAR_PBCH_E_DWORD; i++)
|
||||
printf("pbch_e[%d]: 0x%08x\t", i, pbch->pbch_e[i]);
|
||||
|
||||
for (int i = 0; i < NR_POLAR_PBCH_E_DWORD; i++)
|
||||
printf("pbch_e[%d]: 0x%08x\t", i, pbch_e[i]);
|
||||
printf("\n");
|
||||
#endif
|
||||
/// Scrambling
|
||||
M = NR_POLAR_PBCH_E;
|
||||
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);
|
||||
M = NR_POLAR_PBCH_E;
|
||||
nushift = (Lmax == 4) ? ssb_index & 3 : ssb_index & 7;
|
||||
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
|
||||
printf("Scrambling:\n");
|
||||
|
||||
for (int i=0; i<NR_POLAR_PBCH_E_DWORD; i++)
|
||||
printf("pbch_e[%d]: 0x%08x\t", i, pbch->pbch_e[i]);
|
||||
for (int i = 0; i < NR_POLAR_PBCH_E_DWORD; i++)
|
||||
printf("pbch_e[%d]: 0x%08x\t", i, pbch_e[i]);
|
||||
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
int16_t mod_pbch_e[NR_POLAR_PBCH_E];
|
||||
/// QPSK modulation
|
||||
for (int i=0; i<NR_POLAR_PBCH_E>>1; i++) {
|
||||
idx = ((pbch->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)+1] = nr_qpsk_mod_table[(idx<<1)+1];
|
||||
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)+1] = nr_qpsk_mod_table[(idx << 1) + 1];
|
||||
#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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
// 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
|
||||
k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier;
|
||||
l = ssb_start_symbol + 1;
|
||||
m = 0;
|
||||
int k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier;
|
||||
int l = ssb_start_symbol + 1;
|
||||
int m = 0;
|
||||
int16_t amp = gNB->TX_AMP;
|
||||
|
||||
for (int ssb_sc_idx = 0; ssb_sc_idx < 240; ssb_sc_idx++) {
|
||||
if ((ssb_sc_idx&3) == nushift) { //skip DMRS
|
||||
@@ -419,7 +455,4 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
|
||||
if (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,
|
||||
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
|
||||
@param
|
||||
@returns 0 on success
|
||||
*/
|
||||
int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
|
||||
c16_t *txdataF,
|
||||
int16_t amp,
|
||||
uint8_t ssb_start_symbol,
|
||||
nfapi_nr_config_request_scf_t *config,
|
||||
NR_DL_FRAME_PARMS *frame_parms);
|
||||
void nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
|
||||
c16_t *txdataF,
|
||||
int16_t amp,
|
||||
uint8_t ssb_start_symbol,
|
||||
nfapi_nr_config_request_scf_t *config,
|
||||
NR_DL_FRAME_PARMS *frame_parms);
|
||||
|
||||
/*!
|
||||
\fn int nr_generate_pbch
|
||||
\fn void nr_generate_pbch
|
||||
\brief Generation of the PBCH
|
||||
@param
|
||||
@returns 0 on success
|
||||
*/
|
||||
int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
|
||||
uint8_t *interleaver,
|
||||
c16_t *txdataF,
|
||||
int16_t amp,
|
||||
uint8_t ssb_start_symbol,
|
||||
uint8_t n_hf,
|
||||
int sfn,
|
||||
nfapi_nr_config_request_scf_t *config,
|
||||
NR_DL_FRAME_PARMS *frame_parms);
|
||||
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);
|
||||
|
||||
/*!
|
||||
\fn int nr_generate_pbch
|
||||
@@ -107,6 +104,7 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
|
||||
@returns the bit index of the output
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
@@ -53,13 +53,6 @@ typedef struct {
|
||||
int lut[MAX_PUCCH0_NID][160][14];
|
||||
} 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 {
|
||||
/// Nfapi DLSCH PDU
|
||||
nfapi_nr_dl_tti_pdsch_pdu pdsch_pdu;
|
||||
@@ -469,7 +462,6 @@ typedef struct PHY_VARS_gNB_s {
|
||||
int max_nb_pdsch;
|
||||
int max_nb_pusch;
|
||||
|
||||
NR_gNB_PBCH pbch;
|
||||
NR_gNB_COMMON common_vars;
|
||||
NR_gNB_PRACH prach_vars;
|
||||
NR_gNB_PRS prs_vars;
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
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;
|
||||
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_
|
||||
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,
|
||||
gNB->nr_pbch_interleaver,
|
||||
nr_generate_pbch(gNB,
|
||||
&ssb_pdu,
|
||||
&txdataF[0][txdataF_offset],
|
||||
gNB->TX_AMP,
|
||||
ssb_start_symbol,
|
||||
n_hf,
|
||||
frame,
|
||||
|
||||
@@ -204,6 +204,7 @@ int main(int argc, char **argv)
|
||||
|
||||
channel_desc_t *gNB2UE;
|
||||
get_softmodem_params()->sa = 1;
|
||||
get_softmodem_params()->usim_test = 1;
|
||||
|
||||
//uint8_t extended_prefix_flag=0;
|
||||
//int8_t interf1=-21,interf2=-21;
|
||||
@@ -230,7 +231,7 @@ int main(int argc, char **argv)
|
||||
int frame_length_complex_samples_no_prefix;
|
||||
NR_DL_FRAME_PARMS *frame_parms;
|
||||
|
||||
int ret, payload_ret=0;
|
||||
int ret;
|
||||
int run_initial_sync=0;
|
||||
|
||||
int loglvl=OAILOG_WARNING;
|
||||
@@ -835,17 +836,15 @@ int main(int argc, char **argv)
|
||||
rxdataF);
|
||||
|
||||
if (ret == 0) {
|
||||
// UE->rx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically
|
||||
// UE->rx_ind.rx_indication_body->mib_pdu.ssb_length; //Lmax, not yet detected automatically
|
||||
uint8_t gNB_xtra_byte = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
gNB_xtra_byte |= ((gNB->pbch.pbch_a >> (31 - i)) & 1) << (7 - i);
|
||||
|
||||
payload_ret = (result.xtra_byte == gNB_xtra_byte);
|
||||
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));
|
||||
}
|
||||
uint32_t xtra_byte = nr_pbch_extra_byte_generation(frame,
|
||||
n_hf,
|
||||
ssb_index,
|
||||
gNB->gNB_config.ssb_table.ssb_subcarrier_offset.value,
|
||||
frame_parms->Lmax);
|
||||
int payload_ret = (result.xtra_byte == xtra_byte);
|
||||
nfapi_nr_dl_tti_ssb_pdu_rel15_t *pdu = &msgDataTx.ssb[ssb_index].ssb_pdu.ssb_pdu_rel15;
|
||||
for (int i = 0; i < 3; i++)
|
||||
payload_ret += (result.decoded_output[i] == ((pdu->bchPayload >> (8 * i)) & 0xff));
|
||||
// printf("ret %d\n", payload_ret);
|
||||
if (payload_ret != 4)
|
||||
n_errors_payload++;
|
||||
|
||||
Reference in New Issue
Block a user