예제 #1
0
void srslte_chest_ul_set_cfg(srslte_chest_ul_t *q, 
                             srslte_refsignal_dmrs_pusch_cfg_t *pusch_cfg,
                             srslte_pucch_cfg_t *pucch_cfg, 
                             srslte_refsignal_srs_cfg_t *srs_cfg)
{
  srslte_refsignal_ul_set_cfg(&q->dmrs_signal, pusch_cfg, pucch_cfg, srs_cfg);
  srslte_refsignal_dmrs_pusch_pregen(&q->dmrs_signal, &q->dmrs_pregen);
  q->dmrs_signal_configured = true; 
}
예제 #2
0
int main(int argc, char **argv) {
  srslte_pucch_t pucch;
  srslte_pucch_cfg_t pucch_cfg;
  srslte_refsignal_ul_t dmrs;
  uint8_t bits[SRSLTE_PUCCH_MAX_BITS];
  uint8_t pucch2_bits[2]; 
  cf_t *sf_symbols = NULL;
  cf_t pucch_dmrs[2*SRSLTE_NRE*3];
  int ret = -1;
  
  parse_args(argc,argv);

  if (srslte_pucch_init(&pucch, cell)) {
    fprintf(stderr, "Error creating PDSCH object\n");
    goto quit;
  }
  if (srslte_refsignal_ul_init(&dmrs, cell)) {
    fprintf(stderr, "Error creating PDSCH object\n");
    goto quit;
  }
  
  bzero(&pucch_cfg, sizeof(srslte_pucch_cfg_t));
  
  for (int i=0;i<SRSLTE_PUCCH_MAX_BITS;i++) {
    bits[i] = i%2;
  }
        
  for (int i=0;i<2;i++) {
    pucch2_bits[i] = i%2;
  }
  
  if (srslte_pucch_set_crnti(&pucch, 11)) {
    fprintf(stderr, "Error setting C-RNTI\n");
    goto quit; 
  }
  
  sf_symbols = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp));
  if (!sf_symbols) {
    goto quit; 
  }

  srslte_pucch_format_t format; 
  for (format=0;format<=SRSLTE_PUCCH_FORMAT_2B;format++) {
    for (uint32_t d=1;d<=3;d++) {
      for (uint32_t ncs=0;ncs<8;ncs+=d) {
        for (uint32_t n_pucch=1;n_pucch<130;n_pucch+=50) {
        
          struct timeval t[3]; 
          
          pucch_cfg.delta_pucch_shift = d; 
          bool group_hopping_en = false; 
          pucch_cfg.N_cs = ncs; 
          pucch_cfg.n_rb_2 = 0; 
    
          gettimeofday(&t[1], NULL);
          if (!srslte_pucch_set_cfg(&pucch, &pucch_cfg, group_hopping_en)) {
            fprintf(stderr, "Error setting PUCCH config\n");
            goto quit; 
          }
          
          if (srslte_pucch_encode(&pucch, format, n_pucch, subframe, bits, sf_symbols)) {
            fprintf(stderr, "Error encoding PUCCH\n");
            goto quit; 
          }
          
          srslte_refsignal_dmrs_pusch_cfg_t pusch_cfg; 
          pusch_cfg.group_hopping_en = group_hopping_en; 
          pusch_cfg.sequence_hopping_en = false; 
          srslte_refsignal_ul_set_cfg(&dmrs, &pusch_cfg, &pucch_cfg, NULL);
          
          if (srslte_refsignal_dmrs_pucch_gen(&dmrs, format, n_pucch, subframe, pucch2_bits, pucch_dmrs)) {
            fprintf(stderr, "Error encoding PUCCH\n");
            goto quit; 
          }
          if (srslte_refsignal_dmrs_pucch_put(&dmrs, format, n_pucch, pucch_dmrs, sf_symbols)) {
            fprintf(stderr, "Error encoding PUCCH\n");
            goto quit; 
          }     
          gettimeofday(&t[2], NULL);
          get_time_interval(t);
          INFO("format %d, n_pucch: %d, ncs: %d, d: %d, t_exec=%d us\n", format, n_pucch, ncs, d, t[0].tv_usec);
        }
      }
    }    
  }

  ret = 0;
