dlsim.c 54.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

#include <fcntl.h>
23
24
#include <math.h>
#include <string.h>
25
26
#include <sys/ioctl.h>
#include <sys/mman.h>
27
28
#include <unistd.h>
#include "common/ran_context.h"
29
30
#include "common/config/config_userapi.h"
#include "common/utils/LOG/log.h"
31
32
33
#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
#include "LAYER2/NR_MAC_UE/mac_defs.h"
#include "LAYER2/NR_MAC_UE/mac_extern.h"
34
#include "PHY/defs_gNB.h"
35
36
#include "PHY/defs_nr_common.h"
#include "PHY/defs_nr_UE.h"
yilmazt's avatar
yilmazt committed
37
#include "PHY/phy_vars_nr_ue.h"
38
39
#include "PHY/types.h"
#include "PHY/INIT/phy_init.h"
40
#include "PHY/MODULATION/modulation_eNB.h"
41
#include "PHY/MODULATION/nr_modulation.h"
42
#include "PHY/MODULATION/modulation_UE.h"
43
#include "PHY/NR_REFSIG/refsig_defs_ue.h"
44
#include "PHY/NR_TRANSPORT/nr_dlsch.h"
Guido Casati's avatar
Guido Casati committed
45
#include "PHY/NR_TRANSPORT/nr_transport_proto.h"
46
#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
47
#include "SCHED_NR/fapi_nr_l1.h"
48
#include "SCHED_NR/sched_nr.h"
49
#include "SCHED_NR_UE/defs.h"
50
51
52
53
#include "SCHED_NR_UE/fapi_nr_ue_l1.h"
#include "NR_PHY_INTERFACE/NR_IF_Module.h"
#include "NR_UE_PHY_INTERFACE/NR_IF_Module.h"

54
#include "LAYER2/NR_MAC_UE/mac_proto.h"
yilmazt's avatar
yilmazt committed
55
56
//#include "LAYER2/NR_MAC_gNB/mac_proto.h"
//#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
57
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
58
#include "NR_asn_constant.h"
59
#include "RRC/NR/MESSAGES/asn1_msg.h"
60
61
62
#include "openair1/SIMULATION/RF/rf.h"
#include "openair1/SIMULATION/TOOLS/sim.h"
#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
knopp's avatar
knopp committed
63
//#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
64
#include "PHY/NR_REFSIG/ptrs_nr.h"
knopp's avatar
knopp committed
65
#include "NR_RRCReconfiguration.h"
Thomas Laurent's avatar
Thomas Laurent committed
66
#define inMicroS(a) (((double)(a))/(get_cpu_freq_GHz()*1000.0))
67
68
#include "SIMULATION/LTE_PHY/common_sim.h"

Thomas Laurent's avatar
Thomas Laurent committed
69
70
#include <openair2/LAYER2/MAC/mac_vars.h>
#include <openair2/RRC/LTE/rrc_vars.h>
71

knopp's avatar
knopp committed
72
73
#include <executables/softmodem-common.h>

74
75
LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC;
rlc_info_t Rlc_info_um,Rlc_info_am_config;
knopp's avatar
knopp committed
76

77
78
79
PHY_VARS_gNB *gNB;
PHY_VARS_NR_UE *UE;
RAN_CONTEXT_t RC;
80
81
int32_t uplink_frequency_offset[MAX_NUM_CCs][4];

82
double cpuf;
83

Thomas Laurent's avatar
Thomas Laurent committed
84
85
uint16_t sf_ahead=4 ;
uint16_t sl_ahead=0;
86
//uint8_t nfapi_mode = 0;
knopp's avatar
knopp committed
87
uint64_t downlink_frequency[MAX_NUM_CCs][4];
Thomas Laurent's avatar
Thomas Laurent committed
88
89
THREAD_STRUCT thread_struct;
nfapi_ue_release_request_body_t release_rntis;
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
90
uint32_t N_RB_DL = 106;
91
92

// dummy functions
knopp's avatar
knopp committed
93
94
int dummy_nr_ue_ul_indication(nr_uplink_indication_t *ul_info)              { return(0);  }

95
96
97
98
99
100
101
102
103
int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
                              const int CC_id,
                              const uint8_t gNB_index,
                              const frame_t frame,
                              const sub_frame_t sub_frame,
                              const rnti_t rnti,
                              const channel_t channel,
                              const uint8_t* pduP,
                              const sdu_size_t pdu_len)
104
105
106
107
{
  return 0;
}

108
109
110
111
112
void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB_index)
{
  return;
}

113
114
115
116
117
118
119
120
121
122
int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
                              const int         CC_id,
                              const uint8_t     gNB_id,
                              const frame_t     frameP,
                              const rb_id_t     Srb_id,
                              uint8_t           *buffer_pP)
{
  return 0;
}

123
124
void
rrc_data_ind(
knopp's avatar
knopp committed
125
  const protocol_ctxt_t *const ctxt_pP,
126
127
128
129
130
131
132
  const rb_id_t                Srb_id,
  const sdu_size_t             sdu_sizeP,
  const uint8_t   *const       buffer_pP
)
{
}

133
134
135
136
137
138
int ocp_gtpv1u_create_s1u_tunnel(instance_t instance,
                                 const gtpv1u_enb_create_tunnel_req_t  *create_tunnel_req,
                                 gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp) {
    return 0;
}

