Commit 20978555 authored by Parminder Singh's avatar Parminder Singh

Review Comments are updated

- updated return function value to -1
- removed static variable for dmrs symbol selection for channel
- Updated sin cos quadrant check conditions
- removed casting from PTRS slope and related calculations
parent 741a5b98
......@@ -25,6 +25,7 @@
#include "nr_ul_estimation.h"
#include "PHY/sse_intrin.h"
#include "PHY/NR_REFSIG/nr_refsig.h"
#include "PHY/NR_REFSIG/dmrs_nr.h"
#include "PHY/NR_REFSIG/ptrs_nr.h"
#include "PHY/NR_TRANSPORT/nr_transport_proto.h"
#include "PHY/NR_UE_ESTIMATION/filt16a_32.h"
......
......@@ -363,7 +363,7 @@ void generate_dmrs_pbch(uint32_t dmrs_pbch_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_H
#endif
}
/* return the position of next dmrs symbol in a slot */
int get_next_dmrs_symbol_in_slot(uint16_t ul_dmrs_symb_pos, uint8_t counter, uint8_t end_symbol)
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++)
{
......@@ -372,7 +372,7 @@ int get_next_dmrs_symbol_in_slot(uint16_t ul_dmrs_symb_pos, uint8_t counter, ui
return symbol;
}
}
return 0;
return -1;
}
......@@ -386,3 +386,29 @@ uint8_t get_dmrs_symbols_in_slot(uint16_t l_prime_mask, uint16_t nb_symb)
}
return tmp;
}
/* return the position of valid dmrs symbol in a slot for channel compensation */
int8_t get_valid_dmrs_idx_for_channel_est(uint16_t dmrs_symb_pos, uint8_t counter)
{
int8_t symbIdx = -1;
/* if current symbol is DMRS then return this index */
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)
{
symbIdx = symbol;
break;
}
}
/* if there is no previous dmrs available then find the next possible*/
if(symbIdx == -1)
{
symbIdx = get_next_dmrs_symbol_in_slot(dmrs_symb_pos,counter,15);
}
return symbIdx;
}
......@@ -61,6 +61,12 @@ uint8_t allowed_xlsch_re_in_dmrs_symbol(uint16_t k,
uint8_t numDmrsCdmGrpsNoData,
uint8_t dmrs_type);
void nr_gen_ref_conj_symbols(uint32_t *in, uint32_t length, int16_t *output, uint16_t offset, int mod_order);
int8_t get_next_dmrs_symbol_in_slot(uint16_t ul_dmrs_symb_pos, uint8_t counter, uint8_t end_symbol);
uint8_t get_dmrs_symbols_in_slot(uint16_t l_prime_mask, uint16_t nb_symb);
int8_t get_valid_dmrs_idx_for_channel_est(uint16_t dmrs_symb_pos, uint8_t counter);
static inline uint8_t is_dmrs_symbol(uint8_t l, uint16_t dmrsSymbMask ) { return ((dmrsSymbMask >> l) & 0x1); }
#undef EXTERN
#endif /* DMRS_NR_H */
......
......@@ -52,13 +52,7 @@ int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB,
uint8_t dmrs_type);
void init_scrambling_luts(void);
void nr_gen_ref_conj_symbols(uint32_t *in, uint32_t length, int16_t *output, uint16_t offset, int mod_order);
uint8_t get_next_dmrs_symbol_in_slot(uint16_t ul_dmrs_symb_pos, uint8_t counter, uint8_t end_symbol);
uint8_t get_dmrs_symbols_in_slot(uint16_t l_prime_mask, uint16_t nb_symb);
void nr_generate_modulation_table(void);
static inline uint8_t is_dmrs_symbol(uint8_t l, uint16_t dmrsSymbMask ) { return ((dmrsSymbMask >> l) & 0x1); }
extern __m64 byte2m64_re[256];
extern __m64 byte2m64_im[256];
......
......@@ -192,29 +192,29 @@ 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 */
uint8_t get_next_ptrs_symbol_in_slot(uint16_t ptrs_symb_pos, uint8_t counter, uint8_t nb_symb)
int8_t get_next_ptrs_symbol_in_slot(uint16_t ptrs_symb_pos, uint8_t counter, uint8_t nb_symb)
{
for(uint8_t symbol = counter; symbol < nb_symb; symbol++)
for(int8_t symbol = counter; symbol < nb_symb; symbol++)
{
if((ptrs_symb_pos >>symbol)&0x01 )
{
return symbol;
}
}
return 0;
return -1;
}
/* get the next nearest estimate from DMRS or PTRS */
uint8_t get_next_estimate_in_slot(uint16_t ptrsSymbPos,uint16_t dmrsSymbPos, uint8_t counter,uint8_t nb_symb)
int8_t get_next_estimate_in_slot(uint16_t ptrsSymbPos,uint16_t dmrsSymbPos, uint8_t counter,uint8_t nb_symb)
{
uint8_t nextPtrs = get_next_ptrs_symbol_in_slot(ptrsSymbPos, counter,nb_symb);
uint8_t nextDmrs = get_next_dmrs_symbol_in_slot(dmrsSymbPos, counter,nb_symb);
if(nextDmrs == 0)
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)
{
return nextPtrs;
}
/* Special case when DMRS is next valid estimation */
if(nextPtrs == 0 && nextDmrs !=0)
if(nextPtrs == -1)
{
return nextDmrs;
}
......@@ -360,9 +360,9 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
int32_t slope = 0;
int16_t *slope_p = (int16_t*)&slope;
uint8_t symbInSlot = startSymbIdx + noSymb;
uint8_t rightRef = 0;
uint8_t leftRef = 0;
uint8_t tmp = 0;
int8_t rightRef = 0;
int8_t leftRef = 0;
int8_t tmp = 0;
for(uint8_t symb = startSymbIdx; symb <symbInSlot; symb ++)
{
/* set DMRS estimates to 0 angle with magnitude 1 */
......@@ -384,7 +384,7 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
else
{
/* The very first symbol must be a PTRS or DMRS */
if((symb == startSymbIdx) && (leftRef == 0) && (rightRef == 0))
if((symb == startSymbIdx) && (leftRef == -1) && (rightRef == -1))
{
printf("Wrong PTRS Setup, PTRS compensation will be skipped !");
return -1;
......@@ -396,7 +396,7 @@ int8_t nr_ptrs_process_slot(uint16_t 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!=0)
if(tmp!=-1)
{
get_slope_from_estimates(rightRef, tmp, estPerSymb, slope_p);
}
......@@ -405,12 +405,12 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
}
else if(is_ptrs_symbol(rightRef,ptrsSymbPos))
{
/* calculate slope from next valid estimates*/
/* 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 ==0) && (symb <symbInSlot))
else if((rightRef ==-1) && (symb <symbInSlot))
{
// in right extrapolation use the last slope
#ifdef DEBUG_PTRS
......@@ -433,8 +433,8 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
void get_slope_from_estimates(uint8_t start, uint8_t end, int16_t *est_p, int16_t *slope_p)
{
uint8_t distance = end - start;
slope_p[0] = (((double)(est_p[end*2]) - (double)(est_p[start*2])) /(double)distance);
slope_p[1] = (((double)(est_p[(end*2)+1]) - (double)(est_p[(start*2)+1])) /(double)distance);
slope_p[0] = (est_p[end*2] - est_p[start*2]) /distance;
slope_p[1] = (est_p[(end*2)+1] - est_p[(start*2)+1]) /distance;
#ifdef DEBUG_PTRS
printf("[PHY][PTRS]: Slop is :(%4d %4d) between Symbol %2d & Symbol %2d\n", slope_p[0],slope_p[1], start, end);
//printf("%d %d - %d %d\n",est_p[end*2],est_p[(end*2)+1],est_p[start*2],est_p[(start*2)+1]);
......@@ -446,11 +446,11 @@ void ptrs_estimate_from_slope(int16_t *error_est, int16_t *slope_p, uint8_t star
{
for(uint8_t i = 1; i< (end -start);i++)
{
error_est[(start+i)*2] = 8 * (((double)(error_est[start*2]) * 0.125 ) + ((double)(0.125 * i * slope_p[0])));// real
error_est[((start +i)*2)+1] = 8 * (((double)(error_est[(start*2)+1]) * 0.125) + ((double)(0.125 * i * slope_p[1]))); //imag
error_est[(start+i)*2] = (error_est[start*2] + (i * slope_p[0]));// real
error_est[((start +i)*2)+1] = (error_est[(start*2)+1] + ( i * slope_p[1])); //imag
#ifdef DEBUG_PTRS
printf("[PHY][PTRS]: Estimated Symbol %2d -> %4d %4d from Slope (%4d %4d)\n", start+i,error_est[(start+i)*2],error_est[((start +i)*2)+1],
slope_p[0],slope_p[1]);
printf("[PHY][PTRS]: Estimated Symbol %2d -> %4d %4d from Slope (%4d %4d)\n", start+i,error_est[(start+i)*2],error_est[((start +i)*2)+1],
slope_p[0],slope_p[1]);
#endif
}
}
......@@ -81,8 +81,8 @@ uint8_t is_ptrs_subcarrier(uint16_t k,
static inline uint8_t is_ptrs_symbol(uint8_t l, uint16_t ptrs_symbols) { return ((ptrs_symbols >> l) & 1); }
uint8_t get_ptrs_symbols_in_slot(uint16_t l_prime_mask, uint16_t start_symb, uint16_t nb_symb);
uint8_t get_next_ptrs_symbol_in_slot(uint16_t ptrsSymbPos, uint8_t counter, uint8_t nb_symb);
uint8_t get_next_estimate_in_slot(uint16_t ptrsSymbPos,uint16_t dmrsSymbPos, uint8_t counter,uint8_t nb_symb);
int8_t get_next_ptrs_symbol_in_slot(uint16_t ptrsSymbPos, uint8_t counter, uint8_t nb_symb);
int8_t get_next_estimate_in_slot(uint16_t ptrsSymbPos,uint16_t dmrsSymbPos, uint8_t counter,uint8_t nb_symb);
void get_slope_from_estimates(uint8_t leftSide, uint8_t rightSide, int16_t *est_p, int16_t *slope_p);
int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
uint16_t ptrsSymbPos,
......
......@@ -37,11 +37,10 @@
#include "PHY/NR_REFSIG/dmrs_nr.h"
#include "PHY/NR_REFSIG/ptrs_nr.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
//#define DEBUG_DLSCH
//#define DEBUG_DLSCH_MAPPING
// forward declarations for mac function to avoid semantic issues
extern int get_num_dmrs(uint16_t dmrs_mask );
void nr_pdsch_codeword_scrambling(uint8_t *in,
uint32_t size,
......
......@@ -25,6 +25,7 @@
#include "nr_estimation.h"
#include "PHY/NR_REFSIG/refsig_defs_ue.h"
#include "PHY/NR_REFSIG/nr_refsig.h"
#include "PHY/NR_REFSIG/dmrs_nr.h"
#include "PHY/NR_REFSIG/ptrs_nr.h"
#include "filt16a_32.h"
......
......@@ -40,6 +40,7 @@
#include "openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h"
#include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h"
#include "PHY/NR_REFSIG/nr_refsig.h"
#include "PHY/NR_REFSIG/dmrs_nr.h"
#ifndef USER_MODE
#define NOCYGWIN_STATIC static
......@@ -2099,8 +2100,7 @@ unsigned short nr_dlsch_extract_rbs_single(int **rxdataF,
unsigned char i,aarx; //,nsymb,sss_symb,pss_symb=0,l;
int *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext;
int8_t DMRSdist = 15; //temporarily save the distance to the DMRS symbol
static uint8_t validDmrsEst = 0; //store last DMRS Symbol index
int8_t validDmrsEst = 0; //store last DMRS Symbol index
unsigned char j=0;
......@@ -2111,15 +2111,9 @@ unsigned short nr_dlsch_extract_rbs_single(int **rxdataF,
k = frame_parms->first_carrier_offset + NR_NB_SC_PER_RB*start_rb;
if(validDmrsEst == 0)
{
validDmrsEst = get_next_dmrs_symbol_in_slot(dlDmrsSymbPos, symbol, DMRSdist);
}
if(is_dmrs_symbol(symbol,dlDmrsSymbPos ) == 1)
{
validDmrsEst = symbol;
}
dl_ch0 = &dl_ch_estimates[aarx][(validDmrsEst*(frame_parms->ofdm_symbol_size))]; //use closest DMRS
validDmrsEst = get_valid_dmrs_idx_for_channel_est(dlDmrsSymbPos,symbol);
dl_ch0 = &dl_ch_estimates[aarx][(validDmrsEst*(frame_parms->ofdm_symbol_size))];
dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(nb_rb_pdsch*12)];
......
......@@ -906,7 +906,7 @@ typedef struct {
uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD];
/// PDSCH DMRS
uint32_t nr_gold_pdsch[2][20][14][NR_MAX_PDSCH_DMRS_INIT_LENGTH_DWORD];//sfn
uint32_t nr_gold_pdsch[2][20][14][NR_MAX_PDSCH_DMRS_INIT_LENGTH_DWORD];
/// PDCCH DMRS
uint32_t nr_gold_pdcch[7][20][3][52];
......
......@@ -37,23 +37,34 @@ 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>=0 && IdxModulo<ResolSinCos ) {
SinValue = LUTSin[IdxModulo];
CosValue = LUTSin[ResolSinCos-IdxModulo];
if(IdxModulo<2*ResolSinCos)//< 2 check for 1st and 2nd
{
if(IdxModulo>=ResolSinCos)//>= 1 is 2nd Quadrant
{
SinValue = LUTSin[2*ResolSinCos-IdxModulo];
CosValue = -LUTSin[IdxModulo-ResolSinCos];
}
else// 1st Quadrant
{
SinValue = LUTSin[IdxModulo];
CosValue = LUTSin[ResolSinCos-IdxModulo];
}
}
else if ( IdxModulo>=ResolSinCos && IdxModulo<2*ResolSinCos ) {
SinValue = LUTSin[2*ResolSinCos-IdxModulo];
CosValue = -LUTSin[IdxModulo-ResolSinCos];
else if((IdxModulo>2*ResolSinCos))//> 2 check for 3rd and 4th
{
if(IdxModulo>=3*ResolSinCos)//> 3 is 4th Quadrant
{
SinValue = -LUTSin[4*ResolSinCos-IdxModulo];
CosValue = LUTSin[IdxModulo-3*ResolSinCos];
}
else//3rd Quadrant
{
SinValue = -LUTSin[IdxModulo-2*ResolSinCos];
CosValue = -LUTSin[3*ResolSinCos-IdxModulo];
}
}
else if ( IdxModulo>=2*ResolSinCos && IdxModulo<3*ResolSinCos ) {
SinValue = -LUTSin[IdxModulo-2*ResolSinCos];
CosValue = -LUTSin[3*ResolSinCos-IdxModulo];
}
else if ( IdxModulo>=3*ResolSinCos && IdxModulo<4*ResolSinCos ) {
SinValue = -LUTSin[4*ResolSinCos-IdxModulo];
CosValue = LUTSin[IdxModulo-3*ResolSinCos];
}
else {
else
{
AssertFatal(0==1,"Error in look-up table of sine function!\n");
}
x = ( ((int32_t)InRe[0] * CosValue) - ((int32_t)InIm[0] * SinValue ));
......@@ -68,3 +79,4 @@ void InitSinLUT( void ) {
LUTSin[i] = sin((double)(M_PI*i)/(2*ResolSinCos)) * (1<<14); //Format: Q14
}
}
......@@ -1824,7 +1824,7 @@ void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
R,
pdsch_rel15->rbSize,
N_sh_symb,
N_PRB_DMRS*dmrs_length, // FIXME // This should be multiplied by the number of dmrs symbols
N_PRB_DMRS*dmrs_length,
N_PRB_oh,
tb_scaling,
pdsch_rel15->nrOfLayers)>>3;
......
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