int srslte_chest_ul_init(srslte_chest_ul_t *q, uint32_t max_prb) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL) { bzero(q, sizeof(srslte_chest_ul_t)); ret = srslte_refsignal_ul_init(&q->dmrs_signal, max_prb); if (ret != SRSLTE_SUCCESS) { fprintf(stderr, "Error initializing CSR signal (%d)\n",ret); goto clean_exit; } q->tmp_noise = srslte_vec_malloc(sizeof(cf_t) * MAX_REFS_SF); if (!q->tmp_noise) { perror("malloc"); goto clean_exit; } q->pilot_estimates = srslte_vec_malloc(sizeof(cf_t) * MAX_REFS_SF); if (!q->pilot_estimates) { perror("malloc"); goto clean_exit; } for (int i=0;i<4;i++) { q->pilot_estimates_tmp[i] = srslte_vec_malloc(sizeof(cf_t) * MAX_REFS_SF); if (!q->pilot_estimates_tmp[i]) { perror("malloc"); goto clean_exit; } } q->pilot_recv_signal = srslte_vec_malloc(sizeof(cf_t) * (MAX_REFS_SF+1)); if (!q->pilot_recv_signal) { perror("malloc"); goto clean_exit; } q->pilot_known_signal = srslte_vec_malloc(sizeof(cf_t) * (MAX_REFS_SF+1)); if (!q->pilot_known_signal) { perror("malloc"); goto clean_exit; } if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, MAX_REFS_SYM)) { fprintf(stderr, "Error initializing vector interpolator\n"); goto clean_exit; } q->smooth_filter_len = 3; srslte_chest_ul_set_smooth_filter3_coeff(q, 0.3333); q->dmrs_signal_configured = false; if (srslte_refsignal_dmrs_pusch_pregen_init(&q->dmrs_signal, &q->dmrs_pregen, max_prb)) { fprintf(stderr, "Error allocating memory for pregenerated signals\n"); goto clean_exit; } } ret = SRSLTE_SUCCESS; clean_exit: if (ret != SRSLTE_SUCCESS) { srslte_chest_ul_free(q); } return ret; }
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); }
/* 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; }
/* 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; }
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); }
int srslte_chest_ul_init(srslte_chest_ul_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && srslte_cell_isvalid(&cell)) { bzero(q, sizeof(srslte_chest_ul_t)); q->cell = cell; ret = srslte_refsignal_ul_init(&q->dmrs_signal, cell); if (ret != SRSLTE_SUCCESS) { fprintf(stderr, "Error initializing CSR signal (%d)\n",ret); goto clean_exit; } q->tmp_noise = srslte_vec_malloc(sizeof(cf_t) * NOF_REFS_SF); if (!q->tmp_noise) { perror("malloc"); goto clean_exit; } q->pilot_estimates = srslte_vec_malloc(sizeof(cf_t) * NOF_REFS_SF); if (!q->pilot_estimates) { perror("malloc"); goto clean_exit; } for (int i=0;i<4;i++) { q->pilot_estimates_tmp[i] = srslte_vec_malloc(sizeof(cf_t) * NOF_REFS_SF); if (!q->pilot_estimates_tmp[i]) { perror("malloc"); goto clean_exit; } } q->pilot_recv_signal = srslte_vec_malloc(sizeof(cf_t) * (NOF_REFS_SF+1)); if (!q->pilot_recv_signal) { perror("malloc"); goto clean_exit; } q->pilot_known_signal = srslte_vec_malloc(sizeof(cf_t) * (NOF_REFS_SF+1)); if (!q->pilot_known_signal) { perror("malloc"); goto clean_exit; } if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, NOF_REFS_SYM)) { fprintf(stderr, "Error initializing vector interpolator\n"); goto clean_exit; } q->smooth_filter_len = 3; srslte_chest_ul_set_smooth_filter3_coeff(q, 0.3333); q->dmrs_signal_configured = false; } ret = SRSLTE_SUCCESS; clean_exit: if (ret != SRSLTE_SUCCESS) { srslte_chest_ul_free(q); } return ret; }