139
140
141
142
143
144
145
146
int
gtpv1u_create_s1u_tunnel(
  const instance_t                              instanceP,
  const gtpv1u_enb_create_tunnel_req_t *const  create_tunnel_req_pP,
  gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP
) {
  return 0;
}
knopp's avatar
knopp committed
147

148
149
150
151
152
153
154
155
int
rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
  const protocol_ctxt_t *const ctxt_pP,
  const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP,
  uint8_t                         *inde_list
) {
  return 0;
}
156

He Shanyun's avatar
He Shanyun committed
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
int
gtpv1u_create_ngu_tunnel(
  const instance_t instanceP,
  const gtpv1u_gnb_create_tunnel_req_t *  const create_tunnel_req_pP,
        gtpv1u_gnb_create_tunnel_resp_t * const create_tunnel_resp_pP){
  return 0;
}

int
gtpv1u_update_ngu_tunnel(
  const instance_t                              instanceP,
  const gtpv1u_gnb_create_tunnel_req_t *const  create_tunnel_req_pP,
  const rnti_t                                  prior_rnti
){
  return 0;
}

174
175
176
177
int ocp_gtpv1u_delete_s1u_tunnel(const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
  return 0;
}

He Shanyun's avatar
He Shanyun committed
178
179
180
181
182
183
184
185
186
int
nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(
  const protocol_ctxt_t *const ctxt_pP,
  const gtpv1u_gnb_create_tunnel_resp_t *const create_tunnel_resp_pP,
  uint8_t                         *inde_list
){
  return 0;
}

Cedric Roux's avatar
Cedric Roux committed
187
188
189
190
191
192
int nr_derive_key(int alg_type, uint8_t alg_id,
               const uint8_t key[32], uint8_t **out)
{
  return 0;
}

193
void config_common(int Mod_idP,
194
                   int ssb_SubcarrierOffset,
195
196
                   int pdsch_AntennaPorts,
                   int pusch_AntennaPorts,
197
		   NR_ServingCellConfigCommon_t *scc
knopp's avatar
knopp committed
198
		   );
199

200
201
202
203
204
205
206
207
208
int generate_dlsch_header(unsigned char *mac_header,
                          unsigned char num_sdus,
                          unsigned short *sdu_lengths,
                          unsigned char *sdu_lcids,
                          unsigned char drx_cmd,
                          unsigned short timing_advance_cmd,
                          unsigned char *ue_cont_res_id,
                          unsigned char short_padding,
                          unsigned short post_padding){return 0;}
209

210
// Dummy function to avoid linking error at compilation of nr-dlsim
211
212
213
214
215
int is_x2ap_enabled(void)
{
  return 0;
}

Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
216
217
218
219
220
221
222
223
224
225
226
int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t     module_idP,
                                            int             CC_idP,
                                            int             UE_id,
                                            rnti_t          rntiP,
                                            const uint8_t   *sduP,
                                            sdu_size_t      sdu_lenP,
                                            const uint8_t   *sdu2P,
                                            sdu_size_t      sdu2_lenP) {
  return 0;
}

Sakthivel Velumani's avatar
Sakthivel Velumani committed
227
228
void processSlotTX(void *arg) {}

Mahesh K's avatar
Mahesh K committed
229
230
231
232
233
234
//nFAPI P7 dummy functions

int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return(0);  }
int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req){ return(0);  }
int oai_nfapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req){ return(0);  }
int oai_nfapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req){ return(0);  }
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
235

236
// needed for some functions
237
openair0_config_t openair0_cfg[MAX_CARDS];
238
void update_ptrs_config(NR_CellGroupConfig_t *secondaryCellGroup, uint16_t *rbSize, uint8_t *mcsIndex,int8_t *ptrs_arg);
239
void update_dmrs_config(NR_CellGroupConfig_t *scg, int8_t* dmrs_arg);
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
240
extern void fix_scd(NR_ServingCellConfig_t *scd);// forward declaration
241

242
/* specific dlsim DL preprocessor: uses rbStart/rbSize/mcs/nrOfLayers from command line of
243
   dlsim, does not search for CCE/PUCCH occasion but simply sets to 0 */
244
int g_mcsIndex = -1, g_mcsTableIdx = 0, g_rbStart = -1, g_rbSize = -1, g_nrOfLayers = 1;
245
246
void nr_dlsim_preprocessor(module_id_t module_id,
                           frame_t frame,
247
                           sub_frame_t slot) {
248
249
250
  NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info;
  AssertFatal(UE_info->num_UEs == 1, "can have only a single UE\n");
  NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[0];
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
251
  NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon;
252
253
254

  /* manually set free CCE to 0 */
  const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific;
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
255
  sched_ctrl->search_space = get_searchspace(scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss);
256
257
258
259
  uint8_t nr_of_candidates;
  find_aggregation_candidates(&sched_ctrl->aggregation_level,
                              &nr_of_candidates,
                              sched_ctrl->search_space);
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
260
  sched_ctrl->coreset = get_coreset(scc, sched_ctrl->active_bwp, sched_ctrl->search_space, target_ss);
261
262
  sched_ctrl->cce_index = 0;

263
  NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static;
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
264

265
  nr_set_pdsch_semi_static(scc,
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
266
                           UE_info->CellGroup[0],
267
268
269
270
271
272
273
274
275
276
277
278
279
                           sched_ctrl->active_bwp,
                           /* tda = */ 2,
                           /* num_dmrs_cdm_grps_no_data = */ 1,
                           ps);

  NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch;
  sched_pdsch->rbStart = g_rbStart;
  sched_pdsch->rbSize = g_rbSize;
  sched_pdsch->mcs = g_mcsIndex;
  /* the following might override the table that is mandated by RRC
   * configuration */
  ps->mcsTableIdx = g_mcsTableIdx;

280
  sched_pdsch->nrOfLayers = g_nrOfLayers;
281
282
283
284
285
286
287
288
289
  sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx);
  sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx);
  sched_pdsch->tb_size = nr_compute_tbs(sched_pdsch->Qm,
                                        sched_pdsch->R,
                                        sched_pdsch->rbSize,
                                        ps->nrOfSymbols,
                                        ps->N_PRB_DMRS * ps->N_DMRS_SLOT,
                                        0 /* N_PRB_oh, 0 for initialBWP */,
                                        0 /* tb_scaling */,
290
                                        sched_pdsch->nrOfLayers)
