Commit 4fe59868 authored by Parminder Singh's avatar Parminder Singh

Corrected conditional statement wrt OAI Formatting Rules

parent b402026a
......@@ -558,28 +558,24 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB,
uint16_t *nb_rb = &rel15_ul->rb_size;
uint8_t *ptrsReOffset = &rel15_ul->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset;
/* loop over antennas */
for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++)
{
for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
phase_per_symbol = (int16_t*)gNB->pusch_vars[ulsch_id]->ptrs_phase_per_slot[aarx];
ptrs_re_symbol = &gNB->pusch_vars[ulsch_id]->ptrs_re_per_slot;
*ptrs_re_symbol = 0;
phase_per_symbol[(2*symbol)+1] = 0; // Imag
/* set DMRS estimates to 0 angle with magnitude 1 */
if(is_dmrs_symbol(symbol,*dmrsSymbPos))
{
if(is_dmrs_symbol(symbol,*dmrsSymbPos)) {
/* set DMRS real estimation to 32767 */
phase_per_symbol[2*symbol]=(int16_t)((1<<15)-1); // 32767
#ifdef DEBUG_UL_PTRS
printf("[PHY][PTRS]: DMRS Symbol %d -> %4d + j*%4d\n", symbol, phase_per_symbol[2*symbol],phase_per_symbol[(2*symbol)+1]);
#endif
}
else// real ptrs value is set to 0
{
else {// real ptrs value is set to 0
phase_per_symbol[2*symbol] = 0; // Real
}
if(symbol == *startSymbIndex)
{
if(symbol == *startSymbIndex) {
*ptrsSymbPos = 0;
set_ptrs_symb_idx(ptrsSymbPos,
*nbSymb,
......@@ -590,8 +586,7 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB,
/* if not PTRS symbol set current ptrs symbol index to zero*/
*ptrsSymbIdx = 0;
/* Check if current symbol contains PTRS */
if(is_ptrs_symbol(symbol, *ptrsSymbPos))
{
if(is_ptrs_symbol(symbol, *ptrsSymbPos)) {
*ptrsSymbIdx = symbol;
/*------------------------------------------------------------------------------------------------------- */
/* 1) Estimate common phase error per PTRS symbol */
......@@ -607,17 +602,14 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB,
ptrs_re_symbol);
}
/* For last OFDM symbol at each antenna perform interpolation and compensation for the slot*/
if(symbol == (symbInSlot -1))
{
if(symbol == (symbInSlot -1)) {
/*------------------------------------------------------------------------------------------------------- */
/* 2) Interpolate PTRS estimated value in TD */
/*------------------------------------------------------------------------------------------------------- */
/* If L-PTRS is > 0 then we need interpolation */
if(*L_ptrs > 0)
{
if(*L_ptrs > 0) {
ret = nr_ptrs_process_slot(*dmrsSymbPos, *ptrsSymbPos, phase_per_symbol, *startSymbIndex, *nbSymb);
if(ret != 0)
{
if(ret != 0) {
LOG_W(PHY,"[PTRS] Compensation is skipped due to error in PTRS slot processing !!\n");
}
}
......@@ -630,12 +622,10 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB,
/*------------------------------------------------------------------------------------------------------- */
/* 3) Compensated DMRS based estimated signal with PTRS estimation */
/*--------------------------------------------------------------------------------------------------------*/
for(uint8_t i = *startSymbIndex; i< symbInSlot ;i++)
{
for(uint8_t i = *startSymbIndex; i< symbInSlot ;i++) {
/* DMRS Symbol has 0 phase so no need to rotate the respective symbol */
/* Skip rotation if the slot processing is wrong */
if((!is_dmrs_symbol(i,*dmrsSymbPos)) && (ret == 0))
{
if((!is_dmrs_symbol(i,*dmrsSymbPos)) && (ret == 0)) {
#ifdef DEBUG_UL_PTRS
printf("[PHY][UL][PTRS]: Rotate Symbol %2d with %d + j* %d\n", i, phase_per_symbol[2* i],phase_per_symbol[(2* i) +1]);
#endif
......
......@@ -365,10 +365,8 @@ void generate_dmrs_pbch(uint32_t dmrs_pbch_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_H
/* return the position of next dmrs symbol in a slot */
int8_t get_next_dmrs_symbol_in_slot(uint16_t ul_dmrs_symb_pos, uint8_t counter, uint8_t end_symbol)
{
for(uint8_t symbol = counter; symbol < end_symbol; symbol++)
{
if((ul_dmrs_symb_pos >> symbol) & 0x01 )
{
for(uint8_t symbol = counter; symbol < end_symbol; symbol++) {
if((ul_dmrs_symb_pos >> symbol) & 0x01 ) {
return symbol;
}
}
......@@ -380,8 +378,7 @@ int8_t get_next_dmrs_symbol_in_slot(uint16_t ul_dmrs_symb_pos, uint8_t counter,
uint8_t get_dmrs_symbols_in_slot(uint16_t l_prime_mask, uint16_t nb_symb)
{
uint8_t tmp = 0;
for (int i = 0; i < nb_symb; i++)
{
for (int i = 0; i < nb_symb; i++) {
tmp += (l_prime_mask >> i) & 0x01;
}
return tmp;
......@@ -392,22 +389,18 @@ int8_t get_valid_dmrs_idx_for_channel_est(uint16_t dmrs_symb_pos, uint8_t count
{
int8_t symbIdx = -1;
/* if current symbol is DMRS then return this index */
if(is_dmrs_symbol(counter, dmrs_symb_pos ) ==1)
{
if(is_dmrs_symbol(counter, dmrs_symb_pos ) ==1) {
return counter;
}
/* find previous DMRS symbol */
for(int8_t symbol = counter;symbol >=0 ; symbol--)
{
if((1<<symbol & dmrs_symb_pos)> 0)
{
for(int8_t symbol = counter;symbol >=0 ; symbol--) {
if((1<<symbol & dmrs_symb_pos)> 0) {
symbIdx = symbol;
break;
}
}
/* if there is no previous dmrs available then find the next possible*/
if(symbIdx == -1)
{
if(symbIdx == -1) {
symbIdx = get_next_dmrs_symbol_in_slot(dmrs_symb_pos,counter,15);
}
return symbIdx;
......
......@@ -194,10 +194,8 @@ uint8_t get_ptrs_symbols_in_slot(uint16_t l_prime_mask, uint16_t start_symb, uin
/* return the position of next ptrs symbol in a slot */
int8_t get_next_ptrs_symbol_in_slot(uint16_t ptrs_symb_pos, uint8_t counter, uint8_t nb_symb)
{
for(int8_t symbol = counter; symbol < nb_symb; symbol++)
{
if((ptrs_symb_pos >>symbol)&0x01 )
{
for(int8_t symbol = counter; symbol < nb_symb; symbol++) {
if((ptrs_symb_pos >>symbol)&0x01 ) {
return symbol;
}
}
......@@ -209,13 +207,11 @@ int8_t get_next_estimate_in_slot(uint16_t ptrsSymbPos,uint16_t dmrsSymbPos, ui
{
int8_t nextPtrs = get_next_ptrs_symbol_in_slot(ptrsSymbPos, counter,nb_symb);
int8_t nextDmrs = get_next_dmrs_symbol_in_slot(dmrsSymbPos, counter,nb_symb);
if(nextDmrs == -1)
{
if(nextDmrs == -1) {
return nextPtrs;
}
/* Special case when DMRS is next valid estimation */
if(nextPtrs == -1)
{
if(nextPtrs == -1) {
return nextDmrs;
}
return (nextPtrs > nextDmrs)?nextDmrs:nextPtrs;
......@@ -276,8 +272,7 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs,
nr_gen_ref_conj_symbols(gold_seq,sc_per_symbol*2,ptrs_p, NR_MOD_TABLE_QPSK_OFFSET,2);// 2 for QPSK
/* loop over all sub carriers to get compensated RE on ptrs symbols*/
for (int re = 0; re < nb_re_pdsch; re++)
{
for (int re = 0; re < nb_re_pdsch; re++) {
is_ptrs_re = is_ptrs_subcarrier(re,
rnti,
0,
......@@ -287,14 +282,12 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs,
ptrsReOffset,
0,// start_re is 0 here
ofdm_symbol_size);
if(is_ptrs_re)
{
if(is_ptrs_re) {
dmrs_comp_p[re_cnt*2] = rxF_comp[re *2];
dmrs_comp_p[(re_cnt*2)+1] = rxF_comp[(re *2)+1];
re_cnt++;
}
else
{
else {
/* Skip PTRS symbols and keep data in a continuous vector */
rxF_comp[cnt *2]= rxF_comp[re *2];
rxF_comp[(cnt *2)+1]= rxF_comp[(re *2)+1];
......@@ -309,8 +302,7 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs,
/* loop over all ptrs sub carriers in a symbol */
/* sum the error vector */
for(int i = 0;i < sc_per_symbol; i++)
{
for(int i = 0;i < sc_per_symbol; i++) {
real+= ptrs_ch_p[(2*i)];
imag+= ptrs_ch_p[(2*i)+1];
}
......@@ -363,45 +355,37 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
int8_t rightRef = 0;
int8_t leftRef = 0;
int8_t tmp = 0;
for(uint8_t symb = startSymbIdx; symb <symbInSlot; symb ++)
{
for(uint8_t symb = startSymbIdx; symb <symbInSlot; symb ++) {
/* Update left and right reference from an estimated symbol */
if((is_ptrs_symbol(symb, ptrsSymbPos)) || (is_dmrs_symbol(symb,dmrsSymbPos)))
{
if((is_ptrs_symbol(symb, ptrsSymbPos)) || (is_dmrs_symbol(symb,dmrsSymbPos))) {
leftRef = symb;
rightRef = get_next_estimate_in_slot(ptrsSymbPos,dmrsSymbPos,symb+1,symbInSlot);
}
else
{
else {
/* The very first symbol must be a PTRS or DMRS */
if((symb == startSymbIdx) && (leftRef == -1) && (rightRef == -1))
{
if((symb == startSymbIdx) && (leftRef == -1) && (rightRef == -1)) {
printf("Wrong PTRS Setup, PTRS compensation will be skipped !");
return -1;
}
/* check for left side first */
/* right side a DMRS symbol then we need to left extrapolate */
if(is_dmrs_symbol(rightRef,dmrsSymbPos))
{
if(is_dmrs_symbol(rightRef,dmrsSymbPos)) {
/* calculate slope from next valid estimates*/
tmp = get_next_estimate_in_slot(ptrsSymbPos,dmrsSymbPos,rightRef+1,symbInSlot);
/* Special case when DMRS is not followed by PTRS symbol then reuse old slope */
if(tmp!=-1)
{
if(tmp!=-1) {
get_slope_from_estimates(rightRef, tmp, estPerSymb, slope_p);
}
ptrs_estimate_from_slope(estPerSymb,slope_p,leftRef, rightRef);
symb = rightRef -1;
}
else if(is_ptrs_symbol(rightRef,ptrsSymbPos))
{
else if(is_ptrs_symbol(rightRef,ptrsSymbPos)) {
/* calculate slope from next valid estimates */
get_slope_from_estimates(leftRef,rightRef,estPerSymb, slope_p);
ptrs_estimate_from_slope(estPerSymb,slope_p,leftRef, rightRef);
symb = rightRef -1;
}
else if((rightRef ==-1) && (symb <symbInSlot))
{
else if((rightRef ==-1) && (symb <symbInSlot)) {
// in right extrapolation use the last slope
#ifdef DEBUG_PTRS
printf("[PHY][PTRS]: Last Slop Reused :(%4f %4f)\n", slope_p[0],slope_p[1]);
......@@ -409,8 +393,7 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
ptrs_estimate_from_slope(estPerSymb,slope_p,symb-1,symbInSlot);
symb = symbInSlot;
}
else
{
else {
printf("Wrong PTRS Setup, PTRS compensation will be skipped !");
return -1;
}
......@@ -434,8 +417,7 @@ void get_slope_from_estimates(uint8_t start, uint8_t end, int16_t *est_p, double
/* estimate from slope */
void ptrs_estimate_from_slope(int16_t *error_est, double *slope_p, uint8_t start, uint8_t end)
{
for(uint8_t i = 1; i< (end -start);i++)
{
for(uint8_t i = 1; i< (end -start);i++) {
error_est[(start+i)*2] = (error_est[start*2] + (int16_t)(i * slope_p[0]));// real
error_est[((start +i)*2)+1] = (error_est[(start*2)+1] + (int16_t)( i * slope_p[1])); //imag
#ifdef DEBUG_PTRS
......
......@@ -169,8 +169,7 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB,
uint16_t n_ptrs = 0;
uint16_t ptrs_idx = 0;
uint8_t is_ptrs_re = 0;
if(rel15->pduBitmap & 0x1)
{
if(rel15->pduBitmap & 0x1) {
set_ptrs_symb_idx(&dlPtrsSymPos,
rel15->NrOfSymbols,
rel15->StartSymbolIndex,
......@@ -325,11 +324,9 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB,
/* calculate if current symbol is PTRS symbols */
ptrs_idx = 0;
if(rel15->pduBitmap & 0x1)
{
if(rel15->pduBitmap & 0x1) {
ptrs_symbol = is_ptrs_symbol(l,dlPtrsSymPos);
if(ptrs_symbol)
{
if(ptrs_symbol) {
/* PTRS QPSK Modulation for each OFDM symbol in a slot */
nr_modulation(pdsch_dmrs[l][0], (n_ptrs<<1), DMRS_MOD_ORDER, mod_ptrs);
}
......
......@@ -994,8 +994,7 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue,
uint8_t *dmrsConfigType = NULL;
uint16_t *nb_rb = NULL;
if(dlsch0_harq->status == ACTIVE)
{
if(dlsch0_harq->status == ACTIVE) {
symbInSlot = dlsch0_harq->start_symbol + dlsch0_harq->nb_symbols;
startSymbIndex = &dlsch0_harq->start_symbol;
nbSymb = &dlsch0_harq->nb_symbols;
......@@ -1008,8 +1007,7 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue,
dmrsConfigType = &dlsch0_harq->ptrs_symbol_index;
nb_rb = &dlsch0_harq->nb_rb;
}
if(dlsch1_harq)
{
if(dlsch1_harq) {
symbInSlot = dlsch1_harq->start_symbol + dlsch0_harq->nb_symbols;
startSymbIndex = &dlsch1_harq->start_symbol;
nbSymb = &dlsch1_harq->nb_symbols;
......@@ -1023,30 +1021,25 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue,
nb_rb = &dlsch1_harq->nb_rb;
}
/* loop over antennas */
for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++)
{
for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
phase_per_symbol = (int16_t*)pdsch_vars[eNB_id]->ptrs_phase_per_slot[aarx];
ptrs_re_symbol = (int32_t*)pdsch_vars[eNB_id]->ptrs_re_per_slot[aarx];
ptrs_re_symbol[symbol] = 0;
phase_per_symbol[(2*symbol)+1] = 0; // Imag
/* set DMRS estimates to 0 angle with magnitude 1 */
if(is_dmrs_symbol(symbol,*dmrsSymbPos))
{
if(is_dmrs_symbol(symbol,*dmrsSymbPos)) {
/* set DMRS real estimation to 32767 */
phase_per_symbol[2*symbol]=(int16_t)((1<<15)-1); // 32767
#ifdef DEBUG_DL_PTRS
printf("[PHY][PTRS]: DMRS Symbol %d -> %4d + j*%4d\n", symbol, phase_per_symbol[2*symbol],phase_per_symbol[(2*symbol)+1]);
#endif
}
else// real ptrs value is set to 0
{
else { // real ptrs value is set to 0
phase_per_symbol[2*symbol] = 0; // Real
}
if(dlsch0_harq->status == ACTIVE)
{
if(symbol == *startSymbIndex)
{
if(dlsch0_harq->status == ACTIVE) {
if(symbol == *startSymbIndex) {
*ptrsSymbPos = 0;
set_ptrs_symb_idx(ptrsSymbPos,
*nbSymb,
......@@ -1057,8 +1050,7 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue,
/* if not PTRS symbol set current ptrs symbol index to zero*/
*ptrsSymbIdx = 0;
/* Check if current symbol contains PTRS */
if(is_ptrs_symbol(symbol, *ptrsSymbPos))
{
if(is_ptrs_symbol(symbol, *ptrsSymbPos)) {
*ptrsSymbIdx = symbol;
/*------------------------------------------------------------------------------------------------------- */
/* 1) Estimate common phase error per PTRS symbol */
......@@ -1076,17 +1068,14 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue,
}// HARQ 0
/* For last OFDM symbol at each antenna perform interpolation and compensation for the slot*/
if(symbol == (symbInSlot -1))
{
if(symbol == (symbInSlot -1)) {
/*------------------------------------------------------------------------------------------------------- */
/* 2) Interpolate PTRS estimated value in TD */
/*------------------------------------------------------------------------------------------------------- */
/* If L-PTRS is > 0 then we need interpolation */
if(*L_ptrs > 0)
{
if(*L_ptrs > 0) {
ret = nr_ptrs_process_slot(*dmrsSymbPos, *ptrsSymbPos, phase_per_symbol, *startSymbIndex, *nbSymb);
if(ret != 0)
{
if(ret != 0) {
LOG_W(PHY,"[PTRS] Compensation is skipped due to error in PTRS slot processing !!\n");
}
}
......@@ -1099,12 +1088,10 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue,
/*------------------------------------------------------------------------------------------------------- */
/* 3) Compensated DMRS based estimated signal with PTRS estimation */
/*--------------------------------------------------------------------------------------------------------*/
for(uint8_t i = *startSymbIndex; i< symbInSlot ;i++)
{
for(uint8_t i = *startSymbIndex; i< symbInSlot ;i++) {
/* DMRS Symbol has 0 phase so no need to rotate the respective symbol */
/* Skip rotation if the slot processing is wrong */
if((!is_dmrs_symbol(i,*dmrsSymbPos)) && (ret == 0))
{
if((!is_dmrs_symbol(i,*dmrsSymbPos)) && (ret == 0)) {
#ifdef DEBUG_DL_PTRS
printf("[PHY][DL][PTRS]: Rotate Symbol %2d with %d + j* %d\n", i, phase_per_symbol[2* i],phase_per_symbol[(2* i) +1]);
#endif
......
......@@ -693,22 +693,19 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
/* Store the valid DL RE's */
pdsch_vars[eNB_id]->dl_valid_re[symbol-1] = len;
if(dlsch0_harq->status == ACTIVE)
{
if(dlsch0_harq->status == ACTIVE) {
startSymbIdx = dlsch0_harq->start_symbol;
nbSymb = dlsch0_harq->nb_symbols;
pduBitmap = dlsch0_harq->pduBitmap;
}
if(dlsch1_harq)
{
if(dlsch1_harq) {
startSymbIdx = dlsch1_harq->start_symbol;
nbSymb = dlsch1_harq->nb_symbols;
pduBitmap = dlsch1_harq->pduBitmap;
}
/* Check for PTRS bitmap and process it respectively */
if((pduBitmap & 0x1) && (type == PDSCH))
{
if((pduBitmap & 0x1) && (type == PDSCH)) {
nr_pdsch_ptrs_processing(ue,
pdsch_vars,
frame_parms,
......@@ -721,17 +718,13 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
}
/* at last symbol in a slot calculate LLR's for whole slot */
if(symbol == (startSymbIdx + nbSymb -1))
{
for(uint8_t i =startSymbIdx; i <= nbSymb;i++)
{
if(symbol == (startSymbIdx + nbSymb -1)) {
for(uint8_t i =startSymbIdx; i <= nbSymb;i++) {
/* re evaluating the first symbol flag as LLR's are done in symbol loop */
if(i == startSymbIdx && i < 3)
{
if(i == startSymbIdx && i < 3) {
first_symbol_flag =1;
}
else
{
else {
first_symbol_flag=0;
}
/* Calculate LLR's for each symbol */
......
......@@ -466,13 +466,13 @@ int main(int argc, char **argv)
case 'T':
enable_ptrs=1;
for(i=0; i < atoi(optarg); i++){
for(i=0; i < atoi(optarg); i++) {
ptrs_arg[i] = atoi(argv[optind++]);
}
break;
case 'U':
modify_dmrs = 1;
for(i=0; i < atoi(optarg); i++){
for(i=0; i < atoi(optarg); i++) {
dmrs_arg[i] = atoi(argv[optind++]);
}
break;
......@@ -610,13 +610,11 @@ int main(int argc, char **argv)
0);
/* -U option modify DMRS */
if(modify_dmrs)
{
if(modify_dmrs) {
update_dmrs_config(secondaryCellGroup, NULL,dmrs_arg);
}
/* -T option enable PTRS */
if(enable_ptrs)
{
if(enable_ptrs) {
update_ptrs_config(secondaryCellGroup, &rbSize, &mcsIndex, ptrs_arg);
}
......@@ -737,8 +735,7 @@ int main(int argc, char **argv)
exit(-1);
}
if(modify_dmrs)
{
if(modify_dmrs) {
update_dmrs_config( NULL,UE,dmrs_arg);
}
init_nr_ue_transport(UE,0);
......@@ -891,7 +888,7 @@ int main(int argc, char **argv)
nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[1];
nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15;
pdu_bit_map = pdsch_pdu_rel15->pduBitmap;
if(pdu_bit_map & 0x1){
if(pdu_bit_map & 0x1) {
set_ptrs_symb_idx(&dlPtrsSymPos,
pdsch_pdu_rel15->NrOfSymbols,
pdsch_pdu_rel15->StartSymbolIndex,
......@@ -899,7 +896,7 @@ int main(int argc, char **argv)
pdsch_pdu_rel15->dlDmrsSymbPos);
ptrsSymbPerSlot = get_ptrs_symbols_in_slot(dlPtrsSymPos, pdsch_pdu_rel15->StartSymbolIndex, pdsch_pdu_rel15->NrOfSymbols);
ptrsRePerSymb = ((rel15->rbSize + rel15->PTRSFreqDensity - 1)/rel15->PTRSFreqDensity);
printf("[DLSIM] PTRS Symbols in a slot: %2d, RE per Symbol: %3d, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb );
printf("[DLSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb );
}
if (run_initial_sync)
nr_common_signal_procedures(gNB,frame,slot);
......@@ -998,8 +995,7 @@ int main(int argc, char **argv)
((short*) UE->common_vars.rxdata[aa])[2*i] = (short) ((r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
((short*) UE->common_vars.rxdata[aa])[2*i+1] = (short) ((r_im[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
/* Add phase noise if enabled */
if (pdu_bit_map & 0x1)
{
if (pdu_bit_map & 0x1) {
phase_noise(ts, &((short*) UE->common_vars.rxdata[aa])[2*i],
&((short*) UE->common_vars.rxdata[aa])[2*i+1]);
}
......@@ -1037,10 +1033,9 @@ int main(int argc, char **argv)
uint8_t nb_symb_sch = rel15->NrOfSymbols;
available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, rel15->nrOfLayers);
if(pdu_bit_map & 0x1)
{
if(pdu_bit_map & 0x1) {
available_bits-= (ptrsSymbPerSlot * ptrsRePerSymb *rel15->nrOfLayers* 2);
printf("[DLSIM][PTRS] Available bits are: %5d, removed PTRS bits are: %5d \n",available_bits, (ptrsSymbPerSlot * ptrsRePerSymb *rel15->nrOfLayers* 2) );
printf("[DLSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5u \n",available_bits, (ptrsSymbPerSlot * ptrsRePerSymb *rel15->nrOfLayers* 2) );
}
for (i = 0; i < available_bits; i++) {
......@@ -1093,7 +1088,7 @@ int main(int argc, char **argv)
printf("*****************************************\n");
printf("\n");
dump_pdsch_stats(gNB);
printf("SNR %f : n_errors (negative CRC) = %d/%d, Avg round %.2f, Channel BER %e, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %d bits/slot\n", SNR, n_errors, n_trials,roundStats[snrRun],(double)errors_scrambling/available_bits/n_trials,effRate,effRate/TBS*100,TBS);
printf("SNR %f : n_errors (negative CRC) = %d/%d, Avg round %.2f, Channel BER %e, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", SNR, n_errors, n_trials,roundStats[snrRun],(double)errors_scrambling/available_bits/n_trials,effRate,effRate/TBS*100,TBS);
printf("\n");
if (print_perf==1) {
......@@ -1219,36 +1214,29 @@ void update_ptrs_config(NR_CellGroupConfig_t *secondaryCellGroup, uint16_t *rbSi
int epre_Ratio = 0;
int reOffset = 0;
if(ptrs_arg[0] ==0)
{
if(ptrs_arg[0] ==0) {
ptrsTimeDenst[2]= *mcsIndex -1;
}
else if(ptrs_arg[0] == 1)
{
else if(ptrs_arg[0] == 1) {
ptrsTimeDenst[1]= *mcsIndex - 1;
ptrsTimeDenst[2]= *mcsIndex + 1;
}
else if(ptrs_arg[0] ==2)
{
else if(ptrs_arg[0] ==2) {
ptrsTimeDenst[0]= *mcsIndex - 1;
ptrsTimeDenst[1]= *mcsIndex + 1;
}
else
{
else {
printf("[DLSIM] Wrong L_PTRS value, using default values 1\n");
}
/* L = 4 if Imcs < MCS4 */
if(ptrs_arg[1] ==2)
{
if(ptrs_arg[1] ==2) {
ptrsFreqDenst[0]= *rbSize - 1;
ptrsFreqDenst[1]= *rbSize + 1;
}
else if(ptrs_arg[1] == 4)
{
else if(ptrs_arg[1] == 4) {
ptrsFreqDenst[1]= *rbSize - 1;
}
else
{
else {
printf("[DLSIM] Wrong K_PTRS value, using default values 2\n");
}
printf("[DLSIM] PTRS Enabled with L %d, K %d \n", 1<<ptrs_arg[0], ptrs_arg[1] );
......@@ -1260,33 +1248,26 @@ void update_dmrs_config(NR_CellGroupConfig_t *scg,PHY_VARS_NR_UE *ue, int8_t* dm
{
int8_t mapping_type = typeA;//default value
int8_t add_pos = pdsch_dmrs_pos0;//default value
if(dmrs_arg[0] == 0)
{
if(dmrs_arg[0] == 0) {
mapping_type = typeA;
}
else if (dmrs_arg[0] == 1)
{
else if (dmrs_arg[0] == 1) {
mapping_type = typeB;
}
/* Additional DMRS positions 0 ,1 and 2 */
if(dmrs_arg[1] >= 0 && dmrs_arg[1] <3 )
{
if(dmrs_arg[1] >= 0 && dmrs_arg[1] <3 ) {
add_pos = dmrs_arg[1];
}
if(scg != NULL)
{
if(scg != NULL) {
NR_BWP_Downlink_t *bwp = scg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[0];
*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = add_pos;
for (int i=0;i<bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;i++)
{
for (int i=0;i<bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;i++) {
bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType = mapping_type;
}
}
if(ue != NULL)
{
for (int i=0;i<MAX_NR_OF_DL_ALLOCATIONS;i++)
{
if(ue != NULL) {
for (int i=0;i<MAX_NR_OF_DL_ALLOCATIONS;i++) {
ue->PDSCH_Config.pdsch_TimeDomainResourceAllocation[i]->mappingType = mapping_type;
}
ue->dmrs_DownlinkConfig.pdsch_dmrs_AdditionalPosition = add_pos;
......
......@@ -979,11 +979,14 @@ int main(int argc, char **argv)
}
else n_trials = 1;
if (input_fd == NULL )
{
sigma_dB = 10 * log10((double)txlev * ((double)frame_parms->ofdm_symbol_size/(12*nb_rb))) - SNR;
if (input_fd == NULL ) {
sigma_dB = 10 * log10((double)txlev * ((double)frame_parms->ofdm_symbol_size/(12*nb_rb))) - SNR;;
sigma = pow(10,sigma_dB/10);
if (n_trials==1) printf("sigma %f (%f dB), txlev %f (factor %f)\n",sigma,sigma_dB,10*log10((double)txlev),(double)(double)frame_parms->ofdm_symbol_size/(12*nb_rb));
if(n_trials==1) printf("sigma %f (%f dB), txlev %f (factor %f)\n",sigma,sigma_dB,10*log10((double)txlev),(double)(double)frame_parms->ofdm_symbol_size/(12*nb_rb));
for (i=0; i<slot_length; i++) {
for (int aa=0; aa<1; aa++) {
s_re[aa][i] = ((double)(((short *)&UE->common_vars.txdata[aa][slot_offset]))[(i<<1)]);
......@@ -991,6 +994,7 @@ int main(int argc, char **argv)
}
}
if (UE2gNB->max_Doppler == 0) {
multipath_channel(UE2gNB,s_re,s_im,r_re,r_im,
slot_length,0,(n_trials==1)?1:0);
......@@ -1000,8 +1004,8 @@ int main(int argc, char **argv)
}
for (i=0; i<slot_length; i++) {
for (ap=0; ap<frame_parms->nb_antennas_rx; ap++) {
((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i) + (delay*2)] = (int16_t)(r_re[ap][i] + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); // convert to fixed point
((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i)+1 + (delay*2)] = (int16_t)(r_im[ap][i] + (sqrt(sigma/2)*gaussdouble(0.0,1.0)));
((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i) + (delay*2)] = (int16_t)((r_re[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); // convert to fixed point
((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i)+1 + (delay*2)] = (int16_t)((r_im[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0)));
/* Add phase noise if enabled */
if (pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {
phase_noise(ts, &((int16_t*)&gNB->common_vars.rxdata[ap][slot_offset])[(2*i)],
......@@ -1009,10 +1013,11 @@ int main(int argc, char **argv)
}
}
}
}
if(pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS)
{
if(pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {
set_ptrs_symb_idx(&ptrsSymPos,
pusch_pdu->nr_of_symbols,
pusch_pdu->start_symbol_index,
......@@ -1020,9 +1025,8 @@ int main(int argc, char **argv)
pusch_pdu->ul_dmrs_symb_pos);
ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ptrsSymPos, pusch_pdu->start_symbol_index, pusch_pdu->nr_of_symbols);
ptrsRePerSymb = ((pusch_pdu->rb_size + ptrs_freq_density - 1)/ptrs_freq_density);
printf("[ULSIM] PTRS Symbols in a slot: %2d, RE per Symbol: %3d, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb );
printf("[ULSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb );
}
////////////////////////////////////////////////////////////
//----------------------------------------------------------
......@@ -1087,7 +1091,7 @@ int main(int argc, char **argv)
}
/* 2*5*(50/2), for RB = 50,K = 2 for 5 OFDM PTRS symbols */
available_bits -= 2 * ptrs_symbols * ((nb_rb + ptrs_freq_density - 1) /ptrs_freq_density);
printf("[ULSIM][PTRS] Available bits are: %5d, removed PTRS bits are: %5d \n",available_bits, (ptrsSymbPerSlot * ptrsRePerSymb * 2) );
printf("[ULSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5d \n",available_bits, (ptrsSymbPerSlot * ptrsRePerSymb * 2) );
}
for (i = 0; i < available_bits; i++) {
......
......@@ -37,28 +37,22 @@ void phase_noise(double ts, int16_t * InRe, int16_t * InIm)
int16_t IdxModulo = ((int32_t)(IdxDouble>0 ? IdxDouble+0.5 : IdxDouble-0.5)) % (ResolSinCos*4);
IdxModulo = IdxModulo<0 ? IdxModulo+ResolSinCos*4 : IdxModulo;
if(IdxModulo<2*ResolSinCos)//< 2 check for 1st and 2nd
{
if(IdxModulo < ResolSinCos)// 1st Quadrant
{
if(IdxModulo<2*ResolSinCos) {//< 2 check for 1st and 2nd
if(IdxModulo < ResolSinCos) {// 1st Quadrant
SinValue = LUTSin[IdxModulo];
CosValue = LUTSin[ResolSinCos-IdxModulo];
}
else// 2nd Quadrant
{
else {// 2nd Quadrant
SinValue = LUTSin[2*ResolSinCos-IdxModulo];
CosValue = -LUTSin[IdxModulo-ResolSinCos];
}
}
else // 3rd and 4th Quadrant
{
if(IdxModulo < 3*ResolSinCos)// 3rd Quadrant
{
else {// 3rd and 4th Quadrant
if(IdxModulo < 3*ResolSinCos) {// 3rd Quadrant
SinValue = -LUTSin[IdxModulo-2*ResolSinCos];
CosValue = -LUTSin[3*ResolSinCos-IdxModulo];
}
else//4th Quadrant
{
else {//4th Quadrant
SinValue = -LUTSin[4*ResolSinCos-IdxModulo];
CosValue = LUTSin[IdxModulo-3*ResolSinCos];
}
......
......@@ -2813,31 +2813,26 @@ bool set_dl_ptrs_values(NR_PTRS_DownlinkConfig_t *ptrs_config,
bool valid = true;
/* as defined in T 38.214 5.1.6.3 */
if(rbSize < 3)
{
if(rbSize < 3) {
valid = false;
return valid;
}
/* Check for Frequency Density values */
if(ptrs_config->frequencyDensity->list.count < 2)
{
if(ptrs_config->frequencyDensity->list.count < 2) {
/* Default value for K_PTRS = 2 as defined in T 38.214 5.1.6.3 */
*K_ptrs = 2;
}
else
{
else {
*K_ptrs = get_K_ptrs(*ptrs_config->frequencyDensity->list.array[0],
*ptrs_config->frequencyDensity->list.array[1],
rbSize);
}
/* Check for time Density values */
if(ptrs_config->timeDensity->list.count < 3)
{
if(ptrs_config->timeDensity->list.count < 3) {
/* Default value for L_PTRS = 1 as defined in T 38.214 5.1.6.3 */
*L_ptrs = 1;
}
else
{
else {
*L_ptrs = get_L_ptrs(*ptrs_config->timeDensity->list.array[0],
*ptrs_config->timeDensity->list.array[1],
*ptrs_config->timeDensity->list.array[2],
......@@ -2847,25 +2842,20 @@ bool set_dl_ptrs_values(NR_PTRS_DownlinkConfig_t *ptrs_config,
*portIndex =*ptrs_config->epre_Ratio;
*nERatio = *ptrs_config->resourceElementOffset;
*reOffset = 0;
/* If either or both of the parameters PT-RS time density (LPT-RS) and PT-RS frequency density (KPT-RS), shown in Table
* 5.1.6.3-1 and Table 5.1.6.3-2, indicates that 'PT-RS not present', the UE shall assume that PT-RS is not present
*/
if(*K_ptrs ==2 || *K_ptrs ==4 )
{
if(*K_ptrs ==2 || *K_ptrs ==4 ) {
valid = true;
}
else
{
else {
valid = false;
return valid;
}
if(*L_ptrs ==0 || *L_ptrs ==1 || *L_ptrs ==2 )
{
if(*L_ptrs ==0 || *L_ptrs ==1 || *L_ptrs ==2 ) {
valid = true;
}
else
{
else {
valid = false;
return valid;
}
......@@ -2875,8 +2865,7 @@ bool set_dl_ptrs_values(NR_PTRS_DownlinkConfig_t *ptrs_config,
* When the UE is receiving a PDSCH with allocation duration of 2 symbols as defined in Clause 7.4.1.1.2 of [4, TS
* 38.211] and if LPT-RS is set to 2 or 4, the UE shall assume PT-RS is not transmitted.
*/
if((NrOfSymbols == 4 && *L_ptrs ==2) || ((NrOfSymbols == 2 && *L_ptrs > 0)))
{
if((NrOfSymbols == 4 && *L_ptrs ==2) || ((NrOfSymbols == 2 && *L_ptrs > 0))) {
valid = false;
return valid;
}
......
......@@ -3838,15 +3838,13 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dc
/* TODO same calculation for MCS table as done in UL */
dlsch_config_pdu_1_1->mcs_table = 0;
/*PTRS configuration */
if(mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS != NULL)
{
if(mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS != NULL) {
valid_ptrs_setup = set_dl_ptrs_values(mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup,
dlsch_config_pdu_1_1->number_rbs, dlsch_config_pdu_1_1->mcs, dlsch_config_pdu_1_1->mcs_table,
&dlsch_config_pdu_1_1->PTRSFreqDensity,&dlsch_config_pdu_1_1->PTRSTimeDensity,
&dlsch_config_pdu_1_1->PTRSPortIndex,&dlsch_config_pdu_1_1->nEpreRatioOfPDSCHToPTRS,
&dlsch_config_pdu_1_1->PTRSReOffset, dlsch_config_pdu_1_1->number_symbols);
if(valid_ptrs_setup==true)
{
if(valid_ptrs_setup==true) {
dlsch_config_pdu_1_1->pduBitmap |= 0x1;
}
}
......
......@@ -523,16 +523,14 @@ void nr_fill_nfapi_dl_pdu(int Mod_idP,
pdsch_pdu_rel15->NrOfSymbols);
/* Check and validate PTRS values */
if(bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS != NULL)
{
if(bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS != NULL) {
valid_ptrs_setup = set_dl_ptrs_values(bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup,
pdsch_pdu_rel15->rbSize, pdsch_pdu_rel15->mcsIndex[0],
pdsch_pdu_rel15->mcsTable[0],
&pdsch_pdu_rel15->PTRSFreqDensity,&pdsch_pdu_rel15->PTRSTimeDensity,
&pdsch_pdu_rel15->PTRSPortIndex,&pdsch_pdu_rel15->nEpreRatioOfPDSCHToPTRS,
&pdsch_pdu_rel15->PTRSReOffset, pdsch_pdu_rel15->NrOfSymbols);
if(valid_ptrs_setup==true)
{
if(valid_ptrs_setup==true) {
pdsch_pdu_rel15->pduBitmap |=0x1;
}
}
......
......@@ -1281,9 +1281,7 @@ void rrc_config_dl_ptrs_params(NR_BWP_Downlink_t *bwp, int *ptrsNrb, int *ptrsMc
{
int i=0;
/* check for memory allocation */
if(bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS == NULL)
{
if(bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS == NULL) {
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS));
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->present = NR_SetupRelease_PTRS_DownlinkConfig_PR_setup;
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup= calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup));
......@@ -1292,23 +1290,18 @@ void rrc_config_dl_ptrs_params(NR_BWP_Downlink_t *bwp, int *ptrsNrb, int *ptrsMc
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->epre_Ratio = calloc(1,sizeof(long));
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->resourceElementOffset = calloc(1,sizeof(long));
/* Fill the given values */
for(i = 0; i < 2; i++)
{
for(i = 0; i < 2; i++) {
ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity->list,&ptrsNrb[i]);
}
for(i = 0; i < 3; i++)
{
for(i = 0; i < 3; i++) {
ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity->list,&ptrsMcs[i]);
}
}// if memory exist then over write the old values
else
{
for(i = 0; i < 2; i++)
{
else {
for(i = 0; i < 2; i++) {
*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity->list.array[i] = ptrsNrb[i];
}
for(i = 0; i < 3; i++)
{
for(i = 0; i < 3; i++) {
*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity->list.array[i] = ptrsMcs[i];
}
}
......
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