Commit 70b6ca63 authored by Khalid Ahmed's avatar Khalid Ahmed Committed by Thomas Schlichter

adding nr_layer_mapping to ulsim

parent ef3c6add
...@@ -644,6 +644,26 @@ void phy_init_nr_ue__PDSCH( NR_UE_PDSCH* const pdsch, const NR_DL_FRAME_PARMS* c ...@@ -644,6 +644,26 @@ void phy_init_nr_ue__PDSCH( NR_UE_PDSCH* const pdsch, const NR_DL_FRAME_PARMS* c
} }
} }
void phy_init_nr_ue_PUSCH( NR_UE_PUSCH* const pusch, const NR_DL_FRAME_PARMS* const fp )
{
int i;
AssertFatal( pusch, "pusch==0" );
pusch->txdata = (int32_t**)malloc16( fp->nb_antennas_tx*sizeof(int32_t*) );
pusch->txdataF = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t*) );
for (i=0; i<fp->nb_antennas_tx; i++) {
pusch->txdata[i] = (int32_t*)malloc16_clear( fp->samples_per_subframe*10*sizeof(int32_t) );
pusch->txdataF[i] = (int32_t *)malloc16_clear( fp->ofdm_symbol_size*fp->symbols_per_slot*10*sizeof(int32_t) );
}
for (i=0; i<NR_MAX_NB_LAYERS; i++)
pusch->txdataF_layers[i] = (int32_t *)malloc16((NR_MAX_PUSCH_ENCODED_LENGTH)*sizeof(int32_t*));
}
int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
int nb_connected_eNB, int nb_connected_eNB,
uint8_t abstraction_flag) uint8_t abstraction_flag)
...@@ -655,14 +675,15 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, ...@@ -655,14 +675,15 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
NR_UE_PDSCH** const pdsch_vars_ra = ue->pdsch_vars_ra; NR_UE_PDSCH** const pdsch_vars_ra = ue->pdsch_vars_ra;
NR_UE_PDSCH** const pdsch_vars_p = ue->pdsch_vars_p; NR_UE_PDSCH** const pdsch_vars_p = ue->pdsch_vars_p;
NR_UE_PDSCH** const pdsch_vars_mch = ue->pdsch_vars_MCH; NR_UE_PDSCH** const pdsch_vars_mch = ue->pdsch_vars_MCH;
NR_UE_PDSCH* (*pdsch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX+1] = &ue->pdsch_vars; NR_UE_PDSCH* (*const pdsch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX+1] = ue->pdsch_vars;
NR_UE_PDCCH* (*pdcch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX] = &ue->pdcch_vars; NR_UE_PDCCH* (*const pdcch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX] = ue->pdcch_vars;
NR_UE_PBCH** const pbch_vars = ue->pbch_vars; NR_UE_PBCH** const pbch_vars = ue->pbch_vars;
NR_UE_PRACH** const prach_vars = ue->prach_vars; NR_UE_PRACH** const prach_vars = ue->prach_vars;
NR_UE_PUSCH* (*const pusch_vars)[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX] = ue->pusch_vars;
int i,j,k,l,slot,symb,q; int i,j,k,l,slot,symb,q,layer;
int eNB_id; int eNB_id;
int th_id; int th_id;
int n_ssb_crb=(fp->N_RB_DL-20); int n_ssb_crb=(fp->N_RB_DL-20);
...@@ -701,6 +722,20 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, ...@@ -701,6 +722,20 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
ue->total_received_bits[eNB_id] = 0; ue->total_received_bits[eNB_id] = 0;
} }
/////////////////////////PUSCH init/////////////////////////
///////////
for (th_id = 0; th_id < RX_NB_TH_MAX; th_id++){
for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++){
(*pusch_vars)[th_id][eNB_id] = (NR_UE_PUSCH *)malloc16(sizeof(NR_UE_PUSCH));
phy_init_nr_ue_PUSCH( (*pusch_vars)[th_id][eNB_id], fp );
}
}
///////////
////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////PUSCH DMRS init///////////////////////// /////////////////////////PUSCH DMRS init/////////////////////////
/////////// ///////////
......
...@@ -204,7 +204,7 @@ typedef struct { ...@@ -204,7 +204,7 @@ typedef struct {
/// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14) /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
uint8_t b_tilde[MAX_NUM_NR_CHANNEL_BITS]; uint8_t b_tilde[MAX_NUM_NR_CHANNEL_BITS];
/// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14) /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
int32_t d[MAX_NUM_NR_RE]; int32_t d_mod[MAX_NUM_NR_RE];
/// Transform-coded "z"-sequences (for definition see 36-211 V8.6 2009-03, p.14-15) /// Transform-coded "z"-sequences (for definition see 36-211 V8.6 2009-03, p.14-15)
int32_t z[MAX_NUM_NR_RE]; int32_t z[MAX_NUM_NR_RE];
/* /*
......
...@@ -277,6 +277,21 @@ typedef struct { ...@@ -277,6 +277,21 @@ typedef struct {
} NR_UE_COMMON_PER_THREAD; } NR_UE_COMMON_PER_THREAD;
typedef struct {
/// \brief Holds the transmit data in time domain.
/// For IFFT_FPGA this points to the same memory as PHY_vars->tx_vars[a].TX_DMA_BUFFER.
/// - first index: tx antenna [0..nb_antennas_tx[
/// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES[
int32_t **txdata;
/// \brief Holds the transmit data in the frequency domain.
/// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER.
/// - first index: tx antenna [0..nb_antennas_tx[
/// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX[
int32_t **txdataF;
/// TX buffers for multiple layers
int32_t *txdataF_layers[NR_MAX_NB_LAYERS];
} NR_UE_PUSCH;
typedef struct { typedef struct {
/// \brief Holds the transmit data in time domain. /// \brief Holds the transmit data in time domain.
/// For IFFT_FPGA this points to the same memory as PHY_vars->tx_vars[a].TX_DMA_BUFFER. /// For IFFT_FPGA this points to the same memory as PHY_vars->tx_vars[a].TX_DMA_BUFFER.
...@@ -943,6 +958,7 @@ typedef struct { ...@@ -943,6 +958,7 @@ typedef struct {
NR_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_eNB_MAX]; NR_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_eNB_MAX];
NR_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX]; NR_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX];
NR_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_eNB_MAX]; NR_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_eNB_MAX];
NR_UE_PUSCH *pusch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX];
NR_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][NR_MAX_NB_CODEWORDS]; // two RxTx Threads NR_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][NR_MAX_NB_CODEWORDS]; // two RxTx Threads
NR_UE_ULSCH_t *ulsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][NR_MAX_NB_CODEWORDS]; // two code words NR_UE_ULSCH_t *ulsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][NR_MAX_NB_CODEWORDS]; // two code words
NR_UE_DLSCH_t *dlsch_SI[NUMBER_OF_CONNECTED_eNB_MAX]; NR_UE_DLSCH_t *dlsch_SI[NUMBER_OF_CONNECTED_eNB_MAX];
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
#define NR_MAX_NB_CODEWORDS 2 #define NR_MAX_NB_CODEWORDS 2
#define NR_MAX_NB_HARQ_PROCESSES 16 #define NR_MAX_NB_HARQ_PROCESSES 16
#define NR_MAX_PDSCH_ENCODED_LENGTH NR_MAX_NB_RB*NR_SYMBOLS_PER_SLOT*NR_NB_SC_PER_RB*8*NR_MAX_NB_LAYERS // 8 is the maximum modulation order (it was 950984 before !!) #define NR_MAX_PDSCH_ENCODED_LENGTH NR_MAX_NB_RB*NR_SYMBOLS_PER_SLOT*NR_NB_SC_PER_RB*8*NR_MAX_NB_LAYERS // 8 is the maximum modulation order (it was 950984 before !!)
#define NR_MAX_PUSCH_ENCODED_LENGTH NR_MAX_PDSCH_ENCODED_LENGTH
#define NR_MAX_PDSCH_TBS 3824 #define NR_MAX_PDSCH_TBS 3824
typedef enum { typedef enum {
......
...@@ -157,6 +157,7 @@ int main(int argc, char **argv) { ...@@ -157,6 +157,7 @@ int main(int argc, char **argv) {
uint16_t nb_symb_sch = 12; uint16_t nb_symb_sch = 12;
uint16_t nb_rb = 50; uint16_t nb_rb = 50;
uint8_t Imcs = 9; uint8_t Imcs = 9;
int eNB_id = 0;
cpuf = get_cpu_freq_GHz(); cpuf = get_cpu_freq_GHz();
...@@ -441,11 +442,14 @@ int main(int argc, char **argv) { ...@@ -441,11 +442,14 @@ int main(int argc, char **argv) {
uint8_t Nl = 1; uint8_t Nl = 1;
uint8_t rvidx = 0; uint8_t rvidx = 0;
uint8_t UE_id = 1; uint8_t UE_id = 1;
uint8_t cwd;
NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id][0]; NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id][0];
nfapi_nr_ul_config_ulsch_pdu_rel15_t *rel15_ul = &ulsch_gNB->harq_processes[harq_pid]->ulsch_pdu.ulsch_pdu_rel15; nfapi_nr_ul_config_ulsch_pdu_rel15_t *rel15_ul = &ulsch_gNB->harq_processes[harq_pid]->ulsch_pdu.ulsch_pdu_rel15;
NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[0][0][0]; NR_UE_PUSCH *pusch_ue = UE->pusch_vars[0][eNB_id];
NR_UE_ULSCH_t **ulsch_ue = UE->ulsch[0][0];
NR_UL_UE_HARQ_t *harq_process_ul_ue;
mod_order = nr_get_Qm(Imcs, 1); mod_order = nr_get_Qm(Imcs, 1);
available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1);
...@@ -476,6 +480,8 @@ int main(int argc, char **argv) { ...@@ -476,6 +480,8 @@ int main(int argc, char **argv) {
uint8_t bit_index; uint8_t bit_index;
uint32_t errors_scrambling; uint32_t errors_scrambling;
uint32_t scrambling_index; uint32_t scrambling_index;
int16_t **tx_layers;
int32_t *mod_symbols[MAX_NUM_NR_RE];
test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8); test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8);
...@@ -486,83 +492,100 @@ int main(int argc, char **argv) { ...@@ -486,83 +492,100 @@ int main(int argc, char **argv) {
for (i = 0; i < TBS / 8; i++) for (i = 0; i < TBS / 8; i++)
test_input[i] = 1;//(unsigned char) rand(); test_input[i] = 1;//(unsigned char) rand();
for (cwd=0; cwd<nb_codewords; cwd++) {
/////////////////////////[adk] preparing NR_UE_ULSCH_t parameters///////////////////////// A HOT FIX until creating nfapi_nr_ul_config_ulsch_pdu_rel15_t /////////////////////////[adk] preparing NR_UE_ULSCH_t parameters///////////////////////// A HOT FIX until creating nfapi_nr_ul_config_ulsch_pdu_rel15_t
/////////// ///////////
ulsch_ue->nb_re_dmrs = nb_re_dmrs; ulsch_ue[cwd]->nb_re_dmrs = nb_re_dmrs;
ulsch_ue->length_dmrs = length_dmrs; ulsch_ue[cwd]->length_dmrs = length_dmrs;
ulsch_ue->rnti = n_rnti; ulsch_ue[cwd]->rnti = n_rnti;
/////////// ///////////
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////[adk] preparing UL harq_process parameters///////////////////////// /////////////////////////[adk] preparing UL harq_process parameters/////////////////////////
/////////// ///////////
NR_UL_UE_HARQ_t *harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; harq_process_ul_ue = ulsch_ue[cwd]->harq_processes[harq_pid];
N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
N_RE_prime = NR_NB_SC_PER_RB*nb_symb_sch - nb_re_dmrs - N_PRB_oh; N_RE_prime = NR_NB_SC_PER_RB*nb_symb_sch - nb_re_dmrs - N_PRB_oh;
if (harq_process_ul_ue) { if (harq_process_ul_ue) {
harq_process_ul_ue->mcs = Imcs; harq_process_ul_ue->mcs = Imcs;
harq_process_ul_ue->Nl = Nl; harq_process_ul_ue->Nl = Nl;
harq_process_ul_ue->nb_rb = nb_rb; harq_process_ul_ue->nb_rb = nb_rb;
harq_process_ul_ue->number_of_symbols = nb_symb_sch; harq_process_ul_ue->number_of_symbols = nb_symb_sch;
harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*nb_codewords; harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*nb_codewords;
harq_process_ul_ue->rvidx = rvidx; harq_process_ul_ue->rvidx = rvidx;
harq_process_ul_ue->TBS = TBS; harq_process_ul_ue->TBS = TBS;
harq_process_ul_ue->a = &test_input[0]; harq_process_ul_ue->a = &test_input[0];
} }
/////////// ///////////
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
#ifdef DEBUG_ULSCHSIM #ifdef DEBUG_ULSCHSIM
for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]);
#endif #endif
/////////////////////////ULSCH coding///////////////////////// /////////////////////////ULSCH coding/////////////////////////
/////////// ///////////
if (input_fd == NULL) { if (input_fd == NULL) {
nr_ulsch_encoding(ulsch_ue, frame_parms, harq_pid); nr_ulsch_encoding(ulsch_ue[cwd], frame_parms, harq_pid);
} }
/////////// ///////////
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
/////////////////////////ULSCH scrambling///////////////////////// /////////////////////////ULSCH scrambling/////////////////////////
/////////// ///////////
for (int q=0; q<nb_codewords; q++){ memset(scrambled_output[cwd], 0, ((available_bits>>5)+1)*sizeof(uint32_t));
memset(scrambled_output[q], 0, ((available_bits>>5)+1)*sizeof(uint32_t));
} nr_pusch_codeword_scrambling(ulsch_ue[cwd]->g,
available_bits,
nr_pusch_codeword_scrambling(ulsch_ue->g, Nid_cell,
available_bits, ulsch_ue[cwd]->rnti,
Nid_cell, scrambled_output[cwd]); // assume one codeword for the moment
ulsch_ue->rnti,
scrambled_output[0]); // assume one codeword for the moment
/////////////
//////////////////////////////////////////////////////////////////////////
/////////////////////////ULSCH modulation/////////////////////////
///////////
nr_modulation(scrambled_output[cwd], // assume one codeword for the moment
available_bits,
mod_order,
ulsch_ue[cwd]->d_mod);
///////////// ///////////
////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/////////////////////////ULSCH modulation///////////////////////// mod_symbols[cwd] = (int32_t *)malloc16((NR_MAX_PUSCH_ENCODED_LENGTH)*sizeof(int32_t*));
memcpy(mod_symbols[cwd],ulsch_ue[cwd]->d_mod,(available_bits/mod_order)*sizeof(int32_t));
}
/////////////////////////ULSCH layer mapping/////////////////////////
/////////// ///////////
nr_modulation(scrambled_output[0], // assume one codeword for the moment tx_layers = (int16_t **)pusch_ue->txdataF_layers;
available_bits,
mod_order, nr_layer_mapping((int16_t **)mod_symbols,
ulsch_ue->d); Nl,
available_bits/mod_order,
tx_layers);
/////////// ///////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
for (SNR = snr0; SNR < snr1; SNR += snr_step) { for (SNR = snr0; SNR < snr1; SNR += snr_step) {
n_errors = 0; n_errors = 0;
...@@ -662,7 +685,7 @@ int main(int argc, char **argv) { ...@@ -662,7 +685,7 @@ int main(int argc, char **argv) {
for (i = 0; i < TBS; i++) { for (i = 0; i < TBS; i++) {
if(((ulsch_ue->g[i] == 0) && (channel_output_fixed[i] < 0)) || ((ulsch_ue->g[i] == 1) && (channel_output_fixed[i] >= 0))) { if(((ulsch_ue[0]->g[i] == 0) && (channel_output_fixed[i] < 0)) || ((ulsch_ue[0]->g[i] == 1) && (channel_output_fixed[i] >= 0))) {
errors_scrambling++; errors_scrambling++;
} }
......
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