291
292
                         >> 3;

293
  /* the simulator assumes the HARQ PID is equal to the slot number */
294
295
  sched_pdsch->dl_harq_pid = slot;

296
297
298
299
300
301
302
303
304
305
306
307
  /* The scheduler uses lists to track whether a HARQ process is
   * free/busy/awaiting retransmission, and updates the HARQ process states.
   * However, in the simulation, we never get ack or nack for any HARQ process,
   * thus the list and HARQ states don't match what the scheduler expects.
   * Therefore, below lines just "repair" everything so that the scheduler
   * won't remark that there is no HARQ feedback */
  sched_ctrl->feedback_dl_harq.head = -1; // always overwrite feedback HARQ process
  if (sched_ctrl->harq_processes[slot].round == 0) // depending on round set in simulation ...
    add_front_nr_list(&sched_ctrl->available_dl_harq, slot); // ... make PID available
  else
    add_front_nr_list(&sched_ctrl->retrans_dl_harq, slot);   // ... make PID retransmission
  sched_ctrl->harq_processes[slot].is_waiting = false;
308
309
310
311
  AssertFatal(sched_pdsch->rbStart >= 0, "invalid rbStart %d\n", sched_pdsch->rbStart);
  AssertFatal(sched_pdsch->rbSize > 0, "invalid rbSize %d\n", sched_pdsch->rbSize);
  AssertFatal(sched_pdsch->mcs >= 0, "invalid mcs %d\n", sched_pdsch->mcs);
  AssertFatal(ps->mcsTableIdx >= 0 && ps->mcsTableIdx <= 2, "invalid mcsTableIdx %d\n", ps->mcsTableIdx);
312
}
313

Sakthivel Velumani's avatar
Sakthivel Velumani committed
314
315
316
typedef struct {
  uint64_t       optmask;   //mask to store boolean config options
  uint8_t        nr_dlsch_parallel; // number of threads for dlsch decoding, 0 means no parallelization
317
  tpool_t        Tpool;             // thread pool
Sakthivel Velumani's avatar
Sakthivel Velumani committed
318
319
320
321
322
323
324
} nrUE_params_t;

nrUE_params_t nrUE_params;

nrUE_params_t *get_nrUE_params(void) {
  return &nrUE_params;
}
325

Sakthivel Velumani's avatar
Sakthivel Velumani committed
326
327
void do_nothing(void *args) {
}
328

329
330
331
int main(int argc, char **argv)
{
  char c;
332
  int i,aa;//,l;
333
  double sigma2, sigma2_dB=10, SNR, snr0=-2.0, snr1=2.0;
334
  uint8_t snr1set=0;
335
336
337
338
  double roundStats[500] = {0};
  double blerStats[500] = {0};
  double berStats[500] = {0};
  double snrStats[500] = {0};
Sakthivel Velumani's avatar
Sakthivel Velumani committed
339
  float effRate;
Francesco Mani's avatar
Francesco Mani committed
340
  //float psnr;
341
  float eff_tp_check = 0.7;
Sakthivel Velumani's avatar
Sakthivel Velumani committed
342
  uint8_t snrRun;
Sakthivel Velumani's avatar
Sakthivel Velumani committed
343
  uint32_t TBS = 0;
344
345
  int **txdata;
  double **s_re,**s_im,**r_re,**r_im;
346
347
  //double iqim = 0.0;
  //unsigned char pbch_pdu[6];
348
349
350
  //  int sync_pos, sync_pos_slot;
  //  FILE *rx_frame_file;
  FILE *output_fd = NULL;
351
  //uint8_t write_output_file=0;
352
  //int result;
353
  //int freq_offset;
knopp's avatar
knopp committed
354
  //  int subframe_offset;
355
  //  char fname[40], vname[40];
Ahmed Hussein's avatar
Ahmed Hussein committed
356
  int trial, n_trials = 1, n_errors = 0, n_false_positive = 0;
357
  //int n_errors2, n_alamouti;
358
  uint8_t n_tx=1,n_rx=1;
359
360
  uint8_t round;
  uint8_t num_rounds = 4;
361
362

  channel_desc_t *gNB2UE;
363
364
365
  //uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0;
  //uint8_t extended_prefix_flag=0;
  //int8_t interf1=-21,interf2=-21;
366
367

  FILE *input_fd=NULL,*pbch_file_fd=NULL;
368
  //char input_val_str[50],input_val_str2[50];
369

370
  //uint8_t frame_mod4,num_pdcch_symbols = 0;
371

372
  SCM_t channel_model = AWGN; // AWGN Rayleigh1 Rayleigh1_anticorr;
373

Thomas Laurent's avatar
Thomas Laurent committed
374
  NB_UE_INST = 1;
375
376
  //double pbch_sinr;
  //int pbch_tx_ant;
Ahmed Hussein's avatar
Ahmed Hussein committed
377
  int N_RB_DL=106,mu=1;
378

379
  //unsigned char frame_type = 0;
380

381
  int frame=1,slot=1;
382
  int frame_length_complex_samples;
Sakthivel Velumani's avatar
Sakthivel Velumani committed
383
  //int frame_length_complex_samples_no_prefix;
384
385
386
387
388
  NR_DL_FRAME_PARMS *frame_parms;
  UE_nr_rxtx_proc_t UE_proc;
  NR_Sched_Rsp_t Sched_INFO;
  gNB_MAC_INST *gNB_mac;
  NR_UE_MAC_INST_t *UE_mac;
389
  int cyclic_prefix_type = NFAPI_CP_NORMAL;
390
  int run_initial_sync=0;
knopp's avatar
knopp committed
391
  int loglvl=OAILOG_INFO;
392

Sakthivel Velumani's avatar
Sakthivel Velumani committed
393
  //float target_error_rate = 0.01;
394
  int css_flag=0;
395
396

  cpuf = get_cpu_freq_GHz();
397
398
399
  int8_t enable_ptrs = 0;
  int8_t modify_dmrs = 0;

400
  int8_t dmrs_arg[3] = {-1,-1,-1};// Invalid values
401
  /* L_PTRS = ptrs_arg[0], K_PTRS = ptrs_arg[1] */
402
403
  int8_t ptrs_arg[2] = {-1,-1};// Invalid values

404
405
406
407
408
409
  uint16_t ptrsRePerSymb = 0;
  uint16_t pdu_bit_map = 0x0;
  uint16_t dlPtrsSymPos = 0;
  uint16_t ptrsSymbPerSlot = 0;
  uint16_t rbSize = 106;
  uint8_t  mcsIndex = 9;
410
  uint8_t  dlsch_threads = 0;
411
  if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0) {
yilmazt's avatar
yilmazt committed
412
    exit_fun("[NR_DLSIM] Error, configuration module init failed\n");
413
414
415
416
  }

  randominit(0);