quit:
  srslte_pucch_free(&pucch);
  srslte_refsignal_ul_free(&dmrs);
  
  if (sf_symbols) {
    free(sf_symbols);
  }
  if (ret) {
    printf("Error\n");
  } else {
    printf("Ok\n");
  }
  exit(ret);
}
예제 #3
0
/* the gateway function */
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{

  if (nrhs != NOF_INPUTS) {
    help();
    return;
  }
  
  srslte_cell_t cell;     
  bzero(&cell, sizeof(srslte_cell_t));
  cell.nof_ports = 1; 
  cell.cp = SRSLTE_CP_NORM; 
  if (mexutils_read_uint32_struct(UECFG, "NCellID", &cell.id)) {
    mexErrMsgTxt("Field NCellID not found in UE config\n");
    return;
  }
  if (mexutils_read_uint32_struct(UECFG, "NULRB", &cell.nof_prb)) {
    mexErrMsgTxt("Field NULRB not found in UE config\n");
    return;
  }

  uint32_t sf_idx = 0; 
  if (mexutils_read_uint32_struct(UECFG, "NSubframe", &sf_idx)) {
    mexErrMsgTxt("Field NSubframe not found in UE config\n");
    return;
  }
  uint32_t nf = 0;
  if (mexutils_read_uint32_struct(UECFG, "NFrame", &nf)) {
    mexErrMsgTxt("Field NFrame not found in UE config\n");
    return;
  }
  uint32_t tti = nf*10+sf_idx;
  
  srslte_refsignal_srs_cfg_t srs_cfg; 
  bzero(&srs_cfg, sizeof(srslte_refsignal_srs_cfg_t));
  
  if (mexutils_read_uint32_struct(SRSCFG, "BWConfig", &srs_cfg.bw_cfg)) {
    mexErrMsgTxt("Field BWConfig not found in SRSCFG\n");
    return;
  }
  if (mexutils_read_uint32_struct(SRSCFG, "BW", &srs_cfg.B)) {
    mexErrMsgTxt("Field BW not found in SRSCFG\n");
    return;
  }
  if (mexutils_read_uint32_struct(SRSCFG, "ConfigIdx", &srs_cfg.I_srs)) {
    mexErrMsgTxt("Field ConfigIdx not found in SRSCFG\n");
    return;
  }
  if (mexutils_read_uint32_struct(SRSCFG, "FreqPosition", &srs_cfg.n_rrc)) {
    mexErrMsgTxt("Field FreqPosition not found in SRSCFG\n");
    return;
  }
  if (mexutils_read_uint32_struct(SRSCFG, "HoppingBW", &srs_cfg.b_hop)) {
    mexErrMsgTxt("Field HoppingBW not found in SRSCFG\n");
    return;
  }
  if (mexutils_read_uint32_struct(SRSCFG, "TxComb", &srs_cfg.k_tc)) {
    mexErrMsgTxt("Field TxComb not found in SRSCFG\n");
    return;
  }
  if (mexutils_read_uint32_struct(SRSCFG, "CyclicShift", &srs_cfg.n_srs)) {
    mexErrMsgTxt("Field CyclicShift not found in SRSCFG\n");
    return;
  }
  bool group_hopping_en = false; 
  char *hop = mexutils_get_char_struct(UECFG, "Hopping"); 
  if (hop) {
    if (!strcmp(hop, "Group")) {
      group_hopping_en = true; 
    }
    mxFree(hop);
  }
  
  cf_t *r_srs = srslte_vec_malloc(sizeof(cf_t) * cell.nof_prb * 12); 
  if (!r_srs) {
    return; 
  }
  bzero(r_srs, cell.nof_prb * 12 * sizeof(cf_t));
  
  cf_t *sf_symbols = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp)); 
  if (!sf_symbols) {
    return; 
  }
  bzero(sf_symbols, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
  
  srslte_refsignal_ul_t refsignal;
  if (srslte_refsignal_ul_init(&refsignal, cell)) {
    mexErrMsgTxt("Error initiating UL refsignal\n");
    return;
  }
  srslte_refsignal_dmrs_pusch_cfg_t pusch_cfg; 
  pusch_cfg.group_hopping_en = group_hopping_en;
  pusch_cfg.sequence_hopping_en = false; 
  srslte_refsignal_ul_set_cfg(&refsignal, &pusch_cfg, NULL, &srs_cfg);

  if (srslte_refsignal_srs_gen(&refsignal, sf_idx, r_srs)) {
    mexErrMsgTxt("Error generating SRS\n");    
    return;
  }
  
  if (srslte_refsignal_srs_put(&refsignal, tti, r_srs, sf_symbols)) {
    mexErrMsgTxt("Error allocating SRS\n");    
    return;
  }
  
  if (nlhs >= 1) {
    uint32_t M_sc = srslte_refsignal_srs_M_sc(&refsignal); ;
    mexutils_write_cf(r_srs, &plhs[0], M_sc, 1);  
  }

  if (nlhs >= 2) {    
    mexutils_write_cf(sf_symbols, &plhs[1], SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp), 1);
  }

  srslte_refsignal_ul_free(&refsignal);  
  free(sf_symbols);
  free(r_srs);
  
  return;
}
예제 #4
0
/* the gateway function */
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  srslte_cell_t cell; 
  srslte_refsignal_ul_t refs;
  srslte_refsignal_dmrs_pusch_cfg_t pusch_cfg;
  uint32_t sf_idx; 

  if (nrhs != NOF_INPUTS) {
    help();
    return;
  }
    
  if (mexutils_read_uint32_struct(UECFG, "NCellID", &cell.id)) {
    mexErrMsgTxt("Field NCellID not found in UE config\n");
    return;
  }
  if (mexutils_read_uint32_struct(UECFG, "NULRB", &cell.nof_prb)) {
    mexErrMsgTxt("Field NCellID not found in UE config\n");
    return;
  }
  cell.cp = SRSLTE_CP_NORM;
  cell.nof_ports = 1; 

  if (mexutils_read_uint32_struct(UECFG, "NSubframe", &sf_idx)) {
    mexErrMsgTxt("Field NSubframe not found in UE config\n");
    return;
  }
  
  bzero(&pusch_cfg, sizeof(srslte_refsignal_dmrs_pusch_cfg_t));


  bool group_hopping_en = false;
  bool sequence_hopping_en = false;
  char *tmp = mexutils_get_char_struct(UECFG, "Hopping");
  if (tmp) {
    if (!strcmp(tmp, "Group")) {
      group_hopping_en = true;
    } else if (!strcmp(tmp, "Sequence")) {
      sequence_hopping_en = true;
    }
    mxFree(tmp);    
  }
  
  
  if (mexutils_read_uint32_struct(UECFG, "SeqGroup", &pusch_cfg.delta_ss)) {
    pusch_cfg.delta_ss = 0; 
  }
  if (mexutils_read_uint32_struct(UECFG, "CyclicShift", &pusch_cfg.cyclic_shift)) {
    pusch_cfg.cyclic_shift = 0; 
  }
  float *prbset; 
  mxArray *p; 
  p = mxGetField(PUSCHCFG, 0, "PRBSet");
  if (!p) {
    mexErrMsgTxt("Error field PRBSet not found in PUSCH config\n");
    return;
  } 
  uint32_t nof_prb = mexutils_read_f(p, &prbset); 
  
  uint32_t cyclic_shift_for_dmrs = 0; 
  if (mexutils_read_uint32_struct(PUSCHCFG, "DynCyclicShift", &cyclic_shift_for_dmrs)) {
    cyclic_shift_for_dmrs = 0; 
  } 
  
  pusch_cfg.beta_pusch = 1.0; 

  if (srslte_refsignal_ul_init(&refs, cell)) {
    mexErrMsgTxt("Error initiating srslte_refsignal_ul\n");
    return;
  }

  mexPrintf("nof_prb: %d, ",nof_prb);
  mexPrintf("cyclic_shift: %d, ",pusch_cfg.cyclic_shift);
  mexPrintf("cyclic_shift_for_dmrs: %d, ", cyclic_shift_for_dmrs);
  mexPrintf("delta_ss: %d, ",pusch_cfg.delta_ss);
  
  cf_t *signal = srslte_vec_malloc(2*SRSLTE_NRE*nof_prb*sizeof(cf_t));
  if (!signal) {
    perror("malloc");
    return;
  }
  cf_t *sf_symbols = srslte_vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp)*sizeof(cf_t));
  if (!sf_symbols) {
    perror("malloc");
    return;
  }
  bzero(sf_symbols, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp)*sizeof(cf_t));
  
  srslte_refsignal_ul_set_cfg(&refs, &pusch_cfg, NULL, NULL, group_hopping_en, sequence_hopping_en);
  
  //mexPrintf("Generating DRMS for ns=%d, nof_prb=%d\n", 2*sf_idx+i,pusch_cfg.nof_prb);
  srslte_refsignal_dmrs_pusch_gen(&refs, nof_prb, sf_idx, cyclic_shift_for_dmrs, signal);    
  uint32_t n_prb[2]; 
  n_prb[0] = prbset[0];
  n_prb[1] = prbset[0];
  srslte_refsignal_dmrs_pusch_put(&refs, signal, nof_prb, n_prb, sf_symbols);                
  if (nlhs >= 1) {
    mexutils_write_cf(sf_symbols, &plhs[0], SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp), 1);  
  }

  srslte_refsignal_ul_free(&refs);  
  free(signal);
  free(prbset);

  return;
}
예제 #5
0
int main(int argc, char **argv) {
  srslte_refsignal_ul_t refs;
  srslte_refsignal_dmrs_pusch_cfg_t pusch_cfg;
  cf_t *signal = NULL;
  int ret = -1;
  
  parse_args(argc,argv);

  if (srslte_refsignal_ul_init(&refs, cell)) {
    fprintf(stderr, "Error initializing UL reference signal\n");
    goto do_exit;
  }

  signal = malloc(2 * SRSLTE_NRE * cell.nof_prb * sizeof(cf_t));
  if (!signal) {
    perror("malloc");
    goto do_exit;
  }
  printf("Running tests for %d PRB\n", cell.nof_prb);
    
  for (int n=6;n<cell.nof_prb;n++) {
    for (int delta_ss=29;delta_ss<SRSLTE_NOF_DELTA_SS;delta_ss++) {
      for (int cshift=0;cshift<SRSLTE_NOF_CSHIFT;cshift++) {
        for (int h=0;h<3;h++) {
          for (int sf_idx=0;sf_idx<10;sf_idx++) {
            for (int cshift_dmrs=0;cshift_dmrs<SRSLTE_NOF_CSHIFT;cshift_dmrs++) {
              
              uint32_t nof_prb = n;
              pusch_cfg.cyclic_shift = cshift;
              pusch_cfg.delta_ss = delta_ss;        
              bool group_hopping_en = false; 
              bool sequence_hopping_en = false; 
              
              if (!h) {
                group_hopping_en = false;
                sequence_hopping_en = false;                
              } else if (h == 1) {
                group_hopping_en = false;
                sequence_hopping_en = true;                
              } else if (h == 2) {
                group_hopping_en = true;
                sequence_hopping_en = false;
              }

              printf("nof_prb: %d, ",nof_prb);
              printf("cyclic_shift: %d, ",pusch_cfg.cyclic_shift);
              printf("cyclic_shift_for_dmrs: %d, ", cshift_dmrs);
              printf("delta_ss: %d, ",pusch_cfg.delta_ss);
              printf("SF_idx: %d\n", sf_idx);
              struct timeval t[3]; 
              
              gettimeofday(&t[1], NULL);
              pusch_cfg.group_hopping_en = group_hopping_en; 
              pusch_cfg.sequence_hopping_en = sequence_hopping_en;
              srslte_refsignal_ul_set_cfg(&refs, &pusch_cfg, NULL, NULL);
              srslte_refsignal_dmrs_pusch_gen(&refs, nof_prb, sf_idx, cshift_dmrs, signal);              
              gettimeofday(&t[2], NULL);
              get_time_interval(t);
              printf("DMRS ExecTime: %d us\n", t[0].tv_usec);

              gettimeofday(&t[1], NULL);
              srslte_refsignal_srs_gen(&refs, sf_idx, signal);
              gettimeofday(&t[2], NULL);
              get_time_interval(t);
              printf("SRS ExecTime: %d us\n", t[0].tv_usec);
            }
          }
        }
      }
    }
  }

  ret = 0;

do_exit:

  if (signal) {
    free(signal);
  }

  srslte_refsignal_ul_free(&refs);
  
  if (!ret) {
    printf("OK\n");
  } 
  exit(ret);
}