Commit 8a919430 authored by Raymond Knopp's avatar Raymond Knopp

commit before merge

parent d1dec5ed
......@@ -695,7 +695,7 @@ uint32_t polar_decoder_int16(int16_t *input,
else if (crclen==6) crc = (uint64_t)(crc6(A64_flip,8*offset+len)>>26)&0x3f;
}
#if 0
#if 1
printf("A %llx B %llx|%llx Cprime %llx|%llx (crc %x,rxcrc %llx %d)\n",
Ar,
B[1],B[0],Cprime[1],Cprime[0],crc,
......
......@@ -30,7 +30,7 @@
* \warning
*/
//#define DEBUG_POLAR_ENCODER
#define DEBUG_POLAR_ENCODER
//#define DEBUG_POLAR_ENCODER_DCI
//#define DEBUG_POLAR_MATLAB
......@@ -258,10 +258,11 @@ static inline void polar_rate_matching(const t_nrPolar_params *polarParams,void
// handle rate matching with a single 128 bit word using bit shuffling
// can be done with SIMD intrisics if needed
if (polarParams->groupsize < 8) {
AssertFatal(polarParams->encoderLength<=128,"Need to handle groupsize<8 and N>128\n");
AssertFatal(polarParams->encoderLength<=512,"Need to handle groupsize(%d)<8 and N(%d)>512\n",polarParams->groupsize,polarParams->encoderLength);
uint128_t *out128=(uint128_t*)out;
uint128_t *in128=(uint128_t*)in;
*out128=0;
for (int i=0;i<=polarParams->encoderLength>>7;i++)
out128[i]=0;
uint128_t tmp0;
#ifdef DEBUG_POLAR_ENCODER
uint128_t tmp1;
......@@ -270,15 +271,21 @@ static inline void polar_rate_matching(const t_nrPolar_params *polarParams,void
#ifdef DEBUG_POLAR_ENCODER
printf("%d<-%u : %llx.%llx =>",i,polarParams->rate_matching_pattern[i],((uint64_t *)out)[1],((uint64_t *)out)[0]);
#endif
tmp0 = (*in128&(((uint128_t)1)<<polarParams->rate_matching_pattern[i]));
uint8_t pi=polarParams->rate_matching_pattern[i];
uint8_t pi7=pi>>7;
uint8_t pimod128=pi&127;
uint8_t imod128=i&127;
uint8_t i7=i>>7;
tmp0 = (in128[pi7]&(((uint128_t)1)<<(pimod128)));
if (tmp0!=0) {
*out128 = *out128 | ((uint128_t)1)<<i;
out128[i7] = out128[i7] | ((uint128_t)1)<<imod128;
#ifdef DEBUG_POLAR_ENCODER
tmp1 = ((uint128_t)1)<<i;
printf("%llx.%llx<->%llx.%llx => %llx.%llx\n",
((uint64_t *)&tmp0)[1],((uint64_t *)&tmp0)[0],
((uint64_t *)&tmp1)[1],((uint64_t *)&tmp1)[0],
((uint64_t *)out)[1],((uint64_t *)out)[0]);
printf("%llx.%llx<->%llx.%llx => %llx.%llx\n",
((uint64_t *)&tmp0)[1],((uint64_t *)&tmp0)[0],
((uint64_t *)&tmp1)[1],((uint64_t *)&tmp1)[0],
((uint64_t *)out)[1],((uint64_t *)out)[0]);
#endif
}
}
......
......@@ -101,45 +101,55 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB,int first_symb,int num_symb) {
NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
NR_gNB_COMMON *common_vars = &gNB->common_vars;
PHY_MEASUREMENTS_gNB *measurements = &gNB->measurements;
uint32_t *rb_mask = gNB->rb_mask_ul;
int rb, offset, offset0, nb_rb, len;
int rb, offset, offset0, nb_symb[275], len;
int32_t *ul_ch;
int32_t n0_power_tot;
int64_t n0_power_tot2;
nb_rb = 0;
n0_power_tot2=0;
for (rb=0; rb<frame_parms->N_RB_UL; rb++) {
n0_power_tot=0;
offset0 = (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size;
if ((rb_mask[rb>>5]&(1<<(rb&31))) == 0) { // check that rb was not used in this subframe
nb_rb++;
for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
measurements->n0_subband_power[aarx][rb]=0;
for (int s=first_symb;s<(first_symb+num_symb);s++) {
offset = offset0 + (s*frame_parms->ofdm_symbol_size);
ul_ch = &common_vars->rxdataF[aarx][offset];
len = 12;
if (((frame_parms->N_RB_UL&1) == 1) &&
(rb==(frame_parms->N_RB_UL>>1))) {
len=6;
}
AssertFatal(ul_ch, "RX signal buffer (freq) problem\n");
measurements->n0_subband_power[aarx][rb] += signal_energy_nodc(ul_ch,len);
} // symbol
measurements->n0_subband_power[aarx][rb]/=num_symb;
int32_t n0_power_tot[275];
for (int s=first_symb;s<(first_symb+num_symb);s++) {
for (rb=0; rb<frame_parms->N_RB_UL; rb++) {
if (s==first_symb) {
n0_power_tot[rb]=0;
nb_symb[rb]=0;
}
offset0 = (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size;
if ((gNB->rb_mask_ul[s][rb>>5]&(1<<(rb&31))) == 0) { // check that rb was not used in this subframe
nb_symb[rb]++;
for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
if (s==first_symb) measurements->n0_subband_power[aarx][rb]=0;
offset = offset0 + (s*frame_parms->ofdm_symbol_size);
ul_ch = &common_vars->rxdataF[aarx][offset];
len = 12;
if (((frame_parms->N_RB_UL&1) == 1) &&
(rb==(frame_parms->N_RB_UL>>1))) {
len=6;
}
AssertFatal(ul_ch, "RX signal buffer (freq) problem\n");
measurements->n0_subband_power[aarx][rb] += signal_energy_nodc(ul_ch,len);
measurements->n0_subband_power_dB[aarx][rb] = dB_fixed(measurements->n0_subband_power[aarx][rb]);
n0_power_tot += measurements->n0_subband_power[aarx][rb];
} //antenna
n0_power_tot/=frame_parms->nb_antennas_rx;
n0_power_tot2 += n0_power_tot;
measurements->n0_subband_power_tot_dB[rb] = dB_fixed(n0_power_tot);
} //antenna
}
} //rb
} // symb
int nb_rb=0;
int32_t n0_subband_tot=0;
int32_t n0_subband_tot_perPRB=0;
for (int rb = 0 ; rb<frame_parms->N_RB_UL;rb++) {
n0_subband_tot_perPRB=0;
if (nb_symb[rb] > 0) {
for (int aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) {
measurements->n0_subband_power[aarx][rb]/=nb_symb[rb];
n0_subband_tot_perPRB+=measurements->n0_subband_power[aarx][rb];
}
n0_subband_tot_perPRB/=frame_parms->nb_antennas_rx;
measurements->n0_subband_power_tot_dB[rb] = dB_fixed(n0_subband_tot_perPRB);
measurements->n0_subband_power_tot_dBm[rb] = measurements->n0_subband_power_tot_dB[rb] - gNB->rx_total_gain_dB - dB_fixed(frame_parms->N_RB_UL);
//printf("n0_subband_power_tot_dB[%d] => %d, over %d symbols\n",rb,measurements->n0_subband_power_tot_dB[rb],nb_symb[rb]);
n0_subband_tot += n0_subband_tot;
nb_rb++;
}
} //rb
if (nb_rb>0) measurements->n0_subband_power_avg_dB = dB_fixed(n0_power_tot2/nb_rb);
}
if (nb_rb>0) measurements->n0_subband_power_avg_dB = dB_fixed(n0_subband_tot/nb_rb);
}
......
This diff is collapsed.
......@@ -59,11 +59,11 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue,
int16_t amp,
int nr_slot_tx,
uint8_t m0,
uint8_t mcs,
uint8_t mcs,
uint8_t nrofSymbols,
uint8_t startingSymbolIndex,
uint16_t startingPRB,
uint16_t secondHopPRB) {
uint16_t secondHopPRB) {
#ifdef DEBUG_NR_PUCCH_TX
printf("\t [nr_generate_pucch0] start function at slot(nr_slot_tx)=%d\n",nr_slot_tx);
#endif
......
......@@ -798,9 +798,8 @@ typedef struct PHY_VARS_gNB_s {
/// PUSCH DMRS
uint32_t ****nr_gold_pusch_dmrs;
// Mask of occupied RBs
uint32_t rb_mask_ul[9];
int ulmask_symb;
// Mask of occupied RBs, per symbol and PRB
uint32_t rb_mask_ul[14][9];
/// CSI RS sequence
uint32_t ***nr_gold_csi_rs;
......
......@@ -474,22 +474,20 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
for (int symbol=0;symbol<14;symbol++) {
if (gNB->gNB_config.tdd_table.max_tdd_periodicity_list[slot_rx].max_num_of_symbol_per_slot_list[symbol].slot_config.value==1){
nb_rb = 0;
for (int m=0;m<9;m++) gNB->rb_mask_ul[m] = 0;
gNB->ulmask_symb = -1;
for (int m=0;m<9;m++) gNB->rb_mask_ul[symbol][m] = 0;
for (int i=0;i<NUMBER_OF_NR_PUCCH_MAX;i++){
NR_gNB_PUCCH_t *pucch = gNB->pucch[i];
if (pucch) {
if ((pucch->active == 1) &&
(pucch->frame == frame_rx) &&
(pucch->frame == frame_rx) &&
(pucch->slot == slot_rx) ) {
gNB->ulmask_symb = symbol;
nfapi_nr_pucch_pdu_t *pucch_pdu = &pucch->pucch_pdu;
if ((symbol>=pucch_pdu->start_symbol_index) &&
(symbol<(pucch_pdu->start_symbol_index + pucch_pdu->nr_of_symbols))){
for (rb=0; rb<pucch_pdu->prb_size; rb++) {
rb2 = rb+pucch_pdu->prb_start+pucch_pdu->bwp_start;
gNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31));
gNB->rb_mask_ul[symbol][rb2>>5] |= (1<<(rb2&31));
}
nb_rb+=pucch_pdu->prb_size;
}
......@@ -512,12 +510,11 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
(ulsch_harq->handled == 0)){
uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index;
uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_pdu.nr_of_symbols;
gNB->ulmask_symb = symbol;
if ((symbol>=symbol_start) &&
(symbol<symbol_end)){
for (rb=0; rb<ulsch_harq->ulsch_pdu.rb_size; rb++) {
rb2 = rb+ulsch_harq->ulsch_pdu.rb_start+ulsch_harq->ulsch_pdu.bwp_start;
gNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31));
gNB->rb_mask_ul[symbol][rb2>>5] |= (1<<(rb2&31));
}
nb_rb+=ulsch_harq->ulsch_pdu.rb_size;
}
......
......@@ -773,9 +773,9 @@ int main(int argc, char **argv)
AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface");
gNB->if_inst->NR_PHY_config_req = nr_phy_config_request;
// common configuration
rrc_mac_config_req_gNB(0,0, n_tx, n_tx, scc, 0, 0, NULL);
rrc_mac_config_req_gNB(0,0, n_tx, n_tx, scc, NULL, 0, 0, NULL);
// UE dedicated configuration
rrc_mac_config_req_gNB(0,0, n_tx, n_tx, scc, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup);
rrc_mac_config_req_gNB(0,0, n_tx, n_tx, scc, NULL, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup);
// reset preprocessor to the one of DLSIM after it has been set during
// rrc_mac_config_req_gNB
gNB_mac->pre_processor_dl = nr_dlsim_preprocessor;
......@@ -1248,7 +1248,7 @@ int main(int argc, char **argv)
(float) n_errors / (float) n_trials);
printf("*****************************************\n");
printf("\n");
dump_pdsch_stats(gNB);
dump_pdsch_stats(stdout,gNB);
printf("SNR %f : n_errors (negative CRC) = %d/%d, Avg round %.2f, Channel BER %e, BLER %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", SNR, n_errors, n_trials,roundStats[snrRun],berStats[snrRun],blerStats[snrRun],effRate,effRate/TBS*100,TBS);
printf("\n");
......
This diff is collapsed.
......@@ -39,7 +39,7 @@ double **cos_lut=NULL,* *sin_lut=NULL;
int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) {
int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int scs) {
double delta_f,freq; // 90 kHz spacing
double delay;
int16_t f;
......@@ -52,7 +52,7 @@ int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) {
cos_lut = (double **)malloc(n_samples*sizeof(double *));
sin_lut = (double **)malloc(n_samples*sizeof(double *));
delta_f = nb_rb*180000/(n_samples-1);
delta_f = nb_rb*12*scs*1000/(n_samples-1);
for (f=-(n_samples>>1); f<=(n_samples>>1); f++) {
freq=delta_f*(double)f*1e-6;// due to the fact that delays is in mus
......@@ -67,14 +67,14 @@ int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) {
cos_lut[f+(n_samples>>1)][l] = cos(2*M_PI*freq*delay);
sin_lut[f+(n_samples>>1)][l] = sin(2*M_PI*freq*delay);
//printf("values cos:%d, sin:%d\n", cos_lut[f][l], sin_lut[f][l]);
// printf("values cos:%f, sin:%f\n", cos_lut[f+(n_samples>>1)][l], sin_lut[f+(n_samples>>1)][l]);
}
}
return(0);
}
int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) {
int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int scs) {
int16_t f,f2,d;
uint8_t aarx,aatx,l;
double *clut,*slut;
......@@ -95,14 +95,14 @@ int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) {
// if called with n_samples<12*nb_rb+1, we decimate the lut
n_samples_max=12*nb_rb+1;
if (init_freq_channel(desc,nb_rb,n_samples_max)==0)
if (init_freq_channel(desc,nb_rb,n_samples_max,scs)==0)
freq_channel_init=1;
else
return(-1);
}
d=(n_samples_max-1)/(n_samples-1);
//printf("no_samples=%d, n_samples_max=%d, d=%d\n",n_samples,n_samples_max,d);
// printf("no_samples=%d, n_samples_max=%d, d=%d,nb_taps %d\n",n_samples,n_samples_max,d,desc->nb_taps);
start_meas(&desc->interp_freq);
for (f=-n_samples_max/2,f2=-n_samples/2; f<n_samples_max/2; f+=d,f2++) {
......@@ -111,6 +111,7 @@ int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) {
for (aarx=0; aarx<desc->nb_rx; aarx++) {
for (aatx=0; aatx<desc->nb_tx; aatx++) {
AssertFatal(n_samples/2+f2 < (2+(275*12)),"reading past chF %d (n_samples %d, f2 %d)\n",n_samples/2+f2,n_samples,f2);
desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].x=0.0;
desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].y=0.0;
......
......@@ -543,12 +543,12 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS
chan_desc->ch[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex));
for (int i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complex *) malloc(1200 * sizeof(struct complex));
chan_desc->chF[i] = (struct complex *) malloc((2+(275*12)) * sizeof(struct complex));
for (int i = 0; i<chan_desc->nb_taps; i++)
chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex));
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **));
chan_desc->R_sqrt = (struct complex **) malloc(tdl_pathsby3*sizeof(struct complex **));
if (nb_tx==2 && nb_rx==2) {
for (int i = 0; i<(tdl_pathsby3); i++)
......@@ -1729,10 +1729,9 @@ void set_channeldesc_name(channel_desc_t *cdesc,char *modelname) {
int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) {
double s;
int i,k,l,aarx,aatx;
struct complex anew[NB_ANTENNAS_TX*NB_ANTENNAS_RX],acorr[NB_ANTENNAS_TX*NB_ANTENNAS_RX];
struct complex anew[desc->nb_tx*desc->nb_rx],acorr[desc->nb_tx*desc->nb_rx];
struct complex phase, alpha, beta;
AssertFatal(desc->nb_tx<=NB_ANTENNAS_TX && desc->nb_rx <= NB_ANTENNAS_RX,
"random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx);
start_meas(&desc->random_channel);
for (i=0; i<(int)desc->nb_taps; i++) {
......
......@@ -477,8 +477,8 @@ int gauss(unsigned int *gauss_LUT,unsigned char Nbits);
double gaussdouble(double,double);
void randominit(unsigned int seed_init);
double uniformrandom(void);
int freq_channel(channel_desc_t *desc,uint16_t nb_rb, int16_t n_samples);
int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples);
int freq_channel(channel_desc_t *desc,uint16_t nb_rb, int16_t n_samples,int scs);
int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int scs);
uint8_t multipath_channel_nosigconv(channel_desc_t *desc);
void multipath_tv_channel(channel_desc_t *desc,
double **tx_sig_re,
......
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