417
  int print_perf             = 0;
418

419
420
  FILE *scg_fd=NULL;
  
421
  while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:M:N:F:GR:dPIL:Ea:b:d:e:m:w:T:U:q")) != -1) {
422
    switch (c) {
423
424
    case 'f':
      scg_fd = fopen(optarg,"r");
425

426
      if (scg_fd==NULL) {
427
428
429
        printf("Error opening %s\n",optarg);
        exit(-1);
      }
430
      break;
431

432
    /*case 'd':
433
      frame_type = 1;
434
      break;*/
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465

    case 'g':
      switch((char)*optarg) {
      case 'A':
        channel_model=SCM_A;
        break;

      case 'B':
        channel_model=SCM_B;
        break;

      case 'C':
        channel_model=SCM_C;
        break;

      case 'D':
        channel_model=SCM_D;
        break;

      case 'E':
        channel_model=EPA;
        break;

      case 'F':
        channel_model=EVA;
        break;

      case 'G':
        channel_model=ETU;
        break;

466
467
468
469
      case 'R':
        channel_model=Rayleigh1;
        break;

470
      default:
471
        printf("Unsupported channel model!\n");
472
473
474
475
476
        exit(-1);
      }

      break;

477
    /*case 'i':
478
479
480
481
482
      interf1=atoi(optarg);
      break;

    case 'j':
      interf2=atoi(optarg);
483
      break;*/
484
485
486
487
488
489
490

    case 'n':
      n_trials = atoi(optarg);
      break;

    case 's':
      snr0 = atof(optarg);
491
      printf("Setting SNR0 to %f\n",snr0);
492
493
494
495
496
      break;

    case 'S':
      snr1 = atof(optarg);
      snr1set=1;
497
      printf("Setting SNR1 to %f\n",snr1);
498
499
500
501
502
503
504
      break;

      /*
      case 't':
      Td= atof(optarg);
      break;
      */
505
    /*case 'p':
506
      extended_prefix_flag=1;
507
      break;*/
508
509
510
511
512
513
514
515
516
517
518

      /*
      case 'r':
      ricean_factor = pow(10,-.1*atof(optarg));
      if (ricean_factor>1) {
        printf("Ricean factor must be between 0 and 1\n");
        exit(-1);
      }
      break;
      */
    case 'x':
519
      g_nrOfLayers=atoi(optarg);
520

521
522
523
      if ((g_nrOfLayers!=1) &&
          (g_nrOfLayers!=2)) {
        printf("Unsupported nr Of Layers %d\n",g_nrOfLayers);
524
525
526
527
528
529
530
531
        exit(-1);
      }

      break;

    case 'y':
      n_tx=atoi(optarg);

532
      if ((n_tx==0) || (n_tx>4)) {//extend gNB to support n_tx = 4
533
        printf("Unsupported number of tx antennas %d\n",n_tx);
534
535
536
537
538
539
540
541
        exit(-1);
      }

      break;

    case 'z':
      n_rx=atoi(optarg);

542
      if ((n_rx==0) || (n_rx>4)) {//extend UE to support n_tx = 4
543
        printf("Unsupported number of rx antennas %d\n",n_rx);
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
        exit(-1);
      }

      break;

    case 'R':
      N_RB_DL = atoi(optarg);
      break;

    case 'F':
      input_fd = fopen(optarg,"r");

      if (input_fd==NULL) {
        printf("Problem with filename %s\n",optarg);
        exit(-1);
      }

      break;

    case 'P':
564
565
      print_perf=1;
      opp_enabled=1;
566
567
568
569
      break;
      
    case 'I':
      run_initial_sync=1;
Sakthivel Velumani's avatar
Sakthivel Velumani committed
570
      //target_error_rate=0.1;
571
      slot = 0;
572
573
574
575
576
577
      break;

    case 'L':
      loglvl = atoi(optarg);
      break;

578

579
580
581
    case 'E':
	css_flag=1;
	break;
582

583

584
    case 'a':
585
      g_rbStart = atoi(optarg);
586
587
588
      break;

    case 'b':
589
      g_rbSize = atoi(optarg);
590
      break;
591
592
593
    case 'd':
      dlsch_threads = atoi(optarg);
      break;    
594
    case 'e':
595
      g_mcsIndex = atoi(optarg);
596
597
      break;

598
599
600
601
602
    case 'q':
      g_mcsTableIdx = 1;
      get_softmodem_params()->use_256qam_table = 1;
      break;

603
604
605
    case 'm':
      mu = atoi(optarg);
      break;
606

607
608
609
610
    case 't':
      eff_tp_check = (float)atoi(optarg)/100;
      break;

611
612
613
    case 'w':
      output_fd = fopen("txdata.dat", "w+");
      break;
Sakthivel Velumani's avatar
Sakthivel Velumani committed
614

615
616
617
618
619
620
621
    case 'T':
      enable_ptrs=1;
      for(i=0; i < atoi(optarg); i++) {
        ptrs_arg[i] = atoi(argv[optind++]);
      }
      break;

622
623
    case 'U':
      modify_dmrs = 1;
624
      for(i=0; i < atoi(optarg); i++) {
625
626
627
        dmrs_arg[i] = atoi(argv[optind++]);
      }
      break;
Sakthivel Velumani's avatar
Sakthivel Velumani committed
628

629
630
631
632
633
    default:
    case 'h':
      printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n",
             argv[0]);
      printf("-h This message\n");
