Commit bf247727 authored by Khalid Ahmed's avatar Khalid Ahmed Committed by Thomas Schlichter

PUSCH DMRS generation

- added get_l_prime function
- added Table 6.4.1.1.3-3
- added added is_dmrs_symbol function
parent e75a96c9
......@@ -57,6 +57,19 @@ void generate_dmrs_pbch(uint32_t dmrs_pbch_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_H
uint8_t get_l0_ul(uint8_t mapping_type, uint8_t dmrs_typeA_position);
uint16_t get_dmrs_freq_idx_ul(uint16_t n, uint8_t k_prime, uint8_t delta, uint8_t dmrs_type);
int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmrs_AdditionalPosition_t additional_pos);
uint8_t is_dmrs_symbol(uint8_t l,
uint16_t k,
uint16_t start_sc,
uint8_t k_prime,
uint16_t n,
uint8_t delta,
uint8_t duration_in_symbols,
dmrs_UplinkConfig_t *dmrs_UplinkConfig,
uint8_t mapping_type,
uint16_t ofdm_symbol_size);
#undef EXTERN
#endif /* DMRS_NR_H */
......
......@@ -32,7 +32,6 @@
#include "nr_sch_dmrs.h"
/*Table 7.4.1.1.2-1 and 7.4.1.1.2-2 38211 Columns: ap - CDM group - Delta - Wf(0) - Wf(1) - Wt(0) - Wt(1)*/
/*Table 6.4.1.1.3-1 is identical to Table 7.4.1.1.2-1 and Table 6.4.1.1.3-2 is identical to Table 7.4.1.1.2-2. UL DMRS can reuse these tables*/
int8_t pdsch_dmrs_1[8][7] = {{0,0,0,1,1,1,1},
......@@ -57,11 +56,6 @@ int8_t pdsch_dmrs_2[12][7] = {{0,0,0,1,1,1,1},
{10,2,4,1,1,1,-1},
{11,2,4,1,-1,1,-1}};
void get_l_prime(uint8_t *l_prime, uint8_t n_symbs) {
for (int i=0; i<n_symbs; i++)
*(l_prime+i) = i;
}
void get_antenna_ports(uint8_t *ap, uint8_t n_symbs, uint8_t config) {
if (config == NFAPI_NR_DMRS_TYPE1)
for (int i=0; i<(4+((n_symbs-1)<<2)); i++)
......
......@@ -30,13 +30,14 @@
* \warning
*/
#ifndef NR_SCH_DMRS_H
#define NR_SCH_DMRS_H
#include "PHY/defs_nr_common.h"
#define NR_PDSCH_DMRS_ANTENNA_PORT0 1000
#define NR_PDSCH_DMRS_NB_ANTENNA_PORTS 12
void get_l_prime(uint8_t *l_prime, uint8_t n_symbs);
void get_antenna_ports(uint8_t *ap, uint8_t n_symbs, uint8_t config);
void get_Wt(int8_t *Wt, uint8_t ap, uint8_t config);
......@@ -48,3 +49,5 @@ uint8_t get_delta(uint8_t ap, uint8_t config);
uint16_t get_dmrs_freq_idx(uint16_t n, uint8_t k_prime, uint8_t delta, uint8_t dmrs_type);
uint8_t get_l0(uint8_t mapping_type, uint8_t dmrs_typeA_position);
#endif
......@@ -33,6 +33,124 @@
#include "PHY/NR_REFSIG/ss_pbch_nr.h"
#include "PHY/NR_REFSIG/dmrs_nr.h"
/***********************************************************************/
// TS 38.211 Table 6.4.1.1.3-3: PUSCH DMRS positions l' within a slot for single-symbol DMRS and intra-slot frequency hopping disabled.
// The first 4 colomns are PUSCH mapping type A and the last 4 colomns are PUSCH mapping type B.
// When l' = l0, it is represented by 1
// E.g. when symbol duration is 12 in colomn 7, value 1057 ('10000100001') which means l' = l0, 5, 10.
int32_t table_6_4_1_1_3_3_pusch_dmrs_positions_l [12][8] = { // Duration in symbols
{-1, -1, -1, -1, 1, 1, 1, 1}, //<4 // (DMRS l' position)
{1, 1, 1, 1, 1, 1, 1, 1}, //4 // (DMRS l' position)
{1, 1, 1, 1, 1, 5, 5, 5}, //5 // (DMRS l' position)
{1, 1, 1, 1, 1, 5, 5, 5}, //6 // (DMRS l' position)
{1, 1, 1, 1, 1, 5, 5, 5}, //7 // (DMRS l' position)
{1, 129, 129, 129, 1, 65, 73, 73}, //8 // (DMRS l' position)
{1, 129, 129, 129, 1, 65, 73, 73}, //9 // (DMRS l' position)
{1, 513, 577, 577, 1, 257, 273, 585}, //10 // (DMRS l' position)
{1, 513, 577, 577, 1, 257, 273, 585}, //11 // (DMRS l' position)
{1, 513, 577, 2337, 1, 1025, 1057, 585}, //12 // (DMRS l' position)
{1, 2049, 2177, 2337, 1, 1025, 1057, 585}, //13 // (DMRS l' position)
{1, 2049, 2177, 2337, 1, 1025, 1057, 585}, //14 // (DMRS l' position)
};
int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmrs_AdditionalPosition_t additional_pos) {
uint8_t row, colomn;
int32_t l_prime;
colomn = additional_pos;
if (mapping_type == typeB)
colomn += 4;
if (duration_in_symbols < 4)
row = 0;
else
row = duration_in_symbols - 3;
l_prime = table_6_4_1_1_3_3_pusch_dmrs_positions_l[row][colomn];
AssertFatal(l_prime>0,"invalid l_prime < 0\n");
return l_prime;
}
/*******************************************************************
*
* NAME : is_dmrs_symbol
*
* PARAMETERS : l ofdm symbol index within slot
* k subcarrier index
* start_sc first subcarrier index
* k_prime index alternating 0 and 1
* n index starting 0,1,...
* delta see Table 6.4.1.1.3
* duration_in_symbols number of scheduled PUSCH ofdm symbols
* dmrs_UplinkConfig DMRS uplink configuration
* mapping_type PUSCH mapping type (A or B)
* ofdm_symbol_size IFFT size
*
* RETURN : 0 if symbol(k,l) is data, or 1 if symbol(k,l) is dmrs
*
* DESCRIPTION : 3GPP TS 38.211 6.4.1.1 Demodulation reference signal for PUSCH
*
*********************************************************************/
uint8_t is_dmrs_symbol(uint8_t l,
uint16_t k,
uint16_t start_sc,
uint8_t k_prime,
uint16_t n,
uint8_t delta,
uint8_t duration_in_symbols,
dmrs_UplinkConfig_t *dmrs_UplinkConfig,
uint8_t mapping_type,
uint16_t ofdm_symbol_size) {
uint8_t is_dmrs_freq, is_dmrs_time, dmrs_type, l0;
int32_t l_prime_mask;
pusch_dmrs_AdditionalPosition_t additional_pos;
is_dmrs_freq = 0;
is_dmrs_time = 0;
dmrs_type = dmrs_UplinkConfig->pusch_dmrs_type;
additional_pos = dmrs_UplinkConfig->pusch_dmrs_AdditionalPosition;
l0 = get_l0_ul(mapping_type, 2);
l_prime_mask = get_l_prime(duration_in_symbols, mapping_type, additional_pos);
if (k == ((start_sc+get_dmrs_freq_idx_ul(n, k_prime, delta, dmrs_type))%ofdm_symbol_size))
is_dmrs_freq = 1;
if (l_prime_mask == 1){
if (l == l0)
is_dmrs_time = 1;
} else if ( (l==l0) || (((l_prime_mask>>l)&1) == 1 && l!=0) )
is_dmrs_time = 1;
if (dmrs_UplinkConfig->pusch_maxLength == pusch_len2){
if (((l_prime_mask>>(l-1))&1) == 1 && l!=0 && l!=1)
is_dmrs_time = 1;
if (l-1 == l0)
is_dmrs_time = 1;
}
if (is_dmrs_time && is_dmrs_freq)
return 1;
else
return 0;
}
/*******************************************************************
*
* NAME : pseudo_random_gold_sequence
......
......@@ -287,17 +287,32 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
uint8_t k_prime=0;
uint8_t is_dmrs;
uint16_t m=0, n=0, dmrs_idx=0, k=0;
for (l=start_symbol; l<start_symbol+harq_process_ul_ue->number_of_symbols; l++) {
k = start_sc;
n = 0;
for (i=0; i<harq_process_ul_ue->nb_rb*NR_NB_SC_PER_RB; i++) {
sample_offsetF = l*frame_parms->ofdm_symbol_size + k;
if ((l == dmrs_symbol) && (k == ((start_sc+get_dmrs_freq_idx_ul(n, k_prime, delta, dmrs_type))%(frame_parms->ofdm_symbol_size)))) {
is_dmrs = 0;
is_dmrs = is_dmrs_symbol(l,
k,
start_sc,
k_prime,
n,
delta,
harq_process_ul_ue->number_of_symbols,
&UE->dmrs_UplinkConfig,
mapping_type,
frame_parms->ofdm_symbol_size);
if (is_dmrs == 1) {
((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[dmrs_idx<<1]) >> 15;
((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15;
......
......@@ -537,6 +537,7 @@ typedef enum {
typedef enum {
pusch_dmrs_pos0 = 0,
pusch_dmrs_pos1 = 1,
pusch_dmrs_pos2 = 2,
pusch_dmrs_pos3 = 3,
} pusch_dmrs_AdditionalPosition_t;
typedef enum {
......
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