diff --git a/mex/lib/mexutils.c b/mex/lib/mexutils.c index 54381a035..8d3aaaee5 100644 --- a/mex/lib/mexutils.c +++ b/mex/lib/mexutils.c @@ -83,9 +83,9 @@ int mexutils_read_cell(const mxArray *ptr, srslte_cell_t *cell) { return -1; } // TODO - cell->cp = CPNORM; - cell->phich_length = PHICH_NORM; - cell->phich_resources = R_1_6; + cell->cp = SRSLTE_SRSLTE_CP_NORM; + cell->phich_length = SRSLTE_PHICH_NORM; + cell->phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_6; return 0; } diff --git a/srslte/examples/cell_measurement.c b/srslte/examples/cell_measurement.c index b7a34f378..4c759d99b 100644 --- a/srslte/examples/cell_measurement.c +++ b/srslte/examples/cell_measurement.c @@ -178,7 +178,7 @@ int main(int argc, char **argv) { } /* set sampling frequency */ - int srate = lte_sampling_freq_hz(cell.nof_prb); + int srate = srslte_sampling_freq_hz(cell.nof_prb); if (srate != -1) { cuhd_set_rx_srate(uhd, (double) srate); } else { @@ -204,7 +204,7 @@ int main(int argc, char **argv) { } /* Configure downlink receiver for the SI-RNTI since will be the only one we'll use */ - ue_dl_set_rnti(&ue_dl, SIRNTI); + ue_dl_set_rnti(&ue_dl, SRSLTE_SIRNTI); /* Initialize subframe counter */ sf_cnt = 0; @@ -218,7 +218,7 @@ int main(int argc, char **argv) { return -1; } - int sf_re = SF_LEN_RE(cell.nof_prb, cell.cp); + int sf_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp); cf_t *sf_symbols = vec_malloc(sf_re * sizeof(cf_t)); @@ -259,7 +259,7 @@ int main(int argc, char **argv) { case DECODE_SIB: /* We are looking for SI Blocks, search only in appropiate places */ if ((ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) { - n = ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data, ue_sync_get_sfidx(&ue_sync), SIRNTI, + n = ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data, ue_sync_get_sfidx(&ue_sync), SRSLTE_SIRNTI, ((int) ceilf((float)3*(((sfn)/2)%4)/2))%4); if (n < 0) { fprintf(stderr, "Error decoding UE DL\n");fflush(stdout); @@ -293,7 +293,7 @@ int main(int argc, char **argv) { srslte_chest_dl_estimate(&chest, sf_symbols, ce, ue_sync_get_sfidx(&ue_sync)); - rssi = VEC_CMA(vec_avg_power_cf(sf_buffer,SF_LEN(lte_symbol_sz(cell.nof_prb))),rssi,nframes); + rssi = VEC_CMA(vec_avg_power_cf(sf_buffer,SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb))),rssi,nframes); rssi_utra = VEC_CMA(srslte_chest_dl_get_rssi(&chest),rssi_utra,nframes); rsrq = VEC_EMA(srslte_chest_dl_get_rsrq(&chest),rsrq,0.05); rsrp = VEC_EMA(srslte_chest_dl_get_rsrp(&chest),rsrp,0.05); diff --git a/srslte/examples/cell_search.c b/srslte/examples/cell_search.c index 43f4cc64b..5a5f86b98 100644 --- a/srslte/examples/cell_search.c +++ b/srslte/examples/cell_search.c @@ -122,7 +122,7 @@ int main(int argc, char **argv) { ue_cell_search_t cs; ue_cell_search_result_t found_cells[3]; int nof_freqs; - lte_earfcn_t channels[MAX_EARFCN]; + srslte_earfcn_t channels[MAX_EARFCN]; uint32_t freq; parse_args(argc, argv); @@ -134,7 +134,7 @@ int main(int argc, char **argv) { } cuhd_set_rx_gain(uhd, uhd_gain); - nof_freqs = lte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN); + nof_freqs = srslte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN); if (nof_freqs < 0) { fprintf(stderr, "Error getting EARFCN list\n"); exit(-1); diff --git a/srslte/examples/cuhd_utils.c b/srslte/examples/cuhd_utils.c index 6cd328050..051624133 100644 --- a/srslte/examples/cuhd_utils.c +++ b/srslte/examples/cuhd_utils.c @@ -61,7 +61,7 @@ int cuhd_mib_decoder(void *uhd, uint32_t max_nof_frames, srslte_cell_t *cell) { goto clean_exit; } - int srate = lte_sampling_freq_hz(MIB_NOF_PRB); + int srate = srslte_sampling_freq_hz(MIB_NOF_PRB); INFO("Setting sampling frequency %.2f MHz for PSS search\n", (float) srate/1000000); cuhd_set_rx_srate(uhd, (float) srate); diff --git a/srslte/examples/pdsch_enodeb.c b/srslte/examples/pdsch_enodeb.c index 1744e18f9..11ae049cc 100644 --- a/srslte/examples/pdsch_enodeb.c +++ b/srslte/examples/pdsch_enodeb.c @@ -53,9 +53,9 @@ srslte_cell_t cell = { 6, // nof_prb 1, // nof_ports 1, // cell_id - CPNORM, // cyclic prefix - R_1, // PHICH resources - PHICH_NORM // PHICH length + SRSLTE_SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_PHICH_R_1, // PHICH resources + SRSLTE_PHICH_NORM // PHICH length }; int net_port = -1; // -1 generates random data @@ -216,7 +216,7 @@ void base_init() { } /* create ifft object */ - if (lte_ifft_init(&ifft, CPNORM, cell.nof_prb)) { + if (lte_ifft_init(&ifft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb)) { fprintf(stderr, "Error creating iFFT object\n"); exit(-1); } @@ -325,7 +325,7 @@ int update_radl(uint32_t sf_idx) { ra_dl.type0_alloc.rbg_bitmask = prbset_to_bitmask(); ra_dl_alloc(&prb_alloc, &ra_dl, cell.nof_prb); - ra_dl_alloc_re(&prb_alloc, cell.nof_prb, 1, cell.nof_prb<10?(cfi+1):cfi, CPNORM); + ra_dl_alloc_re(&prb_alloc, cell.nof_prb, 1, cell.nof_prb<10?(cfi+1):cfi, SRSLTE_SRSLTE_CP_NORM); ra_mcs_from_idx_dl(mcs_idx, prb_alloc.slot[0].nof_prb, &ra_dl.mcs); ra_pdsch_fprint(stdout, &ra_dl, cell.nof_prb); @@ -461,11 +461,11 @@ int main(int argc, char **argv) { parse_args(argc, argv); N_id_2 = cell.id % 3; - sf_n_re = 2 * SRSLTE_CPNORM_NSYMB * cell.nof_prb * RE_X_RB; - sf_n_samples = 2 * SLOT_LEN(lte_symbol_sz(cell.nof_prb)); + sf_n_re = 2 * SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE; + sf_n_samples = 2 * SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb)); - cell.phich_length = PHICH_NORM; - cell.phich_resources = R_1; + cell.phich_length = SRSLTE_PHICH_NORM; + cell.phich_resources = SRSLTE_PHICH_R_1; sfn = 0; prbset_num = (int) ceilf((float) cell.nof_prb / ra_type0_P(cell.nof_prb)); @@ -486,13 +486,13 @@ int main(int argc, char **argv) { for (i = 0; i < SRSLTE_MAX_PORTS; i++) { // now there's only 1 port sf_symbols[i] = sf_buffer; - slot1_symbols[i] = &sf_buffer[SLOT_LEN_RE(cell.nof_prb, cell.cp)]; + slot1_symbols[i] = &sf_buffer[SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)]; } #ifndef DISABLE_UHD if (!output_file_name) { printf("Set TX rate: %.2f MHz\n", - cuhd_set_tx_srate(uhd, lte_sampling_freq_hz(cell.nof_prb)) / 1000000); + cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000); printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain)); printf("Set TX freq: %.2f MHz\n", cuhd_set_tx_freq(uhd, uhd_freq) / 1000000); @@ -525,9 +525,9 @@ int main(int argc, char **argv) { bzero(sf_buffer, sizeof(cf_t) * sf_n_re); if (sf_idx == 0 || sf_idx == 5) { - pss_put_slot(pss_signal, sf_buffer, cell.nof_prb, CPNORM); + pss_put_slot(pss_signal, sf_buffer, cell.nof_prb, SRSLTE_SRSLTE_CP_NORM); sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, sf_buffer, cell.nof_prb, - CPNORM); + SRSLTE_SRSLTE_CP_NORM); } srslte_refsignal_cs_put_sf(cell, 0, est.csr_signal.pilots[0][sf_idx], sf_buffer); @@ -591,7 +591,7 @@ int main(int argc, char **argv) { lte_ifft_run_sf(&ifft, sf_buffer, output_buffer); float norm_factor = (float) cell.nof_prb/15/sqrtf(ra_dl.prb_alloc.slot[0].nof_prb); - vec_sc_prod_cfc(output_buffer, uhd_amp*norm_factor, output_buffer, SF_LEN_PRB(cell.nof_prb)); + vec_sc_prod_cfc(output_buffer, uhd_amp*norm_factor, output_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb)); /* send to file or usrp */ if (output_file_name) { diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index 815613ee0..cc066745c 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -93,7 +93,7 @@ typedef struct { void args_default(prog_args_t *args) { args->nof_subframes = -1; - args->rnti = SIRNTI; + args->rnti = SRSLTE_SIRNTI; args->force_N_id_2 = -1; // Pick the best args->input_file_name = NULL; args->file_nof_prb = 6; @@ -281,7 +281,7 @@ int main(int argc, char **argv) { } /* set sampling frequency */ - int srate = lte_sampling_freq_hz(cell.nof_prb); + int srate = srslte_sampling_freq_hz(cell.nof_prb); if (srate != -1) { cuhd_set_rx_srate(uhd, (double) srate); } else { @@ -305,9 +305,9 @@ int main(int argc, char **argv) { state = DECODE_PDSCH; /* preset cell configuration */ cell.id = 1; - cell.cp = CPNORM; - cell.phich_length = PHICH_NORM; - cell.phich_resources = R_1; + cell.cp = SRSLTE_SRSLTE_CP_NORM; + cell.phich_length = SRSLTE_PHICH_NORM; + cell.phich_resources = SRSLTE_PHICH_R_1; cell.nof_ports = 1; cell.nof_prb = prog_args.file_nof_prb; @@ -386,7 +386,7 @@ int main(int argc, char **argv) { } break; case DECODE_PDSCH: - if (prog_args.rnti != SIRNTI) { + if (prog_args.rnti != SRSLTE_SIRNTI) { decode_pdsch = true; } else { /* We are looking for SIB1 Blocks, search only in appropiate places */ @@ -397,10 +397,10 @@ int main(int argc, char **argv) { } } if (decode_pdsch) { - if (prog_args.rnti != SIRNTI) { + if (prog_args.rnti != SRSLTE_SIRNTI) { n = ue_dl_decode(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync)); } else { - n = ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync), SIRNTI, + n = ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync), SRSLTE_SIRNTI, ((int) ceilf((float)3*(((sfn)/2)%4)/2))%4); } if (n < 0) { @@ -520,13 +520,13 @@ int main(int argc, char **argv) { plot_real_t p_sync, pce; plot_scatter_t pscatequal, pscatequal_pdcch; -float tmp_plot[SLOT_LEN_RE(MAX_PRB, CPNORM)]; -float tmp_plot2[SLOT_LEN_RE(MAX_PRB, CPNORM)]; -float tmp_plot3[SLOT_LEN_RE(MAX_PRB, CPNORM)]; +float tmp_plot[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)]; +float tmp_plot2[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)]; +float tmp_plot3[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)]; void *plot_thread_run(void *arg) { int i; - uint32_t nof_re = SF_LEN_RE(ue_dl.cell.nof_prb, ue_dl.cell.cp); + uint32_t nof_re = SRSLTE_SF_LEN_RE(ue_dl.cell.nof_prb, ue_dl.cell.cp); while(1) { sem_wait(&plot_sem); @@ -544,8 +544,8 @@ void *plot_thread_run(void *arg) { tmp_plot2[i] = -80; } } - //for (i=0;i= 0) { time_adv_sec = prog_args.ta_usec*1e-6; } @@ -562,17 +562,17 @@ int main(int argc, char **argv) { exit(-1); } - vec_sc_prod_cfc(ul_signal, prog_args.beta_pusch, ul_signal, SF_LEN_PRB(cell.nof_prb)); + vec_sc_prod_cfc(ul_signal, prog_args.beta_pusch, ul_signal, SRSLTE_SF_LEN_PRB(cell.nof_prb)); timestamp_copy(&next_tx_time, &uhd_time); timestamp_add(&next_tx_time, 0, 0.006 + i*0.008 - time_adv_sec); // send after 6 sub-frames (6 ms) printf("Send %d samples PUSCH sfn: %d. RV_idx=%d, Last frame time = %.6f " "send PUSCH time = %.6f TA: %.1f us\n", - SF_LEN_PRB(cell.nof_prb), sfn, ra_pusch.rv_idx, + SRSLTE_SF_LEN_PRB(cell.nof_prb), sfn, ra_pusch.rv_idx, timestamp_real(&uhd_time), timestamp_real(&next_tx_time), time_adv_sec*1000000); - cuhd_send_timed(uhd, ul_signal, SF_LEN_PRB(cell.nof_prb), + cuhd_send_timed(uhd, ul_signal, SRSLTE_SF_LEN_PRB(cell.nof_prb), next_tx_time.full_secs, next_tx_time.frac_secs); //cuhd_start_rx_stream(uhd); @@ -611,14 +611,14 @@ int main(int argc, char **argv) { exit(-1); } - vec_save_file("pusch_tx", ul_signal, SF_LEN_PRB(cell.nof_prb)*sizeof(cf_t)); + vec_save_file("pusch_tx", ul_signal, SRSLTE_SF_LEN_PRB(cell.nof_prb)*sizeof(cf_t)); #ifdef use_usrp cuhd_recv_with_time(uhd, dummy, 4, 1, &uhd_time.full_secs, &uhd_time.frac_secs); timestamp_copy(&next_tx_time, &uhd_time); while(1) { timestamp_add(&next_tx_time, 0, 0.002); // send every 2 ms - cuhd_send_timed(uhd, ul_signal, SF_LEN_PRB(cell.nof_prb), + cuhd_send_timed(uhd, ul_signal, SRSLTE_SF_LEN_PRB(cell.nof_prb), next_tx_time.full_secs, next_tx_time.frac_secs); } #else @@ -631,7 +631,7 @@ int main(int argc, char **argv) { case RECV_CONNSETUP: if (ue_sync_get_sfidx(&ue_sync) == (ul_sf_idx+4)%10) { //verbose=VERBOSE_DEBUG; - vec_save_file("connsetup",sf_buffer,SF_LEN_PRB(cell.nof_prb)*sizeof(cf_t)); + vec_save_file("connsetup",sf_buffer,SRSLTE_SF_LEN_PRB(cell.nof_prb)*sizeof(cf_t)); } else { //verbose=VERBOSE_NONE; } diff --git a/srslte/examples/synch_file.c b/srslte/examples/synch_file.c index fba630eef..6743e15cd 100644 --- a/srslte/examples/synch_file.c +++ b/srslte/examples/synch_file.c @@ -219,7 +219,7 @@ int main(int argc, char **argv) { /* If peak detected */ if (peak_value[N_id_2] > corr_peak_threshold) { - sss_idx = peak_pos[N_id_2]-2*(symbol_sz+CP(symbol_sz,CPNORM_LEN)); + sss_idx = peak_pos[N_id_2]-2*(symbol_sz+SRSLTE_CP(symbol_sz,SRSLTE_SRSLTE_CP_NORM_LEN)); if (sss_idx >= 0) { sss_synch_m0m1_diff(&sss[N_id_2], &input[sss_idx], &m0, &m0_value, &m1, &m1_value); diff --git a/srslte/include/srslte/ch_estimation/refsignal_ul.h b/srslte/include/srslte/ch_estimation/refsignal_ul.h index f484e4679..e0f06c62d 100644 --- a/srslte/include/srslte/ch_estimation/refsignal_ul.h +++ b/srslte/include/srslte/ch_estimation/refsignal_ul.h @@ -61,7 +61,7 @@ typedef struct SRSLTE_API { /** Uplink DeModulation Reference Signal (DMRS) */ typedef struct SRSLTE_API { srslte_cell_t cell; - uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NSYMB]; + uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]; float *tmp_arg; uint32_t n_prs_pusch[SRSLTE_NOF_DELTA_SS][SRSLTE_NSLOTS_X_FRAME]; // We precompute n_prs needed for cyclic shift alpha at srslte_refsignal_dl_init() uint32_t f_gh[SRSLTE_NSLOTS_X_FRAME]; diff --git a/srslte/include/srslte/common/phy_common.h b/srslte/include/srslte/common/phy_common.h index dfae48189..6e221ee63 100644 --- a/srslte/include/srslte/common/phy_common.h +++ b/srslte/include/srslte/common/phy_common.h @@ -39,92 +39,102 @@ #define SRSLTE_NSUBFRAMES_X_FRAME 10 #define SRSLTE_NSLOTS_X_FRAME (2*SRSLTE_NSUBFRAMES_X_FRAME) -#define LTE_NSOFT_BITS 250368 // Soft buffer size for Category 1 UE +#define SRSLTE_NSOFT_BITS 250368 // Soft buffer size for Category 1 UE #define SRSLTE_MAX_PORTS 4 -#define MAX_LAYERS 8 -#define MAX_CODEWORDS 2 +#define SRSLTE_MAX_LAYERS 8 +#define SRSLTE_MAX_CODEWORDS 2 -#define LTE_CRC24A 0x1864CFB -#define LTE_CRC24B 0X1800063 -#define LTE_CRC16 0x11021 -#define LTE_CRC8 0x19B +#define SRSLTE_LTE_CRC24A 0x1864CFB +#define SRSLTE_LTE_CRC24B 0X1800063 +#define SRSLTE_LTE_CRC16 0x11021 +#define SRSLTE_LTE_CRC8 0x19B -typedef enum {CPNORM, CPEXT} srslte_cp_t; +typedef enum {SRSLTE_SRSLTE_CP_NORM, SRSLTE_SRSLTE_CP_EXT} srslte_cp_t; -#define CRNTI_START 0x003D -#define CRNTI_END 0xFFF3 -#define RARNTI_START 0x0001 -#define RARNTI_END 0x003C -#define SIRNTI 0xFFFF -#define PRNTI 0xFFFE -#define MRNTI 0xFFFD +#define SRSLTE_CRNTI_START 0x003D +#define SRSLTE_CRNTI_END 0xFFF3 +#define SRSLTE_RARNTI_START 0x0001 +#define SRSLTE_RARNTI_END 0x003C +#define SRSLTE_SIRNTI 0xFFFF +#define SRSLTE_PRNTI 0xFFFE +#define SRSLTE_MRNTI 0xFFFD -#define CELL_ID_UNKNOWN 1000 +#define SRSLTE_CELL_ID_UNKNOWN 1000 -#define MAX_NSYMB 7 +#define SRSLTE_MAX_NSYMB 7 -#define MAX_PRB 110 -#define RE_X_RB 12 +#define SRSLTE_MAX_PRB 110 +#define SRSLTE_NRE 12 -#define SYMBOL_SZ_MAX 2048 +#define SRSLTE_SYMBOL_SZ_MAX 2048 -#define SRSLTE_CPNORM_NSYMB 7 -#define CPNORM_SF_NSYMB (2*SRSLTE_CPNORM_NSYMB) -#define CPNORM_0_LEN 160 -#define CPNORM_LEN 144 +#define SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB 7 +#define SRSLTE_SRSLTE_CP_NORM_SF_NSYMB (2*SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB) +#define SRSLTE_SRSLTE_CP_NORM_0_LEN 160 +#define SRSLTE_SRSLTE_CP_NORM_LEN 144 -#define CPEXT_NSYMB 6 -#define CPEXT_SF_NSYMB (2*CPEXT_NSYMB) -#define CPEXT_LEN 512 -#define CPEXT_7_5_LEN 1024 +#define SRSLTE_SRSLTE_CP_EXT_NSYMB 6 +#define SRSLTE_SRSLTE_CP_EXT_SF_NSYMB (2*SRSLTE_SRSLTE_CP_EXT_NSYMB) +#define SRSLTE_SRSLTE_CP_EXT_LEN 512 +#define SRSLTE_SRSLTE_CP_EXT_7_5_LEN 1024 -#define CP_ISNORM(cp) (cp==CPNORM) -#define CP_ISEXT(cp) (cp==CPEXT) -#define CP_NSYMB(cp) (CP_ISNORM(cp)?SRSLTE_CPNORM_NSYMB:CPEXT_NSYMB) +#define SRSLTE_CP_ISNORM(cp) (cp==SRSLTE_SRSLTE_CP_NORM) +#define SRSLTE_CP_ISEXT(cp) (cp==SRSLTE_SRSLTE_CP_EXT) +#define SRSLTE_CP_NSYMB(cp) (SRSLTE_CP_ISNORM(cp)?SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB:SRSLTE_SRSLTE_CP_EXT_NSYMB) -#define CP(symbol_sz, c) ((int) ceil((((float) (c)*(symbol_sz))/2048))) -#define CP_NORM(symbol, symbol_sz) ((symbol==0)?CP((symbol_sz),CPNORM_0_LEN):CP((symbol_sz),CPNORM_LEN)) -#define CP_EXT(symbol_sz) (CP((symbol_sz),CPEXT_LEN)) +#define SRSLTE_CP(symbol_sz, c) ((int) ceil((((float) (c)*(symbol_sz))/2048))) +#define SRSLTE_CP_NORM(symbol, symbol_sz) ((symbol==0)?SRSLTE_CP((symbol_sz),SRSLTE_SRSLTE_CP_NORM_0_LEN):SRSLTE_CP((symbol_sz),SRSLTE_SRSLTE_CP_NORM_LEN)) +#define SRSLTE_CP_EXT(symbol_sz) (SRSLTE_CP((symbol_sz),SRSLTE_SRSLTE_CP_EXT_LEN)) -#define SLOT_LEN(symbol_sz) (480*((symbol_sz)/64)) -#define SF_LEN(symbol_sz) (2*SLOT_LEN(symbol_sz)) -#define SF_LEN_MAX (SF_LEN(SYMBOL_SZ_MAX)) +#define SRSLTE_SLOT_LEN(symbol_sz) (480*((symbol_sz)/64)) +#define SRSLTE_SF_LEN(symbol_sz) (2*SRSLTE_SLOT_LEN(symbol_sz)) +#define SRSLTE_SF_LEN_MAX (SRSLTE_SF_LEN(SRSLTE_SYMBOL_SZ_MAX)) -#define SLOT_LEN_PRB(nof_prb) (SLOT_LEN(lte_symbol_sz(nof_prb))) -#define SF_LEN_PRB(nof_prb) (SF_LEN(lte_symbol_sz(nof_prb))) +#define SRSLTE_SLOT_LEN_PRB(nof_prb) (SRSLTE_SLOT_LEN(srslte_symbol_sz(nof_prb))) +#define SRSLTE_SF_LEN_PRB(nof_prb) (SRSLTE_SF_LEN(srslte_symbol_sz(nof_prb))) -#define SLOT_LEN_RE(nof_prb, cp) (nof_prb*RE_X_RB*CP_NSYMB(cp)) -#define SF_LEN_RE(nof_prb, cp) (2*SLOT_LEN_RE(nof_prb, cp)) +#define SRSLTE_SLOT_LEN_RE(nof_prb, cp) (nof_prb*SRSLTE_NRE*SRSLTE_CP_NSYMB(cp)) +#define SRSLTE_SF_LEN_RE(nof_prb, cp) (2*SRSLTE_SLOT_LEN_RE(nof_prb, cp)) -#define TA_OFFSET (10e-6) +#define SRSLTE_TA_OFFSET (10e-6) -#define LTE_TS 1.0/(15000.0*2048) +#define SRSLTE_LTE_TS 1.0/(15000.0*2048) -#define SLOT_IDX_CPNORM(symbol_idx, symbol_sz) (symbol_idx==0?0:(symbol_sz + CP(symbol_sz, CPNORM_0_LEN) + \ - (symbol_idx-1)*(symbol_sz+CP(symbol_sz, CPNORM_LEN)))) -#define SLOT_IDX_CPEXT(idx, symbol_sz) (idx*(symbol_sz+CP(symbol_sz, CPEXT_LEN))) +#define SRSLTE_SLOT_IDX_CPNORM(symbol_idx, symbol_sz) (symbol_idx==0?0:(symbol_sz + SRSLTE_CP(symbol_sz, SRSLTE_SRSLTE_CP_NORM_0_LEN) + \ + (symbol_idx-1)*(symbol_sz+SRSLTE_CP(symbol_sz, SRSLTE_SRSLTE_CP_NORM_LEN)))) +#define SRSLTE_SLOT_IDX_CPEXT(idx, symbol_sz) (idx*(symbol_sz+SRSLTE_CP(symbol_sz, SRSLTE_SRSLTE_CP_EXT_LEN))) -#define RE_IDX(nof_prb, symbol_idx, sample_idx) ((symbol_idx)*(nof_prb)*(RE_X_RB) + sample_idx) +#define SRSLTE_RE_IDX(nof_prb, symbol_idx, sample_idx) ((symbol_idx)*(nof_prb)*(SRSLTE_NRE) + sample_idx) -#define RS_VSHIFT(cell_id) (cell_id%6) +#define SRSLTE_RS_VSHIFT(cell_id) (cell_id%6) -#define GUARD_RE(nof_prb) ((lte_symbol_sz(nof_prb)-nof_prb*RE_X_RB)/2) +#define SRSLTE_GUARD_RE(nof_prb) ((srslte_symbol_sz(nof_prb)-nof_prb*SRSLTE_NRE)/2) -#define SYMBOL_HAS_REF(l, cp, nof_ports) ((l == 1 && nof_ports == 4) \ +#define SRSLTE_SYMBOL_HAS_REF(l, cp, nof_ports) ((l == 1 && nof_ports == 4) \ || l == 0 \ - || l == CP_NSYMB(cp) - 3) + || l == SRSLTE_CP_NSYMB(cp) - 3) -#define NOF_LTE_BANDS 29 +#define SRSLTE_NOF_LTE_BANDS 29 -#define NOF_TC_CB_SIZES 188 +#define SRSLTE_NOF_TC_CB_SIZES 188 typedef _Complex float cf_t; -typedef enum SRSLTE_API { PHICH_NORM = 0, PHICH_EXT} phich_length_t; -typedef enum SRSLTE_API { R_1_6 = 0, R_1_2, R_1, R_2} phich_resources_t; +typedef enum SRSLTE_API { + SRSLTE_PHICH_NORM = 0, + SRSLTE_PHICH_EXT +} srslte_phich_length_t; + +typedef enum SRSLTE_API { + SRSLTE_PHICH_SRSLTE_PHICH_R_1_6 = 0, + SRSLTE_PHICH_SRSLTE_PHICH_R_1_2, + SRSLTE_PHICH_R_1, + SRSLTE_PHICH_R_2 + +} srslte_phich_resources_t; typedef struct SRSLTE_API { uint32_t nof_prb; @@ -132,97 +142,95 @@ typedef struct SRSLTE_API { uint32_t bw_idx; uint32_t id; srslte_cp_t cp; - phich_length_t phich_length; - phich_resources_t phich_resources; + srslte_phich_length_t phich_length; + srslte_phich_resources_t phich_resources; }srslte_cell_t; typedef enum SRSLTE_API { SINGLE_ANTENNA,TX_DIVERSITY, SPATIAL_MULTIPLEX -} lte_mimo_type_t; +} srslte_mimo_type_t; typedef enum SRSLTE_API { LTE_BPSK = 0, LTE_QPSK = 1, LTE_QAM16 = 2, LTE_QAM64 = 3 -} lte_mod_t; +} srslte_mod_t; typedef struct SRSLTE_API { int id; float fd; -} lte_earfcn_t; +} srslte_earfcn_t; enum band_geographical_area { ALL, NAR, APAC, EMEA, JAPAN, CALA, NA }; -SRSLTE_API bool lte_cell_isvalid(srslte_cell_t *cell); - -SRSLTE_API void lte_cell_fprint(FILE *stream, - srslte_cell_t *cell); +SRSLTE_API bool srslte_cell_isvalid(srslte_cell_t *cell); -SRSLTE_API bool lte_cellid_isvalid(uint32_t cell_id); +SRSLTE_API void srslte_cell_fprint(FILE *stream, + srslte_cell_t *cell); -SRSLTE_API bool lte_nofprb_isvalid(uint32_t nof_prb); +SRSLTE_API bool srslte_cellid_isvalid(uint32_t cell_id); -SRSLTE_API bool lte_sfidx_isvalid(uint32_t sf_idx); +SRSLTE_API bool srslte_nofprb_isvalid(uint32_t nof_prb); -SRSLTE_API bool lte_portid_isvalid(uint32_t port_id); +SRSLTE_API bool srslte_sfidx_isvalid(uint32_t sf_idx); -SRSLTE_API bool lte_N_id_2_isvalid(uint32_t N_id_2); +SRSLTE_API bool srslte_portid_isvalid(uint32_t port_id); -SRSLTE_API bool lte_N_id_1_isvalid(uint32_t N_id_1); +SRSLTE_API bool srslte_N_id_2_isvalid(uint32_t N_id_2); -SRSLTE_API bool lte_symbol_sz_isvalid(uint32_t symbol_sz); +SRSLTE_API bool srslte_N_id_1_isvalid(uint32_t N_id_1); -SRSLTE_API int lte_symbol_sz(uint32_t nof_prb); +SRSLTE_API bool srssrslte_symbol_sz_isvalid(uint32_t symbol_sz); +SRSLTE_API int srslte_symbol_sz(uint32_t nof_prb); -SRSLTE_API int lte_sampling_freq_hz(uint32_t nof_prb); -SRSLTE_API uint32_t lte_re_x_prb(uint32_t ns, - uint32_t symbol, - uint32_t nof_ports, - uint32_t nof_symbols); +SRSLTE_API int srslte_sampling_freq_hz(uint32_t nof_prb); -SRSLTE_API uint32_t lte_voffset(uint32_t symbol_id, - uint32_t cell_id, - uint32_t nof_ports); +SRSLTE_API uint32_t srslte_re_x_prb(uint32_t ns, + uint32_t symbol, + uint32_t nof_ports, + uint32_t nof_symbols); -SRSLTE_API uint32_t lte_N_ta_new_rar(uint32_t ta); +SRSLTE_API uint32_t srslte_voffset(uint32_t symbol_id, + uint32_t cell_id, + uint32_t nof_ports); -SRSLTE_API uint32_t lte_N_ta_new(uint32_t N_ta_old, - uint32_t ta); +SRSLTE_API uint32_t srssrslte_N_ta_new_rar(uint32_t ta); -SRSLTE_API int lte_cb_size(uint32_t index); +SRSLTE_API uint32_t srslte_N_ta_new(uint32_t N_ta_old, + uint32_t ta); -SRSLTE_API bool lte_cb_size_isvalid(uint32_t size); +SRSLTE_API int srslte_cb_size(uint32_t index); -SRSLTE_API char *lte_cp_string(srslte_cp_t cp); +SRSLTE_API bool srslte_cb_size_isvalid(uint32_t size); -SRSLTE_API char *lte_mod_string(lte_mod_t mod); +SRSLTE_API char *srslte_cp_string(srslte_cp_t cp); -SRSLTE_API uint32_t lte_mod_bits_x_symbol(lte_mod_t mod); +SRSLTE_API char *srslte_mod_string(srslte_mod_t mod); -SRSLTE_API int lte_find_cb_index(uint32_t long_cb); +SRSLTE_API uint32_t srslte_mod_bits_x_symbol(srslte_mod_t mod); -SRSLTE_API float lte_band_fd(uint32_t earfcn); +SRSLTE_API int srslte_find_cb_index(uint32_t long_cb); -SRSLTE_API int lte_band_get_fd_band(uint32_t band, - lte_earfcn_t *earfcn, - int earfcn_start, - int earfcn_end, - uint32_t max_elems); +SRSLTE_API float srslte_band_fd(uint32_t earfcn); -SRSLTE_API int lte_band_get_fd_band_all(uint32_t band, - lte_earfcn_t *earfcn, - uint32_t max_nelems); +SRSLTE_API int srslte_band_get_fd_band(uint32_t band, + srslte_earfcn_t *earfcn, + int earfcn_start, + int earfcn_end, + uint32_t max_elems); -SRSLTE_API int lte_band_get_fd_region(enum band_geographical_area region, - lte_earfcn_t *earfcn, - uint32_t max_elems); +SRSLTE_API int srslte_band_get_fd_band_all(uint32_t band, + srslte_earfcn_t *earfcn, + uint32_t max_nelems); -SRSLTE_API int lte_str2mimotype(char *mimo_type_str, - lte_mimo_type_t *type); +SRSLTE_API int srslte_band_get_fd_region(enum band_geographical_area region, + srslte_earfcn_t *earfcn, + uint32_t max_elems); -SRSLTE_API char *lte_mimotype2str(lte_mimo_type_t type); +SRSLTE_API int srslte_str2mimotype(char *mimo_type_str, + srslte_mimo_type_t *type); diff --git a/srslte/include/srslte/filter/dft_precoding.h b/srslte/include/srslte/filter/dft_precoding.h index c0946702b..33a8882a4 100644 --- a/srslte/include/srslte/filter/dft_precoding.h +++ b/srslte/include/srslte/filter/dft_precoding.h @@ -39,8 +39,8 @@ typedef _Complex float cf_t; typedef struct SRSLTE_API { uint32_t max_prb; - srslte_dft_plan_t dft_plan[MAX_PRB]; - srslte_dft_plan_t idft_plan[MAX_PRB]; + srslte_dft_plan_t dft_plan[SRSLTE_MAX_PRB]; + srslte_dft_plan_t idft_plan[SRSLTE_MAX_PRB]; }dft_precoding_t; diff --git a/srslte/include/srslte/mimo/layermap.h b/srslte/include/srslte/mimo/layermap.h index a7efbf505..6143bf2ba 100644 --- a/srslte/include/srslte/mimo/layermap.h +++ b/srslte/include/srslte/mimo/layermap.h @@ -36,20 +36,20 @@ typedef _Complex float cf_t; /* Generates the vector of layer-mapped symbols "x" based on the vector of data symbols "d" */ SRSLTE_API int layermap_single(cf_t *d, cf_t *x, int nof_symbols); -SRSLTE_API int layermap_diversity(cf_t *d, cf_t *x[MAX_LAYERS], int nof_layers, int nof_symbols); -SRSLTE_API int layermap_multiplex(cf_t *d[MAX_CODEWORDS], cf_t *x[MAX_LAYERS], int nof_cw, int nof_layers, - int nof_symbols[MAX_CODEWORDS]); -SRSLTE_API int layermap_type(cf_t *d[MAX_CODEWORDS], cf_t *x[MAX_LAYERS], int nof_cw, int nof_layers, - int nof_symbols[MAX_CODEWORDS], lte_mimo_type_t type); +SRSLTE_API int layermap_diversity(cf_t *d, cf_t *x[SRSLTE_MAX_LAYERS], int nof_layers, int nof_symbols); +SRSLTE_API int layermap_multiplex(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_LAYERS], int nof_cw, int nof_layers, + int nof_symbols[SRSLTE_MAX_CODEWORDS]); +SRSLTE_API int layermap_type(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_LAYERS], int nof_cw, int nof_layers, + int nof_symbols[SRSLTE_MAX_CODEWORDS], srslte_mimo_type_t type); /* Generates the vector of data symbols "d" based on the vector of layer-mapped symbols "x" */ SRSLTE_API int layerdemap_single(cf_t *x, cf_t *d, int nof_symbols); -SRSLTE_API int layerdemap_diversity(cf_t *x[MAX_LAYERS], cf_t *d, int nof_layers, int nof_layer_symbols); -SRSLTE_API int layerdemap_multiplex(cf_t *x[MAX_LAYERS], cf_t *d[MAX_CODEWORDS], int nof_layers, int nof_cw, - int nof_layer_symbols, int nof_symbols[MAX_CODEWORDS]); -SRSLTE_API int layerdemap_type(cf_t *x[MAX_LAYERS], cf_t *d[MAX_CODEWORDS], int nof_layers, int nof_cw, - int nof_layer_symbols, int nof_symbols[MAX_CODEWORDS], lte_mimo_type_t type); +SRSLTE_API int layerdemap_diversity(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d, int nof_layers, int nof_layer_symbols); +SRSLTE_API int layerdemap_multiplex(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d[SRSLTE_MAX_CODEWORDS], int nof_layers, int nof_cw, + int nof_layer_symbols, int nof_symbols[SRSLTE_MAX_CODEWORDS]); +SRSLTE_API int layerdemap_type(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d[SRSLTE_MAX_CODEWORDS], int nof_layers, int nof_cw, + int nof_layer_symbols, int nof_symbols[SRSLTE_MAX_CODEWORDS], srslte_mimo_type_t type); #endif // LAYERMAP_H_ diff --git a/srslte/include/srslte/mimo/precoding.h b/srslte/include/srslte/mimo/precoding.h index 048a9fb9e..fb8482915 100644 --- a/srslte/include/srslte/mimo/precoding.h +++ b/srslte/include/srslte/mimo/precoding.h @@ -63,17 +63,17 @@ SRSLTE_API int precoding_single(precoding_t *q, int nof_symbols); SRSLTE_API int precoding_diversity(precoding_t *q, - cf_t *x[MAX_LAYERS], + cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_ports, int nof_symbols); SRSLTE_API int precoding_type(precoding_t *q, - cf_t *x[MAX_LAYERS], + cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_layers, int nof_ports, int nof_symbols, - lte_mimo_type_t type); + srslte_mimo_type_t type); /* Estimates the vector "x" based on the received signal "y" and the channel estimates "h" */ @@ -87,7 +87,7 @@ SRSLTE_API int predecoding_single(precoding_t *q, SRSLTE_API int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], - cf_t *x[MAX_LAYERS], + cf_t *x[SRSLTE_MAX_LAYERS], int nof_ports, int nof_symbols, float noise_estimate); @@ -95,11 +95,11 @@ SRSLTE_API int predecoding_diversity(precoding_t *q, SRSLTE_API int predecoding_type(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], - cf_t *x[MAX_LAYERS], + cf_t *x[SRSLTE_MAX_LAYERS], int nof_ports, int nof_layers, int nof_symbols, - lte_mimo_type_t type, + srslte_mimo_type_t type, float noise_estimate); #endif /* PRECODING_H_ */ diff --git a/srslte/include/srslte/modem/demod_hard.h b/srslte/include/srslte/modem/demod_hard.h index cfd0d6fac..c09295b12 100644 --- a/srslte/include/srslte/modem/demod_hard.h +++ b/srslte/include/srslte/modem/demod_hard.h @@ -38,12 +38,12 @@ typedef _Complex float cf_t; typedef struct SRSLTE_API { - lte_mod_t mod; /* In this implementation, mapping table is hard-coded */ + srslte_mod_t mod; /* In this implementation, mapping table is hard-coded */ }demod_hard_t; SRSLTE_API void demod_hard_init(demod_hard_t* q); -SRSLTE_API void demod_hard_table_set(demod_hard_t* q, lte_mod_t mod); +SRSLTE_API void demod_hard_table_set(demod_hard_t* q, srslte_mod_t mod); SRSLTE_API int demod_hard_demodulate(demod_hard_t* q, cf_t* symbols, uint8_t *bits, uint32_t nsymbols); @@ -52,7 +52,7 @@ SRSLTE_API int demod_hard_demodulate(demod_hard_t* q, cf_t* symbols, uint8_t *bi typedef struct SRSLTE_API { demod_hard_t obj; struct demod_hard_init { - lte_mod_t std; // Symbol mapping standard (see modem_table.h) + srslte_mod_t std; // Symbol mapping standard (see modem_table.h) } init; cf_t* input; diff --git a/srslte/include/srslte/modem/demod_soft.h b/srslte/include/srslte/modem/demod_soft.h index 39e2f7654..b5346feee 100644 --- a/srslte/include/srslte/modem/demod_soft.h +++ b/srslte/include/srslte/modem/demod_soft.h @@ -60,7 +60,7 @@ typedef struct SRSLTE_API { modem_table_t table; struct demod_soft_init{ - lte_mod_t std; // symbol mapping standard (see modem_table.h) + srslte_mod_t std; // symbol mapping standard (see modem_table.h) } init; const cf_t* input; diff --git a/srslte/include/srslte/modem/mod.h b/srslte/include/srslte/modem/mod.h index bbde3d1a5..18445dc5e 100644 --- a/srslte/include/srslte/modem/mod.h +++ b/srslte/include/srslte/modem/mod.h @@ -43,7 +43,7 @@ SRSLTE_API int mod_modulate(modem_table_t* table, const uint8_t *bits, cf_t* sym typedef struct SRSLTE_API { modem_table_t obj; struct mod_init { - lte_mod_t std; // symbol mapping standard (see modem_table.h) + srslte_mod_t std; // symbol mapping standard (see modem_table.h) } init; const uint8_t* input; diff --git a/srslte/include/srslte/modem/modem_table.h b/srslte/include/srslte/modem/modem_table.h index dc988c54e..82a1ff3d2 100644 --- a/srslte/include/srslte/modem/modem_table.h +++ b/srslte/include/srslte/modem/modem_table.h @@ -66,7 +66,7 @@ SRSLTE_API int modem_table_set(modem_table_t* q, uint32_t nbits_x_symbol); SRSLTE_API int modem_table_lte(modem_table_t* q, - lte_mod_t modulation, + srslte_mod_t modulation, bool compute_soft_demod); #endif // MODEM_TABLE_ diff --git a/srslte/include/srslte/phch/pbch.h b/srslte/include/srslte/phch/pbch.h index cca93f6e2..c40a9c299 100644 --- a/srslte/include/srslte/phch/pbch.h +++ b/srslte/include/srslte/phch/pbch.h @@ -45,8 +45,8 @@ #define BCH_PAYLOADCRC_LEN (BCH_PAYLOAD_LEN+16) #define BCH_ENCODED_LEN 3*(BCH_PAYLOADCRC_LEN) -#define PBCH_RE_CPNORM 240 -#define PBCH_RE_CPEXT 216 +#define PBCH_RE_SRSLTE_SRSLTE_CP_NORM 240 +#define PBCH_RE_SRSLTE_SRSLTE_CP_EXT 216 typedef _Complex float cf_t; diff --git a/srslte/include/srslte/phch/phich.h b/srslte/include/srslte/phch/phich.h index 90d9f14de..f22e95142 100644 --- a/srslte/include/srslte/phch/phich.h +++ b/srslte/include/srslte/phch/phich.h @@ -40,18 +40,18 @@ typedef _Complex float cf_t; -#define PHICH_NORM_NSEQUENCES 8 -#define PHICH_EXT_NSEQUENCES 4 -#define PHICH_MAX_SEQUENCES PHICH_NORM_NSEQUENCES +#define SRSLTE_PHICH_NORM_NSEQUENCES 8 +#define SRSLTE_PHICH_EXT_NSEQUENCES 4 +#define PHICH_MAX_SEQUENCES SRSLTE_PHICH_NORM_NSEQUENCES #define PHICH_NBITS 3 -#define PHICH_NORM_MSYMB PHICH_NBITS * 4 -#define PHICH_EXT_MSYMB PHICH_NBITS * 2 -#define PHICH_MAX_NSYMB PHICH_NORM_MSYMB -#define PHICH_NORM_C 1 -#define PHICH_EXT_C 2 -#define PHICH_NORM_NSF 4 -#define PHICH_EXT_NSF 2 +#define SRSLTE_PHICH_NORM_MSYMB PHICH_NBITS * 4 +#define SRSLTE_PHICH_EXT_MSYMB PHICH_NBITS * 2 +#define PHICH_SRSLTE_MAX_NSYMB SRSLTE_PHICH_NORM_MSYMB +#define SRSLTE_PHICH_NORM_C 1 +#define SRSLTE_PHICH_EXT_C 2 +#define SRSLTE_PHICH_NORM_NSF 4 +#define SRSLTE_PHICH_EXT_NSF 2 /* phich object */ typedef struct SRSLTE_API { @@ -61,11 +61,11 @@ typedef struct SRSLTE_API { regs_t *regs; /* buffers */ - cf_t ce[SRSLTE_MAX_PORTS][PHICH_MAX_NSYMB]; - cf_t phich_symbols[SRSLTE_MAX_PORTS][PHICH_MAX_NSYMB]; - cf_t phich_x[SRSLTE_MAX_PORTS][PHICH_MAX_NSYMB]; - cf_t phich_d[PHICH_MAX_NSYMB]; - cf_t phich_d0[PHICH_MAX_NSYMB]; + cf_t ce[SRSLTE_MAX_PORTS][PHICH_SRSLTE_MAX_NSYMB]; + cf_t phich_symbols[SRSLTE_MAX_PORTS][PHICH_SRSLTE_MAX_NSYMB]; + cf_t phich_x[SRSLTE_MAX_PORTS][PHICH_SRSLTE_MAX_NSYMB]; + cf_t phich_d[PHICH_SRSLTE_MAX_NSYMB]; + cf_t phich_d0[PHICH_SRSLTE_MAX_NSYMB]; cf_t phich_z[PHICH_NBITS]; /* bit message */ diff --git a/srslte/include/srslte/phch/pucch.h b/srslte/include/srslte/phch/pucch.h index f8490c02a..b2ef837e6 100644 --- a/srslte/include/srslte/phch/pucch.h +++ b/srslte/include/srslte/phch/pucch.h @@ -71,7 +71,7 @@ typedef struct SRSLTE_API { srslte_cell_t cell; pucch_cfg_t pucch_cfg; - uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NSYMB]; + uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]; float tmp_arg[PUCCH_N_SF_MAX*PUCCH_N_SEQ]; float y[PUCCH_N_SEQ]; }pucch_t; @@ -93,7 +93,7 @@ SRSLTE_API int pucch_encode(pucch_t *q, uint8_t bits[PUCCH_MAX_BITS], cf_t *sf_symbols); -SRSLTE_API float pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NSYMB], +SRSLTE_API float pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB], pucch_cfg_t *cfg, srslte_cp_t cp, bool is_drms, @@ -102,7 +102,7 @@ SRSLTE_API float pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLT uint32_t *n_oc); SRSLTE_API int generate_n_cs_cell(srslte_cell_t cell, - uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NSYMB]); + uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]); SRSLTE_API bool pucch_cfg_isvalid(pucch_cfg_t *cfg); diff --git a/srslte/include/srslte/phch/ra.h b/srslte/include/srslte/phch/ra.h index 99c508373..8f2639a09 100644 --- a/srslte/include/srslte/phch/ra.h +++ b/srslte/include/srslte/phch/ra.h @@ -38,7 +38,7 @@ */ typedef struct SRSLTE_API { - lte_mod_t mod; + srslte_mod_t mod; int tbs; } ra_mcs_t; @@ -72,7 +72,7 @@ typedef struct SRSLTE_API { } ra_type2_t; typedef struct SRSLTE_API { - bool prb_idx[MAX_PRB]; + bool prb_idx[SRSLTE_MAX_PRB]; uint32_t nof_prb; } ra_prb_slot_t; diff --git a/srslte/include/srslte/phch/regs.h b/srslte/include/srslte/phch/regs.h index 47aedb3b9..60e0ffdc4 100644 --- a/srslte/include/srslte/phch/regs.h +++ b/srslte/include/srslte/phch/regs.h @@ -63,8 +63,8 @@ typedef struct SRSLTE_API { bool cfi_initiated; uint32_t ngroups_phich; - phich_resources_t phich_res; - phich_length_t phich_len; + srslte_phich_resources_t phich_res; + srslte_phich_length_t phich_len; regs_ch_t pcfich; regs_ch_t *phich; // there are several phich diff --git a/srslte/lib/ch_estimation/src/chest_dl.c b/srslte/lib/ch_estimation/src/chest_dl.c index 07e5b89a6..91d3e8934 100644 --- a/srslte/lib/ch_estimation/src/chest_dl.c +++ b/srslte/lib/ch_estimation/src/chest_dl.c @@ -59,7 +59,7 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && - lte_cell_isvalid(&cell)) + srslte_cell_isvalid(&cell)) { bzero(q, sizeof(srslte_chest_dl_t)); @@ -112,12 +112,12 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell) } } - if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, RE_X_RB*cell.nof_prb)) { + if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, SRSLTE_NRE*cell.nof_prb)) { fprintf(stderr, "Error initializing vector interpolator\n"); goto clean_exit; } - if (srslte_interp_linear_init(&q->srslte_interp_lin, 2*cell.nof_prb, RE_X_RB/2)) { + if (srslte_interp_linear_init(&q->srslte_interp_lin, 2*cell.nof_prb, SRSLTE_NRE/2)) { fprintf(stderr, "Error initializing interpolator\n"); goto clean_exit; } @@ -220,11 +220,11 @@ static float estimate_noise_port(srslte_chest_dl_t *q, uint32_t port_id, cf_t *a /* Uses the 5 empty transmitted SC before and after the SSS and PSS sequences for noise estimation */ static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) { - int k_sss = (CP_NSYMB(q->cell.cp) - 2) * q->cell.nof_prb * RE_X_RB + q->cell.nof_prb * RE_X_RB / 2 - 31; + int k_sss = (SRSLTE_CP_NSYMB(q->cell.cp) - 2) * q->cell.nof_prb * SRSLTE_NRE + q->cell.nof_prb * SRSLTE_NRE / 2 - 31; float noise_power = 0; noise_power += vec_avg_power_cf(&input[k_sss-5], 5); // 5 empty SC before SSS noise_power += vec_avg_power_cf(&input[k_sss+62], 5); // 5 empty SC after SSS - int k_pss = (CP_NSYMB(q->cell.cp) - 1) * q->cell.nof_prb * RE_X_RB + q->cell.nof_prb * RE_X_RB / 2 - 31; + int k_pss = (SRSLTE_CP_NSYMB(q->cell.cp) - 1) * q->cell.nof_prb * SRSLTE_NRE + q->cell.nof_prb * SRSLTE_NRE / 2 - 31; noise_power += vec_avg_power_cf(&input[k_pss-5], 5); // 5 empty SC before PSS noise_power += vec_avg_power_cf(&input[k_pss+62], 5); // 5 empty SC after PSS @@ -285,7 +285,7 @@ static void average_pilots(srslte_chest_dl_t *q, uint32_t port_id) } -#define cesymb(i) ce[RE_IDX(q->cell.nof_prb,i,0)] +#define cesymb(i) ce[SRSLTE_RE_IDX(q->cell.nof_prb,i,0)] static void interpolate_pilots(srslte_chest_dl_t *q, cf_t *ce, uint32_t port_id) { @@ -297,12 +297,12 @@ static void interpolate_pilots(srslte_chest_dl_t *q, cf_t *ce, uint32_t port_id) for (l=0;lcell, l, port_id, 0); srslte_interp_linear_offset(&q->srslte_interp_lin, &pilot_avg(0), - &ce[srslte_refsignal_cs_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * RE_X_RB], - fidx_offset, RE_X_RB/2-fidx_offset); + &ce[srslte_refsignal_cs_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], + fidx_offset, SRSLTE_NRE/2-fidx_offset); } /* Now interpolate in the time domain between symbols */ - if (CP_ISNORM(q->cell.cp)) { + if (SRSLTE_CP_ISNORM(q->cell.cp)) { if (nsymbols == 4) { srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(4), &cesymb(1), 3); srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(4), &cesymb(7), &cesymb(5), 2); @@ -333,8 +333,8 @@ float srslte_chest_dl_rssi(srslte_chest_dl_t *q, cf_t *input, uint32_t port_id) float rssi = 0; uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); for (l=0;lcell.cp, port_id) * q->cell.nof_prb * RE_X_RB]; - rssi += vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * RE_X_RB); + cf_t *tmp = &input[srslte_refsignal_cs_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE]; + rssi += vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * SRSLTE_NRE); } return rssi/nsymbols; } @@ -394,7 +394,7 @@ int srslte_chest_dl_estimate(srslte_chest_dl_t *q, cf_t *input, cf_t *ce[SRSLTE_ float srslte_chest_dl_get_noise_estimate(srslte_chest_dl_t *q) { float noise = vec_acc_ff(q->noise_estimate, q->cell.nof_ports)/q->cell.nof_ports; #ifdef NOISE_POWER_USE_ESTIMATES - return noise*sqrtf(lte_symbol_sz(q->cell.nof_prb)); + return noise*sqrtf(srslte_symbol_sz(q->cell.nof_prb)); #else return noise; #endif @@ -407,7 +407,7 @@ float srslte_chest_dl_get_snr(srslte_chest_dl_t *q) { } float srslte_chest_dl_get_rssi(srslte_chest_dl_t *q) { - return 4*q->rssi[0]/q->cell.nof_prb/RE_X_RB; + return 4*q->rssi[0]/q->cell.nof_prb/SRSLTE_NRE; } /* q->rssi[0] is the average power in all RE in all symbol containing references for port 0 . q->rssi[0]/q->cell.nof_prb is the average power per PRB diff --git a/srslte/lib/ch_estimation/src/refsignal_dl.c b/srslte/lib/ch_estimation/src/refsignal_dl.c index a46416a52..2eb277ef0 100644 --- a/srslte/lib/ch_estimation/src/refsignal_dl.c +++ b/srslte/lib/ch_estimation/src/refsignal_dl.c @@ -90,12 +90,12 @@ inline uint32_t srslte_refsignal_cs_fidx(srslte_cell_t cell, uint32_t l, uint32_ inline uint32_t srslte_refsignal_cs_nsymbol(uint32_t l, srslte_cp_t cp, uint32_t port_id) { if (port_id < 2) { if (l % 2) { - return (l/2+1)*CP_NSYMB(cp) - 3; + return (l/2+1)*SRSLTE_CP_NSYMB(cp) - 3; } else { - return (l/2)*CP_NSYMB(cp); + return (l/2)*SRSLTE_CP_NSYMB(cp); } } else { - return 1+l*CP_NSYMB(cp); + return 1+l*SRSLTE_CP_NSYMB(cp); } } @@ -113,17 +113,17 @@ int srslte_refsignal_cs_init(srslte_refsignal_cs_t * q, srslte_cell_t cell) int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && - lte_cell_isvalid(&cell)) + srslte_cell_isvalid(&cell)) { ret = SRSLTE_ERROR; bzero(q, sizeof(srslte_refsignal_cs_t)); bzero(&seq, sizeof(sequence_t)); - if (sequence_init(&seq, 2 * 2 * MAX_PRB)) { + if (sequence_init(&seq, 2 * 2 * SRSLTE_MAX_PRB)) { goto free_and_exit; } - if (CP_ISNORM(cell.cp)) { + if (SRSLTE_CP_ISNORM(cell.cp)) { N_cp = 1; } else { N_cp = 0; @@ -155,7 +155,7 @@ int srslte_refsignal_cs_init(srslte_refsignal_cs_t * q, srslte_cell_t cell) /* Compute signal */ for (i = 0; i < 2*q->cell.nof_prb; i++) { - mp = i + MAX_PRB - cell.nof_prb; + mp = i + SRSLTE_MAX_PRB - cell.nof_prb; /* save signal */ q->pilots[p][ns/2][SRSLTE_REFSIGNAL_PILOT_IDX(i,(ns%2)*nsymbols+l,q->cell)] = (1 - 2 * (float) seq.c[2 * mp]) / sqrt(2) + @@ -198,8 +198,8 @@ int srslte_refsignal_cs_put_sf(srslte_cell_t cell, uint32_t port_id, cf_t *pilot uint32_t i, l; uint32_t fidx; - if (lte_cell_isvalid(&cell) && - lte_portid_isvalid(port_id) && + if (srslte_cell_isvalid(&cell) && + srslte_portid_isvalid(port_id) && pilots != NULL && sf_symbols != NULL) { @@ -209,8 +209,8 @@ int srslte_refsignal_cs_put_sf(srslte_cell_t cell, uint32_t port_id, cf_t *pilot /* Compute offset frequency index */ fidx = ((srslte_refsignal_cs_v(port_id, l) + (cell.id % 6)) % 6); for (i = 0; i < 2*cell.nof_prb; i++) { - sf_symbols[RE_IDX(cell.nof_prb, nsymbol, fidx)] = pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i,l,cell)]; - fidx += RE_X_RB/2; // 1 reference every 6 RE + sf_symbols[SRSLTE_RE_IDX(cell.nof_prb, nsymbol, fidx)] = pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i,l,cell)]; + fidx += SRSLTE_NRE/2; // 1 reference every 6 RE } } return SRSLTE_SUCCESS; @@ -228,8 +228,8 @@ int srslte_refsignal_cs_get_sf(srslte_cell_t cell, uint32_t port_id, cf_t *sf_sy uint32_t i, l; uint32_t fidx; - if (lte_cell_isvalid(&cell) && - lte_portid_isvalid(port_id) && + if (srslte_cell_isvalid(&cell) && + srslte_portid_isvalid(port_id) && pilots != NULL && sf_symbols != NULL) { @@ -238,8 +238,8 @@ int srslte_refsignal_cs_get_sf(srslte_cell_t cell, uint32_t port_id, cf_t *sf_sy /* Compute offset frequency index */ fidx = ((srslte_refsignal_cs_v(port_id, l) + (cell.id % 6)) % 6); for (i = 0; i < 2*cell.nof_prb; i++) { - pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i,l,cell)] = sf_symbols[RE_IDX(cell.nof_prb, nsymbol, fidx)]; - fidx += RE_X_RB/2; // 2 references per PRB + pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i,l,cell)] = sf_symbols[SRSLTE_RE_IDX(cell.nof_prb, nsymbol, fidx)]; + fidx += SRSLTE_NRE/2; // 2 references per PRB } } return SRSLTE_SUCCESS; diff --git a/srslte/lib/ch_estimation/src/refsignal_ul.c b/srslte/lib/ch_estimation/src/refsignal_ul.c index f28058e8c..dd8a728b1 100644 --- a/srslte/lib/ch_estimation/src/refsignal_ul.c +++ b/srslte/lib/ch_estimation/src/refsignal_ul.c @@ -73,13 +73,13 @@ static int generate_n_prs(srslte_refsignal_ul_t * q) { for (uint32_t delta_ss=0;delta_sscell.id / 30) << 5) + (((q->cell.id % 30) + delta_ss) % 30); - if (sequence_LTE_pr(&seq, 8 * CP_NSYMB(q->cell.cp) * 20, c_init)) { + if (sequence_LTE_pr(&seq, 8 * SRSLTE_CP_NSYMB(q->cell.cp) * 20, c_init)) { return SRSLTE_ERROR; } for (uint32_t ns=0;nscell.cp) * ns + i] << i); + n_prs += (seq.c[8 * SRSLTE_CP_NSYMB(q->cell.cp) * ns + i] << i); } q->n_prs_pusch[delta_ss][ns] = n_prs; } @@ -135,13 +135,13 @@ int srslte_refsignal_ul_init(srslte_refsignal_ul_t * q, srslte_cell_t cell) int ret = SRSLTE_ERROR_INVALID_INPUTS; - if (q != NULL && lte_cell_isvalid(&cell)) { + if (q != NULL && srslte_cell_isvalid(&cell)) { bzero(q, sizeof(srslte_refsignal_ul_t)); q->cell = cell; // Allocate temporal buffer for computing signal argument - q->tmp_arg = vec_malloc(RE_X_RB * q->cell.nof_prb * sizeof(cf_t)); + q->tmp_arg = vec_malloc(SRSLTE_NRE * q->cell.nof_prb * sizeof(cf_t)); if (!q->tmp_arg) { perror("malloc"); goto free_and_exit; @@ -194,13 +194,13 @@ uint32_t largest_prime_lower_than(uint32_t x) { } static void arg_r_uv_1prb(float *arg, uint32_t u) { - for (int i = 0; i < RE_X_RB; i++) { + for (int i = 0; i < SRSLTE_NRE; i++) { arg[i] = phi_M_sc_12[u][i] * M_PI / 4; } } static void arg_r_uv_2prb(float *arg, uint32_t u) { - for (int i = 0; i < 2*RE_X_RB; i++) { + for (int i = 0; i < 2*SRSLTE_NRE; i++) { arg[i] = phi_M_sc_24[u][i] * M_PI / 4; } } @@ -238,7 +238,7 @@ static void compute_pusch_r_uv_arg(srslte_refsignal_ul_t *q, srslte_refsignal_dr } else if (nof_prb == 2) { arg_r_uv_2prb(q->tmp_arg, u); } else { - arg_r_uv_mprb(q->tmp_arg, RE_X_RB*nof_prb, u, v); + arg_r_uv_mprb(q->tmp_arg, SRSLTE_NRE*nof_prb, u, v); } } @@ -273,9 +273,9 @@ void srslte_refsignal_drms_pusch_put(srslte_refsignal_ul_t *q, srslte_refsignal_ { for (uint32_t ns_idx=0;ns_idx<2;ns_idx++) { DEBUG("Putting DRMS to n_prb: %d, L: %d, ns_idx: %d\n", n_prb[ns_idx], nof_prb, ns_idx); - uint32_t L = (ns_idx+1)*CP_NSYMB(q->cell.cp)-4; - memcpy(&sf_symbols[RE_IDX(q->cell.nof_prb, L, n_prb[ns_idx]*RE_X_RB)], - &r_pusch[ns_idx*RE_X_RB*nof_prb], nof_prb*RE_X_RB*sizeof(cf_t)); + uint32_t L = (ns_idx+1)*SRSLTE_CP_NSYMB(q->cell.cp)-4; + memcpy(&sf_symbols[SRSLTE_RE_IDX(q->cell.nof_prb, L, n_prb[ns_idx]*SRSLTE_NRE)], + &r_pusch[ns_idx*SRSLTE_NRE*nof_prb], nof_prb*SRSLTE_NRE*sizeof(cf_t)); } } @@ -308,15 +308,15 @@ int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t *q, srslte_refsignal_d float alpha = pusch_get_alpha(q, cfg, ns); if (verbose == VERBOSE_DEBUG) { - uint32_t N_sz = largest_prime_lower_than(nof_prb*RE_X_RB); + uint32_t N_sz = largest_prime_lower_than(nof_prb*SRSLTE_NRE); DEBUG("Generating PUSCH DRMS sequence with parameters:\n",0); DEBUG("\tbeta: %.1f, nof_prb: %d, u: %d, v: %d, alpha: %f, N_sc: %d, root q: %d, nprs: %d\n", cfg->beta_pusch, nof_prb, u, v, alpha, N_sz, get_q(u,v,N_sz),q->n_prs_pusch[cfg->delta_ss][ns]); } // Do complex exponential and adjust amplitude - for (int i=0;ibeta_pusch * cexpf(I*(q->tmp_arg[i] + alpha*i)); + for (int i=0;ibeta_pusch * cexpf(I*(q->tmp_arg[i] + alpha*i)); } } ret = 0; @@ -337,7 +337,7 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg, case PUCCH_FORMAT_1: case PUCCH_FORMAT_1A: case PUCCH_FORMAT_1B: - if (CP_ISNORM(q->cell.cp)) { + if (SRSLTE_CP_ISNORM(q->cell.cp)) { N_rs = 3; pucch_symbol=pucch_symbol_format1_cpnorm; } else { @@ -346,7 +346,7 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg, } break; case PUCCH_FORMAT_2: - if (CP_ISNORM(q->cell.cp)) { + if (SRSLTE_CP_ISNORM(q->cell.cp)) { N_rs = 2; pucch_symbol=pucch_symbol_format2_cpnorm; } else { @@ -375,14 +375,14 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg, case PUCCH_FORMAT_1: case PUCCH_FORMAT_1A: case PUCCH_FORMAT_1B: - if (CP_ISNORM(q->cell.cp)) { + if (SRSLTE_CP_ISNORM(q->cell.cp)) { w=w_arg_pucch_format1_cpnorm[n_oc]; } else { w=w_arg_pucch_format1_cpext[n_oc]; } break; case PUCCH_FORMAT_2: - if (CP_ISNORM(q->cell.cp)) { + if (SRSLTE_CP_ISNORM(q->cell.cp)) { w=w_arg_pucch_format2_cpnorm; } else { w=w_arg_pucch_format2_cpext; @@ -395,8 +395,8 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg, } if (w) { - for (uint32_t n=0;nbeta_pucch*cexpf(I*(w[m]+q->tmp_arg[n]+alpha*n)); + for (uint32_t n=0;nbeta_pucch*cexpf(I*(w[m]+q->tmp_arg[n]+alpha*n)); } } else { return SRSLTE_ERROR; diff --git a/srslte/lib/ch_estimation/test/chest_test_dl.c b/srslte/lib/ch_estimation/test/chest_test_dl.c index 6bb484291..6f158b6d9 100644 --- a/srslte/lib/ch_estimation/test/chest_test_dl.c +++ b/srslte/lib/ch_estimation/test/chest_test_dl.c @@ -37,7 +37,7 @@ srslte_cell_t cell = { 6, // nof_prb 1, // nof_ports 1000, // cell_id - CPNORM // cyclic prefix + SRSLTE_SRSLTE_CP_NORM // cyclic prefix }; char *output_matlab = NULL; @@ -62,7 +62,7 @@ void parse_args(int argc, char **argv) { cell.nof_prb = atoi(argv[optind]); break; case 'e': - cell.cp = CPEXT; + cell.cp = SRSLTE_SRSLTE_CP_EXT; break; case 'c': cell.id = atoi(argv[optind]); @@ -100,7 +100,7 @@ int main(int argc, char **argv) { } } - num_re = 2 * cell.nof_prb * RE_X_RB * CP_NSYMB(cell.cp); + num_re = 2 * cell.nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cell.cp); input = malloc(num_re * sizeof(cf_t)); if (!input) { @@ -154,11 +154,11 @@ int main(int argc, char **argv) { srslte_refsignal_cs_put_sf(cell, n_port, est.csr_signal.pilots[n_port/2][sf_idx], input); - for (i=0;i<2*CP_NSYMB(cell.cp);i++) { - for (j=0;j= 1) { - mexutils_write_cf(sf_symbols, &plhs[0], SF_LEN_RE(cell.nof_prb, cell.cp), 1); + mexutils_write_cf(sf_symbols, &plhs[0], SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp), 1); } srslte_refsignal_ul_free(&refs); diff --git a/srslte/lib/ch_estimation/test/refsignal_ul_test.c b/srslte/lib/ch_estimation/test/refsignal_ul_test.c index 4fa62341a..d6709a44d 100644 --- a/srslte/lib/ch_estimation/test/refsignal_ul_test.c +++ b/srslte/lib/ch_estimation/test/refsignal_ul_test.c @@ -37,7 +37,7 @@ srslte_cell_t cell = { 100, // nof_prb SRSLTE_MAX_PORTS, // nof_ports 1, // cell_id - CPNORM // cyclic prefix + SRSLTE_SRSLTE_CP_NORM // cyclic prefix }; void usage(char *prog) { @@ -59,7 +59,7 @@ void parse_args(int argc, char **argv) { cell.nof_prb = atoi(argv[optind]); break; case 'e': - cell.cp = CPEXT; + cell.cp = SRSLTE_SRSLTE_CP_EXT; break; case 'c': cell.id = atoi(argv[optind]); @@ -82,7 +82,7 @@ int main(int argc, char **argv) { parse_args(argc,argv); - signal = malloc(2 * RE_X_RB * cell.nof_prb * sizeof(cf_t)); + signal = malloc(2 * SRSLTE_NRE * cell.nof_prb * sizeof(cf_t)); if (!signal) { perror("malloc"); goto do_exit; diff --git a/srslte/lib/common/src/fft.c b/srslte/lib/common/src/fft.c index d2cffd293..507019447 100644 --- a/srslte/lib/common/src/fft.c +++ b/srslte/lib/common/src/fft.c @@ -38,7 +38,7 @@ #include "srslte/utils/vector.h" int srslte_fft_init_(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb, dft_dir_t dir) { - int symbol_sz = lte_symbol_sz(nof_prb); + int symbol_sz = srslte_symbol_sz(nof_prb); if (symbol_sz < 0) { fprintf(stderr, "Error: Invalid nof_prb=%d\n", nof_prb); @@ -58,16 +58,16 @@ int srslte_fft_init_(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb, dft_dir_ dft_plan_set_dc(&q->fft_plan, true); q->symbol_sz = (uint32_t) symbol_sz; - q->nof_symbols = CP_NSYMB(cp); + q->nof_symbols = SRSLTE_CP_NSYMB(cp); q->cp = cp; q->freq_shift = false; - q->nof_re = nof_prb * RE_X_RB; + q->nof_re = nof_prb * SRSLTE_NRE; q->nof_guards = ((symbol_sz - q->nof_re) / 2); - q->slot_sz = SLOT_LEN(symbol_sz); + q->slot_sz = SRSLTE_SLOT_LEN(symbol_sz); DEBUG("Init %s symbol_sz=%d, nof_symbols=%d, cp=%s, nof_re=%d, nof_guards=%d\n", dir==FORWARD?"FFT":"iFFT", q->symbol_sz, q->nof_symbols, - q->cp==CPNORM?"Normal":"Extended", q->nof_re, q->nof_guards); + q->cp==SRSLTE_SRSLTE_CP_NORM?"Normal":"Extended", q->nof_re, q->nof_guards); return SRSLTE_SUCCESS; } @@ -114,7 +114,7 @@ int lte_ifft_init(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb) { * Caution: This function shall not be called during run-time */ int srslte_fft_set_freq_shift(srslte_fft_t *q, float freq_shift) { - q->shift_buffer = vec_malloc(sizeof(cf_t) * SF_LEN(q->symbol_sz)); + q->shift_buffer = vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN(q->symbol_sz)); if (!q->shift_buffer) { perror("malloc"); return -1; @@ -122,7 +122,7 @@ int srslte_fft_set_freq_shift(srslte_fft_t *q, float freq_shift) { cf_t *ptr = q->shift_buffer; for (uint32_t n=0;n<2;n++) { for (uint32_t i=0;inof_symbols;i++) { - uint32_t cplen = CP_ISNORM(q->cp)?CP_NORM(i, q->symbol_sz):CP_EXT(q->symbol_sz); + uint32_t cplen = SRSLTE_CP_ISNORM(q->cp)?SRSLTE_CP_NORM(i, q->symbol_sz):SRSLTE_CP_EXT(q->symbol_sz); for (uint32_t t=0;tsymbol_sz+cplen;t++) { ptr[t] = cexpf(I*2*M_PI*((float) t-(float)cplen)*freq_shift/q->symbol_sz); } @@ -148,7 +148,7 @@ void lte_ifft_free(srslte_fft_t *q) { void srslte_fft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) { uint32_t i; for (i=0;inof_symbols;i++) { - input += CP_ISNORM(q->cp)?CP_NORM(i, q->symbol_sz):CP_EXT(q->symbol_sz); + input += SRSLTE_CP_ISNORM(q->cp)?SRSLTE_CP_NORM(i, q->symbol_sz):SRSLTE_CP_EXT(q->symbol_sz); dft_run_c(&q->fft_plan, input, q->tmp); memcpy(output, &q->tmp[q->nof_guards], q->nof_re * sizeof(cf_t)); input += q->symbol_sz; @@ -172,7 +172,7 @@ void srslte_fft_run_sf(srslte_fft_t *q, cf_t *input, cf_t *output) { void lte_ifft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) { uint32_t i, cp_len; for (i=0;inof_symbols;i++) { - cp_len = CP_ISNORM(q->cp)?CP_NORM(i, q->symbol_sz):CP_EXT(q->symbol_sz); + cp_len = SRSLTE_CP_ISNORM(q->cp)?SRSLTE_CP_NORM(i, q->symbol_sz):SRSLTE_CP_EXT(q->symbol_sz); memcpy(&q->tmp[q->nof_guards], input, q->nof_re * sizeof(cf_t)); dft_run_c(&q->fft_plan, q->tmp, &output[cp_len]); input += q->nof_re; diff --git a/srslte/lib/common/src/phy_common.c b/srslte/lib/common/src/phy_common.c index 1244e4cf3..3acac855d 100644 --- a/srslte/lib/common/src/phy_common.c +++ b/srslte/lib/common/src/phy_common.c @@ -34,7 +34,7 @@ #include "srslte/common/phy_common.h" -const uint32_t tc_cb_sizes[NOF_TC_CB_SIZES] = { 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, +const uint32_t tc_cb_sizes[SRSLTE_NOF_TC_CB_SIZES] = { 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328, 336, 344, 352, 360, 368, 376, 384, 392, 400, 408, 416, 424, 432, 440, 448, 456, @@ -53,7 +53,7 @@ const uint32_t tc_cb_sizes[NOF_TC_CB_SIZES] = { 40, 48, 56, 64, 72, 80, 88, 96, /* Returns true if the structure pointed by cell has valid parameters */ -bool lte_cellid_isvalid(uint32_t cell_id) { +bool srslte_cellid_isvalid(uint32_t cell_id) { if (cell_id < 504) { return true; } else { @@ -61,25 +61,25 @@ bool lte_cellid_isvalid(uint32_t cell_id) { } } -bool lte_nofprb_isvalid(uint32_t nof_prb) { - if (nof_prb >= 6 && nof_prb <= MAX_PRB) { +bool srslte_nofprb_isvalid(uint32_t nof_prb) { + if (nof_prb >= 6 && nof_prb <= SRSLTE_MAX_PRB) { return true; } else { return false; } } -bool lte_cell_isvalid(srslte_cell_t *cell) { - return lte_cellid_isvalid(cell->id) && - lte_portid_isvalid(cell->nof_ports) && - lte_nofprb_isvalid(cell->nof_prb); +bool srslte_cell_isvalid(srslte_cell_t *cell) { + return srslte_cellid_isvalid(cell->id) && + srslte_portid_isvalid(cell->nof_ports) && + srslte_nofprb_isvalid(cell->nof_prb); } -void lte_cell_fprint(FILE *stream, srslte_cell_t *cell) { - fprintf(stream, "PCI: %d, CP: %s, PRB: %d, Ports: %d\n", cell->id, lte_cp_string(cell->cp), cell->nof_prb, cell->nof_ports); +void srslte_cell_fprint(FILE *stream, srslte_cell_t *cell) { + fprintf(stream, "PCI: %d, CP: %s, PRB: %d, Ports: %d\n", cell->id, srslte_cp_string(cell->cp), cell->nof_prb, cell->nof_ports); } -bool lte_sfidx_isvalid(uint32_t sf_idx) { +bool srslte_sfidx_isvalid(uint32_t sf_idx) { if (sf_idx <= SRSLTE_NSUBFRAMES_X_FRAME) { return true; } else { @@ -87,7 +87,7 @@ bool lte_sfidx_isvalid(uint32_t sf_idx) { } } -bool lte_portid_isvalid(uint32_t port_id) { +bool srslte_portid_isvalid(uint32_t port_id) { if (port_id <= SRSLTE_MAX_PORTS) { return true; } else { @@ -95,7 +95,7 @@ bool lte_portid_isvalid(uint32_t port_id) { } } -bool lte_N_id_2_isvalid(uint32_t N_id_2) { +bool srslte_N_id_2_isvalid(uint32_t N_id_2) { if (N_id_2 < 3) { return true; } else { @@ -103,7 +103,7 @@ bool lte_N_id_2_isvalid(uint32_t N_id_2) { } } -bool lte_N_id_1_isvalid(uint32_t N_id_1) { +bool srslte_N_id_1_isvalid(uint32_t N_id_1) { if (N_id_1 < 169) { return true; } else { @@ -115,16 +115,16 @@ bool lte_N_id_1_isvalid(uint32_t N_id_1) { /* * Returns Turbo coder interleaver size for Table 5.1.3-3 (36.212) index */ -int lte_cb_size(uint32_t index) { - if (index < NOF_TC_CB_SIZES) { +int srslte_cb_size(uint32_t index) { + if (index < SRSLTE_NOF_TC_CB_SIZES) { return (int) tc_cb_sizes[index]; } else { return SRSLTE_ERROR; } } -bool lte_cb_size_isvalid(uint32_t size) { - for (int i=0;i 1282) { ta = 1282; } @@ -198,21 +198,21 @@ uint32_t lte_N_ta_new_rar(uint32_t ta) { /* * Finds index of minimum K>=long_cb in Table 5.1.3-3 of 36.212 */ -int lte_find_cb_index(uint32_t long_cb) { +int srslte_find_cb_index(uint32_t long_cb) { int j = 0; - while (j < NOF_TC_CB_SIZES && tc_cb_sizes[j] < long_cb) { + while (j < SRSLTE_NOF_TC_CB_SIZES && tc_cb_sizes[j] < long_cb) { j++; } - if (j == NOF_TC_CB_SIZES) { + if (j == SRSLTE_NOF_TC_CB_SIZES) { return SRSLTE_ERROR; } else { return j; } } -int lte_sampling_freq_hz(uint32_t nof_prb) { - int n = lte_symbol_sz(nof_prb); +int srslte_sampling_freq_hz(uint32_t nof_prb) { + int n = srslte_symbol_sz(nof_prb); if (n == -1) { return SRSLTE_ERROR; } else { @@ -220,7 +220,7 @@ int lte_sampling_freq_hz(uint32_t nof_prb) { } } -int lte_symbol_sz(uint32_t nof_prb) { +int srslte_symbol_sz(uint32_t nof_prb) { if (nof_prb<=0) { return SRSLTE_ERROR; } @@ -240,7 +240,7 @@ int lte_symbol_sz(uint32_t nof_prb) { return SRSLTE_ERROR; } -bool lte_symbol_sz_isvalid(uint32_t symbol_sz) { +bool srssrslte_symbol_sz_isvalid(uint32_t symbol_sz) { if (symbol_sz == 128 || symbol_sz == 256 || symbol_sz == 512 || @@ -252,7 +252,7 @@ bool lte_symbol_sz_isvalid(uint32_t symbol_sz) { } } -uint32_t lte_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports) { +uint32_t srslte_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports) { if (nof_ports == 1 && symbol_id==0) { return (cell_id+3) % 6; } else { @@ -261,33 +261,33 @@ uint32_t lte_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports) { } /* Returns the number of available RE per PRB */ -uint32_t lte_re_x_prb(uint32_t ns, uint32_t symbol, uint32_t nof_ports, uint32_t nof_symbols) { +uint32_t srslte_re_x_prb(uint32_t ns, uint32_t symbol, uint32_t nof_ports, uint32_t nof_symbols) { if (symbol == 0) { if (((ns % 2) == 0) || (ns == 1)) { - return RE_X_RB - 4; + return SRSLTE_NRE - 4; } else { if (nof_ports == 1) { - return RE_X_RB - 2; + return SRSLTE_NRE - 2; } else { - return RE_X_RB - 4; + return SRSLTE_NRE - 4; } } } else if (symbol == 1) { if (ns == 1) { - return RE_X_RB - 4; + return SRSLTE_NRE - 4; } else if (nof_ports == 4) { - return RE_X_RB - 4; + return SRSLTE_NRE - 4; } else { - return RE_X_RB; + return SRSLTE_NRE; } } else if (symbol == nof_symbols - 3) { if (nof_ports == 1) { - return RE_X_RB - 2; + return SRSLTE_NRE - 2; } else { - return RE_X_RB - 4; + return SRSLTE_NRE - 4; } } else { - return RE_X_RB; + return SRSLTE_NRE; } } @@ -300,7 +300,7 @@ struct lte_band { enum band_geographical_area area; }; -struct lte_band lte_bands[NOF_LTE_BANDS] = { +struct lte_band lte_bands[SRSLTE_NOF_LTE_BANDS] = { {1, 2110, 0, 599, ALL}, {2, 1930, 600, 1199, NAR}, {3, 1805, 1200, 1949, ALL}, @@ -333,7 +333,7 @@ struct lte_band lte_bands[NOF_LTE_BANDS] = { }; #define EOF_BAND 9919 -int lte_str2mimotype(char *mimo_type_str, lte_mimo_type_t *type) { +int srslte_str2mimotype(char *mimo_type_str, srslte_mimo_type_t *type) { if (!strcmp(mimo_type_str, "single")) { *type = SINGLE_ANTENNA; } else if (!strcmp(mimo_type_str, "diversity")) { @@ -346,18 +346,6 @@ int lte_str2mimotype(char *mimo_type_str, lte_mimo_type_t *type) { return SRSLTE_SUCCESS; } -char *lte_mimotype2str(lte_mimo_type_t type) { - switch(type) { - case SINGLE_ANTENNA: - return "single"; - case TX_DIVERSITY: - return "diversity"; - case SPATIAL_MULTIPLEX: - return "multiplex"; - } - return NULL; -} - float get_fd(struct lte_band *band, uint32_t earfcn) { if (earfcn >= band->earfcn_offset) { return band->fd_low_mhz + 0.1*(earfcn - band->earfcn_offset); @@ -366,31 +354,31 @@ float get_fd(struct lte_band *band, uint32_t earfcn) { } } -float lte_band_fd(uint32_t earfcn) { +float srslte_band_fd(uint32_t earfcn) { uint32_t i; i=0; - while(i < NOF_LTE_BANDS && lte_bands[i].earfcn_offset 0;i++) { + for (i=0;i 0;i++) { if (lte_bands[i].area == region) { - n = lte_band_get_fd_band(i, &earfcn[nof_fd], -1, -1, max_elems); + n = srslte_band_get_fd_band(i, &earfcn[nof_fd], -1, -1, max_elems); if (n != -1) { nof_fd += n; max_elems -= n; diff --git a/srslte/lib/common/test/fft_test.c b/srslte/lib/common/test/fft_test.c index 935ed711c..9f5ffd592 100644 --- a/srslte/lib/common/test/fft_test.c +++ b/srslte/lib/common/test/fft_test.c @@ -35,7 +35,7 @@ #include "srslte/srslte.h" int nof_prb = -1; -srslte_cp_t cp = CPNORM; +srslte_cp_t cp = SRSLTE_SRSLTE_CP_NORM; void usage(char *prog) { printf("Usage: %s\n", prog); @@ -51,7 +51,7 @@ void parse_args(int argc, char **argv) { nof_prb = atoi(argv[optind]); break; case 'e': - cp = CPEXT; + cp = SRSLTE_SRSLTE_CP_EXT; break; default: usage(argv[0]); @@ -78,7 +78,7 @@ int main(int argc, char **argv) { max_prb = nof_prb; } while(n_prb <= max_prb) { - n_re = CP_NSYMB(cp) * n_prb * RE_X_RB; + n_re = SRSLTE_CP_NSYMB(cp) * n_prb * SRSLTE_NRE; printf("Running test for %d PRB, %d RE... ", n_prb, n_re);fflush(stdout); @@ -87,7 +87,7 @@ int main(int argc, char **argv) { perror("malloc"); exit(-1); } - outfft = malloc(sizeof(cf_t) * SLOT_LEN(lte_symbol_sz(n_prb))); + outfft = malloc(sizeof(cf_t) * SRSLTE_SLOT_LEN(srslte_symbol_sz(n_prb))); if (!outfft) { perror("malloc"); exit(-1); diff --git a/srslte/lib/fec/src/tc_interl_lte.c b/srslte/lib/fec/src/tc_interl_lte.c index f47686798..2834fa00e 100644 --- a/srslte/lib/fec/src/tc_interl_lte.c +++ b/srslte/lib/fec/src/tc_interl_lte.c @@ -40,7 +40,7 @@ * ************************************************/ -const uint32_t f1_list[NOF_TC_CB_SIZES] = { 3, 7, 19, 7, 7, 11, 5, 11, 7, 41, 103, +const uint32_t f1_list[SRSLTE_NOF_TC_CB_SIZES] = { 3, 7, 19, 7, 7, 11, 5, 11, 7, 41, 103, 15, 9, 17, 9, 21, 101, 21, 57, 23, 13, 27, 11, 27, 85, 29, 33, 15, 17, 33, 103, 19, 19, 37, 19, 21, 21, 115, 193, 21, 133, 81, 45, 23, 243, 151, 155, 25, 51, 47, 91, 29, 29, 247, 29, 89, 91, 157, 55, 31, 17, 35, 227, 65, 19, @@ -53,7 +53,7 @@ const uint32_t f1_list[NOF_TC_CB_SIZES] = { 3, 7, 19, 7, 7, 11, 5, 11, 7, 41, 10 39, 127, 39, 39, 31, 113, 41, 251, 43, 21, 43, 45, 45, 161, 89, 323, 47, 23, 47, 263 }; -const uint32_t f2_list[NOF_TC_CB_SIZES] = { 10, 12, 42, 16, 18, 20, 22, 24, 26, 84, +const uint32_t f2_list[SRSLTE_NOF_TC_CB_SIZES] = { 10, 12, 42, 16, 18, 20, 22, 24, 26, 84, 90, 32, 34, 108, 38, 120, 84, 44, 46, 48, 50, 52, 36, 56, 58, 60, 62, 32, 198, 68, 210, 36, 74, 76, 78, 120, 82, 84, 86, 44, 90, 46, 94, 48, 98, 40, 102, 52, 106, 72, 110, 168, 114, 58, 118, 180, 122, 62, 84, 64, 66, 68, 420, @@ -76,7 +76,7 @@ int tc_interl_LTE_gen(tc_interl_t *h, uint32_t long_cb) { return -1; } - cb_table_idx = lte_find_cb_index(long_cb); + cb_table_idx = srslte_find_cb_index(long_cb); if (cb_table_idx == -1) { fprintf(stderr, "Can't find long_cb=%d in valid TC CB table\n", long_cb); return -1; diff --git a/srslte/lib/fec/test/crc_test.h b/srslte/lib/fec/test/crc_test.h index 5c64fca0a..25f714954 100644 --- a/srslte/lib/fec/test/crc_test.h +++ b/srslte/lib/fec/test/crc_test.h @@ -40,10 +40,10 @@ typedef struct { static expected_word_t expected_words[] = { - {5001, 24, LTE_CRC24A, 1, 0x1C5C97}, // LTE CRC24A (36.212 Sec 5.1.1) - {5001, 24, LTE_CRC24B, 1, 0x36D1F0}, // LTE CRC24B - {5001, 16, LTE_CRC16, 1, 0x7FF4}, // LTE CRC16: 0x7FF4 - {5001, 8, LTE_CRC8, 1, 0xF0}, // LTE CRC8 0xF8 + {5001, 24, SRSLTE_LTE_CRC24A, 1, 0x1C5C97}, // LTE CRC24A (36.212 Sec 5.1.1) + {5001, 24, SRSLTE_LTE_CRC24B, 1, 0x36D1F0}, // LTE CRC24B + {5001, 16, SRSLTE_LTE_CRC16, 1, 0x7FF4}, // LTE CRC16: 0x7FF4 + {5001, 8, SRSLTE_LTE_CRC8, 1, 0xF0}, // LTE CRC8 0xF8 {-1, -1, 0, 0, 0} }; diff --git a/srslte/lib/fec/test/turbodecoder_test.c b/srslte/lib/fec/test/turbodecoder_test.c index 133973337..1c594104f 100644 --- a/srslte/lib/fec/test/turbodecoder_test.c +++ b/srslte/lib/fec/test/turbodecoder_test.c @@ -152,7 +152,7 @@ int main(int argc, char **argv) { if (test_known_data) { frame_length = KNOWN_DATA_LEN; } else { - frame_length = lte_cb_size(lte_find_cb_index(frame_length)); + frame_length = srslte_cb_size(srslte_find_cb_index(frame_length)); } coded_length = 3 * (frame_length) + TOTALTAIL; diff --git a/srslte/lib/fec/test/turbodecoder_test_mex.c b/srslte/lib/fec/test/turbodecoder_test_mex.c index 76e914190..471cbb6fe 100644 --- a/srslte/lib/fec/test/turbodecoder_test_mex.c +++ b/srslte/lib/fec/test/turbodecoder_test_mex.c @@ -66,7 +66,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } nof_bits = (nof_symbols-12)/3; - if (!lte_cb_size_isvalid(nof_bits)) { + if (!srslte_cb_size_isvalid(nof_bits)) { mexErrMsgTxt("Invalid codeblock size\n"); return; } diff --git a/srslte/lib/filter/src/dft_precoding.c b/srslte/lib/filter/src/dft_precoding.c index 29373dc89..fbf731b9c 100644 --- a/srslte/lib/filter/src/dft_precoding.c +++ b/srslte/lib/filter/src/dft_precoding.c @@ -46,17 +46,17 @@ int dft_precoding_init(dft_precoding_t *q, uint32_t max_prb) int ret = SRSLTE_ERROR_INVALID_INPUTS; bzero(q, sizeof(dft_precoding_t)); - if (max_prb <= MAX_PRB) { + if (max_prb <= SRSLTE_MAX_PRB) { ret = SRSLTE_ERROR; for (uint32_t i=1;idft_plan[i], i*RE_X_RB, FORWARD)) { + if (dft_plan_c(&q->dft_plan[i], i*SRSLTE_NRE, FORWARD)) { fprintf(stderr, "Error: Creating DFT plan %d\n",i); goto clean_exit; } dft_plan_set_norm(&q->dft_plan[i], true); - if (dft_plan_c(&q->idft_plan[i], i*RE_X_RB, BACKWARD)) { + if (dft_plan_c(&q->idft_plan[i], i*SRSLTE_NRE, BACKWARD)) { fprintf(stderr, "Error: Creating DFT plan %d\n",i); goto clean_exit; } @@ -105,7 +105,7 @@ int dft_precoding(dft_precoding_t *q, cf_t *input, cf_t *output, } for (uint32_t i=0;idft_plan[nof_prb], &input[i*RE_X_RB*nof_prb], &output[i*RE_X_RB*nof_prb]); + dft_run_c(&q->dft_plan[nof_prb], &input[i*SRSLTE_NRE*nof_prb], &output[i*SRSLTE_NRE*nof_prb]); } return SRSLTE_SUCCESS; @@ -120,7 +120,7 @@ int dft_predecoding(dft_precoding_t *q, cf_t *input, cf_t *output, } for (uint32_t i=0;idft_plan[nof_prb], &input[i*RE_X_RB*nof_prb], &output[i*RE_X_RB*nof_prb]); + dft_run_c(&q->dft_plan[nof_prb], &input[i*SRSLTE_NRE*nof_prb], &output[i*SRSLTE_NRE*nof_prb]); } return SRSLTE_SUCCESS; diff --git a/srslte/lib/mimo/src/layermap.c b/srslte/lib/mimo/src/layermap.c index 299ae86ac..2e5b36319 100644 --- a/srslte/lib/mimo/src/layermap.c +++ b/srslte/lib/mimo/src/layermap.c @@ -40,7 +40,7 @@ int layermap_single(cf_t *d, cf_t *x, int nof_symbols) { return nof_symbols; } -int layermap_diversity(cf_t *d, cf_t *x[MAX_LAYERS], int nof_layers, int nof_symbols) { +int layermap_diversity(cf_t *d, cf_t *x[SRSLTE_MAX_LAYERS], int nof_layers, int nof_symbols) { int i, j; for (i=0;i MAX_CODEWORDS) { - fprintf(stderr, "Maximum number of codewords is %d (nof_cw=%d)\n", MAX_CODEWORDS, nof_cw); + if (nof_cw > SRSLTE_MAX_CODEWORDS) { + fprintf(stderr, "Maximum number of codewords is %d (nof_cw=%d)\n", SRSLTE_MAX_CODEWORDS, nof_cw); return -1; } - if (nof_layers > MAX_LAYERS) { - fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", MAX_LAYERS, nof_layers); + if (nof_layers > SRSLTE_MAX_LAYERS) { + fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", SRSLTE_MAX_LAYERS, nof_layers); return -1; } if (nof_layers < nof_cw) { @@ -134,7 +134,7 @@ int layerdemap_single(cf_t *x, cf_t *d, int nof_symbols) { memcpy(d, x, sizeof(cf_t) * nof_symbols); return nof_symbols; } -int layerdemap_diversity(cf_t *x[MAX_LAYERS], cf_t *d, int nof_layers, int nof_layer_symbols) { +int layerdemap_diversity(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d, int nof_layers, int nof_layer_symbols) { int i, j; for (i=0;i MAX_CODEWORDS) { - fprintf(stderr, "Maximum number of codewords is %d (nof_cw=%d)\n", MAX_CODEWORDS, nof_cw); + if (nof_cw > SRSLTE_MAX_CODEWORDS) { + fprintf(stderr, "Maximum number of codewords is %d (nof_cw=%d)\n", SRSLTE_MAX_CODEWORDS, nof_cw); return -1; } - if (nof_layers > MAX_LAYERS) { - fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", MAX_LAYERS, nof_layers); + if (nof_layers > SRSLTE_MAX_LAYERS) { + fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", SRSLTE_MAX_LAYERS, nof_layers); return -1; } if (nof_layers < nof_cw) { diff --git a/srslte/lib/mimo/src/precoding.c b/srslte/lib/mimo/src/precoding.c index 2005bff44..85fabcbe6 100644 --- a/srslte/lib/mimo/src/precoding.c +++ b/srslte/lib/mimo/src/precoding.c @@ -138,7 +138,7 @@ int predecoding_single(precoding_t *q, cf_t *y, cf_t *h, cf_t *x, int nof_symbol /* ZF/MMSE STBC equalizer x=y(H'H+n0·I)^(-1)H' (ZF is n0=0.0) */ -int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x[MAX_LAYERS], +int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x[SRSLTE_MAX_LAYERS], int nof_ports, int nof_symbols, float noise_estimate) { int i; @@ -240,17 +240,17 @@ int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf } /* 36.211 v10.3.0 Section 6.3.4 */ -int predecoding_type(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x[MAX_LAYERS], - int nof_ports, int nof_layers, int nof_symbols, lte_mimo_type_t type, float noise_estimate) { +int predecoding_type(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x[SRSLTE_MAX_LAYERS], + int nof_ports, int nof_layers, int nof_symbols, srslte_mimo_type_t type, float noise_estimate) { if (nof_ports > SRSLTE_MAX_PORTS) { fprintf(stderr, "Maximum number of ports is %d (nof_ports=%d)\n", SRSLTE_MAX_PORTS, nof_ports); return -1; } - if (nof_layers > MAX_LAYERS) { + if (nof_layers > SRSLTE_MAX_LAYERS) { fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", - MAX_LAYERS, nof_layers); + SRSLTE_MAX_LAYERS, nof_layers); return -1; } @@ -295,7 +295,7 @@ int precoding_single(precoding_t *q, cf_t *x, cf_t *y, int nof_symbols) { memcpy(y, x, nof_symbols * sizeof(cf_t)); return nof_symbols; } -int precoding_diversity(precoding_t *q, cf_t *x[MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_ports, +int precoding_diversity(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_ports, int nof_symbols) { int i; if (nof_ports == 2) { @@ -341,17 +341,17 @@ int precoding_diversity(precoding_t *q, cf_t *x[MAX_LAYERS], cf_t *y[SRSLTE_MAX_ } /* 36.211 v10.3.0 Section 6.3.4 */ -int precoding_type(precoding_t *q, cf_t *x[MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_layers, - int nof_ports, int nof_symbols, lte_mimo_type_t type) { +int precoding_type(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_layers, + int nof_ports, int nof_symbols, srslte_mimo_type_t type) { if (nof_ports > SRSLTE_MAX_PORTS) { fprintf(stderr, "Maximum number of ports is %d (nof_ports=%d)\n", SRSLTE_MAX_PORTS, nof_ports); return -1; } - if (nof_layers > MAX_LAYERS) { + if (nof_layers > SRSLTE_MAX_LAYERS) { fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", - MAX_LAYERS, nof_layers); + SRSLTE_MAX_LAYERS, nof_layers); return -1; } diff --git a/srslte/lib/mimo/test/layermap_test.c b/srslte/lib/mimo/test/layermap_test.c index 19c4e9d95..7f409f252 100644 --- a/srslte/lib/mimo/test/layermap_test.c +++ b/srslte/lib/mimo/test/layermap_test.c @@ -74,14 +74,14 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { int i, j, num_errors, symbols_layer; - cf_t *d[MAX_CODEWORDS], *x[MAX_LAYERS], *dp[MAX_CODEWORDS]; - lte_mimo_type_t type; - int nof_symb_cw[MAX_CODEWORDS]; + cf_t *d[SRSLTE_MAX_CODEWORDS], *x[SRSLTE_MAX_LAYERS], *dp[SRSLTE_MAX_CODEWORDS]; + srslte_mimo_type_t type; + int nof_symb_cw[SRSLTE_MAX_CODEWORDS]; int n[2]; parse_args(argc, argv); - if (lte_str2mimotype(mimo_type_name, &type)) { + if (srslte_str2mimotype(mimo_type_name, &type)) { fprintf(stderr, "Invalid MIMO type %s\n", mimo_type_name); exit(-1); } diff --git a/srslte/lib/mimo/test/precoding_test.c b/srslte/lib/mimo/test/precoding_test.c index 748574beb..e9e7128b9 100644 --- a/srslte/lib/mimo/test/precoding_test.c +++ b/srslte/lib/mimo/test/precoding_test.c @@ -79,19 +79,19 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { int i, j; float mse; - cf_t *x[MAX_LAYERS], *r[SRSLTE_MAX_PORTS], *y[SRSLTE_MAX_PORTS], *h[SRSLTE_MAX_PORTS], - *xr[MAX_LAYERS]; - lte_mimo_type_t type; + cf_t *x[SRSLTE_MAX_LAYERS], *r[SRSLTE_MAX_PORTS], *y[SRSLTE_MAX_PORTS], *h[SRSLTE_MAX_PORTS], + *xr[SRSLTE_MAX_LAYERS]; + srslte_mimo_type_t type; precoding_t precoding; parse_args(argc, argv); - if (nof_ports > SRSLTE_MAX_PORTS || nof_layers > MAX_LAYERS) { + if (nof_ports > SRSLTE_MAX_PORTS || nof_layers > SRSLTE_MAX_LAYERS) { fprintf(stderr, "Invalid number of layers or ports\n"); exit(-1); } - if (lte_str2mimotype(mimo_type_name, &type)) { + if (srslte_str2mimotype(mimo_type_name, &type)) { fprintf(stderr, "Invalid MIMO type %s\n", mimo_type_name); exit(-1); } diff --git a/srslte/lib/modem/src/demod_hard.c b/srslte/lib/modem/src/demod_hard.c index 57d86cb52..81341d9a4 100644 --- a/srslte/lib/modem/src/demod_hard.c +++ b/srslte/lib/modem/src/demod_hard.c @@ -37,7 +37,7 @@ void demod_hard_init(demod_hard_t* q) { bzero((void*) q, sizeof(demod_hard_t)); } -void demod_hard_table_set(demod_hard_t* q, lte_mod_t mod) { +void demod_hard_table_set(demod_hard_t* q, srslte_mod_t mod) { q->mod = mod; } diff --git a/srslte/lib/modem/src/modem_table.c b/srslte/lib/modem/src/modem_table.c index 3940bbd35..5dfde43bc 100644 --- a/srslte/lib/modem/src/modem_table.c +++ b/srslte/lib/modem/src/modem_table.c @@ -71,7 +71,7 @@ int modem_table_set(modem_table_t* q, cf_t* table, soft_table_t *soft_table, uin return SRSLTE_SUCCESS; } -int modem_table_lte(modem_table_t* q, lte_mod_t modulation, bool compute_soft_demod) { +int modem_table_lte(modem_table_t* q, srslte_mod_t modulation, bool compute_soft_demod) { switch(modulation) { case LTE_BPSK: q->nbits_x_symbol = 1; diff --git a/srslte/lib/modem/test/modem_test.c b/srslte/lib/modem/test/modem_test.c index 1a06eb69d..6a513a193 100644 --- a/srslte/lib/modem/test/modem_test.c +++ b/srslte/lib/modem/test/modem_test.c @@ -40,7 +40,7 @@ time_t start, finish; struct timeval x, y; int num_bits = 1000; -lte_mod_t modulation; +srslte_mod_t modulation; bool soft_output = false, soft_exact = false; void usage(char *prog) { diff --git a/srslte/lib/modem/test/soft_demod_test.c b/srslte/lib/modem/test/soft_demod_test.c index a5f36ea18..1c7d37af0 100644 --- a/srslte/lib/modem/test/soft_demod_test.c +++ b/srslte/lib/modem/test/soft_demod_test.c @@ -38,7 +38,7 @@ int nof_frames = 10; int num_bits = 1000; -lte_mod_t modulation = 10; +srslte_mod_t modulation = 10; void usage(char *prog) { printf("Usage: %s [nfv] -m modulation (1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64)\n", prog); diff --git a/srslte/lib/phch/src/dci.c b/srslte/lib/phch/src/dci.c index aa0ed939f..11df55aa3 100644 --- a/srslte/lib/phch/src/dci.c +++ b/srslte/lib/phch/src/dci.c @@ -51,7 +51,7 @@ int dci_msg_to_ra_dl(dci_msg_t *msg, uint16_t msg_rnti, if (msg != NULL && ra_dl != NULL && - lte_cell_isvalid(&cell) && + srslte_cell_isvalid(&cell) && cfi > 0 && cfi < 4) { @@ -71,7 +71,7 @@ int dci_msg_to_ra_dl(dci_msg_t *msg, uint16_t msg_rnti, bzero(ra_dl, sizeof(ra_pdsch_t)); bool crc_is_crnti = false; - if (msg_rnti >= CRNTI_START && msg_rnti <= CRNTI_END) { + if (msg_rnti >= SRSLTE_CRNTI_START && msg_rnti <= SRSLTE_CRNTI_END) { crc_is_crnti = true; } if (dci_msg_unpack_pdsch(msg, ra_dl, cell.nof_prb, crc_is_crnti)) { @@ -866,7 +866,7 @@ int dci_msg_get_type(dci_msg_t *msg, dci_msg_type_t *type, uint32_t nof_prb, return SRSLTE_SUCCESS; } else if (msg->nof_bits == dci_format_sizeof(Format1A, nof_prb)) { /* The RNTI is not the only condition. Also some fields in the packet. - * if (msg_rnti >= CRNTI_START && msg_rnti <= CRNTI_END) { + * if (msg_rnti >= SRSLTE_CRNTI_START && msg_rnti <= SRSLTE_CRNTI_END) { type->type = RA_PROC_PDCCH; type->format = Format1A; } else { @@ -876,7 +876,7 @@ int dci_msg_get_type(dci_msg_t *msg, dci_msg_type_t *type, uint32_t nof_prb, //} return SRSLTE_SUCCESS; } else if (msg->nof_bits == dci_format_sizeof(Format1C, nof_prb)) { - if (msg_rnti == MRNTI) { + if (msg_rnti == SRSLTE_MRNTI) { type->type = MCCH_CHANGE; type->format = Format1C; } else { diff --git a/srslte/lib/phch/src/harq.c b/srslte/lib/phch/src/harq.c index 08403fd6c..0a5e98d67 100644 --- a/srslte/lib/phch/src/harq.c +++ b/srslte/lib/phch/src/harq.c @@ -42,7 +42,7 @@ #include "srslte/utils/debug.h" -#define MAX_PDSCH_RE(cp) (2 * CP_NSYMB(cp) * 12) +#define MAX_PDSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12) /* Calculate Codeblock Segmentation as in Section 5.1.2 of 36.212 */ int codeblock_segmentation(struct cb_segm *s, uint32_t tbs) { @@ -63,14 +63,14 @@ int codeblock_segmentation(struct cb_segm *s, uint32_t tbs) { s->C = (uint32_t) ceilf((float) B / (MAX_LONG_CB - 24)); Bp = B + 24 * s->C; } - ret = lte_find_cb_index((Bp-1) / s->C + 1); + ret = srslte_find_cb_index((Bp-1) / s->C + 1); if (ret != SRSLTE_ERROR) { idx1 = (uint32_t) ret; - ret = lte_cb_size(idx1); + ret = srslte_cb_size(idx1); if (ret != SRSLTE_ERROR) { s->K1 = (uint32_t) ret; if (idx1 > 0) { - ret = lte_cb_size(idx1 - 1); + ret = srslte_cb_size(idx1 - 1); } if (ret != SRSLTE_ERROR) { if (s->C == 1) { @@ -214,8 +214,8 @@ int harq_setup_dl(harq_t *q, ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx, ra_dl_a // Number of symbols, RE and bits per subframe for DL q->nof_re = q->dl_alloc.re_sf[q->sf_idx]; - q->nof_symb = 2*CP_NSYMB(q->cell.cp)-q->dl_alloc.lstart; - q->nof_bits = q->nof_re * lte_mod_bits_x_symbol(q->mcs.mod); + q->nof_symb = 2*SRSLTE_CP_NSYMB(q->cell.cp)-q->dl_alloc.lstart; + q->nof_bits = q->nof_re * srslte_mod_bits_x_symbol(q->mcs.mod); q->nof_prb = q->dl_alloc.slot[0].nof_prb; ret = SRSLTE_SUCCESS; @@ -237,9 +237,9 @@ int harq_setup_ul(harq_t *q, ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx, ra_ul_a memcpy(&q->ul_alloc, ul_alloc, sizeof(ra_ul_alloc_t)); // Number of symbols, RE and bits per subframe for UL - q->nof_symb = 2*(CP_NSYMB(q->cell.cp)-1); - q->nof_re = q->nof_symb*q->ul_alloc.L_prb*RE_X_RB; - q->nof_bits = q->nof_re * lte_mod_bits_x_symbol(q->mcs.mod); + q->nof_symb = 2*(SRSLTE_CP_NSYMB(q->cell.cp)-1); + q->nof_re = q->nof_symb*q->ul_alloc.L_prb*SRSLTE_NRE; + q->nof_bits = q->nof_re * srslte_mod_bits_x_symbol(q->mcs.mod); q->nof_prb = q->ul_alloc.L_prb; ret = SRSLTE_SUCCESS; diff --git a/srslte/lib/phch/src/pbch.c b/srslte/lib/phch/src/pbch.c index 0dd86a207..ec32d5694 100644 --- a/srslte/lib/phch/src/pbch.c +++ b/srslte/lib/phch/src/pbch.c @@ -61,37 +61,37 @@ int pbch_cp(cf_t *input, cf_t *output, srslte_cell_t cell, bool put) { if (put) { ptr = input; - output += cell.nof_prb * RE_X_RB / 2 - 36; + output += cell.nof_prb * SRSLTE_NRE / 2 - 36; } else { ptr = output; - input += cell.nof_prb * RE_X_RB / 2 - 36; + input += cell.nof_prb * SRSLTE_NRE / 2 - 36; } /* symbol 0 & 1 */ for (i = 0; i < 2; i++) { prb_cp_ref(&input, &output, cell.id % 3, 4, 4*6, put); if (put) { - output += cell.nof_prb * RE_X_RB - 2*36 + (cell.id%3==2?1:0); + output += cell.nof_prb * SRSLTE_NRE - 2*36 + (cell.id%3==2?1:0); } else { - input += cell.nof_prb * RE_X_RB - 2*36 + (cell.id%3==2?1:0); + input += cell.nof_prb * SRSLTE_NRE - 2*36 + (cell.id%3==2?1:0); } } /* symbols 2 & 3 */ - if (CP_ISNORM(cell.cp)) { + if (SRSLTE_CP_ISNORM(cell.cp)) { for (i = 0; i < 2; i++) { prb_cp(&input, &output, 6); if (put) { - output += cell.nof_prb * RE_X_RB - 2*36; + output += cell.nof_prb * SRSLTE_NRE - 2*36; } else { - input += cell.nof_prb * RE_X_RB - 2*36; + input += cell.nof_prb * SRSLTE_NRE - 2*36; } } } else { prb_cp(&input, &output, 6); if (put) { - output += cell.nof_prb * RE_X_RB - 2*36; + output += cell.nof_prb * SRSLTE_NRE - 2*36; } else { - input += cell.nof_prb * RE_X_RB - 2*36; + input += cell.nof_prb * SRSLTE_NRE - 2*36; } prb_cp_ref(&input, &output, cell.id % 3, 4, 4*6, put); } @@ -132,15 +132,15 @@ int pbch_init(pbch_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && - lte_cell_isvalid(&cell)) + srslte_cell_isvalid(&cell)) { ret = SRSLTE_ERROR; bzero(q, sizeof(pbch_t)); q->cell = cell; - q->nof_symbols = (CP_ISNORM(q->cell.cp)) ? PBCH_RE_CPNORM : PBCH_RE_CPEXT; + q->nof_symbols = (SRSLTE_CP_ISNORM(q->cell.cp)) ? PBCH_RE_SRSLTE_SRSLTE_CP_NORM : PBCH_RE_SRSLTE_SRSLTE_CP_EXT; - if (precoding_init(&q->precoding, SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); } @@ -159,7 +159,7 @@ int pbch_init(pbch_t *q, srslte_cell_t cell) { if (viterbi_init(&q->decoder, viterbi_37, poly, 40, true)) { goto clean; } - if (crc_init(&q->crc, LTE_CRC16, 16)) { + if (crc_init(&q->crc, SRSLTE_LTE_CRC16, 16)) { goto clean; } q->encoder.K = 7; @@ -262,25 +262,25 @@ void pbch_mib_unpack(uint8_t *msg, srslte_cell_t *cell, uint32_t *sfn) { break; } if (*msg) { - cell->phich_length = PHICH_EXT; + cell->phich_length = SRSLTE_PHICH_EXT; } else { - cell->phich_length = PHICH_NORM; + cell->phich_length = SRSLTE_PHICH_NORM; } msg++; phich_res = bit_unpack(&msg, 2); switch (phich_res) { case 0: - cell->phich_resources = R_1_6; + cell->phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_6; break; case 1: - cell->phich_resources = R_1_2; + cell->phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_2; break; case 2: - cell->phich_resources = R_1; + cell->phich_resources = SRSLTE_PHICH_R_1; break; case 3: - cell->phich_resources = R_2; + cell->phich_resources = SRSLTE_PHICH_R_2; break; } if (sfn) { @@ -305,20 +305,20 @@ void pbch_mib_pack(srslte_cell_t *cell, uint32_t sfn, uint8_t *msg) { } bit_pack(bw, &msg, 3); - *msg = cell->phich_length == PHICH_EXT; + *msg = cell->phich_length == SRSLTE_PHICH_EXT; msg++; switch (cell->phich_resources) { - case R_1_6: + case SRSLTE_PHICH_SRSLTE_PHICH_R_1_6: phich_res = 0; break; - case R_1_2: + case SRSLTE_PHICH_SRSLTE_PHICH_R_1_2: phich_res = 1; break; - case R_1: + case SRSLTE_PHICH_R_1: phich_res = 2; break; - case R_2: + case SRSLTE_PHICH_R_2: phich_res = 3; break; } @@ -331,19 +331,19 @@ void pbch_mib_fprint(FILE *stream, srslte_cell_t *cell, uint32_t sfn, uint32_t c printf(" - Nof ports: %d\n", cell->nof_ports); printf(" - PRB: %d\n", cell->nof_prb); printf(" - PHICH Length: %s\n", - cell->phich_length == PHICH_EXT ? "Extended" : "Normal"); + cell->phich_length == SRSLTE_PHICH_EXT ? "Extended" : "Normal"); printf(" - PHICH Resources: "); switch (cell->phich_resources) { - case R_1_6: + case SRSLTE_PHICH_SRSLTE_PHICH_R_1_6: printf("1/6"); break; - case R_1_2: + case SRSLTE_PHICH_SRSLTE_PHICH_R_1_2: printf("1/2"); break; - case R_1: + case SRSLTE_PHICH_R_1: printf("1"); break; - case R_2: + case SRSLTE_PHICH_R_2: printf("2"); break; } @@ -438,7 +438,7 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS] uint32_t nant; int i; int nof_bits; - cf_t *x[MAX_LAYERS]; + cf_t *x[SRSLTE_MAX_LAYERS]; int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -458,7 +458,7 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS] for (i = 0; i < SRSLTE_MAX_PORTS; i++) { x[i] = q->pbch_x[i]; } - memset(&x[SRSLTE_MAX_PORTS], 0, sizeof(cf_t*) * (MAX_LAYERS - SRSLTE_MAX_PORTS)); + memset(&x[SRSLTE_MAX_PORTS], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - SRSLTE_MAX_PORTS)); /* extract symbols */ if (q->nof_symbols != pbch_get(slot1_symbols, q->pbch_symbols[0], q->cell)) { @@ -540,7 +540,7 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS] int pbch_encode(pbch_t *q, uint8_t bch_payload[BCH_PAYLOAD_LEN], cf_t *slot1_symbols[SRSLTE_MAX_PORTS]) { int i; int nof_bits; - cf_t *x[MAX_LAYERS]; + cf_t *x[SRSLTE_MAX_LAYERS]; if (q != NULL && bch_payload != NULL) @@ -557,7 +557,7 @@ int pbch_encode(pbch_t *q, uint8_t bch_payload[BCH_PAYLOAD_LEN], cf_t *slot1_sym for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->pbch_x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); if (q->frame_idx == 0) { memcpy(q->data, bch_payload, sizeof(uint8_t) * BCH_PAYLOAD_LEN); diff --git a/srslte/lib/phch/src/pcfich.c b/srslte/lib/phch/src/pcfich.c index 1eeb99976..7facc6eee 100644 --- a/srslte/lib/phch/src/pcfich.c +++ b/srslte/lib/phch/src/pcfich.c @@ -66,7 +66,7 @@ int pcfich_init(pcfich_t *q, regs_t *regs, srslte_cell_t cell) { if (q != NULL && regs != NULL && - lte_cell_isvalid(&cell)) + srslte_cell_isvalid(&cell)) { ret = SRSLTE_ERROR; @@ -75,7 +75,7 @@ int pcfich_init(pcfich_t *q, regs_t *regs, srslte_cell_t cell) { q->regs = regs; q->nof_symbols = PCFICH_RE; - if (precoding_init(&q->precoding, SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); } @@ -164,7 +164,7 @@ int pcfich_decode(pcfich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], f /* Set pointers for layermapping & precoding */ int i; - cf_t *x[MAX_LAYERS]; + cf_t *x[SRSLTE_MAX_LAYERS]; cf_t *ce_precoding[SRSLTE_MAX_PORTS]; if (q != NULL && @@ -239,7 +239,7 @@ int pcfich_encode(pcfich_t *q, uint32_t cfi, cf_t *slot_symbols[SRSLTE_MAX_PORTS { /* Set pointers for layermapping & precoding */ - cf_t *x[MAX_LAYERS]; + cf_t *x[SRSLTE_MAX_LAYERS]; cf_t *symbols_precoding[SRSLTE_MAX_PORTS]; /* number of layers equals number of ports */ diff --git a/srslte/lib/phch/src/pdcch.c b/srslte/lib/phch/src/pdcch.c index 93cbd6fcc..464a330ea 100644 --- a/srslte/lib/phch/src/pdcch.c +++ b/srslte/lib/phch/src/pdcch.c @@ -61,14 +61,14 @@ int pdcch_init(pdcch_t *q, regs_t *regs, srslte_cell_t cell) { if (q != NULL && regs != NULL && - lte_cell_isvalid(&cell)) + srslte_cell_isvalid(&cell)) { ret = SRSLTE_ERROR; bzero(q, sizeof(pdcch_t)); q->cell = cell; q->regs = regs; - if (precoding_init(&q->precoding, SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); } @@ -81,7 +81,7 @@ int pdcch_init(pdcch_t *q, regs_t *regs, srslte_cell_t cell) { if (modem_table_lte(&q->mod, LTE_QPSK, true)) { goto clean; } - if (crc_init(&q->crc, LTE_CRC16, 16)) { + if (crc_init(&q->crc, SRSLTE_LTE_CRC16, 16)) { goto clean; } @@ -366,7 +366,7 @@ int pdcch_extract_llr(pdcch_t *q, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], /* Set pointers for layermapping & precoding */ uint32_t i, nof_symbols; - cf_t *x[MAX_LAYERS]; + cf_t *x[SRSLTE_MAX_LAYERS]; if (q != NULL && nsubframe < 10 && @@ -386,7 +386,7 @@ int pdcch_extract_llr(pdcch_t *q, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->pdcch_x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); /* extract symbols */ int n = regs_pdcch_get(q->regs, sf_symbols, q->pdcch_symbols[0]); @@ -502,7 +502,7 @@ int pdcch_encode(pdcch_t *q, dci_msg_t *msg, dci_location_t location, uint16_t r int ret = SRSLTE_ERROR_INVALID_INPUTS; uint32_t i; - cf_t *x[MAX_LAYERS]; + cf_t *x[SRSLTE_MAX_LAYERS]; uint32_t nof_symbols; if (q != NULL && @@ -531,7 +531,7 @@ int pdcch_encode(pdcch_t *q, dci_msg_t *msg, dci_location_t location, uint16_t r for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->pdcch_x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); scrambling_b_offset(&q->seq_pdcch[nsubframe], q->pdcch_e, 72 * location.ncce, e_bits); diff --git a/srslte/lib/phch/src/pdsch.c b/srslte/lib/phch/src/pdsch.c index 1a2e11ae2..cad3baa8a 100644 --- a/srslte/lib/phch/src/pdsch.c +++ b/srslte/lib/phch/src/pdsch.c @@ -42,11 +42,11 @@ #include "srslte/utils/vector.h" -#define MAX_PDSCH_RE(cp) (2 * CP_NSYMB(cp) * 12) +#define MAX_PDSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12) -const static lte_mod_t modulations[4] = +const static srslte_mod_t modulations[4] = { LTE_BPSK, LTE_QPSK, LTE_QAM16, LTE_QAM64 }; //#define DEBUG_IDX @@ -84,7 +84,7 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc, } for (s = 0; s < 2; s++) { - for (l = 0; l < CP_NSYMB(q->cell.cp); l++) { + for (l = 0; l < SRSLTE_CP_NSYMB(q->cell.cp); l++) { for (n = 0; n < q->cell.nof_prb; n++) { // If this PRB is assigned @@ -94,14 +94,14 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc, } else { lstart = 0; } - lend = CP_NSYMB(q->cell.cp); + lend = SRSLTE_CP_NSYMB(q->cell.cp); is_pbch = is_sss = false; // Skip PSS/SSS signals if (s == 0 && (nsubframe == 0 || nsubframe == 5)) { if (n >= q->cell.nof_prb / 2 - 3 && n < q->cell.nof_prb / 2 + 3) { - lend = CP_NSYMB(q->cell.cp) - 2; + lend = SRSLTE_CP_NSYMB(q->cell.cp) - 2; is_sss = true; } } @@ -113,17 +113,17 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc, is_pbch = true; } } - lp = l + s * CP_NSYMB(q->cell.cp); + lp = l + s * SRSLTE_CP_NSYMB(q->cell.cp); if (put) { out_ptr = &output[(lp * q->cell.nof_prb + n) - * RE_X_RB]; + * SRSLTE_NRE]; } else { in_ptr = &input[(lp * q->cell.nof_prb + n) - * RE_X_RB]; + * SRSLTE_NRE]; } // This is a symbol in a normal PRB with or without references if (l >= lstart && l < lend) { - if (SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) { + if (SRSLTE_SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) { if (nof_refs == 2 && l != 0) { offset = q->cell.id % 3 + 3; } else { @@ -138,7 +138,7 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc, // If the number or total PRB is odd, half of the the PBCH or SS will fall into the symbol if ((q->cell.nof_prb % 2) && ((is_pbch && l < lstart) || (is_sss && l >= lend))) { if (n == q->cell.nof_prb / 2 - 3) { - if (SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) { + if (SRSLTE_SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) { prb_cp_ref(&in_ptr, &out_ptr, offset, nof_refs, nof_refs/2, put); } else { prb_cp_half(&in_ptr, &out_ptr, 1); @@ -149,7 +149,7 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc, } else { in_ptr += 6; } - if (SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) { + if (SRSLTE_SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) { prb_cp_ref(&in_ptr, &out_ptr, offset, nof_refs, nof_refs/2, put); } else { prb_cp_half(&in_ptr, &out_ptr, 1); @@ -201,7 +201,7 @@ int pdsch_init(pdsch_t *q, srslte_cell_t cell) { int i; if (q != NULL && - lte_cell_isvalid(&cell)) + srslte_cell_isvalid(&cell)) { bzero(q, sizeof(pdsch_t)); @@ -213,7 +213,7 @@ int pdsch_init(pdsch_t *q, srslte_cell_t cell) { INFO("Init PDSCH: %d ports %d PRBs, max_symbols: %d\n", q->cell.nof_ports, q->cell.nof_prb, q->max_re); - if (precoding_init(&q->precoding, SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); goto clean; } @@ -232,7 +232,7 @@ int pdsch_init(pdsch_t *q, srslte_cell_t cell) { q->rnti_is_set = false; // Allocate floats for reception (LLRs) - q->pdsch_e = vec_malloc(sizeof(float) * q->max_re * lte_mod_bits_x_symbol(LTE_QAM64)); + q->pdsch_e = vec_malloc(sizeof(float) * q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64)); if (!q->pdsch_e) { goto clean; } @@ -310,7 +310,7 @@ int pdsch_set_rnti(pdsch_t *q, uint16_t rnti) { uint32_t i; for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { if (sequence_pdsch(&q->seq_pdsch[i], rnti, 0, 2 * i, q->cell.id, - q->max_re * lte_mod_bits_x_symbol(LTE_QAM64))) { + q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64))) { return SRSLTE_ERROR; } } @@ -344,7 +344,7 @@ int pdsch_decode_rnti(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLT /* Set pointers for layermapping & precoding */ uint32_t i, n; - cf_t *x[MAX_LAYERS]; + cf_t *x[SRSLTE_MAX_LAYERS]; if (q != NULL && sf_symbols != NULL && @@ -353,13 +353,13 @@ int pdsch_decode_rnti(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLT { INFO("Decoding PDSCH SF: %d, Mod %s, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", - harq->sf_idx, lte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); + harq->sf_idx, srslte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->pdsch_x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); /* extract symbols */ n = pdsch_get(q, sf_symbols, q->pdsch_symbols[0], &harq->dl_alloc, harq->sf_idx); @@ -439,7 +439,7 @@ int pdsch_encode_rnti(pdsch_t *q, harq_t *harq, uint8_t *data, uint16_t rnti, cf { int i; /* Set pointers for layermapping & precoding */ - cf_t *x[MAX_LAYERS]; + cf_t *x[SRSLTE_MAX_LAYERS]; int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && @@ -470,13 +470,13 @@ int pdsch_encode_rnti(pdsch_t *q, harq_t *harq, uint8_t *data, uint16_t rnti, cf } INFO("Encoding PDSCH SF: %d, Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", - harq->sf_idx, lte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); + harq->sf_idx, srslte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->pdsch_x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); if (dlsch_encode(&q->dl_sch, harq, data, q->pdsch_e)) { fprintf(stderr, "Error encoding TB\n"); diff --git a/srslte/lib/phch/src/phich.c b/srslte/lib/phch/src/phich.c index 1070be7b3..83e0226ef 100644 --- a/srslte/lib/phch/src/phich.c +++ b/srslte/lib/phch/src/phich.c @@ -42,10 +42,10 @@ #include "srslte/utils/debug.h" /** Table 6.9.1-2 */ -const cf_t w_normal[PHICH_NORM_NSEQUENCES][4] = { { 1, 1, 1, 1 }, +const cf_t w_normal[SRSLTE_PHICH_NORM_NSEQUENCES][4] = { { 1, 1, 1, 1 }, { 1, -1, 1, -1 }, { 1, 1, -1, -1 }, { 1, -1, -1, 1 }, { I, I, I, I }, { I, -I, I, -I }, { I, I, -I, -I }, { I, -I, -I, I } }; -const cf_t w_ext[PHICH_EXT_NSEQUENCES][2] = { { 1, 1 }, { 1, -1 }, { I, I }, { +const cf_t w_ext[SRSLTE_PHICH_EXT_NSEQUENCES][2] = { { 1, 1 }, { 1, -1 }, { I, I }, { I, -I } }; @@ -66,7 +66,7 @@ int phich_init(phich_t *q, regs_t *regs, srslte_cell_t cell) { if (q != NULL && regs != NULL && - lte_cell_isvalid(&cell)) + srslte_cell_isvalid(&cell)) { bzero(q, sizeof(phich_t)); @@ -75,7 +75,7 @@ int phich_init(phich_t *q, regs_t *regs, srslte_cell_t cell) { q->cell = cell; q->regs = regs; - if (precoding_init(&q->precoding, SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); } @@ -151,7 +151,7 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo /* Set pointers for layermapping & precoding */ int i, j; - cf_t *x[MAX_LAYERS]; + cf_t *x[SRSLTE_MAX_LAYERS]; cf_t *ce_precoding[SRSLTE_MAX_PORTS]; if (q == NULL || slot_symbols == NULL) { @@ -163,13 +163,13 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo return SRSLTE_ERROR_INVALID_INPUTS; } - if (CP_ISEXT(q->cell.cp)) { - if (nseq >= PHICH_EXT_NSEQUENCES) { + if (SRSLTE_CP_ISEXT(q->cell.cp)) { + if (nseq >= SRSLTE_PHICH_EXT_NSEQUENCES) { fprintf(stderr, "Invalid nseq %d\n", nseq); return SRSLTE_ERROR_INVALID_INPUTS; } } else { - if (nseq >= PHICH_NORM_NSEQUENCES) { + if (nseq >= SRSLTE_PHICH_NORM_NSEQUENCES) { fprintf(stderr, "Invalid nseq %d\n", nseq); return SRSLTE_ERROR_INVALID_INPUTS; } @@ -190,7 +190,7 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo } /* extract symbols */ - if (PHICH_MAX_NSYMB + if (PHICH_SRSLTE_MAX_NSYMB != regs_phich_get(q->regs, slot_symbols, q->phich_symbols[0], ngroup)) { fprintf(stderr, "There was an error getting the phich symbols\n"); return SRSLTE_ERROR; @@ -198,7 +198,7 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo /* extract channel estimates */ for (i = 0; i < q->cell.nof_ports; i++) { - if (PHICH_MAX_NSYMB != regs_phich_get(q->regs, ce[i], q->ce[i], ngroup)) { + if (PHICH_SRSLTE_MAX_NSYMB != regs_phich_get(q->regs, ce[i], q->ce[i], ngroup)) { fprintf(stderr, "There was an error getting the phich symbols\n"); return SRSLTE_ERROR; } @@ -208,55 +208,55 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo if (q->cell.nof_ports == 1) { /* no need for layer demapping */ predecoding_single(&q->precoding, q->phich_symbols[0], q->ce[0], q->phich_d0, - PHICH_MAX_NSYMB, noise_estimate); + PHICH_SRSLTE_MAX_NSYMB, noise_estimate); } else { predecoding_diversity(&q->precoding, q->phich_symbols[0], ce_precoding, x, - q->cell.nof_ports, PHICH_MAX_NSYMB, noise_estimate); + q->cell.nof_ports, PHICH_SRSLTE_MAX_NSYMB, noise_estimate); layerdemap_diversity(x, q->phich_d0, q->cell.nof_ports, - PHICH_MAX_NSYMB / q->cell.nof_ports); + PHICH_SRSLTE_MAX_NSYMB / q->cell.nof_ports); } DEBUG("Recv!!: \n", 0); DEBUG("d0: ", 0); if (VERBOSE_ISDEBUG()) - vec_fprint_c(stdout, q->phich_d0, PHICH_MAX_NSYMB); + vec_fprint_c(stdout, q->phich_d0, PHICH_SRSLTE_MAX_NSYMB); - if (CP_ISEXT(q->cell.cp)) { + if (SRSLTE_CP_ISEXT(q->cell.cp)) { if (ngroup % 2) { - for (i = 0; i < PHICH_EXT_MSYMB / 2; i++) { + for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) { q->phich_d[2 * i + 0] = q->phich_d0[4 * i + 2]; q->phich_d[2 * i + 1] = q->phich_d0[4 * i + 3]; } } else { - for (i = 0; i < PHICH_EXT_MSYMB / 2; i++) { + for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) { q->phich_d[2 * i + 0] = q->phich_d0[4 * i]; q->phich_d[2 * i + 1] = q->phich_d0[4 * i + 1]; } } } else { - memcpy(q->phich_d, q->phich_d0, PHICH_MAX_NSYMB * sizeof(cf_t)); + memcpy(q->phich_d, q->phich_d0, PHICH_SRSLTE_MAX_NSYMB * sizeof(cf_t)); } DEBUG("d: ", 0); if (VERBOSE_ISDEBUG()) - vec_fprint_c(stdout, q->phich_d, PHICH_EXT_MSYMB); + vec_fprint_c(stdout, q->phich_d, SRSLTE_PHICH_EXT_MSYMB); scrambling_c(&q->seq_phich[subframe], q->phich_d); /* De-spreading */ - if (CP_ISEXT(q->cell.cp)) { + if (SRSLTE_CP_ISEXT(q->cell.cp)) { for (i = 0; i < PHICH_NBITS; i++) { q->phich_z[i] = 0; - for (j = 0; j < PHICH_EXT_NSF; j++) { + for (j = 0; j < SRSLTE_PHICH_EXT_NSF; j++) { q->phich_z[i] += conjf(w_ext[nseq][j]) - * q->phich_d[i * PHICH_EXT_NSF + j] / PHICH_EXT_NSF; + * q->phich_d[i * SRSLTE_PHICH_EXT_NSF + j] / SRSLTE_PHICH_EXT_NSF; } } } else { for (i = 0; i < PHICH_NBITS; i++) { q->phich_z[i] = 0; - for (j = 0; j < PHICH_NORM_NSF; j++) { + for (j = 0; j < SRSLTE_PHICH_NORM_NSF; j++) { q->phich_z[i] += conjf(w_normal[nseq][j]) - * q->phich_d[i * PHICH_NORM_NSF + j] / PHICH_NORM_NSF; + * q->phich_d[i * SRSLTE_PHICH_NORM_NSF + j] / SRSLTE_PHICH_NORM_NSF; } } } @@ -290,13 +290,13 @@ int phich_encode(phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32 return SRSLTE_ERROR_INVALID_INPUTS; } - if (CP_ISEXT(q->cell.cp)) { - if (nseq >= PHICH_EXT_NSEQUENCES) { + if (SRSLTE_CP_ISEXT(q->cell.cp)) { + if (nseq >= SRSLTE_PHICH_EXT_NSEQUENCES) { fprintf(stderr, "Invalid nseq %d\n", nseq); return SRSLTE_ERROR_INVALID_INPUTS; } } else { - if (nseq >= PHICH_NORM_NSEQUENCES) { + if (nseq >= SRSLTE_PHICH_NORM_NSEQUENCES) { fprintf(stderr, "Invalid nseq %d\n", nseq); return SRSLTE_ERROR_INVALID_INPUTS; } @@ -308,7 +308,7 @@ int phich_encode(phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32 /* Set pointers for layermapping & precoding */ - cf_t *x[MAX_LAYERS]; + cf_t *x[SRSLTE_MAX_LAYERS]; cf_t *symbols_precoding[SRSLTE_MAX_PORTS]; /* number of layers equals number of ports */ @@ -329,35 +329,35 @@ int phich_encode(phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32 vec_fprint_c(stdout, q->phich_z, PHICH_NBITS); /* Spread with w */ - if (CP_ISEXT(q->cell.cp)) { - for (i = 0; i < PHICH_EXT_MSYMB; i++) { - q->phich_d[i] = w_ext[nseq][i % PHICH_EXT_NSF] - * q->phich_z[i / PHICH_EXT_NSF]; + if (SRSLTE_CP_ISEXT(q->cell.cp)) { + for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB; i++) { + q->phich_d[i] = w_ext[nseq][i % SRSLTE_PHICH_EXT_NSF] + * q->phich_z[i / SRSLTE_PHICH_EXT_NSF]; } } else { - for (i = 0; i < PHICH_NORM_MSYMB; i++) { - q->phich_d[i] = w_normal[nseq][i % PHICH_NORM_NSF] - * q->phich_z[i / PHICH_NORM_NSF]; + for (i = 0; i < SRSLTE_PHICH_NORM_MSYMB; i++) { + q->phich_d[i] = w_normal[nseq][i % SRSLTE_PHICH_NORM_NSF] + * q->phich_z[i / SRSLTE_PHICH_NORM_NSF]; } } DEBUG("d: ", 0); if (VERBOSE_ISDEBUG()) - vec_fprint_c(stdout, q->phich_d, PHICH_EXT_MSYMB); + vec_fprint_c(stdout, q->phich_d, SRSLTE_PHICH_EXT_MSYMB); scrambling_c(&q->seq_phich[subframe], q->phich_d); /* align to REG */ - if (CP_ISEXT(q->cell.cp)) { + if (SRSLTE_CP_ISEXT(q->cell.cp)) { if (ngroup % 2) { - for (i = 0; i < PHICH_EXT_MSYMB / 2; i++) { + for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) { q->phich_d0[4 * i + 0] = 0; q->phich_d0[4 * i + 1] = 0; q->phich_d0[4 * i + 2] = q->phich_d[2 * i]; q->phich_d0[4 * i + 3] = q->phich_d[2 * i + 1]; } } else { - for (i = 0; i < PHICH_EXT_MSYMB / 2; i++) { + for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) { q->phich_d0[4 * i + 0] = q->phich_d[2 * i]; q->phich_d0[4 * i + 1] = q->phich_d[2 * i + 1]; q->phich_d0[4 * i + 2] = 0; @@ -365,21 +365,21 @@ int phich_encode(phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32 } } } else { - memcpy(q->phich_d0, q->phich_d, PHICH_MAX_NSYMB * sizeof(cf_t)); + memcpy(q->phich_d0, q->phich_d, PHICH_SRSLTE_MAX_NSYMB * sizeof(cf_t)); } DEBUG("d0: ", 0); if (VERBOSE_ISDEBUG()) - vec_fprint_c(stdout, q->phich_d0, PHICH_MAX_NSYMB); + vec_fprint_c(stdout, q->phich_d0, PHICH_SRSLTE_MAX_NSYMB); /* layer mapping & precoding */ if (q->cell.nof_ports > 1) { - layermap_diversity(q->phich_d0, x, q->cell.nof_ports, PHICH_MAX_NSYMB); + layermap_diversity(q->phich_d0, x, q->cell.nof_ports, PHICH_SRSLTE_MAX_NSYMB); precoding_diversity(&q->precoding, x, symbols_precoding, q->cell.nof_ports, - PHICH_MAX_NSYMB / q->cell.nof_ports); + PHICH_SRSLTE_MAX_NSYMB / q->cell.nof_ports); /**FIXME: According to 6.9.2, Precoding for 4 tx ports is different! */ } else { - memcpy(q->phich_symbols[0], q->phich_d0, PHICH_MAX_NSYMB * sizeof(cf_t)); + memcpy(q->phich_symbols[0], q->phich_d0, PHICH_SRSLTE_MAX_NSYMB * sizeof(cf_t)); } /* mapping to resource elements */ diff --git a/srslte/lib/phch/src/prb_dl.c b/srslte/lib/phch/src/prb_dl.c index ee12af88e..33c3e3953 100644 --- a/srslte/lib/phch/src/prb_dl.c +++ b/srslte/lib/phch/src/prb_dl.c @@ -53,7 +53,7 @@ void prb_cp_ref(cf_t **input, cf_t **output, int offset, int nof_refs, int nof_intervals, bool advance_output) { int i; - int ref_interval = ((RE_X_RB / nof_refs) - 1); + int ref_interval = ((SRSLTE_NRE / nof_refs) - 1); memcpy(*output, *input, offset * sizeof(cf_t)); print_indexes(*input, offset); *input += offset; @@ -83,18 +83,18 @@ void prb_cp_ref(cf_t **input, cf_t **output, int offset, int nof_refs, } void prb_cp(cf_t **input, cf_t **output, int nof_prb) { - memcpy(*output, *input, sizeof(cf_t) * RE_X_RB * nof_prb); - print_indexes(*input, RE_X_RB); - *input += nof_prb * RE_X_RB; - *output += nof_prb * RE_X_RB; + memcpy(*output, *input, sizeof(cf_t) * SRSLTE_NRE * nof_prb); + print_indexes(*input, SRSLTE_NRE); + *input += nof_prb * SRSLTE_NRE; + *output += nof_prb * SRSLTE_NRE; } void prb_cp_half(cf_t **input, cf_t **output, int nof_prb) { - memcpy(*output, *input, sizeof(cf_t) * RE_X_RB * nof_prb / 2); - print_indexes(*input, RE_X_RB/2); - *input += nof_prb * RE_X_RB / 2; - *output += nof_prb * RE_X_RB / 2; + memcpy(*output, *input, sizeof(cf_t) * SRSLTE_NRE * nof_prb / 2); + print_indexes(*input, SRSLTE_NRE/2); + *input += nof_prb * SRSLTE_NRE / 2; + *output += nof_prb * SRSLTE_NRE / 2; } void prb_put_ref_(cf_t **input, cf_t **output, int offset, int nof_refs, diff --git a/srslte/lib/phch/src/pucch.c b/srslte/lib/phch/src/pucch.c index 6ff8a133b..defbdd1cf 100644 --- a/srslte/lib/phch/src/pucch.c +++ b/srslte/lib/phch/src/pucch.c @@ -42,7 +42,7 @@ #include "srslte/utils/vector.h" #include "srslte/filter/dft_precoding.h" -#define MAX_PUSCH_RE(cp) (2 * CP_NSYMB(cp) * 12) +#define MAX_PUSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12) bool pucch_cfg_isvalid(pucch_cfg_t *cfg) { return true; @@ -50,18 +50,18 @@ bool pucch_cfg_isvalid(pucch_cfg_t *cfg) { /* Generates n_cs_cell according to Sec 5.4 of 36.211 */ -int generate_n_cs_cell(srslte_cell_t cell, uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NSYMB]) +int generate_n_cs_cell(srslte_cell_t cell, uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]) { sequence_t seq; bzero(&seq, sizeof(sequence_t)); - sequence_LTE_pr(&seq, 8*CP_NSYMB(cell.cp)*SRSLTE_NSLOTS_X_FRAME, cell.id); + sequence_LTE_pr(&seq, 8*SRSLTE_CP_NSYMB(cell.cp)*SRSLTE_NSLOTS_X_FRAME, cell.id); for (uint32_t ns=0;nsn_pucch < c*cfg->N_cs/cfg->delta_pucch_shift)?cfg->N_cs:12; uint32_t n_prime = cfg->n_pucch; @@ -85,17 +85,17 @@ float pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NS n_prime = (cfg->n_pucch-c*cfg->N_cs/cfg->delta_pucch_shift)%(cfg->N_cs/cfg->delta_pucch_shift); } - uint32_t n_oc_div = (!is_drms && CP_ISEXT(cp))?2:1; + uint32_t n_oc_div = (!is_drms && SRSLTE_CP_ISEXT(cp))?2:1; uint32_t n_oc = n_prime*cfg->delta_pucch_shift/N_prime; - if (!is_drms && CP_ISEXT(cp)) { + if (!is_drms && SRSLTE_CP_ISEXT(cp)) { n_oc *= 2; } if (n_oc_ptr) { *n_oc_ptr = n_oc; } uint32_t n_cs = 0; - if (CP_ISNORM(cp)) { + if (SRSLTE_CP_ISNORM(cp)) { n_cs = (n_cs_cell[ns][l]+(n_prime*cfg->delta_pucch_shift+(n_oc%cfg->delta_pucch_shift))%N_prime)%12; } else { n_cs = (n_cs_cell[ns][l]+(n_prime*cfg->delta_pucch_shift+n_oc/n_oc_div)%N_prime)%12; @@ -121,7 +121,7 @@ int pucch_get(pucch_t *q, harq_t *harq, cf_t *input, cf_t *output) { /** Initializes the PDCCH transmitter and receiver */ int pucch_init(pucch_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; - if (q != NULL && lte_cell_isvalid(&cell)) { + if (q != NULL && srslte_cell_isvalid(&cell)) { ret = SRSLTE_ERROR; bzero(q, sizeof(pucch_t)); diff --git a/srslte/lib/phch/src/pusch.c b/srslte/lib/phch/src/pusch.c index 834c9624b..63d7e6dcd 100644 --- a/srslte/lib/phch/src/pusch.c +++ b/srslte/lib/phch/src/pusch.c @@ -42,11 +42,11 @@ #include "srslte/utils/vector.h" #include "srslte/filter/dft_precoding.h" -#define MAX_PUSCH_RE(cp) (2 * CP_NSYMB(cp) * 12) +#define MAX_PUSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12) -const static lte_mod_t modulations[4] = +const static srslte_mod_t modulations[4] = { LTE_BPSK, LTE_QPSK, LTE_QAM16, LTE_QAM64 }; static int f_hop_sum(pusch_t *q, uint32_t i) { @@ -90,7 +90,7 @@ int pusch_cp(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output, bool advance_i pusch_hopping_cfg_t *hopping = &q->hopping_cfg; uint32_t L_ref = 3; - if (CP_ISEXT(q->cell.cp)) { + if (SRSLTE_CP_ISEXT(q->cell.cp)) { L_ref = 2; } INFO("PUSCH Freq hopping: %d\n", harq->ul_alloc.freq_hopping); @@ -131,25 +131,25 @@ int pusch_cp(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output, bool advance_i } harq->ul_alloc.n_prb_tilde[slot] = n_prb_tilde; INFO("Allocating PUSCH %d PRB to index %d at slot %d\n",harq->ul_alloc.L_prb, n_prb_tilde,slot); - for (uint32_t l=0;lcell.cp);l++) { + for (uint32_t l=0;lcell.cp);l++) { if (l != L_ref) { - uint32_t idx = RE_IDX(q->cell.nof_prb, l+slot*CP_NSYMB(q->cell.cp), - n_prb_tilde*RE_X_RB); + uint32_t idx = SRSLTE_RE_IDX(q->cell.nof_prb, l+slot*SRSLTE_CP_NSYMB(q->cell.cp), + n_prb_tilde*SRSLTE_NRE); if (advance_input) { out_ptr = &output[idx]; } else { in_ptr = &input[idx]; } - memcpy(out_ptr, in_ptr, harq->ul_alloc.L_prb * RE_X_RB * sizeof(cf_t)); + memcpy(out_ptr, in_ptr, harq->ul_alloc.L_prb * SRSLTE_NRE * sizeof(cf_t)); if (advance_input) { - in_ptr += harq->ul_alloc.L_prb*RE_X_RB; + in_ptr += harq->ul_alloc.L_prb*SRSLTE_NRE; } else { - out_ptr += harq->ul_alloc.L_prb*RE_X_RB; + out_ptr += harq->ul_alloc.L_prb*SRSLTE_NRE; } } } } - return RE_X_RB*harq->ul_alloc.L_prb; + return SRSLTE_NRE*harq->ul_alloc.L_prb; } int pusch_put(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output) { @@ -167,7 +167,7 @@ int pusch_init(pusch_t *q, srslte_cell_t cell) { int i; if (q != NULL && - lte_cell_isvalid(&cell)) + srslte_cell_isvalid(&cell)) { bzero(q, sizeof(pusch_t)); @@ -202,7 +202,7 @@ int pusch_init(pusch_t *q, srslte_cell_t cell) { } /* This is for equalization at receiver */ - if (precoding_init(&q->equalizer, SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (precoding_init(&q->equalizer, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); goto clean; } @@ -210,13 +210,13 @@ int pusch_init(pusch_t *q, srslte_cell_t cell) { q->rnti_is_set = false; // Allocate floats for reception (LLRs). Buffer casted to uint8_t for transmission - q->pusch_q = vec_malloc(sizeof(float) * q->max_re * lte_mod_bits_x_symbol(LTE_QAM64)); + q->pusch_q = vec_malloc(sizeof(float) * q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64)); if (!q->pusch_q) { goto clean; } // Allocate floats for reception (LLRs). Buffer casted to uint8_t for transmission - q->pusch_g = vec_malloc(sizeof(float) * q->max_re * lte_mod_bits_x_symbol(LTE_QAM64)); + q->pusch_g = vec_malloc(sizeof(float) * q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64)); if (!q->pusch_g) { goto clean; } @@ -293,7 +293,7 @@ int pusch_set_rnti(pusch_t *q, uint16_t rnti) { for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { if (sequence_pusch(&q->seq_pusch[i], rnti, 2 * i, q->cell.id, - q->max_re * lte_mod_bits_x_symbol(LTE_QAM64))) { + q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64))) { return SRSLTE_ERROR; } } @@ -317,7 +317,7 @@ int pusch_decode(pusch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce, float noi if (q->rnti_is_set) { INFO("Decoding PUSCH SF: %d, Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", - harq->sf_idx, lte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); + harq->sf_idx, srslte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); /* extract symbols */ n = pusch_get(q, harq, sf_symbols, q->pusch_d); @@ -411,7 +411,7 @@ int pusch_uci_encode_rnti(pusch_t *q, harq_t *harq, uint8_t *data, uci_data_t uc } INFO("Encoding PUSCH SF: %d, Mod %s, RNTI: %d, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", - harq->sf_idx, lte_mod_string(harq->mcs.mod), rnti, harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); + harq->sf_idx, srslte_mod_string(harq->mcs.mod), rnti, harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); bzero(q->pusch_q, harq->nof_bits); if (ulsch_uci_encode(&q->dl_sch, harq, data, uci_data, q->pusch_g, q->pusch_q)) { diff --git a/srslte/lib/phch/src/ra.c b/srslte/lib/phch/src/ra.c index ce668e6b6..b81f4fe8b 100644 --- a/srslte/lib/phch/src/ra.c +++ b/srslte/lib/phch/src/ra.c @@ -48,9 +48,9 @@ uint32_t ra_re_x_prb(uint32_t subframe, uint32_t slot, uint32_t prb_idx, uint32_ bool skip_refs = false; if (slot == 0) { - re = (CP_NSYMB(cp) - nof_ctrl_symbols) * RE_X_RB; + re = (SRSLTE_CP_NSYMB(cp) - nof_ctrl_symbols) * SRSLTE_NRE; } else { - re = CP_NSYMB(cp) * RE_X_RB; + re = SRSLTE_CP_NSYMB(cp) * SRSLTE_NRE; } /* if it's the prb in the middle, there are less RE due to PBCH and PSS/SSS */ @@ -58,27 +58,27 @@ uint32_t ra_re_x_prb(uint32_t subframe, uint32_t slot, uint32_t prb_idx, uint32_ && (prb_idx >= nof_prb / 2 - 3 && prb_idx < nof_prb / 2 + 3)) { if (subframe == 0) { if (slot == 0) { - re = (CP_NSYMB(cp) - nof_ctrl_symbols - 2) * RE_X_RB; + re = (SRSLTE_CP_NSYMB(cp) - nof_ctrl_symbols - 2) * SRSLTE_NRE; } else { - if (CP_ISEXT(cp)) { - re = (CP_NSYMB(cp) - 4) * RE_X_RB; + if (SRSLTE_CP_ISEXT(cp)) { + re = (SRSLTE_CP_NSYMB(cp) - 4) * SRSLTE_NRE; skip_refs = true; } else { - re = (CP_NSYMB(cp) - 4) * RE_X_RB + 2 * nof_ports; + re = (SRSLTE_CP_NSYMB(cp) - 4) * SRSLTE_NRE + 2 * nof_ports; } } } else if (subframe == 5) { if (slot == 0) { - re = (CP_NSYMB(cp) - nof_ctrl_symbols - 2) * RE_X_RB; + re = (SRSLTE_CP_NSYMB(cp) - nof_ctrl_symbols - 2) * SRSLTE_NRE; } } if ((nof_prb % 2) && (prb_idx == nof_prb / 2 - 3 || prb_idx == nof_prb / 2 + 3)) { if (slot == 0) { - re += 2 * RE_X_RB / 2; + re += 2 * SRSLTE_NRE / 2; } else if (subframe == 0) { - re += 4 * RE_X_RB / 2 - nof_ports; - if (CP_ISEXT(cp)) { + re += 4 * SRSLTE_NRE / 2 - nof_ports; + if (SRSLTE_CP_ISEXT(cp)) { re -= nof_ports > 2 ? 2 : nof_ports; } } @@ -497,7 +497,7 @@ int ra_tbs_from_idx_format1c(uint32_t tbs_idx) { /* Downlink Transport Block size determination as defined in 7.1.7.2 on 36.213 */ int ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb) { - if (tbs_idx < 27 && n_prb > 0 && n_prb <= MAX_PRB) { + if (tbs_idx < 27 && n_prb > 0 && n_prb <= SRSLTE_MAX_PRB) { return tbs_table[tbs_idx][n_prb - 1]; } else { return SRSLTE_ERROR; @@ -509,7 +509,7 @@ int ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb) { */ int ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb) { uint32_t idx; - if (n_prb > 0 && n_prb <= MAX_PRB) { + if (n_prb > 0 && n_prb <= SRSLTE_MAX_PRB) { return SRSLTE_ERROR; } if (tbs < tbs_table[0][n_prb]) { @@ -549,7 +549,7 @@ void ra_pusch_fprint(FILE *f, ra_pusch_t *ra, uint32_t nof_prb) { fprintf(f, " - Number of PRBs:\t\t\t%d\n", ra_nprb_ul(ra, nof_prb)); fprintf(f, " - Modulation and coding scheme index:\t%d\n", ra->mcs_idx); - fprintf(f, " - Modulation type:\t\t\t%s\n", lte_mod_string(ra->mcs.mod)); + fprintf(f, " - Modulation type:\t\t\t%s\n", srslte_mod_string(ra->mcs.mod)); fprintf(f, " - Transport block size:\t\t%d\n", ra->mcs.tbs); fprintf(f, " - New data indicator:\t\t\t%s\n", ra->ndi ? "Yes" : "No"); fprintf(f, " - Redundancy version:\t\t\t%d\n", ra->rv_idx); @@ -612,7 +612,7 @@ void ra_pdsch_fprint(FILE *f, ra_pdsch_t *ra, uint32_t nof_prb) { fprintf(f, " - Number of PRBs:\t\t\t%d\n", ra_nprb_dl(ra, nof_prb)); fprintf(f, " - Modulation and coding scheme index:\t%d\n", ra->mcs_idx); - fprintf(f, " - Modulation type:\t\t\t%s\n", lte_mod_string(ra->mcs.mod)); + fprintf(f, " - Modulation type:\t\t\t%s\n", srslte_mod_string(ra->mcs.mod)); fprintf(f, " - Transport block size:\t\t%d\n", ra->mcs.tbs); fprintf(f, " - HARQ process:\t\t\t%d\n", ra->harq_process); fprintf(f, " - New data indicator:\t\t\t%s\n", ra->ndi ? "Yes" : "No"); diff --git a/srslte/lib/phch/src/regs.c b/srslte/lib/phch/src/regs.c index 52e72be1f..d4116219f 100644 --- a/srslte/lib/phch/src/regs.c +++ b/srslte/lib/phch/src/regs.c @@ -34,7 +34,7 @@ #include "srslte/phch/regs.h" #include "srslte/utils/debug.h" -#define REG_IDX(r, i, n) r->k[i]+r->l*n*RE_X_RB +#define REG_IDX(r, i, n) r->k[i]+r->l*n*SRSLTE_NRE regs_reg_t *regs_find_reg(regs_t *h, uint32_t k, uint32_t l); @@ -240,16 +240,16 @@ int regs_phich_init(regs_t *h) { int ret = SRSLTE_ERROR; switch(h->phich_res) { - case R_1_6: + case SRSLTE_PHICH_SRSLTE_PHICH_R_1_6: ng = (float) 1/6; break; - case R_1_2: + case SRSLTE_PHICH_SRSLTE_PHICH_R_1_2: ng = (float) 1/2; break; - case R_1: + case SRSLTE_PHICH_R_1: ng = 1; break; - case R_2: + case SRSLTE_PHICH_R_2: ng = 2; break; default: @@ -263,7 +263,7 @@ int regs_phich_init(regs_t *h) { return -1; } INFO("Creating %d PHICH mapping units. %s length, Ng=%.2f\n",h->ngroups_phich, - h->phich_len==PHICH_EXT?"Extended":"Normal",ng); + h->phich_len==SRSLTE_PHICH_EXT?"Extended":"Normal",ng); for (i=0;ingroups_phich;i++) { h->phich[i].nof_regs = REGS_PHICH_REGS_X_GROUP; h->phich[i].regs = malloc(sizeof(regs_reg_t*) * REGS_PHICH_REGS_X_GROUP); @@ -304,7 +304,7 @@ int regs_phich_init(regs_t *h) { nreg=0; for (mi=0;mingroups_phich;mi++) { // here ngroups is the number of mapping units for (i=0;i<3;i++) { - li=h->phich_len==PHICH_EXT?i:0; // Step 7 + li=h->phich_len==SRSLTE_PHICH_EXT?i:0; // Step 7 ni=((h->cell.id*n[li]/n[0])+mi+i*n[li]/3) % n[li]; // Step 8 h->phich[mi].regs[i] = regs_phich[li][ni]; h->phich[mi].regs[i]->assigned = true; @@ -315,7 +315,7 @@ int regs_phich_init(regs_t *h) { // now the number of mapping units = number of groups for normal cp. For extended cp // ngroups = 2 * number mapping units - if (CP_ISEXT(h->cell.cp)) { + if (SRSLTE_CP_ISEXT(h->cell.cp)) { h->ngroups_phich *= 2; } ret = SRSLTE_SUCCESS; @@ -342,7 +342,7 @@ clean_and_exit: void regs_phich_free(regs_t *h) { uint32_t i; if (h->phich) { - if (CP_ISEXT(h->cell.cp)) { + if (SRSLTE_CP_ISEXT(h->cell.cp)) { h->ngroups_phich /= 2; } for (i=0;ingroups_phich;i++) { @@ -384,7 +384,7 @@ int regs_phich_add(regs_t *h, cf_t phich_symbols[REGS_PHICH_NSYM], uint32_t ngro fprintf(stderr, "Error invalid ngroup %d\n", ngroup); return SRSLTE_ERROR_INVALID_INPUTS; } - if (CP_ISEXT(h->cell.cp)) { + if (SRSLTE_CP_ISEXT(h->cell.cp)) { ngroup /= 2; } regs_ch_t *rch = &h->phich[ngroup]; @@ -402,8 +402,8 @@ int regs_phich_add(regs_t *h, cf_t phich_symbols[REGS_PHICH_NSYM], uint32_t ngro int regs_phich_reset(regs_t *h, cf_t *slot_symbols) { uint32_t i; uint32_t ngroup, ng; - for (ngroup = 0;ngroup < h->ngroups_phich;CP_ISEXT(h->cell.cp)?ngroup+=2:ngroup++) { - if (CP_ISEXT(h->cell.cp)) { + for (ngroup = 0;ngroup < h->ngroups_phich;SRSLTE_CP_ISEXT(h->cell.cp)?ngroup+=2:ngroup++) { + if (SRSLTE_CP_ISEXT(h->cell.cp)) { ng = ngroup/2; } else { ng = ngroup; @@ -427,7 +427,7 @@ int regs_phich_get(regs_t *h, cf_t *slot_symbols, cf_t phich_symbols[REGS_PHICH_ fprintf(stderr, "Error invalid ngroup %d\n", ngroup); return SRSLTE_ERROR_INVALID_INPUTS; } - if (CP_ISEXT(h->cell.cp)) { + if (SRSLTE_CP_ISEXT(h->cell.cp)) { ngroup /= 2; } regs_ch_t *rch = &h->phich[ngroup]; @@ -470,11 +470,11 @@ int regs_pcfich_init(regs_t *h) { INFO("PCFICH allocating %d regs. CellID: %d, PRB: %d\n", ch->nof_regs, h->cell.id, h->cell.nof_prb); - k_hat = (RE_X_RB / 2) * (h->cell.id % (2 * h->cell.nof_prb)); + k_hat = (SRSLTE_NRE / 2) * (h->cell.id % (2 * h->cell.nof_prb)); for (i = 0; i < REGS_PCFICH_NREGS; i++) { - k = (k_hat + (i * h->cell.nof_prb / 2) * (RE_X_RB / 2)) - % (h->cell.nof_prb * RE_X_RB); + k = (k_hat + (i * h->cell.nof_prb / 2) * (SRSLTE_NRE / 2)) + % (h->cell.nof_prb * SRSLTE_NRE); ch->regs[i] = regs_find_reg(h, k, 0); if (!ch->regs[i]) { fprintf(stderr, "Error allocating PCFICH: REG (%d,0) not found\n", @@ -586,7 +586,7 @@ int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, srslte_cp_t cp) { case 2: return 3; case 3: - if (CP_ISNORM(cp)) { + if (SRSLTE_CP_ISNORM(cp)) { return 3; } else { return 2; @@ -660,7 +660,7 @@ void regs_free(regs_t *h) { */ int regs_set_cfi(regs_t *h, uint32_t cfi) { if (cfi > 0 && cfi <= 3) { - if (h->phich_len == PHICH_EXT && + if (h->phich_len == SRSLTE_PHICH_EXT && ((h->cell.nof_prb < 10 && cfi < 2) || (h->cell.nof_prb >= 10 && cfi < 3))) { fprintf(stderr, "PHICH length is extended. The number of control symbols should be at least 3.\n"); return SRSLTE_ERROR_INVALID_INPUTS; @@ -688,7 +688,7 @@ int regs_init(regs_t *h, srslte_cell_t cell) { uint32_t max_ctrl_symbols; if (h != NULL && - lte_cell_isvalid(&cell)) + srslte_cell_isvalid(&cell)) { bzero(h, sizeof(regs_t)); ret = SRSLTE_ERROR; @@ -710,7 +710,7 @@ int regs_init(regs_t *h, srslte_cell_t cell) { h->nof_regs += h->cell.nof_prb * n[i]; } INFO("Indexing %d REGs. CellId: %d, %d PRB, CP: %s\n", h->nof_regs, h->cell.id, h->cell.nof_prb, - CP_ISNORM(h->cell.cp)?"Normal":"Extended"); + SRSLTE_CP_ISNORM(h->cell.cp)?"Normal":"Extended"); h->regs = malloc(sizeof(regs_reg_t) * h->nof_regs); if (!h->regs) { perror("malloc"); @@ -722,7 +722,7 @@ int regs_init(regs_t *h, srslte_cell_t cell) { k = i = prb = jmax = 0; while (k < h->nof_regs) { if (n[i] == 3 || (n[i] == 2 && jmax != 1)) { - if (regs_reg_init(&h->regs[k], i, j[i], prb * RE_X_RB, n[i], vo)) { + if (regs_reg_init(&h->regs[k], i, j[i], prb * SRSLTE_NRE, n[i], vo)) { fprintf(stderr, "Error initializing REGs\n"); goto clean_and_exit; } diff --git a/srslte/lib/phch/src/sch.c b/srslte/lib/phch/src/sch.c index 42dc75ba2..384334f71 100644 --- a/srslte/lib/phch/src/sch.c +++ b/srslte/lib/phch/src/sch.c @@ -48,11 +48,11 @@ int sch_init(sch_t *q) { if (q) { bzero(q, sizeof(sch_t)); - if (crc_init(&q->crc_tb, LTE_CRC24A, 24)) { + if (crc_init(&q->crc_tb, SRSLTE_LTE_CRC24A, 24)) { fprintf(stderr, "Error initiating CRC\n"); goto clean; } - if (crc_init(&q->crc_cb, LTE_CRC24B, 24)) { + if (crc_init(&q->crc_cb, SRSLTE_LTE_CRC24B, 24)) { fprintf(stderr, "Error initiating CRC\n"); goto clean; } @@ -124,7 +124,7 @@ static int encode_tb(sch_t *q, harq_t *harq, uint8_t *data, uint8_t *e_bits, uin uint32_t i; uint32_t cb_len, rp, wp, rlen, F, n_e; int ret = SRSLTE_ERROR_INVALID_INPUTS; - uint32_t Qm = lte_mod_bits_x_symbol(harq->mcs.mod); + uint32_t Qm = srslte_mod_bits_x_symbol(harq->mcs.mod); if (q != NULL && data != NULL && @@ -246,7 +246,7 @@ static int decode_tb(sch_t *q, harq_t *harq, float *e_bits, uint8_t *data, uint3 uint32_t par_rx, par_tx; uint32_t i; uint32_t cb_len, rp, wp, rlen, F, n_e; - uint32_t Qm = lte_mod_bits_x_symbol(harq->mcs.mod); + uint32_t Qm = srslte_mod_bits_x_symbol(harq->mcs.mod); if (q != NULL && data != NULL && @@ -450,9 +450,9 @@ int ulsch_uci_encode(sch_t *q, harq_t *harq, uint8_t *data, uci_data_t uci_data, uint32_t Q_prime_cqi = 0; uint32_t Q_prime_ack = 0; uint32_t Q_prime_ri = 0; - uint32_t Q_m = lte_mod_bits_x_symbol(harq->mcs.mod); + uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod); - uint32_t nof_symbols = 12*harq->ul_alloc.L_prb*RE_X_RB; + uint32_t nof_symbols = 12*harq->ul_alloc.L_prb*SRSLTE_NRE; uint32_t nb_q = nof_symbols * Q_m; bzero(q_bits, sizeof(uint8_t) * nb_q); diff --git a/srslte/lib/phch/src/sequences.c b/srslte/lib/phch/src/sequences.c index f1ad72986..6d2720bdd 100644 --- a/srslte/lib/phch/src/sequences.c +++ b/srslte/lib/phch/src/sequences.c @@ -35,7 +35,7 @@ */ int sequence_pbch(sequence_t *seq, srslte_cp_t cp, uint32_t cell_id) { bzero(seq, sizeof(sequence_t)); - return sequence_LTE_pr(seq, CP_ISNORM(cp)?1920:1728, cell_id); + return sequence_LTE_pr(seq, SRSLTE_CP_ISNORM(cp)?1920:1728, cell_id); } /** diff --git a/srslte/lib/phch/src/uci.c b/srslte/lib/phch/src/uci.c index cc8047a11..76715056d 100644 --- a/srslte/lib/phch/src/uci.c +++ b/srslte/lib/phch/src/uci.c @@ -104,7 +104,7 @@ static uint8_t M_basis_seq_pucch[20][13]={ }; int uci_cqi_init(uci_cqi_pusch_t *q) { - if (crc_init(&q->crc, LTE_CRC8, 8)) { + if (crc_init(&q->crc, SRSLTE_LTE_CRC8, 8)) { return SRSLTE_ERROR; } return SRSLTE_SUCCESS; @@ -115,20 +115,20 @@ void uci_cqi_free(uci_cqi_pusch_t *q) { } static uint32_t Q_prime_cqi(uint32_t O, float beta, uint32_t Q_prime_ri, harq_t *harq) { - uint32_t M_sc = harq->ul_alloc.L_prb * RE_X_RB; + uint32_t M_sc = harq->ul_alloc.L_prb * SRSLTE_NRE; uint32_t K = harq->cb_segm.C1*harq->cb_segm.K1 + harq->cb_segm.C2*harq->cb_segm.K2; uint32_t Q_prime = 0; if (K > 0) { - uint32_t M_sc_init = harq->nof_prb * RE_X_RB; + uint32_t M_sc_init = harq->nof_prb * SRSLTE_NRE; uint32_t L = (O<11)?0:8; uint32_t x = (uint32_t) ceilf((float) (O+L)*M_sc_init*harq->nof_symb*beta/K); Q_prime = MIN(x, M_sc * harq->nof_symb - Q_prime_ri); } else { - Q_prime = 12*harq->ul_alloc.L_prb*RE_X_RB - Q_prime_ri; + Q_prime = 12*harq->ul_alloc.L_prb*SRSLTE_NRE - Q_prime_ri; } return Q_prime; @@ -222,7 +222,7 @@ int uci_encode_cqi_pusch(uci_cqi_pusch_t *q, uint8_t *cqi_data, uint32_t cqi_len { uint32_t Q_prime = Q_prime_cqi(cqi_len, beta, Q_prime_ri, harq); - uint32_t Q_m = lte_mod_bits_x_symbol(harq->mcs.mod); + uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod); int ret = SRSLTE_ERROR; if (cqi_len <= 11) { @@ -248,7 +248,7 @@ static int uci_ulsch_interleave_ack(uint8_t ack_coded_bits[6], uint32_t ack_q_bi if (H_prime_total/N_pusch_symbs >= 1+ack_q_bit_idx/4) { uint32_t row = H_prime_total/N_pusch_symbs-1-ack_q_bit_idx/4; uint32_t colidx = (3*ack_q_bit_idx)%4; - uint32_t col = CP_ISNORM(cp)?ack_column_set_norm[colidx]:ack_column_set_ext[colidx]; + uint32_t col = SRSLTE_CP_ISNORM(cp)?ack_column_set_norm[colidx]:ack_column_set_ext[colidx]; for(uint32_t k=0; k= 1+ri_q_bit_idx/4) { uint32_t row = H_prime_total/N_pusch_symbs-1-ri_q_bit_idx/4; uint32_t colidx = (3*ri_q_bit_idx)%4; - uint32_t col = CP_ISNORM(cp)?ri_column_set_norm[colidx]:ri_column_set_ext[colidx]; + uint32_t col = SRSLTE_CP_ISNORM(cp)?ri_column_set_norm[colidx]:ri_column_set_ext[colidx]; printf("r=%d-%d\n",H_prime_total/N_pusch_symbs,1+ri_q_bit_idx/4); for(uint32_t k=0; kul_alloc.L_prb * RE_X_RB; + uint32_t M_sc = harq->ul_alloc.L_prb * SRSLTE_NRE; uint32_t K = harq->cb_segm.C1*harq->cb_segm.K1 + harq->cb_segm.C2*harq->cb_segm.K2; @@ -301,7 +301,7 @@ static uint32_t Q_prime_ri_ack(uint32_t O, uint32_t O_cqi, float beta, harq_t *h } } - uint32_t M_sc_init = harq->nof_prb * RE_X_RB; + uint32_t M_sc_init = harq->nof_prb * SRSLTE_NRE; uint32_t x = (uint32_t) ceilf((float) O*M_sc_init*harq->nof_symb*beta/K); @@ -323,7 +323,7 @@ static void encode_ri_ack(uint8_t data, uint8_t q_encoded_bits[6], uint8_t Q_m) */ int uci_encode_ack(uint8_t data, uint32_t O_cqi, float beta, harq_t *harq, uint32_t H_prime_total, uint8_t *q_bits) { - uint32_t Q_m = lte_mod_bits_x_symbol(harq->mcs.mod); + uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Qprime = Q_prime_ri_ack(1, O_cqi, beta, harq); uint8_t q_encoded_bits[6]; @@ -342,7 +342,7 @@ int uci_encode_ack(uint8_t data, uint32_t O_cqi, float beta, harq_t *harq, uint3 */ int uci_encode_ri(uint8_t data, uint32_t O_cqi, float beta, harq_t *harq, uint32_t H_prime_total, uint8_t *q_bits) { - uint32_t Q_m = lte_mod_bits_x_symbol(harq->mcs.mod); + uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Qprime = Q_prime_ri_ack(1, O_cqi, beta, harq); uint8_t q_encoded_bits[6]; diff --git a/srslte/lib/phch/test/dci_unpacking.c b/srslte/lib/phch/test/dci_unpacking.c index 422416b28..8c5e0ffb7 100644 --- a/srslte/lib/phch/test/dci_unpacking.c +++ b/srslte/lib/phch/test/dci_unpacking.c @@ -82,7 +82,7 @@ int main(int argc, char **argv) { dci_msg_type_t dci_type; msg.nof_bits = len; - if (dci_msg_get_type(&msg, &dci_type, nof_prb, SIRNTI)) { + if (dci_msg_get_type(&msg, &dci_type, nof_prb, SRSLTE_SIRNTI)) { fprintf(stderr, "Can't obtain DCI message type\n"); exit(-1); } diff --git a/srslte/lib/phch/test/pbch_file_test.c b/srslte/lib/phch/test/pbch_file_test.c index 48aacd0a7..0e15645f8 100644 --- a/srslte/lib/phch/test/pbch_file_test.c +++ b/srslte/lib/phch/test/pbch_file_test.c @@ -39,16 +39,16 @@ srslte_cell_t cell = { 6, // nof_prb 2, // nof_ports 150, // cell_id - CPNORM, // cyclic prefix - R_1, // PHICH resources - PHICH_NORM // PHICH length + SRSLTE_SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_PHICH_R_1, // PHICH resources + SRSLTE_PHICH_NORM // PHICH length }; int nof_frames = 1; uint8_t bch_payload_file[BCH_PAYLOAD_LEN] = {0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -#define FLEN (10*SF_LEN(lte_symbol_sz(cell.nof_prb))) +#define FLEN (10*SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb))) filesource_t fsrc; cf_t *input_buffer, *fft_buffer, *ce[SRSLTE_MAX_PORTS]; @@ -86,7 +86,7 @@ void parse_args(int argc, char **argv) { verbose++; break; case 'e': - cell.cp = CPEXT; + cell.cp = SRSLTE_SRSLTE_CP_EXT; break; default: usage(argv[0]); @@ -113,21 +113,21 @@ int base_init() { exit(-1); } - fft_buffer = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); + fft_buffer = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); if (!fft_buffer) { perror("malloc"); return -1; } for (i=0;i= 4) { - mexutils_write_cf(ce[0], &plhs[3], SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14); + mexutils_write_cf(ce[0], &plhs[3], SRSLTE_SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14); } if (nlhs >= 5) { - mexutils_write_cf(ce[1], &plhs[4], SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14); + mexutils_write_cf(ce[1], &plhs[4], SRSLTE_SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14); } if (nlhs >= 6) { mexutils_write_cf(pbch.pbch_symbols[0], &plhs[5], pbch.nof_symbols, 1); diff --git a/srslte/lib/phch/test/pcfich_file_test.c b/srslte/lib/phch/test/pcfich_file_test.c index 292f8d847..8395424b9 100644 --- a/srslte/lib/phch/test/pcfich_file_test.c +++ b/srslte/lib/phch/test/pcfich_file_test.c @@ -41,9 +41,9 @@ srslte_cell_t cell = { 6, // nof_prb 1, // nof_ports 0, // cell_id - CPNORM, // cyclic prefix - R_1, // PHICH resources - PHICH_NORM // PHICH length + SRSLTE_SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_PHICH_R_1, // PHICH resources + SRSLTE_PHICH_NORM // PHICH length }; int flen; @@ -90,7 +90,7 @@ void parse_args(int argc, char **argv) { verbose++; break; case 'e': - cell.cp = CPEXT; + cell.cp = SRSLTE_SRSLTE_CP_EXT; break; default: usage(argv[0]); @@ -121,7 +121,7 @@ int base_init() { fmatlab = NULL; } - flen = SLOT_LEN(lte_symbol_sz(cell.nof_prb)); + flen = SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb)); input_buffer = malloc(flen * sizeof(cf_t)); if (!input_buffer) { @@ -129,14 +129,14 @@ int base_init() { exit(-1); } - fft_buffer = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); + fft_buffer = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); if (!fft_buffer) { perror("malloc"); return -1; } for (i=0;i= 5) { - mexutils_write_f(pdsch.pdsch_e, &plhs[4], harq_process.dl_alloc.re_sf[sf_idx] * lte_mod_bits_x_symbol(mcs.mod), 1); + mexutils_write_f(pdsch.pdsch_e, &plhs[4], harq_process.dl_alloc.re_sf[sf_idx] * srslte_mod_bits_x_symbol(mcs.mod), 1); } srslte_chest_dl_free(&chest); diff --git a/srslte/lib/phch/test/phich_file_test.c b/srslte/lib/phch/test/phich_file_test.c index 9a01bc221..752f029ba 100644 --- a/srslte/lib/phch/test/phich_file_test.c +++ b/srslte/lib/phch/test/phich_file_test.c @@ -40,9 +40,9 @@ srslte_cell_t cell = { 50, // cell.nof_prb 2, // cell.nof_ports 150, // cell.id - CPNORM, // cyclic prefix - R_1, // PHICH resources - PHICH_NORM // PHICH length + SRSLTE_SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_PHICH_R_1, // PHICH resources + SRSLTE_PHICH_NORM // PHICH length }; int flen; @@ -89,19 +89,19 @@ void parse_args(int argc, char **argv) { break; case 'g': if (!strcmp(argv[optind], "1/6")) { - cell.phich_resources = R_1_6; + cell.phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_6; } else if (!strcmp(argv[optind], "1/2")) { - cell.phich_resources = R_1_2; + cell.phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_2; } else if (!strcmp(argv[optind], "1")) { - cell.phich_resources = R_1; + cell.phich_resources = SRSLTE_PHICH_R_1; } else if (!strcmp(argv[optind], "2")) { - cell.phich_resources = R_2; + cell.phich_resources = SRSLTE_PHICH_R_2; } else { fprintf(stderr, "Invalid phich ng factor %s. Setting to default.\n", argv[optind]); } break; case 'e': - cell.phich_length = PHICH_EXT; + cell.phich_length = SRSLTE_PHICH_EXT; break; case 'n': cell.nof_prb = atoi(argv[optind]); @@ -113,7 +113,7 @@ void parse_args(int argc, char **argv) { verbose++; break; case 'l': - cell.cp = CPEXT; + cell.cp = SRSLTE_SRSLTE_CP_EXT; break; default: usage(argv[0]); @@ -144,7 +144,7 @@ int base_init() { fmatlab = NULL; } - flen = SLOT_LEN(lte_symbol_sz(cell.nof_prb)); + flen = SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb)); input_buffer = malloc(flen * sizeof(cf_t)); if (!input_buffer) { @@ -152,14 +152,14 @@ int base_init() { exit(-1); } - fft_buffer = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); + fft_buffer = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); if (!fft_buffer) { perror("malloc"); return -1; } for (i=0;i= 1) { - mexutils_write_cf(scfdma, &plhs[0], SF_LEN_PRB(cell.nof_prb), 1); + mexutils_write_cf(scfdma, &plhs[0], SRSLTE_SF_LEN_PRB(cell.nof_prb), 1); } if (nlhs >= 2) { mexutils_write_cf(sf_symbols, &plhs[1], nof_re, 1); diff --git a/srslte/lib/phch/test/pusch_test.c b/srslte/lib/phch/test/pusch_test.c index 11d2cabbb..71d19b99e 100644 --- a/srslte/lib/phch/test/pusch_test.c +++ b/srslte/lib/phch/test/pusch_test.c @@ -38,15 +38,15 @@ srslte_cell_t cell = { 6, // nof_prb 1, // nof_ports 0, // cell_id - CPNORM, // cyclic prefix - R_1_6, // PHICH resources - PHICH_NORM // PHICH length + SRSLTE_SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_PHICH_SRSLTE_PHICH_R_1_6, // PHICH resources + SRSLTE_PHICH_NORM // PHICH length }; uint32_t cfi = 2; uint32_t tbs = 0; uint32_t subframe = 1; -lte_mod_t modulation = LTE_QPSK; +srslte_mod_t modulation = LTE_QPSK; uint32_t rv_idx = 0; uint32_t L_prb = 2; uint32_t n_prb = 0; @@ -199,7 +199,7 @@ int main(int argc, char **argv) { pusch_set_hopping_cfg(&pusch, &ul_hopping); - uint32_t nof_re = RE_X_RB*cell.nof_prb*2*CP_NSYMB(cell.cp); + uint32_t nof_re = SRSLTE_NRE*cell.nof_prb*2*SRSLTE_CP_NSYMB(cell.cp); sf_symbols = vec_malloc(sizeof(cf_t) * nof_re); if (!sf_symbols) { perror("malloc"); @@ -234,10 +234,10 @@ int main(int argc, char **argv) { } - cf_t *scfdma = vec_malloc(sizeof(cf_t) * SF_LEN_PRB(cell.nof_prb)); - bzero(scfdma, sizeof(cf_t) * SF_LEN_PRB(cell.nof_prb)); + cf_t *scfdma = vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); + bzero(scfdma, sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); srslte_fft_t fft; - lte_ifft_init(&fft, CPNORM, cell.nof_prb); + lte_ifft_init(&fft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb); srslte_fft_set_freq_shift(&fft, 0.5); lte_ifft_run_sf(&fft, sf_symbols, scfdma); diff --git a/srslte/lib/phch/test/ulsch_encode_test_mex.c b/srslte/lib/phch/test/ulsch_encode_test_mex.c index fe5412dff..c137c365a 100644 --- a/srslte/lib/phch/test/ulsch_encode_test_mex.c +++ b/srslte/lib/phch/test/ulsch_encode_test_mex.c @@ -66,7 +66,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) srslte_cell_t cell; cell.nof_prb = 100; cell.id=1; - cell.cp=CPNORM; + cell.cp=SRSLTE_SRSLTE_CP_NORM; if (harq_init(&harq_process, cell)) { mexErrMsgTxt("Error initiating HARQ\n"); return; @@ -135,7 +135,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) prb_alloc.n_prb[1] = prbset[0]; free(prbset); - mexPrintf("Q_m: %d, NPRB: %d, RV: %d\n", lte_mod_bits_x_symbol(mcs.mod), prb_alloc.L_prb, rv); + mexPrintf("Q_m: %d, NPRB: %d, RV: %d\n", srslte_mod_bits_x_symbol(mcs.mod), prb_alloc.L_prb, rv); if (harq_setup_ul(&harq_process, mcs, 0, 0, &prb_alloc)) { mexErrMsgTxt("Error configuring HARQ process\n"); diff --git a/srslte/lib/scrambling/src/scrambling.c b/srslte/lib/scrambling/src/scrambling.c index d8e3f4b5f..4e5d40b59 100644 --- a/srslte/lib/scrambling/src/scrambling.c +++ b/srslte/lib/scrambling/src/scrambling.c @@ -97,11 +97,11 @@ int compute_sequences(scrambling_hl* h) { switch (h->init.channel) { case SCRAMBLING_PBCH: return sequence_pbch(&h->obj.seq[0], - h->init.nof_symbols == SRSLTE_CPNORM_NSYMB ? CPNORM : CPEXT, h->init.cell_id); + h->init.nof_symbols == SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB ? SRSLTE_SRSLTE_CP_NORM : SRSLTE_SRSLTE_CP_EXT, h->init.cell_id); case SCRAMBLING_PDSCH: for (int ns = 0; ns < SRSLTE_NSUBFRAMES_X_FRAME; ns++) { sequence_pdsch(&h->obj.seq[ns], h->init.nrnti, 0, 2 * ns, h->init.cell_id, - LTE_NSOFT_BITS); + SRSLTE_NSOFT_BITS); } return 0; case SCRAMBLING_PCFICH: @@ -111,7 +111,7 @@ int compute_sequences(scrambling_hl* h) { return 0; case SCRAMBLING_PDCCH: for (int ns = 0; ns < SRSLTE_NSUBFRAMES_X_FRAME; ns++) { - sequence_pdcch(&h->obj.seq[ns], 2 * ns, h->init.cell_id, LTE_NSOFT_BITS); + sequence_pdcch(&h->obj.seq[ns], 2 * ns, h->init.cell_id, SRSLTE_NSOFT_BITS); } return 0; case SCRAMBLING_PMCH: diff --git a/srslte/lib/scrambling/test/scrambling_test.c b/srslte/lib/scrambling/test/scrambling_test.c index 1f2fa15eb..77d67b2f1 100644 --- a/srslte/lib/scrambling/test/scrambling_test.c +++ b/srslte/lib/scrambling/test/scrambling_test.c @@ -38,7 +38,7 @@ char *sequence_name = NULL; bool do_floats = false; -srslte_cp_t cp = CPNORM; +srslte_cp_t cp = SRSLTE_SRSLTE_CP_NORM; int cell_id = -1; void usage(char *prog) { @@ -55,7 +55,7 @@ void parse_args(int argc, char **argv) { cell_id = atoi(argv[optind]); break; case 'e': - cp = CPEXT; + cp = SRSLTE_SRSLTE_CP_EXT; break; case 'f': do_floats = true; diff --git a/srslte/lib/sync/src/find_sss.c b/srslte/lib/sync/src/find_sss.c index 2332e4a8f..0a3b0c1c7 100644 --- a/srslte/lib/sync/src/find_sss.c +++ b/srslte/lib/sync/src/find_sss.c @@ -70,7 +70,7 @@ static void corr_all_sz_partial(cf_t z[N_SSS], float s[N_SSS][N_SSS], uint32_t M } static void extract_pair_sss(sss_synch_t *q, cf_t *input, cf_t *ce, cf_t y[2][N_SSS]) { - cf_t input_fft[SYMBOL_SZ_MAX]; + cf_t input_fft[SRSLTE_SYMBOL_SZ_MAX]; dft_run_c(&q->dftp_input, input, input_fft); diff --git a/srslte/lib/sync/src/pss.c b/srslte/lib/sync/src/pss.c index 18b5f8688..6a00fe9b9 100644 --- a/srslte/lib/sync/src/pss.c +++ b/srslte/lib/sync/src/pss.c @@ -44,7 +44,7 @@ int pss_synch_init_N_id_2(cf_t *pss_signal_time, cf_t *pss_signal_freq, uint32_t cf_t pss_signal_pad[2048]; int ret = SRSLTE_ERROR_INVALID_INPUTS; - if (lte_N_id_2_isvalid(N_id_2) && + if (srslte_N_id_2_isvalid(N_id_2) && fft_size <= 2048) { @@ -243,7 +243,7 @@ int pss_generate(cf_t *signal, uint32_t N_id_2) { */ void pss_put_slot(cf_t *pss_signal, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp) { int k; - k = (CP_NSYMB(cp) - 1) * nof_prb * RE_X_RB + nof_prb * RE_X_RB / 2 - 31; + k = (SRSLTE_CP_NSYMB(cp) - 1) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31; memset(&slot[k - 5], 0, 5 * sizeof(cf_t)); memcpy(&slot[k], pss_signal, PSS_LEN * sizeof(cf_t)); memset(&slot[k + PSS_LEN], 0, 5 * sizeof(cf_t)); @@ -253,7 +253,7 @@ void pss_put_slot(cf_t *pss_signal, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp /** Sets the current N_id_2 value. Returns -1 on error, 0 otherwise */ int pss_synch_set_N_id_2(pss_synch_t *q, uint32_t N_id_2) { - if (!lte_N_id_2_isvalid((N_id_2))) { + if (!srslte_N_id_2_isvalid((N_id_2))) { fprintf(stderr, "Invalid N_id_2 %d\n", N_id_2); return -1; } else { @@ -286,7 +286,7 @@ int pss_synch_find_pss(pss_synch_t *q, cf_t *input, float *corr_peak_value) uint32_t corr_peak_pos; uint32_t conv_output_len; - if (!lte_N_id_2_isvalid(q->N_id_2)) { + if (!srslte_N_id_2_isvalid(q->N_id_2)) { fprintf(stderr, "Error finding PSS peak, Must set N_id_2 first\n"); return SRSLTE_ERROR; } @@ -388,13 +388,13 @@ SRSLTE_API cf_t *tmp2; */ int pss_synch_chest(pss_synch_t *q, cf_t *input, cf_t ce[PSS_LEN]) { int ret = SRSLTE_ERROR_INVALID_INPUTS; - cf_t input_fft[SYMBOL_SZ_MAX]; + cf_t input_fft[SRSLTE_SYMBOL_SZ_MAX]; if (q != NULL && input != NULL) { - if (!lte_N_id_2_isvalid(q->N_id_2)) { + if (!srslte_N_id_2_isvalid(q->N_id_2)) { fprintf(stderr, "Error finding PSS peak, Must set N_id_2 first\n"); return SRSLTE_ERROR; } diff --git a/srslte/lib/sync/src/sss.c b/srslte/lib/sync/src/sss.c index 53663e508..52a74fcf1 100644 --- a/srslte/lib/sync/src/sss.c +++ b/srslte/lib/sync/src/sss.c @@ -98,7 +98,7 @@ void sss_synch_free(sss_synch_t *q) { /** Sets the N_id_2 to search for */ int sss_synch_set_N_id_2(sss_synch_t *q, uint32_t N_id_2) { - if (!lte_N_id_2_isvalid(N_id_2)) { + if (!srslte_N_id_2_isvalid(N_id_2)) { fprintf(stderr, "Invalid N_id_2 %d\n", N_id_2); return SRSLTE_ERROR; } else { @@ -112,7 +112,7 @@ int sss_synch_set_N_id_2(sss_synch_t *q, uint32_t N_id_2) { void sss_put_slot(float *sss, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp) { uint32_t i, k; - k = (CP_NSYMB(cp) - 2) * nof_prb * RE_X_RB + nof_prb * RE_X_RB / 2 - 31; + k = (SRSLTE_CP_NSYMB(cp) - 2) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31; if (k > 5) { memset(&slot[k - 5], 0, 5 * sizeof(cf_t)); diff --git a/srslte/lib/sync/src/sync.c b/srslte/lib/sync/src/sync.c index fd8016d75..75041cf49 100644 --- a/srslte/lib/sync/src/sync.c +++ b/srslte/lib/sync/src/sync.c @@ -59,7 +59,7 @@ int sync_init(sync_t *q, uint32_t frame_size, uint32_t fft_size) { bzero(q, sizeof(sync_t)); q->detect_cp = true; - q->cp = CPNORM; + q->cp = SRSLTE_SRSLTE_CP_NORM; q->mean_peak_value = 0.0; q->sss_en = true; q->correct_cfo = true; @@ -115,11 +115,11 @@ void sync_sss_en(sync_t *q, bool enabled) { } bool sync_sss_detected(sync_t *q) { - return lte_N_id_1_isvalid(q->N_id_1); + return srslte_N_id_1_isvalid(q->N_id_1); } int sync_get_cell_id(sync_t *q) { - if (lte_N_id_2_isvalid(q->N_id_2) && lte_N_id_1_isvalid(q->N_id_1)) { + if (srslte_N_id_2_isvalid(q->N_id_2) && srslte_N_id_1_isvalid(q->N_id_1)) { return q->N_id_1*3 + q->N_id_2; } else { return -1; @@ -127,7 +127,7 @@ int sync_get_cell_id(sync_t *q) { } int sync_set_N_id_2(sync_t *q, uint32_t N_id_2) { - if (lte_N_id_2_isvalid(N_id_2)) { + if (srslte_N_id_2_isvalid(N_id_2)) { q->N_id_2 = N_id_2; return SRSLTE_SUCCESS; } else { @@ -188,8 +188,8 @@ srslte_cp_t sync_detect_cp(sync_t *q, cf_t *input, uint32_t peak_pos) float R_norm, R_ext, C_norm, C_ext; float M_norm=0, M_ext=0; - uint32_t cp_norm_len = CP_NORM(7, q->fft_size); - uint32_t cp_ext_len = CP_EXT(q->fft_size); + uint32_t cp_norm_len = SRSLTE_CP_NORM(7, q->fft_size); + uint32_t cp_ext_len = SRSLTE_CP_EXT(q->fft_size); cf_t *input_cp_norm = &input[peak_pos-2*(q->fft_size+cp_norm_len)]; cf_t *input_cp_ext = &input[peak_pos-2*(q->fft_size+cp_ext_len)]; @@ -215,14 +215,14 @@ srslte_cp_t sync_detect_cp(sync_t *q, cf_t *input, uint32_t peak_pos) q->M_ext_avg = VEC_EMA(M_ext/2, q->M_ext_avg, CP_EMA_ALPHA); if (q->M_norm_avg > q->M_ext_avg) { - return CPNORM; + return SRSLTE_SRSLTE_CP_NORM; } else if (q->M_norm_avg < q->M_ext_avg) { - return CPEXT; + return SRSLTE_SRSLTE_CP_EXT; } else { if (R_norm > R_ext) { - return CPNORM; + return SRSLTE_SRSLTE_CP_NORM; } else { - return CPEXT; + return SRSLTE_SRSLTE_CP_EXT; } } } @@ -236,7 +236,7 @@ int sync_sss(sync_t *q, cf_t *input, uint32_t peak_pos, srslte_cp_t cp) { sss_synch_set_N_id_2(&q->sss, q->N_id_2); /* Make sure we have enough room to find SSS sequence */ - sss_idx = (int) peak_pos-2*q->fft_size-CP(q->fft_size, (CP_ISNORM(q->cp)?CPNORM_LEN:CPEXT_LEN)); + sss_idx = (int) peak_pos-2*q->fft_size-SRSLTE_CP(q->fft_size, (SRSLTE_CP_ISNORM(q->cp)?SRSLTE_SRSLTE_CP_NORM_LEN:SRSLTE_SRSLTE_CP_EXT_LEN)); if (sss_idx < 0) { INFO("Not enough room to decode CP SSS (sss_idx=%d, peak_pos=%d)\n", sss_idx, peak_pos); return SRSLTE_ERROR; @@ -260,7 +260,7 @@ int sync_sss(sync_t *q, cf_t *input, uint32_t peak_pos, srslte_cp_t cp) { if (ret >= 0) { q->N_id_1 = (uint32_t) ret; DEBUG("SSS detected N_id_1=%d, sf_idx=%d, %s CP\n", - q->N_id_1, q->sf_idx, CP_ISNORM(q->cp)?"Normal":"Extended"); + q->N_id_1, q->sf_idx, SRSLTE_CP_ISNORM(q->cp)?"Normal":"Extended"); return 1; } else { q->N_id_1 = 1000; @@ -283,7 +283,7 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit if (q != NULL && input != NULL && - lte_N_id_2_isvalid(q->N_id_2) && + srslte_N_id_2_isvalid(q->N_id_2) && fft_size_isvalid(q->fft_size)) { int peak_pos; @@ -321,7 +321,7 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit } if (q->detect_cp) { - if (peak_pos + find_offset >= 2*(q->fft_size + CP_EXT(q->fft_size))) { + if (peak_pos + find_offset >= 2*(q->fft_size + SRSLTE_CP_EXT(q->fft_size))) { q->cp = sync_detect_cp(q, input, peak_pos + find_offset); } else { INFO("Not enough room to detect CP length. Peak position: %d\n", peak_pos); @@ -351,7 +351,7 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit INFO("SYNC ret=%d N_id_2=%d find_offset=%d pos=%d peak=%.2f threshold=%.2f sf_idx=%d, CFO=%.3f KHz\n", ret, q->N_id_2, find_offset, peak_pos, q->peak_value, q->threshold, q->sf_idx, 15*q->mean_cfo); - } else if (lte_N_id_2_isvalid(q->N_id_2)) { + } else if (srslte_N_id_2_isvalid(q->N_id_2)) { fprintf(stderr, "Must call sync_set_N_id_2() first!\n"); } diff --git a/srslte/lib/sync/test/pss_mex.c b/srslte/lib/sync/test/pss_mex.c index 8424dcaf4..051b02c29 100644 --- a/srslte/lib/sync/test/pss_mex.c +++ b/srslte/lib/sync/test/pss_mex.c @@ -69,7 +69,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } - if (pss_synch_init_fft(&pss, frame_len, lte_symbol_sz(cell.nof_prb))) { + if (pss_synch_init_fft(&pss, frame_len, srslte_symbol_sz(cell.nof_prb))) { fprintf(stderr, "Error initiating PSS\n"); exit(-1); } diff --git a/srslte/lib/sync/test/pss_usrp.c b/srslte/lib/sync/test/pss_usrp.c index fb5b8bbb6..5775dc722 100644 --- a/srslte/lib/sync/test/pss_usrp.c +++ b/srslte/lib/sync/test/pss_usrp.c @@ -54,7 +54,7 @@ int nof_frames = -1; uint32_t fft_size=64; float threshold = 0.4; int N_id_2_sync = -1; -srslte_cp_t cp=CPNORM; +srslte_cp_t cp=SRSLTE_SRSLTE_CP_NORM; void usage(char *prog) { printf("Usage: %s [aedgtvnp] -f rx_frequency_hz -i cell_id\n", prog); @@ -90,7 +90,7 @@ void parse_args(int argc, char **argv) { threshold = atof(argv[optind]); break; case 'e': - cp = CPEXT; + cp = SRSLTE_SRSLTE_CP_EXT; break; case 'i': cell_id = atoi(argv[optind]); @@ -241,7 +241,7 @@ int main(int argc, char **argv) { } // Find SSS - int sss_idx = peak_idx-2*fft_size-(CP_ISNORM(cp)?CP(fft_size, CPNORM_LEN):CP(fft_size, CPEXT_LEN)); + int sss_idx = peak_idx-2*fft_size-(SRSLTE_CP_ISNORM(cp)?SRSLTE_CP(fft_size, SRSLTE_SRSLTE_CP_NORM_LEN):SRSLTE_CP(fft_size, SRSLTE_SRSLTE_CP_EXT_LEN)); if (sss_idx >= 0 && sss_idx < flen-fft_size) { sss_synch_m0m1_partial(&sss, &buffer[sss_idx], 3, NULL, &m0, &m0_value, &m1, &m1_value); if (sss_synch_N_id_1(&sss, m0, m1) != N_id_1) { @@ -261,9 +261,9 @@ int main(int argc, char **argv) { } // Estimate CP - if (peak_idx > 2*(fft_size + CP_EXT(fft_size))) { + if (peak_idx > 2*(fft_size + SRSLTE_CP_EXT(fft_size))) { srslte_cp_t cp = sync_detect_cp(&ssync, buffer, peak_idx); - if (CP_ISNORM(cp)) { + if (SRSLTE_CP_ISNORM(cp)) { cp_is_norm++; } } diff --git a/srslte/lib/sync/test/sss_mex.c b/srslte/lib/sync/test/sss_mex.c index 480c65657..3462a4d6c 100644 --- a/srslte/lib/sync/test/sss_mex.c +++ b/srslte/lib/sync/test/sss_mex.c @@ -81,7 +81,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } - if (sss_synch_init(&sss, lte_symbol_sz(cell.nof_prb))) { + if (sss_synch_init(&sss, srslte_symbol_sz(cell.nof_prb))) { mexErrMsgTxt("Error initializing SSS object\n"); return; } @@ -89,7 +89,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) sss_synch_set_N_id_2(&sss, cell.id%3); // Find SSS - uint32_t sss_idx = SLOT_IDX_CPNORM(5,lte_symbol_sz(cell.nof_prb)); + uint32_t sss_idx = SRSLTE_SLOT_IDX_CPNORM(5,srslte_symbol_sz(cell.nof_prb)); if (sss_idx > frame_len) { mexErrMsgTxt("Error too few samples provided.\n"); return; diff --git a/srslte/lib/sync/test/sync_test.c b/srslte/lib/sync/test/sync_test.c index 59081d78a..312a397b8 100644 --- a/srslte/lib/sync/test/sync_test.c +++ b/srslte/lib/sync/test/sync_test.c @@ -38,10 +38,10 @@ #include "srslte/srslte.h" int cell_id = -1, offset = 0; -srslte_cp_t cp = CPNORM; +srslte_cp_t cp = SRSLTE_SRSLTE_CP_NORM; uint32_t nof_prb=6; -#define FLEN SF_LEN(fft_size) +#define FLEN SRSLTE_SF_LEN(fft_size) void usage(char *prog) { printf("Usage: %s [cpoev]\n", prog); @@ -66,7 +66,7 @@ void parse_args(int argc, char **argv) { offset = atoi(argv[optind]); break; case 'e': - cp = CPEXT; + cp = SRSLTE_SRSLTE_CP_EXT; break; case 'v': verbose++; @@ -92,7 +92,7 @@ int main(int argc, char **argv) { parse_args(argc, argv); - fft_size = lte_symbol_sz(nof_prb); + fft_size = srslte_symbol_sz(nof_prb); if (fft_size < 0) { fprintf(stderr, "Invalid nof_prb=%d\n", nof_prb); exit(-1); @@ -165,7 +165,7 @@ int main(int argc, char **argv) { exit(-1); } if (sync_get_cp(&sync) != cp) { - printf("Detected CP should be %s\n", CP_ISNORM(cp)?"Normal":"Extended"); + printf("Detected CP should be %s\n", SRSLTE_CP_ISNORM(cp)?"Normal":"Extended"); exit(-1); } } diff --git a/srslte/lib/ue/src/ue_cell_search.c b/srslte/lib/ue/src/ue_cell_search.c index 9abd08373..9c0e4a053 100644 --- a/srslte/lib/ue/src/ue_cell_search.c +++ b/srslte/lib/ue/src/ue_cell_search.c @@ -56,7 +56,7 @@ int ue_cell_search_init_max(ue_cell_search_t * q, uint32_t max_frames, bzero(q, sizeof(ue_cell_search_t)); bzero(&cell, sizeof(srslte_cell_t)); - cell.id = CELL_ID_UNKNOWN; + cell.id = SRSLTE_CELL_ID_UNKNOWN; cell.nof_prb = CS_NOF_PRB; if (ue_sync_init(&q->ue_sync, cell, recv_callback, stream_handler)) { @@ -157,7 +157,7 @@ static void get_cell(ue_cell_search_t * q, uint32_t nof_detected_frames, ue_cell found_cell->peak = 0; for (i=0;icandidates[i].cell_id == found_cell->cell_id) { - if (CP_ISNORM(q->candidates[i].cp)) { + if (SRSLTE_CP_ISNORM(q->candidates[i].cp)) { nof_normal++; } } @@ -167,9 +167,9 @@ static void get_cell(ue_cell_search_t * q, uint32_t nof_detected_frames, ue_cell found_cell->peak /= nof_detected_frames; if (nof_normal > q->mode_ntimes[mode_pos]/2) { - found_cell->cp = CPNORM; + found_cell->cp = SRSLTE_SRSLTE_CP_NORM; } else { - found_cell->cp = CPEXT; + found_cell->cp = SRSLTE_SRSLTE_CP_EXT; } found_cell->mode = (float) q->mode_ntimes[mode_pos]/nof_detected_frames; @@ -239,7 +239,7 @@ int ue_cell_search_scan_N_id_2(ue_cell_search_t * q, uint32_t N_id_2, ue_cell_se ("CELL SEARCH: [%3d/%3d/%d]: Found peak PSR=%.3f, Cell_id: %d CP: %s\n", nof_detected_frames, nof_scanned_frames, q->nof_frames_to_scan, q->candidates[nof_detected_frames].peak, q->candidates[nof_detected_frames].cell_id, - lte_cp_string(q->candidates[nof_detected_frames].cp)); + srslte_cp_string(q->candidates[nof_detected_frames].cp)); memcpy(&tmp_pss_corr[nof_detected_frames*32], &q->ue_sync.strack.pss.conv_output_avg[128], 32*sizeof(float)); memcpy(&tmp_sss_corr[nof_detected_frames*31], diff --git a/srslte/lib/ue/src/ue_dl.c b/srslte/lib/ue/src/ue_dl.c index 34ec0ea12..7479f92cb 100644 --- a/srslte/lib/ue/src/ue_dl.c +++ b/srslte/lib/ue/src/ue_dl.c @@ -30,11 +30,11 @@ #include #include -#define CURRENT_FFTSIZE lte_symbol_sz(q->cell.nof_prb) -#define CURRENT_SFLEN SF_LEN(CURRENT_FFTSIZE) +#define CURRENT_FFTSIZE srslte_symbol_sz(q->cell.nof_prb) +#define CURRENT_SFLEN SRSLTE_SF_LEN(CURRENT_FFTSIZE) -#define CURRENT_SLOTLEN_RE SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp) -#define CURRENT_SFLEN_RE SF_LEN_RE(q->cell.nof_prb, q->cell.cp) +#define CURRENT_SLOTLEN_RE SRSLTE_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp) +#define CURRENT_SFLEN_RE SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp) #define MAX_CANDIDATES 64 @@ -44,7 +44,7 @@ int ue_dl_init(ue_dl_t *q, int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && - lte_cell_isvalid(&cell)) + srslte_cell_isvalid(&cell)) { ret = SRSLTE_ERROR; @@ -219,7 +219,7 @@ int ue_dl_decode_rnti_rv_packet(ue_dl_t *q, dci_msg_t *dci_msg, uint8_t *data, return SRSLTE_ERROR; } - if (rnti != SIRNTI) { + if (rnti != SRSLTE_SIRNTI) { rvidx = q->ra_dl.rv_idx; } if (harq_setup_dl(&q->harq_process[0], q->ra_dl.mcs, rvidx, sf_idx, &q->ra_dl.prb_alloc)) { @@ -276,7 +276,7 @@ int ue_dl_decode_rnti_rv(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx } /* Generate PDCCH candidates */ - if (rnti == SIRNTI) { + if (rnti == SRSLTE_SIRNTI) { nof_locations = pdcch_common_locations(&q->pdcch, locations, MAX_CANDIDATES, cfi); formats = common_formats; nof_formats = nof_common_formats; diff --git a/srslte/lib/ue/src/ue_mib.c b/srslte/lib/ue/src/ue_mib.c index 925caa100..88011cb10 100644 --- a/srslte/lib/ue/src/ue_mib.c +++ b/srslte/lib/ue/src/ue_mib.c @@ -48,14 +48,14 @@ int ue_mib_init(ue_mib_t * q, ret = SRSLTE_ERROR; bzero(q, sizeof(ue_mib_t)); - q->sf_symbols = vec_malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); + q->sf_symbols = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); if (!q->sf_symbols) { perror("malloc"); goto clean_exit; } for (int i=0;ice[i] = vec_malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); + q->ce[i] = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); if (!q->ce[i]) { perror("malloc"); goto clean_exit; @@ -133,11 +133,11 @@ int ue_mib_decode(ue_mib_t * q, cf_t *input, } for (int i=0;ice[i][SLOT_LEN_RE(q->chest.cell.nof_prb, q->chest.cell.cp)]; + ce_slot1[i] = &q->ce[i][SRSLTE_SLOT_LEN_RE(q->chest.cell.nof_prb, q->chest.cell.cp)]; } /* Decode PBCH */ - ret = pbch_decode(&q->pbch, &q->sf_symbols[SLOT_LEN_RE(q->chest.cell.nof_prb, q->chest.cell.cp)], + ret = pbch_decode(&q->pbch, &q->sf_symbols[SRSLTE_SLOT_LEN_RE(q->chest.cell.nof_prb, q->chest.cell.cp)], ce_slot1, srslte_chest_dl_get_noise_estimate(&q->chest), bch_payload, nof_tx_ports, sfn_offset); if (ret < 0) { diff --git a/srslte/lib/ue/src/ue_sync.c b/srslte/lib/ue/src/ue_sync.c index a4d2b968c..c5c81e9fd 100644 --- a/srslte/lib/ue/src/ue_sync.c +++ b/srslte/lib/ue/src/ue_sync.c @@ -51,12 +51,12 @@ int ue_sync_init_file(ue_sync_t *q, uint32_t nof_prb, char *file_name) { if (q != NULL && file_name != NULL && - lte_nofprb_isvalid(nof_prb)) + srslte_nofprb_isvalid(nof_prb)) { ret = SRSLTE_ERROR; bzero(q, sizeof(ue_sync_t)); q->file_mode = true; - q->sf_len = SF_LEN(lte_symbol_sz(nof_prb)); + q->sf_len = SRSLTE_SF_LEN(srslte_symbol_sz(nof_prb)); if (filesource_init(&q->file_source, file_name, COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", file_name); @@ -89,7 +89,7 @@ int ue_sync_init(ue_sync_t *q, if (q != NULL && stream_handler != NULL && - lte_nofprb_isvalid(cell.nof_prb) && + srslte_nofprb_isvalid(cell.nof_prb) && recv_callback != NULL) { ret = SRSLTE_ERROR; @@ -99,8 +99,8 @@ int ue_sync_init(ue_sync_t *q, q->stream = stream_handler; q->recv_callback = recv_callback; q->cell = cell; - q->fft_size = lte_symbol_sz(q->cell.nof_prb); - q->sf_len = SF_LEN(q->fft_size); + q->fft_size = srslte_symbol_sz(q->cell.nof_prb); + q->sf_len = SRSLTE_SF_LEN(q->fft_size); q->file_mode = false; if (cell.id == 1000) { @@ -249,7 +249,7 @@ static int find_peak_ok(ue_sync_t *q) { q->frame_find_cnt++; INFO("Found peak %d at %d, value %.3f, Cell_id: %d CP: %s\n", q->frame_find_cnt, q->peak_idx, - sync_get_last_peak_value(&q->sfind), q->cell.id, lte_cp_string(q->cell.cp)); + sync_get_last_peak_value(&q->sfind), q->cell.id, srslte_cp_string(q->cell.cp)); if (q->frame_find_cnt >= q->nof_avg_find_frames || q->peak_idx < 2*q->fft_size) { INFO("Realigning frame, reading %d samples\n", q->peak_idx+q->sf_len/2); diff --git a/srslte/lib/ue/src/ue_ul.c b/srslte/lib/ue/src/ue_ul.c index 1ef041284..ac6121c70 100644 --- a/srslte/lib/ue/src/ue_ul.c +++ b/srslte/lib/ue/src/ue_ul.c @@ -31,11 +31,11 @@ #include "srslte/ue/ue_ul.h" -#define CURRENT_FFTSIZE lte_symbol_sz(q->cell.nof_prb) -#define CURRENT_SFLEN SF_LEN(CURRENT_FFTSIZE) +#define CURRENT_FFTSIZE srslte_symbol_sz(q->cell.nof_prb) +#define CURRENT_SFLEN SRSLTE_SF_LEN(CURRENT_FFTSIZE) -#define CURRENT_SLOTLEN_RE SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp) -#define CURRENT_SFLEN_RE SF_LEN_RE(q->cell.nof_prb, q->cell.cp) +#define CURRENT_SLOTLEN_RE SRSLTE_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp) +#define CURRENT_SFLEN_RE SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp) int ue_ul_init(ue_ul_t *q, @@ -44,7 +44,7 @@ int ue_ul_init(ue_ul_t *q, int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && - lte_cell_isvalid(&cell)) + srslte_cell_isvalid(&cell)) { ret = SRSLTE_ERROR; @@ -85,7 +85,7 @@ int ue_ul_init(ue_ul_t *q, perror("malloc"); goto clean_exit; } - q->refsignal = vec_malloc(2 * RE_X_RB * q->cell.nof_prb * sizeof(cf_t)); + q->refsignal = vec_malloc(2 * SRSLTE_NRE * q->cell.nof_prb * sizeof(cf_t)); if (!q->refsignal) { perror("malloc"); goto clean_exit; @@ -214,11 +214,11 @@ int ue_ul_pusch_uci_encode_rnti(ue_ul_t *q, ra_pusch_t *ra_ul, uint8_t *data, uc lte_ifft_run_sf(&q->fft, q->sf_symbols, output_signal); - //cfo_correct(&q->cfo, output_signal, output_signal, q->current_cfo / lte_symbol_sz(q->cell.nof_prb)); + //cfo_correct(&q->cfo, output_signal, output_signal, q->current_cfo / srslte_symbol_sz(q->cell.nof_prb)); if (q->normalize_en) { float norm_factor = (float) q->cell.nof_prb/10/sqrtf(q->harq_process[0].ul_alloc.L_prb); - vec_sc_prod_cfc(output_signal, norm_factor, output_signal, SF_LEN_PRB(q->cell.nof_prb)); + vec_sc_prod_cfc(output_signal, norm_factor, output_signal, SRSLTE_SF_LEN_PRB(q->cell.nof_prb)); } ret = SRSLTE_SUCCESS;