634
635
      //printf("-p Use extended prefix mode\n");
      //printf("-d Use TDD\n");
636
637
638
639
      printf("-n Number of frames to simulate\n");
      printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB.  If n_frames is 1 then just SNR is simulated\n");
      printf("-S Ending SNR, runs from SNR0 to SNR1\n");
      printf("-t Delay spread for multipath channel\n");
640
      printf("-g [A,B,C,D,E,F,G,R] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models or R for MIMO model (ignores delay spread and Ricean factor)\n");
641
      printf("-y Number of TX antennas used in gNB\n");
642
      printf("-z Number of RX antennas used in UE\n");
643
644
      //printf("-i Relative strength of first intefering gNB (in dB) - cell_id mod 3 = 1\n");
      //printf("-j Relative strength of second intefering gNB (in dB) - cell_id mod 3 = 2\n");
645
646
647
      printf("-R N_RB_DL\n");
      printf("-O oversampling factor (1,2,4,8,16)\n");
      printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n");
648
      //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n");
649
      printf("-f raw file containing RRC configuration (generated by gNB)\n");
650
      printf("-F Input filename (.txt format) for RX conformance testing\n");
651
      printf("-E used CSS scheduler\n");
652
      printf("-o CORESET offset\n");
653
654
      printf("-a Start PRB for PDSCH\n");
      printf("-b Number of PRB for PDSCH\n");
Sakthivel Velumani's avatar
Sakthivel Velumani committed
655
656
      printf("-c Start symbol for PDSCH (fixed for now)\n");
      printf("-j Number of symbols for PDSCH (fixed for now)\n");
657
      printf("-e MSC index\n");
658
      printf("-q Use 2nd MCS table (256 QAM table) for PDSCH\n");
659
      printf("-t Acceptable effective throughput (in percentage)\n");
660
      printf("-T Enable PTRS, arguments list L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 2 0 2 \n");
661
      printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:2} DMRS ConfType{1:2}, e.g. -U 3 0 2 1 \n");
662
      printf("-P Print DLSCH performances\n");
Sakthivel Velumani's avatar
Sakthivel Velumani committed
663
      printf("-w Write txdata to binary file (one frame)\n");
664
      printf("-d number of dlsch threads, 0: no dlsch parallelization\n");
665
666
667
668
      exit (-1);
      break;
    }
  }
669

670
671
672
  logInit();
  set_glog(loglvl);
  T_stdout = 1;
673
674
  /* initialize the sin table */
  InitSinLUT();
675

676
  get_softmodem_params()->phy_test = 1;
677
678
  get_softmodem_params()->do_ra = 0;

679
680
  if (snr1set==0)
    snr1 = snr0+10;
681
  init_dlsch_tpool(dlsch_threads);
682
683


684
685
686
  RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
  RC.gNB[0] = (PHY_VARS_gNB*) malloc(sizeof(PHY_VARS_gNB ));
  memset(RC.gNB[0],0,sizeof(PHY_VARS_gNB));
knopp's avatar
knopp committed
687

688
  gNB = RC.gNB[0];
689
690
691
692
693
694
  frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
  frame_parms->nb_antennas_tx = n_tx;
  frame_parms->nb_antennas_rx = n_rx;
  frame_parms->N_RB_DL = N_RB_DL;
  frame_parms->N_RB_UL = N_RB_DL;

knopp's avatar
knopp committed
695
  RC.nb_nr_macrlc_inst = 1;
