Commit 46968b12 authored by Khalid Ahmed's avatar Khalid Ahmed Committed by Thomas Schlichter
Browse files

adding a temp nfapi_nr_ul_config and using it to initialize ulsch

- modifying generate_ue_ulsch_params to work with nfapi_nr_ul_config struct
- removing ulsim_params struct
parent 176d8730
......@@ -561,6 +561,47 @@ typedef struct {
nfapi_bf_vector_t bf_vector;
} nfapi_nr_dl_config_pdcch_parameters_rel15_t;
//--------------------------------------------------------//
// This is a temp nfapi struct.
// Once the specs for nfapi UL is ready we will update this struct
typedef struct {
nfapi_tl_t tl;
uint16_t rnti;
uint8_t rnti_type;
uint8_t dci_format;
/// Number of CRB in BWP that this DCI configures
uint16_t n_RB_BWP;
uint8_t config_type;
uint8_t search_space_type;
uint8_t common_search_space_type;
uint8_t aggregation_level;
uint16_t nb_rb;
uint8_t n_symb;
int Imcs;
int8_t rb_offset;
int first_rb; // first rb for PUSCH TX
uint8_t nb_codewords;
uint8_t Nl; // number of layers
uint8_t rvidx;
uint8_t cr_mapping_type;
uint8_t reg_bundle_size;
uint8_t interleaver_size;
uint8_t shift_index;
uint8_t mux_pattern;
uint8_t precoder_granularity;
uint8_t first_slot;
uint8_t first_symbol;
uint8_t nb_ss_sets_per_slot;
uint8_t nb_slots;
uint8_t sfn_mod2;
uint16_t scrambling_id;
nfapi_bf_vector_t bf_vector;
} temp_nfapi_nr_ul_config_pdcch_parameters_rel15_t;
//--------------------------------------------------------//
typedef struct {
nfapi_tl_t tl;
uint16_t length;
......
......@@ -1055,6 +1055,22 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
NR_DL_FRAME_PARMS* frame_parms,
uint8_t harq_pid);
/*! \brief Fill up NR_UE_ULSCH_t and NR_UL_UE_HARQ_t structs
@param[in] UE, Pointer to PHY_VARS_NR_UE struct
@param[in] nr_ul_pdcch_params, pointer to temp_nfapi_nr_ul_config_pdcch_parameters_rel15_t struct
@param[in] thread_id, thread id
@param[in] gNB_id, gNB id
@param[in] harq_pid, harq id
@param[in] test_input, pointer to ulsch pdu to be sent
*/
int generate_ue_ulsch_params(PHY_VARS_NR_UE *UE,
temp_nfapi_nr_ul_config_pdcch_parameters_rel15_t *nr_ul_pdcch_params,
uint8_t thread_id,
int gNB_id,
unsigned char harq_pid,
unsigned char *test_input);
/*! \brief Perform PUSCH scrambling. TS 38.211 V15.4.0 subclause 6.3.1.1
@param[in] in, Pointer to input bits
@param[in] size, of input bits
......
......@@ -47,6 +47,63 @@
#endif
int generate_ue_ulsch_params(PHY_VARS_NR_UE *UE,
temp_nfapi_nr_ul_config_pdcch_parameters_rel15_t *nr_ul_pdcch_params,
uint8_t thread_id,
int gNB_id,
unsigned char harq_pid,
unsigned char *test_input){
int N_PRB_oh, N_RE_prime, cwd_idx, length_dmrs, Nid_cell;
uint16_t n_rnti;
NR_UE_ULSCH_t *ulsch_ue;
NR_UL_UE_HARQ_t *harq_process_ul_ue;
length_dmrs = 1;
n_rnti = 0x1234;
Nid_cell = 0;
for (cwd_idx = 0; cwd_idx < nr_ul_pdcch_params->nb_codewords; cwd_idx++) {
ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_idx];
harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid];
ulsch_ue->length_dmrs = length_dmrs;
ulsch_ue->rnti = n_rnti;
ulsch_ue->Nid_cell = Nid_cell;
ulsch_ue->Nsc_pusch = nr_ul_pdcch_params->nb_rb*NR_NB_SC_PER_RB;
ulsch_ue->Nsymb_pusch = nr_ul_pdcch_params->n_symb;
ulsch_ue->nb_re_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength*(UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4;
N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
N_RE_prime = NR_NB_SC_PER_RB*nr_ul_pdcch_params->n_symb - ulsch_ue->nb_re_dmrs - N_PRB_oh;
if (harq_process_ul_ue) {
harq_process_ul_ue->mcs = nr_ul_pdcch_params->Imcs;
harq_process_ul_ue->Nl = nr_ul_pdcch_params->Nl;
harq_process_ul_ue->nb_rb = nr_ul_pdcch_params->nb_rb;
harq_process_ul_ue->first_rb = nr_ul_pdcch_params->first_rb;
harq_process_ul_ue->number_of_symbols = nr_ul_pdcch_params->n_symb;
harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nr_ul_pdcch_params->nb_rb*nr_ul_pdcch_params->nb_codewords;
harq_process_ul_ue->rvidx = nr_ul_pdcch_params->rvidx;
harq_process_ul_ue->a = test_input;
harq_process_ul_ue->TBS = nr_compute_tbs(nr_ul_pdcch_params->Imcs,
nr_ul_pdcch_params->nb_rb,
nr_ul_pdcch_params->n_symb,
ulsch_ue->nb_re_dmrs,
length_dmrs,
nr_ul_pdcch_params->Nl);
}
}
return 0;
}
void nr_pusch_codeword_scrambling(uint8_t *in,
......
......@@ -64,21 +64,6 @@ RAN_CONTEXT_t RC;
double cpuf;
typedef struct ulsim_params_s {
uint16_t Nid_cell;
uint8_t nb_codewords;
uint8_t Imcs;
uint16_t nb_symb_sch;
int eNB_id;
int nb_rb;
int first_rb;
uint8_t length_dmrs;
uint8_t Nl;
uint8_t rvidx;
uint8_t UE_id;
uint16_t n_rnti;
} ulsim_params_t;
// dummy functions
int nfapi_mode = 0;
int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) {
......@@ -112,56 +97,6 @@ NR_IF_Module_init(int Mod_id) {
return (NULL);
}
int generate_ue_ulsch_params(PHY_VARS_NR_UE *UE,
ulsim_params_t *ulsim_params,
uint8_t thread_id,
unsigned char harq_pid,
unsigned char *test_input){
int N_PRB_oh, N_RE_prime, cwd_idx;
NR_UE_ULSCH_t *ulsch_ue;
NR_UL_UE_HARQ_t *harq_process_ul_ue;
for (cwd_idx = 0;cwd_idx < 1;cwd_idx++){
ulsch_ue = UE->ulsch[thread_id][ulsim_params->eNB_id][cwd_idx];
harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid];
ulsch_ue->length_dmrs = ulsim_params->length_dmrs;
ulsch_ue->rnti = ulsim_params->n_rnti;
ulsch_ue->Nid_cell = ulsim_params->Nid_cell;
ulsch_ue->Nsc_pusch = ulsim_params->nb_rb*NR_NB_SC_PER_RB;
ulsch_ue->Nsymb_pusch = ulsim_params->nb_symb_sch;
ulsch_ue->nb_re_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength*(UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4;
N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
N_RE_prime = NR_NB_SC_PER_RB*ulsim_params->nb_symb_sch - ulsch_ue->nb_re_dmrs - N_PRB_oh;
if (harq_process_ul_ue) {
harq_process_ul_ue->mcs = ulsim_params->Imcs;
harq_process_ul_ue->Nl = ulsim_params->Nl;
harq_process_ul_ue->nb_rb = ulsim_params->nb_rb;
harq_process_ul_ue->first_rb = ulsim_params->first_rb;
harq_process_ul_ue->number_of_symbols = ulsim_params->nb_symb_sch;
harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*ulsim_params->nb_rb*ulsim_params->nb_codewords;
harq_process_ul_ue->rvidx = ulsim_params->rvidx;
harq_process_ul_ue->a = test_input;
harq_process_ul_ue->TBS = nr_compute_tbs(ulsim_params->Imcs,
ulsim_params->nb_rb,
ulsim_params->nb_symb_sch,
ulsch_ue->nb_re_dmrs,
ulsim_params->length_dmrs,
ulsim_params->Nl);
}
}
return 0;
}
void exit_function(const char *file, const char *function, const int line, const char *s) {
const char *msg = s == NULL ? "no comment" : s;
......@@ -210,7 +145,6 @@ int main(int argc, char **argv) {
//int8_t interf1 = -21, interf2 = -21;
FILE *input_fd = NULL;
SCM_t channel_model = AWGN; //Rayleigh1_anticorr;
ulsim_params_t ulsim_params;
uint16_t N_RB_DL = 106, N_RB_UL = 106, mu = 1;
//unsigned char frame_type = 0;
int frame = 0;
......@@ -222,15 +156,20 @@ int main(int argc, char **argv) {
int start_symbol = NR_SYMBOLS_PER_SLOT - nb_symb_sch;
uint16_t nb_rb = 50;
uint8_t Imcs = 9;
int eNB_id = 0;
int gNB_id = 0;
int ap;
int tx_offset;
double txlev;
int start_rb = 30;
int start_rb = 90;
int UE_id =0; // [hna] only works for UE_id = 0 because NUMBER_OF_NR_UE_MAX is set to 1 (phy_init_nr_gNB causes segmentation fault)
cpuf = get_cpu_freq_GHz();
temp_nfapi_nr_ul_config_pdcch_parameters_rel15_t nr_ul_pdcch_params;
if (load_configmodule(argc, argv) == 0) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
......@@ -486,18 +425,13 @@ int main(int argc, char **argv) {
}
}
ulsim_params.Nid_cell = Nid_cell;
ulsim_params.nb_codewords = nb_codewords;
ulsim_params.Imcs = Imcs;
ulsim_params.nb_symb_sch = nb_symb_sch;
ulsim_params.eNB_id = eNB_id;
ulsim_params.nb_rb = nb_rb;
ulsim_params.first_rb = start_rb;
ulsim_params.length_dmrs = 1;
ulsim_params.Nl = 1;
ulsim_params.rvidx = 0;
ulsim_params.UE_id = 0;
ulsim_params.n_rnti = n_rnti;
nr_ul_pdcch_params.nb_codewords = nb_codewords;
nr_ul_pdcch_params.Imcs = Imcs;
nr_ul_pdcch_params.n_symb = nb_symb_sch;
nr_ul_pdcch_params.nb_rb = nb_rb;
nr_ul_pdcch_params.first_rb = start_rb;
nr_ul_pdcch_params.Nl = 1;
nr_ul_pdcch_params.rvidx = 0;
unsigned char harq_pid = 0;
unsigned int TBS = 8424;
......@@ -508,9 +442,9 @@ int main(int argc, char **argv) {
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);
TBS = nr_compute_tbs(Imcs, nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, ulsim_params.Nl);
TBS = nr_compute_tbs(Imcs, nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, nr_ul_pdcch_params.Nl);
NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[ulsim_params.UE_id+1][0];
NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id+1][0];
ulsch_gNB->harq_processes[harq_pid]->G = available_bits; // [hna] temp until length_dmrs and nb_re_dmrs are signaled
nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &ulsch_gNB->harq_processes[harq_pid]->ulsch_pdu;
......@@ -524,8 +458,8 @@ int main(int argc, char **argv) {
rel15_ul->ulsch_pdu_rel15.number_symbols = nb_symb_sch;
rel15_ul->ulsch_pdu_rel15.Qm = mod_order;
rel15_ul->ulsch_pdu_rel15.mcs = Imcs;
rel15_ul->ulsch_pdu_rel15.rv = ulsim_params.rvidx;
rel15_ul->ulsch_pdu_rel15.n_layers = ulsim_params.Nl;
rel15_ul->ulsch_pdu_rel15.rv = nr_ul_pdcch_params.rvidx;
rel15_ul->ulsch_pdu_rel15.n_layers = nr_ul_pdcch_params.Nl;
///////////////////////////////////////////////////
unsigned char *estimated_output_bit;
......@@ -538,8 +472,6 @@ int main(int argc, char **argv) {
test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
int UE_id = ulsim_params.UE_id; // [hna] only works for UE_id = 0 because NUMBER_OF_NR_UE_MAX is set to 1 (phy_init_nr_gNB causes segmentation fault)
/////////////////////////phy_procedures_nr_ue_TX///////////////////////
///////////
......@@ -547,8 +479,9 @@ int main(int argc, char **argv) {
test_input[i] = (unsigned char) rand();
generate_ue_ulsch_params(UE,
&ulsim_params,
&nr_ul_pdcch_params,
0,
gNB_id,
harq_pid,
test_input);
......@@ -556,15 +489,15 @@ int main(int argc, char **argv) {
harq_pid,
slot,
0,
eNB_id);
gNB_id);
nr_ue_pusch_common_procedures(UE,
slot,
ulsim_params.Nl,
nr_ul_pdcch_params.Nl,
&UE->frame_parms);
///////////
////////////////////////////////////////////////////
///////////
////////////////////////////////////////////////////
tx_offset = slot*frame_parms->samples_per_slot;
txlev = (double) signal_energy_amp_shift(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0],
......
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