Commit 4a242993 authored by rmagueta's avatar rmagueta

Merge remote-tracking branch 'origin/bandwidth-testing' into bandwidth-testing-abs

# Conflicts:
#	openair1/PHY/MODULATION/slot_fep_nr.c
#	openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c
#	openair1/PHY/NR_TRANSPORT/pucch_rx.c
#	openair2/LAYER2/NR_MAC_UE/config_ue.c
#	openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c
#	openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
#	openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
#	openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c
#	openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
parents 54ae3148 4c6b707b
......@@ -55,7 +55,6 @@ int32_t nrLDPC_decod(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_
t_nrLDPC_lut* p_lut = &lut;
//printf("p_procBuf->cnProcBuf = %p\n", p_procBuf->cnProcBuf);
// Initialize decoder core(s) with correct LUTs
numLLR = nrLDPC_init(p_decParams, p_lut);
......@@ -231,7 +230,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP
// First iteration finished
while ( (i < (numMaxIter-1)) && (pcRes != 0) )
while ( (i < numMaxIter) && (pcRes != 0) )
{
// Increase iteration counter
i++;
......
......@@ -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
}
}
......
......@@ -92,9 +92,7 @@ if ((Kprime%Kb) > 0)
else
Z = (Kprime/Kb);
#ifdef DEBUG_SEGMENTATION
printf("nr segmetation B %u Bprime %u Kprime %u z %u \n", B, Bprime, Kprime, Z);
#endif
LOG_D(PHY,"nr segmetation B %u Bprime %u Kprime %u z %u \n", B, Bprime, Kprime, Z);
if (Z <= 2) {
*K = 2;
......@@ -148,10 +146,8 @@ else
*F = ((*K) - Kprime);
#ifdef DEBUG_SEGMENTATION
printf("final nr seg output Z %u K %u F %u \n", *Zout, *K, *F);
printf("C %u, K %u, Bprime_bytes %u, Bprime %u, F %u\n",*C,*K,Bprime>>3,Bprime,*F);
#endif
LOG_D(PHY,"final nr seg output Z %u K %u F %u \n", *Zout, *K, *F);
LOG_D(PHY,"C %u, K %u, Bprime_bytes %u, Bprime %u, F %u\n",*C,*K,Bprime>>3,Bprime,*F);
if ((input_buffer) && (output_buffers)) {
......
......@@ -356,6 +356,7 @@ void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms,
int symb_offset = (slot%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot;
int soffset = (slot&3)*frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size;
for (int symbol=first_symbol;symbol<nsymb;symbol++) {
uint32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation[1])[symbol + symb_offset];
......
......@@ -201,6 +201,7 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq
rx_power[ulsch_id][aarx] += meas->rx_spatial_power[ulsch_id][aatx][aarx];
}
LOG_D(PHY, "[ULSCH ID %d] RX power in antenna %d = %d\n", ulsch_id, aarx, rx_power[ulsch_id][aarx]);
rx_power_tot[ulsch_id] += rx_power[ulsch_id][aarx];
......@@ -212,12 +213,13 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq
meas->wideband_cqi_tot[ulsch_id] = dB_fixed2(rx_power_tot[ulsch_id], meas->n0_power_tot);
meas->rx_rssi_dBm[ulsch_id] = rx_power_avg_dB[ulsch_id] + 30 - 10 * log10(pow(2, 30)) - (rx_gain - rx_gain_offset) - dB_fixed(fp->ofdm_symbol_size);
LOG_D(PHY, "[ULSCH %d] RSSI %d dBm/RE, RSSI (digital) %d dB (N_RB_UL %d), WBand CQI tot %d dB, N0 Power tot %d\n",
LOG_D(PHY, "[ULSCH %d] RSSI %d dBm/RE, RSSI (digital) %d dB (N_RB_UL %d), WBand CQI tot %d dB, N0 Power tot %d, RX Power tot %d\n",
ulsch_id,
meas->rx_rssi_dBm[ulsch_id],
rx_power_avg_dB[ulsch_id],
N_RB_UL,
meas->wideband_cqi_tot[ulsch_id],
meas->n0_power_tot);
meas->n0_power_tot,
rx_power_tot[ulsch_id]);
}
......@@ -319,7 +319,6 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)];
ul_ch+=8;
}
// Treat first 2 pilots specially (right edge)
......
......@@ -46,11 +46,11 @@ uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r) {
AssertFatal(Nl>0,"Nl is 0\n");
AssertFatal(Qm>0,"Qm is 0\n");
LOG_D(PHY,"nr_get_E : (G %d, C %d, Qm %d, Nl %d, r %d)\n",G, C, Qm, Nl, r);
if (r <= Cprime - ((G/(Nl*Qm))%Cprime) - 1)
E = Nl*Qm*(G/(Nl*Qm*Cprime));
else
E = Nl*Qm*((G/(Nl*Qm*Cprime))+1);
LOG_D(PHY,"nr_get_E : (G %d, C %d, Qm %d, Nl %d, r %d), E %d\n",G, C, Qm, Nl, r, E);
return E;
}
......@@ -429,9 +429,10 @@ void nr_processULSegment(void* arg) {
if (check_crc((uint8_t*)llrProcBuf,length_dec,ulsch_harq->F,crc_type)) {
#ifdef PRINT_CRC_CHECK
LOG_I(PHY, "Segment %d CRC OK\n",r);
LOG_I(PHY, "Segment %d CRC OK, iterations %d/%d\n",r,no_iteration_ldpc,max_ldpc_iterations);
#endif
rdata->decodeIterations = no_iteration_ldpc;
if (rdata->decodeIterations > p_decoderParms->numMaxIter) rdata->decodeIterations--;
} else {
#ifdef PRINT_CRC_CHECK
LOG_I(PHY, "CRC NOK\n");
......@@ -509,7 +510,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
A = (harq_process->TBS)<<3;
LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d\n",harq_pid,A,G, mcs, n_layers, nb_rb, Qm, n_layers);
LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d, Coderate %d\n",harq_pid,A,G, mcs, n_layers, nb_rb, Qm, n_layers, R);
if (R<1024)
Coderate = (float) R /(float) 1024;
......
......@@ -582,22 +582,29 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext,
unsigned short nb_rb,
unsigned char output_shift) {
#ifdef __AVX2__
int off = ((nb_rb&1) == 1)? 4:0;
#else
int off = 0;
#endif
#ifdef DEBUG_CH_COMP
int16_t *rxF, *ul_ch;
int prnt_idx;
rxF = (int16_t *)&rxdataF_ext[0][symbol*(off+(nb_rb*12))];
ul_ch = (int16_t *)&ul_ch_estimates_ext[0][symbol*(off+(nb_rb*1))2];
for (int ant=0; ant<frame_parms->nb_antennas_rx; ant++) {
rxF = (int16_t *)&rxdataF_ext[ant][symbol*(off+(nb_rb*12))];
ul_ch = (int16_t *)&ul_ch_estimates_ext[ant][symbol*(off+(nb_rb*12))];
printf("--------------------symbol = %d, mod_order = %d, output_shift = %d-----------------------\n", symbol, mod_order, output_shift);
printf("----------------Before compensation------------------\n");
printf("--------------------symbol = %d, mod_order = %d, output_shift = %d-----------------------\n", symbol, mod_order, output_shift);
printf("----------------Before compensation------------------\n");
for (prnt_idx=0;prnt_idx<12*nb_rb*2;prnt_idx+=2){
for (prnt_idx=0;prnt_idx<12*5*2;prnt_idx+=2){
printf("rxF[%d] = (%d,%d)\n", prnt_idx>>1, rxF[prnt_idx],rxF[prnt_idx+1]);
printf("ul_ch[%d] = (%d,%d)\n", prnt_idx>>1, ul_ch[prnt_idx],ul_ch[prnt_idx+1]);
printf("rxF[%d] = (%d,%d)\n", prnt_idx>>1, rxF[prnt_idx],rxF[prnt_idx+1]);
printf("ul_ch[%d] = (%d,%d)\n", prnt_idx>>1, ul_ch[prnt_idx],ul_ch[prnt_idx+1]);
}
}
#endif
......@@ -607,25 +614,21 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext,
int print_idx;
ch_mag = (int16_t *)&ul_ch_mag[0][symbol*(off+(nb_rb*12))];
for (int ant=0; ant<frame_parms->nb_antennas_rx; ant++) {
ch_mag = (int16_t *)&ul_ch_mag[ant][symbol*(off+(nb_rb*12))];
printf("--------------------symbol = %d, mod_order = %d-----------------------\n", symbol, mod_order);
printf("----------------Before computation------------------\n");
printf("--------------------symbol = %d, mod_order = %d-----------------------\n", symbol, mod_order);
printf("----------------Before computation------------------\n");
for (print_idx=0;print_idx<50;print_idx++){
for (print_idx=0;print_idx<5;print_idx++){
printf("ch_mag[%d] = %d\n", print_idx, ch_mag[print_idx]);
printf("ch_mag[%d] = %d\n", print_idx, ch_mag[print_idx]);
}
}
#endif
#ifdef __AVX2__
int off = ((nb_rb&1) == 1)? 4:0;
#else
int off = 0;
#endif
#if defined(__i386) || defined(__x86_64__)
unsigned short rb;
......@@ -1068,14 +1071,16 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext,
#ifdef DEBUG_CH_COMP
rxF = (int16_t *)&rxdataF_comp[0][(symbol*(off+(nb_rb*12)))];
for (int ant=0; ant<frame_parms->nb_antennas_rx; ant++) {
rxF = (int16_t *)&rxdataF_comp[ant][(symbol*(off+(nb_rb*12)))];
printf("----------------After compansation------------------\n");
printf("----------------After compansation------------------\n");
for (prnt_idx=0;prnt_idx<12*nb_rb*2;prnt_idx+=2){
for (prnt_idx=0;prnt_idx<12*5*2;prnt_idx+=2){
printf("rxF[%d] = (%d,%d)\n", prnt_idx>>1, rxF[prnt_idx],rxF[prnt_idx+1]);
printf("rxF[%d] = (%d,%d)\n", prnt_idx>>1, rxF[prnt_idx],rxF[prnt_idx+1]);
}
}
#endif
......@@ -1083,14 +1088,16 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext,
#ifdef DEBUG_CH_MAG
ch_mag = (int16_t *)&ul_ch_mag[0][(symbol*(off+(nb_rb*12)))];
for (int ant=0; ant<frame_parms->nb_antennas_rx; ant++) {
ch_mag = (int16_t *)&ul_ch_mag[ant][(symbol*(off+(nb_rb*12)))];
printf("----------------After computation------------------\n");
printf("----------------After computation------------------\n");
for (print_idx=0;print_idx<12*nb_rb*2;print_idx+=2){
for (print_idx=0;print_idx<12*5*2;print_idx+=2){
printf("ch_mag[%d] = (%d,%d)\n", print_idx>>1, ch_mag[print_idx],ch_mag[print_idx+1]);
printf("ch_mag[%d] = (%d,%d)\n", print_idx>>1, ch_mag[print_idx],ch_mag[print_idx+1]);
}
}
#endif
......@@ -1318,8 +1325,8 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB,
start_meas(&gNB->ulsch_mrc_stats);
nr_ulsch_detection_mrc(frame_parms,
gNB->pusch_vars[ulsch_id]->rxdataF_comp,
gNB->pusch_vars[ulsch_id]->ul_ch_mag,
gNB->pusch_vars[ulsch_id]->ul_ch_magb,
gNB->pusch_vars[ulsch_id]->ul_ch_mag0,
gNB->pusch_vars[ulsch_id]->ul_ch_magb0,
symbol,
rel15_ul->rb_size);
stop_meas(&gNB->ulsch_mrc_stats);
......
......@@ -251,6 +251,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
prb_offset[1] = pucch_pdu->bwp_start+pucch_pdu->second_hop_prb;
}
AssertFatal(pucch_pdu->nr_of_symbols < 3,"nr_of_symbols %d not allowed\n",pucch_pdu->nr_of_symbols);
uint32_t re_offset[2]={0,0};
uint8_t l2;
......@@ -261,12 +262,15 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
x_re[1] = table_5_2_2_2_2_Re[u[1]];
x_im[1] = table_5_2_2_2_2_Im[u[1]];
int16_t xr[2][24] __attribute__((aligned(32)));
int64_t xrtmag=0;
int16_t xr[1+frame_parms->nb_antennas_rx][1+pucch_pdu->nr_of_symbols][24] __attribute__((aligned(32)));
int64_t xrtmag=0,xrtmag_next=0;
uint8_t maxpos=0;
uint8_t index=0;
memset((void*)xr[0],0,24*sizeof(int16_t));
memset((void*)xr[1],0,24*sizeof(int16_t));
for (l=0; l<pucch_pdu->nr_of_symbols; l++) {
for (int aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) {
memset((void*)xr[aarx][l],0,24*sizeof(int16_t));
}
}
int n2;
for (l=0; l<pucch_pdu->nr_of_symbols; l++) {
......@@ -281,70 +285,96 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
r=(int16_t*)&rxdataF[aa][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[l]];
n2=0;
for (n=0;n<12;n++,n2+=2) {
xr[l][n2] +=(int16_t)(((int32_t)x_re[l][n]*r[n2]+(int32_t)x_im[l][n]*r[n2+1])>>15);
xr[l][n2+1]+=(int16_t)(((int32_t)x_re[l][n]*r[n2+1]-(int32_t)x_im[l][n]*r[n2])>>15);
xr[aa][l][n2] +=(int16_t)(((int32_t)x_re[l][n]*r[n2]+(int32_t)x_im[l][n]*r[n2+1])>>15);
xr[aa][l][n2+1]+=(int16_t)(((int32_t)x_re[l][n]*r[n2+1]-(int32_t)x_im[l][n]*r[n2])>>15);
#ifdef DEBUG_NR_PUCCH_RX
printf("x (%d,%d), r%d.%d (%d,%d), xr (%d,%d)\n",
x_re[l][n],x_im[l][n],l2,re_offset[l],r[n2],r[n2+1],xr[l][n2],xr[l][n2+1]);
x_re[l][n],x_im[l][n],l2,re_offset[l],r[n2],r[n2+1],xr[aa][l][n2],xr[aa][l][n2+1]);
#endif
}
}
}
int32_t corr_re[2];
int32_t corr_im[2];
int32_t corr_re[1+frame_parms->nb_antennas_rx][2];
int32_t corr_im[1+frame_parms->nb_antennas_rx][2];
//int32_t no_corr = 0;
int seq_index;
int64_t temp;
int64_t av_corr=0;
for(i=0;i<nr_sequences;i++){
for (l=0;l<pucch_pdu->nr_of_symbols;l++) {
corr_re[l]=0;
corr_im[l]=0;
seq_index = (pucch_pdu->initial_cyclic_shift+
mcs[i]+
gNB->pucch0_lut.lut[cs_ind][slot][l+pucch_pdu->start_symbol_index])%12;
#ifdef DEBUG_NR_PUCCH_RX
printf("PUCCH symbol %d seq %d, seq_index %d, mcs %d\n",l,i,seq_index,mcs[i]);
#endif
n2=0;
for (n=0;n<12;n++,n2+=2) {
corr_re[l]+=(xr[l][n2]*idft12_re[seq_index][n]+xr[l][n2+1]*idft12_im[seq_index][n])>>15;
corr_im[l]+=(xr[l][n2]*idft12_im[seq_index][n]-xr[l][n2+1]*idft12_re[seq_index][n])>>15;
for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) {
corr_re[aa][l]=0;
corr_im[aa][l]=0;
n2=0;
for (n=0;n<12;n++,n2+=2) {
corr_re[aa][l]+=(xr[aa][l][n2]*idft12_re[seq_index][n]+xr[aa][l][n2+1]*idft12_im[seq_index][n])>>15;
corr_im[aa][l]+=(xr[aa][l][n2]*idft12_im[seq_index][n]-xr[aa][l][n2+1]*idft12_re[seq_index][n])>>15;
}
}
}
if (pucch_pdu->freq_hop_flag == 0 && l==1) {// non-coherent correlation
temp=0;
for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++)
temp+=(int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0];
}
LOG_D(PHY,"PUCCH IDFT[%d/%d] = (%d,%d)=>%f\n",mcs[i],seq_index,corr_re[0],corr_im[0],10*log10((double)corr_re[0]*corr_re[0] + (double)corr_im[0]*corr_im[0]));
if (l>1) LOG_D(PHY,"PUCCH 2nd symbol IDFT[%d/%d] = (%d,%d)=>%f\n",mcs[i],seq_index,corr_re[1],corr_im[1],10*log10((double)corr_re[1]*corr_re[1] + (double)corr_im[1]*corr_im[1]));
LOG_D(PHY,"PUCCH IDFT[%d/%d] = (%d,%d)=>%f\n",mcs[i],seq_index,corr_re[0][0],corr_im[0][0],10*log10((double)corr_re[0][0]*corr_re[0][0] + (double)corr_im[0][0]*corr_im[0][0]));
if (l>1) LOG_D(PHY,"PUCCH 2nd symbol IDFT[%d/%d] = (%d,%d)=>%f\n",mcs[i],seq_index,corr_re[0][1],corr_im[0][1],10*log10((double)corr_re[0][1]*corr_re[0][1] + (double)corr_im[0][1]*corr_im[0][1]));
if (pucch_pdu->freq_hop_flag == 0 && l==1) {// non-coherent correlation
temp=0;
for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++)
temp+=(int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0];
}
if (pucch_pdu->freq_hop_flag == 0 && l==1) // non-coherent correlation
temp=(int64_t)corr_re[0]*corr_re[0] + (int64_t)corr_im[0]*corr_im[0];
else if (pucch_pdu->freq_hop_flag == 0 && l==2) {
int64_t corr_re2 = (int64_t)corr_re[0]+corr_re[1];
int64_t corr_im2 = (int64_t)corr_im[0]+corr_im[1];
int64_t corr_re2=0;
int64_t corr_im2=0;
temp=0;
for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) {
corr_re2 = (int64_t)corr_re[aa][0]+corr_re[aa][1];
corr_im2 = (int64_t)corr_im[aa][0]+corr_im[aa][1];
// coherent combining of 2 symbols and then complex modulus for single-frequency case
temp=corr_re2*corr_re2 + corr_im2*corr_im2;
temp+=corr_re2*corr_re2 + corr_im2*corr_im2;
}
}
else if (pucch_pdu->freq_hop_flag == 1)
else if (pucch_pdu->freq_hop_flag == 1) {
// full non-coherent combining of 2 symbols for frequency-hopping case
temp = (int64_t)corr_re[0]*corr_re[0] + (int64_t)corr_im[0]*corr_im[0] + (int64_t)corr_re[1]*corr_re[1] + (int64_t)corr_im[1]*corr_im[1];
temp=0;
for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++)
temp += (int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0] + (int64_t)corr_re[aa][1]*corr_re[aa][1] + (int64_t)corr_im[aa][1]*corr_im[aa][1];
}
else AssertFatal(1==0,"shouldn't happen\n");
av_corr+=temp;
if (temp>xrtmag) {
xrtmag_next = xrtmag;
xrtmag=temp;
maxpos=i;
uci_stats->current_pucch0_stat0 = dB_fixed64((int64_t)corr_re[0]*corr_re[0] + (int64_t)corr_im[0]*corr_im[0]);
if (l==2) uci_stats->current_pucch0_stat1 = dB_fixed64((int64_t)corr_re[1]*corr_re[1] + (int64_t)corr_im[1]*corr_im[1]);
uci_stats->current_pucch0_stat0 = 0;
int64_t temp2=0,temp3=0;;
for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) {
temp2 += ((int64_t)corr_re[aa][0]*corr_re[aa][0] + (int64_t)corr_im[aa][0]*corr_im[aa][0]);
if (l==2) temp3 += ((int64_t)corr_re[aa][1]*corr_re[aa][1] + (int64_t)corr_im[aa][1]*corr_im[aa][1]);
}
uci_stats->current_pucch0_stat0= dB_fixed64(temp2);
if (l==2) uci_stats->current_pucch0_stat1= dB_fixed64(temp3);
}
}
av_corr/=nr_sequences/l;
int xrtmag_dBtimes10 = 10*(int)dB_fixed64(xrtmag);
int xrtmag_dBtimes10 = 10*(int)dB_fixed64(xrtmag/frame_parms->nb_antennas_rx);
int xrtmag_next_dBtimes10 = 10*(int)dB_fixed64(xrtmag_next/frame_parms->nb_antennas_rx);
#ifdef DEBUG_NR_PUCCH_RX
printf("PUCCH 0 : maxpos %d\n",maxpos);
#endif
......@@ -352,7 +382,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
index=maxpos;
uci_stats->pucch0_n00 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[0]];
uci_stats->pucch0_n01 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[1]];
LOG_D(PHY,"n00[%d] = %d, n01[%d] = %d\n",prb_offset[0],uci_stats->pucch0_n00,prb_offset[1],uci_stats->pucch0_n01);
// estimate CQI for MAC (from antenna port 0 only)
int max_n0 = uci_stats->pucch0_n00>uci_stats->pucch0_n01 ? uci_stats->pucch0_n00:uci_stats->pucch0_n01;
int SNRtimes10,sigenergy=0;
......@@ -366,10 +396,10 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
else if (SNRtimes10 > 635) cqi=255;
else cqi=(640+SNRtimes10)/5;
uci_stats->pucch0_thres = gNB->pucch0_thres + (10*max_n0);
uci_stats->pucch0_thres = gNB->pucch0_thres; /* + (10*max_n0);*/
bool no_conf=false;
if (nr_sequences>1) {
if (xrtmag_dBtimes10 < uci_stats->pucch0_thres)
if (xrtmag_dBtimes10 < uci_stats->pucch0_thres+xrtmag_next_dBtimes10)
no_conf=true;
}
gNB->bad_pucch += no_conf;
......@@ -399,9 +429,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
uci_pdu->harq->harq_confidence_level = no_conf ? 1 : 0;
uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(1);
uci_pdu->harq->harq_list[0].harq_value = index&0x01;
LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ value %d with confidence level (0 is good, 1 is bad) %d xrt_mag %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d\n",
frame,slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10);
LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ value %d with confidence level (0 is good, 1 is bad) %d xrt_mag %d srt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d\n",
frame,slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10);
if (pucch_pdu->sr_flag == 1) {
uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
uci_pdu->sr->sr_indication = (index>1) ? 1 : 0;
......@@ -417,8 +446,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2);
uci_pdu->harq->harq_list[1].harq_value = index&0x01;
uci_pdu->harq->harq_list[0].harq_value = (index>>1)&0x01;
LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d, xrt_mag %d\n",
frame,slot,uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10);
LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d, xrt_mag %d xrt_mag_next %d\n",
frame,slot,uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10);
if (pucch_pdu->sr_flag == 1) {
uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
uci_pdu->sr->sr_indication = (index>3) ? 1 : 0;
......@@ -1090,85 +1119,109 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
//extract pucch and dmrs first
int l2=pucch_pdu->start_symbol_index;
int re_offset = (12*pucch_pdu->prb_start) + (12*pucch_pdu->bwp_start) + frame_parms->first_carrier_offset;
if (re_offset>= frame_parms->ofdm_symbol_size)
re_offset-=frame_parms->ofdm_symbol_size;
int re_offset[2];
re_offset[0] = 12*(pucch_pdu->prb_start+pucch_pdu->bwp_start) + frame_parms->first_carrier_offset;
int soffset=(slot&3)*frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size;
if (re_offset[0]>= frame_parms->ofdm_symbol_size)
re_offset[0]-=frame_parms->ofdm_symbol_size;
if (pucch_pdu->freq_hop_flag == 0) re_offset[1] = re_offset[0];
else {
re_offset[1] = 12*(pucch_pdu->second_hop_prb+pucch_pdu->bwp_start) + frame_parms->first_carrier_offset;
if (re_offset[1]>= frame_parms->ofdm_symbol_size)
re_offset[1]-=frame_parms->ofdm_symbol_size;
}
AssertFatal(pucch_pdu->prb_size*pucch_pdu->nr_of_symbols > 1,"number of PRB*SYMB (%d,%d)< 2",
pucch_pdu->prb_size,pucch_pdu->nr_of_symbols);
int Prx = gNB->gNB_config.carrier_config.num_rx_ant.value;
int Prx2 = (Prx==1)?2:Prx;
// use 2 for Nb antennas in case of single antenna to allow the following allocations
int16_t r_re_ext[Prx2][8*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32)));
int16_t r_im_ext[Prx2][8*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32)));
int16_t r_re_ext2[Prx2][8*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32)));
int16_t r_im_ext2[Prx2][8*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32)));
int16_t rd_re_ext[Prx2][4*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32)));
int16_t rd_im_ext[Prx2][4*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32)));
int prb_size_ext = pucch_pdu->prb_size+(pucch_pdu->prb_size&1);
int16_t r_re_ext[Prx2][2][8*prb_size_ext] __attribute__((aligned(32)));
int16_t r_im_ext[Prx2][2][8*prb_size_ext] __attribute__((aligned(32)));
int16_t r_re_ext2[Prx2][2][8*prb_size_ext] __attribute__((aligned(32)));
int16_t r_im_ext2[Prx2][2][8*prb_size_ext] __attribute__((aligned(32)));
int16_t rd_re_ext[Prx2][2][4*prb_size_ext] __attribute__((aligned(32)));
int16_t rd_im_ext[Prx2][2][4*prb_size_ext] __attribute__((aligned(32)));
int16_t *r_re_ext_p,*r_im_ext_p,*rd_re_ext_p,*rd_im_ext_p;
int nb_re_pucch = 12*pucch_pdu->prb_size;
int16_t rp[Prx2][nb_re_pucch*2],*tmp_rp;
int16_t rp[Prx2][2][nb_re_pucch*2],*tmp_rp;
__m64 dmrs_re,dmrs_im;
for (int aa=0;aa<Prx;aa++){
tmp_rp = (int16_t *)&rxdataF[aa][soffset+(l2*frame_parms->ofdm_symbol_size)];
for (int symb=0;symb<pucch_pdu->nr_of_symbols;symb++) {
tmp_rp = ((int16_t *)&rxdataF[aa][soffset + (l2+symb)*frame_parms->ofdm_symbol_size]);
if (re_offset + nb_re_pucch < frame_parms->ofdm_symbol_size) {
memcpy1((void*)rp[aa],(void*)&tmp_rp[re_offset*2],nb_re_pucch*sizeof(int32_t));
}
else {
int neg_length = frame_parms->ofdm_symbol_size-re_offset;
int pos_length = nb_re_pucch-neg_length;
memcpy1((void*)rp[aa],(void*)&tmp_rp[re_offset*2],neg_length*sizeof(int32_t));
memcpy1((void*)&rp[aa][neg_length*2],(void*)tmp_rp,pos_length*sizeof(int32_t));
if (re_offset[symb] + nb_re_pucch < frame_parms->ofdm_symbol_size) {
memcpy1((void*)rp[aa][symb],(void*)&tmp_rp[re_offset[symb]*2],nb_re_pucch*sizeof(int32_t));
}
else {
int neg_length = frame_parms->ofdm_symbol_size-re_offset[symb];
int pos_length = nb_re_pucch-neg_length;
memcpy1((void*)rp[aa][symb],(void*)&tmp_rp[re_offset[symb]*2],neg_length*sizeof(int32_t));
memcpy1((void*)&rp[aa][symb][neg_length*2],(void*)tmp_rp,pos_length*sizeof(int32_t));
}
}
}
#ifdef DEBUG_NR_PUCCH_RX
printf("Decoding pucch2 for %d symbols, %d PRB\n",pucch_pdu->nr_of_symbols,pucch_pdu->prb_size);
#endif
int nc_group_size=1; // 2 PRB
int ngroup = pucch_pdu->prb_size/nc_group_size/2;
int32_t corr32_re[ngroup][Prx2],corr32_im[ngroup][Prx2];
for (int aa=0;aa<Prx;aa++) for (int group=0;group<ngroup;group++) { corr32_re[group][aa]=0; corr32_im[group][aa]=0;}
int ngroup = prb_size_ext/nc_group_size/2;
int32_t corr32_re[2][ngroup][Prx2],corr32_im[2][ngroup][Prx2];
for (int aa=0;aa<Prx;aa++)
for (int group=0;group<ngroup;group++) {
corr32_re[0][group][aa]=0; corr32_im[0][group][aa]=0;
corr32_re[1][group][aa]=0; corr32_im[1][group][aa]=0;
}
if (pucch_pdu->nr_of_symbols == 1) {
AssertFatal((pucch_pdu->prb_size&1) == 0,"prb_size %d is not a multiple of 2\n",pucch_pdu->prb_size);
// 24 PRBs contains 48x16-bit, so 6x8x16-bit
// AssertFatal((pucch_pdu->prb_size&1) == 0,"prb_size %d is not a multiple of 2\n",pucch_pdu->prb_size);
if ((pucch_pdu->prb_size&1) > 0) { // if the number of PRBs is odd
for (int symb=0; symb<pucch_pdu->nr_of_symbols;symb++) {
for (int aa=0;aa<Prx;aa++) {
memset(&r_re_ext[aa][symb][8*pucch_pdu->prb_size],0,8*pucch_pdu->prb_size*sizeof(int16_t));
memset(&r_im_ext[aa][symb][8*pucch_pdu->prb_size],0,8*pucch_pdu->prb_size*sizeof(int16_t));
memset(&rd_re_ext[aa][symb][4*pucch_pdu->prb_size],0,8*pucch_pdu->prb_size*sizeof(int16_t));
memset(&rd_im_ext[aa][symb][4*pucch_pdu->prb_size],0,8*pucch_pdu->prb_size*sizeof(int16_t));
}
}
}
for (int symb=0; symb<pucch_pdu->nr_of_symbols;symb++) {
// 24 REs contains 48x16-bit, so 6x8x16-bit
for (int prb=0;prb<pucch_pdu->prb_size;prb+=2) {
for (int aa=0;aa<Prx;aa++) {
r_re_ext_p=&r_re_ext[aa][8*prb];
r_im_ext_p=&r_im_ext[aa][8*prb];
rd_re_ext_p=&rd_re_ext[aa][4*prb];
rd_im_ext_p=&rd_im_ext[aa][4*prb];
r_re_ext_p=&r_re_ext[aa][symb][8*prb];
r_im_ext_p=&r_im_ext[aa][symb][8*prb];
rd_re_ext_p=&rd_re_ext[aa][symb][4*prb];
rd_im_ext_p=&rd_im_ext[aa][symb][4*prb];
for (int idx=0; idx<8; idx++) {
r_re_ext_p[idx<<1]=rp[aa][prb*24+6*idx];
r_im_ext_p[idx<<1]=rp[aa][prb*24+1+6*idx];
rd_re_ext_p[idx]=rp[aa][prb*24+2+6*idx];
rd_im_ext_p[idx]=rp[aa][prb*24+3+6*idx];
r_re_ext_p[1+(idx<<1)]=rp[aa][prb*24+4+6*idx];
r_im_ext_p[1+(idx<<1)]=rp[aa][prb*24+5+6*idx];
r_re_ext_p[idx<<1]=rp[aa][symb][prb*24+6*idx];
r_im_ext_p[idx<<1]=rp[aa][symb][prb*24+1+6*idx];
rd_re_ext_p[idx]=rp[aa][symb][prb*24+2+6*idx];
rd_im_ext_p[idx]=rp[aa][symb][prb*24+3+6*idx];
r_re_ext_p[1+(idx<<1)]=rp[aa][symb][prb*24+4+6*idx];
r_im_ext_p[1+(idx<<1)]=rp[aa][symb][prb*24+5+6*idx];
}
#ifdef DEBUG_NR_PUCCH_RX
for (int i=0;i<8;i++) printf("Ant %d PRB %d dmrs[%d] -> (%d,%d)\n",aa,prb+(i>>2),i,rd_re_ext_p[i],rd_im_ext_p[i]);
for (int i=0;i<16;i++) printf("Ant %d PRB %d data[%d] -> (%d,%d)\n",aa,prb+(i>>3),i,r_re_ext_p[i],r_im_ext_p[i]);
for (int i=0;i<8;i++) printf("Ant %d PRB %d dmrs[%d] -> (%d,%d)\n",aa,prb+(i>>2),i,rd_re_ext_p[i],rd_im_ext_p[i]);
for (int i=0;i<16;i++) printf("Ant %d PRB %d data[%d] -> (%d,%d)\n",aa,prb+(i>>3),i,r_re_ext_p[i],r_im_ext_p[i]);
#endif
} // aa
} // prb
// first compute DMRS component
uint32_t x1, x2, s=0;
x2 = (((1<<17)*((14*slot) + (pucch_pdu->start_symbol_index) + 1)*((2*pucch_pdu->dmrs_scrambling_id) + 1)) + (2*pucch_pdu->dmrs_scrambling_id))%(1U<<31); // c_init calculation according to TS38.211 subclause
x2 = (((1<<17)*((14*slot) + (pucch_pdu->start_symbol_index+symb) + 1)*((2*pucch_pdu->dmrs_scrambling_id) + 1)) + (2*pucch_pdu->dmrs_scrambling_id))%(1U<<31); // c_init calculation according to TS38.211 subclause
#ifdef DEBUG_NR_PUCCH_RX
printf("slot %d, start_symbol_index %d, dmrs_scrambling_id %d\n",
slot,pucch_pdu->start_symbol_index,pucch_pdu->dmrs_scrambling_id);
printf("slot %d, start_symbol_index %d, symbol %d, dmrs_scrambling_id %d\n",
slot,pucch_pdu->start_symbol_index,symb,pucch_pdu->dmrs_scrambling_id);
#endif
int reset = 1;
for (int i=0; i<=(pucch_pdu->prb_start>>2); i++) {
......@@ -1183,77 +1236,74 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
dmrs_im = byte2m64_im[((uint8_t*)&s)[(group&1)<<1]];
#ifdef DEBUG_NR_PUCCH_RX
printf("Group %d: s %x x2 %x ((%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
group,
((uint16_t*)&s)[0],x2,
((int16_t*)&dmrs_re)[0],((int16_t*)&dmrs_im)[0],
((int16_t*)&dmrs_re)[1],((int16_t*)&dmrs_im)[1],
((int16_t*)&dmrs_re)[2],((int16_t*)&dmrs_im)[2],
((int16_t*)&dmrs_re)[3],((int16_t*)&dmrs_im)[3]);
group,
((uint16_t*)&s)[0],x2,
((int16_t*)&dmrs_re)[0],((int16_t*)&dmrs_im)[0],
((int16_t*)&dmrs_re)[1],((int16_t*)&dmrs_im)[1],
((int16_t*)&dmrs_re)[2],((int16_t*)&dmrs_im)[2],
((int16_t*)&dmrs_re)[3],((int16_t*)&dmrs_im)[3]);
#endif
for (int aa=0;aa<Prx;aa++) {
rd_re_ext_p=&rd_re_ext[aa][8*group];
rd_im_ext_p=&rd_im_ext[aa][8*group];
rd_re_ext_p=&rd_re_ext[aa][symb][8*group];
rd_im_ext_p=&rd_im_ext[aa][symb][8*group];
#ifdef DEBUG_NR_PUCCH_RX
printf("Group %d: rd ((%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
group,
rd_re_ext_p[0],rd_im_ext_p[0],
rd_re_ext_p[1],rd_im_ext_p[1],
rd_re_ext_p[2],rd_im_ext_p[2],
rd_re_ext_p[3],rd_im_ext_p[3]);
printf("Group %d: rd ((%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
group,
rd_re_ext_p[0],rd_im_ext_p[0],
rd_re_ext_p[1],rd_im_ext_p[1],
rd_re_ext_p[2],rd_im_ext_p[2],
rd_re_ext_p[3],rd_im_ext_p[3]);
#endif
corr32_re[group][aa]+=(rd_re_ext_p[0]*((int16_t*)&dmrs_re)[0] + rd_im_ext_p[0]*((int16_t*)&dmrs_im)[0]);
corr32_im[group][aa]+=(-rd_re_ext_p[0]*((int16_t*)&dmrs_im)[0] + rd_im_ext_p[0]*((int16_t*)&dmrs_re)[0]);
corr32_re[group][aa]+=(rd_re_ext_p[1]*((int16_t*)&dmrs_re)[1] + rd_im_ext_p[1]*((int16_t*)&dmrs_im)[1]);
corr32_im[group][aa]+=(-rd_re_ext_p[1]*((int16_t*)&dmrs_im)[1] + rd_im_ext_p[1]*((int16_t*)&dmrs_re)[1]);
corr32_re[group][aa]+=(rd_re_ext_p[2]*((int16_t*)&dmrs_re)[2] + rd_im_ext_p[2]*((int16_t*)&dmrs_im)[2]);
corr32_im[group][aa]+=(-rd_re_ext_p[2]*((int16_t*)&dmrs_im)[2] + rd_im_ext_p[2]*((int16_t*)&dmrs_re)[2]);
corr32_re[group][aa]+=(rd_re_ext_p[3]*((int16_t*)&dmrs_re)[3] + rd_im_ext_p[3]*((int16_t*)&dmrs_im)[3]);
corr32_im[group][aa]+=(-rd_re_ext_p[3]*((int16_t*)&dmrs_im)[3] + rd_im_ext_p[3]*((int16_t*)&dmrs_re)[3]);
corr32_re[symb][group][aa]+=(rd_re_ext_p[0]*((int16_t*)&dmrs_re)[0] + rd_im_ext_p[0]*((int16_t*)&dmrs_im)[0]);
corr32_im[symb][group][aa]+=(-rd_re_ext_p[0]*((int16_t*)&dmrs_im)[0] + rd_im_ext_p[0]*((int16_t*)&dmrs_re)[0]);
corr32_re[symb][group][aa]+=(rd_re_ext_p[1]*((int16_t*)&dmrs_re)[1] + rd_im_ext_p[1]*((int16_t*)&dmrs_im)[1]);
corr32_im[symb][group][aa]+=(-rd_re_ext_p[1]*((int16_t*)&dmrs_im)[1] + rd_im_ext_p[1]*((int16_t*)&dmrs_re)[1]);
corr32_re[symb][group][aa]+=(rd_re_ext_p[2]*((int16_t*)&dmrs_re)[2] + rd_im_ext_p[2]*((int16_t*)&dmrs_im)[2]);
corr32_im[symb][group][aa]+=(-rd_re_ext_p[2]*((int16_t*)&dmrs_im)[2] + rd_im_ext_p[2]*((int16_t*)&dmrs_re)[2]);
corr32_re[symb][group][aa]+=(rd_re_ext_p[3]*((int16_t*)&dmrs_re)[3] + rd_im_ext_p[3]*((int16_t*)&dmrs_im)[3]);
corr32_im[symb][group][aa]+=(-rd_re_ext_p[3]*((int16_t*)&dmrs_im)[3] + rd_im_ext_p[3]*((int16_t*)&dmrs_re)[3]);
}
dmrs_re = byte2m64_re[((uint8_t*)&s)[1+((group&1)<<1)]];
dmrs_im = byte2m64_im[((uint8_t*)&s)[1+((group&1)<<1)]];
#ifdef DEBUG_NR_PUCCH_RX
printf("Group %d: s %x ((%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
group,
((uint16_t*)&s)[1],
((int16_t*)&dmrs_re)[0],((int16_t*)&dmrs_im)[0],
((int16_t*)&dmrs_re)[1],((int16_t*)&dmrs_im)[1],
((int16_t*)&dmrs_re)[2],((int16_t*)&dmrs_im)[2],
((int16_t*)&dmrs_re)[3],((int16_t*)&dmrs_im)[3]);
group,
((uint16_t*)&s)[1],
((int16_t*)&dmrs_re)[0],((int16_t*)&dmrs_im)[0],
((int16_t*)&dmrs_re)[1],((int16_t*)&dmrs_im)[1],
((int16_t*)&dmrs_re)[2],((int16_t*)&dmrs_im)[2],
((int16_t*)&dmrs_re)[3],((int16_t*)&dmrs_im)[3]);
#endif
for (int aa=0;aa<Prx;aa++) {
rd_re_ext_p=&rd_re_ext[aa][8*group];
rd_im_ext_p=&rd_im_ext[aa][8*group];
rd_re_ext_p=&rd_re_ext[aa][symb][8*group];
rd_im_ext_p=&rd_im_ext[aa][symb][8*group];
#ifdef DEBUG_NR_PUCCH_RX
printf("Group %d: rd ((%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
group,
rd_re_ext_p[4],rd_im_ext_p[4],
rd_re_ext_p[5],rd_im_ext_p[5],
rd_re_ext_p[6],rd_im_ext_p[6],
rd_re_ext_p[7],rd_im_ext_p[7]);
printf("Group %d: rd ((%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
group,
rd_re_ext_p[4],rd_im_ext_p[4],
rd_re_ext_p[5],rd_im_ext_p[5],
rd_re_ext_p[6],rd_im_ext_p[6],
rd_re_ext_p[7],rd_im_ext_p[7]);
#endif
corr32_re[group][aa]+=(rd_re_ext_p[4]*((int16_t*)&dmrs_re)[0] + rd_im_ext_p[4]*((int16_t*)&dmrs_im)[0]);
corr32_im[group][aa]+=(-rd_re_ext_p[4]*((int16_t*)&dmrs_im)[0] + rd_im_ext_p[4]*((int16_t*)&dmrs_re)[0]);
corr32_re[group][aa]+=(rd_re_ext_p[5]*((int16_t*)&dmrs_re)[1] + rd_im_ext_p[5]*((int16_t*)&dmrs_im)[1]);
corr32_im[group][aa]+=(-rd_re_ext_p[5]*((int16_t*)&dmrs_im)[1] + rd_im_ext_p[5]*((int16_t*)&dmrs_re)[1]);
corr32_re[group][aa]+=(rd_re_ext_p[6]*((int16_t*)&dmrs_re)[2] + rd_im_ext_p[6]*((int16_t*)&dmrs_im)[2]);
corr32_im[group][aa]+=(-rd_re_ext_p[6]*((int16_t*)&dmrs_im)[2] + rd_im_ext_p[6]*((int16_t*)&dmrs_re)[2]);
corr32_re[group][aa]+=(rd_re_ext_p[7]*((int16_t*)&dmrs_re)[3] + rd_im_ext_p[7]*((int16_t*)&dmrs_im)[3]);
corr32_im[group][aa]+=(-rd_re_ext_p[7]*((int16_t*)&dmrs_im)[3] + rd_im_ext_p[7]*((int16_t*)&dmrs_re)[3]);
corr32_re[group][aa]>>=5;
corr32_im[group][aa]>>=5;
corr32_re[symb][group][aa]+=(rd_re_ext_p[4]*((int16_t*)&dmrs_re)[0] + rd_im_ext_p[4]*((int16_t*)&dmrs_im)[0]);
corr32_im[symb][group][aa]+=(-rd_re_ext_p[4]*((int16_t*)&dmrs_im)[0] + rd_im_ext_p[4]*((int16_t*)&dmrs_re)[0]);
corr32_re[symb][group][aa]+=(rd_re_ext_p[5]*((int16_t*)&dmrs_re)[1] + rd_im_ext_p[5]*((int16_t*)&dmrs_im)[1]);
corr32_im[symb][group][aa]+=(-rd_re_ext_p[5]*((int16_t*)&dmrs_im)[1] + rd_im_ext_p[5]*((int16_t*)&dmrs_re)[1]);
corr32_re[symb][group][aa]+=(rd_re_ext_p[6]*((int16_t*)&dmrs_re)[2] + rd_im_ext_p[6]*((int16_t*)&dmrs_im)[2]);
corr32_im[symb][group][aa]+=(-rd_re_ext_p[6]*((int16_t*)&dmrs_im)[2] + rd_im_ext_p[6]*((int16_t*)&dmrs_re)[2]);
corr32_re[symb][group][aa]+=(rd_re_ext_p[7]*((int16_t*)&dmrs_re)[3] + rd_im_ext_p[7]*((int16_t*)&dmrs_im)[3]);
corr32_im[symb][group][aa]+=(-rd_re_ext_p[7]*((int16_t*)&dmrs_im)[3] + rd_im_ext_p[7]*((int16_t*)&dmrs_re)[3]);
/* corr32_re[group][aa]>>=5;
corr32_im[group][aa]>>=5;*/
#ifdef DEBUG_NR_PUCCH_RX
printf("Group %d: corr32 (%d,%d)\n",group,corr32_re[group][aa],corr32_im[group][aa]);
printf("Group %d: corr32 (%d,%d)\n",group,corr32_re[symb][group][aa],corr32_im[symb][group][aa]);
#endif
} //aa
if ((group&1) == 1) s = lte_gold_generic(&x1, &x2, 0);
} // group
}
else { // 2 symbol case
AssertFatal(1==0, "Fill in 2 symbol PUCCH2 case\n");
}
} // symb
uint32_t x1, x2, s=0;
// unscrambling
......@@ -1262,112 +1312,114 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
#ifdef DEBUG_NR_PUCCH_RX
printf("x2 %x, s %x\n",x2,s);
#endif
__m64 c_re0,c_im0,c_re1,c_im1,c_re2,c_im2,c_re3,c_im3;
re_offset=0;
for (int prb=0;prb<pucch_pdu->prb_size;prb+=2,re_offset+=16) {
c_re0 = byte2m64_re[((uint8_t*)&s)[0]];
c_im0 = byte2m64_im[((uint8_t*)&s)[0]];
c_re1 = byte2m64_re[((uint8_t*)&s)[1]];
c_im1 = byte2m64_im[((uint8_t*)&s)[1]];
c_re2 = byte2m64_re[((uint8_t*)&s)[2]];
c_im2 = byte2m64_im[((uint8_t*)&s)[2]];
c_re3 = byte2m64_re[((uint8_t*)&s)[3]];
c_im3 = byte2m64_im[((uint8_t*)&s)[3]];
for (int symb=0;symb<pucch_pdu->nr_of_symbols;symb++) {
__m64 c_re0,c_im0,c_re1,c_im1,c_re2,c_im2,c_re3,c_im3;
int re_off=0;
for (int prb=0;prb<prb_size_ext;prb+=2,re_off+=16) {
c_re0 = byte2m64_re[((uint8_t*)&s)[0]];
c_im0 = byte2m64_im[((uint8_t*)&s)[0]];
c_re1 = byte2m64_re[((uint8_t*)&s)[1]];
c_im1 = byte2m64_im[((uint8_t*)&s)[1]];
c_re2 = byte2m64_re[((uint8_t*)&s)[2]];
c_im2 = byte2m64_im[((uint8_t*)&s)[2]];
c_re3 = byte2m64_re[((uint8_t*)&s)[3]];
c_im3 = byte2m64_im[((uint8_t*)&s)[3]];
for (int aa=0;aa<Prx;aa++) {
for (int aa=0;aa<Prx;aa++) {
#ifdef DEBUG_NR_PUCCH_RX
printf("prb %d: rd ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb,
r_re_ext[aa][re_offset],r_im_ext[aa][re_offset],
r_re_ext[aa][re_offset+1],r_im_ext[aa][re_offset+1],
r_re_ext[aa][re_offset+2],r_im_ext[aa][re_offset+2],
r_re_ext[aa][re_offset+3],r_im_ext[aa][re_offset+3],
r_re_ext[aa][re_offset+4],r_im_ext[aa][re_offset+4],
r_re_ext[aa][re_offset+5],r_im_ext[aa][re_offset+5],
r_re_ext[aa][re_offset+6],r_im_ext[aa][re_offset+6],
r_re_ext[aa][re_offset+7],r_im_ext[aa][re_offset+7]);
printf("prb %d (%x): c ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb,s,
((int16_t*)&c_re0)[0],((int16_t*)&c_im0)[0],
((int16_t*)&c_re0)[1],((int16_t*)&c_im0)[1],
((int16_t*)&c_re0)[2],((int16_t*)&c_im0)[2],
((int16_t*)&c_re0)[3],((int16_t*)&c_im0)[3],
((int16_t*)&c_re1)[0],((int16_t*)&c_im1)[0],
((int16_t*)&c_re1)[1],((int16_t*)&c_im1)[1],
((int16_t*)&c_re1)[2],((int16_t*)&c_im1)[2],
((int16_t*)&c_re1)[3],((int16_t*)&c_im1)[3]
);
printf("prb %d: rd ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb+1,
r_re_ext[aa][re_offset+8],r_im_ext[aa][re_offset+8],
r_re_ext[aa][re_offset+9],r_im_ext[aa][re_offset+9],
r_re_ext[aa][re_offset+10],r_im_ext[aa][re_offset+10],
r_re_ext[aa][re_offset+11],r_im_ext[aa][re_offset+11],
r_re_ext[aa][re_offset+12],r_im_ext[aa][re_offset+12],
r_re_ext[aa][re_offset+13],r_im_ext[aa][re_offset+13],
r_re_ext[aa][re_offset+14],r_im_ext[aa][re_offset+14],
r_re_ext[aa][re_offset+15],r_im_ext[aa][re_offset+15]);
printf("prb %d (%x): c ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb+1,s,
((int16_t*)&c_re2)[0],((int16_t*)&c_im2)[0],
((int16_t*)&c_re2)[1],((int16_t*)&c_im2)[1],
((int16_t*)&c_re2)[2],((int16_t*)&c_im2)[2],
((int16_t*)&c_re2)[3],((int16_t*)&c_im2)[3],
((int16_t*)&c_re3)[0],((int16_t*)&c_im3)[0],
((int16_t*)&c_re3)[1],((int16_t*)&c_im3)[1],
((int16_t*)&c_re3)[2],((int16_t*)&c_im3)[2],
((int16_t*)&c_re3)[3],((int16_t*)&c_im3)[3]
);
printf("prb %d: rd ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb,
r_re_ext[aa][symb][re_off],r_im_ext[aa][symb][re_off],
r_re_ext[aa][symb][re_off+1],r_im_ext[aa][symb][re_off+1],
r_re_ext[aa][symb][re_off+2],r_im_ext[aa][symb][re_off+2],
r_re_ext[aa][symb][re_off+3],r_im_ext[aa][symb][re_off+3],
r_re_ext[aa][symb][re_off+4],r_im_ext[aa][symb][re_off+4],
r_re_ext[aa][symb][re_off+5],r_im_ext[aa][symb][re_off+5],
r_re_ext[aa][symb][re_off+6],r_im_ext[aa][symb][re_off+6],
r_re_ext[aa][symb][re_off+7],r_im_ext[aa][symb][re_off+7]);
printf("prb %d (%x): c ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb,s,
((int16_t*)&c_re0)[0],((int16_t*)&c_im0)[0],
((int16_t*)&c_re0)[1],((int16_t*)&c_im0)[1],
((int16_t*)&c_re0)[2],((int16_t*)&c_im0)[2],
((int16_t*)&c_re0)[3],((int16_t*)&c_im0)[3],
((int16_t*)&c_re1)[0],((int16_t*)&c_im1)[0],
((int16_t*)&c_re1)[1],((int16_t*)&c_im1)[1],
((int16_t*)&c_re1)[2],((int16_t*)&c_im1)[2],
((int16_t*)&c_re1)[3],((int16_t*)&c_im1)[3]
);
printf("prb %d: rd ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb+1,
r_re_ext[aa][symb][re_off+8],r_im_ext[aa][symb][re_off+8],
r_re_ext[aa][symb][re_off+9],r_im_ext[aa][symb][re_off+9],
r_re_ext[aa][symb][re_off+10],r_im_ext[aa][symb][re_off+10],
r_re_ext[aa][symb][re_off+11],r_im_ext[aa][symb][re_off+11],
r_re_ext[aa][symb][re_off+12],r_im_ext[aa][symb][re_off+12],
r_re_ext[aa][symb][re_off+13],r_im_ext[aa][symb][re_off+13],
r_re_ext[aa][symb][re_off+14],r_im_ext[aa][symb][re_off+14],
r_re_ext[aa][symb][re_off+15],r_im_ext[aa][symb][re_off+15]);
printf("prb %d (%x): c ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb+1,s,
((int16_t*)&c_re2)[0],((int16_t*)&c_im2)[0],
((int16_t*)&c_re2)[1],((int16_t*)&c_im2)[1],
((int16_t*)&c_re2)[2],((int16_t*)&c_im2)[2],
((int16_t*)&c_re2)[3],((int16_t*)&c_im2)[3],
((int16_t*)&c_re3)[0],((int16_t*)&c_im3)[0],
((int16_t*)&c_re3)[1],((int16_t*)&c_im3)[1],
((int16_t*)&c_re3)[2],((int16_t*)&c_im3)[2],
((int16_t*)&c_re3)[3],((int16_t*)&c_im3)[3]
);
#endif
((__m64*)&r_re_ext2[aa][re_offset])[0] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][re_offset])[0],c_im0);
((__m64*)&r_re_ext[aa][re_offset])[0] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][re_offset])[0],c_re0);
((__m64*)&r_im_ext2[aa][re_offset])[0] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][re_offset])[0],c_re0);
((__m64*)&r_im_ext[aa][re_offset])[0] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][re_offset])[0],c_im0);
((__m64*)&r_re_ext2[aa][symb][re_off])[0] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][symb][re_off])[0],c_im0);
((__m64*)&r_re_ext[aa][symb][re_off])[0] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][symb][re_off])[0],c_re0);
((__m64*)&r_im_ext2[aa][symb][re_off])[0] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][symb][re_off])[0],c_re0);
((__m64*)&r_im_ext[aa][symb][re_off])[0] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][symb][re_off])[0],c_im0);
((__m64*)&r_re_ext2[aa][re_offset])[1] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][re_offset])[1],c_im1);
((__m64*)&r_re_ext[aa][re_offset])[1] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][re_offset])[1],c_re1);
((__m64*)&r_im_ext2[aa][re_offset])[1] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][re_offset])[1],c_re1);
((__m64*)&r_im_ext[aa][re_offset])[1] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][re_offset])[1],c_im1);
((__m64*)&r_re_ext2[aa][symb][re_off])[1] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][symb][re_off])[1],c_im1);
((__m64*)&r_re_ext[aa][symb][re_off])[1] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][symb][re_off])[1],c_re1);
((__m64*)&r_im_ext2[aa][symb][re_off])[1] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][symb][re_off])[1],c_re1);
((__m64*)&r_im_ext[aa][symb][re_off])[1] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][symb][re_off])[1],c_im1);
((__m64*)&r_re_ext2[aa][re_offset])[2] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][re_offset])[2],c_im2);
((__m64*)&r_re_ext[aa][re_offset])[2] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][re_offset])[2],c_re2);
((__m64*)&r_im_ext2[aa][re_offset])[2] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][re_offset])[2],c_re2);
((__m64*)&r_im_ext[aa][re_offset])[2] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][re_offset])[2],c_im2);
((__m64*)&r_re_ext2[aa][symb][re_off])[2] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][symb][re_off])[2],c_im2);
((__m64*)&r_re_ext[aa][symb][re_off])[2] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][symb][re_off])[2],c_re2);
((__m64*)&r_im_ext2[aa][symb][re_off])[2] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][symb][re_off])[2],c_re2);
((__m64*)&r_im_ext[aa][symb][re_off])[2] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][symb][re_off])[2],c_im2);
((__m64*)&r_re_ext2[aa][re_offset])[3] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][re_offset])[3],c_im3);
((__m64*)&r_re_ext[aa][re_offset])[3] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][re_offset])[3],c_re3);
((__m64*)&r_im_ext2[aa][re_offset])[3] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][re_offset])[3],c_re3);
((__m64*)&r_im_ext[aa][re_offset])[3] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][re_offset])[3],c_im3);
((__m64*)&r_re_ext2[aa][symb][re_off])[3] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][symb][re_off])[3],c_im3);
((__m64*)&r_re_ext[aa][symb][re_off])[3] = _mm_mullo_pi16(((__m64*)&r_re_ext[aa][symb][re_off])[3],c_re3);
((__m64*)&r_im_ext2[aa][symb][re_off])[3] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][symb][re_off])[3],c_re3);
((__m64*)&r_im_ext[aa][symb][re_off])[3] = _mm_mullo_pi16(((__m64*)&r_im_ext[aa][symb][re_off])[3],c_im3);
#ifdef DEBUG_NR_PUCCH_RX
printf("prb %d: r ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb,
r_re_ext[aa][re_offset],r_im_ext[aa][re_offset],
r_re_ext[aa][re_offset+1],r_im_ext[aa][re_offset+1],
r_re_ext[aa][re_offset+2],r_im_ext[aa][re_offset+2],
r_re_ext[aa][re_offset+3],r_im_ext[aa][re_offset+3],
r_re_ext[aa][re_offset+4],r_im_ext[aa][re_offset+4],
r_re_ext[aa][re_offset+5],r_im_ext[aa][re_offset+5],
r_re_ext[aa][re_offset+6],r_im_ext[aa][re_offset+6],
r_re_ext[aa][re_offset+7],r_im_ext[aa][re_offset+7]);
printf("prb %d: r ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb+1,
r_re_ext[aa][re_offset+8],r_im_ext[aa][re_offset+8],
r_re_ext[aa][re_offset+9],r_im_ext[aa][re_offset+9],
r_re_ext[aa][re_offset+10],r_im_ext[aa][re_offset+10],
r_re_ext[aa][re_offset+11],r_im_ext[aa][re_offset+11],
r_re_ext[aa][re_offset+12],r_im_ext[aa][re_offset+12],
r_re_ext[aa][re_offset+13],r_im_ext[aa][re_offset+13],
r_re_ext[aa][re_offset+14],r_im_ext[aa][re_offset+14],
r_re_ext[aa][re_offset+15],r_im_ext[aa][re_offset+15]);
printf("prb %d: r ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb,
r_re_ext[aa][symb][re_off],r_im_ext[aa][symb][re_off],
r_re_ext[aa][symb][re_off+1],r_im_ext[aa][symb][re_off+1],
r_re_ext[aa][symb][re_off+2],r_im_ext[aa][symb][re_off+2],
r_re_ext[aa][symb][re_off+3],r_im_ext[aa][symb][re_off+3],
r_re_ext[aa][symb][re_off+4],r_im_ext[aa][symb][re_off+4],
r_re_ext[aa][symb][re_off+5],r_im_ext[aa][symb][re_off+5],
r_re_ext[aa][symb][re_off+6],r_im_ext[aa][symb][re_off+6],
r_re_ext[aa][symb][re_off+7],r_im_ext[aa][symb][re_off+7]);
printf("prb %d: r ((%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
prb+1,
r_re_ext[aa][symb][re_off+8],r_im_ext[aa][symb][re_off+8],
r_re_ext[aa][symb][re_off+9],r_im_ext[aa][symb][re_off+9],
r_re_ext[aa][symb][re_off+10],r_im_ext[aa][symb][re_off+10],
r_re_ext[aa][symb][re_off+11],r_im_ext[aa][symb][re_off+11],
r_re_ext[aa][symb][re_off+12],r_im_ext[aa][symb][re_off+12],
r_re_ext[aa][symb][re_off+13],r_im_ext[aa][symb][re_off+13],
r_re_ext[aa][symb][re_off+14],r_im_ext[aa][symb][re_off+14],
r_re_ext[aa][symb][re_off+15],r_im_ext[aa][symb][re_off+15]);
#endif
}
s = lte_gold_generic(&x1, &x2, 0);
}
s = lte_gold_generic(&x1, &x2, 0);
#ifdef DEBUG_NR_PUCCH_RX
printf("\n");
printf("\n");
#endif
}
}
} //symb
int nb_bit = pucch_pdu->bit_len_harq+pucch_pdu->sr_flag+pucch_pdu->bit_len_csi_part1+pucch_pdu->bit_len_csi_part2;
AssertFatal(nb_bit > 2 && nb_bit< 65,"illegal length (%d : %d,%d,%d,%d)\n",nb_bit,pucch_pdu->bit_len_harq,pucch_pdu->sr_flag,pucch_pdu->bit_len_csi_part1,pucch_pdu->bit_len_csi_part2);
......@@ -1375,15 +1427,17 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
uint8_t corr_dB;
int decoderState=2;
if (nb_bit < 12) { // short blocklength case
__m256i *rp_re[Prx2];
__m256i *rp2_re[Prx2];
__m256i *rp_im[Prx2];
__m256i *rp2_im[Prx2];
__m256i *rp_re[Prx2][2];
__m256i *rp2_re[Prx2][2];
__m256i *rp_im[Prx2][2];
__m256i *rp2_im[Prx2][2];
for (int aa=0;aa<Prx;aa++) {
rp_re[aa] = (__m256i*)r_re_ext[aa];
rp_im[aa] = (__m256i*)r_im_ext[aa];
rp2_re[aa] = (__m256i*)r_re_ext2[aa];
rp2_im[aa] = (__m256i*)r_im_ext2[aa];
for (int symb=0;symb<pucch_pdu->nr_of_symbols;symb++) {
rp_re[aa][symb] = (__m256i*)r_re_ext[aa][symb];
rp_im[aa][symb] = (__m256i*)r_im_ext[aa][symb];
rp2_re[aa][symb] = (__m256i*)r_re_ext2[aa][symb];
rp2_im[aa][symb] = (__m256i*)r_im_ext2[aa][symb];
}
}
__m256i prod_re[Prx2],prod_im[Prx2];
uint64_t corr=0;
......@@ -1402,76 +1456,91 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
#endif
uint64_t corr_tmp = 0;
for (int group=0;group<ngroup;group++) {
// do complex correlation
for (int aa=0;aa<Prx;aa++) {
prod_re[aa] = _mm256_srai_epi16(_mm256_adds_epi16(_mm256_mullo_epi16(pucch2_lut[nb_bit-3][cw<<1],rp_re[aa][group]),
_mm256_mullo_epi16(pucch2_lut[nb_bit-3][(cw<<1)+1],rp_im[aa][group])),5);
prod_im[aa] = _mm256_srai_epi16(_mm256_subs_epi16(_mm256_mullo_epi16(pucch2_lut[nb_bit-3][cw<<1],rp2_im[aa][group]),
_mm256_mullo_epi16(pucch2_lut[nb_bit-3][(cw<<1)+1],rp2_re[aa][group])),5);
for (int symb=0;symb<pucch_pdu->nr_of_symbols;symb++) {
for (int group=0;group<ngroup;group++) {
// do complex correlation
for (int aa=0;aa<Prx;aa++) {
prod_re[aa] = /*_mm256_srai_epi16(*/_mm256_adds_epi16(_mm256_mullo_epi16(pucch2_lut[nb_bit-3][cw<<1],rp_re[aa][symb][group]),
_mm256_mullo_epi16(pucch2_lut[nb_bit-3][(cw<<1)+1],rp_im[aa][symb][group]))/*,5)*/;
prod_im[aa] = /*_mm256_srai_epi16(*/_mm256_subs_epi16(_mm256_mullo_epi16(pucch2_lut[nb_bit-3][cw<<1],rp2_im[aa][symb][group]),
_mm256_mullo_epi16(pucch2_lut[nb_bit-3][(cw<<1)+1],rp2_re[aa][symb][group]))/*,5)*/;
#ifdef DEBUG_NR_PUCCH_RX
printf("prod_re[%d] => (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",aa,
((int16_t*)&prod_re[aa])[0],((int16_t*)&prod_re[aa])[1],((int16_t*)&prod_re[aa])[2],((int16_t*)&prod_re[aa])[3],
((int16_t*)&prod_re[aa])[4],((int16_t*)&prod_re[aa])[5],((int16_t*)&prod_re[aa])[6],((int16_t*)&prod_re[aa])[7],
((int16_t*)&prod_re[aa])[8],((int16_t*)&prod_re[aa])[9],((int16_t*)&prod_re[aa])[10],((int16_t*)&prod_re[aa])[11],
((int16_t*)&prod_re[aa])[12],((int16_t*)&prod_re[aa])[13],((int16_t*)&prod_re[aa])[14],((int16_t*)&prod_re[aa])[15]);
printf("prod_im[%d] => (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",aa,
((int16_t*)&prod_im[aa])[0],((int16_t*)&prod_im[aa])[1],((int16_t*)&prod_im[aa])[2],((int16_t*)&prod_im[aa])[3],
((int16_t*)&prod_im[aa])[4],((int16_t*)&prod_im[aa])[5],((int16_t*)&prod_im[aa])[6],((int16_t*)&prod_im[aa])[7],
((int16_t*)&prod_im[aa])[8],((int16_t*)&prod_im[aa])[9],((int16_t*)&prod_im[aa])[10],((int16_t*)&prod_im[aa])[11],
((int16_t*)&prod_im[aa])[12],((int16_t*)&prod_im[aa])[13],((int16_t*)&prod_im[aa])[14],((int16_t*)&prod_im[aa])[15]);
printf("prod_re[%d] => (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\n",aa,
((int16_t*)&prod_re[aa])[0],((int16_t*)&prod_re[aa])[1],((int16_t*)&prod_re[aa])[2],((int16_t*)&prod_re[aa])[3],
((int16_t*)&prod_re[aa])[4],((int16_t*)&prod_re[aa])[5],((int16_t*)&prod_re[aa])[6],((int16_t*)&prod_re[aa])[7],
((int16_t*)&prod_re[aa])[8],((int16_t*)&prod_re[aa])[9],((int16_t*)&prod_re[aa])[10],((int16_t*)&prod_re[aa])[11],
((int16_t*)&prod_re[aa])[12],((int16_t*)&prod_re[aa])[13],((int16_t*)&prod_re[aa])[14],((int16_t*)&prod_re[aa])[15]);
printf("prod_im[%d] => (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\n",aa,
((int16_t*)&prod_im[aa])[0],((int16_t*)&prod_im[aa])[1],((int16_t*)&prod_im[aa])[2],((int16_t*)&prod_im[aa])[3],
((int16_t*)&prod_im[aa])[4],((int16_t*)&prod_im[aa])[5],((int16_t*)&prod_im[aa])[6],((int16_t*)&prod_im[aa])[7],
((int16_t*)&prod_im[aa])[8],((int16_t*)&prod_im[aa])[9],((int16_t*)&prod_im[aa])[10],((int16_t*)&prod_im[aa])[11],
((int16_t*)&prod_im[aa])[12],((int16_t*)&prod_im[aa])[13],((int16_t*)&prod_im[aa])[14],((int16_t*)&prod_im[aa])[15]);
#endif
prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1
prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]);
prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3
prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]);
prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3+4+5+6+7
prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]);
prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15
prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]);
}
int64_t corr_re=0,corr_im=0;
for (int aa=0;aa<Prx;aa++) {
LOG_D(PHY,"pucch2 cw %d group %d aa %d: (%d,%d)+(%d,%d) = (%d,%d)\n",cw,group,aa,
corr32_re[group][aa],corr32_im[group][aa],
((int16_t*)(&prod_re[aa]))[0],
((int16_t*)(&prod_im[aa]))[0],
corr32_re[group][aa]+((int16_t*)(&prod_re[aa]))[0],
corr32_im[group][aa]+((int16_t*)(&prod_im[aa]))[0]);
corr_re = ( corr32_re[group][aa]+((int16_t*)(&prod_re[aa]))[0]);
corr_im = ( corr32_im[group][aa]+((int16_t*)(&prod_im[aa]))[0]);
corr_tmp += corr_re*corr_re + corr_im*corr_im;
} // aa loop
}// group loop
LOG_D(PHY,"cw %d, metric %f dB\n",cw,10*log10(corr_tmp));
prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1
prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]);
prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3
prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]);
prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3+4+5+6+7
prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]);
prod_re[aa] = _mm256_hadds_epi16(prod_re[aa],prod_re[aa]);// 0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15
prod_im[aa] = _mm256_hadds_epi16(prod_im[aa],prod_im[aa]);
}
int64_t corr_re=0,corr_im=0;
for (int aa=0;aa<Prx;aa++) {
#ifdef DEBUG_NR_PUCCH_RX
printf("pucch2 cw %d group %d aa %d: (%d,%d)+(%d,%d) = (%d,%d)\n",cw,group,aa,
corr32_re[symb][group][aa],corr32_im[symb][group][aa],
((int16_t*)(&prod_re[aa]))[0],
((int16_t*)(&prod_im[aa]))[0],
corr32_re[symb][group][aa]+((int16_t*)(&prod_re[aa]))[0],
corr32_im[symb][group][aa]+((int16_t*)(&prod_im[aa]))[0]);
#endif
LOG_D(PHY,"pucch2 cw %d group %d aa %d: (%d,%d)+(%d,%d) = (%d,%d)\n",cw,group,aa,
corr32_re[symb][group][aa],corr32_im[symb][group][aa],
((int16_t*)(&prod_re[aa]))[0],
((int16_t*)(&prod_im[aa]))[0],
corr32_re[symb][group][aa]+((int16_t*)(&prod_re[aa]))[0],
corr32_im[symb][group][aa]+((int16_t*)(&prod_im[aa]))[0]);
corr_re = ( corr32_re[symb][group][aa]+((int16_t*)(&prod_re[aa]))[0]);
corr_im = ( corr32_im[symb][group][aa]+((int16_t*)(&prod_im[aa]))[0]);
corr_tmp += corr_re*corr_re + corr_im*corr_im;
} // aa loop
}// group loop
} // symb loop
if (corr_tmp > corr) {
corr = corr_tmp;
cw_ML=cw;
corr = corr_tmp;
cw_ML=cw;
}
} // cw loop
corr_dB = dB_fixed64((uint64_t)corr);
#ifdef DEBUG_NR_PUCCH_RX
printf("cw_ML %d, metric %d dB\n",cw_ML,corr_dB);
#endif
LOG_D(PHY,"cw_ML %d, metric %d dB\n",cw_ML,corr_dB);
decodedPayload[0]=(uint64_t)cw_ML;
}
else { // polar coded case
t_nrPolar_params *currentPtr = nr_polar_params(2,nb_bit,pucch_pdu->prb_size,1,&gNB->uci_polarParams);
__m64 *rp_re[Prx2];
__m64 *rp2_re[Prx2];
__m64 *rp_im[Prx2];
__m64 *rp2_im[Prx2];
__m128i llrs[pucch_pdu->prb_size*2];
__m64 *rp_re[Prx2][2];
__m64 *rp2_re[Prx2][2];
__m64 *rp_im[Prx2][2];
__m64 *rp2_im[Prx2][2];
__m128i llrs[pucch_pdu->prb_size*2*pucch_pdu->nr_of_symbols];
for (int aa=0;aa<Prx;aa++) {
rp_re[aa] = (__m64*)r_re_ext[aa];
rp_im[aa] = (__m64*)r_im_ext[aa];
rp2_re[aa] = (__m64*)r_re_ext2[aa];
rp2_im[aa] = (__m64*)r_im_ext2[aa];
for (int symb=0;symb<pucch_pdu->nr_of_symbols;symb++) {
rp_re[aa][symb] = (__m64*)r_re_ext[aa][symb];
rp_im[aa][symb] = (__m64*)r_im_ext[aa][symb];
rp2_re[aa][symb] = (__m64*)r_re_ext2[aa][symb];
rp2_im[aa][symb] = (__m64*)r_im_ext2[aa][symb];
}
}
__m64 prod_re[Prx2],prod_im[Prx2];
......@@ -1491,35 +1560,35 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
int32_t corr_re,corr_im,corr_tmp;
__m128i corr16,llr_num,llr_den;
uint64_t corr = 0;
for (int half_prb=0;half_prb<(2*pucch_pdu->prb_size);half_prb++) {
llr_num=_mm_set1_epi16(0);llr_den=_mm_set1_epi16(0);
for (int cw=0;cw<256;cw++) {
corr_tmp=0;
for (int aa=0;aa<Prx;aa++) {
prod_re[aa] = _mm_srai_pi16(_mm_adds_pi16(_mm_mullo_pi16(pucch2_polar_4bit[cw&15],rp_re[aa][half_prb]),
_mm_mullo_pi16(pucch2_polar_4bit[cw>>4],rp_im[aa][half_prb])),5);
prod_im[aa] = _mm_srai_pi16(_mm_subs_pi16(_mm_mullo_pi16(pucch2_polar_4bit[cw&15],rp2_im[aa][half_prb]),
_mm_mullo_pi16(pucch2_polar_4bit[cw>>4],rp2_re[aa][half_prb])),5);
prod_re[aa] = _mm_hadds_pi16(prod_re[aa],prod_re[aa]);// 0+1
prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]);
prod_re[aa] = _mm_hadds_pi16(prod_re[aa],prod_re[aa]);// 0+1+2+3
prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]);
// this is for UL CQI measurement
if (cw==0) corr += ((int64_t)corr32_re[half_prb>>2][aa]*corr32_re[half_prb>>2][aa])+
((int64_t)corr32_im[half_prb>>2][aa]*corr32_im[half_prb>>2][aa]);
corr_re = ( corr32_re[half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_re[aa]))[0]);
corr_im = ( corr32_im[half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_im[aa]))[0]);
corr_tmp += corr_re*corr_re + corr_im*corr_im;
LOG_D(PHY,"pucch2 half_prb %d cw %d (%d,%d) aa %d: (%d,%d,%d,%d,%d,%d,%d,%d)x(%d,%d,%d,%d,%d,%d,%d,%d) (%d,%d)+(%d,%d) = (%d,%d) => %d\n",
half_prb,cw,cw&15,cw>>4,aa,
((int16_t*)&pucch2_polar_4bit[cw&15])[0],((int16_t*)&pucch2_polar_4bit[cw>>4])[0],
((int16_t*)&pucch2_polar_4bit[cw&15])[1],((int16_t*)&pucch2_polar_4bit[cw>>4])[1],
((int16_t*)&pucch2_polar_4bit[cw&15])[2],((int16_t*)&pucch2_polar_4bit[cw>>4])[2],
for (int symb=0;symb<pucch_pdu->nr_of_symbols;symb++) {
for (int half_prb=0;half_prb<(2*pucch_pdu->prb_size);half_prb++) {
llr_num=_mm_set1_epi16(0);llr_den=_mm_set1_epi16(0);
for (int cw=0;cw<256;cw++) {
corr_tmp=0;
for (int aa=0;aa<Prx;aa++) {
prod_re[aa] = _mm_srai_pi16(_mm_adds_pi16(_mm_mullo_pi16(pucch2_polar_4bit[cw&15],rp_re[aa][symb][half_prb]),
_mm_mullo_pi16(pucch2_polar_4bit[cw>>4],rp_im[aa][symb][half_prb])),5);
prod_im[aa] = _mm_srai_pi16(_mm_subs_pi16(_mm_mullo_pi16(pucch2_polar_4bit[cw&15],rp2_im[aa][symb][half_prb]),
_mm_mullo_pi16(pucch2_polar_4bit[cw>>4],rp2_re[aa][symb][half_prb])),5);
prod_re[aa] = _mm_hadds_pi16(prod_re[aa],prod_re[aa]);// 0+1
prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]);
prod_re[aa] = _mm_hadds_pi16(prod_re[aa],prod_re[aa]);// 0+1+2+3
prod_im[aa] = _mm_hadds_pi16(prod_im[aa],prod_im[aa]);
// this is for UL CQI measurement
if (cw==0) corr += ((int64_t)corr32_re[symb][half_prb>>2][aa]*corr32_re[symb][half_prb>>2][aa])+
((int64_t)corr32_im[symb][half_prb>>2][aa]*corr32_im[symb][half_prb>>2][aa]);
corr_re = ( corr32_re[symb][half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_re[aa]))[0]);
corr_im = ( corr32_im[symb][half_prb>>2][aa]/(2*nc_group_size*4/2)+((int16_t*)(&prod_im[aa]))[0]);
corr_tmp += corr_re*corr_re + corr_im*corr_im;
/*
LOG_D(PHY,"pucch2 half_prb %d cw %d (%d,%d) aa %d: (%d,%d,%d,%d,%d,%d,%d,%d)x(%d,%d,%d,%d,%d,%d,%d,%d) (%d,%d)+(%d,%d) = (%d,%d) => %d\n",
half_prb,cw,cw&15,cw>>4,aa,
((int16_t*)&pucch2_polar_4bit[cw&15])[0],((int16_t*)&pucch2_polar_4bit[cw>>4])[0],
((int16_t*)&pucch2_polar_4bit[cw&15])[1],((int16_t*)&pucch2_polar_4bit[cw>>4])[1],
((int16_t*)&pucch2_polar_4bit[cw&15])[2],((int16_t*)&pucch2_polar_4bit[cw>>4])[2],
((int16_t*)&pucch2_polar_4bit[cw&15])[3],((int16_t*)&pucch2_polar_4bit[cw>>4])[3],
((int16_t*)&rp_re[aa][half_prb])[0],((int16_t*)&rp_im[aa][half_prb])[0],
((int16_t*)&rp_re[aa][half_prb])[1],((int16_t*)&rp_im[aa][half_prb])[1],
......@@ -1531,7 +1600,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
corr_re,
corr_im,
corr_tmp);
*/
}
corr16 = _mm_set1_epi16((int16_t)(corr_tmp>>8));
......@@ -1571,18 +1640,19 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
}
// compute llrs
llrs[half_prb] = _mm_subs_epi16(llr_num,llr_den);
LOG_D(PHY,"llrs[%d] : (%d,%d,%d,%d,%d,%d,%d,%d)\n",
half_prb,
((int16_t*)&llrs[half_prb])[0],
((int16_t*)&llrs[half_prb])[1],
((int16_t*)&llrs[half_prb])[2],
((int16_t*)&llrs[half_prb])[3],
((int16_t*)&llrs[half_prb])[4],
((int16_t*)&llrs[half_prb])[5],
((int16_t*)&llrs[half_prb])[6],
((int16_t*)&llrs[half_prb])[7]);
} // half_prb
llrs[half_prb + (symb*2*pucch_pdu->prb_size)] = _mm_subs_epi16(llr_num,llr_den);
LOG_D(PHY,"llrs[%d] : (%d,%d,%d,%d,%d,%d,%d,%d)\n",
half_prb,
((int16_t*)&llrs[half_prb])[0],
((int16_t*)&llrs[half_prb])[1],
((int16_t*)&llrs[half_prb])[2],
((int16_t*)&llrs[half_prb])[3],
((int16_t*)&llrs[half_prb])[4],
((int16_t*)&llrs[half_prb])[5],
((int16_t*)&llrs[half_prb])[6],
((int16_t*)&llrs[half_prb])[7]);
} // half_prb
} // symb
// run polar decoder on llrs
decoderState = polar_decoder_int16((int16_t*)llrs, decodedPayload, 0, currentPtr);
LOG_D(PHY,"UCI decoderState %d, payload[0] %llu\n",decoderState,(unsigned long long)decodedPayload[0]);
......@@ -1591,9 +1661,10 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
LOG_D(PHY,"metric %d dB\n",corr_dB);
}
re_offset = (12*pucch_pdu->prb_start) + (12*pucch_pdu->bwp_start) + frame_parms->first_carrier_offset;
// estimate CQI for MAC (from antenna port 0 only)
int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset],12*pucch_pdu->prb_size)) - (10*gNB->measurements.n0_power_tot_dB);
// estimate CQI for MAC (from antenna port 0 only)
int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]],
12*pucch_pdu->prb_size)) -
(10*gNB->measurements.n0_power_tot_dB);
int cqi,bit_left;
if (SNRtimes10 < -640) cqi=0;
else if (SNRtimes10 > 635) cqi=255;
......@@ -1606,7 +1677,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
uci_pdu->pucch_format=0;
uci_pdu->ul_cqi=cqi;
uci_pdu->timing_advance=0xffff; // currently not valid
uci_pdu->rssi=1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc(&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset],12*pucch_pdu->prb_size)));
uci_pdu->rssi=1280 - (10*dB_fixed(32767*32767)-dB_fixed_times10(signal_energy_nodc(&rxdataF[0][soffset+(l2*frame_parms->ofdm_symbol_size)+re_offset[0]],12*pucch_pdu->prb_size)));
if (pucch_pdu->bit_len_harq>0) {
int harq_bytes=pucch_pdu->bit_len_harq>>3;
if ((pucch_pdu->bit_len_harq&7) > 0) harq_bytes++;
......
......@@ -1200,7 +1200,8 @@ void nr_dlsch_decoding_process(void *arg) {
ret = dlsch->max_ldpc_iterations;
harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, harq_process->Qm,harq_process->Nl);
G = harq_process->G;
LOG_D(PHY,"DLSCH Decoding process, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb);
LOG_D(PHY,"DLSCH Decoding process, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d, Coderate %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb,harq_process->R);
if ((harq_process->R)<1024)
Coderate = (float) (harq_process->R) /(float) 1024;
......
......@@ -808,7 +808,7 @@ typedef struct PHY_VARS_gNB_s {
/// PUSCH DMRS
uint32_t ****nr_gold_pusch_dmrs;
// Mask of occupied RBs
// Mask of occupied RBs, per symbol and PRB
uint32_t rb_mask_ul[14][9];
/// CSI RS sequence
......
......@@ -265,8 +265,8 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) {
// if all segments are done
if (rdata->nbSegments == ulsch_harq->processedSegments) {
if (decodeSuccess) {
LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for SFN/SF %d.%d (pid %d, ndi %d, status %d, round %d, TBS %d)\n",
gNB->Mod_id,ulsch_harq->frame,ulsch_harq->slot,rdata->harq_pid,pusch_pdu->pusch_data.new_data_indicator,ulsch_harq->status,ulsch_harq->round,ulsch_harq->TBS);
LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for SFN/SF %d.%d (pid %d, ndi %d, status %d, round %d, TBS %d, Max interation (all seg) %d)\n",
gNB->Mod_id,ulsch_harq->frame,ulsch_harq->slot,rdata->harq_pid,pusch_pdu->pusch_data.new_data_indicator,ulsch_harq->status,ulsch_harq->round,ulsch_harq->TBS,rdata->decodeIterations);
ulsch_harq->status = SCH_IDLE;
ulsch_harq->round = 0;
ulsch->harq_mask &= ~(1 << rdata->harq_pid);
......@@ -275,7 +275,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) {
nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0,0);
//dumpsig=1;
} else {
LOG_I(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, ndi %d, status %d, round %d, RV %d, TBS %d) r %d\n",
LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, ndi %d, status %d, round %d, RV %d, TBS %d) r %d\n",
gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot,
rdata->harq_pid,pusch_pdu->pusch_data.new_data_indicator,ulsch_harq->status, ulsch_harq->round, ulsch_harq->ulsch_pdu.pusch_data.rv_index,ulsch_harq->TBS,r);
ulsch_harq->round++;
......
......@@ -779,9 +779,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, 0, 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, 0, 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;
......@@ -1260,7 +1260,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");
......
......@@ -67,7 +67,7 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
int main(int argc, char **argv)
{
char c;
int i,aa=0;//,l;
int i;//,l;
double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0;
double cfo=0;
uint8_t snr1set=0;
......@@ -101,9 +101,8 @@ int main(int argc, char **argv)
uint16_t startingPRB=0,startingPRB_intraSlotHopping=0; //PRB number not sure see 9.2.1, 38.213 for more info. Should be actually present in the resource set provided
uint16_t nrofPRB=2;
uint8_t timeDomainOCC=0;
SCM_t channel_model=AWGN;//Rayleigh1_anticorr;
double DS_TDL = .03;
SCM_t channel_model=TDL_C;
double DS_TDL = .3;
int N_RB_DL=273,mu=1;
float target_error_rate=0.001;
......@@ -113,7 +112,7 @@ int main(int argc, char **argv)
//unsigned char frame_type = 0;
int loglvl=OAILOG_WARNING;
int sr_flag = 0;
int pucch_DTX_thres = 155;
cpuf = get_cpu_freq_GHz();
if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0) {
......@@ -123,7 +122,7 @@ int main(int argc, char **argv)
randominit(0);
logInit();
while ((c = getopt (argc, argv, "f:hA:f:g:i:I:P:B:b:T:m:n:r:o:s:S:x:y:z:N:F:GR:IL:q:c")) != -1) {
while ((c = getopt (argc, argv, "f:hA:f:g:i:I:P:B:b:t:T:m:n:r:o:s:S:x:y:z:N:F:GR:IL:q:c")) != -1) {
switch (c) {
case 'f':
//write_output_file=1;
......@@ -207,11 +206,11 @@ int main(int argc, char **argv)
printf("Setting SNR1 to %f\n",snr1);
break;
/*
case 't':
Td= atof(optarg);
pucch_DTX_thres= atoi(optarg);
break;
/*
case 'p':
extended_prefix_flag=1;
break;
......@@ -251,7 +250,7 @@ int main(int argc, char **argv)
case 'z':
n_rx=atoi(optarg);
if ((n_rx==0) || (n_rx>2)) {
if ((n_rx==0) || (n_rx>8)) {
printf("Unsupported number of rx antennas %d\n",n_rx);
exit(-1);
}
......@@ -350,25 +349,27 @@ int main(int argc, char **argv)
if (snr1set==0) snr1 = snr0+10;
printf("Initializing gNodeB for mu %d, N_RB_DL %d\n",mu,N_RB_DL);
printf("Initializing gNodeB for mu %d, N_RB_DL %d, n_rx %d\n",mu,N_RB_DL,n_rx);
if((format!=0) && (format!=1) && (format!=2)){
printf("PUCCH format %d not supported\n",format);
exit(0);
}
AssertFatal(((format < 2)&&(nr_bit<3)&&(actual_payload<4)) ||
AssertFatal(((format < 2)&&(nr_bit<3)&&(actual_payload<5)) ||
((format == 2)&&(nr_bit>2)&&(nr_bit<65)),"illegal combination format %d, nr_bit %d\n",
format,nr_bit);
int do_DTX=0;
if ((format < 2) && (actual_payload == 4)) do_DTX=1;
actual_payload &= ((1<<nr_bit)-1);
printf("Transmitted payload is %ld\n",actual_payload);
printf("Transmitted payload is %ld, do_DTX = %d\n",actual_payload,do_DTX);
RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB));
RC.gNB[0] = calloc(1,sizeof(PHY_VARS_gNB));
gNB = RC.gNB[0];
memset((void*)gNB,0,sizeof(*gNB));
gNB->pucch0_thres = pucch_DTX_thres;
frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
frame_parms->nb_antennas_tx = n_tx;
frame_parms->nb_antennas_rx = n_rx;
......@@ -380,7 +381,7 @@ int main(int argc, char **argv)
cfg->carrier_config.num_tx_ant.value = n_tx;
cfg->carrier_config.num_rx_ant.value = n_rx;
nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions);
phy_init_nr_gNB(gNB,0,0);
phy_init_nr_gNB(gNB,0,1);
double fs,bw,scs,eps;
......@@ -430,33 +431,47 @@ int main(int argc, char **argv)
frame_length_complex_samples = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME;
//frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP;
s_re = malloc(2*sizeof(double*));
s_im = malloc(2*sizeof(double*));
r_re = malloc(2*sizeof(double*));
r_im = malloc(2*sizeof(double*));
txdataF = malloc(2*sizeof(int*));
rxdataF = malloc(2*sizeof(int*));
s_re = malloc(n_tx*sizeof(double*));
s_im = malloc(n_tx*sizeof(double*));
r_re = malloc(n_rx*sizeof(double*));
r_im = malloc(n_rx*sizeof(double*));
txdataF = malloc(n_tx*sizeof(int*));
rxdataF = malloc(n_rx*sizeof(int*));
gNB->common_vars.rxdataF=rxdataF;
memcpy((void*)&gNB->frame_parms,(void*)frame_parms,sizeof(frame_parms));
for (i=0; i<2; i++) {
s_re[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(s_re[i],frame_length_complex_samples*sizeof(double));
s_im[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(s_im[i],frame_length_complex_samples*sizeof(double));
r_re[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(r_re[i],frame_length_complex_samples*sizeof(double));
r_im[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(r_im[i],frame_length_complex_samples*sizeof(double));
printf("Allocating %d samples for txdataF/rxdataF\n",14*frame_parms->ofdm_symbol_size);
txdataF[i] = memalign(32,14*frame_parms->ofdm_symbol_size*sizeof(int));
bzero(txdataF[i],14*frame_parms->ofdm_symbol_size*sizeof(int));
rxdataF[i] = memalign(32,14*frame_parms->ofdm_symbol_size*sizeof(int));
bzero(rxdataF[i],14*frame_parms->ofdm_symbol_size*sizeof(int));
for (int aatx=0; aatx<n_tx; aatx++) {
s_re[aatx] = calloc(1,frame_length_complex_samples*sizeof(double));
s_im[aatx] = calloc(1,frame_length_complex_samples*sizeof(double));
printf("Allocating %d samples for txdataF\n",frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size);
txdataF[aatx] = memalign(32,14*frame_parms->ofdm_symbol_size*sizeof(int));
bzero(txdataF[aatx],14*frame_parms->ofdm_symbol_size*sizeof(int));
}
for (int aarx=0; aarx<n_rx; aarx++) {
r_re[aarx] = calloc(1,frame_length_complex_samples*sizeof(double));
r_im[aarx] = calloc(1,frame_length_complex_samples*sizeof(double));
printf("Allocating %d samples for rxdataF\n",frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size);
rxdataF[aarx] = memalign(32,14*frame_parms->ofdm_symbol_size*sizeof(int));
bzero(rxdataF[aarx],14*frame_parms->ofdm_symbol_size*sizeof(int));
}
//configure UE
UE = calloc(1,sizeof(PHY_VARS_NR_UE));
memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS));
UE->frame_parms.nb_antennas_rx=2;
UE->pucch_config_common_nr->hoppingId = Nid_cell;
//phy_init_nr_top(UE); //called from init_nr_ue_signal
UE->perfect_ce = 0;
if(eps!=0.0)
UE->UE_fo_compensation = 1; // if a frequency offset is set then perform fo estimation and compensation
if (init_nr_ue_signal(UE, 1, 0) != 0)
{
printf("Error at UE NR initialisation\n");
exit(-1);
}
uint8_t mcs=0;
int shift = 0;
if(format==0){
......@@ -472,122 +487,98 @@ int main(int argc, char **argv)
}
else if (format == 2 && nr_bit > 11) gNB->uci_polarParams = nr_polar_params(2, nr_bit, nrofPRB, 1, NULL);
startingPRB_intraSlotHopping=N_RB_DL-1;
uint32_t hopping_id=Nid_cell;
uint32_t dmrs_scrambling_id = 0, data_scrambling_id=0;
//configure UE
UE = malloc(sizeof(PHY_VARS_NR_UE));
memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS));
fapi_nr_ul_config_pucch_pdu pucch_tx_pdu;
if (format==0) {
pucch_tx_pdu.format_type = 0;
pucch_tx_pdu.nr_of_symbols = nrofSymbols;
pucch_tx_pdu.start_symbol_index = startingSymbolIndex;
pucch_tx_pdu.bwp_start = 0;
pucch_tx_pdu.prb_start = startingPRB;
pucch_tx_pdu.hopping_id = hopping_id;
pucch_tx_pdu.group_hop_flag = 0;
pucch_tx_pdu.sequence_hop_flag = 0;
pucch_tx_pdu.freq_hop_flag = 0;
pucch_tx_pdu.mcs = mcs;
pucch_tx_pdu.initial_cyclic_shift = 0;
pucch_tx_pdu.second_hop_prb = startingPRB_intraSlotHopping;
}
if (format==2) {
pucch_tx_pdu.format_type = 2;
pucch_tx_pdu.rnti = 0x1234;
pucch_tx_pdu.n_bit = nr_bit;
pucch_tx_pdu.payload = actual_payload;
pucch_tx_pdu.nr_of_symbols = nrofSymbols;
pucch_tx_pdu.start_symbol_index = startingSymbolIndex;
pucch_tx_pdu.bwp_start = 0;
pucch_tx_pdu.prb_start = startingPRB;
pucch_tx_pdu.prb_size = nrofPRB;
pucch_tx_pdu.hopping_id = hopping_id;
pucch_tx_pdu.group_hop_flag = 0;
pucch_tx_pdu.sequence_hop_flag = 0;
pucch_tx_pdu.freq_hop_flag = 0;
pucch_tx_pdu.dmrs_scrambling_id = dmrs_scrambling_id;
pucch_tx_pdu.data_scrambling_id = data_scrambling_id;
pucch_tx_pdu.second_hop_prb = startingPRB_intraSlotHopping;
}
UE->perfect_ce = 0;
if(eps!=0.0)
UE->UE_fo_compensation = 1; // if a frequency offset is set then perform fo estimation and compensation
if (init_nr_ue_signal(UE, 1, 0) != 0)
{
printf("Error at UE NR initialisation\n");
exit(-1);
}
pucch_GroupHopping_t PUCCH_GroupHopping = pucch_tx_pdu.group_hop_flag + (pucch_tx_pdu.sequence_hop_flag<<1);
//t_nrPolar_params *currentPtr;
for(SNR=snr0;SNR<=snr1;SNR=SNR+1){
for(SNR=snr0;SNR<=snr1;SNR=SNR+0.5){
ack_nack_errors=0;
sr_errors=0;
n_errors = 0;
for (trial=0; trial<n_trials; trial++) {
bzero(txdataF[aa],frame_parms->ofdm_symbol_size*sizeof(int));
if(format==0){
nr_generate_pucch0(UE,
txdataF,
frame_parms,
amp,
nr_slot_tx,
&pucch_tx_pdu);
for (int aatx=0;aatx<1;aatx++)
bzero(txdataF[aatx],frame_parms->ofdm_symbol_size*sizeof(int));
if(format==0 && do_DTX==0){
nr_generate_pucch0(UE,txdataF,frame_parms,PUCCH_GroupHopping,hopping_id,amp,nr_slot_tx,m0,mcs,nrofSymbols,startingSymbolIndex,startingPRB,
nrofSymbols>1?(N_RB_DL-1):0);
}
else if (format == 1){
nr_generate_pucch1(UE,
txdataF,
frame_parms,
amp,
nr_slot_tx,
&pucch_tx_pdu);
else if (format == 1 && do_DTX==0){
nr_generate_pucch1(UE,txdataF,frame_parms,UE->pucch_config_dedicated,actual_payload,amp,nr_slot_tx,m0,nrofSymbols,startingSymbolIndex,startingPRB,startingPRB_intraSlotHopping,0,nr_bit);
}
else {
nr_generate_pucch2(UE,
txdataF,
frame_parms,
amp,
nr_slot_tx,
&pucch_tx_pdu);
else if (do_DTX == 0){
nr_generate_pucch2(UE,0x1234,dmrs_scrambling_id,data_scrambling_id,txdataF,frame_parms,UE->pucch_config_dedicated,actual_payload,amp,nr_slot_tx,nrofSymbols,startingSymbolIndex,nrofPRB,startingPRB,nr_bit);
}
int txlev = signal_energy(&txdataF[aa][startingSymbolIndex*frame_parms->ofdm_symbol_size],
frame_parms->ofdm_symbol_size);
// printf("txlev %d (%d dB), offset %d\n",txlev,dB_fixed(txlev),startingSymbolIndex*frame_parms->ofdm_symbol_size);
// note : this scaling
int nb_re = (format == 0 || format == 1)? 12 : 12*nrofPRB;
sigma2_dB = 10*log10((double)txlev*UE->frame_parms.ofdm_symbol_size/nb_re)-SNR;
sigma2 = pow(10,sigma2_dB/10);
for(i=startingSymbolIndex*frame_parms->ofdm_symbol_size; i<(startingSymbolIndex+1)*frame_parms->ofdm_symbol_size; i++) {
((int16_t*)rxdataF[aa])[i<<1] = (int16_t)(100.0*((double)(((int16_t *)txdataF[aa])[(i<<1)]) + sqrt(sigma2/2)*gaussdouble(0.0,1.0))/sqrt((double)txlev));
((int16_t*)rxdataF[aa])[1+(i<<1)]=(int16_t)(100.0*((double)(((int16_t *)txdataF[aa])[(i<<1)+1])+ sqrt(sigma2/2)*gaussdouble(0.0,1.0))/sqrt((double)txlev));
// SNR Computation
// standard says: SNR = S / N, where S is the total signal energy, N is the noise energy in the transmission bandwidth (i.e. N_RB_DL resource blocks)
// txlev = S. Note: signal_energy_nodc normalizes by the length of the vector, so multiply output by ofdm_symbol_size
double txlev = do_DTX == 0 ? signal_energy_nodc(&txdataF[0][startingSymbolIndex*frame_parms->ofdm_symbol_size],
frame_parms->ofdm_symbol_size) * (double)frame_parms->ofdm_symbol_size
: 1e5;
int N_RB = (format == 0) ? 1 : nrofPRB;
// sigma2 is variance per dimension, so N/(N_RB*12)
// so, sigma2 = N/(N_RB_DL*12) => (S/SNR)/(N_RB*12)
sigma2_dB = 10*log10(txlev/(12.0*N_RB))-SNR;
sigma2 = pow(10.0,sigma2_dB/10.0);
if (n_trials==1) printf("txlev %f (%f dB), offset %d, sigma2 %f ( %f dB)\n",txlev,10*log10(txlev),startingSymbolIndex*frame_parms->ofdm_symbol_size,sigma2,sigma2_dB);
random_channel(UE2gNB,0);
freq_channel(UE2gNB,N_RB_DL,1+(N_RB_DL*12),scs/1000);
int i0;
double txr,txi,rxr,rxi,nr,ni;
for (int symb=0; symb<gNB->frame_parms.symbols_per_slot;symb++) {
if (symb<startingSymbolIndex || symb >= startingSymbolIndex+nrofSymbols) {
i0 = symb*gNB->frame_parms.ofdm_symbol_size;
for (int re=0;re<N_RB_DL*12;re++) {
i=i0+((gNB->frame_parms.first_carrier_offset + re)%gNB->frame_parms.ofdm_symbol_size);
for (int aarx=0;aarx<n_rx;aarx++) {
nr = sqrt(sigma2/2)*gaussdouble(0.0,1.0);
ni = sqrt(sigma2/2)*gaussdouble(0.0,1.0);
((int16_t*)rxdataF[aarx])[i<<1] = (int16_t)(100.0*(nr)/sqrt((double)txlev));
((int16_t*)rxdataF[aarx])[1+(i<<1)]= (int16_t)(100.0*(ni)/sqrt((double)txlev));
}
}
}
}
int rxlev = signal_energy(&rxdataF[aa][startingSymbolIndex*frame_parms->ofdm_symbol_size],
frame_parms->ofdm_symbol_size);
for (int symb=0; symb<nrofSymbols; symb++) {
i0 = (startingSymbolIndex + symb)*gNB->frame_parms.ofdm_symbol_size;
for (int re=0;re<N_RB_DL*12;re++) {
i=i0+((gNB->frame_parms.first_carrier_offset + re)%gNB->frame_parms.ofdm_symbol_size);
for (int aarx=0;aarx<n_rx;aarx++) {
txr = (double)(((int16_t *)txdataF[0])[(i<<1)]);
txi = (double)(((int16_t *)txdataF[0])[1+(i<<1)]);
rxr = txr*UE2gNB->chF[aarx][re].x - txi*UE2gNB->chF[aarx][re].y;
rxi = txr*UE2gNB->chF[aarx][re].y + txi*UE2gNB->chF[aarx][re].x;
nr = sqrt(sigma2/2)*gaussdouble(0.0,1.0);
ni = sqrt(sigma2/2)*gaussdouble(0.0,1.0);
((int16_t*)rxdataF[aarx])[i<<1] = (int16_t)(100.0*(rxr + nr)/sqrt((double)txlev));
((int16_t*)rxdataF[aarx])[1+(i<<1)]= (int16_t)(100.0*(rxi + ni)/sqrt((double)txlev));
if (n_trials==1 && abs(txr) > 0) printf("symb %d, re %d , aarx %d : txr %f, txi %f, chr %f, chi %f, nr %f, ni %f, rxr %f, rxi %f => %d,%d\n",
symb, re, aarx, txr,txi,
UE2gNB->chF[aarx][re].x,UE2gNB->chF[aarx][re].y,
nr,ni, rxr,rxi,
((int16_t*)rxdataF[aarx])[i<<1],((int16_t*)rxdataF[aarx])[1+(i<<1)]);
}
}
}
int rxlev=0;
for (int aarx=0;aarx<n_rx;aarx++) rxlev += signal_energy(&rxdataF[aarx][startingSymbolIndex*frame_parms->ofdm_symbol_size],
frame_parms->ofdm_symbol_size);
// noise measurement
gNB->ulmask_symb = startingSymbolIndex;
for (int rb=0; rb<nrofPRB; rb++) {
int rb2 = rb+startingPRB;
gNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31));
for (int s=0;s<frame_parms->symbols_per_slot;s++){
if (s>=startingSymbolIndex && s<(startingSymbolIndex+nrofSymbols))
for (int rb=0; rb<N_RB; rb++) {
int rb2 = rb+startingPRB;
gNB->rb_mask_ul[s][rb2>>5] |= (1<<(rb2&31));
}
}
gNB_I0_measurements(gNB, startingSymbolIndex, nrofSymbols);
gNB_I0_measurements(gNB, nr_slot_tx, 0, gNB->frame_parms.symbols_per_slot);
if (n_trials==1) printf("rxlev %d (%d dB), sigma2 %f dB, SNR %f, TX %f\n",rxlev,dB_fixed(rxlev),sigma2_dB,SNR,10*log10((double)txlev*UE->frame_parms.ofdm_symbol_size/12));
if(format==0){
nfapi_nr_uci_pucch_pdu_format_0_1_t uci_pdu;
nfapi_nr_pucch_pdu_t pucch_pdu;
gNB->uci_stats[0].rnti = 0x1234;
pucch_pdu.rnti = 0x1234;
pucch_pdu.subcarrier_spacing = 1;
pucch_pdu.group_hop_flag = PUCCH_GroupHopping&1;
pucch_pdu.sequence_hop_flag = (PUCCH_GroupHopping>>1)&1;
......@@ -601,18 +592,27 @@ int main(int argc, char **argv)
pucch_pdu.start_symbol_index = startingSymbolIndex;
pucch_pdu.prb_start = startingPRB;
pucch_pdu.bwp_start = 0;
pucch_pdu.freq_hop_flag = 0;
pucch_pdu.bwp_size = N_RB_DL;
if (nrofSymbols>1) {
pucch_pdu.freq_hop_flag = 1;
pucch_pdu.second_hop_prb = N_RB_DL-1;
}
else pucch_pdu.freq_hop_flag = 0;
nr_decode_pucch0(gNB, nr_frame_tx, nr_slot_tx,&uci_pdu,&pucch_pdu);
if(sr_flag==1){
if (uci_pdu.sr->sr_indication == 0 || uci_pdu.sr->sr_confidence_level == 1)
sr_errors+=1;
}
if(nr_bit>0){
if(nr_bit==1)
if(nr_bit==1 && do_DTX == 0)
ack_nack_errors+=(actual_payload^uci_pdu.harq->harq_list[0].harq_value);
else
else if (do_DTX == 0)
ack_nack_errors+=(((actual_payload&1)^uci_pdu.harq->harq_list[0].harq_value)+((actual_payload>>1)^uci_pdu.harq->harq_list[1].harq_value));
free(uci_pdu.harq->harq_list);
else if ((uci_pdu.harq->harq_confidence_level == 0 && uci_pdu.harq->harq_list[0].harq_value == 1) ||
(uci_pdu.harq->harq_confidence_level == 0 && nr_bit == 2 && uci_pdu.harq->harq_list[1].harq_value==1))
ack_nack_errors++;
free(uci_pdu.harq->harq_list);
}
}
else if (format==1) {
......@@ -644,6 +644,11 @@ int main(int argc, char **argv)
pucch_pdu.prb_start = startingPRB;
pucch_pdu.dmrs_scrambling_id = dmrs_scrambling_id;
pucch_pdu.data_scrambling_id = data_scrambling_id;
if (nrofSymbols>1) {
pucch_pdu.freq_hop_flag = 1;
pucch_pdu.second_hop_prb = N_RB_DL-1;
}
else pucch_pdu.freq_hop_flag = 0;
nr_decode_pucch2(gNB,nr_slot_tx,&uci_pdu,&pucch_pdu);
int csi_part1_bytes=pucch_pdu.bit_len_csi_part1>>3;
if ((pucch_pdu.bit_len_csi_part1&7) > 0) csi_part1_bytes++;
......@@ -668,13 +673,15 @@ int main(int argc, char **argv)
}
}
for (i=0; i<2; i++) {
free(s_re[i]);
free(s_im[i]);
free(r_re[i]);
free(r_im[i]);
free(txdataF[i]);
free(rxdataF[i]);
for (int aatx=0; aatx<n_tx; aatx++) {
free(s_re[aatx]);
free(s_im[aatx]);
free(txdataF[aatx]);
}
for (int aarx=0; aarx<n_rx; aarx++) {
free(r_re[aarx]);
free(r_im[aarx]);
free(rxdataF[aarx]);
}
free(s_re);
free(s_im);
......
......@@ -243,11 +243,6 @@ openair0_config_t openair0_cfg[MAX_CARDS];
//const uint8_t nr_rv_round_map[4] = {0, 2, 1, 3};
channel_desc_t *UE2gNB[NUMBER_OF_UE_MAX][NUMBER_OF_gNB_MAX];
double s_re0[122880],s_im0[122880],r_re0[122880],r_im0[122880];
double s_re1[122880],s_im1[122880],r_re1[122880],r_im1[122880];
double r_re2[122880],r_im2[122880];
double r_re3[122880],r_im3[122880];
int main(int argc, char **argv)
{
......@@ -259,10 +254,7 @@ int main(int argc, char **argv)
uint8_t snr1set = 0;
int slot = 8, frame = 1;
FILE *output_fd = NULL;
double *s_re[2]= {s_re0,s_re1};
double *s_im[2]= {s_im0,s_im1};
double *r_re[4]= {r_re0,r_re1,r_re2,r_re3};
double *r_im[4]= {r_im0,r_im1,r_im2,r_im3};
double **s_re,**s_im,**r_re,**r_im;
//uint8_t write_output_file = 0;
int trial, n_trials = 1, n_false_positive = 0, delay = 0;
double maxDoppler = 0.0;
......@@ -298,8 +290,9 @@ int main(int argc, char **argv)
cpuf = get_cpu_freq_GHz();
int msg3_flag = 0;
int rv_index = 0;
float roundStats[50];
float effRate;
float roundStats[100];
double effRate[100];
double effTP[100];
//float eff_tp_check = 0.7;
uint8_t snrRun;
int prb_inter = 0;
......@@ -315,7 +308,7 @@ int main(int argc, char **argv)
uint16_t ptrsRePerSymb = 0;
uint8_t transform_precoding = 1; // 0 - ENABLE, 1 - DISABLE
uint8_t num_dmrs_cdm_grps_no_data = 1;
uint8_t num_dmrs_cdm_grps_no_data = 2;
uint8_t mcs_table = 0;
UE_nr_rxtx_proc_t UE_proc;
......@@ -502,7 +495,7 @@ int main(int argc, char **argv)
case 'z':
n_rx = atoi(optarg);
if ((n_rx == 0) || (n_rx > 2)) {
if ((n_rx == 0) || (n_rx > 8)) {
printf("Unsupported number of rx antennas %d\n", n_rx);
exit(-1);
}
......@@ -670,7 +663,7 @@ int main(int argc, char **argv)
gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t));
gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
char tp_param[] = "n";
initTpool(tp_param, gNB->threadPool, true);
initTpool(tp_param, gNB->threadPool, false);
initNotifiedFIFO(gNB->respDecode);
//gNB_config = &gNB->gNB_config;
......@@ -683,12 +676,14 @@ int main(int argc, char **argv)
frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
//frame_parms->nb_antennas_tx = n_tx;
//frame_parms->nb_antennas_rx = n_rx;
frame_parms->N_RB_DL = N_RB_DL;
frame_parms->N_RB_UL = N_RB_UL;
frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL;
s_re = malloc(n_tx*sizeof(double*));
s_im = malloc(n_tx*sizeof(double*));
r_re = malloc(n_rx*sizeof(double*));
r_im = malloc(n_rx*sizeof(double*));
RC.nb_nr_macrlc_inst = 1;
RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int));
......@@ -723,9 +718,15 @@ int main(int argc, char **argv)
gNB->if_inst->NR_PHY_config_req = nr_phy_config_request;
// common configuration
rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, 0, 0, NULL);
rrc_mac_config_req_gNB(0,0, n_tx, n_rx, 0, scc, &rrc.carrier.mib,0, 0, NULL);
// UE dedicated configuration
rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup);
rrc_mac_config_req_gNB(0,0, n_tx, n_rx, 0, scc, &rrc.carrier.mib,1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup);
frame_parms->nb_antennas_tx = n_tx;
frame_parms->nb_antennas_rx = n_rx;
nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
cfg->carrier_config.num_tx_ant.value = n_tx;
cfg->carrier_config.num_rx_ant.value = n_rx;
nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,0,0x01);
phy_init_nr_gNB(gNB,0,1);
N_RB_DL = gNB->frame_parms.N_RB_DL;
......@@ -768,7 +769,18 @@ int main(int argc, char **argv)
}
*/
nr_l2_init_ue(NULL);
//Configure UE
NR_UE_RRC_INST_t rrcue;
memset(&rrcue,0,sizeof(NR_UE_RRC_INST_t));
rrc.carrier.MIB = (uint8_t*) malloc(4);
rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0);
rrcue.mib = rrc.carrier.mib.message.choice.mib;
rrcue.scell_group_config=secondaryCellGroup;
nr_l2_init_ue(&rrcue);
NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0);
UE->if_inst = nr_ue_if_module_init(0);
......@@ -779,11 +791,7 @@ int main(int argc, char **argv)
UE_mac->if_module = nr_ue_if_module_init(0);
//Configure UE
rrc.carrier.MIB = (uint8_t*) malloc(4);
rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0);
nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib, NULL, NULL, secondaryCellGroup);
// nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib, NULL, NULL, secondaryCellGroup);
nr_ue_phy_config_request(&UE_mac->phy_config);
......@@ -851,12 +859,13 @@ int main(int argc, char **argv)
{
add_pos = dmrs_arg[1];
}
printf("NOTE: DMRS config is modified with Mapping Type %d , Additional Position %d \n", mapping_type, add_pos );
}
printf("NOTE: DMRS config is modified with Mapping Type %d , Additional Position %d \n", mapping_type, add_pos );
uint8_t length_dmrs = pusch_len1;
uint16_t l_prime_mask = get_l_prime(nb_symb_sch, mapping_type, add_pos, length_dmrs, start_symbol, NR_MIB__dmrs_TypeA_Position_pos2);
uint16_t number_dmrs_symbols = get_dmrs_symbols_in_slot(l_prime_mask, nb_symb_sch);
printf("num dmrs sym %d\n",number_dmrs_symbols);
uint8_t nb_re_dmrs = (dmrs_config_type == pusch_dmrs_type1) ? 6 : 4;
// if transform precoding is enabled
......@@ -868,11 +877,11 @@ int main(int argc, char **argv)
AssertFatal(index >= 0, "Num RBs not configured according to 3GPP 38.211 section 6.3.1.4. For PUSCH with transform precoding, num RBs cannot be multiple of any other primenumber other than 2,3,5\n");
dmrs_config_type = pusch_dmrs_type1;
nb_re_dmrs = nb_re_dmrs * num_dmrs_cdm_grps_no_data;
printf("[ULSIM]: TRANSFORM PRECODING ENABLED. Num RBs: %d, index for DMRS_SEQ: %d\n", nb_rb, index);
}
nb_re_dmrs = nb_re_dmrs * num_dmrs_cdm_grps_no_data;
unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, number_dmrs_symbols, mod_order, 1);
unsigned int TBS = nr_compute_tbs(mod_order, code_rate, nb_rb, nb_symb_sch, nb_re_dmrs * number_dmrs_symbols, 0, 0, precod_nbr_layers);
......@@ -914,13 +923,24 @@ int main(int argc, char **argv)
printf("NOTE: PTRS Enabled with L %d, K %d \n", ptrs_time_density, ptrs_freq_density );
}
if (input_fd != NULL) max_rounds=1;
if (input_fd != NULL || n_trials == 1) max_rounds=1;
if(1<<ptrs_time_density >= nb_symb_sch)
pdu_bit_map &= ~PUSCH_PDU_BITMAP_PUSCH_PTRS; // disable PUSCH PTRS
printf("\n");
int frame_length_complex_samples = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME;
for (int aatx=0; aatx<n_tx; aatx++) {
s_re[aatx] = calloc(1,frame_length_complex_samples*sizeof(double));
s_im[aatx] = calloc(1,frame_length_complex_samples*sizeof(double));
}
for (int aarx=0; aarx<n_rx; aarx++) {
r_re[aarx] = calloc(1,frame_length_complex_samples*sizeof(double));
r_im[aarx] = calloc(1,frame_length_complex_samples*sizeof(double));
}
//for (int i=0;i<16;i++) printf("%f\n",gaussdouble(0.0,1.0));
snrRun = 0;
int n_errs = 0;
......@@ -962,7 +982,10 @@ int main(int argc, char **argv)
sizeof(int16_t),
slot_length<<1,
input_fd);
if (read_errors==0) exit(1);
if (read_errors==0) {
printf("error reading file\n");
exit(1);
}
for (int i=0;i<16;i+=2) printf("slot_offset %d : %d,%d\n",
slot_offset,
((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[i],
......@@ -972,14 +995,24 @@ int main(int argc, char **argv)
code_rate = nr_get_code_rate_ul(Imcs, mcs_table);
}
uint32_t errors_scrambling[4][100];
int n_errors[4][100];
int round_trials[4][100];
double blerStats[4][100];
double berStats[4][100];
double snrStats[100];
memset(errors_scrambling, 0, sizeof(uint32_t)*4*100);
memset(n_errors, 0, sizeof(int)*4*100);
memset(round_trials, 0, sizeof(int)*4*100);
memset(blerStats, 0, sizeof(double)*4*100);
memset(berStats, 0, sizeof(double)*4*100);
memset(snrStats, 0, sizeof(double)*100);
for (SNR = snr0; SNR < snr1; SNR += snr_step) {
varArray_t *table_rx=initVarArray(1000,sizeof(double));
int error_flag = 0;
n_false_positive = 0;
effRate = 0;
int n_errors[4] = {0,0,0,0};;
int round_trials[4]={0,0,0,0};
uint32_t errors_scrambling[4] = {0,0,0,0};
effRate[snrRun] = 0;
effTP[snrRun] = 0;
reset_meas(&gNB->phy_proc_rx);
reset_meas(&gNB->rx_pusch_stats);
reset_meas(&gNB->ulsch_decoding_stats);
......@@ -1004,7 +1037,7 @@ int main(int argc, char **argv)
errors_decoding = 0;
memset((void*)roundStats,0,50*sizeof(roundStats[0]));
while (round<max_rounds && crc_status) {
round_trials[round]++;
round_trials[round][snrRun]++;
ulsch_ue[0]->harq_processes[harq_pid]->round = round;
gNB->ulsch[0][0]->harq_processes[harq_pid]->round = round;
rv_index = nr_rv_round_map[round];
......@@ -1054,7 +1087,7 @@ int main(int argc, char **argv)
pusch_pdu->ul_dmrs_scrambling_id = *scc->physCellId;
pusch_pdu->scid = 0;
pusch_pdu->dmrs_ports = 1;
pusch_pdu->num_dmrs_cdm_grps_no_data = msg3_flag == 0 ? 1 : 2;
pusch_pdu->num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data;
pusch_pdu->resource_alloc = 1;
pusch_pdu->rb_start = start_rb;
pusch_pdu->rb_size = nb_rb;
......@@ -1117,7 +1150,7 @@ int main(int argc, char **argv)
ul_config.ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type;
ul_config.ul_config_list[0].pusch_config_pdu.mcs_index = Imcs;
ul_config.ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table;
ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = msg3_flag == 0 ? 1 : 2;
ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data;
ul_config.ul_config_list[0].pusch_config_pdu.nrOfLayers = precod_nbr_layers;
ul_config.ul_config_list[0].pusch_config_pdu.absolute_delta_PUSCH = 0;
......@@ -1262,6 +1295,58 @@ int main(int argc, char **argv)
(nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_M("rxsigF0_comp.m","rxsF0_comp",
&gNB->pusch_vars[0]->rxdataF_comp[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_M("chmagF0.m","chmF0",
&gNB->pusch_vars[0]->ul_ch_mag[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_M("chmagbF0.m","chmbF0",
&gNB->pusch_vars[0]->ul_ch_magb[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
if (n_rx == 2) {
LOG_MM("rxsigF0_comp.m","rxsF1_comp",
&gNB->pusch_vars[0]->rxdataF_comp[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("rxsigF0_ext.m","rxsF1_ext",
&gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chestF0_ext.m","chF1_ext",
&gNB->pusch_vars[0]->ul_ch_estimates_ext[1][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],
(nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chmagF0.m","chmF1",
&gNB->pusch_vars[0]->ul_ch_mag[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chmagbF0.m","chmbF1",
&gNB->pusch_vars[0]->ul_ch_magb[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
} else if (n_rx == 4) {
LOG_MM("rxsigF0_comp.m","rxsF1_comp",
&gNB->pusch_vars[0]->rxdataF_comp[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("rxsigF0_comp.m","rxsF2_comp",
&gNB->pusch_vars[0]->rxdataF_comp[2][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("rxsigF0_comp.m","rxsF3_comp",
&gNB->pusch_vars[0]->rxdataF_comp[3][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("rxsigF0_ext.m","rxsF1_ext",
&gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("rxsigF0_ext.m","rxsF2_ext",
&gNB->pusch_vars[0]->rxdataF_ext[2][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("rxsigF0_ext.m","rxsF3_ext",
&gNB->pusch_vars[0]->rxdataF_ext[3][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chestF0_ext.m","chF1_ext",
&gNB->pusch_vars[0]->ul_ch_estimates_ext[1][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],
(nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chestF0_ext.m","chF2_ext",
&gNB->pusch_vars[0]->ul_ch_estimates_ext[2][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],
(nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chestF0_ext.m","chF3_ext",
&gNB->pusch_vars[0]->ul_ch_estimates_ext[3][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],
(nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chmagF0.m","chmF1",
&gNB->pusch_vars[0]->ul_ch_mag[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chmagF0.m","chmF2",
&gNB->pusch_vars[0]->ul_ch_mag[2][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chmagF0.m","chmF3",
&gNB->pusch_vars[0]->ul_ch_mag[3][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chmagbF0.m","chmbF1",
&gNB->pusch_vars[0]->ul_ch_magb[1][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chmagbF0.m","chmbF2",
&gNB->pusch_vars[0]->ul_ch_magb[2][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
LOG_MM("chmagbF0.m","chmbF3",
&gNB->pusch_vars[0]->ul_ch_magb[3][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1);
}
LOG_M("rxsigF0_llr.m","rxsF0_llr",
&gNB->pusch_vars[0]->llr[0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0);
}
......@@ -1270,7 +1355,7 @@ int main(int argc, char **argv)
if ((gNB->ulsch[0][0]->last_iteration_cnt >=
gNB->ulsch[0][0]->max_ldpc_iterations+1) || ul_proc_error == 1) {
error_flag = 1;
n_errors[round]++;
n_errors[round][snrRun]++;
crc_status = 1;
} else {
crc_status = 0;
......@@ -1298,15 +1383,15 @@ int main(int argc, char **argv)
{
/*if(errors_scrambling == 0)
printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i);*/
errors_scrambling[round]++;
errors_scrambling[round][snrRun]++;
}
}
round++;
} // round
if (n_trials == 1 && errors_scrambling[0] > 0) {
printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %u\n" "\x1B[0m", frame, trial, errors_scrambling[0]);
if (n_trials == 1 && errors_scrambling[0][snrRun] > 0) {
printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %u\n" "\x1B[0m", frame, trial, errors_scrambling[0][snrRun]);
}
for (i = 0; i < TBS; i++) {
......@@ -1323,8 +1408,8 @@ int main(int argc, char **argv)
if (n_trials == 1) {
for (int r=0;r<ulsch_ue[0]->harq_processes[harq_pid]->C;r++)
for (int i=0;i<ulsch_ue[0]->harq_processes[harq_pid]->K>>3;i++) {
/*if ((ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]) != 0) printf("************");
printf("r %d: in[%d] %x, out[%d] %x (%x)\n",r,
if ((ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]) != 0) printf("************");
/*printf("r %d: in[%d] %x, out[%d] %x (%x)\n",r,
i,ulsch_ue[0]->harq_processes[harq_pid]->c[r][i],
i,ulsch_gNB->harq_processes[harq_pid]->c[r][i],
ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]);*/
......@@ -1336,26 +1421,36 @@ int main(int argc, char **argv)
printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding = %u\n" "\x1B[0m", frame, trial, errors_decoding);
}
roundStats[snrRun] += ((float)round);
if (!crc_status) effRate += ((float)TBS)/round;
if (!crc_status) effRate[snrRun] += ((double)TBS)/(double)round;
} // trial loop
roundStats[snrRun]/=((float)n_trials);
effRate /= n_trials;
effRate[snrRun] /= (double)n_trials;
printf("*****************************************\n");
printf("SNR %f: n_errors (%d/%d,%d/%d,%d/%d,%d/%d) (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u,%u/%u,%u/%u,%u/%u\n", SNR, n_errors[0], round_trials[0],n_errors[1], round_trials[1],n_errors[2], round_trials[2],n_errors[3], round_trials[3], n_false_positive, n_trials, errors_scrambling[0],available_bits*n_trials,errors_scrambling[1],available_bits*n_trials,errors_scrambling[2],available_bits*n_trials,errors_scrambling[3],available_bits*n_trials);
printf("SNR %f: n_errors (%d/%d,%d/%d,%d/%d,%d/%d) (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u,%u/%u,%u/%u,%u/%u\n", SNR, n_errors[0][snrRun], round_trials[0][snrRun],n_errors[1][snrRun], round_trials[1][snrRun],n_errors[2][snrRun], round_trials[2][snrRun],n_errors[3][snrRun], round_trials[3][snrRun], n_false_positive, n_trials, errors_scrambling[0][snrRun],available_bits*n_trials,errors_scrambling[1][snrRun],available_bits*n_trials,errors_scrambling[2][snrRun],available_bits*n_trials,errors_scrambling[3][snrRun],available_bits*n_trials);
printf("\n");
blerStats[0][snrRun] = (double)n_errors[0][snrRun]/round_trials[0][snrRun];
blerStats[1][snrRun] = (double)n_errors[1][snrRun]/round_trials[1][snrRun];
blerStats[2][snrRun] = (double)n_errors[2][snrRun]/round_trials[2][snrRun];
blerStats[3][snrRun] = (double)n_errors[3][snrRun]/round_trials[3][snrRun];
berStats[0][snrRun] = (double)errors_scrambling[0][snrRun]/available_bits/round_trials[0][snrRun];
berStats[1][snrRun] = (double)errors_scrambling[1][snrRun]/available_bits/round_trials[1][snrRun];
berStats[2][snrRun] = (double)errors_scrambling[2][snrRun]/available_bits/round_trials[2][snrRun];
berStats[3][snrRun] = (double)errors_scrambling[3][snrRun]/available_bits/round_trials[3][snrRun];
effTP[snrRun] = effRate[snrRun]/(double)TBS*(double)100;
printf("SNR %f: Channel BLER (%e,%e,%e,%e), Channel BER (%e,%e,%e,%e) Avg round %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n",
SNR,
(double)n_errors[0]/round_trials[0],
(double)n_errors[1]/round_trials[0],
(double)n_errors[2]/round_trials[0],
(double)n_errors[3]/round_trials[0],
(double)errors_scrambling[0]/available_bits/round_trials[0],
(double)errors_scrambling[1]/available_bits/round_trials[0],
(double)errors_scrambling[2]/available_bits/round_trials[0],
(double)errors_scrambling[3]/available_bits/round_trials[0],
roundStats[snrRun],effRate,effRate/TBS*100,TBS);
blerStats[0][snrRun],
blerStats[1][snrRun],
blerStats[2][snrRun],
blerStats[3][snrRun],
berStats[0][snrRun],
berStats[1][snrRun],
berStats[2][snrRun],
berStats[3][snrRun],
roundStats[snrRun],effRate[snrRun],effTP[snrRun],TBS);
FILE *fd=fopen("nr_ulsim.log","w");
dump_pusch_stats(fd,gNB);
......@@ -1388,18 +1483,47 @@ int main(int argc, char **argv)
if(n_trials==1)
break;
if ((float)n_errors[0]/(float)n_trials <= target_error_rate) {
if ((float)n_errors[0][snrRun]/(float)n_trials <= target_error_rate) {
printf("*************\n");
printf("PUSCH test OK\n");
printf("*************\n");
break;
//break;
}
snrStats[snrRun] = SNR;
snrRun++;
n_errs = n_errors[0];
n_errs = n_errors[0][snrRun];
} // SNR loop
printf("\n");
printf( "Num RB:\t%d\n"
"Num symbols:\t%d\n"
"MCS:\t%d\n"
"DMRS config type:\t%d\n"
"DMRS add pos:\t%d\n"
"PUSCH mapping type:\t%d\n"
"DMRS length:\t%d\n"
"DMRS CDM gr w/o data:\t%d\n",
nb_rb,
nb_symb_sch,
Imcs,
dmrs_config_type,
add_pos,
mapping_type,
length_dmrs,
num_dmrs_cdm_grps_no_data);
LOG_M("ulsimStats.m","SNR",snrStats,snrRun,1,7);
LOG_MM("ulsimStats.m","BLER_round0",blerStats[0],snrRun,1,7);
LOG_MM("ulsimStats.m","BLER_round1",blerStats[1],snrRun,1,7);
LOG_MM("ulsimStats.m","BLER_round2",blerStats[2],snrRun,1,7);
LOG_MM("ulsimStats.m","BLER_round3",blerStats[3],snrRun,1,7);
LOG_MM("ulsimStats.m","BER_round0",berStats[0],snrRun,1,7);
LOG_MM("ulsimStats.m","BER_round1",berStats[1],snrRun,1,7);
LOG_MM("ulsimStats.m","BER_round2",berStats[2],snrRun,1,7);
LOG_MM("ulsimStats.m","BER_round3",berStats[3],snrRun,1,7);
LOG_MM("ulsimStats.m","EffRate",effRate,snrRun,1,7);
LOG_MM("ulsimStats.m","EffTP",effTP,snrRun,1,7);
free(test_input_bit);
free(estimated_output_bit);
......
......@@ -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].r=0.0;
desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].i=0.0;
......
......@@ -519,12 +519,12 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS
chan_desc->ch[i] = (struct complexd *) malloc(chan_desc->channel_length * sizeof(struct complexd));
for (int i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complexd *) malloc(1200 * sizeof(struct complexd));
chan_desc->chF[i] = (struct complexd *) malloc((2+(275*12)) * sizeof(struct complexd));
for (int i = 0; i<chan_desc->nb_taps; i++)
chan_desc->a[i] = (struct complexd *) malloc(nb_tx*nb_rx * sizeof(struct complexd));
chan_desc->R_sqrt = (struct complexd **) malloc(6*sizeof(struct complexd **));
chan_desc->R_sqrt = (struct complexd **) malloc(tdl_pathsby3*sizeof(struct complexd **));
if (nb_tx==2 && nb_rx==2) {
for (int i = 0; i<(tdl_pathsby3); i++)
......@@ -1708,10 +1708,8 @@ 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 complexd anew[NB_ANTENNAS_TX*NB_ANTENNAS_RX],acorr[NB_ANTENNAS_TX*NB_ANTENNAS_RX];
struct complexd anew[desc->nb_tx*desc->nb_rx],acorr[desc->nb_tx*desc->nb_rx];
struct complexd 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++) {
......@@ -1735,7 +1733,7 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) {
}
#ifdef DEBUG_CH
printf("(%d,%d,%d) %f->(%f,%f) (%f,%f) phase (%f,%f)\n",aarx,aatx,i,desc->amps[i],anew[aarx+(aatx*desc->nb_rx)].x,anew[aarx+(aatx*desc->nb_rx)].y,desc->aoa,desc->ricean_factor,phase.x,phase.y);
printf("(%d,%d,%d) %f->(%f,%f) (%f,%f) phase (%f,%f)\n",aarx,aatx,i,desc->amps[i],anew[aarx+(aatx*desc->nb_rx)].r,anew[aarx+(aatx*desc->nb_rx)].i,desc->aoa,desc->ricean_factor,phase.r,phase.i);
#endif
} //aatx
} //aarx
......@@ -1827,7 +1825,7 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) {
} //nb_taps
#ifdef DEBUG_CH
printf("(%d,%d,%d)->(%e,%e)\n",k,aarx,aatx,desc->ch[aarx+(aatx*desc->nb_rx)][k].x,desc->ch[aarx+(aatx*desc->nb_rx)][k].y);
printf("(%d,%d,%d)->(%e,%e)\n",k,aarx,aatx,desc->ch[aarx+(aatx*desc->nb_rx)][k].r,desc->ch[aarx+(aatx*desc->nb_rx)][k].i);
#endif
} //channel_length
}
......
......@@ -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,
......
......@@ -1286,24 +1286,30 @@ int64_t *get_prach_config_info(frequency_range_t freq_range,
void find_aggregation_candidates(uint8_t *aggregation_level,
uint8_t *nr_of_candidates,
NR_SearchSpace_t *ss) {
NR_SearchSpace_t *ss,
int maxL) {
AssertFatal(maxL>=1,"maxL %d not ok\n",maxL);
if (ss->nrofCandidates->aggregationLevel1 != NR_SearchSpace__nrofCandidates__aggregationLevel1_n0) {
*aggregation_level = 1;
*nr_of_candidates = ss->nrofCandidates->aggregationLevel1;
}
if (maxL == 1) return;
if (ss->nrofCandidates->aggregationLevel2 != NR_SearchSpace__nrofCandidates__aggregationLevel2_n0) {
*aggregation_level = 2;
*nr_of_candidates = ss->nrofCandidates->aggregationLevel2;
}
if (maxL == 2) return;
if (ss->nrofCandidates->aggregationLevel4 != NR_SearchSpace__nrofCandidates__aggregationLevel4_n0) {
*aggregation_level = 4;
*nr_of_candidates = ss->nrofCandidates->aggregationLevel4;
}
if (maxL == 4) return;
if (ss->nrofCandidates->aggregationLevel8 != NR_SearchSpace__nrofCandidates__aggregationLevel8_n0) {
*aggregation_level = 8;
*nr_of_candidates = ss->nrofCandidates->aggregationLevel8;
}
if (maxL == 8) return;
if (ss->nrofCandidates->aggregationLevel16 != NR_SearchSpace__nrofCandidates__aggregationLevel16_n0) {
*aggregation_level = 16;
*nr_of_candidates = ss->nrofCandidates->aggregationLevel16;
......
......@@ -64,7 +64,8 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDLBWP,
void find_aggregation_candidates(uint8_t *aggregation_level,
uint8_t *nr_of_candidates,
NR_SearchSpace_t *ss);
NR_SearchSpace_t *ss,
int maxL);
void find_monitoring_periodicity_offset_common(NR_SearchSpace_t *ss,
uint16_t *slot_period,
......
......@@ -540,6 +540,7 @@ void config_control_ue(NR_UE_MAC_INST_t *mac){
NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id;
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated;
if (dl_bwp_id==0) AssertFatal(mac->scc_SIB,"dl_bwp_id 0 (DL %d,UL %d) means mac->scc_SIB should exist here!\n",(int)mac->DL_BWP_Id,(int)mac->UL_BWP_Id);
NR_BWP_DownlinkCommon_t *bwp_Common = dl_bwp_id>0 ? scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]->bwp_Common :
&mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP;
......@@ -655,6 +656,9 @@ int nr_rrc_mac_config_req_ue(
if(scell_group_config != NULL ){
mac->cg = scell_group_config;
mac->servCellIndex = *scell_group_config->spCellConfig->servCellIndex;
mac->DL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id : 0;
mac->UL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id : 0;
config_control_ue(mac);
if (scell_group_config->spCellConfig->reconfigurationWithSync) {
if (scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) {
......
......@@ -206,6 +206,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac,
bool use_default);
uint8_t nr_ue_get_sdu(module_id_t module_idP,
int cc_id,
frame_t frameP,
sub_frame_t subframe,
uint8_t gNB_index,
......
......@@ -54,13 +54,18 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd
LOG_D(MAC,"Filling search candidates for DCI\n");
uint8_t aggregation;
find_aggregation_candidates(&aggregation,
&rel15->number_of_candidates,
ss);
for (int i=0; i<rel15->number_of_candidates; i++) {
rel15->CCE[i] = i*aggregation;
rel15->L[i] = aggregation;
uint8_t number_of_candidates=0;
int i=0;
for (int maxL=16;maxL>0;maxL>>1) {
find_aggregation_candidates(&aggregation,
&number_of_candidates,
ss,maxL);
rel15->number_of_candidates += number_of_candidates;
for (; i<rel15->number_of_candidates; i++) {
rel15->CCE[i] = i*aggregation;
rel15->L[i] = aggregation;
}
}
}
......
......@@ -938,11 +938,11 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
if (ulcfg_pdu->pdu_type == FAPI_NR_UL_CONFIG_TYPE_PUSCH) {
uint16_t TBS_bytes = ulcfg_pdu->pusch_config_pdu.pusch_data.tb_size;
LOG_D(NR_MAC,"harq_id %d, NDI %d NDI_DCI %d, TBS_bytes %d\n",
LOG_D(NR_MAC,"harq_id %d, NDI %d NDI_DCI %d, TBS_bytes %d (ra_state %d)\n",
ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id,
mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id],
ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator,
TBS_bytes);
TBS_bytes,ra->ra_state);
if (ra->ra_state == WAIT_RAR && !ra->cfra){
memcpy(ulsch_input_buffer, mac->ulsch_pdu.payload, TBS_bytes);
LOG_D(NR_MAC,"[RAPROC] Msg3 to be transmitted:\n");
......@@ -961,7 +961,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
(ra->ra_state == WAIT_RAR && ra->cfra))){
// Getting IP traffic to be transmitted
nr_ue_get_sdu(mod_id, frame_tx, slot_tx, gNB_index, ulsch_input_buffer, TBS_bytes);
nr_ue_get_sdu(mod_id, cc_id,frame_tx, slot_tx, gNB_index, ulsch_input_buffer, TBS_bytes);
}
LOG_D(NR_MAC,"Flipping NDI for harq_id %d\n",ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator);
......@@ -2042,6 +2042,7 @@ void nr_ue_sib1_scheduler(module_id_t module_idP,
to generate the complete MAC PDU with sub-headers and MAC CEs according to ULSCH MAC PDU generation (6.1.2 TS 38.321)
the selected sub-header for the payload sub-PDUs is NR_MAC_SUBHEADER_LONG
* @module_idP Module ID
* @CC_id Component Carrier index
* @frameP current UL frame
* @subframe current UL slot
* @gNB_index gNB index
......@@ -2049,6 +2050,7 @@ void nr_ue_sib1_scheduler(module_id_t module_idP,
* @buflen TBS
*/
uint8_t nr_ue_get_sdu(module_id_t module_idP,
int CC_id,
frame_t frameP,
sub_frame_t subframe,
uint8_t gNB_index,
......
......@@ -614,6 +614,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
}
UE_info->UE_sched_ctrl->search_space = get_searchspace(scc, bwpd, target_ss);
UE_info->UE_sched_ctrl->coreset = get_coreset(scc, bwpd, UE_info->UE_sched_ctrl->search_space, target_ss);
UE_info->UE_sched_ctrl->maxL = 2;
}
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
......
......@@ -724,36 +724,23 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t
tdd_beam_association[num_tdd_period] = ra->beam_id;
}
int bwpSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
int bwpStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
int scs = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing;
int fh = 0;
int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength;
int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType;
if (ra->CellGroup) {
AssertFatal(ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
"downlinkBWP_ToAddModList has %d BWP!\n", ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
int act_bwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
int act_bwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength;
mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType;
scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing;
fh = ubwp->bwp_Dedicated->pusch_Config->choice.setup->frequencyHopping ? 1 : 0;
if ((bwpStart < act_bwp_start) || (bwpSize > act_bwp_size))
bwpStart = act_bwp_start;
}
uint16_t *vrb_map_UL =
&RC.nrmac[module_idP]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE];
uint16_t *vrb_map_UL = &RC.nrmac[module_idP]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE];
int BWPStart = nr_mac->type0_PDCCH_CSS_config[ra->beam_id].cset_start_rb;
int BWPSize = nr_mac->type0_PDCCH_CSS_config[ra->beam_id].num_rbs;
int rbStart = 0;
for (int i = 0; (i < ra->msg3_nb_rb) && (rbStart <= (bwpSize - ra->msg3_nb_rb)); i++) {
if (vrb_map_UL[rbStart + bwpStart + i]) {
for (int i = 0; (i < ra->msg3_nb_rb) && (rbStart <= (BWPSize - ra->msg3_nb_rb)); i++) {
if (vrb_map_UL[rbStart + BWPStart + i]) {
rbStart += i;
i = 0;
}
}
if (rbStart > (bwpSize - ra->msg3_nb_rb)) {
if (rbStart > (BWPSize - ra->msg3_nb_rb)) {
// cannot find free vrb_map for msg3 retransmission in this slot
return;
}
......@@ -778,34 +765,17 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t
ra->msg3_round,
startSymbolAndLength,
ra->rnti, scs,
bwpSize, bwpStart,
BWPSize, BWPStart,
mappingtype, fh,
rbStart, ra->msg3_nb_rb);
future_ul_tti_req->n_pdus += 1;
// generation of DCI 0_0 to schedule msg3 retransmission
NR_SearchSpace_t *ss = ra->ra_ss;
NR_BWP_Downlink_t *bwp = NULL;
NR_ControlResourceSet_t *coreset = NULL;
NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = *ss->controlResourceSetId==0 ? &nr_mac->type0_PDCCH_CSS_config[ra->beam_id] : NULL;
NR_BWP_t *genericParameters = NULL;
if (ra->CellGroup &&
ra->CellGroup->spCellConfig &&
ra->CellGroup->spCellConfig->spCellConfigDedicated &&
ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList &&
ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]) {
bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1];
genericParameters = &bwp->bwp_Common->genericParameters;
}
else {
genericParameters= &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters;
}
if (*ss->controlResourceSetId == 0)
coreset = nr_mac->sched_ctrlCommon->coreset; // this is coreset 0
else
coreset = get_coreset(scc, bwp, ss, NR_SearchSpace__searchSpaceType_PR_common);
coreset = nr_mac->sched_ctrlCommon->coreset; // this is coreset 0
AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg3 retransmission\n");
nfapi_nr_ul_dci_request_t *ul_dci_req = &nr_mac->UL_dci_req[CC_id];
......@@ -825,8 +795,8 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t
uint8_t aggregation_level;
uint8_t nr_of_candidates;
find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss);
int CCEIndex = allocate_nr_CCEs(nr_mac, bwp, coreset, aggregation_level, 0, 0, nr_of_candidates);
find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss, 4);
int CCEIndex = allocate_nr_CCEs(nr_mac, NULL, coreset, aggregation_level, 0, 0, nr_of_candidates);
if (CCEIndex < 0) {
LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti);
return;
......@@ -868,7 +838,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t
// Mark the corresponding RBs as used
for (int rb = 0; rb < ra->msg3_nb_rb; rb++) {
vrb_map_UL[rbStart + bwpStart + rb] = 1;
vrb_map_UL[rbStart + BWPStart + rb] = 1;
}
// reset state to wait msg3
......@@ -1200,7 +1170,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
uint8_t aggregation_level;
uint8_t nr_of_candidates;
find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss);
find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss,4);
int CCEIndex = allocate_nr_CCEs(nr_mac, bwp, coreset, aggregation_level,0,0,nr_of_candidates);
if (CCEIndex < 0) {
LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti);
......@@ -1470,7 +1440,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
// get CCEindex, needed also for PUCCH and then later for PDCCH
uint8_t aggregation_level;
uint8_t nr_of_candidates;
find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss);
find_aggregation_candidates(&aggregation_level, &nr_of_candidates, ss,4);
int CCEIndex = allocate_nr_CCEs(nr_mac, bwp, coreset, aggregation_level,0,0,nr_of_candidates);
if (CCEIndex < 0) {
LOG_E(NR_MAC, "%s(): cannot find free CCE for RA RNTI %04x!\n", __func__, ra->rnti);
......
......@@ -349,8 +349,8 @@ uint32_t schedule_control_sib1(module_id_t module_id,
gNB_mac->sched_ctrlCommon->num_total_bytes = num_total_bytes;
uint8_t nr_of_candidates;
find_aggregation_candidates(&gNB_mac->sched_ctrlCommon->aggregation_level, &nr_of_candidates, gNB_mac->sched_ctrlCommon->search_space);
find_aggregation_candidates(&gNB_mac->sched_ctrlCommon->aggregation_level, &nr_of_candidates, gNB_mac->sched_ctrlCommon->search_space,8);
AssertFatal(nr_of_candidates>0,"nr_of_candidates is 0\n");
gNB_mac->sched_ctrlCommon->cce_index = allocate_nr_CCEs(RC.nrmac[module_id],
NULL,
gNB_mac->sched_ctrlCommon->coreset,
......
......@@ -740,7 +740,7 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t
if (UE_info->num_UEs == 0)
return;
if (slot!=1) return;
if (slot!=1 && slot!=11) return;
const int CC_id = 0;
......@@ -884,11 +884,12 @@ void nr_schedule_ue_spec(module_id_t module_id,
UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++;
LOG_D(NR_MAC,
"%4d.%2d [DLSCH/PDSCH/PUCCH] UE %d RNTI %04x start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) TPC %d\n",
"%4d.%2d [DLSCH/PDSCH/PUCCH] UE %d RNTI %04x DCI L %d start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) TPC %d\n",
frame,
slot,
UE_id,
rnti,
sched_ctrl->aggregation_level,
sched_pdsch->rbStart,
sched_pdsch->rbSize,
ps->startSymbolIndex,
......
......@@ -326,7 +326,8 @@ void nr_preprocessor_phytest(module_id_t module_id,
uint8_t nr_of_candidates;
find_aggregation_candidates(&sched_ctrl->aggregation_level,
&nr_of_candidates,
sched_ctrl->search_space);
sched_ctrl->search_space,
sched_ctrl->maxL);
const int cid = sched_ctrl->coreset->controlResourceSetId;
const uint16_t Y = UE_info->Y[UE_id][cid][slot];
const int m = UE_info->num_pdcch_cand[UE_id][cid];
......@@ -483,7 +484,8 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_
uint8_t nr_of_candidates;
find_aggregation_candidates(&sched_ctrl->aggregation_level,
&nr_of_candidates,
sched_ctrl->search_space);
sched_ctrl->search_space,
sched_ctrl->maxL);
const int cid = sched_ctrl->coreset->controlResourceSetId;
const uint16_t Y = UE_info->Y[UE_id][cid][slot];
const int m = UE_info->num_pdcch_cand[UE_id][cid];
......
......@@ -2342,7 +2342,8 @@ bool find_free_CCE(module_id_t module_id,
uint8_t nr_of_candidates;
find_aggregation_candidates(&sched_ctrl->aggregation_level,
&nr_of_candidates,
sched_ctrl->search_space);
sched_ctrl->search_space,
sched_ctrl->maxL);
const int cid = sched_ctrl->coreset->controlResourceSetId;
const uint16_t Y = RC.nrmac[module_id]->UE_info.Y[UE_id][cid][slot];
const int m = RC.nrmac[module_id]->UE_info.num_pdcch_cand[UE_id][cid];
......
......@@ -406,10 +406,8 @@ int nr_process_mac_pdu(module_id_t module_idP,
1,
NULL);
} else {
LOG_W(NR_MAC,"[UE %d] Frame/Slot %d.%d : Received LCID %d which is not configured, dropping packet\n",UE_id,frameP,slot,rx_lcid);
return -1;
AssertFatal(1==0,"[UE %d] Frame/Slot %d.%d : Received LCID %d which is not configured, dropping packet\n",UE_id,frameP,slot,rx_lcid);
}
break;
case UL_SCH_LCID_SRB3:
// todo
......@@ -930,6 +928,7 @@ bool allocate_ul_retransmission(module_id_t module_id,
const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_bwp || ubwpd) ? 1 : 2;
const int tda = sched_ctrl->active_ubwp ? RC.nrmac[module_id]->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 0;
LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda);
printf("num_dmrs_cdm_grps_no_data %d, tbs %d\n",num_dmrs_cdm_grps_no_data,retInfo->tb_size);
if (tda == retInfo->time_domain_allocation) {
/* Check the resource is enough for retransmission */
while (rbStart < bwpSize && !rballoc_mask[rbStart])
......@@ -1484,12 +1483,13 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot)
sched_ctrl->last_ul_slot = sched_pusch->slot;
LOG_D(NR_MAC,
"ULSCH/PUSCH: %4d.%2d RNTI %04x UL sched %4d.%2d start %2d RBS %3d startSymbol %2d nb_symbol %2d dmrs_pos %x MCS %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d est %6d sched %6d est BSR %6d TPC %d\n",
"ULSCH/PUSCH: %4d.%2d RNTI %04x UL sched %4d.%2d DCI L %d start %2d RBS %3d startSymbol %2d nb_symbol %2d dmrs_pos %x MCS %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d est %6d sched %6d est BSR %6d TPC %d\n",
frame,
slot,
rnti,
sched_pusch->frame,
sched_pusch->slot,
sched_ctrl->aggregation_level,
sched_pusch->rbStart,
sched_pusch->rbSize,
ps->startSymbolIndex,
......
......@@ -530,7 +530,8 @@ typedef struct {
/// corresponding to the sched_pusch/sched_pdsch structures below
int cce_index;
uint8_t aggregation_level;
/// maximum aggregation level for UE, can be used to select level
int maxL;
/// PUCCH scheduling information. Array of two: HARQ+SR in the first field,
/// CSI in second. This order is important for nr_acknack_scheduling()!
NR_sched_pucch_t sched_pucch[2];
......
......@@ -399,15 +399,22 @@ int rlc_module_init(int enb_flag)
{
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static int inited = 0;
static int inited_ue = 0;
if (pthread_mutex_lock(&lock)) abort();
if (inited) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
if (enb_flag == 1 && inited) {
LOG_E(RLC, "%s:%d:%s: fatal, inited already 1\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
if (enb_flag == 0 && inited_ue) {
LOG_E(RLC, "%s:%d:%s: fatal, inited_ue already 1\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
inited = 1;
if (enb_flag == 1) inited = 1;
if (enb_flag == 0) inited_ue = 1;
nr_rlc_ue_manager = new_nr_rlc_ue_manager(enb_flag);
......
......@@ -1311,6 +1311,19 @@ void fill_initial_SpCellConfig(rnti_t rnti,
ASN_SEQUENCE_ADD(&bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcic);
SpCellConfig->spCellConfigDedicated->tag_Id=0;
SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig));
NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig = calloc(1,sizeof(*pdsch_servingcellconfig));
SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup;
SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig;
pdsch_servingcellconfig->codeBlockGroupTransmission = NULL;
pdsch_servingcellconfig->xOverhead = NULL;
pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH));
*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = NR_PDSCH_ServingCellConfig__nrofHARQ_ProcessesForPDSCH_n16;
pdsch_servingcellconfig->pucch_Cell= NULL;
pdsch_servingcellconfig->ext1=calloc(1,sizeof(*pdsch_servingcellconfig->ext1));
pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1,sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers));
*pdsch_servingcellconfig->ext1->maxMIMO_Layers = 2;
}
void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup) {
......
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