696
697
698
  RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int));
  for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
    RC.nb_nr_mac_CC[i] = 1;
knopp's avatar
knopp committed
699
700
701
  mac_top_init_gNB();
  gNB_mac = RC.nrmac[0];
  gNB_RRC_INST rrc;
knopp's avatar
knopp committed
702
  memset((void*)&rrc,0,sizeof(rrc));
703

704
  /*
knopp's avatar
knopp committed
705
  // read in SCGroupConfig
knopp's avatar
knopp committed
706
  AssertFatal(scg_fd != NULL,"no reconfig.raw file\n");
knopp's avatar
knopp committed
707
708
709
710
  char buffer[1024];
  int msg_len=fread(buffer,1,1024,scg_fd);
  NR_RRCReconfiguration_t *NR_RRCReconfiguration;

knopp's avatar
knopp committed
711
  printf("Decoding NR_RRCReconfiguration (%d bytes)\n",msg_len);
knopp's avatar
knopp committed
712
713
714
715
716
717
718
719
720
721
722
723
724
725
  asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
						  &asn_DEF_NR_RRCReconfiguration,
						  (void **)&NR_RRCReconfiguration,
						  (uint8_t *)buffer,
						  msg_len); 
  
  if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
    AssertFatal(1==0,"NR_RRCReConfiguration decode error\n");
    // free the memory
    SEQUENCE_free( &asn_DEF_NR_RRCReconfiguration, NR_RRCReconfiguration, 1 );
    exit(-1);
  }      
  fclose(scg_fd);

knopp's avatar
knopp committed
726
727
  AssertFatal(NR_RRCReconfiguration->criticalExtensions.present == NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration,"wrong NR_RRCReconfiguration->criticalExstions.present type\n");

knopp's avatar
knopp committed
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
  NR_RRCReconfiguration_IEs_t *reconfig_ies = NR_RRCReconfiguration->criticalExtensions.choice.rrcReconfiguration;
  NR_CellGroupConfig_t *secondaryCellGroup;
  dec_rval = uper_decode_complete( NULL,
				   &asn_DEF_NR_CellGroupConfig,
				   (void **)&secondaryCellGroup,
				   (uint8_t *)reconfig_ies->secondaryCellGroup->buf,
				   reconfig_ies->secondaryCellGroup->size); 
  
  if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
    AssertFatal(1==0,"NR_CellGroupConfig decode error\n");
    // free the memory
    SEQUENCE_free( &asn_DEF_NR_CellGroupConfig, secondaryCellGroup, 1 );
    exit(-1);
  }      
  
743
744
  NR_ServingCellConfigCommon_t *scc = secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
  */
knopp's avatar
knopp committed
745

746
747
748
749

  rrc.carrier.servingcellconfigcommon = calloc(1,sizeof(*rrc.carrier.servingcellconfigcommon));

  NR_ServingCellConfigCommon_t *scc = rrc.carrier.servingcellconfigcommon;
Shweta Shrivastava's avatar
Shweta Shrivastava committed
750
  NR_ServingCellConfig_t *scd = calloc(1,sizeof(NR_ServingCellConfig_t));
751
752
  NR_CellGroupConfig_t *secondaryCellGroup=calloc(1,sizeof(*secondaryCellGroup));
  prepare_scc(rrc.carrier.servingcellconfigcommon);
753
  uint64_t ssb_bitmap = 1;
754
  fill_scc(rrc.carrier.servingcellconfigcommon,&ssb_bitmap,N_RB_DL,N_RB_DL,mu,mu);
755
  ssb_bitmap = 1;// Enable only first SSB with index ssb_indx=0
Francesco Mani's avatar
Francesco Mani committed
756
757
  fix_scc(scc,ssb_bitmap);

Shweta Shrivastava's avatar
Shweta Shrivastava committed
758
  prepare_scd(scd);
759

760
  fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, 0, 1, n_tx, 0, 0, 0);
761

762
763
  /* RRC parameter validation for secondaryCellGroup */
  fix_scd(scd);
764
  /* -U option modify DMRS */
765
  if(modify_dmrs) {
766
    update_dmrs_config(secondaryCellGroup, dmrs_arg);
767
  }
768
  /* -T option enable PTRS */
769
  if(enable_ptrs) {
770
    update_ptrs_config(secondaryCellGroup, &rbSize, &mcsIndex, ptrs_arg);
771
772
  }

773

774
  //xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup);
knopp's avatar
knopp committed
775

knopp's avatar
knopp committed
776
777
  AssertFatal((gNB->if_inst         = NR_IF_Module_init(0))!=NULL,"Cannot register interface");
  gNB->if_inst->NR_PHY_config_req      = nr_phy_config_request;
knopp's avatar
knopp committed
778
  // common configuration
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
779
  rrc_mac_config_req_gNB(0,0, n_tx, n_tx, scc, 0, 0, NULL);
knopp's avatar
knopp committed
780
  // UE dedicated configuration
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
781
  rrc_mac_config_req_gNB(0,0, n_tx, n_tx, scc, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup);
782
783
784
  // reset preprocessor to the one of DLSIM after it has been set during
  // rrc_mac_config_req_gNB
  gNB_mac->pre_processor_dl = nr_dlsim_preprocessor;
785
  phy_init_nr_gNB(gNB,0,1);
786
  N_RB_DL = gNB->frame_parms.N_RB_DL;
787
788
789
  NR_UE_info_t *UE_info = &RC.nrmac[0]->UE_info;
  UE_info->num_UEs=1;

