Commit 0316431e authored by Laurent THOMAS's avatar Laurent THOMAS Committed by Robert Schmidt

Use gold cache for PBCH encoding&decoding

parent 9d81708b
......@@ -143,8 +143,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB)
gNB->max_nb_pdsch = MAX_MOBILES_PER_GNB;
init_delay_table(fp->ofdm_symbol_size, MAX_DELAY_COMP, NR_MAX_OFDM_SYMBOL_SIZE, fp->delay_table);
// PBCH DMRS gold sequences generation
nr_init_pbch_dmrs(gNB);
//PDCCH DMRS init
gNB->nr_gold_pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **));
uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs;
......
......@@ -21,38 +21,6 @@
#include "nr_refsig.h"
void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB)
{
unsigned int x1 = 0, x2 = 0;
uint16_t Nid, i_ssb, i_ssb2;
unsigned char Lmax, l, n_hf, N_hf;
nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
uint8_t reset;
Nid = cfg->cell_config.phy_cell_id.value;
Lmax = fp->Lmax;
N_hf = (Lmax == 4)? 2:1;
for (n_hf = 0; n_hf < N_hf; n_hf++) {
for (l = 0; l < Lmax ; l++) {
i_ssb = l & (Lmax-1);
i_ssb2 = i_ssb + (n_hf<<2);
reset = 1;
x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3);
for (uint8_t n=0; n<NR_PBCH_DMRS_LENGTH_DWORD; n++) {
gNB->nr_gold_pbch_dmrs[n_hf][l][n] = lte_gold_generic(&x1, &x2, reset);
reset = 0;
}
}
}
}
void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid)
{
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
......
......@@ -22,34 +22,6 @@
#include "refsig_defs_ue.h"
#include "openair1/PHY/LTE_TRANSPORT/transport_proto.h" // for lte_gold_generic()
void nr_gold_pbch(uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD], int Nid, int Lmax)
{
unsigned int n = 0, x1 = 0, x2 = 0;
unsigned int i_ssb, i_ssb2;
unsigned char l, n_hf, N_hf;
uint8_t reset;
N_hf = (Lmax == 4)? 2:1;
for (n_hf = 0; n_hf < N_hf; n_hf++) {
for (l = 0; l < Lmax ; l++) {
i_ssb = l & (Lmax-1);
i_ssb2 = i_ssb + (n_hf<<2);
reset = 1;
x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3);
for (n=0; n<NR_PBCH_DMRS_LENGTH_DWORD; n++) {
nr_gold_pbch[n_hf][l][n] = lte_gold_generic(&x1, &x2, reset);
reset = 0;
}
}
}
}
void nr_gold_pdcch(PHY_VARS_NR_UE* ue,
unsigned short nid)
{
......
......@@ -29,11 +29,6 @@
#include "PHY/LTE_REFSIG/lte_refsig.h"
#include "PHY/sse_intrin.h"
/*!\brief This function generates the NR Gold sequence (38-211, Sec 5.2.1) for the PBCH DMRS.
@param PHY_VARS_gNB* gNB structure provides configuration, frame parameters and the pointers to the 32 bits sequence storage tables
*/
void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB);
/*
This function generates NR Gold Sequence(ts 138.211) for the PRS.
@param PHY_VARS_gNB* gNB structure provides configuration, frame parameters and the pointers to the 32 bits sequence storage tables
......
......@@ -25,5 +25,6 @@
#define __NR_REFSIG_COMMON_H__
uint32_t *gold_cache(uint32_t key, int length);
uint32_t *nr_gold_pbch(int Lmax, int Nid, int n_hf, int ssb);
#endif
......@@ -164,3 +164,11 @@ uint32_t *gold_cache(uint32_t key, int length)
LOG_D(PHY, "created a gold sequence, start %d; len %d\n", key, length);
return firstFree + roundedHeaderSz;
}
uint32_t *nr_gold_pbch(int Lmax, int Nid, int n_hf, int l)
{
int i_ssb = l & (Lmax - 1);
int i_ssb2 = i_ssb + (n_hf << 2);
uint32_t x2 = (1 << 11) * (i_ssb2 + 1) * ((Nid >> 2) + 1) + (1 << 6) * (i_ssb2 + 1) + (Nid & 3);
return gold_cache(x2, NR_PBCH_DMRS_LENGTH_DWORD);
}
......@@ -51,8 +51,6 @@ int nr_pdsch_dmrs_rx(const PHY_VARS_NR_UE *ue,
unsigned short nb_pdsch_rb,
uint8_t config_type);
void nr_gold_pbch(uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD], int Nid, int Lmax);
void nr_gold_pdcch(PHY_VARS_NR_UE* ue,
unsigned short n_idDMRS);
......
......@@ -33,9 +33,9 @@
#include "PHY/defs_gNB.h"
#include "PHY/NR_TRANSPORT/nr_transport_proto.h"
#include "PHY/LTE_REFSIG/lte_refsig.h"
#include "PHY/sse_intrin.h"
#include "executables/softmodem-common.h"
#include "openair1/PHY/NR_REFSIG/nr_refsig_common.h"
//#define DEBUG_PBCH
//#define DEBUG_PBCH_ENCODING
......@@ -143,27 +143,22 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
}
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) {
uint8_t reset, offset;
uint32_t x1 = 0, x2 = 0, s = 0;
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;
reset = 1;
// x1 is set in lte_gold_generic
x2 = Nid;
const int len = (nushift * M + 31) / 32 + (length + 31) / 32;
uint32_t *s = gold_cache(Nid, len);
// The Gold sequence is shifted by nushift* M, so we skip (nushift*M /32) double words
for (int i=0; i<(uint16_t)ceil(((float)nushift*M)/32); i++) {
s = lte_gold_generic(&x1, &x2, reset);
reset = 0;
}
int goldIdx = (nushift * M + 31) / 32 - 1;
// Scrambling is now done with offset (nushift*M)%32
offset = (nushift*M)&0x1f;
uint8_t offset = (nushift * M) & 0x1f;
#ifdef DEBUG_PBCH_ENCODING
printf("Scrambling params: nushift %d M %d length %d encoded %d offset %d\n", nushift, M, length, encoded, offset);
#endif
......@@ -178,29 +173,22 @@ static void nr_pbch_scrambling(NR_gNB_PBCH *pbch,
if ((unscrambling_mask>>i)&1)
pbch->pbch_a_prime ^= ((pbch->pbch_a_interleaved>>i)&1)<<i;
else {
if (((k+offset)&0x1f)==0) {
s = lte_gold_generic(&x1, &x2, reset);
reset = 0;
}
pbch->pbch_a_prime ^= (((pbch->pbch_a_interleaved>>i)&1) ^ ((s>>((k+offset)&0x1f))&1))<<i;
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) {
s = lte_gold_generic(&x1, &x2, reset);
reset = 0;
}
pbch_e[i>>5] ^= (((s>>((i+offset)&0x1f))&1)<<(i&0x1f));
if (((i + offset) & 0x1f) == 0)
goldIdx++;
pbch_e[i >> 5] ^= (((s[goldIdx] >> ((i + 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);
......
......@@ -644,7 +644,6 @@ c32_t nr_pbch_dmrs_correlation(const NR_DL_FRAME_PARMS *fp,
int nr_pbch_channel_estimation(const NR_DL_FRAME_PARMS *fp,
const sl_nr_ue_phy_params_t *sl_phy_params,
const uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD],
int estimateSz,
struct complex16 dl_ch_estimates[][estimateSz],
struct complex16 dl_ch_estimates_time[][fp->ofdm_symbol_size],
......@@ -679,7 +678,7 @@ int nr_pbch_channel_estimation(const NR_DL_FRAME_PARMS *fp,
AssertFatal(dmrss >= 0 && dmrss < 3, "symbol %d is illegal for PBCH DM-RS \n", dmrss);
gold_seq = nr_gold_pbch[n_hf][ssb_index];
gold_seq = nr_gold_pbch(fp->Lmax, Nid, n_hf, ssb_index);
lastsymbol = 2;
num_rbs = 20;
}
......
......@@ -68,7 +68,6 @@ c32_t nr_pbch_dmrs_correlation(const NR_DL_FRAME_PARMS *fp,
int nr_pbch_channel_estimation(const NR_DL_FRAME_PARMS *fp,
const sl_nr_ue_phy_params_t *sl_phy_params,
const uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD],
int estimateSz,
struct complex16 dl_ch_estimates[][estimateSz],
struct complex16 dl_ch_estimates_time[][fp->ofdm_symbol_size],
......
......@@ -71,7 +71,6 @@ static bool nr_pbch_detection(const UE_nr_rxtx_proc_t *proc,
int *ssb_index,
int *symbol_offset,
fapiPbch_t *result,
const uint32_t nr_gold_pbch_ref[2][64][NR_PBCH_DMRS_LENGTH_DWORD],
const c16_t rxdataF[][frame_parms->samples_per_slot_wCP])
{
const int N_L = (frame_parms->Lmax == 4) ? 4 : 8;
......@@ -90,7 +89,7 @@ static bool nr_pbch_detection(const UE_nr_rxtx_proc_t *proc,
i - pbch_initial_symbol,
Nid_cell,
ssb_start_subcarrier,
nr_gold_pbch_ref[hf][l],
nr_gold_pbch(frame_parms->Lmax, Nid_cell, hf, l),
rxdataF);
csum(cumul, cumul, meas);
}
......@@ -110,7 +109,6 @@ static bool nr_pbch_detection(const UE_nr_rxtx_proc_t *proc,
for(int i=pbch_initial_symbol; i<pbch_initial_symbol+3;i++)
nr_pbch_channel_estimation(frame_parms,
NULL,
nr_gold_pbch_ref,
estimateSz,
dl_ch_estimates,
dl_ch_estimates_time,
......@@ -277,9 +275,7 @@ void nr_scan_ssb(void *arg)
#endif
ssbInfo->freqOffset = freq_offset_pss + freq_offset_sss;
uint32_t nr_gold_pbch_ref[2][64][NR_PBCH_DMRS_LENGTH_DWORD];
if (ssbInfo->syncRes.cell_detected) { // we got sss channel
nr_gold_pbch(nr_gold_pbch_ref, ssbInfo->nidCell, fp->Lmax);
ssbInfo->syncRes.cell_detected = nr_pbch_detection(ssbInfo->proc,
ssbInfo->fp,
ssbInfo->nidCell,
......@@ -289,7 +285,6 @@ void nr_scan_ssb(void *arg)
&ssbInfo->ssbIndex,
&ssbInfo->symbolOffset,
&ssbInfo->pbchResult,
nr_gold_pbch_ref,
rxdataF); // start pbch detection at first symbol after pss
}
}
......@@ -400,7 +395,6 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
// and we do not know yet in which slot it goes.
compensate_freq_offset(ue->common_vars.rxdata, fp, res.freqOffset, res.syncRes.frame_id);
}
nr_gold_pbch(ue->nr_gold_pbch, fp->Nid_cell, fp->Lmax);
// sync at symbol ue->symbol_offset
// computing the offset wrt the beginning of the frame
int mu = fp->numerology_index;
......
......@@ -464,7 +464,6 @@ nr_initial_sync_t sl_nr_slss_search(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc,
for (int symbol = 0; symbol < SL_NR_NUMSYM_SLSS_NORMAL_CP - 1;) {
nr_pbch_channel_estimation(frame_parms,
&UE->SL_UE_PHY_PARAMS,
UE->nr_gold_pbch,
rxdataF_sz,
dl_ch_estimates,
dl_ch_estimates_time,
......
......@@ -33,12 +33,11 @@
#include "PHY/CODING/coding_extern.h"
#include "PHY/phy_extern_nr_ue.h"
#include "PHY/sse_intrin.h"
#include "PHY/LTE_REFSIG/lte_refsig.h"
#include "PHY/INIT/nr_phy_init.h"
#include "openair1/SCHED_NR_UE/defs.h"
#include <openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h>
#include <openair1/PHY/TOOLS/phy_scope_interface.h>
#include "openair1/PHY/NR_REFSIG/nr_refsig_common.h"
//#define DEBUG_PBCH
//#define DEBUG_PBCH_ENCODING
......@@ -294,46 +293,30 @@ void nr_pbch_unscrambling(int16_t *demod_pbch_e,
uint32_t pbch_a_prime,
uint32_t *pbch_a_interleaved)
{
uint8_t reset, offset;
uint32_t x1 = 0, x2 = 0, s = 0;
uint8_t k=0;
reset = 1;
// x1 is set in first call to lte_gold_generic
x2 = Nid; //this is c_init
uint32_t *seq = gold_cache(Nid, (nushift * M + length + 31) / 32); // this is c_init
// The Gold sequence is shifted by nushift* M, so we skip (nushift*M /32) double words
for (int i=0; i<(uint16_t)ceil(((float)nushift*M)/32); i++) {
s = lte_gold_generic(&x1, &x2, reset);
reset = 0;
}
int idxGold = (nushift * M + 31) / 32 - 1;
// Scrambling is now done with offset (nushift*M)%32
offset = (nushift*M)&0x1f;
for (int i=0; i<length; i++) {
/*if (((i+offset)&0x1f)==0) {
s = lte_gold_generic(&x1, &x2, reset);
reset = 0;
}*/
int offset = (nushift * M) & 0x1f;
uint8_t k = 0;
for (int i = 0; i < length; i++) {
if (bitwise) {
if (((k+offset)&0x1f)==0 && (!((unscrambling_mask>>i)&1))) {
s = lte_gold_generic(&x1, &x2, reset);
reset = 0;
}
*pbch_a_interleaved ^= ((unscrambling_mask>>i)&1)? ((pbch_a_prime>>i)&1)<<i : (((pbch_a_prime>>i)&1) ^ ((s>>((k+offset)&0x1f))&1))<<i;
if (((k + offset) & 0x1f) == 0 && (!((unscrambling_mask >> i) & 1)))
idxGold++;
*pbch_a_interleaved ^= ((unscrambling_mask >> i) & 1)
? ((pbch_a_prime >> i) & 1) << i
: (((pbch_a_prime >> i) & 1) ^ ((seq[idxGold] >> ((k + offset) & 0x1f)) & 1)) << i;
k += (!((unscrambling_mask>>i)&1));
#ifdef DEBUG_PBCH_ENCODING
printf("i %d k %d offset %d (unscrambling_mask>>i)&1) %d s: %08x\t pbch_a_interleaved 0x%08x (!((unscrambling_mask>>i)&1)) %d\n", i, k, offset, (unscrambling_mask>>i)&1, s, *pbch_a_interleaved,
(!((unscrambling_mask>>i)&1)));
#endif
} else {
if (((i+offset)&0x1f)==0) {
s = lte_gold_generic(&x1, &x2, reset);
reset = 0;
}
if (((i + offset) & 0x1f) == 0)
idxGold++;
if (((s>>((i+offset)&0x1f))&1)==1)
if (seq[idxGold] & (1UL << ((i + offset) % 32)))
demod_pbch_e[i] = -demod_pbch_e[i];
#ifdef DEBUG_PBCH_ENCODING
......
......@@ -606,9 +606,6 @@ typedef struct PHY_VARS_gNB_s {
// PUCCH0 Look-up table for cyclic-shifts
NR_gNB_PUCCH0_LUT_t pucch0_lut;
/// PBCH DMRS sequence
uint32_t nr_gold_pbch_dmrs[2][64][NR_PBCH_DMRS_LENGTH_DWORD];
/// PBCH interleaver
uint8_t nr_pbch_interleaver[NR_POLAR_PBCH_PAYLOAD_BITS];
......
......@@ -408,10 +408,6 @@ typedef struct PHY_VARS_NR_UE_s {
#endif
/// PBCH DMRS sequence
uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD];
/// PDSCH DMRS
uint32_t ****nr_gold_pdsch[NUMBER_OF_CONNECTED_eNB_MAX];
......
......@@ -26,7 +26,6 @@
#include "PHY/NR_TRANSPORT/nr_ulsch.h"
#include "PHY/NR_TRANSPORT/nr_dci.h"
#include "PHY/NR_ESTIMATION/nr_ul_estimation.h"
#include "PHY/NR_REFSIG/nr_refsig_common.h"
#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h"
#include "fapi_nr_l1.h"
#include "common/utils/LOG/log.h"
......@@ -109,20 +108,13 @@ void nr_common_signal_procedures(PHY_VARS_gNB *gNB,int frame,int slot, nfapi_nr_
nr_generate_pss(&txdataF[0][txdataF_offset], gNB->TX_AMP, ssb_start_symbol, cfg, fp);
nr_generate_sss(&txdataF[0][txdataF_offset], gNB->TX_AMP, ssb_start_symbol, cfg, fp);
if (fp->Lmax == 4)
nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index & 7],
&txdataF[0][txdataF_offset],
gNB->TX_AMP,
ssb_start_symbol,
cfg,
fp);
else
nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[0][ssb_index & 7],
&txdataF[0][txdataF_offset],
gNB->TX_AMP,
ssb_start_symbol,
cfg,
fp);
int hf = fp->Lmax == 4 ? n_hf : 0;
nr_generate_pbch_dmrs(nr_gold_pbch(fp->Lmax, gNB->gNB_config.cell_config.phy_cell_id.value, hf, ssb_index & 7),
&txdataF[0][txdataF_offset],
gNB->TX_AMP,
ssb_start_symbol,
cfg,
fp);
#if T_TRACER
if (T_ACTIVE(T_GNB_PHY_MIB)) {
......
......@@ -916,7 +916,6 @@ int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_
start_meas(&ue->dlsch_channel_estimation_stats);
nr_pbch_channel_estimation(&ue->frame_parms,
NULL,
ue->nr_gold_pbch,
estimateSz,
dl_ch_estimates,
dl_ch_estimates_time,
......
......@@ -196,7 +196,6 @@ int psbch_pscch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr
start_meas(&sl_phy_params->channel_estimation_stats);
nr_pbch_channel_estimation(fp,
&ue->SL_UE_PHY_PARAMS,
ue->nr_gold_pbch,
estimateSz,
dl_ch_estimates,
dl_ch_estimates_time,
......
......@@ -840,8 +840,6 @@ int main(int argc, char **argv)
init_nr_ue_transport(UE);
nr_gold_pbch(UE->nr_gold_pbch, frame_parms->Nid_cell, frame_parms->Lmax);
// compute the scramblingID_pdcch and the gold pdcch
UE->scramblingID_pdcch = frame_parms->Nid_cell;
nr_gold_pdcch(UE, frame_parms->Nid_cell);
......
......@@ -618,8 +618,6 @@ int main(int argc, char **argv)
exit(-1);
}
nr_gold_pbch(UE->nr_gold_pbch, Nid_cell, frame_parms->Lmax);
processingData_L1tx_t msgDataTx;
// generate signal
const uint32_t rxdataF_sz = UE->frame_parms.samples_per_slot_wCP;
......@@ -803,7 +801,6 @@ int main(int argc, char **argv)
nr_pbch_channel_estimation(&UE->frame_parms,
&UE->SL_UE_PHY_PARAMS,
UE->nr_gold_pbch,
estimateSz,
dl_ch_estimates,
dl_ch_estimates_time,
......
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