knopp's avatar
knopp committed
790
  // stub to configure frame_parms
knopp's avatar
knopp committed
791
  //  nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions);
knopp's avatar
knopp committed
792
793
  // call MAC to configure common parameters

794
795
796
797
798
799
  /* rrc_mac_config_req_gNB() has created one user, so set the scheduling
   * parameters from command line in global variables that will be picked up by
   * scheduling preprocessor */
  if (g_mcsIndex < 0) g_mcsIndex = 9;
  if (g_rbStart < 0) g_rbStart=0;
  if (g_rbSize < 0) g_rbSize = N_RB_DL - g_rbStart;
knopp's avatar
knopp committed
800

801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
  double fs,bw;

  if (mu == 1 && N_RB_DL == 217) { 
    fs = 122.88e6;
    bw = 80e6;
  }					       
  else if (mu == 1 && N_RB_DL == 245) {
    fs = 122.88e6;
    bw = 90e6;
  }
  else if (mu == 1 && N_RB_DL == 273) {
    fs = 122.88e6;
    bw = 100e6;
  }
  else if (mu == 1 && N_RB_DL == 106) { 
    fs = 61.44e6;
    bw = 40e6;
  }
819
820
821
822
  else if (mu == 3 && N_RB_DL == 66) {
    fs = 122.88e6;
    bw = 100e6;
  }
Francesco Mani's avatar
Francesco Mani committed
823
824
825
826
  else if (mu == 3 && N_RB_DL == 32) {
    fs = 61.44e6;
    bw = 50e6;
  }
827
828
829
830
831
  else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL);

  gNB2UE = new_channel_desc_scm(n_tx,
                                n_rx,
                                channel_model,
832
                                fs/1e6,//sampling frequency in MHz
833
				bw,
834
				30e-9,
835
836
                                0,
                                0,
837
                                0, 0);
838
839

  if (gNB2UE==NULL) {
840
    printf("Problem generating channel model. Exiting.\n");
841
842
843
844
    exit(-1);
  }

  frame_length_complex_samples = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME;
Sakthivel Velumani's avatar
Sakthivel Velumani committed
845
  //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP*NR_NUMBER_OF_SUBFRAMES_PER_FRAME;
846

847
848
849
850
851
  s_re = malloc(n_tx*sizeof(double*));
  s_im = malloc(n_tx*sizeof(double*));
  r_re = malloc(n_rx*sizeof(double*));
  r_im = malloc(n_rx*sizeof(double*));
  txdata = malloc(n_tx*sizeof(int*));
852

853
  for (i=0; i<n_tx; i++) {
854
855
856
857
858
    s_re[i] = malloc(frame_length_complex_samples*sizeof(double));
    bzero(s_re[i],frame_length_complex_samples*sizeof(double));
    s_im[i] = malloc(frame_length_complex_samples*sizeof(double));
    bzero(s_im[i],frame_length_complex_samples*sizeof(double));

859
860
861
862
863
864
    printf("Allocating %d samples for txdata\n",frame_length_complex_samples);
    txdata[i] = malloc(frame_length_complex_samples*sizeof(int));
    bzero(txdata[i],frame_length_complex_samples*sizeof(int));
  }

  for (i=0; i<n_rx; i++) {
865
866
867
868
869
870
871
872
873
874
875
876
877
    r_re[i] = malloc(frame_length_complex_samples*sizeof(double));
    bzero(r_re[i],frame_length_complex_samples*sizeof(double));
    r_im[i] = malloc(frame_length_complex_samples*sizeof(double));
    bzero(r_im[i],frame_length_complex_samples*sizeof(double));
  }

  if (pbch_file_fd!=NULL) {
    load_pbch_desc(pbch_file_fd);
  }


  //configure UE
  UE = malloc(sizeof(PHY_VARS_NR_UE));
knopp's avatar
knopp committed
878
  memset((void*)UE,0,sizeof(PHY_VARS_NR_UE));
879
880
881
882
  PHY_vars_UE_g = malloc(sizeof(PHY_VARS_NR_UE**));
  PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_NR_UE*));
  PHY_vars_UE_g[0][0] = UE;
  memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS));
883
  UE->frame_parms.nb_antennas_rx = n_rx;
knopp's avatar
knopp committed
884

885
  if (run_initial_sync==1)  UE->is_synchronized = 0;
886
  else                      {UE->is_synchronized = 1; UE->UE_mode[0]=PUSCH;}
887
888
889
890
891
892
893
894
895
                      
  UE->perfect_ce = 0;

  if (init_nr_ue_signal(UE, 1, 0) != 0)
  {
    printf("Error at UE NR initialisation\n");
    exit(-1);
  }

896
897
  init_nr_ue_transport(UE,0);

898
  nr_gold_pbch(UE);
Francesco Mani's avatar
Francesco Mani committed
899
  nr_gold_pdcch(UE,0);
900

901
  nr_l2_init_ue(NULL);
902
  UE_mac = get_mac_inst(0);
903

904
905
906
  UE->if_inst = nr_ue_if_module_init(0);
  UE->if_inst->scheduled_response = nr_ue_scheduled_response;
  UE->if_inst->phy_config_request = nr_ue_phy_config_request;
907
  UE->if_inst->dl_indication = nr_ue_dl_indication;
908
  UE->if_inst->ul_indication = dummy_nr_ue_ul_indication;
909

910

911
  UE_mac->if_module = nr_ue_if_module_init(0);
912

913
  unsigned int available_bits=0;
Ahmed Hussein's avatar
Ahmed Hussein committed
914
915
916
917
918
  unsigned char *estimated_output_bit;
  unsigned char *test_input_bit;
  unsigned int errors_bit    = 0;
  uint32_t errors_scrambling = 0;

Sakthivel Velumani's avatar
Sakthivel Velumani committed
919
  initTpool("N", &(nrUE_params.Tpool), false);
920

Ahmed Hussein's avatar
Ahmed Hussein committed
921
922
  test_input_bit       = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
  estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
923
924
  
  // generate signal
925
926
  AssertFatal(input_fd==NULL,"Not ready for input signal file\n");
  gNB->pbch_configured = 1;
927
928
  gNB->ssb[0].ssb_pdu.ssb_pdu_rel15.bchPayload=0x001234;
  gNB->ssb[0].ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = 0;
knopp's avatar
knopp committed
929

930
  //Configure UE
931
932
  rrc.carrier.MIB = (uint8_t*) malloc(4);
  rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0);
Roberto Louro Magueta's avatar
Roberto Louro Magueta committed
933
  nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib, NULL, NULL, secondaryCellGroup);
934

935
936
937
938
939
940
941
942

  nr_dcireq_t dcireq;
  nr_scheduled_response_t scheduled_response;
  memset((void*)&dcireq,0,sizeof(dcireq));
  memset((void*)&scheduled_response,0,sizeof(scheduled_response));
  dcireq.module_id = 0;
  dcireq.gNB_index = 0;
  dcireq.cc_id     = 0;
943
  
944
945
946
947
948
949
950
  scheduled_response.dl_config = &dcireq.dl_config_req;
  scheduled_response.ul_config = &dcireq.ul_config_req;
  scheduled_response.tx_request = NULL;
  scheduled_response.module_id = 0;
  scheduled_response.CC_id     = 0;
  scheduled_response.frame = frame;
  scheduled_response.slot  = slot;
951
  scheduled_response.thread_id = 0;
Francesco Mani's avatar
Francesco Mani committed
952

953
  nr_ue_phy_config_request(&UE_mac->phy_config);
Francesco Mani's avatar
Francesco Mani committed
954
  //NR_COMMON_channels_t *cc = RC.nrmac[0]->common_channels;
Sakthivel Velumani's avatar
Sakthivel Velumani committed
955
  snrRun = 0;
956

957

Ahmed Hussein's avatar
Ahmed Hussein committed
958
  for (SNR = snr0; SNR < snr1; SNR += .2) {
959

960
961
962
963
964
965
966
967
968
969
970
    varArray_t *table_tx=initVarArray(1000,sizeof(double));
    reset_meas(&gNB->phy_proc_tx); // total gNB tx
    reset_meas(&gNB->dlsch_scrambling_stats);
    reset_meas(&gNB->dlsch_interleaving_stats);
    reset_meas(&gNB->dlsch_rate_matching_stats);
    reset_meas(&gNB->dlsch_segmentation_stats);
    reset_meas(&gNB->dlsch_modulation_stats);
    reset_meas(&gNB->dlsch_encoding_stats);
    reset_meas(&gNB->tinput);
    reset_meas(&gNB->tprep);
    reset_meas(&gNB->tparity);
971
    reset_meas(&gNB->toutput);
972

973
974
    clear_pdsch_stats(gNB);

975
    n_errors = 0;
Sakthivel Velumani's avatar
Sakthivel Velumani committed
976
    effRate = 0;
977
978
    //n_errors2 = 0;
    //n_alamouti = 0;
979
    errors_scrambling=0;
980
    n_false_positive = 0;
knopp's avatar
knopp committed
981
982
    if (n_trials== 1) num_rounds = 1;

Ahmed Hussein's avatar
Ahmed Hussein committed
983
    for (trial = 0; trial < n_trials; trial++) {
984

985
      errors_bit = 0;
Ahmed Hussein's avatar
Ahmed Hussein committed
986
      //multipath channel
987
      //multipath_channel(gNB2UE,s_re,s_im,r_re,r_im,frame_length_complex_samples,0);
988

989
      UE->rx_offset=0;
990
991
992
      UE_proc.thread_id  = 0;
      UE_proc.frame_rx   = frame;
      UE_proc.nr_slot_rx = slot;
993
994
995
      
      dcireq.frame     = frame;
      dcireq.slot      = slot;
996

997
      NR_UE_DLSCH_t *dlsch0 = UE->dlsch[UE_proc.thread_id][0][0];
998

999
      int harq_pid = slot;
1000
1001
1002
      NR_DL_UE_HARQ_t *UE_harq_process = dlsch0->harq_processes[harq_pid];

      NR_gNB_DLSCH_t *gNB_dlsch = gNB->dlsch[0][0];
1003
      nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &gNB_dlsch->harq_process.pdsch_pdu.pdsch_pdu_rel15;
1004
      
1005
      UE_harq_process->ack = 0;
1006
      round = 0;
Sakthivel Velumani's avatar
Sakthivel Velumani committed
1007
1008
      UE_harq_process->round = round;
      UE_harq_process->first_tx = 1;
1009
        
1010
      while ((round<num_rounds) && (UE_harq_process->ack==0)) {
1011
1012
        memset(RC.nrmac[0]->cce_list[1][0],0,MAX_NUM_CCE*sizeof(int));
        memset(RC.nrmac[0]->cce_list[1][1],0,MAX_NUM_CCE*sizeof(int));
1013
        clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot);
1014