diff --git a/cuhd/lib/cuhd_utils.c b/cuhd/lib/cuhd_utils.c index 68f1ea6e6..95d68686a 100644 --- a/cuhd/lib/cuhd_utils.c +++ b/cuhd/lib/cuhd_utils.c @@ -64,9 +64,9 @@ int cuhd_rssi_scan(void *uhd, float *freqs, float *rssi, int nof_bands, double f goto free_and_exit; } } - rssi[i] = vec_avg_power_cf(buffer, nsamp); + rssi[i] = srslte_vec_avg_power_cf(buffer, nsamp); printf("[%3d]: Freq %4.1f Mhz - RSSI: %3.2f dBm\r", i, f/1000000, 10*log10f(rssi[i]) + 30); fflush(stdout); - if (VERBOSE_ISINFO()) { + if (SRSLTE_VERBOSE_ISINFO()) { printf("\n"); } } diff --git a/matlab/sync/check_pss.m b/matlab/sync/check_pss.m index 133e6f127..a0a3544f0 100644 --- a/matlab/sync/check_pss.m +++ b/matlab/sync/check_pss.m @@ -16,7 +16,7 @@ for i=1:nf end fs=fs+960; -[sfo sfo_v]=sfo_estimate(fs, 5/1000); +[sfo sfo_v]=srslte_sfo_estimate(fs, 5/1000); subplot(1,3,1) plot(1:nf,fs) diff --git a/matlab/sync/sfo_estimate.m b/matlab/sync/sfo_estimate.m index f0160a868..16c208712 100644 --- a/matlab/sync/sfo_estimate.m +++ b/matlab/sync/sfo_estimate.m @@ -1,4 +1,4 @@ -function [ sfo sfo_v ] = sfo_estimate( fs, T ) +function [ sfo sfo_v ] = srslte_sfo_estimate( fs, T ) nanfs=fs(~isnan(fs)); diff --git a/matlab/tests/pdcch_bler.m b/matlab/tests/pdcch_bler.m index 1b9a2976d..dba19332e 100644 --- a/matlab/tests/pdcch_bler.m +++ b/matlab/tests/pdcch_bler.m @@ -43,7 +43,7 @@ cec.InterpWinSize = 1; % Interpolation window size %% DCI Message Generation % Generate a DCI message to be mapped to the PDCCH. -dciConfig.DCIFormat = 'Format1A'; % DCI message format +dciConfig.DCIFormat = 'SRSLTE_DCI_FORMAT1A'; % DCI message format dciConfig.Allocation.RIV = 26; % Resource indication value % Create DCI message for given configuration diff --git a/matlab/tests/pdsch_resalloc.m b/matlab/tests/pdsch_resalloc.m index 61c9d9740..d274c0c99 100644 --- a/matlab/tests/pdsch_resalloc.m +++ b/matlab/tests/pdsch_resalloc.m @@ -12,7 +12,7 @@ enb.NTotalSubframes=1; enb.DuplexMode = 'FDD'; dci.NDLRB = enb.NDLRB; -dci.DCIFormat = 'Format1C'; +dci.DCIFormat = 'SRSLTE_DCI_FORMAT1C'; dci.AllocationType=1; %dci.Allocation.Bitmap='01111000011110000'; %dci.Allocation.Subset=3; diff --git a/matlab/tests/pusch_test.m b/matlab/tests/pusch_test.m index 88fe29f1b..b10e833b2 100644 --- a/matlab/tests/pusch_test.m +++ b/matlab/tests/pusch_test.m @@ -51,7 +51,7 @@ for i=1:length(TBs) subframe_mat(idx)=cw_mat; waveform = lteSCFDMAModulate(ueConfig,subframe_mat,0); - [waveform_lib, subframe_lib, cwlib]=liblte_pusch_encode(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit); + [waveform_lib, subframe_lib, cwlib]=liblte_srslte_pusch_encode(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit); err=mean(abs(waveform-waveform_lib)); if (err > 10^-6) disp(err) diff --git a/mex/lib/mexutils.c b/mex/lib/mexutils.c index 8d3aaaee5..8e39d6fbf 100644 --- a/mex/lib/mexutils.c +++ b/mex/lib/mexutils.c @@ -91,7 +91,7 @@ int mexutils_read_cell(const mxArray *ptr, srslte_cell_t *cell) { int mexutils_read_cf(const mxArray *ptr, cf_t **buffer) { int numelems = mxGetNumberOfElements(ptr); - cf_t *tmp = vec_malloc(numelems * sizeof(cf_t)); + cf_t *tmp = srslte_vec_malloc(numelems * sizeof(cf_t)); if (tmp) { double *inr=mxGetPr(ptr); double *ini=mxGetPi(ptr); @@ -110,7 +110,7 @@ int mexutils_read_cf(const mxArray *ptr, cf_t **buffer) { int mexutils_read_f(const mxArray *ptr, float **buffer) { int numelems = mxGetNumberOfElements(ptr); - float *tmp = vec_malloc(numelems * sizeof(float)); + float *tmp = srslte_vec_malloc(numelems * sizeof(float)); if (tmp) { double *inr=mxGetPr(ptr); for (int i=0;iuhd_gain); printf("\t-l Force N_id_2 [Default best]\n"); printf("\t-n nof_subframes [Default %d]\n", args->nof_subframes); - printf("\t-v [set verbose to debug, default none]\n"); + printf("\t-v [set srslte_verbose to debug, default none]\n"); } int parse_args(prog_args_t *args, int argc, char **argv) { @@ -102,7 +102,7 @@ int parse_args(prog_args_t *args, int argc, char **argv) { args->force_N_id_2 = atoi(argv[optind]); break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(args, argv[0]); @@ -136,11 +136,11 @@ int main(int argc, char **argv) { prog_args_t prog_args; srslte_cell_t cell; int64_t sf_cnt; - ue_sync_t ue_sync; - ue_mib_t ue_mib; + srslte_ue_sync_t ue_sync; + srslte_ue_mib_t ue_mib; void *uhd; - ue_dl_t ue_dl; - srslte_fft_t fft; + srs_ue_dl_t ue_dl; + srslte_ofdm_t fft; srslte_chest_dl_t chest; uint32_t nframes=0; uint32_t nof_trials = 0; @@ -190,26 +190,26 @@ int main(int argc, char **argv) { cuhd_stop_rx_stream(uhd); cuhd_flush_buffer(uhd); - if (ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) { + if (srslte_ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) { fprintf(stderr, "Error initiating ue_sync\n"); return -1; } - if (ue_dl_init(&ue_dl, cell)) { + if (srs_ue_dl_init(&ue_dl, cell)) { fprintf(stderr, "Error initiating UE downlink processing module\n"); return -1; } - if (ue_mib_init(&ue_mib, cell)) { + if (srslte_ue_mib_init(&ue_mib, cell)) { fprintf(stderr, "Error initaiting UE MIB decoder\n"); return -1; } /* Configure downlink receiver for the SI-RNTI since will be the only one we'll use */ - ue_dl_set_rnti(&ue_dl, SRSLTE_SIRNTI); + srs_ue_dl_set_rnti(&ue_dl, SRSLTE_SIRNTI); /* Initialize subframe counter */ sf_cnt = 0; - if (srslte_fft_init(&fft, cell.cp, cell.nof_prb)) { + if (srslte_ofdm_tx_init(&fft, cell.cp, cell.nof_prb)) { fprintf(stderr, "Error initiating FFT\n"); return -1; } @@ -220,10 +220,10 @@ int main(int argc, char **argv) { int sf_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp); - cf_t *sf_symbols = vec_malloc(sf_re * sizeof(cf_t)); + cf_t *sf_symbols = srslte_vec_malloc(sf_re * sizeof(cf_t)); for (int i=0;iid, cell->cp, cuhd_recv_wrapper_cs, uhd)) { - fprintf(stderr, "Error initiating ue_mib_sync\n"); + if (srslte_ue_mib_sync_init(&ue_mib, cell->id, cell->cp, cuhd_recv_wrapper_cs, uhd)) { + fprintf(stderr, "Error initiating srslte_ue_mib_sync\n"); goto clean_exit; } - int srate = srslte_sampling_freq_hz(MIB_NOF_PRB); + int srate = srslte_sampling_freq_hz(SRSLTE_UE_MIB_NOF_PRB); INFO("Setting sampling frequency %.2f MHz for PSS search\n", (float) srate/1000000); cuhd_set_rx_srate(uhd, (float) srate); @@ -69,20 +69,20 @@ int cuhd_mib_decoder(void *uhd, uint32_t max_nof_frames, srslte_cell_t *cell) { cuhd_start_rx_stream(uhd); /* Find and decody MIB */ - ret = ue_mib_sync_decode(&ue_mib, max_nof_frames, bch_payload, &cell->nof_ports, NULL); + ret = srslte_ue_mib_sync_decode(&ue_mib, max_nof_frames, bch_payload, &cell->nof_ports, NULL); if (ret < 0) { fprintf(stderr, "Error decoding MIB\n"); goto clean_exit; } if (ret == 1) { - bit_unpack_vector(bch_payload, bch_payload_unpacked, BCH_PAYLOAD_LEN); + srslte_bit_unpack_vector(bch_payload, bch_payload_unpacked, BCH_PAYLOAD_LEN); bcch_bch_unpack(bch_payload_unpacked, BCH_PAYLOAD_LEN, cell, NULL); } clean_exit: cuhd_stop_rx_stream(uhd); - ue_mib_sync_free(&ue_mib); + srslte_ue_mib_sync_free(&ue_mib); return ret; } @@ -93,25 +93,25 @@ int cuhd_cell_search(void *uhd, cell_search_cfg_t *config, int force_N_id_2, srslte_cell_t *cell) { int ret = SRSLTE_ERROR; - ue_cell_search_t cs; - ue_cell_search_result_t found_cells[3]; + srslte_ue_cellsearch_t cs; + srslte_ue_cellsearch_result_t found_cells[3]; - bzero(found_cells, 3*sizeof(ue_cell_search_result_t)); + bzero(found_cells, 3*sizeof(srslte_ue_cellsearch_result_t)); - if (ue_cell_search_init(&cs, cuhd_recv_wrapper_cs, uhd)) { + if (srslte_ue_cellsearch_init(&cs, cuhd_recv_wrapper_cs, uhd)) { fprintf(stderr, "Error initiating UE cell detect\n"); return SRSLTE_ERROR; } if (config->max_frames_pss) { - ue_cell_search_set_nof_frames_to_scan(&cs, config->max_frames_pss); + srslte_ue_cellsearch_set_nof_frames_to_scan(&cs, config->max_frames_pss); } if (config->threshold) { - ue_cell_search_set_threshold(&cs, config->threshold); + srslte_ue_cellsearch_set_threshold(&cs, config->threshold); } - INFO("Setting sampling frequency %.2f MHz for PSS search\n", CS_SAMP_FREQ/1000000); - cuhd_set_rx_srate(uhd, CS_SAMP_FREQ); + INFO("Setting sampling frequency %.2f MHz for PSS search\n", SRSLTE_CS_SAMP_FREQ/1000000); + cuhd_set_rx_srate(uhd, SRSLTE_CS_SAMP_FREQ); INFO("Starting receiver...\n", 0); cuhd_start_rx_stream(uhd); @@ -119,10 +119,10 @@ int cuhd_cell_search(void *uhd, cell_search_cfg_t *config, /* Find a cell in the given N_id_2 or go through the 3 of them to find the strongest */ uint32_t max_peak_cell = 0; if (force_N_id_2 >= 0) { - ret = ue_cell_search_scan_N_id_2(&cs, force_N_id_2, &found_cells[force_N_id_2]); + ret = srslte_ue_cellsearch_scan_N_id_2(&cs, force_N_id_2, &found_cells[force_N_id_2]); max_peak_cell = force_N_id_2; } else { - ret = ue_cell_search_scan(&cs, found_cells, &max_peak_cell); + ret = srslte_ue_cellsearch_scan(&cs, found_cells, &max_peak_cell); } if (ret < 0) { fprintf(stderr, "Error searching cell\n"); @@ -139,7 +139,7 @@ int cuhd_cell_search(void *uhd, cell_search_cfg_t *config, } cuhd_stop_rx_stream(uhd); - ue_cell_search_free(&cs); + srslte_ue_cellsearch_free(&cs); return ret; } diff --git a/srslte/examples/hl_example.c b/srslte/examples/hl_example.c index 2d07df74a..05acd5fb0 100644 --- a/srslte/examples/hl_example.c +++ b/srslte/examples/hl_example.c @@ -39,10 +39,10 @@ void usage(char *arg) { int main(int argc, char **argv) { srslte_binsource_hl bs; - mod_hl mod; + srslte_mod_hl mod; srslte_ch_awgn_hl ch; - demod_soft_hl demod_s; - demod_hard_hl demod_h; + srslte_demod_soft_hl demod_s; + srslte_demod_hard_hl demod_h; bzero(&bs,sizeof(bs)); bzero(&mod,sizeof(mod)); @@ -65,7 +65,7 @@ int main(int argc, char **argv) { bs.output = malloc(nbits); mod.in_len = nbits; - mod.init.std = LTE_BPSK; + mod.init.std = SRSLTE_MOD_BPSK; mod.input = bs.output; mod.output = malloc(nbits*sizeof(_Complex float)); @@ -75,22 +75,22 @@ int main(int argc, char **argv) { ch.output = malloc(nbits*sizeof(_Complex float)); demod_h.in_len = nbits; - demod_h.init.std = LTE_BPSK; + demod_h.init.std = SRSLTE_MOD_BPSK; demod_h.input = ch.output; demod_h.output = malloc(nbits); demod_s.in_len = nbits; - demod_s.init.std = LTE_BPSK; + demod_s.init.std = SRSLTE_MOD_BPSK; demod_s.input = ch.output; demod_s.output = malloc(sizeof(float)*nbits); - demod_s.ctrl_in.alg_type = APPROX; + demod_s.ctrl_in.alg_type = SRSLTE_DEMOD_SOFT_ALG_APPROX; demod_s.ctrl_in.sigma = var; if ( srslte_binsource_initialize(&bs) || mod_initialize(&mod) || srslte_ch_awgn_initialize(&ch) || - demod_hard_initialize(&demod_h) || - demod_soft_initialize(&demod_s) + srslte_demod_hard_initialize(&demod_h) || + srslte_demod_soft_initialize(&demod_s) ) { printf("Error initializing modules\n"); exit(-1); @@ -99,8 +99,8 @@ int main(int argc, char **argv) { srslte_binsource_work(&bs); mod_work(&mod); srslte_ch_awgn_work(&ch); - demod_hard_work(&demod_h); - demod_soft_work(&demod_s); + srslte_demod_hard_work(&demod_h); + srslte_demod_soft_work(&demod_s); /* hard decision for soft demodulation */ uint8_t* tmp = malloc(nbits); @@ -108,8 +108,8 @@ int main(int argc, char **argv) { tmp[i] = demod_s.output[i]>0?1:0; } - printf("Hard errors: %u/%d\n",bit_diff(bs.output,demod_h.output,nbits),nbits); - printf("Soft errors: %u/%d\n",bit_diff(bs.output,tmp,nbits),nbits); + printf("Hard errors: %u/%d\n",srslte_bit_diff(bs.output,demod_h.output,nbits),nbits); + printf("Soft errors: %u/%d\n",srslte_bit_diff(bs.output,tmp,nbits),nbits); free(bs.output); free(mod.output); diff --git a/srslte/examples/ll_example.c b/srslte/examples/ll_example.c index 1f81ff058..e93b56cad 100644 --- a/srslte/examples/ll_example.c +++ b/srslte/examples/ll_example.c @@ -45,7 +45,7 @@ int main(int argc, char **argv) { exit(-1); } printf("output: "); - bit_fprint(stdout,output,100); + srslte_bit_fprint(stdout,output,100); printf("Done\n"); exit(0); } diff --git a/srslte/examples/pdsch_enodeb.c b/srslte/examples/pdsch_enodeb.c index 2b808c8af..1dd80eb71 100644 --- a/srslte/examples/pdsch_enodeb.c +++ b/srslte/examples/pdsch_enodeb.c @@ -69,14 +69,14 @@ float uhd_amp = 0.03, uhd_gain = 70.0, uhd_freq = 2400000000; bool null_file_sink=false; srslte_filesink_t fsink; -srslte_fft_t ifft; -pbch_t pbch; -pcfich_t pcfich; -pdcch_t pdcch; -pdsch_t pdsch; -harq_t harq_process; -regs_t regs; -ra_pdsch_t ra_dl; +srslte_ofdm_t ifft; +srslte_pbch_t pbch; +srslte_pcfich_t pcfich; +srslte_pdcch_t pdcch; +srslte_pdsch_t pdsch; +srslte_harq_t harq_process; +srslte_regs_t regs; +srslte_ra_pdsch_t ra_dl; cf_t *sf_buffer = NULL, *output_buffer = NULL; @@ -108,7 +108,7 @@ void usage(char *prog) { printf("\t-c cell id [Default %d]\n", cell.id); printf("\t-p nof_prb [Default %d]\n", cell.nof_prb); printf("\t-u listen TCP port for input data (-1 is random) [Default %d]\n", net_port); - printf("\t-v [set verbose to debug, default none]\n"); + printf("\t-v [set srslte_verbose to debug, default none]\n"); } void parse_args(int argc, char **argv) { @@ -146,7 +146,7 @@ void parse_args(int argc, char **argv) { cell.id = atoi(argv[optind]); break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(argv[0]); @@ -216,44 +216,44 @@ void base_init() { } /* create ifft object */ - if (lte_ifft_init(&ifft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb)) { + if (srslte_ofdm_rx_init(&ifft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb)) { fprintf(stderr, "Error creating iFFT object\n"); exit(-1); } - srslte_fft_set_normalize(&ifft, true); - if (pbch_init(&pbch, cell)) { + srslte_ofdm_set_normalize(&ifft, true); + if (srslte_pbch_init(&pbch, cell)) { fprintf(stderr, "Error creating PBCH object\n"); exit(-1); } - if (regs_init(®s, cell)) { + if (srslte_regs_init(®s, cell)) { fprintf(stderr, "Error initiating regs\n"); exit(-1); } - if (pcfich_init(&pcfich, ®s, cell)) { + if (srslte_pcfich_init(&pcfich, ®s, cell)) { fprintf(stderr, "Error creating PBCH object\n"); exit(-1); } - if (regs_set_cfi(®s, cfi)) { + if (srslte_regs_set_cfi(®s, cfi)) { fprintf(stderr, "Error setting CFI\n"); exit(-1); } - if (pdcch_init(&pdcch, ®s, cell)) { + if (srslte_pdcch_init(&pdcch, ®s, cell)) { fprintf(stderr, "Error creating PDCCH object\n"); exit(-1); } - if (pdsch_init(&pdsch, cell)) { + if (srslte_pdsrslte_sch_init(&pdsch, cell)) { fprintf(stderr, "Error creating PDSCH object\n"); exit(-1); } - pdsch_set_rnti(&pdsch, 1234); + srslte_pdsch_set_rnti(&pdsch, 1234); - if (harq_init(&harq_process, cell)) { + if (srslte_harq_init(&harq_process, cell)) { fprintf(stderr, "Error initiating HARQ process\n"); exit(-1); } @@ -262,12 +262,12 @@ void base_init() { void base_free() { harq_free(&harq_process); - pdsch_free(&pdsch); - pdcch_free(&pdcch); - regs_free(®s); - pbch_free(&pbch); + srslte_pdsch_free(&pdsch); + srslte_pdcch_free(&pdcch); + srslte_regs_free(®s); + srslte_pbch_free(&pbch); - lte_ifft_free(&ifft); + srslte_ofdm_rx_free(&ifft); if (sf_buffer) { free(sf_buffer); @@ -304,7 +304,7 @@ reverse(register unsigned int x) uint32_t prbset_to_bitmask() { uint32_t mask=0; - int nb = (int) ceilf((float) cell.nof_prb / ra_type0_P(cell.nof_prb)); + int nb = (int) ceilf((float) cell.nof_prb / srslte_ra_type0_P(cell.nof_prb)); for (int i=0;i= prbset_orig && i < prbset_orig + prbset_num) { mask = mask | (0x1<= nbytes) { // wait for packet to be transmitted sem_wait(&net_sem); - bit_pack_vector(&data_unpacked[wpm], data, nbytes*8); + srslte_bit_pack_vector(&data_unpacked[wpm], data, nbytes*8); INFO("Sent %d/%d bytes ready\n", nbytes, rpm); rpm -= nbytes; wpm += nbytes; @@ -439,15 +439,15 @@ void *net_thread_fnc(void *arg) { int main(int argc, char **argv) { int nf=0, sf_idx=0, N_id_2=0; - cf_t pss_signal[PSS_LEN]; - float sss_signal0[SSS_LEN]; // for subframe 0 - float sss_signal5[SSS_LEN]; // for subframe 5 + cf_t pss_signal[SRSLTE_PSS_LEN]; + float sss_signal0[SRSLTE_SSS_LEN]; // for subframe 0 + float sss_signal5[SRSLTE_SSS_LEN]; // for subframe 5 uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_packed[BCH_PAYLOAD_LEN/8]; int i; cf_t *sf_symbols[SRSLTE_MAX_PORTS]; cf_t *slot1_symbols[SRSLTE_MAX_PORTS]; - dci_msg_t dci_msg; - dci_location_t locations[SRSLTE_NSUBFRAMES_X_FRAME][30]; + srslte_dci_msg_t dci_msg; + srslte_dci_location_t locations[SRSLTE_NSUBFRAMES_X_FRAME][30]; uint32_t sfn; srslte_chest_dl_t est; @@ -468,15 +468,15 @@ int main(int argc, char **argv) { cell.phich_resources = SRSLTE_PHICH_R_1; sfn = 0; - prbset_num = (int) ceilf((float) cell.nof_prb / ra_type0_P(cell.nof_prb)); + prbset_num = (int) ceilf((float) cell.nof_prb / srslte_ra_type0_P(cell.nof_prb)); last_prbset_num = prbset_num; /* this *must* be called after setting slot_len_* */ base_init(); /* Generate PSS/SSS signals */ - pss_generate(pss_signal, N_id_2); - sss_generate(sss_signal0, sss_signal5, cell.id); + srslte_pss_generate(pss_signal, N_id_2); + srslte_sss_generate(sss_signal0, sss_signal5, cell.id); /* Generate CRS signals */ if (srslte_chest_dl_init(&est, cell)) { @@ -512,7 +512,7 @@ int main(int argc, char **argv) { /* Initiate valid DCI locations */ for (i=0;i 0 && net_packet_ready) { if (null_file_sink) { - bit_unpack_vector(data, data_tmp, ra_dl.mcs.tbs); + srslte_bit_unpack_vector(data, data_tmp, ra_dl.mcs.tbs); if (srslte_netsink_write(&net_sink, data_tmp, 1+(ra_dl.mcs.tbs-1)/8) < 0) { fprintf(stderr, "Error sending data through UDP socket\n"); } @@ -588,10 +588,10 @@ int main(int argc, char **argv) { } /* Transform to OFDM symbols */ - lte_ifft_run_sf(&ifft, sf_buffer, output_buffer); + srslte_ofdm_rx_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, SRSLTE_SF_LEN_PRB(cell.nof_prb)); + srslte_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) { @@ -601,7 +601,7 @@ int main(int argc, char **argv) { usleep(1000); } else { #ifndef DISABLE_UHD - vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, sf_n_samples); + srslte_vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, sf_n_samples); cuhd_send(uhd, output_buffer, sf_n_samples, true); #endif } diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index 714b55e02..fd9961893 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -130,7 +130,7 @@ void usage(prog_args_t *args, char *prog) { printf("\t-S remote UDP address to send input signal [Default %s]\n", args->net_address_signal); printf("\t-u remote TCP port to send data (-1 does nothing with it) [Default %d]\n", args->net_port); printf("\t-U remote TCP address to send data [Default %s]\n", args->net_address); - printf("\t-v [set verbose to debug, default none]\n"); + printf("\t-v [set srslte_verbose to debug, default none]\n"); } void parse_args(prog_args_t *args, int argc, char **argv) { @@ -181,7 +181,7 @@ void parse_args(prog_args_t *args, int argc, char **argv) { args->disable_plots = true; break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(args, argv[0]); @@ -218,8 +218,8 @@ extern float mean_exec_time; enum receiver_state { DECODE_MIB, DECODE_PDSCH} state; -ue_dl_t ue_dl; -ue_sync_t ue_sync; +srs_ue_dl_t ue_dl; +srslte_ue_sync_t ue_sync; prog_args_t prog_args; uint32_t sfn = 0; // system frame number @@ -230,7 +230,7 @@ int main(int argc, char **argv) { int ret; srslte_cell_t cell; int64_t sf_cnt; - ue_mib_t ue_mib; + srslte_ue_mib_t ue_mib; #ifndef DISABLE_UHD void *uhd; #endif @@ -293,7 +293,7 @@ int main(int argc, char **argv) { cuhd_stop_rx_stream(uhd); cuhd_flush_buffer(uhd); - if (ue_mib_init(&ue_mib, cell)) { + if (srslte_ue_mib_init(&ue_mib, cell)) { fprintf(stderr, "Error initaiting UE MIB decoder\n"); exit(-1); } @@ -311,7 +311,7 @@ int main(int argc, char **argv) { cell.nof_ports = 1; cell.nof_prb = prog_args.file_nof_prb; - if (ue_sync_init_file(&ue_sync, prog_args.file_nof_prb, prog_args.input_file_name)) { + if (srslte_ue_sync_init_file(&ue_sync, prog_args.file_nof_prb, prog_args.input_file_name)) { fprintf(stderr, "Error initiating ue_sync\n"); exit(-1); } @@ -319,20 +319,20 @@ int main(int argc, char **argv) { } else { #ifndef DISABLE_UHD state = DECODE_MIB; - if (ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) { + if (srslte_ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) { fprintf(stderr, "Error initiating ue_sync\n"); exit(-1); } #endif } - if (ue_dl_init(&ue_dl, cell)) { // This is the User RNTI + if (srs_ue_dl_init(&ue_dl, cell)) { // This is the User RNTI fprintf(stderr, "Error initiating UE downlink processing module\n"); exit(-1); } /* Configure downlink receiver for the SI-RNTI since will be the only one we'll use */ - ue_dl_set_rnti(&ue_dl, prog_args.rnti); + srs_ue_dl_set_rnti(&ue_dl, prog_args.rnti); /* Initialize subframe counter */ sf_cnt = 0; @@ -361,23 +361,23 @@ int main(int argc, char **argv) { /* Main loop */ while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) { - ret = ue_sync_get_buffer(&ue_sync, &sf_buffer); + ret = srslte_ue_sync_get_buffer(&ue_sync, &sf_buffer); if (ret < 0) { - fprintf(stderr, "Error calling ue_sync_work()\n"); + fprintf(stderr, "Error calling srslte_ue_sync_work()\n"); } - /* ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */ + /* srslte_ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */ if (ret == 1) { switch (state) { case DECODE_MIB: - if (ue_sync_get_sfidx(&ue_sync) == 0) { - pbch_decode_reset(&ue_mib.pbch); - n = ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset); + if (srslte_ue_sync_get_sfidx(&ue_sync) == 0) { + decode_reset(&ue_mib.pbch); + n = srslte_ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset); if (n < 0) { fprintf(stderr, "Error decoding UE MIB\n"); exit(-1); - } else if (n == MIB_FOUND) { - bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN); + } else if (n == SRSLTE_UE_MIB_FOUND) { + srslte_bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN); bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn); printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset); sfn = (sfn + sfn_offset)%1024; @@ -390,7 +390,7 @@ int main(int argc, char **argv) { decode_pdsch = true; } else { /* We are looking for SIB1 Blocks, search only in appropiate places */ - if ((ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) { + if ((srslte_ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) { decode_pdsch = true; } else { decode_pdsch = false; @@ -398,9 +398,9 @@ int main(int argc, char **argv) { } if (decode_pdsch) { if (prog_args.rnti != SRSLTE_SIRNTI) { - n = ue_dl_decode(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync)); + n = srs_ue_dl_decode(&ue_dl, sf_buffer, data_packed, srslte_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), SRSLTE_SIRNTI, + n = srs_ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data_packed, srslte_ue_sync_get_sfidx(&ue_sync), SRSLTE_SIRNTI, ((int) ceilf((float)3*(((sfn)/2)%4)/2))%4); } if (n < 0) { @@ -408,15 +408,15 @@ int main(int argc, char **argv) { } else if (n > 0) { /* Send data if socket active */ if (prog_args.net_port > 0) { - bit_unpack_vector(data_packed, data, n); + srslte_bit_unpack_vector(data_packed, data, n); srslte_netsink_write(&net_sink, data, 1+(n-1)/8); } } nof_trials++; - rsrq = VEC_EMA(srslte_chest_dl_get_rsrq(&ue_dl.chest), rsrq, 0.05); - rsrp = VEC_EMA(srslte_chest_dl_get_rsrp(&ue_dl.chest), rsrp, 0.05); - snr = VEC_EMA(srslte_chest_dl_get_snr(&ue_dl.chest), snr, 0.01); + rsrq = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrq(&ue_dl.chest), rsrq, 0.05); + rsrp = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrp(&ue_dl.chest), rsrp, 0.05); + snr = SRSLTE_VEC_EMA(srslte_chest_dl_get_snr(&ue_dl.chest), snr, 0.01); nframes++; if (isnan(rsrq)) { rsrq = 0; @@ -443,32 +443,32 @@ int main(int argc, char **argv) { #endif } - if (ue_sync_get_sfidx(&ue_sync) != 5 && ue_sync_get_sfidx(&ue_sync) != 0) { + if (srslte_ue_sync_get_sfidx(&ue_sync) != 5 && srslte_ue_sync_get_sfidx(&ue_sync) != 0) { pdcch_tx++; } // Plot and Printf - if (ue_sync_get_sfidx(&ue_sync) == 5) { + if (srslte_ue_sync_get_sfidx(&ue_sync) == 5) { #ifdef STDOUT_COMPACT printf("SFN: %4d, PDCCH-Miss: %5.2f%% (%d missed), PDSCH-BLER: %5.2f%% (%d errors)\r", - sfn, 100*(1-(float) ue_dl.nof_pdcch_detected/nof_trials),pdcch_tx-ue_dl.nof_pdcch_detected, + sfn, 100*(1-(float) ue_dl.nof_detected/nof_trials),pdcch_tx-ue_dl.nof_detected, (float) 100*ue_dl.pkt_errors/ue_dl.pkts_total,ue_dl.pkt_errors); #else printf("CFO: %+6.2f KHz, SFO: %+6.2f Khz, " "RSRP: %+5.1f dBm, RSRQ: %5.1f dB, SNR: %4.1f dB, " "PDCCH-Miss: %5.2f%% (%d), PDSCH-BLER: %5.2f%% (%d)\r", - ue_sync_get_cfo(&ue_sync)/1000, ue_sync_get_sfo(&ue_sync)/1000, + srslte_ue_sync_get_cfo(&ue_sync)/1000, srslte_ue_sync_get_sfo(&ue_sync)/1000, 10*log10(rsrp*1000)-gain_offset, 10*log10(rsrq), 10*log10(snr), - 100*(1-(float) ue_dl.nof_pdcch_detected/nof_trials), pdcch_tx-ue_dl.nof_pdcch_detected, + 100*(1-(float) ue_dl.nof_detected/nof_trials), pdcch_tx-ue_dl.nof_detected, (float) 100*ue_dl.pkt_errors/ue_dl.pkts_total, ue_dl.pkt_errors); #endif } break; } - if (ue_sync_get_sfidx(&ue_sync) == 9) { + if (srslte_ue_sync_get_sfidx(&ue_sync) == 9) { sfn++; if (sfn == 1024) { sfn = 0; @@ -477,25 +477,25 @@ int main(int argc, char **argv) { #ifndef DISABLE_GRAPHICS if (!prog_args.disable_plots) { - plot_sf_idx = ue_sync_get_sfidx(&ue_sync); + plot_sf_idx = srslte_ue_sync_get_sfidx(&ue_sync); sem_post(&plot_sem); } #endif } else if (ret == 0) { printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r", - sync_get_peak_value(&ue_sync.sfind), + srslte_sync_get_peak_value(&ue_sync.sfind), ue_sync.frame_total_cnt, ue_sync.state); } sf_cnt++; } // Main loop - ue_dl_free(&ue_dl); - ue_sync_free(&ue_sync); + srs_ue_dl_free(&ue_dl); + srslte_ue_sync_free(&ue_sync); #ifndef DISABLE_UHD if (!prog_args.input_file_name) { - ue_mib_free(&ue_mib); + srslte_ue_mib_free(&ue_mib); cuhd_close(uhd); } #endif @@ -549,8 +549,8 @@ void *plot_thread_run(void *arg) { //} plot_real_setNewData(&pce, tmp_plot2, SRSLTE_REFSIGNAL_NUM_SF(ue_dl.cell.nof_prb,0)); if (!prog_args.input_file_name) { - int max = vec_max_fi(ue_sync.strack.pss.conv_output_avg, ue_sync.strack.pss.frame_size+ue_sync.strack.pss.fft_size-1); - vec_sc_prod_fff(ue_sync.strack.pss.conv_output_avg, + int max = srslte_vec_max_fi(ue_sync.strack.pss.conv_output_avg, ue_sync.strack.pss.frame_size+ue_sync.strack.pss.fft_size-1); + srslte_vec_sc_prod_fff(ue_sync.strack.pss.conv_output_avg, 1/ue_sync.strack.pss.conv_output_avg[max], tmp_plot2, ue_sync.strack.pss.frame_size+ue_sync.strack.pss.fft_size-1); @@ -558,13 +558,13 @@ void *plot_thread_run(void *arg) { } - plot_scatter_setNewData(&pscatequal, ue_dl.pdsch.pdsch_d, nof_symbols); - plot_scatter_setNewData(&pscatequal_pdcch, ue_dl.pdcch.pdcch_d, 36*ue_dl.pdcch.nof_cce); + plot_scatter_setNewData(&pscatequal, ue_dl.pdsch.d, nof_symbols); + plot_scatter_setNewData(&pscatequal_pdcch, ue_dl.pdcch.d, 36*ue_dl.pdcch.nof_cce); if (plot_sf_idx == 1) { if (prog_args.net_port_signal > 0) { - srslte_netsink_write(&net_sink_signal, &sf_buffer[ue_sync_sf_len(&ue_sync)/7], - ue_sync_sf_len(&ue_sync)); + srslte_netsink_write(&net_sink_signal, &sf_buffer[srslte_ue_sync_sf_len(&ue_sync)/7], + srslte_ue_sync_sf_len(&ue_sync)); } } diff --git a/srslte/examples/prach_ue.c b/srslte/examples/prach_ue.c index 525a3aff0..93914a841 100644 --- a/srslte/examples/prach_ue.c +++ b/srslte/examples/prach_ue.c @@ -105,7 +105,7 @@ void usage(prog_args_t *args, char *prog) { printf("\t-p PRACH preamble idx [Default %d]\n",args->preamble_idx); printf("\t-l Force N_id_2 [Default best]\n"); printf("\t-n nof_subframes [Default %d]\n", args->nof_subframes); - printf("\t-v [set verbose to debug, default none]\n"); + printf("\t-v [set srslte_verbose to debug, default none]\n"); } void parse_args(prog_args_t *args, int argc, char **argv) { @@ -147,7 +147,7 @@ void parse_args(prog_args_t *args, int argc, char **argv) { args->force_N_id_2 = atoi(argv[optind]); break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(args, argv[0]); @@ -184,10 +184,10 @@ enum receiver_state { DECODE_MIB, SEND_PRACH, RECV_RAR, RECV_CONNSETUP} state; #define NOF_PRACH_SEQUENCES 52 -ue_dl_t ue_dl; -ue_ul_t ue_ul; -ue_sync_t ue_sync; -prach_t prach; +srs_ue_dl_t ue_dl; +srslte_ue_ul_t ue_ul; +srslte_ue_sync_t ue_sync; +srslte_prach_t prach; int prach_buffer_len; prog_args_t prog_args; @@ -265,20 +265,20 @@ int rar_unpack(uint8_t *buffer, rar_msg_t *msg) msg->hdr_type = *ptr++; if(msg->hdr_type == rar_header_type_bi) { ptr += 2; - msg->BI = bit_unpack(&ptr, 4); + msg->BI = srslte_bit_unpack(&ptr, 4); ret = SRSLTE_SUCCESS; } else if (msg->hdr_type == rar_header_type_rapid) { - msg->RAPID = bit_unpack(&ptr, 6); + msg->RAPID = srslte_bit_unpack(&ptr, 6); ptr++; - msg->timing_adv_cmd = bit_unpack(&ptr, 11); + msg->timing_adv_cmd = srslte_bit_unpack(&ptr, 11); msg->hopping_flag = *ptr++; - msg->rba = bit_unpack(&ptr, 10); - msg->mcs = bit_unpack(&ptr, 4); - msg->tpc_command = (rar_tpc_command_t) bit_unpack(&ptr, 3); + msg->rba = srslte_bit_unpack(&ptr, 10); + msg->mcs = srslte_bit_unpack(&ptr, 4); + msg->tpc_command = (rar_tpc_command_t) srslte_bit_unpack(&ptr, 3); msg->ul_delay = *ptr++; msg->csi_req = *ptr++; - msg->temp_c_rnti = bit_unpack(&ptr, 16); + msg->temp_c_rnti = srslte_bit_unpack(&ptr, 16); ret = SRSLTE_SUCCESS; } } @@ -293,13 +293,13 @@ int main(int argc, char **argv) { int ret; srslte_cell_t cell; int64_t sf_cnt; - ue_mib_t ue_mib; + srslte_ue_mib_t ue_mib; void *uhd; int n; uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN]; uint32_t sfn_offset; rar_msg_t rar_msg; - ra_pusch_t ra_pusch; + srslte_ra_pusch_t ra_pusch; uint32_t rar_window_start = 0, rar_trials = 0, rar_window_stop = 0; srslte_timestamp_t uhd_time; srslte_timestamp_t next_tx_time; @@ -368,33 +368,33 @@ int main(int argc, char **argv) { #endif - if (ue_mib_init(&ue_mib, cell)) { + if (srslte_ue_mib_init(&ue_mib, cell)) { fprintf(stderr, "Error initaiting UE MIB decoder\n"); exit(-1); } - if (prach_init(&prach, srslte_symbol_sz(cell.nof_prb), 0, 0, false, 1)) { + if (srslte_prach_init(&prach, srslte_symbol_sz(cell.nof_prb), 0, 0, false, 1)) { fprintf(stderr, "Error initializing PRACH\n"); exit(-1); } prach_buffer_len = prach.N_seq + prach.N_cp; - prach_buffer = vec_malloc(prach_buffer_len*sizeof(cf_t)); + prach_buffer = srslte_vec_malloc(prach_buffer_len*sizeof(cf_t)); if(!prach_buffer) { perror("maloc"); exit(-1); } - if(prach_gen(&prach, prog_args.preamble_idx, 0, prog_args.beta_prach, prach_buffer)){ + if(srslte_prach_gen(&prach, prog_args.preamble_idx, 0, prog_args.beta_prach, prach_buffer)){ fprintf(stderr, "Error generating prach sequence\n"); return -1; } - if (ue_ul_init(&ue_ul, cell)) { + if (srslte_ue_ul_init(&ue_ul, cell)) { fprintf(stderr, "Error initiating UE UL\n"); exit(-1); } - pusch_hopping_cfg_t hop_cfg; - bzero(&hop_cfg, sizeof(pusch_hopping_cfg_t)); + srslte_pusch_hopping_cfg_t hop_cfg; + bzero(&hop_cfg, sizeof(srslte_pusch_hopping_cfg_t)); srslte_refsignal_drms_pusch_cfg_t drms_cfg; bzero(&drms_cfg, sizeof(srslte_refsignal_drms_pusch_cfg_t)); drms_cfg.beta_pusch = 1.0; @@ -404,16 +404,16 @@ int main(int argc, char **argv) { drms_cfg.cyclic_shift = 0; drms_cfg.cyclic_shift_for_drms = 0; drms_cfg.en_drms_2 = false; - ue_ul_set_pusch_cfg(&ue_ul, &drms_cfg, &hop_cfg); + srslte_ue_ul_set_pusch_cfg(&ue_ul, &drms_cfg, &hop_cfg); - cf_t *ul_signal = vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); + cf_t *ul_signal = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); if (!ul_signal) { perror("malloc"); exit(-1); } bzero(ul_signal, sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); - if (ue_dl_init(&ue_dl, cell)) { + if (srs_ue_dl_init(&ue_dl, cell)) { fprintf(stderr, "Error initiating UE downlink processing module\n"); exit(-1); } @@ -423,7 +423,7 @@ int main(int argc, char **argv) { #ifdef use_usrp - if (ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper_timed, uhd)) { + if (srslte_ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper_timed, uhd)) { fprintf(stderr, "Error initiating ue_sync\n"); exit(-1); } @@ -445,9 +445,9 @@ int main(int argc, char **argv) { while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) { #ifdef kk - ret = ue_sync_get_buffer(&ue_sync, &sf_buffer); + ret = srslte_ue_sync_get_buffer(&ue_sync, &sf_buffer); if (ret < 0) { - fprintf(stderr, "Error calling ue_sync_work()\n"); + fprintf(stderr, "Error calling srslte_ue_sync_work()\n"); } #else ret = 1; @@ -455,28 +455,28 @@ int main(int argc, char **argv) { cf_t dummy[4]; #endif - /* ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */ + /* srslte_ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */ if (ret == 1) { if (state != RECV_RAR) { /* Run FFT for all subframe data */ - srslte_fft_run_sf(&ue_dl.fft, sf_buffer, ue_dl.sf_symbols); + srslte_ofdm_tx_sf(&ue_dl.fft, sf_buffer, ue_dl.sf_symbols); /* Get channel estimates for each port */ - srslte_chest_dl_estimate(&ue_dl.chest, ue_dl.sf_symbols, ue_dl.ce, ue_sync_get_sfidx(&ue_sync)); + srslte_chest_dl_estimate(&ue_dl.chest, ue_dl.sf_symbols, ue_dl.ce, srslte_ue_sync_get_sfidx(&ue_sync)); } if (sf_cnt > 1000) { switch (state) { case DECODE_MIB: - if (ue_sync_get_sfidx(&ue_sync) == 0) { - pbch_decode_reset(&ue_mib.pbch); - n = ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset); + if (srslte_ue_sync_get_sfidx(&ue_sync) == 0) { + decode_reset(&ue_mib.pbch); + n = srslte_ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset); if (n < 0) { fprintf(stderr, "Error decoding UE MIB\n"); exit(-1); - } else if (n == MIB_FOUND) { - bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN); + } else if (n == SRSLTE_UE_MIB_FOUND) { + srslte_bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN); bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn); printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset); sfn = (sfn + sfn_offset)%1024; @@ -487,8 +487,8 @@ int main(int argc, char **argv) { case SEND_PRACH: #ifdef kk - if (((sfn%2) == 1) && (ue_sync_get_sfidx(&ue_sync) == 1)) { - ue_sync_get_last_timestamp(&ue_sync, &uhd_time); + if (((sfn%2) == 1) && (srslte_ue_sync_get_sfidx(&ue_sync) == 1)) { + srslte_ue_sync_get_last_timestamp(&ue_sync, &uhd_time); srslte_timestamp_copy(&next_tx_time, &uhd_time); srslte_timestamp_add(&next_tx_time, 0, 0.01); // send next frame (10 ms) @@ -508,7 +508,7 @@ int main(int argc, char **argv) { srslte_timestamp_copy(&tx_time, &rx_time); printf("Transmitting PRACH...\n"); - vec_save_file("prach_tx", prach_buffers[7], prach_buffer_len*sizeof(cf_t)); + srslte_vec_save_file("srslte_prach_tx", prach_buffers[7], prach_buffer_len*sizeof(cf_t)); while(1) { srslte_timestamp_add(&tx_time, 0, 0.001); // send every (10 ms) cuhd_send_timed(uhd, prach_buffers[7], prach_buffer_len, @@ -520,9 +520,9 @@ int main(int argc, char **argv) { case RECV_RAR: #ifdef kk - if ((sfn == rar_window_start && ue_sync_get_sfidx(&ue_sync) > 3) || sfn > rar_window_start) { - printf("Looking for RAR in sfn: %d sf_idx: %d\n", sfn, ue_sync_get_sfidx(&ue_sync)); - n = ue_dl_decode_rnti(&ue_dl, sf_buffer, data_rx, ue_sync_get_sfidx(&ue_sync), ra_rnti); + if ((sfn == rar_window_start && srslte_ue_sync_get_sfidx(&ue_sync) > 3) || sfn > rar_window_start) { + printf("Looking for RAR in sfn: %d sf_idx: %d\n", sfn, srslte_ue_sync_get_sfidx(&ue_sync)); + n = srs_ue_dl_decode_rnti(&ue_dl, sf_buffer, data_rx, srslte_ue_sync_get_sfidx(&ue_sync), ra_rnti); if (n < 0) { fprintf(stderr, "Error decoding UE DL\n");fflush(stdout); } else if (n > 0) { @@ -535,14 +535,14 @@ int main(int argc, char **argv) { //cuhd_flush_buffer(uhd); rar_msg_fprint(stdout, &rar_msg); - dci_rar_to_ra_ul(rar_msg.rba, rar_msg.mcs, rar_msg.hopping_flag, cell.nof_prb, &ra_pusch); - ra_pusch_fprint(stdout, &ra_pusch, cell.nof_prb); + srslte_dci_rar_to_ra_ul(rar_msg.rba, rar_msg.mcs, rar_msg.hopping_flag, cell.nof_prb, &ra_pusch); + srslte_ra_pusch_fprint(stdout, &ra_pusch, cell.nof_prb); - ra_ul_alloc(&ra_pusch.prb_alloc, &ra_pusch, 0, cell.nof_prb); + srslte_ra_ul_alloc(&ra_pusch.prb_alloc, &ra_pusch, 0, cell.nof_prb); - ue_sync_get_last_timestamp(&ue_sync, &uhd_time); + srslte_ue_sync_get_last_timestamp(&ue_sync, &uhd_time); - bit_pack_vector((uint8_t*) conn_request_msg, data, ra_pusch.mcs.tbs); + srslte_bit_pack_vector((uint8_t*) conn_request_msg, data, ra_pusch.mcs.tbs); uint32_t n_ta = srssrslte_N_ta_new_rar(rar_msg.timing_adv_cmd); printf("ta: %d, n_ta: %d\n", rar_msg.timing_adv_cmd, n_ta); @@ -554,15 +554,15 @@ int main(int argc, char **argv) { const uint32_t rv[N_TX]={0,2,3,1,0}; for (int i=0; i 0) { printf("Received ConnectionSetup len: %d.\n", n); - vec_fprint_hex(stdout, data_rx, n); + srslte_vec_fprint_hex(stdout, data_rx, n); } else { conn_setup_trial++; if (conn_setup_trial == 20) { @@ -651,7 +651,7 @@ int main(int argc, char **argv) { break; } - if (ue_sync_get_sfidx(&ue_sync) == 9) { + if (srslte_ue_sync_get_sfidx(&ue_sync) == 9) { sfn++; if (sfn == 1024) { sfn = 0; @@ -662,17 +662,17 @@ int main(int argc, char **argv) { } else if (ret == 0) { printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r", - sync_get_peak_value(&ue_sync.sfind), + srslte_sync_get_peak_value(&ue_sync.sfind), ue_sync.frame_total_cnt, ue_sync.state); } sf_cnt++; } // Main loop - ue_dl_free(&ue_dl); - ue_sync_free(&ue_sync); + srs_ue_dl_free(&ue_dl); + srslte_ue_sync_free(&ue_sync); - ue_mib_free(&ue_mib); + srslte_ue_mib_free(&ue_mib); cuhd_close(uhd); printf("\nBye\n"); exit(0); diff --git a/srslte/examples/synch_file.c b/srslte/examples/synch_file.c index d43f204ea..9cb5a97c9 100644 --- a/srslte/examples/synch_file.c +++ b/srslte/examples/synch_file.c @@ -52,7 +52,7 @@ void usage(char *prog) { printf("\t-N out_N_id_2 [Default %d]\n", out_N_id_2); printf("\t-f force_N_id_2 [Default %d]\n", force_N_id_2); printf("\t-c force_cfo [Default disabled]\n"); - printf("\t-v verbose\n"); + printf("\t-v srslte_verbose\n"); } void parse_args(int argc, char **argv) { @@ -87,7 +87,7 @@ void parse_args(int argc, char **argv) { force_cfo = atof(argv[optind]); break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(argv[0]); @@ -103,9 +103,9 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { srslte_filesource_t fsrc; srslte_filesink_t fsink; - pss_synch_t pss[3]; // One for each N_id_2 - sss_synch_t sss[3]; // One for each N_id_2 - cfo_t cfocorr; + srslte_pss_synch_t pss[3]; // One for each N_id_2 + srslte_sss_synch_t sss[3]; // One for each N_id_2 + srslte_cfo_t cfocorr; int peak_pos[3]; float *cfo; float peak_value[3]; @@ -153,7 +153,7 @@ int main(int argc, char **argv) { exit(-1); } - if (cfo_init(&cfocorr, frame_length)) { + if (srslte_cfo_init(&cfocorr, frame_length)) { fprintf(stderr, "Error initiating CFO\n"); return -1; } @@ -164,19 +164,19 @@ int main(int argc, char **argv) { * a) requries more memory but has less latency and is paralellizable. */ for (N_id_2=0;N_id_2<3;N_id_2++) { - if (pss_synch_init(&pss[N_id_2], frame_length)) { + if (srslte_pss_synch_init(&pss[N_id_2], frame_length)) { fprintf(stderr, "Error initializing PSS object\n"); exit(-1); } - if (pss_synch_set_N_id_2(&pss[N_id_2], N_id_2)) { + if (srslte_pss_synch_set_N_id_2(&pss[N_id_2], N_id_2)) { fprintf(stderr, "Error initializing N_id_2\n"); exit(-1); } - if (sss_synch_init(&sss[N_id_2], 128)) { + if (srslte_sss_synch_init(&sss[N_id_2], 128)) { fprintf(stderr, "Error initializing SSS object\n"); exit(-1); } - if (sss_synch_set_N_id_2(&sss[N_id_2], N_id_2)) { + if (srslte_sss_synch_set_N_id_2(&sss[N_id_2], N_id_2)) { fprintf(stderr, "Error initializing N_id_2\n"); exit(-1); } @@ -195,15 +195,15 @@ int main(int argc, char **argv) { gettimeofday(&tdata[1], NULL); if (force_cfo != CFO_AUTO) { - cfo_correct(&cfocorr, input, input, force_cfo/128); + srslte_cfo_correct(&cfocorr, input, input, force_cfo/128); } if (force_N_id_2 != -1) { N_id_2 = force_N_id_2; - peak_pos[N_id_2] = pss_synch_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]); + peak_pos[N_id_2] = srslte_pss_synch_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]); } else { for (N_id_2=0;N_id_2<3;N_id_2++) { - peak_pos[N_id_2] = pss_synch_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]); + peak_pos[N_id_2] = srslte_pss_synch_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]); } float max_value=-99999; N_id_2=-1; @@ -221,13 +221,13 @@ int main(int argc, char **argv) { 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], + srslte_sss_synch_m0m1_diff(&sss[N_id_2], &input[sss_idx], &m0, &m0_value, &m1, &m1_value); - cfo[frame_cnt] = pss_synch_cfo_compute(&pss[N_id_2], &input[peak_pos[N_id_2]-128]); + cfo[frame_cnt] = srslte_pss_synch_cfo_compute(&pss[N_id_2], &input[peak_pos[N_id_2]-128]); printf("\t%d\t%d\t%d\t%d\t%.3f\t\t%3d\t%d\t%d\t%.3f\n", - frame_cnt,N_id_2, sss_synch_N_id_1(&sss[N_id_2], m0, m1), - sss_synch_subframe(m0, m1), peak_value[N_id_2], + frame_cnt,N_id_2, srslte_sss_synch_N_id_1(&sss[N_id_2], m0, m1), + srslte_sss_synch_subframe(m0, m1), peak_value[N_id_2], peak_pos[N_id_2], m0, m1, cfo[frame_cnt]); } @@ -255,8 +255,8 @@ int main(int argc, char **argv) { printf("Average CFO: %.3f\n", cfo_mean); for (N_id_2=0;N_id_2<3;N_id_2++) { - pss_synch_free(&pss[N_id_2]); - sss_synch_free(&sss[N_id_2]); + srslte_pss_synch_free(&pss[N_id_2]); + srslte_sss_synch_free(&sss[N_id_2]); } srslte_filesource_free(&fsrc); diff --git a/srslte/include/srslte/ch_estimation/chest_dl.h b/srslte/include/srslte/ch_estimation/chest_dl.h index 4a6ebe162..978bffb40 100644 --- a/srslte/include/srslte/ch_estimation/chest_dl.h +++ b/srslte/include/srslte/ch_estimation/chest_dl.h @@ -35,7 +35,6 @@ #include "srslte/config.h" #include "srslte/resampling/interp.h" -#include "srslte/filter/filter2d.h" #include "srslte/ch_estimation/refsignal_dl.h" #include "srslte/common/phy_common.h" @@ -68,7 +67,7 @@ typedef struct { cf_t *tmp_timeavg[SRSLTE_CHEST_MAX_FILTER_TIME_LEN]; cf_t *tmp_timeavg_mult; - srslte_interp_linvec_t srslte_interp_linvec; + srslte_interp_linsrslte_vec_t srslte_interp_linvec; srslte_interp_lin_t srslte_interp_lin; float rssi[SRSLTE_MAX_PORTS]; diff --git a/srslte/include/srslte/ch_estimation/refsignal_ul.h b/srslte/include/srslte/ch_estimation/refsignal_ul.h index 1d3c00c8e..0be5ad77b 100644 --- a/srslte/include/srslte/ch_estimation/refsignal_ul.h +++ b/srslte/include/srslte/ch_estimation/refsignal_ul.h @@ -86,14 +86,14 @@ SRSLTE_API void srslte_refsignal_drms_pusch_put(srslte_refsignal_ul_t *q, uint32_t n_prb[2], cf_t *sf_symbols); -SRSLTE_API int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t *q, +SRSLTE_API int srslte_refsignal_dmrs_gen(srslte_refsignal_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *cfg, uint32_t nof_prb, uint32_t sf_idx, cf_t *r_pusch); SRSLTE_API int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, - pucch_cfg_t *cfg, + srslte_pucch_cfg_t *cfg, uint32_t sf_idx, uint32_t n_rb, cf_t *r_pucch) ; diff --git a/srslte/include/srslte/common/phy_common.h b/srslte/include/srslte/common/phy_common.h index 6e221ee63..b97c945b2 100644 --- a/srslte/include/srslte/common/phy_common.h +++ b/srslte/include/srslte/common/phy_common.h @@ -147,11 +147,16 @@ typedef struct SRSLTE_API { }srslte_cell_t; typedef enum SRSLTE_API { - SINGLE_ANTENNA,TX_DIVERSITY, SPATIAL_MULTIPLEX + SRSLTE_MIMO_TYPE_SINGLE_ANTENNA, + SRSLTE_MIMO_TYPE_TX_DIVERSITY, + SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX } srslte_mimo_type_t; typedef enum SRSLTE_API { - LTE_BPSK = 0, LTE_QPSK = 1, LTE_QAM16 = 2, LTE_QAM64 = 3 + SRSLTE_MOD_BPSK = 0, + SRSLTE_MOD_QPSK, + SRSLTE_MOD_16QAM, + SRSLTE_MOD_64QAM } srslte_mod_t; typedef struct SRSLTE_API { @@ -160,7 +165,13 @@ typedef struct SRSLTE_API { } srslte_earfcn_t; enum band_geographical_area { - ALL, NAR, APAC, EMEA, JAPAN, CALA, NA + SRSLTE_BAND_GEO_AREA_ALL, + SRSLTE_BAND_GEO_AREA_NAR, + SRSLTE_BAND_GEO_AREA_APAC, + SRSLTE_BAND_GEO_AREA_EMEA, + SRSLTE_BAND_GEO_AREA_JAPAN, + SRSLTE_BAND_GEO_AREA_CALA, + SRSLTE_BAND_GEO_AREA_NA }; SRSLTE_API bool srslte_cell_isvalid(srslte_cell_t *cell); diff --git a/srslte/include/srslte/utils/dft.h b/srslte/include/srslte/dft/dft.h similarity index 54% rename from srslte/include/srslte/utils/dft.h rename to srslte/include/srslte/dft/dft.h index 49194195f..2e2981dd8 100644 --- a/srslte/include/srslte/utils/dft.h +++ b/srslte/include/srslte/dft/dft.h @@ -46,12 +46,12 @@ */ typedef enum { - COMPLEX, REAL -}dft_mode_t; + SRSLTE_DFT_COMPLEX, SRSLTE_REAL +}srslte_dft_mode_t; typedef enum { - FORWARD, BACKWARD -}dft_dir_t; + SRSLTE_DFT_FORWARD, SRSLTE_DFT_BACKWARD +}srslte_dft_dir_t; typedef struct SRSLTE_API { int size; // DFT length @@ -63,33 +63,56 @@ typedef struct SRSLTE_API { bool db; // Provide output in dB? bool norm; // Normalize output? bool dc; // Handle insertion/removal of null DC carrier internally? - dft_dir_t dir; // Forward/Backward - dft_mode_t mode; // Complex/Real + srslte_dft_dir_t dir; // Forward/Backward + srslte_dft_mode_t mode; // Complex/Real }srslte_dft_plan_t; -typedef _Complex float dft_c_t; -typedef float dft_r_t; +typedef _Complex float cf_t; /* Create DFT plans */ -SRSLTE_API int dft_plan(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir, - dft_mode_t type); -SRSLTE_API int dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir); -SRSLTE_API int dft_plan_r(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir); -SRSLTE_API void dft_plan_free(srslte_dft_plan_t *plan); +SRSLTE_API int srslte_dft_plan(srslte_dft_plan_t *plan, + int dft_points, + srslte_dft_dir_t dir, + srslte_dft_mode_t type); + +SRSLTE_API int srslte_dft_plan_c(srslte_dft_plan_t *plan, + int dft_points, + srslte_dft_dir_t dir); + +SRSLTE_API int srslte_dft_plan_r(srslte_dft_plan_t *plan, + int dft_points, + srslte_dft_dir_t dir); + +SRSLTE_API void srslte_dft_plan_free(srslte_dft_plan_t *plan); /* Set options */ -SRSLTE_API void dft_plan_set_mirror(srslte_dft_plan_t *plan, bool val); -SRSLTE_API void dft_plan_set_db(srslte_dft_plan_t *plan, bool val); -SRSLTE_API void dft_plan_set_norm(srslte_dft_plan_t *plan, bool val); -SRSLTE_API void dft_plan_set_dc(srslte_dft_plan_t *plan, bool val); +SRSLTE_API void srslte_dft_plan_set_mirror(srslte_dft_plan_t *plan, + bool val); + +SRSLTE_API void srslte_dft_plan_set_db(srslte_dft_plan_t *plan, + bool val); + +SRSLTE_API void srslte_dft_plan_set_norm(srslte_dft_plan_t *plan, + bool val); + +SRSLTE_API void srslte_dft_plan_set_dc(srslte_dft_plan_t *plan, + bool val); /* Compute DFT */ -SRSLTE_API void dft_run(srslte_dft_plan_t *plan, void *in, void *out); -SRSLTE_API void dft_run_c(srslte_dft_plan_t *plan, dft_c_t *in, dft_c_t *out); -SRSLTE_API void dft_run_r(srslte_dft_plan_t *plan, dft_r_t *in, dft_r_t *out); +SRSLTE_API void srslte_dft_run(srslte_dft_plan_t *plan, + void *in, + void *out); + +SRSLTE_API void srslte_dft_run_c(srslte_dft_plan_t *plan, + cf_t *in, + cf_t *out); + +SRSLTE_API void srslte_dft_run_r(srslte_dft_plan_t *plan, + float *in, + float *out); #endif // DFT_H_ diff --git a/srslte/include/srslte/filter/dft_precoding.h b/srslte/include/srslte/dft/dft_precoding.h similarity index 79% rename from srslte/include/srslte/filter/dft_precoding.h rename to srslte/include/srslte/dft/dft_precoding.h index d13a508bb..a3c60d02a 100644 --- a/srslte/include/srslte/filter/dft_precoding.h +++ b/srslte/include/srslte/dft/dft_precoding.h @@ -31,7 +31,7 @@ #include "srslte/config.h" #include "srslte/common/phy_common.h" -#include "srslte/utils/dft.h" +#include "srslte/dft/dft.h" typedef _Complex float cf_t; @@ -42,22 +42,22 @@ typedef struct SRSLTE_API { srslte_dft_plan_t dft_plan[SRSLTE_MAX_PRB]; srslte_dft_plan_t idft_plan[SRSLTE_MAX_PRB]; -}srslte_srslte_dft_precoding_t; +}srslte_dft_precoding_t; -SRSLTE_API int srslte_srslte_dft_precoding_init(srslte_srslte_dft_precoding_t *q, +SRSLTE_API int srslte_dft_precoding_init(srslte_dft_precoding_t *q, uint32_t max_prb); -SRSLTE_API void srslte_srslte_dft_precoding_free(srslte_srslte_dft_precoding_t *q); +SRSLTE_API void srslte_dft_precoding_free(srslte_dft_precoding_t *q); -SRSLTE_API bool srslte_srslte_dft_precoding_valid_prb(uint32_t nof_prb); +SRSLTE_API bool srslte_dft_precoding_valid_prb(uint32_t nof_prb); -SRSLTE_API int srslte_dft_precoding(srslte_srslte_dft_precoding_t *q, +SRSLTE_API int srslte_dft_precoding(srslte_dft_precoding_t *q, cf_t *input, cf_t *output, uint32_t nof_prb, uint32_t nof_symbols); -SRSLTE_API int srslte_dft_predecoding(srslte_srslte_dft_precoding_t *q, +SRSLTE_API int srslte_dft_predecoding(srslte_dft_precoding_t *q, cf_t *input, cf_t *output, uint32_t nof_prb, diff --git a/srslte/include/srslte/common/fft.h b/srslte/include/srslte/dft/ofdm.h similarity index 74% rename from srslte/include/srslte/common/fft.h rename to srslte/include/srslte/dft/ofdm.h index 64030a450..0dad1dcf6 100644 --- a/srslte/include/srslte/common/fft.h +++ b/srslte/include/srslte/dft/ofdm.h @@ -35,7 +35,7 @@ #include "srslte/config.h" #include "srslte/common/phy_common.h" -#include "srslte/utils/dft.h" +#include "srslte/dft/dft.h" typedef _Complex float cf_t; /* this is only a shortcut */ @@ -52,40 +52,42 @@ typedef struct SRSLTE_API{ bool freq_shift; cf_t *shift_buffer; -}srslte_fft_t; +}srslte_ofdm_t; -SRSLTE_API int srslte_fft_init(srslte_fft_t *q, +SRSLTE_API int srslte_ofdm_tx_init(srslte_ofdm_t *q, srslte_cp_t cp_type, uint32_t nof_prb); -SRSLTE_API void srslte_fft_free(srslte_fft_t *q); +SRSLTE_API void srslte_ofdm_tx_free(srslte_ofdm_t *q); -SRSLTE_API void srslte_fft_run_slot(srslte_fft_t *q, +SRSLTE_API void srslte_ofdm_tx_slot(srslte_ofdm_t *q, cf_t *input, cf_t *output); -SRSLTE_API void srslte_fft_run_sf(srslte_fft_t *q, +SRSLTE_API void srslte_ofdm_tx_sf(srslte_ofdm_t *q, cf_t *input, cf_t *output); -SRSLTE_API int lte_ifft_init(srslte_fft_t *q, - srslte_cp_t cp_type, - uint32_t nof_prb); -SRSLTE_API void lte_ifft_free(srslte_fft_t *q); -SRSLTE_API void lte_ifft_run_slot(srslte_fft_t *q, +SRSLTE_API int srslte_ofdm_rx_init(srslte_ofdm_t *q, + srslte_cp_t cp_type, + uint32_t nof_prb); + +SRSLTE_API void srslte_ofdm_rx_free(srslte_ofdm_t *q); + +SRSLTE_API void srslte_ofdm_rx_slot(srslte_ofdm_t *q, cf_t *input, cf_t *output); -SRSLTE_API void lte_ifft_run_sf(srslte_fft_t *q, +SRSLTE_API void srslte_ofdm_rx_sf(srslte_ofdm_t *q, cf_t *input, cf_t *output); -SRSLTE_API int srslte_fft_set_freq_shift(srslte_fft_t *q, +SRSLTE_API int srslte_ofdm_set_freq_shift(srslte_ofdm_t *q, float freq_shift); -SRSLTE_API void srslte_fft_set_normalize(srslte_fft_t *q, +SRSLTE_API void srslte_ofdm_set_normalize(srslte_ofdm_t *q, bool normalize_enable); #endif diff --git a/srslte/include/srslte/filter/filter2d.h b/srslte/include/srslte/filter/filter2d.h deleted file mode 100644 index ac91c99b3..000000000 --- a/srslte/include/srslte/filter/filter2d.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2014 The srsLTE Developers. See the - * COPYRIGHT file at the top-level directory of this distribution. - * - * \section LICENSE - * - * This file is part of the srsLTE library. - * - * srsLTE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsLTE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * A copy of the GNU Lesser General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - - - -#ifndef FILTER2D_ -#define FILTER2D_ - -#include "srslte/config.h" -#include - -/* 2-D real filter of complex input - * - */ -typedef _Complex float cf_t; - -typedef struct SRSLTE_API{ - uint32_t sztime; // Output signal size in the time domain - uint32_t szfreq; // Output signal size in the freq domain - uint32_t ntime; // 2-D Filter size in time domain - uint32_t nfreq; // 2-D Filter size in frequency domain - float **taps; // 2-D filter coefficients - float norm; //normalization factor - cf_t *output; // Output signal -} srslte_filter2d_t; - -SRSLTE_API int srslte_filter2d_init (srslte_filter2d_t* q, - float **taps, - uint32_t ntime, - uint32_t nfreq, - uint32_t sztime, - uint32_t szfreq); - -SRSLTE_API int srslte_filter2d_init_ones (srslte_filter2d_t* q, - uint32_t ntime, - uint32_t nfreq, - uint32_t sztime, - uint32_t szfreq); - -SRSLTE_API void srslte_filter2d_free(srslte_filter2d_t *q); - -SRSLTE_API void srslte_filter2d_step(srslte_filter2d_t *q); - -SRSLTE_API void srslte_filter2d_reset(srslte_filter2d_t *q); - -SRSLTE_API void srslte_filter2d_add(srslte_filter2d_t *q, - cf_t h, - uint32_t time_idx, - uint32_t freq_idx); - -SRSLTE_API void srslte_filter2d_add_out(srslte_filter2d_t *q, cf_t x, int time_idx, int freq_idx); - -SRSLTE_API void srslte_filter2d_get_symbol(srslte_filter2d_t *q, - uint32_t nsymbol, - cf_t *output); -#endif // FILTER2D_ diff --git a/srslte/include/srslte/mimo/precoding.h b/srslte/include/srslte/mimo/precoding.h index fb8482915..40086865a 100644 --- a/srslte/include/srslte/mimo/precoding.h +++ b/srslte/include/srslte/mimo/precoding.h @@ -29,6 +29,7 @@ #define PRECODING_H_ #include "srslte/config.h" +#include "srslte/common/phy_common.h" typedef _Complex float cf_t; @@ -47,59 +48,59 @@ typedef struct { float *z_real; float *z_imag; uint32_t max_frame_len; -}precoding_t; +} srslte_precoding_t; -SRSLTE_API int precoding_init(precoding_t *q, - uint32_t max_frame_len); +SRSLTE_API int srslte_precoding_init(srslte_precoding_t *q, + uint32_t max_frame_len); -SRSLTE_API void precoding_free(precoding_t *q); +SRSLTE_API void srslte_precoding_free(srslte_precoding_t *q); /* Generates the vector "y" from the input vector "x" */ -SRSLTE_API int precoding_single(precoding_t *q, - cf_t *x, - cf_t *y, - int nof_symbols); - -SRSLTE_API int precoding_diversity(precoding_t *q, - 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[SRSLTE_MAX_LAYERS], - cf_t *y[SRSLTE_MAX_PORTS], - int nof_layers, - int nof_ports, - int nof_symbols, - srslte_mimo_type_t type); +SRSLTE_API int srslte_precoding_single(srslte_precoding_t *q, + cf_t *x, + cf_t *y, + int nof_symbols); + +SRSLTE_API int srslte_precoding_diversity(srslte_precoding_t *q, + cf_t *x[SRSLTE_MAX_LAYERS], + cf_t *y[SRSLTE_MAX_PORTS], + int nof_ports, int nof_symbols); + +SRSLTE_API int srslte_precoding_type(srslte_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); /* Estimates the vector "x" based on the received signal "y" and the channel estimates "h" */ -SRSLTE_API int predecoding_single(precoding_t *q, - cf_t *y, - cf_t *h, - cf_t *x, - int nof_symbols, - float noise_estimate); - -SRSLTE_API 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); - -SRSLTE_API 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); +SRSLTE_API int srslte_predecoding_single(srslte_precoding_t *q, + cf_t *y, + cf_t *h, + cf_t *x, + int nof_symbols, + float noise_estimate); + +SRSLTE_API int srslte_predecoding_diversity(srslte_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); + +SRSLTE_API int srslte_predecoding_type(srslte_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); #endif /* PRECODING_H_ */ diff --git a/srslte/include/srslte/modem/demod_hard.h b/srslte/include/srslte/modem/demod_hard.h index c09295b12..b388b0958 100644 --- a/srslte/include/srslte/modem/demod_hard.h +++ b/srslte/include/srslte/modem/demod_hard.h @@ -39,19 +39,23 @@ typedef _Complex float cf_t; typedef struct SRSLTE_API { srslte_mod_t mod; /* In this implementation, mapping table is hard-coded */ -}demod_hard_t; +}srslte_demod_hard_t; -SRSLTE_API void demod_hard_init(demod_hard_t* q); -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); +SRSLTE_API void srslte_demod_hard_init(srslte_demod_hard_t* q); +SRSLTE_API void srslte_demod_hard_table_set(srslte_demod_hard_t* q, + srslte_mod_t mod); +SRSLTE_API int srslte_demod_hard_demodulate(srslte_demod_hard_t* q, + cf_t* symbols, + uint8_t *bits, + uint32_t nsymbols); /* High-level API */ typedef struct SRSLTE_API { - demod_hard_t obj; - struct demod_hard_init { + srslte_demod_hard_t obj; + struct srslte_demod_hard_init { srslte_mod_t std; // Symbol mapping standard (see modem_table.h) } init; @@ -60,11 +64,11 @@ typedef struct SRSLTE_API { uint8_t* output; int out_len; -}demod_hard_hl; +}srslte_demod_hard_hl; -SRSLTE_API int demod_hard_initialize(demod_hard_hl* hl); -SRSLTE_API int demod_hard_work(demod_hard_hl* hl); -SRSLTE_API int demod_hard_stop(demod_hard_hl* hl); +SRSLTE_API int srslte_demod_hard_initialize(srslte_demod_hard_hl* hl); +SRSLTE_API int srslte_demod_hard_work(srslte_demod_hard_hl* hl); +SRSLTE_API int srslte_demod_hard_stop(srslte_demod_hard_hl* hl); #endif // DEMOD_HARD_ diff --git a/srslte/include/srslte/modem/demod_soft.h b/srslte/include/srslte/modem/demod_soft.h index b5346feee..5c0f53dd9 100644 --- a/srslte/include/srslte/modem/demod_soft.h +++ b/srslte/include/srslte/modem/demod_soft.h @@ -35,50 +35,65 @@ #include "srslte/config.h" #include "modem_table.h" -enum alg { EXACT, APPROX }; +typedef enum SRSLTE_API { + SRSLTE_DEMOD_SOFT_ALG_EXACT, + SRSLTE_DEMOD_SOFT_ALG_APPROX +} srslte_demod_soft_alg_t; typedef struct SRSLTE_API { float sigma; // noise power - enum alg alg_type; // soft demapping algorithm (EXACT or APPROX) - modem_table_t *table; // symbol mapping table (see modem_table.h) + srslte_demod_soft_alg_t alg_type; // soft demapping algorithm (SRSLTE_DEMOD_SOFT_ALG_EXACT or SRSLTE_DEMOD_SOFT_ALG_APPROX) + srslte_srslte_modem_table_t *table; // symbol mapping table (see modem_table.h) uint32_t *zones; float *dd; uint32_t max_symbols; -}demod_soft_t; +} srslte_demod_soft_t; -SRSLTE_API int demod_soft_init(demod_soft_t *q, uint32_t max_symbols); -SRSLTE_API void demod_soft_free(demod_soft_t *q); -SRSLTE_API void demod_soft_table_set(demod_soft_t *q, modem_table_t *table); -SRSLTE_API void demod_soft_alg_set(demod_soft_t *q, enum alg alg_type); -SRSLTE_API void demod_soft_sigma_set(demod_soft_t *q, float sigma); -SRSLTE_API int demod_soft_demodulate(demod_soft_t *q, const cf_t* symbols, float* llr, int nsymbols); +SRSLTE_API int srslte_demod_soft_init(srslte_demod_soft_t *q, + uint32_t max_symbols); + +SRSLTE_API void srslte_demod_soft_free(srslte_demod_soft_t *q); + +SRSLTE_API void srslte_demod_soft_table_set(srslte_demod_soft_t *q, + srslte_srslte_modem_table_t *table); + +SRSLTE_API void srslte_demod_soft_alg_set(srslte_demod_soft_t *q, + srslte_demod_soft_alg_t alg_type); + +SRSLTE_API void srslte_demod_soft_sigma_set(srslte_demod_soft_t *q, + float sigma); + +SRSLTE_API int srslte_demod_soft_demodulate(srslte_demod_soft_t *q, + const cf_t* symbols, + float* llr, + int nsymbols); /* High-level API */ typedef struct SRSLTE_API { - demod_soft_t obj; - modem_table_t table; + srslte_demod_soft_t obj; + srslte_srslte_modem_table_t table; - struct demod_soft_init{ + struct srslte_demod_soft_init{ srslte_mod_t std; // symbol mapping standard (see modem_table.h) } init; const cf_t* input; int in_len; - struct demod_soft_ctrl_in { + struct srslte_demod_soft_ctrl_in { float sigma; // Estimated noise variance - enum alg alg_type; // soft demapping algorithm (EXACT or APPROX) + srslte_demod_soft_alg_t alg_type; // soft demapping algorithm (SRSLTE_DEMOD_SOFT_ALG_EXACT or SRSLTE_DEMOD_SOFT_ALG_APPROX) }ctrl_in; float* output; int out_len; -}demod_soft_hl; +}srslte_demod_soft_hl; -SRSLTE_API int demod_soft_initialize(demod_soft_hl* hl); -SRSLTE_API int demod_soft_work(demod_soft_hl* hl); -SRSLTE_API int demod_soft_stop(demod_soft_hl* hl); +SRSLTE_API int srslte_demod_soft_initialize(srslte_demod_soft_hl* hl); +SRSLTE_API int srslte_demod_soft_work(srslte_demod_soft_hl* hl); +SRSLTE_API int srslte_demod_soft_stop(srslte_demod_soft_hl* hl); #endif // DEMOD_SOFT_ diff --git a/srslte/include/srslte/modem/mod.h b/srslte/include/srslte/modem/mod.h index 18445dc5e..d724e6ad2 100644 --- a/srslte/include/srslte/modem/mod.h +++ b/srslte/include/srslte/modem/mod.h @@ -37,24 +37,27 @@ typedef _Complex float cf_t; -SRSLTE_API int mod_modulate(modem_table_t* table, const uint8_t *bits, cf_t* symbols, uint32_t nbits); +SRSLTE_API int srslte_mod_modulate(srslte_srslte_modem_table_t* table, + uint8_t *bits, + cf_t* symbols, + uint32_t nbits); /* High-level API */ typedef struct SRSLTE_API { - modem_table_t obj; + srslte_srslte_modem_table_t obj; struct mod_init { srslte_mod_t std; // symbol mapping standard (see modem_table.h) } init; - const uint8_t* input; + uint8_t* input; int in_len; cf_t* output; int out_len; -}mod_hl; +}srslte_mod_hl; -SRSLTE_API int mod_initialize(mod_hl* hl); -SRSLTE_API int mod_work(mod_hl* hl); -SRSLTE_API int mod_stop(mod_hl* hl); +SRSLTE_API int mod_initialize(srslte_mod_hl* hl); +SRSLTE_API int mod_work(srslte_mod_hl* hl); +SRSLTE_API int mod_stop(srslte_mod_hl* hl); #endif // MOD_ diff --git a/srslte/include/srslte/modem/modem_table.h b/srslte/include/srslte/modem/modem_table.h index 82a1ff3d2..c4cb0184f 100644 --- a/srslte/include/srslte/modem/modem_table.h +++ b/srslte/include/srslte/modem/modem_table.h @@ -43,30 +43,30 @@ typedef struct SRSLTE_API { uint32_t min_idx[2][64][6]; /* NEW: for each constellation point zone (2, 4, 16, 64 for BPSK, QPSK, 16QAM, 64QAM) the 2x(1, 2, 4, and 6 closest constellation points) for each bit, respectively. */ uint32_t d_idx[64][7]; /* NEW: for each constellation point zone (2, 4, 16, 64 for BPSK, QPSK, 16QAM, 64QAM) the 2, 3, 5 and 7 indices to constellation points that need to be computed for any recevied symbol modulated as BPSK, QPSK, 16QAM, and 64QAM, respectively. */ -}soft_table_t; +}srslte_soft_table_t; typedef struct SRSLTE_API { cf_t* symbol_table; // bit-to-symbol mapping - soft_table_t soft_table; // symbol-to-bit mapping (used in soft demodulating) + srslte_soft_table_t soft_table; // symbol-to-bit mapping (used in soft demodulating) uint32_t nsymbols; // number of modulation symbols uint32_t nbits_x_symbol; // number of bits per symbol -}modem_table_t; +}srslte_srslte_modem_table_t; -SRSLTE_API void modem_table_init(modem_table_t* q); +SRSLTE_API void srslte_modem_table_init(srslte_srslte_modem_table_t* q); -SRSLTE_API void modem_table_free(modem_table_t* q); +SRSLTE_API void srslte_modem_table_free(srslte_srslte_modem_table_t* q); -SRSLTE_API void modem_table_reset(modem_table_t* q); +SRSLTE_API void srslte_modem_table_reset(srslte_srslte_modem_table_t* q); -SRSLTE_API int modem_table_set(modem_table_t* q, - cf_t* table, - soft_table_t *soft_table, - uint32_t nsymbols, - uint32_t nbits_x_symbol); +SRSLTE_API int srslte_modem_table_set(srslte_srslte_modem_table_t* q, + cf_t* table, + srslte_soft_table_t *soft_table, + uint32_t nsymbols, + uint32_t nbits_x_symbol); -SRSLTE_API int modem_table_lte(modem_table_t* q, - srslte_mod_t modulation, - bool compute_soft_demod); +SRSLTE_API int srslte_modem_table_lte(srslte_srslte_modem_table_t* q, + srslte_mod_t modulation, + bool compute_soft_demod); #endif // MODEM_TABLE_ diff --git a/srslte/include/srslte/phch/cqi.h b/srslte/include/srslte/phch/cqi.h index 01af1c3d3..ff2a14309 100644 --- a/srslte/include/srslte/phch/cqi.h +++ b/srslte/include/srslte/phch/cqi.h @@ -46,7 +46,7 @@ transmission mode 8 configured without PMI/RI reporting). */ typedef struct SRSLTE_API { uint8_t wideband_cqi; // 4-bit width uint32_t subband_diff_cqi; // 2N-bit width -} cqi_hl_subband_t; +} srslte_cqi_hl_subband_t; /* Table 5.2.2.6.3-1: Fields for channel quality information feedback for UE selected subband CQI reports @@ -56,7 +56,7 @@ typedef struct SRSLTE_API { uint8_t wideband_cqi; // 4-bit width uint8_t subband_diff_cqi; // 2-bit width uint32_t position_subband; // L-bit width -} cqi_ue_subband_t; +} srslte_cqi_ue_subband_t; /* Table 5.2.3.3.1-1: Fields for channel quality information feedback for wideband CQI reports (transmission mode 1, transmission mode 2, transmission mode 3, transmission mode 7 and @@ -65,29 +65,29 @@ This is for PUCCH Format 2 reports */ typedef struct SRSLTE_API { uint8_t wideband_cqi; // 4-bit width -} cqi_format2_wideband_t; +} srslte_cqi_format2_wideband_t; typedef struct SRSLTE_API { uint8_t subband_cqi; // 4-bit width uint8_t subband_label; // 1- or 2-bit width -} cqi_format2_subband_t; +} srslte_cqi_format2_subband_t; -SRSLTE_API int cqi_hl_subband_pack(cqi_hl_subband_t *msg, +SRSLTE_API int srslte_cqi_hl_subband_pack(srslte_cqi_hl_subband_t *msg, uint32_t N, uint8_t *buff, uint32_t buff_len); -SRSLTE_API int cqi_ue_subband_pack(cqi_ue_subband_t *msg, +SRSLTE_API int srslte_cqi_ue_subband_pack(srslte_cqi_ue_subband_t *msg, uint32_t L, uint8_t *buff, uint32_t buff_len); -SRSLTE_API int cqi_format2_wideband_pack(cqi_format2_wideband_t *msg, +SRSLTE_API int srslte_cqi_format2_wideband_pack(srslte_cqi_format2_wideband_t *msg, uint8_t *buff, uint32_t buff_len); -SRSLTE_API int cqi_format2_subband_pack(cqi_format2_subband_t *msg, +SRSLTE_API int srslte_cqi_format2_subband_pack(srslte_cqi_format2_subband_t *msg, uint8_t *buff, uint32_t buff_len); diff --git a/srslte/include/srslte/phch/dci.h b/srslte/include/srslte/phch/dci.h index a07330c6f..6695b6368 100644 --- a/srslte/include/srslte/phch/dci.h +++ b/srslte/include/srslte/phch/dci.h @@ -46,91 +46,100 @@ typedef _Complex float cf_t; #define DCI_MAX_BITS 57 typedef enum { - Format0, Format1, Format1A, Format1C, FormatError -} dci_format_t; + SRSLTE_DCI_FORMAT0, + SRSLTE_DCI_FORMAT1, + SRSLTE_DCI_FORMAT1A, + SRSLTE_DCI_FORMAT1C, + SRSLTE_DCI_FORMAT_ERROR +} srslte_dci_format_t; // Each type is for a different interface to packing/unpacking functions typedef struct SRSLTE_API { enum { - PUSCH_SCHED, PDSCH_SCHED, MCCH_CHANGE, TPC_COMMAND, RA_PROC_PDCCH + SRSLTE_DCI_MSG_TYPE_PUSCH_SCHED, + SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED, + SRSLTE_DCI_MSG_TYPE_MCCH_CHANGE, + SRSLTE_DCI_MSG_TYPE_TPC_COMMAND, + SRSLTE_DCI_MSG_TYPE_RA_PROC_PDCCH } type; - dci_format_t format; -}dci_msg_type_t; + srslte_dci_format_t format; +}srslte_dci_msg_type_t; typedef enum { - DCI_COMMON = 0, DCI_UE = 1 + SRSLTE_DCI_SPEC_COMMON_ = 0, + SRSLTE_DCI_SPEC_UE = 1 } dci_spec_t; typedef struct SRSLTE_API { uint32_t L; // Aggregation level uint32_t ncce; // Position of first CCE of the dci -} dci_location_t; +} srslte_dci_location_t; typedef struct SRSLTE_API { uint8_t data[DCI_MAX_BITS]; uint32_t nof_bits; -} dci_msg_t; +} srslte_dci_msg_t; /* Converts a received PDSCH DL scheduling DCI message * to ra structures ready to be passed to the harq setup function */ -SRSLTE_API int dci_msg_to_ra_dl(dci_msg_t *msg, - uint16_t msg_rnti, - srslte_cell_t cell, - uint32_t cfi, - ra_pdsch_t *ra_dl); - -SRSLTE_API int dci_msg_to_ra_ul(dci_msg_t *msg, - uint32_t nof_prb, - uint32_t n_rb_ho, - ra_pusch_t *ra_ul); - -SRSLTE_API int dci_rar_to_ra_ul(uint32_t rba, - uint32_t trunc_mcs, - bool hopping_flag, - uint32_t nof_prb, - ra_pusch_t *ra); - -SRSLTE_API dci_format_t dci_format_from_string(char *str); - -SRSLTE_API char* dci_format_string(dci_format_t format); - -SRSLTE_API int dci_location_set(dci_location_t *c, - uint32_t L, - uint32_t nCCE); - -SRSLTE_API bool dci_location_isvalid(dci_location_t *c); - -SRSLTE_API int dci_msg_get_type(dci_msg_t *msg, - dci_msg_type_t *type, - uint32_t nof_prb, - uint16_t msg_rnti); - -SRSLTE_API void dci_msg_type_fprint(FILE *f, - dci_msg_type_t type); - -// For dci_msg_type_t = PUSCH_SCHED -SRSLTE_API int dci_msg_pack_pusch(ra_pusch_t *data, - dci_msg_t *msg, - uint32_t nof_prb); - -SRSLTE_API int dci_msg_unpack_pusch(dci_msg_t *msg, - ra_pusch_t *data, - uint32_t nof_prb); - -// For dci_msg_type_t = PDSCH_SCHED -SRSLTE_API int dci_msg_pack_pdsch(ra_pdsch_t *data, - dci_msg_t *msg, - dci_format_t format, - uint32_t nof_prb, - bool srslte_crc_is_crnti); - -SRSLTE_API int dci_msg_unpack_pdsch(dci_msg_t *msg, - ra_pdsch_t *data, - uint32_t nof_prb, - bool srslte_crc_is_crnti); - -SRSLTE_API uint32_t dci_format_sizeof(dci_format_t format, - uint32_t nof_prb); +SRSLTE_API int srslte_dci_msg_to_ra_dl(srslte_dci_msg_t *msg, + uint16_t msg_rnti, + srslte_cell_t cell, + uint32_t cfi, + srslte_ra_pdsch_t *ra_dl); + +SRSLTE_API int srslte_dci_msg_to_ra_ul(srslte_dci_msg_t *msg, + uint32_t nof_prb, + uint32_t n_rb_ho, + srslte_ra_pusch_t *ra_ul); + +SRSLTE_API int srslte_dci_rar_to_ra_ul(uint32_t rba, + uint32_t trunc_mcs, + bool hopping_flag, + uint32_t nof_prb, + srslte_ra_pusch_t *ra); + +SRSLTE_API srslte_dci_format_t srslte_dci_format_from_string(char *str); + +SRSLTE_API char* srslte_dci_format_string(srslte_dci_format_t format); + +SRSLTE_API int srslte_dci_location_set(srslte_dci_location_t *c, + uint32_t L, + uint32_t nCCE); + +SRSLTE_API bool srslte_dci_location_isvalid(srslte_dci_location_t *c); + +SRSLTE_API int srslte_dci_msg_get_type(srslte_dci_msg_t *msg, + srslte_dci_msg_type_t *type, + uint32_t nof_prb, + uint16_t msg_rnti); + +SRSLTE_API void srslte_dci_msg_type_fprint(FILE *f, + srslte_dci_msg_type_t type); + +// For srslte_dci_msg_type_t = SRSLTE_DCI_MSG_TYPE_PUSCH_SCHED +SRSLTE_API int srslte_dci_msg_pack_pusch(srslte_ra_pusch_t *data, + srslte_dci_msg_t *msg, + uint32_t nof_prb); + +SRSLTE_API int srslte_dci_msg_unpack_pusch(srslte_dci_msg_t *msg, + srslte_ra_pusch_t *data, + uint32_t nof_prb); + +// For srslte_dci_msg_type_t = SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED +SRSLTE_API int srslte_dci_msg_pack_pdsch(srslte_ra_pdsch_t *data, + srslte_dci_msg_t *msg, + srslte_dci_format_t format, + uint32_t nof_prb, + bool srslte_crc_is_crnti); + +SRSLTE_API int srslte_dci_msg_unpack_pdsch(srslte_dci_msg_t *msg, + srslte_ra_pdsch_t *data, + uint32_t nof_prb, + bool srslte_crc_is_crnti); + +SRSLTE_API uint32_t srslte_dci_format_sizeof(srslte_dci_format_t format, + uint32_t nof_prb); #endif // DCI_ diff --git a/srslte/include/srslte/phch/harq.h b/srslte/include/srslte/phch/harq.h index 729ed1d56..254713598 100644 --- a/srslte/include/srslte/phch/harq.h +++ b/srslte/include/srslte/phch/harq.h @@ -34,21 +34,21 @@ #include "srslte/phch/ra.h" - struct cb_segm { + typedef struct SRSLTE_API { uint32_t F; uint32_t C; uint32_t K1; uint32_t K2; uint32_t C1; uint32_t C2; -}; +} srslte_harq_cbsegm_t; typedef struct SRSLTE_API { - ra_mcs_t mcs; + srslte_ra_mcs_t mcs; uint32_t rv; uint32_t sf_idx; - ra_dl_alloc_t dl_alloc; - ra_ul_alloc_t ul_alloc; + srslte_srslte_ra_dl_alloc_t dl_alloc; + srslte_srslte_ra_ul_alloc_t ul_alloc; srslte_cell_t cell; uint32_t nof_re; // Number of RE per subframe @@ -61,31 +61,31 @@ typedef struct SRSLTE_API { float **pdsch_w_buff_f; uint8_t **pdsch_w_buff_c; - struct cb_segm cb_segm; + srslte_harq_cbsegm_t cb_segm; -} harq_t; +} srslte_harq_t; -SRSLTE_API int harq_init(harq_t * q, - srslte_cell_t cell); +SRSLTE_API int srslte_harq_init(srslte_harq_t * q, + srslte_cell_t cell); -SRSLTE_API int harq_setup_dl(harq_t *p, - ra_mcs_t mcs, - uint32_t rv, - uint32_t sf_idx, - ra_dl_alloc_t *prb_alloc); +SRSLTE_API int srslte_harq_setup_dl(srslte_harq_t *p, + srslte_ra_mcs_t mcs, + uint32_t rv, + uint32_t sf_idx, + srslte_srslte_ra_dl_alloc_t *prb_alloc); -SRSLTE_API int harq_setup_ul(harq_t *p, - ra_mcs_t mcs, - uint32_t rv, - uint32_t sf_idx, - ra_ul_alloc_t *prb_alloc); +SRSLTE_API int srslte_harq_setup_ul(srslte_harq_t *p, + srslte_ra_mcs_t mcs, + uint32_t rv, + uint32_t sf_idx, + srslte_srslte_ra_ul_alloc_t *prb_alloc); -SRSLTE_API void harq_reset(harq_t *p); +SRSLTE_API void srslte_harq_reset(srslte_harq_t *p); -SRSLTE_API void harq_free(harq_t *p); +SRSLTE_API void srslte_harq_free(srslte_harq_t *p); -SRSLTE_API int codeblock_segmentation(struct cb_segm *s, - uint32_t tbs); +SRSLTE_API int srslte_harq_codeblock_segmentation(srslte_harq_cbsegm_t *s, + uint32_t tbs); #endif \ No newline at end of file diff --git a/srslte/include/srslte/phch/pbch.h b/srslte/include/srslte/phch/pbch.h index b9388a819..5b0316472 100644 --- a/srslte/include/srslte/phch/pbch.h +++ b/srslte/include/srslte/phch/pbch.h @@ -58,34 +58,34 @@ typedef struct SRSLTE_API { /* buffers */ cf_t *ce[SRSLTE_MAX_PORTS]; - cf_t *pbch_symbols[SRSLTE_MAX_PORTS]; - cf_t *pbch_x[SRSLTE_MAX_PORTS]; - cf_t *pbch_d; - float *pbch_llr; + cf_t *symbols[SRSLTE_MAX_PORTS]; + cf_t *x[SRSLTE_MAX_PORTS]; + cf_t *d; + float *llr; float *temp; - float pbch_rm_f[BCH_ENCODED_LEN]; - uint8_t *pbch_rm_b; + float rm_f[BCH_ENCODED_LEN]; + uint8_t *rm_b; uint8_t data[BCH_PAYLOADCRC_LEN]; uint8_t data_enc[BCH_ENCODED_LEN]; uint32_t frame_idx; /* tx & rx objects */ - modem_table_t mod; - demod_soft_t demod; - srslte_sequence_t seq_pbch; + srslte_srslte_modem_table_t mod; + srslte_demod_soft_t demod; + srslte_sequence_t seq; srslte_viterbi_t decoder; srslte_crc_t crc; srslte_convcoder_t encoder; - precoding_t precoding; + srslte_precoding_t precoding; -} pbch_t; +} srslte_pbch_t; -SRSLTE_API int pbch_init(pbch_t *q, +SRSLTE_API int srslte_pbch_init(srslte_pbch_t *q, srslte_cell_t cell); -SRSLTE_API void pbch_free(pbch_t *q); -SRSLTE_API int pbch_decode(pbch_t *q, +SRSLTE_API void srslte_pbch_free(srslte_pbch_t *q); +SRSLTE_API int srslte_pbch_decode(srslte_pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS], float noise_estimate, @@ -93,21 +93,21 @@ SRSLTE_API int pbch_decode(pbch_t *q, uint32_t *nof_tx_ports, uint32_t *sfn_offset); -SRSLTE_API int pbch_encode(pbch_t *q, +SRSLTE_API int srslte_pbch_encode(srslte_pbch_t *q, uint8_t bch_payload[BCH_PAYLOAD_LEN], cf_t *slot1_symbols[SRSLTE_MAX_PORTS]); -SRSLTE_API void pbch_decode_reset(pbch_t *q); +SRSLTE_API void srslte_pbch_decode_reset(srslte_pbch_t *q); -SRSLTE_API void pbch_mib_unpack(uint8_t *msg, +SRSLTE_API void srslte_pbch_mib_unpack(uint8_t *msg, srslte_cell_t *cell, uint32_t *sfn); -SRSLTE_API void pbch_mib_pack(srslte_cell_t *cell, +SRSLTE_API void srslte_pbch_mib_pack(srslte_cell_t *cell, uint32_t sfn, uint8_t *msg); -SRSLTE_API void pbch_mib_fprint(FILE *stream, +SRSLTE_API void srslte_pbch_mib_fprint(FILE *stream, srslte_cell_t *cell, uint32_t sfn, uint32_t cell_id); diff --git a/srslte/include/srslte/phch/pcfich.h b/srslte/include/srslte/phch/pcfich.h index 75fd0b74d..c2f04c202 100644 --- a/srslte/include/srslte/phch/pcfich.h +++ b/srslte/include/srslte/phch/pcfich.h @@ -48,13 +48,13 @@ typedef struct SRSLTE_API { int nof_symbols; /* handler to REGs resource mapper */ - regs_t *regs; + srslte_regs_t *regs; /* buffers */ cf_t ce[SRSLTE_MAX_PORTS][PCFICH_RE]; - cf_t pcfich_symbols[SRSLTE_MAX_PORTS][PCFICH_RE]; - cf_t pcfich_x[SRSLTE_MAX_PORTS][PCFICH_RE]; - cf_t pcfich_d[PCFICH_RE]; + cf_t symbols[SRSLTE_MAX_PORTS][PCFICH_RE]; + cf_t x[SRSLTE_MAX_PORTS][PCFICH_RE]; + cf_t d[PCFICH_RE]; // cfi table in floats float cfi_table_float[3][PCFICH_CFI_LEN]; @@ -66,20 +66,20 @@ typedef struct SRSLTE_API { float data_f[PCFICH_CFI_LEN]; /* tx & rx objects */ - modem_table_t mod; - demod_soft_t demod; - srslte_sequence_t seq_pcfich[SRSLTE_NSUBFRAMES_X_FRAME]; - precoding_t precoding; + srslte_srslte_modem_table_t mod; + srslte_demod_soft_t demod; + srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; + srslte_precoding_t precoding; -} pcfich_t; +} srslte_pcfich_t; -SRSLTE_API int pcfich_init(pcfich_t *q, - regs_t *regs, +SRSLTE_API int srslte_pcfich_init(srslte_pcfich_t *q, + srslte_regs_t *regs, srslte_cell_t cell); -SRSLTE_API void pcfich_free(pcfich_t *q); +SRSLTE_API void srslte_pcfich_free(srslte_pcfich_t *q); -SRSLTE_API int pcfich_decode(pcfich_t *q, +SRSLTE_API int srslte_pcfich_decode(srslte_pcfich_t *q, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, @@ -87,7 +87,7 @@ SRSLTE_API int pcfich_decode(pcfich_t *q, uint32_t *cfi, float *corr_result); -SRSLTE_API int pcfich_encode(pcfich_t *q, +SRSLTE_API int srslte_pcfich_encode(srslte_pcfich_t *q, uint32_t cfi, cf_t *sf_symbols[SRSLTE_MAX_PORTS], uint32_t subframe); diff --git a/srslte/include/srslte/phch/pdcch.h b/srslte/include/srslte/phch/pdcch.h index 534b97bbd..01fa0e209 100644 --- a/srslte/include/srslte/phch/pdcch.h +++ b/srslte/include/srslte/phch/pdcch.h @@ -47,7 +47,7 @@ typedef _Complex float cf_t; typedef enum SRSLTE_API { SEARCH_UE, SEARCH_COMMON -} pdcch_search_mode_t; +} srslte_pdcch_search_mode_t; /* PDCCH object */ @@ -57,70 +57,70 @@ typedef struct SRSLTE_API { uint32_t nof_cce; uint32_t max_bits; - regs_t *regs; + srslte_regs_t *regs; /* buffers */ cf_t *ce[SRSLTE_MAX_PORTS]; - cf_t *pdcch_symbols[SRSLTE_MAX_PORTS]; - cf_t *pdcch_x[SRSLTE_MAX_PORTS]; - cf_t *pdcch_d; - uint8_t *pdcch_e; - float pdcch_rm_f[3 * (DCI_MAX_BITS + 16)]; - float *pdcch_llr; + cf_t *symbols[SRSLTE_MAX_PORTS]; + cf_t *x[SRSLTE_MAX_PORTS]; + cf_t *d; + uint8_t *e; + float rm_f[3 * (DCI_MAX_BITS + 16)]; + float *llr; /* tx & rx objects */ - modem_table_t mod; - demod_soft_t demod; - srslte_sequence_t seq_pdcch[SRSLTE_NSUBFRAMES_X_FRAME]; + srslte_srslte_modem_table_t mod; + srslte_demod_soft_t demod; + srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_viterbi_t decoder; srslte_crc_t crc; - precoding_t precoding; + srslte_precoding_t precoding; -} pdcch_t; +} srslte_pdcch_t; -SRSLTE_API int pdcch_init(pdcch_t *q, - regs_t *regs, - srslte_cell_t cell); +SRSLTE_API int srslte_pdcch_init(srslte_pdcch_t *q, + srslte_regs_t *regs, + srslte_cell_t cell); -SRSLTE_API void pdcch_free(pdcch_t *q); +SRSLTE_API void srslte_pdcch_free(srslte_pdcch_t *q); /* Encoding function */ -SRSLTE_API int pdcch_encode(pdcch_t *q, - dci_msg_t *msg, - dci_location_t location, - uint16_t rnti, - cf_t *sf_symbols[SRSLTE_MAX_PORTS], - uint32_t nsubframe, - uint32_t cfi); - -/* Decoding functions: Extract the LLRs and save them in the pdcch_t object */ -SRSLTE_API int pdcch_extract_llr(pdcch_t *q, - cf_t *sf_symbols, - cf_t *ce[SRSLTE_MAX_PORTS], - float noise_estimate, - uint32_t nsubframe, - uint32_t cfi); - -/* Decoding functions: Try to decode a DCI message after calling pdcch_extract_llr */ -SRSLTE_API int pdcch_decode_msg(pdcch_t *q, - dci_msg_t *msg, - dci_location_t *location, - dci_format_t format, - uint16_t *srslte_crc_rem); +SRSLTE_API int srslte_pdcch_encode(srslte_pdcch_t *q, + srslte_dci_msg_t *msg, + srslte_dci_location_t location, + uint16_t rnti, + cf_t *sf_symbols[SRSLTE_MAX_PORTS], + uint32_t nsubframe, + uint32_t cfi); + +/* Decoding functions: Extract the LLRs and save them in the srslte_pdcch_t object */ +SRSLTE_API int srslte_pdcch_extract_llr(srslte_pdcch_t *q, + cf_t *sf_symbols, + cf_t *ce[SRSLTE_MAX_PORTS], + float noise_estimate, + uint32_t nsubframe, + uint32_t cfi); + +/* Decoding functions: Try to decode a DCI message after calling srslte_pdcch_extract_llr */ +SRSLTE_API int srslte_pdcch_decode_msg(srslte_pdcch_t *q, + srslte_dci_msg_t *msg, + srslte_dci_location_t *location, + srslte_dci_format_t format, + uint16_t *srslte_crc_rem); /* Function for generation of UE-specific search space DCI locations */ -SRSLTE_API uint32_t pdcch_ue_locations(pdcch_t *q, - dci_location_t *locations, - uint32_t max_locations, - uint32_t nsubframe, - uint32_t cfi, - uint16_t rnti); +SRSLTE_API uint32_t srslte_pdcch_ue_locations(srslte_pdcch_t *q, + srslte_dci_location_t *locations, + uint32_t max_locations, + uint32_t nsubframe, + uint32_t cfi, + uint16_t rnti); /* Function for generation of common search space DCI locations */ -SRSLTE_API uint32_t pdcch_common_locations(pdcch_t *q, - dci_location_t *locations, - uint32_t max_locations, - uint32_t cfi); +SRSLTE_API uint32_t srslte_pdcch_common_locations(srslte_pdcch_t *q, + srslte_dci_location_t *locations, + uint32_t max_locations, + uint32_t cfi); #endif diff --git a/srslte/include/srslte/phch/pdsch.h b/srslte/include/srslte/phch/pdsch.h index a3b13513a..e04b1875c 100644 --- a/srslte/include/srslte/phch/pdsch.h +++ b/srslte/include/srslte/phch/pdsch.h @@ -41,7 +41,7 @@ #include "srslte/phch/sch.h" #include "srslte/phch/harq.h" -#define TDEC_MAX_ITERATIONS 5 +#define SRSLTE_PDSCH_MAX_TDEC_ITERS 5 typedef _Complex float cf_t; @@ -56,57 +56,57 @@ typedef struct SRSLTE_API { /* buffers */ // void buffers are shared for tx and rx cf_t *ce[SRSLTE_MAX_PORTS]; - cf_t *pdsch_symbols[SRSLTE_MAX_PORTS]; - cf_t *pdsch_x[SRSLTE_MAX_PORTS]; - cf_t *pdsch_d; - void *pdsch_e; + cf_t *symbols[SRSLTE_MAX_PORTS]; + cf_t *x[SRSLTE_MAX_PORTS]; + cf_t *d; + void *e; /* tx & rx objects */ - modem_table_t mod[4]; - demod_soft_t demod; - srslte_sequence_t seq_pdsch[SRSLTE_NSUBFRAMES_X_FRAME]; - precoding_t precoding; + srslte_srslte_modem_table_t mod[4]; + srslte_demod_soft_t demod; + srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; + srslte_precoding_t precoding; - sch_t dl_sch; + srslte_sch_t dl_sch; -}pdsch_t; +} srslte_pdsch_t; -SRSLTE_API int pdsch_init(pdsch_t *q, - srslte_cell_t cell); +SRSLTE_API int srslte_pdsch_init(srslte_pdsch_t *q, + srslte_cell_t cell); -SRSLTE_API void pdsch_free(pdsch_t *q); +SRSLTE_API void srslte_pdsch_free(srslte_pdsch_t *q); -SRSLTE_API int pdsch_set_rnti(pdsch_t *q, - uint16_t rnti); +SRSLTE_API int srslte_pdsch_set_rnti(srslte_pdsch_t *q, + uint16_t rnti); -SRSLTE_API int pdsch_encode(pdsch_t *q, - harq_t *harq_process, - uint8_t *data, - cf_t *sf_symbols[SRSLTE_MAX_PORTS]); +SRSLTE_API int srslte_pdsch_encode(srslte_pdsch_t *q, + srslte_harq_t *harq_process, + uint8_t *data, + cf_t *sf_symbols[SRSLTE_MAX_PORTS]); -SRSLTE_API int pdsch_encode_rnti(pdsch_t *q, - harq_t *harq_process, - uint8_t *data, - uint16_t rnti, - cf_t *sf_symbols[SRSLTE_MAX_PORTS]); +SRSLTE_API int srslte_pdsch_encode_rnti(srslte_pdsch_t *q, + srslte_harq_t *harq_process, + uint8_t *data, + uint16_t rnti, + cf_t *sf_symbols[SRSLTE_MAX_PORTS]); -SRSLTE_API int pdsch_decode(pdsch_t *q, - harq_t *harq_process, - cf_t *sf_symbols, - cf_t *ce[SRSLTE_MAX_PORTS], - float noise_estimate, - uint8_t *data); +SRSLTE_API int srslte_pdsch_decode(srslte_pdsch_t *q, + srslte_harq_t *harq_process, + cf_t *sf_symbols, + cf_t *ce[SRSLTE_MAX_PORTS], + float noise_estimate, + uint8_t *data); -SRSLTE_API int pdsch_decode_rnti(pdsch_t *q, - harq_t *harq_process, - cf_t *sf_symbols, - cf_t *ce[SRSLTE_MAX_PORTS], - float noise_estimate, - uint16_t rnti, - uint8_t *data); +SRSLTE_API int srslte_pdsch_decode_rnti(srslte_pdsch_t *q, + srslte_harq_t *harq_process, + cf_t *sf_symbols, + cf_t *ce[SRSLTE_MAX_PORTS], + float noise_estimate, + uint16_t rnti, + uint8_t *data); -SRSLTE_API float pdsch_average_noi(pdsch_t *q); +SRSLTE_API float srslte_pdsch_average_noi(srslte_pdsch_t *q); -SRSLTE_API uint32_t pdsch_last_noi(pdsch_t *q); +SRSLTE_API uint32_t srslte_pdsch_last_noi(srslte_pdsch_t *q); #endif diff --git a/srslte/include/srslte/phch/phich.h b/srslte/include/srslte/phch/phich.h index 878ef31de..e3400317e 100644 --- a/srslte/include/srslte/phch/phich.h +++ b/srslte/include/srslte/phch/phich.h @@ -41,70 +41,69 @@ typedef _Complex float cf_t; #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 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 +#define SRSLTE_PHICH_EXT_NSEQUENCES 4 +#define SRSLTE_PHICH_NBITS 3 + +#define SRSLTE_PHICH_NORM_MSYMB SRSLTE_PHICH_NBITS * 4 +#define SRSLTE_PHICH_EXT_MSYMB SRSLTE_PHICH_NBITS * 2 +#define SRSLTE_PHICH_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 { srslte_cell_t cell; /* handler to REGs resource mapper */ - regs_t *regs; + srslte_regs_t *regs; /* buffers */ - 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]; + cf_t ce[SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB]; + cf_t symbols[SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB]; + cf_t x[SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB]; + cf_t d[SRSLTE_PHICH_MAX_NSYMB]; + cf_t d0[SRSLTE_PHICH_MAX_NSYMB]; + cf_t z[SRSLTE_PHICH_NBITS]; /* bit message */ - uint8_t data[PHICH_NBITS]; + uint8_t data[SRSLTE_PHICH_NBITS]; /* tx & rx objects */ - modem_table_t mod; - demod_hard_t demod; - srslte_sequence_t seq_phich[SRSLTE_NSUBFRAMES_X_FRAME]; - precoding_t precoding; - -}phich_t; - -SRSLTE_API int phich_init(phich_t *q, - regs_t *regs, - srslte_cell_t cell); - -SRSLTE_API void phich_free(phich_t *q); - -SRSLTE_API int phich_decode(phich_t *q, - cf_t *slot_symbols, - cf_t *ce[SRSLTE_MAX_PORTS], - float noise_estimate, - uint32_t ngroup, - uint32_t nseq, - uint32_t nsubframe, - uint8_t *ack, - uint32_t *distance); - -SRSLTE_API int phich_encode(phich_t *q, - uint8_t ack, - uint32_t ngroup, - uint32_t nseq, - uint32_t nsubframe, - cf_t *slot_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API void phich_reset(phich_t *q, - cf_t *slot_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API uint32_t phich_ngroups(phich_t *q); + srslte_srslte_modem_table_t mod; + srslte_demod_hard_t demod; + srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; + srslte_precoding_t precoding; + +} srslte_phich_t; + +SRSLTE_API int srslte_phich_init(srslte_phich_t *q, + srslte_regs_t *regs, + srslte_cell_t cell); + +SRSLTE_API void srslte_phich_free(srslte_phich_t *q); + +SRSLTE_API int srslte_phich_decode(srslte_phich_t *q, + cf_t *slot_symbols, + cf_t *ce[SRSLTE_MAX_PORTS], + float noise_estimate, + uint32_t ngroup, + uint32_t nseq, + uint32_t nsubframe, + uint8_t *ack, + uint32_t *distance); + +SRSLTE_API int srslte_phich_encode(srslte_phich_t *q, + uint8_t ack, + uint32_t ngroup, + uint32_t nseq, + uint32_t nsubframe, + cf_t *slot_symbols[SRSLTE_MAX_PORTS]); + +SRSLTE_API void srslte_phich_reset(srslte_phich_t *q, + cf_t *slot_symbols[SRSLTE_MAX_PORTS]); + +SRSLTE_API uint32_t srslte_phich_ngroups(srslte_phich_t *q); #endif // PHICH_ diff --git a/srslte/include/srslte/phch/prach.h b/srslte/include/srslte/phch/prach.h index e5279fd2f..adce53944 100644 --- a/srslte/include/srslte/phch/prach.h +++ b/srslte/include/srslte/phch/prach.h @@ -33,13 +33,10 @@ #include #include #include "srslte/config.h" -#include "srslte/utils/dft.h" +#include "srslte/dft/dft.h" typedef _Complex float cf_t; -//PRACH detection threshold is PRACH_DETECT_FACTOR*average -#define PRACH_DETECT_FACTOR 10 - /** Generation and detection of RACH signals for uplink. * Currently only supports preamble formats 0-3. * Does not currently support high speed flag. @@ -83,30 +80,30 @@ typedef struct SRSLTE_API { srslte_dft_plan_t *zc_ifft; -}prach_t; +} srslte_prach_t; -SRSLTE_API int prach_init(prach_t *p, - uint32_t N_ifft_ul, - uint32_t preamble_format, - uint32_t root_seq_index, - bool high_speed_flag, - uint32_t zero_corr_zone_config); +SRSLTE_API int srslte_prach_init(srslte_prach_t *p, + uint32_t N_ifft_ul, + uint32_t preamble_format, + uint32_t root_seq_index, + bool high_speed_flag, + uint32_t zero_corr_zone_config); -SRSLTE_API int prach_gen(prach_t *p, - uint32_t seq_index, - uint32_t freq_offset, - float beta_prach, - cf_t *signal); +SRSLTE_API int srslte_prach_gen(srslte_prach_t *p, + uint32_t seq_index, + uint32_t freq_offset, + float beta_prach, + cf_t *signal); -SRSLTE_API int prach_detect(prach_t *p, - uint32_t freq_offset, - cf_t *signal, - uint32_t sig_len, - uint32_t *indices, - uint32_t *ind_len); +SRSLTE_API int srslte_prach_detect(srslte_prach_t *p, + uint32_t freq_offset, + cf_t *signal, + uint32_t sig_len, + uint32_t *indices, + uint32_t *ind_len); -SRSLTE_API int prach_free(prach_t *p); +SRSLTE_API int srslte_prach_free(srslte_prach_t *p); -SRSLTE_API int prach_print_seqs(prach_t *p); +SRSLTE_API int srslte_prach_print_seqs(srslte_prach_t *p); #endif // PRACH_ diff --git a/srslte/include/srslte/phch/pucch.h b/srslte/include/srslte/phch/pucch.h index b2ef837e6..8feea36e1 100644 --- a/srslte/include/srslte/phch/pucch.h +++ b/srslte/include/srslte/phch/pucch.h @@ -39,71 +39,69 @@ #include "srslte/phch/regs.h" #include "srslte/phch/sch.h" #include "srslte/phch/harq.h" -#include "srslte/filter/dft_precoding.h" - -#define TDEC_MAX_ITERATIONS 5 +#include "srslte/dft/dft_precoding.h" typedef _Complex float cf_t; -#define PUCCH_N_SEQ 12 // Only Format 1, 1a and 1b supported -#define PUCCH_MAX_BITS 2 -#define PUCCH_N_SF_MAX 4 +#define SRSLTE_PUCCH_N_SEQ 12 // Only Format 1, 1a and 1b supported +#define SRSLTE_PUCCH_MAX_BITS 2 +#define SRSLTE_PUCCH_N_SF_MAX 4 typedef enum SRSLTE_API { - PUCCH_FORMAT_1 = 0, - PUCCH_FORMAT_1A, - PUCCH_FORMAT_1B, - PUCCH_FORMAT_2, - PUCCH_FORMAT_2A, - PUCCH_FORMAT_2B, -} pucch_format_t; + SRSLTE_PUCCH_FORMAT_1 = 0, + SRSLTE_PUCCH_FORMAT_1A, + SRSLTE_PUCCH_FORMAT_1B, + SRSLTE_PUCCH_FORMAT_2, + SRSLTE_PUCCH_FORMAT_2A, + SRSLTE_PUCCH_FORMAT_2B, +} srslte_pucch_format_t; typedef struct SRSLTE_API { - pucch_format_t format; + srslte_pucch_format_t format; float beta_pucch; uint32_t delta_pucch_shift; uint32_t n_pucch; uint32_t N_cs; -} pucch_cfg_t; +} srslte_pucch_cfg_t; /* PUSCH object */ typedef struct SRSLTE_API { srslte_cell_t cell; - pucch_cfg_t pucch_cfg; + srslte_pucch_cfg_t pucch_cfg; 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; + float tmp_arg[SRSLTE_PUCCH_N_SF_MAX*SRSLTE_PUCCH_N_SEQ]; + float y[SRSLTE_PUCCH_N_SEQ]; +}srslte_pucch_t; -SRSLTE_API int pucch_init(pucch_t *q, - srslte_cell_t cell); +SRSLTE_API int srslte_pucch_init(srslte_pucch_t *q, + srslte_cell_t cell); -SRSLTE_API void pucch_free(pucch_t *q); +SRSLTE_API void srslte_pucch_free(srslte_pucch_t *q); -SRSLTE_API void pucch_set_cfg(pucch_t *q, - pucch_cfg_t *cfg); +SRSLTE_API void srslte_pucch_set_cfg(srslte_pucch_t *q, + srslte_pucch_cfg_t *cfg); -SRSLTE_API int pucch_set_rnti(pucch_t *q, - uint16_t rnti); +SRSLTE_API int srslte_pucch_set_rnti(srslte_pucch_t *q, + uint16_t rnti); -SRSLTE_API int pucch_encode(pucch_t *q, - pucch_cfg_t *cfg, - uint8_t bits[PUCCH_MAX_BITS], - cf_t *sf_symbols); +SRSLTE_API int srslte_pucch_encode(srslte_pucch_t *q, + srslte_pucch_cfg_t *cfg, + uint8_t bits[SRSLTE_PUCCH_MAX_BITS], + cf_t *sf_symbols); -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, - uint32_t ns, - uint32_t l, - uint32_t *n_oc); +SRSLTE_API float srslte_pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB], + srslte_pucch_cfg_t *cfg, + srslte_cp_t cp, + bool is_drms, + uint32_t ns, + uint32_t l, + 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_SRSLTE_SRSLTE_CP_NORM_NSYMB]); +SRSLTE_API int srslte_generate_n_cs_cell(srslte_cell_t cell, + 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); +SRSLTE_API bool srslte_pucch_cfg_isvalid(srslte_pucch_cfg_t *cfg); #endif diff --git a/srslte/include/srslte/phch/pusch.h b/srslte/include/srslte/phch/pusch.h index 6a8111ef4..fecf45370 100644 --- a/srslte/include/srslte/phch/pusch.h +++ b/srslte/include/srslte/phch/pusch.h @@ -39,102 +39,102 @@ #include "srslte/phch/regs.h" #include "srslte/phch/sch.h" #include "srslte/phch/harq.h" -#include "srslte/filter/dft_precoding.h" +#include "srslte/dft/dft_precoding.h" -#define TDEC_MAX_ITERATIONS 5 +#define SRSLTE_PUSCH_MAX_TDEC_ITERS 5 typedef _Complex float cf_t; typedef struct { enum { - hop_mode_inter_sf = 1, - hop_mode_intra_sf = 0 + SRSLTE_PUSCH_HOP_MODE_INTER_SF = 1, + SRSLTE_PUSCH_HOP_MODE_INTRA_SF = 0 } hop_mode; uint32_t current_tx_nb; uint32_t hopping_offset; uint32_t n_sb; -} pusch_hopping_cfg_t; +} srslte_pusch_hopping_cfg_t; /* PUSCH object */ typedef struct SRSLTE_API { srslte_cell_t cell; - pusch_hopping_cfg_t hopping_cfg; + srslte_pusch_hopping_cfg_t hopping_cfg; uint32_t max_re; bool rnti_is_set; uint16_t rnti; - srslte_srslte_dft_precoding_t srslte_dft_precoding; + srslte_dft_precoding_t dft_precoding; - precoding_t equalizer; + srslte_precoding_t equalizer; /* buffers */ // void buffers are shared for tx and rx cf_t *ce; - cf_t *pusch_z; - cf_t *pusch_d; + cf_t *z; + cf_t *d; - void *pusch_q; - void *pusch_g; + void *q; + void *g; /* tx & rx objects */ - modem_table_t mod[4]; - demod_soft_t demod; - srslte_sequence_t seq_pusch[SRSLTE_NSUBFRAMES_X_FRAME]; + srslte_srslte_modem_table_t mod[4]; + srslte_demod_soft_t demod; + srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_sequence_t seq_type2_fo; - sch_t dl_sch; + srslte_sch_t dl_sch; -}pusch_t; +}srslte_pusch_t; -SRSLTE_API int pusch_init(pusch_t *q, - srslte_cell_t cell); +SRSLTE_API int srslte_pusch_init(srslte_pusch_t *q, + srslte_cell_t cell); -SRSLTE_API void pusch_free(pusch_t *q); +SRSLTE_API void srslte_pusch_free(srslte_pusch_t *q); -SRSLTE_API void pusch_set_hopping_cfg(pusch_t *q, - pusch_hopping_cfg_t *cfg); +SRSLTE_API void srslte_pusch_set_hopping_cfg(srslte_pusch_t *q, + srslte_pusch_hopping_cfg_t *cfg); -SRSLTE_API int pusch_set_rnti(pusch_t *q, - uint16_t rnti); +SRSLTE_API int srslte_pusch_set_rnti(srslte_pusch_t *q, + uint16_t rnti); -SRSLTE_API int pusch_encode(pusch_t *q, - harq_t *harq_process, - uint8_t *data, - cf_t *sf_symbols); +SRSLTE_API int srslte_pusch_encode(srslte_pusch_t *q, + srslte_harq_t *harq_process, + uint8_t *data, + cf_t *sf_symbols); -SRSLTE_API int pusch_encode_rnti(pusch_t *q, - harq_t *harq_process, - uint8_t *data, - uint16_t rnti, - cf_t *sf_symbols); +SRSLTE_API int srslte_pusch_encode_rnti(srslte_pusch_t *q, + srslte_harq_t *harq_process, + uint8_t *data, + uint16_t rnti, + cf_t *sf_symbols); -SRSLTE_API int pusch_uci_encode(pusch_t *q, - harq_t *harq_process, - uint8_t *data, - uci_data_t uci_data, - cf_t *sf_symbols); +SRSLTE_API int srslte_pusch_uci_encode(srslte_pusch_t *q, + srslte_harq_t *harq_process, + uint8_t *data, + srslte_uci_data_t uci_data, + cf_t *sf_symbols); -SRSLTE_API int pusch_uci_encode_rnti(pusch_t *q, - harq_t *harq, - uint8_t *data, - uci_data_t uci_data, - uint16_t rnti, - cf_t *sf_symbols); +SRSLTE_API int srslte_pusch_uci_encode_rnti(srslte_pusch_t *q, + srslte_harq_t *harq, + uint8_t *data, + srslte_uci_data_t uci_data, + uint16_t rnti, + cf_t *sf_symbols); -SRSLTE_API int pusch_decode(pusch_t *q, - harq_t *harq_process, - cf_t *sf_symbols, - cf_t *ce, - float noise_estimate, - uint8_t *data); +SRSLTE_API int srslte_pusch_decode(srslte_pusch_t *q, + srslte_harq_t *harq_process, + cf_t *sf_symbols, + cf_t *ce, + float noise_estimate, + uint8_t *data); -SRSLTE_API float pusch_average_noi(pusch_t *q); +SRSLTE_API float srslte_pusch_average_noi(srslte_pusch_t *q); -SRSLTE_API uint32_t pusch_last_noi(pusch_t *q); +SRSLTE_API uint32_t srslte_pusch_last_noi(srslte_pusch_t *q); #endif diff --git a/srslte/include/srslte/phch/ra.h b/srslte/include/srslte/phch/ra.h index 8f2639a09..f3d2c2944 100644 --- a/srslte/include/srslte/phch/ra.h +++ b/srslte/include/srslte/phch/ra.h @@ -32,6 +32,7 @@ #include #include "srslte/config.h" +#include "srslte/common/phy_common.h" /** Structures and utility functions for DL/UL resource * allocation. @@ -40,164 +41,166 @@ typedef struct SRSLTE_API { srslte_mod_t mod; int tbs; -} ra_mcs_t; +} srslte_ra_mcs_t; typedef enum SRSLTE_API { - alloc_type0 = 0, alloc_type1 = 1, alloc_type2 = 2 -} ra_type_t; + SRSLTE_RA_ALLOC_TYPE0 = 0, + SRSLTE_RA_ALLOC_TYPE1 = 1, + SRSLTE_RA_ALLOC_TYPE2 = 2 +} srslte_ra_type_t; typedef struct SRSLTE_API { uint32_t rbg_bitmask; -} ra_type0_t; +} srslte_ra_type0_t; typedef struct SRSLTE_API { uint32_t vrb_bitmask; uint32_t rbg_subset; bool shift; -} ra_type1_t; +} srslte_ra_type1_t; typedef struct SRSLTE_API { uint32_t riv; // if L_crb==0, DCI message packer will take this value directly uint32_t L_crb; uint32_t RB_start; enum { - nprb1a_2 = 0, nprb1a_3 = 1 + SRSLTE_RA_TYPE2_NPRB1A_2 = 0, SRSLTE_RA_TYPE2_NPRB1A_3 = 1 } n_prb1a; enum { - t2_ng1 = 0, t2_ng2 = 1 + SRSLTE_RA_TYPE2_NG1 = 0, SRSLTE_RA_TYPE2_NG2 = 1 } n_gap; enum { - t2_loc = 0, t2_dist = 1 + SRSLTE_RA_TYPE2_LOC = 0, SRSLTE_RA_TYPE2_DIST = 1 } mode; -} ra_type2_t; +} srslte_ra_type2_t; typedef struct SRSLTE_API { bool prb_idx[SRSLTE_MAX_PRB]; uint32_t nof_prb; -} ra_prb_slot_t; +} srslte_ra_prb_slot_t; typedef struct SRSLTE_API { - ra_prb_slot_t slot[2]; + srslte_ra_prb_slot_t slot[2]; uint32_t lstart; uint32_t re_sf[SRSLTE_NSUBFRAMES_X_FRAME]; -} ra_dl_alloc_t; +} srslte_srslte_ra_dl_alloc_t; typedef struct SRSLTE_API { uint32_t n_prb[2]; uint32_t n_prb_tilde[2]; uint32_t L_prb; uint32_t freq_hopping; -} ra_ul_alloc_t; +} srslte_srslte_ra_ul_alloc_t; typedef struct SRSLTE_API { uint16_t rnti; - ra_type_t alloc_type; + srslte_ra_type_t alloc_type; union { - ra_type0_t type0_alloc; - ra_type1_t type1_alloc; - ra_type2_t type2_alloc; + srslte_ra_type0_t type0_alloc; + srslte_ra_type1_t type1_alloc; + srslte_ra_type2_t type2_alloc; }; - ra_dl_alloc_t prb_alloc; + srslte_srslte_ra_dl_alloc_t prb_alloc; uint32_t mcs_idx; - ra_mcs_t mcs; + srslte_ra_mcs_t mcs; uint32_t harq_process; uint32_t rv_idx; bool ndi; -} ra_pdsch_t; +} srslte_ra_pdsch_t; typedef struct SRSLTE_API { - /* 36.213 Table 8.4-2: hop_half is 0 for < 10 Mhz and 10 for > 10 Mhz. - * hop_quart is 00 for > 10 Mhz and hop_quart_neg is 01 for > 10 Mhz. + /* 36.213 Table 8.4-2: SRSLTE_RA_PUSCH_HOP_HALF is 0 for < 10 Mhz and 10 for > 10 Mhz. + * SRSLTE_RA_PUSCH_HOP_QUART is 00 for > 10 Mhz and SRSLTE_RA_PUSCH_HOP_QUART_NEG is 01 for > 10 Mhz. */ enum { - hop_disabled = -1, - hop_quart = 0, - hop_quart_neg = 1, - hop_half = 2, - hop_type_2 = 3 + SRSLTE_RA_PUSCH_HOP_DISABLED = -1, + SRSLTE_RA_PUSCH_HOP_QUART = 0, + SRSLTE_RA_PUSCH_HOP_QUART_NEG = 1, + SRSLTE_RA_PUSCH_HOP_HALF = 2, + SRSLTE_RA_PUSCH_HOP_TYPE2 = 3 } freq_hop_fl; - ra_ul_alloc_t prb_alloc; + srslte_srslte_ra_ul_alloc_t prb_alloc; - ra_type2_t type2_alloc; + srslte_ra_type2_t type2_alloc; uint32_t mcs_idx; - ra_mcs_t mcs; + srslte_ra_mcs_t mcs; uint32_t rv_idx; // If set to non-zero, a retransmission is requested with the same modulation - // than before (Format0 message, see also 8.6.1 in 36.2313). + // than before (SRSLTE_DCI_FORMAT0 message, see also 8.6.1 in 36.2313). bool ndi; bool cqi_request; -} ra_pusch_t; +} srslte_ra_pusch_t; -SRSLTE_API void ra_prb_fprint(FILE *f, - ra_prb_slot_t *prb, - uint32_t nof_prb); +SRSLTE_API void srslte_ra_prb_fprint(FILE *f, + srslte_ra_prb_slot_t *prb, + uint32_t nof_prb); -SRSLTE_API int ra_dl_alloc(ra_dl_alloc_t *prb, - ra_pdsch_t *ra, - uint32_t nof_prb); +SRSLTE_API int srslte_ra_dl_alloc(srslte_srslte_ra_dl_alloc_t *prb, + srslte_ra_pdsch_t *ra, + uint32_t nof_prb); -SRSLTE_API int ra_ul_alloc(ra_ul_alloc_t *prb, - ra_pusch_t *ra, - uint32_t n_rb_ho, - uint32_t nof_prb); +SRSLTE_API int srslte_ra_ul_alloc(srslte_srslte_ra_ul_alloc_t *prb, + srslte_ra_pusch_t *ra, + uint32_t n_rb_ho, + uint32_t nof_prb); -SRSLTE_API void ra_dl_alloc_re(ra_dl_alloc_t *prb_dist, - uint32_t nof_prb, - uint32_t nof_ports, - uint32_t nof_ctrl_symbols, - srslte_cp_t cp); +SRSLTE_API void srslte_ra_dl_alloc_re(srslte_srslte_ra_dl_alloc_t *prb_dist, + uint32_t nof_prb, + uint32_t nof_ports, + uint32_t nof_ctrl_symbols, + srslte_cp_t cp); -SRSLTE_API uint32_t ra_nprb_dl(ra_pdsch_t *ra, - uint32_t nof_prb); +SRSLTE_API uint32_t srslte_ra_nprb_dl(srslte_ra_pdsch_t *ra, + uint32_t nof_prb); -SRSLTE_API uint32_t ra_nprb_ul(ra_pusch_t *ra, - uint32_t nof_prb); +SRSLTE_API uint32_t srslte_ra_nprb_ul(srslte_ra_pusch_t *ra, + uint32_t nof_prb); -SRSLTE_API int ra_mcs_from_idx_dl(uint32_t mcs_idx, - uint32_t nof_prb, - ra_mcs_t *mcs); +SRSLTE_API int srslte_ra_mcs_from_idx_dl(uint32_t mcs_idx, + uint32_t nof_prb, + srslte_ra_mcs_t *mcs); -SRSLTE_API int ra_mcs_from_idx_ul(uint32_t mcs_idx, - uint32_t nof_prb, - ra_mcs_t *mcs); +SRSLTE_API int srslte_ra_mcs_from_idx_ul(uint32_t mcs_idx, + uint32_t nof_prb, + srslte_ra_mcs_t *mcs); -SRSLTE_API int ra_tbs_from_idx_format1c(uint32_t tbs_idx); +SRSLTE_API int srslte_srslte_ra_tbs_from_idx_format1c(uint32_t tbs_idx); -SRSLTE_API int ra_tbs_from_idx(uint32_t tbs_idx, - uint32_t n_prb); +SRSLTE_API int srslte_ra_tbs_from_idx(uint32_t tbs_idx, + uint32_t n_prb); -SRSLTE_API int ra_tbs_to_table_idx(uint32_t tbs, - uint32_t n_prb); +SRSLTE_API int srslte_ra_tbs_to_table_idx(uint32_t tbs, + uint32_t n_prb); -SRSLTE_API uint32_t ra_type0_P(uint32_t nof_prb); +SRSLTE_API uint32_t srslte_ra_type0_P(uint32_t nof_prb); -SRSLTE_API uint32_t ra_type2_to_riv(uint32_t L_crb, - uint32_t RB_start, - uint32_t nof_prb); +SRSLTE_API uint32_t srslte_ra_type2_to_riv(uint32_t L_crb, + uint32_t RB_start, + uint32_t nof_prb); -SRSLTE_API void ra_type2_from_riv(uint32_t riv, - uint32_t *L_crb, - uint32_t *RB_start, - uint32_t nof_prb, - uint32_t nof_vrb); +SRSLTE_API void srslte_ra_type2_from_riv(uint32_t riv, + uint32_t *L_crb, + uint32_t *RB_start, + uint32_t nof_prb, + uint32_t nof_vrb); -SRSLTE_API uint32_t ra_type2_n_vrb_dl(uint32_t nof_prb, - bool ngap_is_1); +SRSLTE_API uint32_t srslte_ra_type2_n_vrb_dl(uint32_t nof_prb, + bool ngap_is_1); -SRSLTE_API uint32_t ra_type2_n_rb_step(uint32_t nof_prb); +SRSLTE_API uint32_t srslte_ra_type2_n_rb_step(uint32_t nof_prb); -SRSLTE_API uint32_t ra_type2_ngap(uint32_t nof_prb, - bool ngap_is_1); +SRSLTE_API uint32_t srslte_ra_type2_ngap(uint32_t nof_prb, + bool ngap_is_1); -SRSLTE_API uint32_t ra_type1_N_rb(uint32_t nof_prb); +SRSLTE_API uint32_t srslte_ra_type1_N_rb(uint32_t nof_prb); -SRSLTE_API void ra_pdsch_fprint(FILE *f, - ra_pdsch_t *ra, - uint32_t nof_prb); +SRSLTE_API void srslte_ra_pdsch_fprint(FILE *f, + srslte_ra_pdsch_t *ra, + uint32_t nof_prb); -SRSLTE_API void ra_pusch_fprint(FILE *f, - ra_pusch_t *ra, - uint32_t nof_prb); +SRSLTE_API void srslte_ra_pusch_fprint(FILE *f, + srslte_ra_pusch_t *ra, + uint32_t nof_prb); #endif /* RB_ALLOC_H_ */ diff --git a/srslte/include/srslte/phch/regs.h b/srslte/include/srslte/phch/regs.h index 60e0ffdc4..9a66f4ab1 100644 --- a/srslte/include/srslte/phch/regs.h +++ b/srslte/include/srslte/phch/regs.h @@ -49,12 +49,12 @@ typedef struct SRSLTE_API { uint32_t k0; uint32_t l; bool assigned; -}regs_reg_t; +}srslte_regs_reg_t; typedef struct SRSLTE_API { uint32_t nof_regs; - regs_reg_t **regs; -}regs_ch_t; + srslte_regs_reg_t **regs; +}srslte_regs_ch_t; typedef struct SRSLTE_API { srslte_cell_t cell; @@ -66,67 +66,67 @@ typedef struct SRSLTE_API { srslte_phich_resources_t phich_res; srslte_phich_length_t phich_len; - regs_ch_t pcfich; - regs_ch_t *phich; // there are several phich - regs_ch_t pdcch[3]; /* PDCCH indexing, permutation and interleaving is computed for + srslte_regs_ch_t pcfich; + srslte_regs_ch_t *phich; // there are several phich + srslte_regs_ch_t pdcch[3]; /* PDCCH indexing, permutation and interleaving is computed for the three possible CFI value */ uint32_t nof_regs; - regs_reg_t *regs; -}regs_t; + srslte_regs_reg_t *regs; +}srslte_regs_t; -SRSLTE_API int regs_init(regs_t *h, - srslte_cell_t cell); +SRSLTE_API int srslte_regs_init(srslte_regs_t *h, + srslte_cell_t cell); -SRSLTE_API void regs_free(regs_t *h); -SRSLTE_API int regs_set_cfi(regs_t *h, - uint32_t nof_ctrl_symbols); +SRSLTE_API void srslte_regs_free(srslte_regs_t *h); +SRSLTE_API int srslte_regs_set_cfi(srslte_regs_t *h, + uint32_t nof_ctrl_symbols); -SRSLTE_API uint32_t regs_pcfich_nregs(regs_t *h); -SRSLTE_API int regs_pcfich_put(regs_t *h, - cf_t pcfich_symbols[REGS_PCFICH_NSYM], +SRSLTE_API uint32_t srslte_regs_pcfich_nregs(srslte_regs_t *h); +SRSLTE_API int srslte_regs_pcfich_put(srslte_regs_t *h, + cf_t symbols[REGS_PCFICH_NSYM], cf_t *slot_symbols); -SRSLTE_API int regs_pcfich_get(regs_t *h, - cf_t *slot_symbols, - cf_t pcfich_symbols[REGS_PCFICH_NSYM]); +SRSLTE_API int srslte_regs_pcfich_get(srslte_regs_t *h, + cf_t *slot_symbols, + cf_t symbols[REGS_PCFICH_NSYM]); -SRSLTE_API uint32_t regs_phich_nregs(regs_t *h); -SRSLTE_API int regs_phich_add(regs_t *h, - cf_t phich_symbols[REGS_PHICH_NSYM], - uint32_t ngroup, - cf_t *slot_symbols); +SRSLTE_API uint32_t srslte_regs_phich_nregs(srslte_regs_t *h); +SRSLTE_API int srslte_regs_phich_add(srslte_regs_t *h, + cf_t symbols[REGS_PHICH_NSYM], + uint32_t ngroup, + cf_t *slot_symbols); -SRSLTE_API int regs_phich_get(regs_t *h, - cf_t *slot_symbols, - cf_t phich_symbols[REGS_PHICH_NSYM], - uint32_t ngroup); +SRSLTE_API int srslte_regs_phich_get(srslte_regs_t *h, + cf_t *slot_symbols, + cf_t symbols[REGS_PHICH_NSYM], + uint32_t ngroup); -SRSLTE_API uint32_t regs_phich_ngroups(regs_t *h); -SRSLTE_API int regs_phich_reset(regs_t *h, - cf_t *slot_symbols); +SRSLTE_API uint32_t srslte_regs_phich_ngroups(srslte_regs_t *h); +SRSLTE_API int srslte_regs_phich_reset(srslte_regs_t *h, + cf_t *slot_symbols); -SRSLTE_API int regs_pdcch_nregs(regs_t *h, uint32_t cfi); -SRSLTE_API int regs_pdcch_put(regs_t *h, - cf_t *pdcch_symbols, - cf_t *slot_symbols); +SRSLTE_API int srslte_regs_pdcch_nregs(srslte_regs_t *h, uint32_t cfi); +SRSLTE_API int srslte_regs_pdcch_put(srslte_regs_t *h, + cf_t *d, + cf_t *slot_symbols); -SRSLTE_API int regs_pdcch_put_offset(regs_t *h, - cf_t *pdcch_symbols, +SRSLTE_API int srslte_regs_pdcch_put_offset(srslte_regs_t *h, + cf_t *d, cf_t *slot_symbols, uint32_t start_reg, uint32_t nof_regs); -SRSLTE_API int regs_pdcch_get(regs_t *h, - cf_t *slot_symbols, - cf_t *pdcch_symbols); - -SRSLTE_API int regs_pdcch_get_offset(regs_t *h, +SRSLTE_API int srslte_regs_pdcch_get(srslte_regs_t *h, cf_t *slot_symbols, - cf_t *pdcch_symbols, - uint32_t start_reg, - uint32_t nof_regs); + cf_t *d); + +SRSLTE_API int srslte_regs_pdcch_get_offset(srslte_regs_t *h, + cf_t *slot_symbols, + cf_t *d, + uint32_t start_reg, + uint32_t nof_regs); #endif // REGS_H_ diff --git a/srslte/include/srslte/phch/sch.h b/srslte/include/srslte/phch/sch.h index 6a4fe8297..c8ad8c654 100644 --- a/srslte/include/srslte/phch/sch.h +++ b/srslte/include/srslte/phch/sch.h @@ -38,7 +38,7 @@ #include "srslte/phch/harq.h" #include "srslte/phch/uci.h" -#define TDEC_MAX_ITERATIONS 5 +#define SRSLTE_PDSCH_MAX_TDEC_ITERS 5 #ifndef SRSLTE_RX_NULL @@ -58,51 +58,51 @@ typedef struct SRSLTE_API { /* buffers */ uint8_t *cb_in; void *cb_out; - void *pdsch_e; + void *e; srslte_tcod_t encoder; srslte_tdec_t decoder; srslte_crc_t srslte_crc_tb; srslte_crc_t srslte_crc_cb; - uci_cqi_pusch_t uci_cqi; + srslte_uci_cqi_pusch_t uci_cqi; -} sch_t; +} srslte_sch_t; -SRSLTE_API int sch_init(sch_t *q); +SRSLTE_API int srslte_sch_init(srslte_sch_t *q); -SRSLTE_API void sch_free(sch_t *q); +SRSLTE_API void srslte_sch_free(srslte_sch_t *q); -SRSLTE_API float sch_average_noi(sch_t *q); +SRSLTE_API float srslte_sch_average_noi(srslte_sch_t *q); -SRSLTE_API uint32_t sch_last_noi(sch_t *q); +SRSLTE_API uint32_t srslte_sch_last_noi(srslte_sch_t *q); -SRSLTE_API int dlsch_encode(sch_t *q, - harq_t *harq_process, +SRSLTE_API int srslte_dlsch_encode(srslte_sch_t *q, + srslte_harq_t *harq_process, uint8_t *data, uint8_t *e_bits); -SRSLTE_API int dlsch_decode(sch_t *q, - harq_t *harq_process, +SRSLTE_API int srslte_dlsch_decode(srslte_sch_t *q, + srslte_harq_t *harq_process, float *e_bits, uint8_t *data); -SRSLTE_API int ulsch_encode(sch_t *q, - harq_t *harq_process, +SRSLTE_API int srslte_ulsch_encode(srslte_sch_t *q, + srslte_harq_t *harq_process, uint8_t *data, uint8_t *g_bits, uint8_t *q_bits); -SRSLTE_API int ulsch_uci_encode(sch_t *q, - harq_t *harq_process, +SRSLTE_API int srslte_ulsch_uci_encode(srslte_sch_t *q, + srslte_harq_t *harq_process, uint8_t *data, - uci_data_t uci_data, + srslte_uci_data_t uci_data, uint8_t *g_bits, uint8_t *q_bits); -SRSLTE_API int ulsch_decode(sch_t *q, - harq_t *harq_process, +SRSLTE_API int srslte_ulsch_decode(srslte_sch_t *q, + srslte_harq_t *harq_process, float *e_bits, uint8_t *data); diff --git a/srslte/include/srslte/phch/uci.h b/srslte/include/srslte/phch/uci.h index 3b2ded9d0..5eb0e77e2 100644 --- a/srslte/include/srslte/phch/uci.h +++ b/srslte/include/srslte/phch/uci.h @@ -34,16 +34,16 @@ #include "srslte/phch/harq.h" #include "srslte/fec/crc.h" -#define MAX_CQI_LEN_PUSCH 512 -#define MAX_CQI_LEN_PUCCH 13 -#define CQI_CODED_PUCCH_B 20 +#define SRSLTE_UCI_MAX_CQI_LEN_PUSCH 512 +#define SRSLTE_UCI_MAX_CQI_LEN_PUCCH 13 +#define SRSLTE_UCI_CQI_CODED_PUCCH_B 20 typedef struct SRSLTE_API { srslte_crc_t crc; - uint8_t tmp_cqi[MAX_CQI_LEN_PUSCH]; - uint8_t encoded_cqi[3*MAX_CQI_LEN_PUSCH]; -} uci_cqi_pusch_t; + uint8_t tmp_cqi[SRSLTE_UCI_MAX_CQI_LEN_PUSCH]; + uint8_t encoded_cqi[3*SRSLTE_UCI_MAX_CQI_LEN_PUSCH]; +} srslte_uci_cqi_pusch_t; typedef struct SRSLTE_API { uint8_t *uci_cqi; @@ -55,37 +55,37 @@ typedef struct SRSLTE_API { uint8_t uci_ack; // Only 1-bit supported for HARQ uint32_t uci_ack_len; float beta_ack; -} uci_data_t; +} srslte_uci_data_t; -SRSLTE_API int uci_cqi_init(uci_cqi_pusch_t *q); +SRSLTE_API int srslte_uci_cqi_init(srslte_uci_cqi_pusch_t *q); -SRSLTE_API void uci_cqi_free(uci_cqi_pusch_t *q); +SRSLTE_API void srslte_uci_cqi_free(srslte_uci_cqi_pusch_t *q); -SRSLTE_API int uci_encode_cqi_pusch(uci_cqi_pusch_t *q, - uint8_t *cqi_data, - uint32_t cqi_len, - float beta, - uint32_t Q_prime_ri, - harq_t *harq_process, - uint8_t *q_bits); +SRSLTE_API int srslte_uci_encode_cqi_pusch(srslte_uci_cqi_pusch_t *q, + uint8_t *cqi_data, + uint32_t cqi_len, + float beta, + uint32_t Q_prime_ri, + srslte_harq_t *harq_process, + uint8_t *q_bits); -SRSLTE_API int uci_encode_cqi_pucch(uint8_t *cqi_data, - uint32_t cqi_len, - uint8_t b_bits[CQI_CODED_PUCCH_B]); +SRSLTE_API int srslte_uci_encode_cqi_pucch(uint8_t *cqi_data, + uint32_t cqi_len, + uint8_t b_bits[SRSLTE_UCI_CQI_CODED_PUCCH_B]); -SRSLTE_API int uci_encode_ack(uint8_t data, - uint32_t O_cqi, - float beta, - harq_t *harq_process, - uint32_t H_prime_total, - uint8_t *q_bits); +SRSLTE_API int srslte_uci_encode_ack(uint8_t data, + uint32_t O_cqi, + float beta, + srslte_harq_t *harq_process, + uint32_t H_prime_total, + uint8_t *q_bits); -SRSLTE_API int uci_encode_ri(uint8_t data, - uint32_t O_cqi, - float beta, - harq_t *harq_process, - uint32_t H_prime_total, - uint8_t *q_bits); +SRSLTE_API int srslte_uci_encode_ri(uint8_t data, + uint32_t O_cqi, + float beta, + srslte_harq_t *harq_process, + uint32_t H_prime_total, + uint8_t *q_bits); #endif \ No newline at end of file diff --git a/srslte/include/srslte/resampling/decim.h b/srslte/include/srslte/resampling/decim.h index 9c50e401b..f7c6759db 100644 --- a/srslte/include/srslte/resampling/decim.h +++ b/srslte/include/srslte/resampling/decim.h @@ -33,7 +33,14 @@ typedef _Complex float cf_t; -SRSLTE_API void decim_c(cf_t *input, cf_t *output, int M, int len); -SRSLTE_API void decim_f(float *input, float *output, int M, int len); +SRSLTE_API void srslte_decim_c(cf_t *input, + cf_t *output, + int M, + int len); + +SRSLTE_API void srslte_decim_f(float *input, + float *output, + int M, + int len); #endif // DECIM_H diff --git a/srslte/include/srslte/resampling/interp.h b/srslte/include/srslte/resampling/interp.h index bbf885dde..daf047bd7 100644 --- a/srslte/include/srslte/resampling/interp.h +++ b/srslte/include/srslte/resampling/interp.h @@ -44,16 +44,16 @@ SRSLTE_API cf_t srslte_interp_linear_onesample_cabs(cf_t input0, cf_t input1); SRSLTE_API void srslte_interp_linear_offset_cabs(cf_t *input, - cf_t *output, - uint32_t M, - uint32_t len, - uint32_t off_st, - uint32_t off_end); + cf_t *output, + uint32_t M, + uint32_t len, + uint32_t off_st, + uint32_t off_end); SRSLTE_API void srslte_interp_linear_f(float *input, - float *output, - uint32_t M, - uint32_t len); + float *output, + uint32_t M, + uint32_t len); @@ -62,18 +62,18 @@ SRSLTE_API void srslte_interp_linear_f(float *input, typedef struct { cf_t *diff_vec; uint32_t vector_len; -} srslte_interp_linvec_t; +} srslte_interp_linsrslte_vec_t; -SRSLTE_API int srslte_interp_linear_vector_init(srslte_interp_linvec_t *q, - uint32_t vector_len); +SRSLTE_API int srslte_interp_linear_vector_init(srslte_interp_linsrslte_vec_t *q, + uint32_t vector_len); -SRSLTE_API void srslte_interp_linear_vector_free(srslte_interp_linvec_t *q); +SRSLTE_API void srslte_interp_linear_vector_free(srslte_interp_linsrslte_vec_t *q); -SRSLTE_API void srslte_interp_linear_vector(srslte_interp_linvec_t *q, - cf_t *in0, - cf_t *in1, - cf_t *between, - uint32_t M); +SRSLTE_API void srslte_interp_linear_vector(srslte_interp_linsrslte_vec_t *q, + cf_t *in0, + cf_t *in1, + cf_t *between, + uint32_t M); @@ -88,16 +88,16 @@ typedef struct { } srslte_interp_lin_t; SRSLTE_API int srslte_interp_linear_init(srslte_interp_lin_t *q, - uint32_t vector_len, - uint32_t M); + uint32_t vector_len, + uint32_t M); SRSLTE_API void srslte_interp_linear_free(srslte_interp_lin_t *q); SRSLTE_API void srslte_interp_linear_offset(srslte_interp_lin_t *q, - cf_t *input, - cf_t *output, - uint32_t off_st, - uint32_t off_end); + cf_t *input, + cf_t *output, + uint32_t off_st, + uint32_t off_end); #endif // INTERP_H diff --git a/srslte/include/srslte/resampling/resample_arb.h b/srslte/include/srslte/resampling/resample_arb.h index 1495486f8..cd17a042b 100644 --- a/srslte/include/srslte/resampling/resample_arb.h +++ b/srslte/include/srslte/resampling/resample_arb.h @@ -35,17 +35,22 @@ typedef _Complex float cf_t; -#define RESAMPLE_ARB_N 32 // Polyphase filter rows -#define RESAMPLE_ARB_M 8 // Polyphase filter columns +#define SRSLTE_RESAMPLE_ARB_N 32 // Polyphase filter rows +#define SRSLTE_RESAMPLE_ARB_M 8 // Polyphase filter columns typedef struct SRSLTE_API { float rate; // Resample rate float step; // Step increment through filter float acc; // Index into filter - cf_t reg[RESAMPLE_ARB_M]; // Our window of samples -}resample_arb_t; + cf_t reg[SRSLTE_RESAMPLE_ARB_M]; // Our window of samples +} srslte_resample_arb_t; -SRSLTE_API void resample_arb_init(resample_arb_t *q, float rate); -SRSLTE_API int resample_arb_compute(resample_arb_t *q, cf_t *input, cf_t *output, int n_in); +SRSLTE_API void srslte_resample_arb_init(srslte_resample_arb_t *q, + float rate); + +SRSLTE_API int srslte_resample_arb_compute(srslte_resample_arb_t *q, + cf_t *input, + cf_t *output, + int n_in); #endif //RESAMPLE_ARB_ diff --git a/srslte/include/srslte/scrambling/scrambling.h b/srslte/include/srslte/scrambling/scrambling.h index 15523f4c7..0be7a5944 100644 --- a/srslte/include/srslte/scrambling/scrambling.h +++ b/srslte/include/srslte/scrambling/scrambling.h @@ -36,68 +36,34 @@ typedef _Complex float cf_t; /* Scrambling has no state */ -SRSLTE_API void scrambling_b(srslte_sequence_t *s, - uint8_t *data); +SRSLTE_API void srslte_scrambling_b(srslte_sequence_t *s, + uint8_t *data); -SRSLTE_API void scrambling_b_offset(srslte_sequence_t *s, - uint8_t *data, - int offset, - int len); +SRSLTE_API void srslte_scrambling_b_offset(srslte_sequence_t *s, + uint8_t *data, + int offset, + int len); -SRSLTE_API void scrambling_b_offset_pusch(srslte_sequence_t *s, - uint8_t *data, - int offset, - int len); +SRSLTE_API void srslte_scrambling_b_offset_pusch(srslte_sequence_t *s, + uint8_t *data, + int offset, + int len); -SRSLTE_API void scrambling_f(srslte_sequence_t *s, - float *data); +SRSLTE_API void srslte_scrambling_f(srslte_sequence_t *s, + float *data); -SRSLTE_API void scrambling_f_offset(srslte_sequence_t *s, - float *data, - int offset, - int len); +SRSLTE_API void srslte_scrambling_f_offset(srslte_sequence_t *s, + float *data, + int offset, + int len); -SRSLTE_API void scrambling_c(srslte_sequence_t *s, - cf_t *data); +SRSLTE_API void srslte_scrambling_c(srslte_sequence_t *s, + cf_t *data); -SRSLTE_API void scrambling_c_offset(srslte_sequence_t *s, - cf_t *data, - int offset, - int len); +SRSLTE_API void srslte_scrambling_c_offset(srslte_sequence_t *s, + cf_t *data, + int offset, + int len); -/* High-level API */ - -/* channel integer values */ -#define SCRAMBLING_PDSCH 0 /* also PUSCH */ -#define SCRAMBLING_PCFICH 1 -#define SCRAMBLING_PDCCH 2 -#define SCRAMBLING_PBCH 3 -#define SCRAMBLING_PMCH 4 -#define SCRAMBLING_PUCCH 5 - -typedef struct SRSLTE_API { - srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME]; -}scrambling_t; - -typedef struct SRSLTE_API { - scrambling_t obj; - struct scrambling_init { - int hard; - int q; - int cell_id; - int nrnti; - int nMBSFN; - int channel; - int nof_symbols; // 7 normal 6 extended - } init; - void *input; // input type may be uint8_t or float depending on hard - int in_len; - struct scrambling_ctrl_in { - int subframe; - } ctrl_in; - void *output; - int out_len; -}scrambling_hl; - #endif // SCRAMBLING_ diff --git a/srslte/include/srslte/srslte.h b/srslte/include/srslte/srslte.h index 461684e52..d3dc1f37b 100644 --- a/srslte/include/srslte/srslte.h +++ b/srslte/include/srslte/srslte.h @@ -41,17 +41,12 @@ #include "srslte/utils/bit.h" #include "srslte/utils/convolution.h" #include "srslte/utils/debug.h" -#include "srslte/utils/dft.h" -#include "srslte/utils/matrix.h" -#include "srslte/utils/mux.h" #include "srslte/utils/cexptab.h" -#include "srslte/utils/pack.h" #include "srslte/utils/vector.h" #include "srslte/common/timestamp.h" #include "srslte/common/sequence.h" #include "srslte/common/phy_common.h" -#include "srslte/common/fft.h" #include "srslte/ch_estimation/chest_dl.h" #include "srslte/ch_estimation/refsignal_dl.h" @@ -72,8 +67,9 @@ #include "srslte/fec/rm_conv.h" #include "srslte/fec/rm_turbo.h" -#include "srslte/filter/filter2d.h" -#include "srslte/filter/dft_precoding.h" +#include "srslte/dft/dft_precoding.h" +#include "srslte/dft/ofdm.h" +#include "srslte/dft/dft.h" #include "srslte/io/binsource.h" #include "srslte/io/filesink.h" diff --git a/srslte/include/srslte/sync/cfo.h b/srslte/include/srslte/sync/cfo.h index 6525a72f7..e85682929 100644 --- a/srslte/include/srslte/sync/cfo.h +++ b/srslte/include/srslte/sync/cfo.h @@ -37,32 +37,32 @@ typedef _Complex float cf_t; /** If the frequency is changed more than the tolerance, a new table is generated */ -#define CFO_TOLERANCE 0.00001 +#define SRSLTE_CFO_TOLERANCE 0.00001 -#define CFO_CEXPTAB_SIZE 4096 +#define SRSLTE_CFO_CEXPTAB_SIZE 4096 typedef struct SRSLTE_API { float last_freq; float tol; int nsamples; - cexptab_t tab; + srslte_cexptab_t tab; cf_t *cur_cexp; -}cfo_t; +}srslte_cfo_t; -SRSLTE_API int cfo_init(cfo_t *h, - uint32_t nsamples); +SRSLTE_API int srslte_cfo_init(srslte_cfo_t *h, + uint32_t nsamples); -SRSLTE_API void cfo_free(cfo_t *h); +SRSLTE_API void srslte_cfo_free(srslte_cfo_t *h); -SRSLTE_API int cfo_realloc(cfo_t *h, - uint32_t samples); +SRSLTE_API int srslte_cfo_realloc(srslte_cfo_t *h, + uint32_t samples); -SRSLTE_API void cfo_set_tol(cfo_t *h, - float tol); +SRSLTE_API void srslte_cfo_set_tol(srslte_cfo_t *h, + float tol); -SRSLTE_API void cfo_correct(cfo_t *h, - cf_t *input, - cf_t *output, - float freq); +SRSLTE_API void srslte_cfo_correct(srslte_cfo_t *h, + cf_t *input, + cf_t *output, + float freq); #endif // CFO_ diff --git a/srslte/include/srslte/sync/pss.h b/srslte/include/srslte/sync/pss.h index a3ee59710..513268709 100644 --- a/srslte/include/srslte/sync/pss.h +++ b/srslte/include/srslte/sync/pss.h @@ -40,21 +40,21 @@ typedef _Complex float cf_t; /* this is only a shortcut */ #define CONVOLUTION_FFT -#define PSS_LEN 62 -#define PSS_RE 6*12 +#define SRSLTE_PSS_LEN 62 +#define SRSLTE_PSS_RE (6*12) /* PSS processing options */ -#define PSS_ACCUMULATE_ABS // If enabled, accumulates the correlation absolute value on consecutive calls to pss_synch_find_pss +#define SRSLTE_PSS_ACCUMULATE_ABS // If enabled, accumulates the correlation absolute value on consecutive calls to srslte_pss_synch_find_pss -#define PSS_ABS_SQUARE // If enabled, compute abs square, otherwise computes absolute value only +#define SRSLTE_PSS_ABS_SQUARE // If enabled, compute abs square, otherwise computes absolute value only -#define PSS_RETURN_PSR // If enabled returns peak to side-lobe ratio, otherwise returns absolute peak value +#define SRSLTE_PSS_RETURN_PSR // If enabled returns peak to side-lobe ratio, otherwise returns absolute peak value /** - * The pss_synch_t object provides functions for fast computation of the crosscorrelation - * between the PSS and received signal and CFO estimation. Also, the function pss_synch_periodic() is designed + * The srslte_pss_synch_t object provides functions for fast computation of the crosscorrelation + * between the PSS and received signal and CFO estimation. Also, the function srslte_pss_synch_tperiodic() is designed * to be called periodically every subframe, taking care of the correct data alignment with respect * to the PSS sequence. * @@ -70,14 +70,14 @@ typedef struct SRSLTE_API { srslte_dft_plan_t dftp_input; #ifdef CONVOLUTION_FFT - conv_fft_cc_t conv_fft; + srslte_conv_fft_cc_t conv_fft; #endif uint32_t frame_size; uint32_t N_id_2; uint32_t fft_size; - cf_t pss_signal_time[3][PSS_LEN]; + cf_t pss_signal_time[3][SRSLTE_PSS_LEN]; cf_t *pss_signal_freq[3]; // One sequence for each N_id_2 cf_t *tmp_input; cf_t *conv_output; @@ -85,53 +85,53 @@ typedef struct SRSLTE_API { float ema_alpha; float *conv_output_avg; float peak_value; -}pss_synch_t; +}srslte_pss_synch_t; typedef enum { PSS_TX, PSS_RX } pss_direction_t; /* Basic functionality */ -SRSLTE_API int pss_synch_init_fft(pss_synch_t *q, - uint32_t frame_size, - uint32_t fft_size); +SRSLTE_API int srslte_pss_synch_init_fft(srslte_pss_synch_t *q, + uint32_t frame_size, + uint32_t fft_size); -SRSLTE_API int pss_synch_init(pss_synch_t *q, - uint32_t frame_size); +SRSLTE_API int srslte_pss_synch_init(srslte_pss_synch_t *q, + uint32_t frame_size); -SRSLTE_API void pss_synch_free(pss_synch_t *q); +SRSLTE_API void srslte_pss_synch_free(srslte_pss_synch_t *q); -SRSLTE_API void pss_synch_reset(pss_synch_t *q); +SRSLTE_API void srslte_pss_synch_reset(srslte_pss_synch_t *q); -SRSLTE_API int pss_generate(cf_t *signal, - uint32_t N_id_2); +SRSLTE_API int srslte_pss_generate(cf_t *signal, + uint32_t N_id_2); -SRSLTE_API void pss_put_slot(cf_t *pss_signal, - cf_t *slot, - uint32_t nof_prb, - srslte_cp_t cp); +SRSLTE_API void srslte_pss_put_slot(cf_t *pss_signal, + cf_t *slot, + uint32_t nof_prb, + srslte_cp_t cp); -SRSLTE_API void pss_synch_set_ema_alpha(pss_synch_t *q, - float alpha); +SRSLTE_API void srslte_pss_synch_set_ema_alpha(srslte_pss_synch_t *q, + float alpha); -SRSLTE_API int pss_synch_set_N_id_2(pss_synch_t *q, - uint32_t N_id_2); +SRSLTE_API int srslte_pss_synch_set_N_id_2(srslte_pss_synch_t *q, + uint32_t N_id_2); -SRSLTE_API int pss_synch_find_pss(pss_synch_t *q, - cf_t *input, - float *corr_peak_value); +SRSLTE_API int srslte_pss_synch_find_pss(srslte_pss_synch_t *q, + cf_t *input, + float *corr_peak_value); -SRSLTE_API int pss_synch_chest(pss_synch_t *q, - cf_t *input, - cf_t ce[PSS_LEN]); +SRSLTE_API int srslte_pss_synch_chest(srslte_pss_synch_t *q, + cf_t *input, + cf_t ce[SRSLTE_PSS_LEN]); -SRSLTE_API float pss_synch_cfo_compute(pss_synch_t* q, - cf_t *pss_recv); +SRSLTE_API float srslte_pss_synch_cfo_compute(srslte_pss_synch_t* q, + cf_t *pss_recv); /* High-level API */ typedef struct SRSLTE_API { - pss_synch_t obj; - struct pss_synch_init { + srslte_pss_synch_t obj; + struct srslte_pss_synch_init { int frame_size; // if 0, 2048 int unsync_nof_pkts; int N_id_2; @@ -139,19 +139,19 @@ typedef struct SRSLTE_API { } init; cf_t *input; int in_len; - struct pss_synch_ctrl_in { + struct srslte_pss_synch_tctrl_in { int correlation_threshold; float manual_cfo; } ctrl_in; cf_t *output; int out_len; -}pss_synch_hl; +}srslte_pss_synch_hl; #define DEFAULT_FRAME_SIZE 2048 -SRSLTE_API int pss_synch_initialize(pss_synch_hl* h); -SRSLTE_API int pss_synch_work(pss_synch_hl* hl); -SRSLTE_API int pss_synch_stop(pss_synch_hl* hl); +SRSLTE_API int srslte_pss_synch_initialize(srslte_pss_synch_hl* h); +SRSLTE_API int srslte_pss_synch_twork(srslte_pss_synch_hl* hl); +SRSLTE_API int srslte_pss_synch_tstop(srslte_pss_synch_hl* hl); #endif // PSS_ diff --git a/srslte/include/srslte/sync/sfo.h b/srslte/include/srslte/sync/sfo.h index f5e05eecc..a50252fe5 100644 --- a/srslte/include/srslte/sync/sfo.h +++ b/srslte/include/srslte/sync/sfo.h @@ -31,7 +31,13 @@ #include "srslte/config.h" -SRSLTE_API float sfo_estimate(int *t0, int len, float period); -SRSLTE_API float sfo_estimate_period(int *t0, int *t, int len, float period); +SRSLTE_API float srslte_sfo_estimate(int *t0, + int len, + float period); + +SRSLTE_API float srslte_sfo_estimate_period(int *t0, + int *t, + int len, + float period); #endif // SFO_ diff --git a/srslte/include/srslte/sync/sss.h b/srslte/include/srslte/sync/sss.h index a1236b3e9..d56bf2c62 100644 --- a/srslte/include/srslte/sync/sss.h +++ b/srslte/include/srslte/sync/sss.h @@ -34,29 +34,29 @@ #include "srslte/config.h" #include "srslte/common/phy_common.h" -#include "srslte/utils/dft.h" +#include "srslte/dft/dft.h" typedef _Complex float cf_t; /* this is only a shortcut */ -#define N_SSS 31 -#define SSS_LEN 2*N_SSS +#define SRSLTE_SSS_N 31 +#define SRSLTE_SSS_LEN 2*SRSLTE_SSS_N -struct sss_tables{ - int z1[N_SSS][N_SSS]; - int c[2][N_SSS]; - int s[N_SSS][N_SSS]; -}; +typedef struct SRSLTE_API { + int z1[SRSLTE_SSS_N][SRSLTE_SSS_N]; + int c[2][SRSLTE_SSS_N]; + int s[SRSLTE_SSS_N][SRSLTE_SSS_N]; +}srslte_sss_tables_t; /* Allocate 32 complex to make it multiple of 32-byte AVX instructions alignment requirement. - * Should use vec_malloc() to make it platform agnostic. + * Should use srslte_vec_malloc() to make it platform agnostic. */ -struct fc_tables{ - float z1[N_SSS][N_SSS]; - float c[2][N_SSS]; - float s[N_SSS][N_SSS]; - float sd[N_SSS][N_SSS-1]; -}; +typedef struct SRSLTE_API { + float z1[SRSLTE_SSS_N][SRSLTE_SSS_N]; + float c[2][SRSLTE_SSS_N]; + float s[SRSLTE_SSS_N][SRSLTE_SSS_N]; + float sd[SRSLTE_SSS_N][SRSLTE_SSS_N-1]; +}srslte_sss_fc_tables_t; /* Low-level API */ @@ -72,107 +72,107 @@ typedef struct SRSLTE_API { uint32_t N_id_2; uint32_t N_id_1_table[30][30]; - struct fc_tables fc_tables[3]; // one for each N_id_2 + srslte_sss_fc_tables_t fc_tables[3]; // one for each N_id_2 - float corr_output_m0[N_SSS]; - float corr_output_m1[N_SSS]; + float corr_output_m0[SRSLTE_SSS_N]; + float corr_output_m1[SRSLTE_SSS_N]; -}sss_synch_t; +}srslte_sss_synch_t; /* Basic functionality */ -SRSLTE_API int sss_synch_init(sss_synch_t *q, - uint32_t fft_size); - -SRSLTE_API int sss_synch_realloc(sss_synch_t *q, - uint32_t fft_size); - -SRSLTE_API void sss_synch_free(sss_synch_t *q); - -SRSLTE_API void sss_generate(float *signal0, - float *signal5, - uint32_t cell_id); - -SRSLTE_API void sss_put_slot(float *sss, - cf_t *symbol, - uint32_t nof_prb, - srslte_cp_t cp); - -SRSLTE_API int sss_synch_set_N_id_2(sss_synch_t *q, - uint32_t N_id_2); - -SRSLTE_API int sss_synch_m0m1_partial(sss_synch_t *q, - cf_t *input, - uint32_t M, - cf_t ce[2*N_SSS], - uint32_t *m0, - float *m0_value, - uint32_t *m1, - float *m1_value); - -SRSLTE_API int sss_synch_m0m1_diff_coh(sss_synch_t *q, - cf_t *input, - cf_t ce[2*N_SSS], - uint32_t *m0, - float *m0_value, - uint32_t *m1, - float *m1_value); - -SRSLTE_API int sss_synch_m0m1_diff(sss_synch_t *q, - cf_t *input, - uint32_t *m0, - float *m0_value, - uint32_t *m1, - float *m1_value); - - -SRSLTE_API uint32_t sss_synch_subframe(uint32_t m0, +SRSLTE_API int srslte_sss_synch_init(srslte_sss_synch_t *q, + uint32_t fft_size); + +SRSLTE_API int srslte_sss_synch_realloc(srslte_sss_synch_t *q, + uint32_t fft_size); + +SRSLTE_API void srslte_sss_synch_free(srslte_sss_synch_t *q); + +SRSLTE_API void srslte_sss_generate(float *signal0, + float *signal5, + uint32_t cell_id); + +SRSLTE_API void srslte_sss_put_slot(float *sss, + cf_t *symbol, + uint32_t nof_prb, + srslte_cp_t cp); + +SRSLTE_API int srslte_sss_synch_set_N_id_2(srslte_sss_synch_t *q, + uint32_t N_id_2); + +SRSLTE_API int srslte_sss_synch_m0m1_partial(srslte_sss_synch_t *q, + cf_t *input, + uint32_t M, + cf_t ce[2*SRSLTE_SSS_N], + uint32_t *m0, + float *m0_value, + uint32_t *m1, + float *m1_value); + +SRSLTE_API int srslte_sss_synch_m0m1_diff_coh(srslte_sss_synch_t *q, + cf_t *input, + cf_t ce[2*SRSLTE_SSS_N], + uint32_t *m0, + float *m0_value, + uint32_t *m1, + float *m1_value); + +SRSLTE_API int srslte_sss_synch_m0m1_diff(srslte_sss_synch_t *q, + cf_t *input, + uint32_t *m0, + float *m0_value, + uint32_t *m1, + float *m1_value); + + +SRSLTE_API uint32_t srslte_sss_synch_subframe(uint32_t m0, + uint32_t m1); + +SRSLTE_API int srslte_sss_synch_N_id_1(srslte_sss_synch_t *q, + uint32_t m0, uint32_t m1); -SRSLTE_API int sss_synch_N_id_1(sss_synch_t *q, - uint32_t m0, - uint32_t m1); - -SRSLTE_API int sss_synch_frame(sss_synch_t *q, - cf_t *input, - uint32_t *subframe_idx, - uint32_t *N_id_1); +SRSLTE_API int srslte_sss_synch_frame(srslte_sss_synch_t *q, + cf_t *input, + uint32_t *subframe_idx, + uint32_t *N_id_1); -SRSLTE_API void sss_synch_set_threshold(sss_synch_t *q, - float threshold); +SRSLTE_API void srslte_sss_synch_set_threshold(srslte_sss_synch_t *q, + float threshold); -SRSLTE_API void sss_synch_set_symbol_sz(sss_synch_t *q, - uint32_t symbol_sz); +SRSLTE_API void srslte_sss_synch_set_symbol_sz(srslte_sss_synch_t *q, + uint32_t symbol_sz); -SRSLTE_API void sss_synch_set_subframe_sz(sss_synch_t *q, - uint32_t subframe_sz); +SRSLTE_API void srslte_sss_synch_set_subframe_sz(srslte_sss_synch_t *q, + uint32_t subframe_sz); /* High-level API */ typedef struct SRSLTE_API { - sss_synch_t obj; - struct sss_synch_init { + srslte_sss_synch_t obj; + struct srslte_sss_synch_init { uint32_t N_id_2; } init; cf_t *input; uint32_t in_len; - struct sss_synch_ctrl_in { + struct srslte_sss_synch_ctrl_in { uint32_t symbol_sz; uint32_t subframe_sz; uint32_t correlation_threshold; } ctrl_in; - struct sss_synch_ctrl_out { + struct srslte_sss_synch_ctrl_out { uint32_t subframe_idx; uint32_t N_id_1; } ctrl_out; -}sss_synch_hl; +}srslte_sss_synch_hl; #define DEFAULT_FRAME_SIZE 2048 -SRSLTE_API int sss_synch_initialize(sss_synch_hl* h); -SRSLTE_API int sss_synch_work(sss_synch_hl* hl); -SRSLTE_API int sss_synch_stop(sss_synch_hl* hl); +SRSLTE_API int srslte_sss_synch_initialize(srslte_sss_synch_hl* h); +SRSLTE_API int srslte_sss_synch_work(srslte_sss_synch_hl* hl); +SRSLTE_API int srslte_sss_synch_stop(srslte_sss_synch_hl* hl); #endif // SSS_ diff --git a/srslte/include/srslte/sync/sync.h b/srslte/include/srslte/sync/sync.h index 8de98f8e1..91d30a1fb 100644 --- a/srslte/include/srslte/sync/sync.h +++ b/srslte/include/srslte/sync/sync.h @@ -37,8 +37,8 @@ #include "srslte/sync/sss.h" #include "srslte/sync/cfo.h" -#define FFT_SIZE_MIN 64 -#define FFT_SIZE_MAX 2048 +#define SRSLTE_SYNC_FFT_SZ_MIN 64 +#define SRSLTE_SYNC_FFT_SZ_MAX 2048 /** * @@ -55,8 +55,8 @@ typedef enum {SSS_DIFF=0, SSS_PARTIAL_3=2, SSS_FULL=1} sss_alg_t; typedef struct SRSLTE_API { - pss_synch_t pss; - sss_synch_t sss; + srslte_pss_synch_t pss; + srslte_sss_synch_t sss; float threshold; float peak_value; float mean_peak_value; @@ -66,7 +66,7 @@ typedef struct SRSLTE_API { uint32_t fft_size; uint32_t frame_size; float mean_cfo; - cfo_t cfocorr; + srslte_cfo_t cfocorr; sss_alg_t sss_alg; bool detect_cp; bool sss_en; @@ -79,79 +79,80 @@ typedef struct SRSLTE_API { float M_norm_avg; float M_ext_avg; -}sync_t; +}srslte_sync_t; -SRSLTE_API int sync_init(sync_t *q, - uint32_t frame_size, - uint32_t fft_size); +SRSLTE_API int srslte_sync_init(srslte_sync_t *q, + uint32_t frame_size, + uint32_t fft_size); -SRSLTE_API void sync_free(sync_t *q); +SRSLTE_API void srslte_sync_free(srslte_sync_t *q); -SRSLTE_API void sync_reset(sync_t *q); +SRSLTE_API void srslte_sync_reset(srslte_sync_t *q); /* Finds a correlation peak in the input signal around position find_offset */ -SRSLTE_API int sync_find(sync_t *q, - cf_t *input, - uint32_t find_offset, - uint32_t *peak_position); +SRSLTE_API int srslte_sync_find(srslte_sync_t *q, + cf_t *input, + uint32_t find_offset, + uint32_t *peak_position); /* Estimates the CP length */ -SRSLTE_API srslte_cp_t sync_detect_cp(sync_t *q, - cf_t *input, - uint32_t peak_pos); +SRSLTE_API srslte_cp_t srslte_sync_detect_cp(srslte_sync_t *q, + cf_t *input, + uint32_t peak_pos); /* Sets the threshold for peak comparison */ -SRSLTE_API void sync_set_threshold(sync_t *q, - float threshold); +SRSLTE_API void srslte_sync_set_threshold(srslte_sync_t *q, + float threshold); /* Gets the subframe idx (0 or 5) */ -SRSLTE_API uint32_t sync_get_sf_idx(sync_t *q); +SRSLTE_API uint32_t srslte_sync_get_sf_idx(srslte_sync_t *q); /* Gets the last peak value */ -SRSLTE_API float sync_get_last_peak_value(sync_t *q); +SRSLTE_API float srslte_sync_get_last_peak_value(srslte_sync_t *q); /* Gets the mean peak value */ -SRSLTE_API float sync_get_peak_value(sync_t *q); +SRSLTE_API float srslte_sync_get_peak_value(srslte_sync_t *q); /* Choose SSS detection algorithm */ -SRSLTE_API void sync_set_sss_algorithm(sync_t *q, - sss_alg_t alg); +SRSLTE_API void srslte_sync_set_sss_algorithm(srslte_sync_t *q, + sss_alg_t alg); /* Sets PSS exponential averaging alpha weight */ -SRSLTE_API void sync_set_em_alpha(sync_t *q, - float alpha); +SRSLTE_API void srslte_sync_set_em_alpha(srslte_sync_t *q, + float alpha); /* Sets the N_id_2 to search for */ -SRSLTE_API int sync_set_N_id_2(sync_t *q, - uint32_t N_id_2); +SRSLTE_API int srslte_sync_set_N_id_2(srslte_sync_t *q, + uint32_t N_id_2); /* Gets the Physical CellId from the last call to synch_run() */ -SRSLTE_API int sync_get_cell_id(sync_t *q); +SRSLTE_API int srslte_sync_get_cell_id(srslte_sync_t *q); /* Gets the CFO estimation from the last call to synch_run() */ -SRSLTE_API float sync_get_cfo(sync_t *q); +SRSLTE_API float srslte_sync_get_cfo(srslte_sync_t *q); /* Gets the CP length estimation from the last call to synch_run() */ -SRSLTE_API srslte_cp_t sync_get_cp(sync_t *q); +SRSLTE_API srslte_cp_t srslte_sync_get_cp(srslte_sync_t *q); /* Sets the CP length estimation (must do it if disabled) */ -SRSLTE_API void sync_set_cp(sync_t *q, srslte_cp_t cp); +SRSLTE_API void srslte_sync_set_cp(srslte_sync_t *q, + srslte_cp_t cp); /* Enables/Disables SSS detection */ -SRSLTE_API void sync_sss_en(sync_t *q, - bool enabled); +SRSLTE_API void srslte_sync_sss_en(srslte_sync_t *q, + bool enabled); -SRSLTE_API bool sync_sss_detected(sync_t *q); +SRSLTE_API bool srslte_sync_sss_detected(srslte_sync_t *q); -SRSLTE_API bool sync_sss_is_en(sync_t *q); +SRSLTE_API bool srslte_sync_sss_is_en(srslte_sync_t *q); /* Enables/Disables CP detection */ -SRSLTE_API void sync_cp_en(sync_t *q, - bool enabled); +SRSLTE_API void srslte_sync_cp_en(srslte_sync_t *q, + bool enabled); -SRSLTE_API void sync_correct_cfo(sync_t *q, - bool enabled); +SRSLTE_API void srslte_sync_correct_cfo(srslte_sync_t *q, + bool enabled); #endif // SYNC_ diff --git a/srslte/include/srslte/ue/ue_cell_search.h b/srslte/include/srslte/ue/ue_cell_search.h index c087b8518..b80dbcfbb 100644 --- a/srslte/include/srslte/ue/ue_cell_search.h +++ b/srslte/include/srslte/ue/ue_cell_search.h @@ -36,7 +36,7 @@ #include "srslte/sync/cfo.h" #include "srslte/ch_estimation/chest_dl.h" #include "srslte/phch/pbch.h" -#include "srslte/common/fft.h" +#include "srslte/dft/ofdm.h" /************************************************************ * @@ -44,8 +44,8 @@ * several synchronized frames and obtains the most common cell_id * and cp length. * - * The I/O stream device sampling frequency must be set to 1.92 MHz (CS_SAMP_FREQ constant) - * before calling to ue_cell_search_scan() functions. + * The I/O stream device sampling frequency must be set to 1.92 MHz (SRSLTE_CS_SAMP_FREQ constant) + * before calling to srslte_ue_cellsearch_scan() functions. * ************************************************************/ @@ -53,14 +53,14 @@ * TODO: Check also peak offset */ -#define CS_DEFAULT_MAXFRAMES_TOTAL 500 -#define CS_DEFAULT_MAXFRAMES_DETECTED 50 +#define SRSLTE_CS_DEFAULT_MAXFRAMES_TOTAL 500 +#define SRSLTE_CS_DEFAULT_MAXFRAMES_DETECTED 50 -#define CS_DEFAULT_NOFFRAMES_TOTAL 50 -#define CS_DEFAULT_NOFFRAMES_DETECTED 10 +#define SRSLTE_CS_DEFAULT_NOFFRAMES_TOTAL 50 +#define SRSLTE_CS_DEFAULT_NOFFRAMES_DETECTED 10 -#define CS_NOF_PRB 6 -#define CS_SAMP_FREQ 1920000.0 +#define SRSLTE_CS_NOF_PRB 6 +#define SRSLTE_CS_SAMP_FREQ 1920000.0 typedef struct SRSLTE_API { uint32_t cell_id; @@ -68,11 +68,11 @@ typedef struct SRSLTE_API { float peak; float mode; float psr; -} ue_cell_search_result_t; +} srslte_ue_cellsearch_result_t; typedef struct SRSLTE_API { - ue_sync_t ue_sync; + srslte_ue_sync_t ue_sync; uint32_t max_frames; uint32_t nof_frames_to_scan; // number of 5 ms frames to scan @@ -81,34 +81,34 @@ typedef struct SRSLTE_API { uint32_t *mode_ntimes; uint8_t *mode_counted; - ue_cell_search_result_t *candidates; -} ue_cell_search_t; + srslte_ue_cellsearch_result_t *candidates; +} srslte_ue_cellsearch_t; -SRSLTE_API int ue_cell_search_init(ue_cell_search_t *q, - int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*), - void *stream_handler); +SRSLTE_API int srslte_ue_cellsearch_init(srslte_ue_cellsearch_t *q, + int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*), + void *stream_handler); -SRSLTE_API int ue_cell_search_init_max(ue_cell_search_t *q, - uint32_t max_frames_total, - int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*), - void *stream_handler); +SRSLTE_API int srslte_ue_cellsearch_init_max(srslte_ue_cellsearch_t *q, + uint32_t max_frames_total, + int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*), + void *stream_handler); -SRSLTE_API void ue_cell_search_free(ue_cell_search_t *q); +SRSLTE_API void srslte_ue_cellsearch_free(srslte_ue_cellsearch_t *q); -SRSLTE_API int ue_cell_search_scan_N_id_2(ue_cell_search_t *q, - uint32_t N_id_2, - ue_cell_search_result_t *found_cell); +SRSLTE_API int srslte_ue_cellsearch_scan_N_id_2(srslte_ue_cellsearch_t *q, + uint32_t N_id_2, + srslte_ue_cellsearch_result_t *found_cell); -SRSLTE_API int ue_cell_search_scan(ue_cell_search_t * q, - ue_cell_search_result_t found_cells[3], - uint32_t *max_N_id_2); +SRSLTE_API int srslte_ue_cellsearch_scan(srslte_ue_cellsearch_t * q, + srslte_ue_cellsearch_result_t found_cells[3], + uint32_t *max_N_id_2); -SRSLTE_API int ue_cell_search_set_nof_frames_to_scan(ue_cell_search_t *q, - uint32_t nof_frames); +SRSLTE_API int srslte_ue_cellsearch_set_nof_frames_to_scan(srslte_ue_cellsearch_t *q, + uint32_t nof_frames); -SRSLTE_API void ue_cell_search_set_threshold(ue_cell_search_t *q, - float threshold); +SRSLTE_API void srslte_ue_cellsearch_set_threshold(srslte_ue_cellsearch_t *q, + float threshold); diff --git a/srslte/include/srslte/ue/ue_dl.h b/srslte/include/srslte/ue/ue_dl.h index 9a3cdb371..a1443880d 100644 --- a/srslte/include/srslte/ue/ue_dl.h +++ b/srslte/include/srslte/ue/ue_dl.h @@ -37,7 +37,7 @@ #include "srslte/ch_estimation/chest_dl.h" -#include "srslte/common/fft.h" +#include "srslte/dft/ofdm.h" #include "srslte/common/phy_common.h" #include "srslte/phch/dci.h" @@ -53,18 +53,18 @@ #include "srslte/config.h" -#define NOF_HARQ_PROCESSES 8 +#define SRSLTE_UE_UL_NOF_HARQ_PROCESSES 8 typedef struct SRSLTE_API { - pcfich_t pcfich; - pdcch_t pdcch; - pdsch_t pdsch; - harq_t harq_process[NOF_HARQ_PROCESSES]; - regs_t regs; - srslte_fft_t fft; + srslte_pcfich_t pcfich; + srslte_pdcch_t pdcch; + srslte_pdsch_t pdsch; + srslte_harq_t harq_process[SRSLTE_UE_UL_NOF_HARQ_PROCESSES]; + srslte_regs_t regs; + srslte_ofdm_t fft; srslte_chest_dl_t chest; - ra_pdsch_t ra_dl; + srslte_ra_pdsch_t ra_dl; srslte_cell_t cell; @@ -73,57 +73,57 @@ typedef struct SRSLTE_API { uint64_t pkt_errors; uint64_t pkts_total; - uint64_t nof_pdcch_detected; + uint64_t nof_detected; uint16_t current_rnti; -}ue_dl_t; +}srs_ue_dl_t; /* This function shall be called just after the initial synchronization */ -SRSLTE_API int ue_dl_init(ue_dl_t *q, - srslte_cell_t cell); - -SRSLTE_API void ue_dl_free(ue_dl_t *q); - -SRSLTE_API int ue_dl_decode_fft_estimate(ue_dl_t *q, - cf_t *input, - uint32_t sf_idx, - uint32_t *cfi); - -SRSLTE_API int ue_dl_decode_rnti_rv_packet(ue_dl_t *q, - dci_msg_t *dci_msg, - uint8_t *data, - uint32_t cfi, - uint32_t sf_idx, - uint16_t rnti, - uint32_t rvidx); - -SRSLTE_API int ue_dl_find_ul_dci(ue_dl_t *q, - dci_msg_t *dci_msg, - uint32_t cfi, - uint32_t sf_idx, - uint16_t rnti); - -SRSLTE_API int ue_dl_decode(ue_dl_t * q, - cf_t *input, - uint8_t *data, - uint32_t sf_idx); - -SRSLTE_API int ue_dl_decode_rnti(ue_dl_t * q, - cf_t *input, - uint8_t *data, - uint32_t sf_idx, - uint16_t rnti); - -SRSLTE_API int ue_dl_decode_rnti_rv(ue_dl_t * q, - cf_t *input, - uint8_t * data, - uint32_t sf_idx, - uint16_t rnti, - uint32_t rvidx); - -SRSLTE_API void ue_dl_reset(ue_dl_t *q); - -SRSLTE_API void ue_dl_set_rnti(ue_dl_t *q, - uint16_t rnti); +SRSLTE_API int srs_ue_dl_init(srs_ue_dl_t *q, + srslte_cell_t cell); + +SRSLTE_API void srs_ue_dl_free(srs_ue_dl_t *q); + +SRSLTE_API int srs_ue_dl_decode_fft_estimate(srs_ue_dl_t *q, + cf_t *input, + uint32_t sf_idx, + uint32_t *cfi); + +SRSLTE_API int srs_ue_dl_decode_rnti_rv_packet(srs_ue_dl_t *q, + srslte_dci_msg_t *dci_msg, + uint8_t *data, + uint32_t cfi, + uint32_t sf_idx, + uint16_t rnti, + uint32_t rvidx); + +SRSLTE_API int srs_ue_dl_find_ul_dci(srs_ue_dl_t *q, + srslte_dci_msg_t *dci_msg, + uint32_t cfi, + uint32_t sf_idx, + uint16_t rnti); + +SRSLTE_API int srs_ue_dl_decode(srs_ue_dl_t * q, + cf_t *input, + uint8_t *data, + uint32_t sf_idx); + +SRSLTE_API int srs_ue_dl_decode_rnti(srs_ue_dl_t * q, + cf_t *input, + uint8_t *data, + uint32_t sf_idx, + uint16_t rnti); + +SRSLTE_API int srs_ue_dl_decode_rnti_rv(srs_ue_dl_t * q, + cf_t *input, + uint8_t * data, + uint32_t sf_idx, + uint16_t rnti, + uint32_t rvidx); + +SRSLTE_API void srs_ue_dl_reset(srs_ue_dl_t *q); + +SRSLTE_API void srs_ue_dl_set_rnti(srs_ue_dl_t *q, + uint16_t rnti); #endif \ No newline at end of file diff --git a/srslte/include/srslte/ue/ue_mac_itf.h b/srslte/include/srslte/ue/ue_mac_itf.h index 9e28d3643..5244197e1 100644 --- a/srslte/include/srslte/ue/ue_mac_itf.h +++ b/srslte/include/srslte/ue/ue_mac_itf.h @@ -1,5 +1,5 @@ -class ue_mac_itf +class srslte_ue_mac_itf { public: virtual void ready_to_send() = 0; diff --git a/srslte/include/srslte/ue/ue_mib.h b/srslte/include/srslte/ue/ue_mib.h index 41023ff50..dea6031ee 100644 --- a/srslte/include/srslte/ue/ue_mib.h +++ b/srslte/include/srslte/ue/ue_mib.h @@ -33,7 +33,7 @@ * * This object decodes the MIB from the PBCH of an LTE signal. * - * The function ue_mib_decode() shall be called multiple times, + * The function srslte_ue_mib_decode() shall be called multiple times, * each passing a number of samples multiple of 19200, sampled at 1.92 MHz * (that is, 10 ms of samples). * @@ -53,69 +53,69 @@ #include "srslte/sync/cfo.h" #include "srslte/ch_estimation/chest_dl.h" #include "srslte/phch/pbch.h" -#include "srslte/common/fft.h" +#include "srslte/dft/ofdm.h" -#define MIB_SRSLTE_MAX_PORTS 4 -#define MIB_NOF_PRB 6 +#define SRSLTE_UE_MIB_MAX_PORTS 4 +#define SRSLTE_UE_MIB_NOF_PRB 6 -#define MIB_FOUND 1 -#define MIB_NOTFOUND 0 +#define SRSLTE_UE_MIB_FOUND 1 +#define SRSLTE_UE_MIB_NOTFOUND 0 typedef struct SRSLTE_API { - sync_t sfind; + srslte_sync_t sfind; cf_t *sf_symbols; - cf_t *ce[MIB_SRSLTE_MAX_PORTS]; + cf_t *ce[SRSLTE_UE_MIB_MAX_PORTS]; - srslte_fft_t fft; + srslte_ofdm_t fft; srslte_chest_dl_t chest; - pbch_t pbch; + srslte_pbch_t pbch; uint8_t bch_payload[BCH_PAYLOAD_LEN]; uint32_t nof_tx_ports; uint32_t sfn_offset; uint32_t frame_cnt; -} ue_mib_t; +} srslte_ue_mib_t; -SRSLTE_API int ue_mib_init(ue_mib_t *q, - srslte_cell_t cell); +SRSLTE_API int srslte_ue_mib_init(srslte_ue_mib_t *q, + srslte_cell_t cell); -SRSLTE_API void ue_mib_free(ue_mib_t *q); +SRSLTE_API void srslte_ue_mib_free(srslte_ue_mib_t *q); -SRSLTE_API void ue_mib_reset(ue_mib_t * q); +SRSLTE_API void srslte_ue_mib_reset(srslte_ue_mib_t * q); -SRSLTE_API int ue_mib_decode(ue_mib_t * q, - cf_t *input, - uint8_t bch_payload[BCH_PAYLOAD_LEN], - uint32_t *nof_tx_ports, - uint32_t *sfn_offset); +SRSLTE_API int srslte_ue_mib_decode(srslte_ue_mib_t * q, + cf_t *input, + uint8_t bch_payload[BCH_PAYLOAD_LEN], + uint32_t *nof_tx_ports, + uint32_t *sfn_offset); /* This interface uses ue_mib and ue_sync to first get synchronized subframes * and then decode MIB */ typedef struct { - ue_mib_t ue_mib; - ue_sync_t ue_sync; -} ue_mib_sync_t; + srslte_ue_mib_t ue_mib; + srslte_ue_sync_t ue_sync; +} srslte_ue_mib_sync_t; -SRSLTE_API int ue_mib_sync_init(ue_mib_sync_t *q, - uint32_t cell_id, - srslte_cp_t cp, - int (recv_callback)(void*, void*, uint32_t, srslte_timestamp_t *), - void *stream_handler); +SRSLTE_API int srslte_ue_mib_sync_init(srslte_ue_mib_sync_t *q, + uint32_t cell_id, + srslte_cp_t cp, + int (recv_callback)(void*, void*, uint32_t, srslte_timestamp_t *), + void *stream_handler); -SRSLTE_API void ue_mib_sync_free(ue_mib_sync_t *q); +SRSLTE_API void srslte_ue_mib_sync_free(srslte_ue_mib_sync_t *q); -SRSLTE_API void ue_mib_sync_reset(ue_mib_sync_t * q); +SRSLTE_API void srslte_ue_mib_sync_reset(srslte_ue_mib_sync_t * q); -SRSLTE_API int ue_mib_sync_decode(ue_mib_sync_t * q, - uint32_t max_frames_timeout, - uint8_t bch_payload[BCH_PAYLOAD_LEN], - uint32_t *nof_tx_ports, - uint32_t *sfn_offset); +SRSLTE_API int srslte_ue_mib_sync_decode(srslte_ue_mib_sync_t * q, + uint32_t max_frames_timeout, + uint8_t bch_payload[BCH_PAYLOAD_LEN], + uint32_t *nof_tx_ports, + uint32_t *sfn_offset); diff --git a/srslte/include/srslte/ue/ue_phy.h b/srslte/include/srslte/ue/ue_phy.h index 019b865d5..e6edc7dd1 100644 --- a/srslte/include/srslte/ue/ue_phy.h +++ b/srslte/include/srslte/ue/ue_phy.h @@ -33,7 +33,7 @@ typedef _Complex float cf_t; -class ue_phy +class srslte_ue_phy { public: @@ -55,7 +55,7 @@ public: bool is_tpc_pucch = false; }; - class pdcch_dl_search : public queue::element { + class dl_search : public queue::element { public: set_crnti(uint16_t rnti); set_crnti_ra_procedure(uint16_t rnti); @@ -169,7 +169,7 @@ public: void set_param(); pdcch_ul_search* get_pdcch_ul_search(uint32_t tti); - pdcch_dl_search* get_pdcch_dl_search(uint32_t tti); + dl_search* get_dl_search(uint32_t tti); ul_assignment* get_ul_assignment(uint32_t tti); dl_assignment* get_dl_assignment(uint32_t tti); phich_assignment* get_phich_assignment(uint32_t tti); @@ -183,11 +183,11 @@ private: IDLE, MEASURE, RX_BCH, RXTX } phy_state; - bool prach_initiated = false; + bool srslte_prach_initiated = false; bool prach_ready_to_send = false; queue pdcch_ul_search; - queue pdcch_dl_search; + queue dl_search; queue ul_assignment; queue dl_assignment; queue phich_assignment; diff --git a/srslte/include/srslte/ue/ue_sync.h b/srslte/include/srslte/ue/ue_sync.h index a07c51007..a1c182a32 100644 --- a/srslte/include/srslte/ue/ue_sync.h +++ b/srslte/include/srslte/ue/ue_sync.h @@ -35,7 +35,7 @@ #include "srslte/sync/cfo.h" #include "srslte/ch_estimation/chest_dl.h" #include "srslte/phch/pbch.h" -#include "srslte/common/fft.h" +#include "srslte/dft/ofdm.h" #include "srslte/common/timestamp.h" #include "srslte/io/filesource.h" @@ -43,26 +43,26 @@ * * This object automatically manages the cell synchronization procedure. * - * The main function is ue_sync_get_buffer(), which returns a pointer + * The main function is srslte_ue_sync_get_buffer(), which returns a pointer * to the aligned subframe of samples (before FFT). This function * should be called regularly, returning every 1 ms. It reads from the * USRP, aligns the samples to the subframe and performs time/freq synch. * * It is also possible to read the signal from a file using the init function - * ue_sync_init_file(). The sampling frequency is derived from the number of PRB. + * srslte_ue_sync_init_file(). The sampling frequency is derived from the number of PRB. * * The function returns 1 when the signal is correctly acquired and the * returned buffer is aligned with the subframe. * *************************************************************/ -typedef enum SRSLTE_API { SF_FIND, SF_TRACK} ue_sync_state_t; +typedef enum SRSLTE_API { SF_FIND, SF_TRACK} srslte_ue_sync_state_t; //#define MEASURE_EXEC_TIME typedef struct SRSLTE_API { - sync_t sfind; - sync_t strack; + srslte_sync_t sfind; + srslte_sync_t strack; void *stream; int (*recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*); @@ -71,13 +71,13 @@ typedef struct SRSLTE_API { srslte_filesource_t file_source; bool file_mode; - ue_sync_state_t state; + srslte_ue_sync_state_t state; cf_t *input_buffer; uint32_t frame_len; uint32_t fft_size; - uint32_t nof_recv_sf; // Number of subframes received each call to ue_sync_get_buffer + uint32_t nof_recv_sf; // Number of subframes received each call to srslte_ue_sync_get_buffer uint32_t nof_avg_find_frames; uint32_t frame_find_cnt; uint32_t sf_len; @@ -102,43 +102,43 @@ typedef struct SRSLTE_API { #ifdef MEASURE_EXEC_TIME float mean_exec_time; #endif -} ue_sync_t; +} srslte_ue_sync_t; -SRSLTE_API int ue_sync_init(ue_sync_t *q, - srslte_cell_t cell, - int (recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*), - void *stream_handler); +SRSLTE_API int srslte_ue_sync_init(srslte_ue_sync_t *q, + srslte_cell_t cell, + int (recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*), + void *stream_handler); -SRSLTE_API int ue_sync_init_file(ue_sync_t *q, - uint32_t nof_prb, - char *file_name); +SRSLTE_API int srslte_ue_sync_init_file(srslte_ue_sync_t *q, + uint32_t nof_prb, + char *file_name); -SRSLTE_API void ue_sync_free(ue_sync_t *q); +SRSLTE_API void srslte_ue_sync_free(srslte_ue_sync_t *q); -SRSLTE_API uint32_t ue_sync_sf_len(ue_sync_t *q); +SRSLTE_API uint32_t srslte_ue_sync_sf_len(srslte_ue_sync_t *q); -SRSLTE_API int ue_sync_get_buffer(ue_sync_t *q, - cf_t **sf_symbols); +SRSLTE_API int srslte_ue_sync_get_buffer(srslte_ue_sync_t *q, + cf_t **sf_symbols); -SRSLTE_API void ue_sync_reset(ue_sync_t *q); +SRSLTE_API void srslte_ue_sync_reset(srslte_ue_sync_t *q); -SRSLTE_API void ue_sync_set_N_id_2(ue_sync_t *q, - uint32_t N_id_2); +SRSLTE_API void ue_srslte_sync_set_N_id_2(srslte_ue_sync_t *q, + uint32_t N_id_2); -SRSLTE_API void ue_sync_decode_sss_on_track(ue_sync_t *q, - bool enabled); +SRSLTE_API void srslte_ue_sync_decode_sss_on_track(srslte_ue_sync_t *q, + bool enabled); -SRSLTE_API ue_sync_state_t ue_sync_get_state(ue_sync_t *q); +SRSLTE_API srslte_ue_sync_state_t srslte_ue_sync_get_state(srslte_ue_sync_t *q); -SRSLTE_API uint32_t ue_sync_get_sfidx(ue_sync_t *q); +SRSLTE_API uint32_t srslte_ue_sync_get_sfidx(srslte_ue_sync_t *q); -SRSLTE_API float ue_sync_get_cfo(ue_sync_t *q); +SRSLTE_API float srslte_ue_sync_get_cfo(srslte_ue_sync_t *q); -SRSLTE_API float ue_sync_get_sfo(ue_sync_t *q); +SRSLTE_API float srslte_ue_sync_get_sfo(srslte_ue_sync_t *q); -SRSLTE_API void ue_sync_get_last_timestamp(ue_sync_t *q, - srslte_timestamp_t *timestamp); +SRSLTE_API void srslte_ue_sync_get_last_timestamp(srslte_ue_sync_t *q, + srslte_timestamp_t *timestamp); diff --git a/srslte/include/srslte/ue/ue_ul.h b/srslte/include/srslte/ue/ue_ul.h index e1e717665..d1865a067 100644 --- a/srslte/include/srslte/ue/ue_ul.h +++ b/srslte/include/srslte/ue/ue_ul.h @@ -37,7 +37,7 @@ #include "srslte/common/phy_common.h" #include "srslte/ch_estimation/chest_dl.h" -#include "srslte/common/fft.h" +#include "srslte/dft/ofdm.h" #include "srslte/ch_estimation/refsignal_ul.h" #include "srslte/phch/pusch.h" #include "srslte/phch/ra.h" @@ -47,76 +47,76 @@ #include "srslte/config.h" -#define NOF_HARQ_PROCESSES 8 +#define SRSLTE_UE_UL_NOF_HARQ_PROCESSES 8 typedef struct SRSLTE_API { - srslte_fft_t fft; - cfo_t cfo; + srslte_ofdm_t fft; + srslte_cfo_t cfo; srslte_cell_t cell; bool normalize_en; float current_cfo; - srslte_refsignal_drms_pusch_cfg_t pusch_drms_cfg; + srslte_refsignal_drms_pusch_cfg_t drms_cfg; srslte_refsignal_ul_t drms; - harq_t harq_process[NOF_HARQ_PROCESSES]; - pusch_t pusch; + srslte_harq_t harq_process[SRSLTE_UE_UL_NOF_HARQ_PROCESSES]; + srslte_pusch_t pusch; cf_t *refsignal; cf_t *sf_symbols; uint16_t current_rnti; -}ue_ul_t; +}srslte_ue_ul_t; /* This function shall be called just after the initial synchronization */ -SRSLTE_API int ue_ul_init(ue_ul_t *q, - srslte_cell_t cell); - -SRSLTE_API void ue_ul_free(ue_ul_t *q); - -SRSLTE_API void ue_ul_set_cfo(ue_ul_t *q, - float cur_cfo); - -SRSLTE_API void ue_ul_set_normalization(ue_ul_t *q, - bool enabled); - -SRSLTE_API void ue_ul_set_pusch_cfg(ue_ul_t *q, - srslte_refsignal_drms_pusch_cfg_t *pusch_drms_cfg, - pusch_hopping_cfg_t *pusch_hopping_cfg); - -SRSLTE_API int ue_ul_pusch_encode(ue_ul_t *q, - ra_pusch_t *ra_ul, - uint8_t *data, - uint32_t sf_idx, - cf_t *output_signal); - -SRSLTE_API int ue_ul_pusch_encode_rnti(ue_ul_t *q, - ra_pusch_t *ra_ul, - uint8_t *data, - uint32_t sf_idx, - uint16_t rnti, - cf_t *output_signal); - -SRSLTE_API int ue_ul_pusch_uci_encode(ue_ul_t *q, - ra_pusch_t *ra_ul, - uint8_t *data, - uci_data_t uci_data, - uint32_t sf_idx, - cf_t *output_signal); - -SRSLTE_API int ue_ul_pusch_uci_encode_rnti(ue_ul_t *q, - ra_pusch_t *ra_ul, - uint8_t *data, - uci_data_t uci_data, - uint32_t sf_idx, - uint16_t rnti, - cf_t *output_signal); - -SRSLTE_API void ue_ul_reset(ue_ul_t *q); - -SRSLTE_API void ue_ul_set_rnti(ue_ul_t *q, - uint16_t rnti); +SRSLTE_API int srslte_ue_ul_init(srslte_ue_ul_t *q, + srslte_cell_t cell); + +SRSLTE_API void srslte_ue_ul_free(srslte_ue_ul_t *q); + +SRSLTE_API void srslte_ue_ul_set_cfo(srslte_ue_ul_t *q, + float cur_cfo); + +SRSLTE_API void srslte_ue_ul_set_normalization(srslte_ue_ul_t *q, + bool enabled); + +SRSLTE_API void srslte_ue_ul_set_pusch_cfg(srslte_ue_ul_t *q, + srslte_refsignal_drms_pusch_cfg_t *drms_cfg, + srslte_pusch_hopping_cfg_t *pusch_hopping_cfg); + +SRSLTE_API int srslte_ue_ul_srslte_pusch_encode(srslte_ue_ul_t *q, + srslte_ra_pusch_t *ra_ul, + uint8_t *data, + uint32_t sf_idx, + cf_t *output_signal); + +SRSLTE_API int srslte_ue_ul_srslte_pusch_encode_rnti(srslte_ue_ul_t *q, + srslte_ra_pusch_t *ra_ul, + uint8_t *data, + uint32_t sf_idx, + uint16_t rnti, + cf_t *output_signal); + +SRSLTE_API int srslte_ue_ul_srslte_pusch_uci_encode(srslte_ue_ul_t *q, + srslte_ra_pusch_t *ra_ul, + uint8_t *data, + srslte_uci_data_t uci_data, + uint32_t sf_idx, + cf_t *output_signal); + +SRSLTE_API int srslte_ue_ul_srslte_pusch_uci_encode_rnti(srslte_ue_ul_t *q, + srslte_ra_pusch_t *ra_ul, + uint8_t *data, + srslte_uci_data_t uci_data, + uint32_t sf_idx, + uint16_t rnti, + cf_t *output_signal); + +SRSLTE_API void srslte_ue_ul_reset(srslte_ue_ul_t *q); + +SRSLTE_API void srslte_ue_ul_set_rnti(srslte_ue_ul_t *q, + uint16_t rnti); #endif \ No newline at end of file diff --git a/srslte/include/srslte/utils/bit.h b/srslte/include/srslte/utils/bit.h index 2b7c55fe1..a1971dd93 100644 --- a/srslte/include/srslte/utils/bit.h +++ b/srslte/include/srslte/utils/bit.h @@ -34,30 +34,30 @@ #include "srslte/config.h" -SRSLTE_API void bit_pack_vector(uint8_t *bit_unpacked, - uint8_t *bits_packed, - int nof_bits); +SRSLTE_API void srslte_bit_pack_vector(uint8_t *srslte_bit_unpacked, + uint8_t *bits_packed, + int nof_bits); -SRSLTE_API void bit_unpack_vector(uint8_t *bits_packed, - uint8_t *bit_unpacked, - int nof_bits); +SRSLTE_API void srslte_bit_unpack_vector(uint8_t *bits_packed, + uint8_t *srslte_bit_unpacked, + int nof_bits); -SRSLTE_API uint32_t bit_unpack(uint8_t **bits, - int nof_bits); +SRSLTE_API uint32_t srslte_bit_unpack(uint8_t **bits, + int nof_bits); -SRSLTE_API void bit_pack(uint32_t value, - uint8_t **bits, - int nof_bits); +SRSLTE_API void srslte_bit_pack(uint32_t value, + uint8_t **bits, + int nof_bits); -SRSLTE_API void bit_fprint(FILE *stream, - uint8_t *bits, - int nof_bits); +SRSLTE_API void srslte_bit_fprint(FILE *stream, + uint8_t *bits, + int nof_bits); -SRSLTE_API uint32_t bit_diff(uint8_t *x, - uint8_t *y, - int nbits); +SRSLTE_API uint32_t srslte_bit_diff(uint8_t *x, + uint8_t *y, + int nbits); -SRSLTE_API uint32_t bit_count(uint32_t n); +SRSLTE_API uint32_t srslte_bit_count(uint32_t n); #endif // BIT_ diff --git a/srslte/include/srslte/utils/cexptab.h b/srslte/include/srslte/utils/cexptab.h index 3214686d5..a46d80f0b 100644 --- a/srslte/include/srslte/utils/cexptab.h +++ b/srslte/include/srslte/utils/cexptab.h @@ -38,20 +38,20 @@ typedef _Complex float cf_t; typedef struct SRSLTE_API { uint32_t size; cf_t *tab; -}cexptab_t; +}srslte_cexptab_t; -SRSLTE_API int cexptab_init(cexptab_t *nco, - uint32_t size); +SRSLTE_API int srslte_cexptab_init(srslte_cexptab_t *nco, + uint32_t size); -SRSLTE_API void cexptab_free(cexptab_t *nco); +SRSLTE_API void srslte_cexptab_free(srslte_cexptab_t *nco); -SRSLTE_API void cexptab_gen(cexptab_t *nco, - cf_t *x, - float freq, - uint32_t len); - -SRSLTE_API void cexptab_gen_direct(cf_t *x, +SRSLTE_API void srslte_cexptab_gen(srslte_cexptab_t *nco, + cf_t *x, float freq, uint32_t len); +SRSLTE_API void srslte_cexptab_gen_direct(cf_t *x, + float freq, + uint32_t len); + #endif // CEXPTAB_ diff --git a/srslte/include/srslte/utils/convolution.h b/srslte/include/srslte/utils/convolution.h index 181ca8159..930d94235 100644 --- a/srslte/include/srslte/utils/convolution.h +++ b/srslte/include/srslte/utils/convolution.h @@ -30,7 +30,7 @@ #define CONVOLUTION_H_ #include "srslte/config.h" -#include "srslte/utils/dft.h" +#include "srslte/dft/dft.h" typedef _Complex float cf_t; @@ -45,35 +45,35 @@ typedef struct SRSLTE_API { srslte_dft_plan_t input_plan; srslte_dft_plan_t filter_plan; srslte_dft_plan_t output_plan; -}conv_fft_cc_t; +}srslte_conv_fft_cc_t; -SRSLTE_API int conv_fft_cc_init(conv_fft_cc_t *q, - uint32_t input_len, - uint32_t filter_len); +SRSLTE_API int srslte_conv_fft_cc_init(srslte_conv_fft_cc_t *q, + uint32_t input_len, + uint32_t filter_len); -SRSLTE_API void conv_fft_cc_free(conv_fft_cc_t *q); +SRSLTE_API void srslte_conv_fft_cc_free(srslte_conv_fft_cc_t *q); -SRSLTE_API uint32_t conv_fft_cc_run(conv_fft_cc_t *q, - cf_t *input, - cf_t *filter, - cf_t *output); +SRSLTE_API uint32_t srslte_conv_fft_cc_run(srslte_conv_fft_cc_t *q, + cf_t *input, + cf_t *filter, + cf_t *output); -SRSLTE_API uint32_t conv_cc(cf_t *input, - cf_t *filter, - cf_t *output, - uint32_t input_len, - uint32_t filter_len); +SRSLTE_API uint32_t srslte_conv_cc(cf_t *input, + cf_t *filter, + cf_t *output, + uint32_t input_len, + uint32_t filter_len); -SRSLTE_API uint32_t conv_same_cf(cf_t *input, - float *filter, - cf_t *output, - uint32_t input_len, - uint32_t filter_len); +SRSLTE_API uint32_t srslte_conv_same_cf(cf_t *input, + float *filter, + cf_t *output, + uint32_t input_len, + uint32_t filter_len); -SRSLTE_API uint32_t conv_same_cc(cf_t *input, - cf_t *filter, - cf_t *output, - uint32_t input_len, - uint32_t filter_len); +SRSLTE_API uint32_t srslte_conv_same_cc(cf_t *input, + cf_t *filter, + cf_t *output, + uint32_t input_len, + uint32_t filter_len); #endif // CONVOLUTION_H_ diff --git a/srslte/include/srslte/utils/debug.h b/srslte/include/srslte/utils/debug.h index 8cc31a76c..c0218f0cb 100644 --- a/srslte/include/srslte/utils/debug.h +++ b/srslte/include/srslte/utils/debug.h @@ -31,36 +31,36 @@ #include #include "srslte/config.h" -#define VERBOSE_DEBUG 2 -#define VERBOSE_INFO 1 -#define VERBOSE_NONE 0 +#define SRSLTE_VERBOSE_DEBUG 2 +#define SRSLTE_VERBOSE_INFO 1 +#define SRSLTE_VERBOSE_NONE 0 #include SRSLTE_API void get_time_interval(struct timeval * tdata); -#ifndef DEBUG_DISABLED +#ifndef SRSLTE_DEBUG_DISABLED -SRSLTE_API extern int verbose; +SRSLTE_API extern int srslte_verbose; -#define VERBOSE_ISINFO() (verbose>=VERBOSE_INFO) -#define VERBOSE_ISDEBUG() (verbose>=VERBOSE_DEBUG) -#define VERBOSE_ISNONE() (verbose==VERBOSE_NONE) +#define SRSLTE_VERBOSE_ISINFO() (srslte_verbose>=SRSLTE_VERBOSE_INFO) +#define SRSLTE_VERBOSE_ISDEBUG() (srslte_verbose>=SRSLTE_VERBOSE_DEBUG) +#define SRSLTE_VERBOSE_ISNONE() (srslte_verbose==SRSLTE_VERBOSE_NONE) -#define PRINT_DEBUG verbose=VERBOSE_DEBUG -#define PRINT_INFO verbose=VERBOSE_INFO -#define PRINT_NONE verbose=VERBOSE_NONE +#define PRINT_DEBUG srslte_verbose=SRSLTE_VERBOSE_DEBUG +#define PRINT_INFO srslte_verbose=SRSLTE_VERBOSE_INFO +#define PRINT_NONE srslte_verbose=SRSLTE_VERBOSE_NONE -#define DEBUG(_fmt, ...) if (verbose >= VERBOSE_DEBUG) \ +#define DEBUG(_fmt, ...) if (srslte_verbose >= SRSLTE_VERBOSE_DEBUG) \ fprintf(stdout, "[DEBUG]: " _fmt, __VA_ARGS__) -#define INFO(_fmt, ...) if (verbose >= VERBOSE_INFO) \ +#define INFO(_fmt, ...) if (srslte_verbose >= SRSLTE_VERBOSE_INFO) \ fprintf(stdout, "[INFO]: " _fmt, __VA_ARGS__) -#else // DEBUG_DISABLED +#else // SRSLTE_DEBUG_DISABLED #define DEBUG #define INFO -#endif // DEBUG_DISABLED +#endif // SRSLTE_DEBUG_DISABLED #endif // DEBUG_H diff --git a/srslte/include/srslte/utils/matrix.h b/srslte/include/srslte/utils/matrix.h deleted file mode 100644 index a565ebc54..000000000 --- a/srslte/include/srslte/utils/matrix.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2014 The srsLTE Developers. See the - * COPYRIGHT file at the top-level directory of this distribution. - * - * \section LICENSE - * - * This file is part of the srsLTE library. - * - * srsLTE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsLTE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * A copy of the GNU Lesser General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - -#ifndef MATRIX_ -#define MATRIX_ - -#include -#include "srslte/config.h" - -typedef _Complex float cf_t; - -SRSLTE_API int matrix_init(void ***m, int sz_x, int sz_y, int elem_sz); -SRSLTE_API void matrix_free(void **q, int sz_x); -SRSLTE_API void matrix_bzero(void **q, int sz_x, int sz_y, int elem_sz); -SRSLTE_API void matrix_fprintf_cf(FILE *f, cf_t **q, int sz_x, int sz_y); -SRSLTE_API void matrix_fprintf_f(FILE *f, float **q, int sz_x, int sz_y); -SRSLTE_API void matrix_copy(void **dst, void **src, int sz_x, int sz_y, int elem_sz); -SRSLTE_API void matrix_dotprod_cf(cf_t **x, cf_t **y, cf_t **out, int sz_x, int sz_y); -SRSLTE_API void matrix_dotprod_float(float **x, float **y, float **out, int sz_x, int sz_y); -SRSLTE_API void matrix_dotprod_int(int **x, int **y, int **out, int sz_x, int sz_y); - -#endif // MATRIX_ - diff --git a/srslte/include/srslte/utils/mux.h b/srslte/include/srslte/utils/mux.h deleted file mode 100644 index 9d0ddeb48..000000000 --- a/srslte/include/srslte/utils/mux.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2014 The srsLTE Developers. See the - * COPYRIGHT file at the top-level directory of this distribution. - * - * \section LICENSE - * - * This file is part of the srsLTE library. - * - * srsLTE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsLTE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * A copy of the GNU Lesser General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - -#ifndef MUX_ -#define MUX_ - -#include "srslte/config.h" - -SRSLTE_API void mux(void **input, void *output, int *input_lengths, int *input_padding_pre, int nof_inputs, - int sample_sz); - -SRSLTE_API void demux(void *input, void **output, int *output_lengths, - int *output_padding_pre, int *output_padding_post, int nof_outputs, - int sample_sz); - -#endif // MUX_ diff --git a/srslte/include/srslte/utils/pack.h b/srslte/include/srslte/utils/pack.h deleted file mode 100644 index f5957d58c..000000000 --- a/srslte/include/srslte/utils/pack.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2014 The srsLTE Developers. See the - * COPYRIGHT file at the top-level directory of this distribution. - * - * \section LICENSE - * - * This file is part of the srsLTE library. - * - * srsLTE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsLTE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * A copy of the GNU Lesser General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - - -#ifndef PACK_ -#define PACK_ - -#include "srslte/config.h" -#include - -SRSLTE_API uint32_t unpack_bits(uint8_t **bits, - int nof_bits); - -SRSLTE_API void pack_bits(uint32_t value, - uint8_t **bits, - int nof_bits); - -#endif // PACK_ diff --git a/srslte/include/srslte/utils/queue.h b/srslte/include/srslte/utils/queue.h index 1c7abbeea..d5fd9a4ee 100644 --- a/srslte/include/srslte/utils/queue.h +++ b/srslte/include/srslte/utils/queue.h @@ -30,7 +30,7 @@ #ifndef QUEUE_H #define QUEUE_H -class queue +class srslte_queue { public: diff --git a/srslte/include/srslte/utils/vector.h b/srslte/include/srslte/utils/vector.h index 6e13ceb42..92b287b4b 100644 --- a/srslte/include/srslte/utils/vector.h +++ b/srslte/include/srslte/utils/vector.h @@ -40,106 +40,106 @@ extern "C" { typedef _Complex float cf_t; -#define MAX(a,b) ((a)>(b)?(a):(b)) -#define MIN(a,b) ((a)<(b)?(a):(b)) +#define SRSLTE_MAX(a,b) ((a)>(b)?(a):(b)) +#define SRSLTE_MIN(a,b) ((a)<(b)?(a):(b)) // Cumulative moving average -#define VEC_CMA(data, average, n) ((average) + ((data) - (average)) / ((n)+1)) +#define SRSLTE_VEC_CMA(data, average, n) ((average) + ((data) - (average)) / ((n)+1)) // Exponential moving average -#define VEC_EMA(data, average, alpha) ((alpha)*(data)+(1-alpha)*(average)) +#define SRSLTE_VEC_EMA(data, average, alpha) ((alpha)*(data)+(1-alpha)*(average)) /** Return the sum of all the elements */ -SRSLTE_API int vec_acc_ii(int *x, uint32_t len); -SRSLTE_API float vec_acc_ff(float *x, uint32_t len); -SRSLTE_API cf_t vec_acc_cc(cf_t *x, uint32_t len); +SRSLTE_API int srslte_vec_acc_ii(int *x, uint32_t len); +SRSLTE_API float srslte_vec_acc_ff(float *x, uint32_t len); +SRSLTE_API cf_t srslte_vec_acc_cc(cf_t *x, uint32_t len); -SRSLTE_API void *vec_malloc(uint32_t size); +SRSLTE_API void *srslte_vec_malloc(uint32_t size); -SRSLTE_API void *vec_realloc(void *ptr, uint32_t old_size, uint32_t new_size); +SRSLTE_API void *srslte_vec_realloc(void *ptr, uint32_t old_size, uint32_t new_size); /* print vectors */ -SRSLTE_API void vec_fprint_c(FILE *stream, cf_t *x, uint32_t len); -SRSLTE_API void vec_fprint_f(FILE *stream, float *x, uint32_t len); -SRSLTE_API void vec_fprint_b(FILE *stream, uint8_t *x, uint32_t len); -SRSLTE_API void vec_fprint_byte(FILE *stream, uint8_t *x, uint32_t len); -SRSLTE_API void vec_fprint_i(FILE *stream, int *x, uint32_t len); -SRSLTE_API void vec_fprint_hex(FILE *stream, uint8_t *x, uint32_t len); +SRSLTE_API void srslte_vec_fprint_c(FILE *stream, cf_t *x, uint32_t len); +SRSLTE_API void srslte_vec_fprint_f(FILE *stream, float *x, uint32_t len); +SRSLTE_API void srslte_vec_fprint_b(FILE *stream, uint8_t *x, uint32_t len); +SRSLTE_API void srslte_vec_fprint_byte(FILE *stream, uint8_t *x, uint32_t len); +SRSLTE_API void srslte_vec_fprint_i(FILE *stream, int *x, uint32_t len); +SRSLTE_API void srslte_vec_fprint_hex(FILE *stream, uint8_t *x, uint32_t len); /* Saves a vector to a file */ -SRSLTE_API void vec_save_file(char *filename, void *buffer, uint32_t len); +SRSLTE_API void srslte_vec_save_file(char *filename, void *buffer, uint32_t len); /* sum two vectors */ -SRSLTE_API void vec_sum_ch(uint8_t *x, uint8_t *y, char *z, uint32_t len); -SRSLTE_API void vec_sum_fff(float *x, float *y, float *z, uint32_t len); -SRSLTE_API void vec_sum_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); +SRSLTE_API void srslte_vec_sum_ch(uint8_t *x, uint8_t *y, char *z, uint32_t len); +SRSLTE_API void srslte_vec_sum_fff(float *x, float *y, float *z, uint32_t len); +SRSLTE_API void srslte_vec_sum_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); /* substract two vectors z=x-y */ -SRSLTE_API void vec_sub_fff(float *x, float *y, float *z, uint32_t len); -SRSLTE_API void vec_sub_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); +SRSLTE_API void srslte_vec_sub_fff(float *x, float *y, float *z, uint32_t len); +SRSLTE_API void srslte_vec_sub_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); /* Square distance */ -SRSLTE_API void vec_square_dist(cf_t symbol, cf_t *points, float *distance, uint32_t npoints); +SRSLTE_API void srslte_vec_square_dist(cf_t symbol, cf_t *points, float *distance, uint32_t npoints); /* scalar addition */ -SRSLTE_API void vec_sc_add_fff(float *x, float h, float *z, uint32_t len); -SRSLTE_API void vec_sc_add_cfc(cf_t *x, float h, cf_t *z, uint32_t len); -SRSLTE_API void vec_sc_add_ccc(cf_t *x, cf_t h, cf_t *z, uint32_t len); +SRSLTE_API void srslte_vec_sc_add_fff(float *x, float h, float *z, uint32_t len); +SRSLTE_API void srslte_vec_sc_add_cfc(cf_t *x, float h, cf_t *z, uint32_t len); +SRSLTE_API void srslte_vec_sc_add_ccc(cf_t *x, cf_t h, cf_t *z, uint32_t len); /* scalar product */ -SRSLTE_API void vec_sc_prod_cfc(cf_t *x, float h, cf_t *z, uint32_t len); -SRSLTE_API void vec_sc_prod_ccc(cf_t *x, cf_t h, cf_t *z, uint32_t len); -SRSLTE_API void vec_sc_prod_fff(float *x, float h, float *z, uint32_t len); +SRSLTE_API void srslte_vec_sc_prod_cfc(cf_t *x, float h, cf_t *z, uint32_t len); +SRSLTE_API void srslte_vec_sc_prod_ccc(cf_t *x, cf_t h, cf_t *z, uint32_t len); +SRSLTE_API void srslte_vec_sc_prod_fff(float *x, float h, float *z, uint32_t len); -SRSLTE_API void vec_convert_fi(float *x, int16_t *z, float scale, uint32_t len); +SRSLTE_API void srslte_vec_convert_fi(float *x, int16_t *z, float scale, uint32_t len); -SRSLTE_API void vec_deinterleave_cf(cf_t *x, float *real, float *imag, uint32_t len); -SRSLTE_API void vec_deinterleave_real_cf(cf_t *x, float *real, uint32_t len); +SRSLTE_API void srslte_vec_deinterleave_cf(cf_t *x, float *real, float *imag, uint32_t len); +SRSLTE_API void srslte_vec_deinterleave_real_cf(cf_t *x, float *real, uint32_t len); -SRSLTE_API void vec_interleave_cf(float *real, float *imag, cf_t *x, uint32_t len); +SRSLTE_API void srslte_vec_interleave_cf(float *real, float *imag, cf_t *x, uint32_t len); /* vector product (element-wise) */ -SRSLTE_API void vec_prod_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); +SRSLTE_API void srslte_vec_prod_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); /* vector product (element-wise) */ -SRSLTE_API void vec_prod_cfc(cf_t *x, float *y, cf_t *z, uint32_t len); +SRSLTE_API void srslte_vec_prod_cfc(cf_t *x, float *y, cf_t *z, uint32_t len); /* conjugate vector product (element-wise) */ -SRSLTE_API void vec_prod_conj_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); +SRSLTE_API void srslte_vec_prod_conj_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); /* Dot-product */ -SRSLTE_API cf_t vec_dot_prod_cfc(cf_t *x, float *y, uint32_t len); -SRSLTE_API cf_t vec_dot_prod_ccc(cf_t *x, cf_t *y, uint32_t len); -SRSLTE_API cf_t vec_dot_prod_conj_ccc(cf_t *x, cf_t *y, uint32_t len); -SRSLTE_API float vec_dot_prod_fff(float *x, float *y, uint32_t len); +SRSLTE_API cf_t srslte_vec_dot_prod_cfc(cf_t *x, float *y, uint32_t len); +SRSLTE_API cf_t srslte_vec_dot_prod_ccc(cf_t *x, cf_t *y, uint32_t len); +SRSLTE_API cf_t srslte_vec_dot_prod_conj_ccc(cf_t *x, cf_t *y, uint32_t len); +SRSLTE_API float srslte_vec_dot_prod_fff(float *x, float *y, uint32_t len); /* z=x/y vector division (element-wise) */ -SRSLTE_API void vec_div_ccc(cf_t *x, cf_t *y, float *y_mod, cf_t *z, float *z_real, float *z_imag, uint32_t len); -void vec_div_cfc(cf_t *x, float *y, cf_t *z, float *z_real, float *z_imag, uint32_t len); -SRSLTE_API void vec_div_fff(float *x, float *y, float *z, uint32_t len); +SRSLTE_API void srslte_vec_div_ccc(cf_t *x, cf_t *y, float *y_mod, cf_t *z, float *z_real, float *z_imag, uint32_t len); +void srslte_vec_div_cfc(cf_t *x, float *y, cf_t *z, float *z_real, float *z_imag, uint32_t len); +SRSLTE_API void srslte_vec_div_fff(float *x, float *y, float *z, uint32_t len); /* conjugate */ -SRSLTE_API void vec_conj_cc(cf_t *x, cf_t *y, uint32_t len); +SRSLTE_API void srslte_vec_conj_cc(cf_t *x, cf_t *y, uint32_t len); /* average vector power */ -SRSLTE_API float vec_avg_power_cf(cf_t *x, uint32_t len); +SRSLTE_API float srslte_vec_avg_power_cf(cf_t *x, uint32_t len); /* return the index of the maximum value in the vector */ -SRSLTE_API uint32_t vec_max_fi(float *x, uint32_t len); -SRSLTE_API uint32_t vec_max_abs_ci(cf_t *x, uint32_t len); +SRSLTE_API uint32_t srslte_vec_max_fi(float *x, uint32_t len); +SRSLTE_API uint32_t srslte_vec_max_abs_ci(cf_t *x, uint32_t len); /* maximum between two vectors */ -SRSLTE_API void vec_max_fff(float *x, float *y, float *z, uint32_t len); +SRSLTE_API void srslte_vec_max_fff(float *x, float *y, float *z, uint32_t len); /* quantify vector of floats and convert to uint8_t */ -SRSLTE_API void vec_quant_fuc(float *in, uint8_t *out, float gain, float offset, float clip, uint32_t len); +SRSLTE_API void srslte_vec_quant_fuc(float *in, uint8_t *out, float gain, float offset, float clip, uint32_t len); /* magnitude of each vector element */ -SRSLTE_API void vec_abs_cf(cf_t *x, float *abs, uint32_t len); -SRSLTE_API void vec_abs_square_cf(cf_t *x, float *abs_square, uint32_t len); +SRSLTE_API void srslte_vec_abs_cf(cf_t *x, float *abs, uint32_t len); +SRSLTE_API void srslte_vec_abs_square_cf(cf_t *x, float *abs_square, uint32_t len); /* argument of each vector element */ -SRSLTE_API void vec_arg_cf(cf_t *x, float *arg, uint32_t len); +SRSLTE_API void srslte_vec_arg_cf(cf_t *x, float *arg, uint32_t len); #ifdef __cplusplus } diff --git a/srslte/lib/agc/src/agc.c b/srslte/lib/agc/src/agc.c index 0953d6dcd..f00735ff9 100644 --- a/srslte/lib/agc/src/agc.c +++ b/srslte/lib/agc/src/agc.c @@ -81,10 +81,10 @@ void srslte_agc_lock(srslte_agc_t *q, bool enable) { void srslte_agc_process(srslte_agc_t *q, cf_t *input, cf_t *output, uint32_t len) { // Apply current gain to input signal - vec_sc_prod_cfc(input, q->gain, output, len); + srslte_vec_sc_prod_cfc(input, q->gain, output, len); // compute output energy estimate - float y = sqrtf(crealf(vec_dot_prod_conj_ccc(output, output, len))/len); + float y = sqrtf(crealf(srslte_vec_dot_prod_conj_ccc(output, output, len))/len); if (q->isfirst) { q->y_out = y; diff --git a/srslte/lib/ch_estimation/src/chest_dl.c b/srslte/lib/ch_estimation/src/chest_dl.c index 91d3e8934..a72ae29c0 100644 --- a/srslte/lib/ch_estimation/src/chest_dl.c +++ b/srslte/lib/ch_estimation/src/chest_dl.c @@ -69,25 +69,25 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell) goto clean_exit; } - q->tmp_freqavg = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(cell.nof_prb)); + q->tmp_freqavg = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(cell.nof_prb)); if (!q->tmp_freqavg) { perror("malloc"); goto clean_exit; } - q->tmp_noise = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(cell.nof_prb)); + q->tmp_noise = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(cell.nof_prb)); if (!q->tmp_noise) { perror("malloc"); goto clean_exit; } for (int i=0;itmp_timeavg[i] = vec_malloc(sizeof(cf_t) * 2*cell.nof_prb); + q->tmp_timeavg[i] = srslte_vec_malloc(sizeof(cf_t) * 2*cell.nof_prb); if (!q->tmp_timeavg[i]) { perror("malloc"); goto clean_exit; } bzero(q->tmp_timeavg[i], sizeof(cf_t) * 2*cell.nof_prb); } - q->tmp_timeavg_mult = vec_malloc(sizeof(cf_t) * 2*cell.nof_prb); + q->tmp_timeavg_mult = srslte_vec_malloc(sizeof(cf_t) * 2*cell.nof_prb); if (!q->tmp_timeavg_mult) { perror("malloc"); goto clean_exit; @@ -95,17 +95,17 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell) bzero(q->tmp_timeavg_mult, sizeof(cf_t) * 2*cell.nof_prb); for (int i=0;ipilot_estimates[i] = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i)); + q->pilot_estimates[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i)); if (!q->pilot_estimates[i]) { perror("malloc"); goto clean_exit; } - q->pilot_estimates_average[i] = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i)); + q->pilot_estimates_average[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i)); if (!q->pilot_estimates_average[i]) { perror("malloc"); goto clean_exit; } - q->pilot_recv_signal[i] = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i)); + q->pilot_recv_signal[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i)); if (!q->pilot_recv_signal[i]) { perror("malloc"); goto clean_exit; @@ -210,10 +210,10 @@ int srslte_chest_dl_set_filter_time(srslte_chest_dl_t *q, float *filter, uint32_ /* Uses the difference between the averaged and non-averaged pilot estimates */ static float estimate_noise_port(srslte_chest_dl_t *q, uint32_t port_id, cf_t *avg_pilots) { /* Use difference between averaged and noisy LS pilot estimates */ - vec_sub_ccc(avg_pilots, q->pilot_estimates[port_id], + srslte_vec_sub_ccc(avg_pilots, q->pilot_estimates[port_id], q->tmp_noise, SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); - return vec_avg_power_cf(q->tmp_noise, SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); + return srslte_vec_avg_power_cf(q->tmp_noise, SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); } #else @@ -222,11 +222,11 @@ static float estimate_noise_port(srslte_chest_dl_t *q, uint32_t port_id, cf_t *a static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) { 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 + noise_power += srslte_vec_avg_power_cf(&input[k_sss-5], 5); // 5 empty SC before SSS + noise_power += srslte_vec_avg_power_cf(&input[k_sss+62], 5); // 5 empty SC after SSS 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 + noise_power += srslte_vec_avg_power_cf(&input[k_pss-5], 5); // 5 empty SC before PSS + noise_power += srslte_vec_avg_power_cf(&input[k_pss+62], 5); // 5 empty SC after PSS return noise_power; } @@ -245,7 +245,7 @@ static void average_pilots(srslte_chest_dl_t *q, uint32_t port_id) for (l=0;lfilter_freq_len > 0) { /* Filter pilot estimates in frequency */ - conv_same_cf(&pilot_est(0), q->filter_freq, &pilot_tmp(0), nref, q->filter_freq_len); + srslte_conv_same_cf(&pilot_est(0), q->filter_freq, &pilot_tmp(0), nref, q->filter_freq_len); /* Adjust extremes using linear interpolation */ @@ -275,8 +275,8 @@ static void average_pilots(srslte_chest_dl_t *q, uint32_t port_id) /* Multiply all symbols by filter and add them */ bzero(&pilot_avg(0), nref * sizeof(cf_t)); for (i=0;ifilter_time_len;i++) { - vec_sc_prod_cfc(q->tmp_timeavg[i], q->filter_time[i], q->tmp_timeavg[i], nref); - vec_sum_ccc(q->tmp_timeavg[i], &pilot_avg(0), &pilot_avg(0), nref); + srslte_vec_sc_prod_cfc(q->tmp_timeavg[i], q->filter_time[i], q->tmp_timeavg[i], nref); + srslte_vec_sum_ccc(q->tmp_timeavg[i], &pilot_avg(0), &pilot_avg(0), nref); } } else { memcpy(&pilot_avg(0), &pilot_tmp(0), nref * sizeof(cf_t)); @@ -334,7 +334,7 @@ float srslte_chest_dl_rssi(srslte_chest_dl_t *q, cf_t *input, uint32_t port_id) uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); for (l=0;lcell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE]; - rssi += vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * SRSLTE_NRE); + rssi += srslte_vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * SRSLTE_NRE); } return rssi/nsymbols; } @@ -343,10 +343,10 @@ float srslte_chest_dl_rssi(srslte_chest_dl_t *q, cf_t *input, uint32_t port_id) float srslte_chest_dl_rsrp(srslte_chest_dl_t *q, uint32_t port_id) { #ifdef RSRP_FROM_ESTIMATES - return vec_avg_power_cf(q->pilot_estimates[port_id], + return srslte_vec_avg_power_cf(q->pilot_estimates[port_id], SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); #else - return vec_avg_power_cf(q->pilot_estimates_average[port_id], + return srslte_vec_avg_power_cf(q->pilot_estimates_average[port_id], SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); #endif } @@ -357,7 +357,7 @@ int srslte_chest_dl_estimate_port(srslte_chest_dl_t *q, cf_t *input, cf_t *ce, u srslte_refsignal_cs_get_sf(q->cell, port_id, input, q->pilot_recv_signal[port_id]); /* Use the known CSR signal to compute Least-squares estimates */ - vec_prod_conj_ccc(q->pilot_recv_signal[port_id], q->csr_signal.pilots[port_id/2][sf_idx], + srslte_vec_prod_conj_ccc(q->pilot_recv_signal[port_id], q->csr_signal.pilots[port_id/2][sf_idx], q->pilot_estimates[port_id], SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); /* Average pilot estimates */ @@ -392,7 +392,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; + float noise = srslte_vec_acc_ff(q->noise_estimate, q->cell.nof_ports)/q->cell.nof_ports; #ifdef NOISE_POWER_USE_ESTIMATES return noise*sqrtf(srslte_symbol_sz(q->cell.nof_prb)); #else @@ -421,6 +421,6 @@ float srslte_chest_dl_get_rsrq(srslte_chest_dl_t *q) { float srslte_chest_dl_get_rsrp(srslte_chest_dl_t *q) { // return sum of power received from all tx ports - return vec_acc_ff(q->rsrp, q->cell.nof_ports); + return srslte_vec_acc_ff(q->rsrp, q->cell.nof_ports); } diff --git a/srslte/lib/ch_estimation/src/refsignal_dl.c b/srslte/lib/ch_estimation/src/refsignal_dl.c index f0dc723ff..b418fa5a2 100644 --- a/srslte/lib/ch_estimation/src/refsignal_dl.c +++ b/srslte/lib/ch_estimation/src/refsignal_dl.c @@ -133,7 +133,7 @@ int srslte_refsignal_cs_init(srslte_refsignal_cs_t * q, srslte_cell_t cell) for (p=0;p<2;p++) { for (i=0;ipilots[p][i] = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, 2*p)); + q->pilots[p][i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, 2*p)); if (!q->pilots[p][i]) { perror("malloc"); goto free_and_exit; diff --git a/srslte/lib/ch_estimation/src/refsignal_ul.c b/srslte/lib/ch_estimation/src/refsignal_ul.c index 3d82f286c..5283a4b89 100644 --- a/srslte/lib/ch_estimation/src/refsignal_ul.c +++ b/srslte/lib/ch_estimation/src/refsignal_ul.c @@ -141,7 +141,7 @@ int srslte_refsignal_ul_init(srslte_refsignal_ul_t * q, srslte_cell_t cell) q->cell = cell; // Allocate temporal buffer for computing signal argument - q->tmp_arg = vec_malloc(SRSLTE_NRE * q->cell.nof_prb * sizeof(cf_t)); + q->tmp_arg = srslte_vec_malloc(SRSLTE_NRE * q->cell.nof_prb * sizeof(cf_t)); if (!q->tmp_arg) { perror("malloc"); goto free_and_exit; @@ -162,7 +162,7 @@ int srslte_refsignal_ul_init(srslte_refsignal_ul_t * q, srslte_cell_t cell) goto free_and_exit; } - if (generate_n_cs_cell(q->cell, q->n_cs_cell)) { + if (srslte_generate_n_cs_cell(q->cell, q->n_cs_cell)) { goto free_and_exit; } @@ -243,7 +243,7 @@ static void compute_pusch_r_uv_arg(srslte_refsignal_ul_t *q, srslte_refsignal_dr } /* Calculates alpha according to 5.5.2.1.1 of 36.211 */ -static float pusch_get_alpha(srslte_refsignal_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *cfg, uint32_t ns) { +static float get_alpha(srslte_refsignal_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *cfg, uint32_t ns) { uint32_t n_drms_2_val = 0; if (cfg->en_drms_2) { n_drms_2_val = n_drms_2[cfg->cyclic_shift_for_drms]; @@ -280,7 +280,7 @@ void srslte_refsignal_drms_pusch_put(srslte_refsignal_ul_t *q, srslte_refsignal_ } /* Generate DRMS for PUSCH signal according to 5.5.2.1 of 36.211 */ -int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *cfg, uint32_t nof_prb, uint32_t sf_idx, cf_t *r_pusch) +int srslte_refsignal_dmrs_gen(srslte_refsignal_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *cfg, uint32_t nof_prb, uint32_t sf_idx, cf_t *r_pusch) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -305,9 +305,9 @@ int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t *q, srslte_refsignal_d compute_pusch_r_uv_arg(q, cfg, nof_prb, u, v); // Add cyclic prefix alpha - float alpha = pusch_get_alpha(q, cfg, ns); + float alpha = get_alpha(q, cfg, ns); - if (verbose == VERBOSE_DEBUG) { + if (srslte_verbose == SRSLTE_VERBOSE_DEBUG) { 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", @@ -324,19 +324,19 @@ int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t *q, srslte_refsignal_d return ret; } -int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg, uint32_t sf_idx, uint32_t n_rb, cf_t *r_pucch) +int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, srslte_pucch_cfg_t *cfg, uint32_t sf_idx, uint32_t n_rb, cf_t *r_pucch) { int ret = SRSLTE_ERROR_INVALID_INPUTS; - if (pucch_cfg_isvalid(cfg)) { + if (srslte_pucch_cfg_isvalid(cfg)) { ret = SRSLTE_ERROR; for (uint32_t ns=2*sf_idx;ns<2*(sf_idx+1);ns++) { uint32_t N_rs=0; uint32_t *pucch_symbol = NULL; switch (cfg->format) { - case PUCCH_FORMAT_1: - case PUCCH_FORMAT_1A: - case PUCCH_FORMAT_1B: + case SRSLTE_PUCCH_FORMAT_1: + case SRSLTE_PUCCH_FORMAT_1A: + case SRSLTE_PUCCH_FORMAT_1B: if (SRSLTE_CP_ISNORM(q->cell.cp)) { N_rs = 3; pucch_symbol=pucch_symbol_format1_cpnorm; @@ -345,7 +345,7 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg, pucch_symbol=pucch_symbol_format1_cpext; } break; - case PUCCH_FORMAT_2: + case SRSLTE_PUCCH_FORMAT_2: if (SRSLTE_CP_ISNORM(q->cell.cp)) { N_rs = 2; pucch_symbol=pucch_symbol_format2_cpnorm; @@ -354,8 +354,8 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg, pucch_symbol=pucch_symbol_format2_cpext; } break; - case PUCCH_FORMAT_2A: - case PUCCH_FORMAT_2B: + case SRSLTE_PUCCH_FORMAT_2A: + case SRSLTE_PUCCH_FORMAT_2B: N_rs = 2; pucch_symbol=pucch_symbol_format2_cpnorm; break; @@ -367,29 +367,29 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg, uint32_t l = pucch_symbol[m]; // Add cyclic prefix alpha - float alpha = pucch_get_alpha(q->n_cs_cell, cfg, q->cell.cp, true, ns, l, &n_oc); + float alpha = srslte_pucch_get_alpha(q->n_cs_cell, cfg, q->cell.cp, true, ns, l, &n_oc); // Choose number of symbols and orthogonal sequence from Tables 5.5.2.2.1-1 to -3 float *w=NULL; switch (cfg->format) { - case PUCCH_FORMAT_1: - case PUCCH_FORMAT_1A: - case PUCCH_FORMAT_1B: + case SRSLTE_PUCCH_FORMAT_1: + case SRSLTE_PUCCH_FORMAT_1A: + case SRSLTE_PUCCH_FORMAT_1B: 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: + case SRSLTE_PUCCH_FORMAT_2: if (SRSLTE_CP_ISNORM(q->cell.cp)) { w=w_arg_pucch_format2_cpnorm; } else { w=w_arg_pucch_format2_cpext; } break; - case PUCCH_FORMAT_2A: - case PUCCH_FORMAT_2B: + case SRSLTE_PUCCH_FORMAT_2A: + case SRSLTE_PUCCH_FORMAT_2B: w=w_arg_pucch_format2_cpnorm; break; } diff --git a/srslte/lib/ch_estimation/test/chest_test_dl.c b/srslte/lib/ch_estimation/test/chest_test_dl.c index 6f158b6d9..4e9974796 100644 --- a/srslte/lib/ch_estimation/test/chest_test_dl.c +++ b/srslte/lib/ch_estimation/test/chest_test_dl.c @@ -71,7 +71,7 @@ void parse_args(int argc, char **argv) { output_matlab = argv[optind]; break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(argv[0]); @@ -83,7 +83,7 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { srslte_chest_dl_t est; - precoding_t cheq; + srslte_precoding_t cheq; cf_t *input = NULL, *ce = NULL, *h = NULL, *output = NULL; int i, j, n_port, sf_idx, cid, num_re; int ret = -1; @@ -131,7 +131,7 @@ int main(int argc, char **argv) { max_cid = cell.id; } - precoding_init(&cheq, num_re); + srslte_precoding_init(&cheq, num_re); while(cid <= max_cid) { cell.id = cid; @@ -173,7 +173,7 @@ int main(int argc, char **argv) { gettimeofday(&t[1], NULL); for (int j=0;j<100;j++) { - predecoding_single(&cheq, input, ce, output, num_re, 0); + srslte_predecoding_single(&cheq, input, ce, output, num_re, 0); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -188,7 +188,7 @@ int main(int argc, char **argv) { gettimeofday(&t[1], NULL); for (int j=0;j<100;j++) { - predecoding_single(&cheq, input, ce, output, num_re, srslte_chest_dl_get_noise_estimate(&est)); + srslte_predecoding_single(&cheq, input, ce, output, num_re, srslte_chest_dl_get_noise_estimate(&est)); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -207,13 +207,13 @@ int main(int argc, char **argv) { if (fmatlab) { fprintf(fmatlab, "input="); - vec_fprint_c(fmatlab, input, num_re); + srslte_vec_fprint_c(fmatlab, input, num_re); fprintf(fmatlab, ";\n"); fprintf(fmatlab, "h="); - vec_fprint_c(fmatlab, h, num_re); + srslte_vec_fprint_c(fmatlab, h, num_re); fprintf(fmatlab, ";\n"); fprintf(fmatlab, "ce="); - vec_fprint_c(fmatlab, ce, num_re); + srslte_vec_fprint_c(fmatlab, ce, num_re); fprintf(fmatlab, ";\n"); } } @@ -228,7 +228,7 @@ int main(int argc, char **argv) { do_exit: - precoding_free(&cheq); + srslte_precoding_free(&cheq); if (output) { free(output); diff --git a/srslte/lib/ch_estimation/test/chest_test_dl_mex.c b/srslte/lib/ch_estimation/test/chest_test_dl_mex.c index 58151cce3..993d9dd64 100644 --- a/srslte/lib/ch_estimation/test/chest_test_dl_mex.c +++ b/srslte/lib/ch_estimation/test/chest_test_dl_mex.c @@ -64,7 +64,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) int i; srslte_cell_t cell; srslte_chest_dl_t chest; - precoding_t cheq; + srslte_precoding_t cheq; cf_t *input_signal = NULL, *output_signal[SRSLTE_MAX_LAYERS]; cf_t *output_signal2 = NULL; cf_t *ce[SRSLTE_MAX_PORTS]; @@ -153,15 +153,15 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) /** Allocate input buffers */ int nof_re = 2*SRSLTE_CP_NSYMB(cell.cp)*cell.nof_prb*SRSLTE_NRE; for (i=0;i= 1) { @@ -201,9 +201,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } if (cell.nof_ports == 1) { - predecoding_single(&cheq, input_signal, ce[0], output_signal2, nof_re, srslte_chest_dl_get_noise_estimate(&chest)); + srslte_predecoding_single(&cheq, input_signal, ce[0], output_signal2, nof_re, srslte_chest_dl_get_noise_estimate(&chest)); } else { - predecoding_diversity(&cheq, input_signal, ce, output_signal, cell.nof_ports, nof_re, srslte_chest_dl_get_noise_estimate(&chest)); + srslte_predecoding_diversity(&cheq, input_signal, ce, output_signal, cell.nof_ports, nof_re, srslte_chest_dl_get_noise_estimate(&chest)); srslte_layerdemap_diversity(output_signal, output_signal2, cell.nof_ports, nof_re/cell.nof_ports); } @@ -254,7 +254,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } srslte_chest_dl_free(&chest); - precoding_free(&cheq); + srslte_precoding_free(&cheq); return; } diff --git a/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c b/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c index ce129a76c..9b0afbe03 100644 --- a/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c +++ b/srslte/lib/ch_estimation/test/refsignal_pusch_mex.c @@ -123,19 +123,19 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexPrintf("cyclic_shift_for_drms: %d, ",pusch_cfg.cyclic_shift_for_drms); mexPrintf("delta_ss: %d, ",pusch_cfg.delta_ss); - cf_t *signal = vec_malloc(2*SRSLTE_NRE*nof_prb*sizeof(cf_t)); + cf_t *signal = srslte_vec_malloc(2*SRSLTE_NRE*nof_prb*sizeof(cf_t)); if (!signal) { perror("malloc"); return; } - cf_t *sf_symbols = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp)*sizeof(cf_t)); + cf_t *sf_symbols = srslte_vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp)*sizeof(cf_t)); if (!sf_symbols) { perror("malloc"); return; } bzero(sf_symbols, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp)*sizeof(cf_t)); //mexPrintf("Generating DRMS for ns=%d, nof_prb=%d\n", 2*sf_idx+i,pusch_cfg.nof_prb); - srslte_refsignal_dmrs_pusch_gen(&refs, &pusch_cfg, nof_prb, sf_idx, signal); + srslte_refsignal_dmrs_gen(&refs, &pusch_cfg, nof_prb, sf_idx, signal); uint32_t n_prb[2]; n_prb[0] = prbset[0]; n_prb[1] = prbset[0]; diff --git a/srslte/lib/ch_estimation/test/refsignal_ul_test.c b/srslte/lib/ch_estimation/test/refsignal_ul_test.c index 8d6454b8c..c772a4571 100644 --- a/srslte/lib/ch_estimation/test/refsignal_ul_test.c +++ b/srslte/lib/ch_estimation/test/refsignal_ul_test.c @@ -65,7 +65,7 @@ void parse_args(int argc, char **argv) { cell.id = atoi(argv[optind]); break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(argv[0]); @@ -123,7 +123,7 @@ int main(int argc, char **argv) { printf("cyclic_shift_for_drms: %d, ",pusch_cfg.cyclic_shift_for_drms); printf("delta_ss: %d, ",pusch_cfg.delta_ss); printf("SF_idx: %d\n", sf_idx); - srslte_refsignal_dmrs_pusch_gen(&refs, &pusch_cfg, nof_prb, sf_idx, signal); + srslte_refsignal_dmrs_gen(&refs, &pusch_cfg, nof_prb, sf_idx, signal); exit(0); } } diff --git a/srslte/lib/common/src/phy_common.c b/srslte/lib/common/src/phy_common.c index 3acac855d..380e9c16d 100644 --- a/srslte/lib/common/src/phy_common.c +++ b/srslte/lib/common/src/phy_common.c @@ -134,13 +134,13 @@ bool srslte_cb_size_isvalid(uint32_t size) { char *srslte_mod_string(srslte_mod_t mod) { switch (mod) { - case LTE_BPSK: + case SRSLTE_MOD_BPSK: return "BPSK"; - case LTE_QPSK: + case SRSLTE_MOD_QPSK: return "QPSK"; - case LTE_QAM16: + case SRSLTE_MOD_16QAM: return "QAM16"; - case LTE_QAM64: + case SRSLTE_MOD_64QAM: return "QAM64"; default: return "N/A"; @@ -149,13 +149,13 @@ char *srslte_mod_string(srslte_mod_t mod) { uint32_t srslte_mod_bits_x_symbol(srslte_mod_t mod) { switch (mod) { - case LTE_BPSK: + case SRSLTE_MOD_BPSK: return 1; - case LTE_QPSK: + case SRSLTE_MOD_QPSK: return 2; - case LTE_QAM16: + case SRSLTE_MOD_16QAM: return 4; - case LTE_QAM64: + case SRSLTE_MOD_64QAM: return 6; default: return 0; @@ -301,45 +301,45 @@ struct lte_band { }; struct lte_band lte_bands[SRSLTE_NOF_LTE_BANDS] = { - {1, 2110, 0, 599, ALL}, - {2, 1930, 600, 1199, NAR}, - {3, 1805, 1200, 1949, ALL}, - {4, 2110, 1950, 2399, NAR}, - {5, 869, 2400, 2649, NAR}, - {6, 875, 2650, 2749, APAC}, - {7, 2620, 2750, 3449, EMEA}, - {8, 925, 3450, 3799, ALL}, - {9, 1844.9, 3800, 4149, APAC}, - {10, 2110, 4150, 4749, NAR}, - {11, 1475.9, 4750, 4949, JAPAN}, - {12, 729, 5010, 5179, NAR}, - {13, 746, 5180, 5279, NAR}, - {14, 758, 5280, 5379, NAR}, - {17, 734, 5730, 5849, NAR}, - {18, 860, 5850, 5999, JAPAN}, - {19, 875, 6000, 6149, JAPAN}, - {20, 791, 6150, 6449, EMEA}, - {21, 1495.9, 6450, 6599, JAPAN}, - {22, 3500, 6600, 7399, NA}, - {23, 2180, 7500, 7699, NAR}, - {24, 1525, 7700, 8039, NAR}, - {25, 1930, 8040, 8689, NAR}, - {26, 859, 8690, 9039, NAR}, - {27, 852, 9040, 9209, NAR}, - {28, 758, 9210, 9659, APAC}, - {29, 717, 9660, 9769, NAR}, - {30, 2350, 9770, 9869, NAR}, - {31, 462.5, 9870, 9919, CALA} + {1, 2110, 0, 599, SRSLTE_BAND_GEO_AREA_ALL}, + {2, 1930, 600, 1199, SRSLTE_BAND_GEO_AREA_NAR}, + {3, 1805, 1200, 1949, SRSLTE_BAND_GEO_AREA_ALL}, + {4, 2110, 1950, 2399, SRSLTE_BAND_GEO_AREA_NAR}, + {5, 869, 2400, 2649, SRSLTE_BAND_GEO_AREA_NAR}, + {6, 875, 2650, 2749, SRSLTE_BAND_GEO_AREA_APAC}, + {7, 2620, 2750, 3449, SRSLTE_BAND_GEO_AREA_EMEA}, + {8, 925, 3450, 3799, SRSLTE_BAND_GEO_AREA_ALL}, + {9, 1844.9, 3800, 4149, SRSLTE_BAND_GEO_AREA_APAC}, + {10, 2110, 4150, 4749, SRSLTE_BAND_GEO_AREA_NAR}, + {11, 1475.9, 4750, 4949, SRSLTE_BAND_GEO_AREA_JAPAN}, + {12, 729, 5010, 5179, SRSLTE_BAND_GEO_AREA_NAR}, + {13, 746, 5180, 5279, SRSLTE_BAND_GEO_AREA_NAR}, + {14, 758, 5280, 5379, SRSLTE_BAND_GEO_AREA_NAR}, + {17, 734, 5730, 5849, SRSLTE_BAND_GEO_AREA_NAR}, + {18, 860, 5850, 5999, SRSLTE_BAND_GEO_AREA_JAPAN}, + {19, 875, 6000, 6149, SRSLTE_BAND_GEO_AREA_JAPAN}, + {20, 791, 6150, 6449, SRSLTE_BAND_GEO_AREA_EMEA}, + {21, 1495.9, 6450, 6599, SRSLTE_BAND_GEO_AREA_JAPAN}, + {22, 3500, 6600, 7399, SRSLTE_BAND_GEO_AREA_NA}, + {23, 2180, 7500, 7699, SRSLTE_BAND_GEO_AREA_NAR}, + {24, 1525, 7700, 8039, SRSLTE_BAND_GEO_AREA_NAR}, + {25, 1930, 8040, 8689, SRSLTE_BAND_GEO_AREA_NAR}, + {26, 859, 8690, 9039, SRSLTE_BAND_GEO_AREA_NAR}, + {27, 852, 9040, 9209, SRSLTE_BAND_GEO_AREA_NAR}, + {28, 758, 9210, 9659, SRSLTE_BAND_GEO_AREA_APAC}, + {29, 717, 9660, 9769, SRSLTE_BAND_GEO_AREA_NAR}, + {30, 2350, 9770, 9869, SRSLTE_BAND_GEO_AREA_NAR}, + {31, 462.5, 9870, 9919, SRSLTE_BAND_GEO_AREA_CALA} }; #define EOF_BAND 9919 int srslte_str2mimotype(char *mimo_type_str, srslte_mimo_type_t *type) { if (!strcmp(mimo_type_str, "single")) { - *type = SINGLE_ANTENNA; + *type = SRSLTE_MIMO_TYPE_SINGLE_ANTENNA; } else if (!strcmp(mimo_type_str, "diversity")) { - *type = TX_DIVERSITY; + *type = SRSLTE_MIMO_TYPE_TX_DIVERSITY; } else if (!strcmp(mimo_type_str, "multiplex")) { - *type = SPATIAL_MULTIPLEX; + *type = SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX; } else { return SRSLTE_ERROR; } diff --git a/srslte/lib/utils/src/dft.c b/srslte/lib/dft/src/dft.c similarity index 67% rename from srslte/lib/utils/src/dft.c rename to srslte/lib/dft/src/dft.c index abf0d5e7e..01aa242f0 100644 --- a/srslte/lib/utils/src/dft.c +++ b/srslte/lib/dft/src/dft.c @@ -31,18 +31,18 @@ #include #include -#include "srslte/utils/dft.h" +#include "srslte/dft/dft.h" #include "srslte/utils/vector.h" #define dft_ceil(a,b) ((a-1)/b+1) #define dft_floor(a,b) (a/b) -int dft_plan(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir, - dft_mode_t mode) { - if(mode == COMPLEX){ - return dft_plan_c(plan,dft_points,dir); +int srslte_dft_plan(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir, + srslte_dft_mode_t mode) { + if(mode == SRSLTE_DFT_COMPLEX){ + return srslte_dft_plan_c(plan,dft_points,dir); } else { - return dft_plan_r(plan,dft_points,dir); + return srslte_dft_plan_r(plan,dft_points,dir); } return 0; } @@ -52,17 +52,17 @@ static void allocate(srslte_dft_plan_t *plan, int size_in, int size_out, int len plan->out = fftwf_malloc(size_out*len); } -int dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir) { +int srslte_dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir) { allocate(plan,sizeof(fftwf_complex),sizeof(fftwf_complex), dft_points); - int sign = (dir == FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD; + int sign = (dir == SRSLTE_DFT_FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD; plan->p = fftwf_plan_dft_1d(dft_points, plan->in, plan->out, sign, 0U); if (!plan->p) { return -1; } plan->size = dft_points; - plan->mode = COMPLEX; + plan->mode = SRSLTE_DFT_COMPLEX; plan->dir = dir; - plan->forward = (dir==FORWARD)?true:false; + plan->forward = (dir==SRSLTE_DFT_FORWARD)?true:false; plan->mirror = false; plan->db = false; plan->norm = false; @@ -71,17 +71,17 @@ int dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir) { return 0; } -int dft_plan_r(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir) { +int srslte_dft_plan_r(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir) { allocate(plan,sizeof(float),sizeof(float), dft_points); - int sign = (dir == FORWARD) ? FFTW_R2HC : FFTW_HC2R; + int sign = (dir == SRSLTE_DFT_FORWARD) ? FFTW_R2HC : FFTW_HC2R; plan->p = fftwf_plan_r2r_1d(dft_points, plan->in, plan->out, sign, 0U); if (!plan->p) { return -1; } plan->size = dft_points; - plan->mode = REAL; + plan->mode = SRSLTE_REAL; plan->dir = dir; - plan->forward = (dir==FORWARD)?true:false; + plan->forward = (dir==SRSLTE_DFT_FORWARD)?true:false; plan->mirror = false; plan->db = false; plan->norm = false; @@ -90,16 +90,16 @@ int dft_plan_r(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir) { return 0; } -void dft_plan_set_mirror(srslte_dft_plan_t *plan, bool val){ +void srslte_dft_plan_set_mirror(srslte_dft_plan_t *plan, bool val){ plan->mirror = val; } -void dft_plan_set_db(srslte_dft_plan_t *plan, bool val){ +void srslte_dft_plan_set_db(srslte_dft_plan_t *plan, bool val){ plan->db = val; } -void dft_plan_set_norm(srslte_dft_plan_t *plan, bool val){ +void srslte_dft_plan_set_norm(srslte_dft_plan_t *plan, bool val){ plan->norm = val; } -void dft_plan_set_dc(srslte_dft_plan_t *plan, bool val){ +void srslte_dft_plan_set_dc(srslte_dft_plan_t *plan, bool val){ plan->dc = val; } @@ -128,56 +128,56 @@ static void copy_post(uint8_t *dst, uint8_t *src, int size_d, int len, } } -void dft_run(srslte_dft_plan_t *plan, void *in, void *out) { - if(plan->mode == COMPLEX) { - dft_run_c(plan,in,out); +void srslte_dft_run(srslte_dft_plan_t *plan, void *in, void *out) { + if(plan->mode == SRSLTE_DFT_COMPLEX) { + srslte_dft_run_c(plan,in,out); } else { - dft_run_r(plan,in,out); + srslte_dft_run_r(plan,in,out); } } -void dft_run_c(srslte_dft_plan_t *plan, dft_c_t *in, dft_c_t *out) { +void srslte_dft_run_c(srslte_dft_plan_t *plan, cf_t *in, cf_t *out) { float norm; int i; fftwf_complex *f_out = plan->out; - copy_pre((uint8_t*)plan->in, (uint8_t*)in, sizeof(dft_c_t), plan->size, + copy_pre((uint8_t*)plan->in, (uint8_t*)in, sizeof(cf_t), plan->size, plan->forward, plan->mirror, plan->dc); fftwf_execute(plan->p); if (plan->norm) { norm = 1.0/sqrtf(plan->size); - vec_sc_prod_cfc(f_out, norm, f_out, plan->size); + srslte_vec_sc_prod_cfc(f_out, norm, f_out, plan->size); } if (plan->db) { for (i=0;isize;i++) { f_out[i] = 10*log10(f_out[i]); } } - copy_post((uint8_t*)out, (uint8_t*)plan->out, sizeof(dft_c_t), plan->size, + copy_post((uint8_t*)out, (uint8_t*)plan->out, sizeof(cf_t), plan->size, plan->forward, plan->mirror, plan->dc); } -void dft_run_r(srslte_dft_plan_t *plan, dft_r_t *in, dft_r_t *out) { +void srslte_dft_run_r(srslte_dft_plan_t *plan, float *in, float *out) { float norm; int i; int len = plan->size; float *f_out = plan->out; - memcpy(plan->in,in,sizeof(dft_r_t)*plan->size); + memcpy(plan->in,in,sizeof(float)*plan->size); fftwf_execute(plan->p); if (plan->norm) { norm = 1.0/plan->size; - vec_sc_prod_fff(f_out, norm, f_out, plan->size); + srslte_vec_sc_prod_fff(f_out, norm, f_out, plan->size); } if (plan->db) { for (i=0;iout,sizeof(dft_r_t)*plan->size); + memcpy(out,plan->out,sizeof(float)*plan->size); } -void dft_plan_free(srslte_dft_plan_t *plan) { +void srslte_dft_plan_free(srslte_dft_plan_t *plan) { if (!plan) return; if (!plan->size) return; if (plan->in) fftwf_free(plan->in); diff --git a/srslte/lib/filter/src/dft_precoding.c b/srslte/lib/dft/src/dft_precoding.c similarity index 65% rename from srslte/lib/filter/src/dft_precoding.c rename to srslte/lib/dft/src/dft_precoding.c index c1d63149f..351a027cd 100644 --- a/srslte/lib/filter/src/dft_precoding.c +++ b/srslte/lib/dft/src/dft_precoding.c @@ -37,30 +37,30 @@ #include "srslte/common/phy_common.h" #include "srslte/utils/debug.h" #include "srslte/utils/vector.h" -#include "srslte/utils/dft.h" -#include "srslte/filter/dft_precoding.h" +#include "srslte/dft/dft.h" +#include "srslte/dft/dft_precoding.h" /* Create DFT plans for transform precoding */ -int srslte_srslte_dft_precoding_init(srslte_srslte_dft_precoding_t *q, uint32_t max_prb) +int srslte_dft_precoding_init(srslte_dft_precoding_t *q, uint32_t max_prb) { int ret = SRSLTE_ERROR_INVALID_INPUTS; - bzero(q, sizeof(srslte_srslte_dft_precoding_t)); + bzero(q, sizeof(srslte_dft_precoding_t)); if (max_prb <= SRSLTE_MAX_PRB) { ret = SRSLTE_ERROR; for (uint32_t i=1;idft_plan[i], i*SRSLTE_NRE, FORWARD)) { + if (srslte_dft_plan_c(&q->dft_plan[i], i*SRSLTE_NRE, SRSLTE_DFT_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*SRSLTE_NRE, BACKWARD)) { + srslte_dft_plan_set_norm(&q->dft_plan[i], true); + if (srslte_dft_plan_c(&q->idft_plan[i], i*SRSLTE_NRE, SRSLTE_DFT_BACKWARD)) { fprintf(stderr, "Error: Creating DFT plan %d\n",i); goto clean_exit; } - dft_plan_set_norm(&q->idft_plan[i], true); + srslte_dft_plan_set_norm(&q->idft_plan[i], true); } } q->max_prb = max_prb; @@ -69,25 +69,25 @@ int srslte_srslte_dft_precoding_init(srslte_srslte_dft_precoding_t *q, uint32_t clean_exit: if (ret == SRSLTE_ERROR) { - srslte_srslte_dft_precoding_free(q); + srslte_dft_precoding_free(q); } return ret; } /* Free DFT plans for transform precoding */ -void srslte_srslte_dft_precoding_free(srslte_srslte_dft_precoding_t *q) +void srslte_dft_precoding_free(srslte_dft_precoding_t *q) { for (uint32_t i=1;imax_prb;i++) { - if(srslte_srslte_dft_precoding_valid_prb(i)) { + if(srslte_dft_precoding_valid_prb(i)) { DEBUG("Freeing DFT precoding plan for %d PRBs\n", i); - dft_plan_free(&q->dft_plan[i]); - dft_plan_free(&q->idft_plan[i]); + srslte_dft_plan_free(&q->dft_plan[i]); + srslte_dft_plan_free(&q->idft_plan[i]); } } - bzero(q, sizeof(srslte_srslte_dft_precoding_t)); + bzero(q, sizeof(srslte_dft_precoding_t)); } -bool srslte_srslte_dft_precoding_valid_prb(uint32_t nof_prb) { +bool srslte_dft_precoding_valid_prb(uint32_t nof_prb) { if (nof_prb == 1 || (nof_prb%2) == 0 || (nof_prb%3) == 0 || (nof_prb%5) == 0) { return true; } else { @@ -95,32 +95,32 @@ bool srslte_srslte_dft_precoding_valid_prb(uint32_t nof_prb) { } } -int srslte_dft_precoding(srslte_srslte_dft_precoding_t *q, cf_t *input, cf_t *output, +int srslte_dft_precoding(srslte_dft_precoding_t *q, cf_t *input, cf_t *output, uint32_t nof_prb, uint32_t nof_symbols) { - if (!srslte_srslte_dft_precoding_valid_prb(nof_prb)) { + if (!srslte_dft_precoding_valid_prb(nof_prb)) { fprintf(stderr, "Error invalid number of PRB (%d)\n", nof_prb); return SRSLTE_ERROR; } for (uint32_t i=0;idft_plan[nof_prb], &input[i*SRSLTE_NRE*nof_prb], &output[i*SRSLTE_NRE*nof_prb]); + srslte_dft_run_c(&q->dft_plan[nof_prb], &input[i*SRSLTE_NRE*nof_prb], &output[i*SRSLTE_NRE*nof_prb]); } return SRSLTE_SUCCESS; } -int srslte_dft_predecoding(srslte_srslte_dft_precoding_t *q, cf_t *input, cf_t *output, +int srslte_dft_predecoding(srslte_dft_precoding_t *q, cf_t *input, cf_t *output, uint32_t nof_prb, uint32_t nof_symbols) { - if (!srslte_srslte_dft_precoding_valid_prb(nof_prb)) { + if (!srslte_dft_precoding_valid_prb(nof_prb)) { fprintf(stderr, "Error invalid number of PRB (%d)\n", nof_prb); return SRSLTE_ERROR; } for (uint32_t i=0;idft_plan[nof_prb], &input[i*SRSLTE_NRE*nof_prb], &output[i*SRSLTE_NRE*nof_prb]); + srslte_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/common/src/fft.c b/srslte/lib/dft/src/ofdm.c similarity index 65% rename from srslte/lib/common/src/fft.c rename to srslte/lib/dft/src/ofdm.c index 507019447..5f774acc3 100644 --- a/srslte/lib/common/src/fft.c +++ b/srslte/lib/dft/src/ofdm.c @@ -32,73 +32,74 @@ #include #include "srslte/common/phy_common.h" -#include "srslte/utils/dft.h" -#include "srslte/common/fft.h" +#include "srslte/dft/dft.h" +#include "srslte/dft/ofdm.h" #include "srslte/utils/debug.h" #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 srslte_ofdm_tx_init_(srslte_ofdm_t *q, srslte_cp_t cp, uint32_t nof_prb, srslte_dft_dir_t dir) { int symbol_sz = srslte_symbol_sz(nof_prb); if (symbol_sz < 0) { fprintf(stderr, "Error: Invalid nof_prb=%d\n", nof_prb); return -1; } - if (dft_plan_c(&q->fft_plan, symbol_sz, dir)) { + if (srslte_dft_plan_c(&q->fft_plan, symbol_sz, dir)) { fprintf(stderr, "Error: Creating DFT plan\n"); return -1; } - q->tmp = malloc((uint32_t) symbol_sz * sizeof(cf_t)); + q->tmp = srslte_vec_malloc((uint32_t) symbol_sz * sizeof(cf_t)); if (!q->tmp) { perror("malloc"); return -1; } - dft_plan_set_mirror(&q->fft_plan, true); - dft_plan_set_dc(&q->fft_plan, true); + srslte_dft_plan_set_mirror(&q->fft_plan, true); + srslte_dft_plan_set_dc(&q->fft_plan, true); q->symbol_sz = (uint32_t) symbol_sz; q->nof_symbols = SRSLTE_CP_NSYMB(cp); q->cp = cp; q->freq_shift = false; + q->shift_buffer = NULL; q->nof_re = nof_prb * SRSLTE_NRE; q->nof_guards = ((symbol_sz - q->nof_re) / 2); 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, + dir==SRSLTE_DFT_FORWARD?"FFT":"iFFT", q->symbol_sz, q->nof_symbols, q->cp==SRSLTE_SRSLTE_CP_NORM?"Normal":"Extended", q->nof_re, q->nof_guards); return SRSLTE_SUCCESS; } -void srslte_fft_free_(srslte_fft_t *q) { - dft_plan_free(&q->fft_plan); +void srslte_ofdm_free_(srslte_ofdm_t *q) { + srslte_dft_plan_free(&q->fft_plan); if (q->tmp) { free(q->tmp); } if (q->shift_buffer) { free(q->shift_buffer); } - bzero(q, sizeof(srslte_fft_t)); + bzero(q, sizeof(srslte_ofdm_t)); } -int srslte_fft_init(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb) { - return srslte_fft_init_(q, cp, nof_prb, FORWARD); +int srslte_ofdm_tx_init(srslte_ofdm_t *q, srslte_cp_t cp, uint32_t nof_prb) { + return srslte_ofdm_tx_init_(q, cp, nof_prb, SRSLTE_DFT_FORWARD); } -void srslte_fft_free(srslte_fft_t *q) { - srslte_fft_free_(q); +void srslte_ofdm_tx_free(srslte_ofdm_t *q) { + srslte_ofdm_free_(q); } -int lte_ifft_init(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb) { +int srslte_ofdm_rx_init(srslte_ofdm_t *q, srslte_cp_t cp, uint32_t nof_prb) { uint32_t i; int ret; - ret = srslte_fft_init_(q, cp, nof_prb, BACKWARD); + ret = srslte_ofdm_tx_init_(q, cp, nof_prb, SRSLTE_DFT_BACKWARD); if (ret == SRSLTE_SUCCESS) { - dft_plan_set_norm(&q->fft_plan, true); + srslte_dft_plan_set_norm(&q->fft_plan, true); /* set now zeros at CP */ for (i=0;inof_symbols;i++) { @@ -113,8 +114,8 @@ int lte_ifft_init(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb) { * Freq_shift is relative to inter-carrier spacing. * 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) * SRSLTE_SF_LEN(q->symbol_sz)); +int srslte_ofdm_set_freq_shift(srslte_ofdm_t *q, float freq_shift) { + q->shift_buffer = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN(q->symbol_sz)); if (!q->shift_buffer) { perror("malloc"); return -1; @@ -131,50 +132,50 @@ int srslte_fft_set_freq_shift(srslte_fft_t *q, float freq_shift) { } /* Disable DC carrier addition */ - dft_plan_set_dc(&q->fft_plan, false); + srslte_dft_plan_set_dc(&q->fft_plan, false); q->freq_shift = true; return SRSLTE_SUCCESS; } -void lte_ifft_free(srslte_fft_t *q) { - srslte_fft_free_(q); +void srslte_ofdm_rx_free(srslte_ofdm_t *q) { + srslte_ofdm_free_(q); } /* Transforms input samples into output OFDM symbols. * Performs FFT on a each symbol and removes CP. */ -void srslte_fft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) { +void srslte_ofdm_tx_slot(srslte_ofdm_t *q, cf_t *input, cf_t *output) { uint32_t i; for (i=0;inof_symbols;i++) { 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); + srslte_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; output += q->nof_re; } } -void srslte_fft_run_sf(srslte_fft_t *q, cf_t *input, cf_t *output) { +void srslte_ofdm_tx_sf(srslte_ofdm_t *q, cf_t *input, cf_t *output) { uint32_t n; if (q->freq_shift) { - vec_prod_ccc(input, q->shift_buffer, input, 2*q->slot_sz); + srslte_vec_prod_ccc(input, q->shift_buffer, input, 2*q->slot_sz); } for (n=0;n<2;n++) { - srslte_fft_run_slot(q, &input[n*q->slot_sz], &output[n*q->nof_re*q->nof_symbols]); + srslte_ofdm_tx_slot(q, &input[n*q->slot_sz], &output[n*q->nof_re*q->nof_symbols]); } } /* Transforms input OFDM symbols into output samples. * Performs FFT on a each symbol and adds CP. */ -void lte_ifft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) { +void srslte_ofdm_rx_slot(srslte_ofdm_t *q, cf_t *input, cf_t *output) { uint32_t i, cp_len; for (i=0;inof_symbols;i++) { 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]); + srslte_dft_run_c(&q->fft_plan, q->tmp, &output[cp_len]); input += q->nof_re; /* add CP */ memcpy(output, &output[q->symbol_sz], cp_len * sizeof(cf_t)); @@ -182,16 +183,16 @@ void lte_ifft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) { } } -void srslte_fft_set_normalize(srslte_fft_t *q, bool normalize_enable) { - dft_plan_set_norm(&q->fft_plan, normalize_enable); +void srslte_ofdm_set_normalize(srslte_ofdm_t *q, bool normalize_enable) { + srslte_dft_plan_set_norm(&q->fft_plan, normalize_enable); } -void lte_ifft_run_sf(srslte_fft_t *q, cf_t *input, cf_t *output) { +void srslte_ofdm_rx_sf(srslte_ofdm_t *q, cf_t *input, cf_t *output) { uint32_t n; for (n=0;n<2;n++) { - lte_ifft_run_slot(q, &input[n*q->nof_re*q->nof_symbols], &output[n*q->slot_sz]); + srslte_ofdm_rx_slot(q, &input[n*q->nof_re*q->nof_symbols], &output[n*q->slot_sz]); } if (q->freq_shift) { - vec_prod_ccc(output, q->shift_buffer, output, 2*q->slot_sz); + srslte_vec_prod_ccc(output, q->shift_buffer, output, 2*q->slot_sz); } } diff --git a/srslte/lib/common/test/CMakeLists.txt b/srslte/lib/dft/test/CMakeLists.txt similarity index 80% rename from srslte/lib/common/test/CMakeLists.txt rename to srslte/lib/dft/test/CMakeLists.txt index dc4bcfe8e..a9c7e1921 100644 --- a/srslte/lib/common/test/CMakeLists.txt +++ b/srslte/lib/dft/test/CMakeLists.txt @@ -23,12 +23,12 @@ # FFT TEST ######################################################################## -ADD_EXECUTABLE(fft_test fft_test.c) -TARGET_LINK_LIBRARIES(fft_test lte_phy) +ADD_EXECUTABLE(ofdm_test ofdm_test.c) +TARGET_LINK_LIBRARIES(ofdm_test lte_phy) -ADD_TEST(fft_normal fft_test) -ADD_TEST(fft_extended fft_test -e) +ADD_TEST(ofdm_normal ofdm_test) +ADD_TEST(ofdm_extended ofdm_test -e) -ADD_TEST(fft_normal_single fft_test -n 6) -ADD_TEST(fft_extended_single fft_test -e -n 6) +ADD_TEST(ofdm_normal_single ofdm_test -n 6) +ADD_TEST(ofdm_extended_single ofdm_test -e -n 6) diff --git a/srslte/lib/common/test/fft_test.c b/srslte/lib/dft/test/ofdm_test.c similarity index 88% rename from srslte/lib/common/test/fft_test.c rename to srslte/lib/dft/test/ofdm_test.c index 9f5ffd592..5c4237ade 100644 --- a/srslte/lib/common/test/fft_test.c +++ b/srslte/lib/dft/test/ofdm_test.c @@ -62,7 +62,7 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { - srslte_fft_t fft, ifft; + srslte_ofdm_t fft, ifft; cf_t *input, *outfft, *outifft; float mse; int n_prb, max_prb, n_re; @@ -98,24 +98,24 @@ int main(int argc, char **argv) { exit(-1); } - if (srslte_fft_init(&fft, cp, n_prb)) { + if (srslte_ofdm_tx_init(&fft, cp, n_prb)) { fprintf(stderr, "Error initializing FFT\n"); exit(-1); } - dft_plan_set_norm(&fft.fft_plan, true); + srslte_dft_plan_set_norm(&fft.fft_plan, true); - if (lte_ifft_init(&ifft, cp, n_prb)) { + if (srslte_ofdm_rx_init(&ifft, cp, n_prb)) { fprintf(stderr, "Error initializing iFFT\n"); exit(-1); } - dft_plan_set_norm(&ifft.fft_plan, true); + srslte_dft_plan_set_norm(&ifft.fft_plan, true); for (i=0;i #include -#include "srslte/utils/pack.h" +#include "srslte/utils/bit.h" #include "srslte/fec/crc.h" void gen_srslte_crc_table(srslte_crc_t *h) { @@ -137,7 +137,7 @@ uint32_t srslte_crc_checksum(srslte_crc_t *h, uint8_t *data, int len) { h->byte |= ((uint8_t) *(pter + k)) << (7 - k); } } else { - h->byte = (uint8_t) (unpack_bits(&pter, 8) & 0xFF); + h->byte = (uint8_t) (srslte_bit_unpack(&pter, 8) & 0xFF); } crc = crctable(h); } @@ -160,6 +160,6 @@ void srslte_crc_attach(srslte_crc_t *h, uint8_t *data, int len) { // Add CRC uint8_t *ptr = &data[len]; - pack_bits(checksum, &ptr, h->order); + srslte_bit_pack(checksum, &ptr, h->order); } diff --git a/srslte/lib/fec/src/turbodecoder.c b/srslte/lib/fec/src/turbodecoder.c index e0b0b1f5c..471d31b85 100644 --- a/srslte/lib/fec/src/turbodecoder.c +++ b/srslte/lib/fec/src/turbodecoder.c @@ -166,9 +166,9 @@ void srslte_map_gen_alpha(srslte_map_gen_t * s, srslte_llr_t * input, srslte_llr int srslte_map_gen_init(srslte_map_gen_t * h, int max_long_cb) { bzero(h, sizeof(srslte_map_gen_t)); - h->beta = vec_malloc(sizeof(srslte_llr_t) * (max_long_cb + SRSLTE_TCOD_TOTALTAIL + 1) * NUMSTATES); + h->beta = srslte_vec_malloc(sizeof(srslte_llr_t) * (max_long_cb + SRSLTE_TCOD_TOTALTAIL + 1) * NUMSTATES); if (!h->beta) { - perror("vec_malloc"); + perror("srslte_vec_malloc"); return -1; } h->max_long_cb = max_long_cb; @@ -209,29 +209,29 @@ int srslte_tdec_init(srslte_tdec_t * h, uint32_t max_long_cb) h->max_long_cb = max_long_cb; - h->llr1 = vec_malloc(sizeof(srslte_llr_t) * len); + h->llr1 = srslte_vec_malloc(sizeof(srslte_llr_t) * len); if (!h->llr1) { - perror("vec_malloc"); + perror("srslte_vec_malloc"); goto clean_and_exit; } - h->llr2 = vec_malloc(sizeof(srslte_llr_t) * len); + h->llr2 = srslte_vec_malloc(sizeof(srslte_llr_t) * len); if (!h->llr2) { - perror("vec_malloc"); + perror("srslte_vec_malloc"); goto clean_and_exit; } - h->w = vec_malloc(sizeof(srslte_llr_t) * len); + h->w = srslte_vec_malloc(sizeof(srslte_llr_t) * len); if (!h->w) { - perror("vec_malloc"); + perror("srslte_vec_malloc"); goto clean_and_exit; } - h->syst = vec_malloc(sizeof(srslte_llr_t) * len); + h->syst = srslte_vec_malloc(sizeof(srslte_llr_t) * len); if (!h->syst) { - perror("vec_malloc"); + perror("srslte_vec_malloc"); goto clean_and_exit; } - h->parity = vec_malloc(sizeof(srslte_llr_t) * len); + h->parity = srslte_vec_malloc(sizeof(srslte_llr_t) * len); if (!h->parity) { - perror("vec_malloc"); + perror("srslte_vec_malloc"); goto clean_and_exit; } diff --git a/srslte/lib/fec/src/viterbi.c b/srslte/lib/fec/src/viterbi.c index 082cb5b3b..e0b788536 100644 --- a/srslte/lib/fec/src/viterbi.c +++ b/srslte/lib/fec/src/viterbi.c @@ -218,7 +218,7 @@ int srslte_viterbi_decode_f(srslte_viterbi_t *q, float *symbols, uint8_t *data, len = 3 * (frame_length + q->K - 1); } if (!q->decode_f) { - vec_quant_fuc(symbols, q->symbols_uc, q->gain_quant, 127.5, 255, len); + srslte_vec_quant_fuc(symbols, q->symbols_uc, q->gain_quant, 127.5, 255, len); return q->decode(q, q->symbols_uc, data, frame_length); } else { return q->decode_f(q, symbols, data, frame_length); diff --git a/srslte/lib/fec/test/rm_turbo_rx_mex.c b/srslte/lib/fec/test/rm_turbo_rx_mex.c index 9aa81a463..969b4b3dc 100644 --- a/srslte/lib/fec/test/rm_turbo_rx_mex.c +++ b/srslte/lib/fec/test/rm_turbo_rx_mex.c @@ -68,8 +68,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) trblklen = (uint32_t) mxGetScalar(TRBLKLEN); rvidx = (uint32_t) mxGetScalar(RV); - struct cb_segm cbsegm; - codeblock_segmentation(&cbsegm, trblklen); + srslte_harq_cbsegm_t cbsegm; + srslte_harq_codeblock_segmentation(&cbsegm, trblklen); cblen = 3*cbsegm.K1+12; w_buff_f = calloc(1,sizeof(float) * cblen * 10); @@ -79,7 +79,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } // allocate memory for output bits - output = vec_malloc(cblen * sizeof(float)); + output = srslte_vec_malloc(cblen * sizeof(float)); srslte_rm_turbo_rx(w_buff_f, cblen * 10, input, in_len, output, cblen, rvidx,cbsegm.F); diff --git a/srslte/lib/fec/test/rm_turbo_test.c b/srslte/lib/fec/test/rm_turbo_test.c index 44b08bcc0..fded81973 100644 --- a/srslte/lib/fec/test/rm_turbo_test.c +++ b/srslte/lib/fec/test/rm_turbo_test.c @@ -129,12 +129,12 @@ int main(int argc, char **argv) { } printf("BITS: "); - vec_fprint_b(stdout, bits, nof_tx_bits); + srslte_vec_fprint_b(stdout, bits, nof_tx_bits); srslte_rm_turbo_tx(w_buff_c, nof_tx_bits * 10, bits, nof_tx_bits, rm_bits, nof_rx_bits, rv_idx); printf("RM: "); - vec_fprint_b(stdout, rm_bits, nof_rx_bits); + srslte_vec_fprint_b(stdout, rm_bits, nof_rx_bits); for (i = 0; i < nof_rx_bits; i++) { rm_symbols[i] = (float) rm_bits[i] ? 1 : -1; @@ -144,15 +144,15 @@ int main(int argc, char **argv) { rv_idx, nof_filler_bits); printf("UMRM: "); - vec_fprint_f(stdout, unrm_symbols, nof_tx_bits); + srslte_vec_fprint_f(stdout, unrm_symbols, nof_tx_bits); for (i=0;i0?1:0; } printf("BITS: "); - vec_fprint_b(stdout, bits_out, nof_tx_bits); + srslte_vec_fprint_b(stdout, bits_out, nof_tx_bits); printf("BITS: "); - vec_fprint_b(stdout, bits, nof_tx_bits); + srslte_vec_fprint_b(stdout, bits, nof_tx_bits); nof_errors = 0; for (i = 0; i < nof_tx_bits; i++) { diff --git a/srslte/lib/fec/test/turbodecoder_test.c b/srslte/lib/fec/test/turbodecoder_test.c index 883dd7370..e8ac5e6b1 100644 --- a/srslte/lib/fec/test/turbodecoder_test.c +++ b/srslte/lib/fec/test/turbodecoder_test.c @@ -93,7 +93,7 @@ void parse_args(int argc, char **argv) { seed = (uint32_t) strtoul(argv[optind], NULL, 0); break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(argv[0]); @@ -162,29 +162,29 @@ int main(int argc, char **argv) { printf(" EbNo: %.2f\n", ebno_db); } - data_tx = vec_malloc(frame_length * sizeof(uint8_t)); + data_tx = srslte_vec_malloc(frame_length * sizeof(uint8_t)); if (!data_tx) { perror("malloc"); exit(-1); } - data_rx = vec_malloc(frame_length * sizeof(uint8_t)); + data_rx = srslte_vec_malloc(frame_length * sizeof(uint8_t)); if (!data_rx) { perror("malloc"); exit(-1); } - symbols = vec_malloc(coded_length * sizeof(uint8_t)); + symbols = srslte_vec_malloc(coded_length * sizeof(uint8_t)); if (!symbols) { perror("malloc"); exit(-1); } - llr = vec_malloc(coded_length * sizeof(float)); + llr = srslte_vec_malloc(coded_length * sizeof(float)); if (!llr) { perror("malloc"); exit(-1); } - llr_c = vec_malloc(coded_length * sizeof(uint8_t)); + llr_c = srslte_vec_malloc(coded_length * sizeof(uint8_t)); if (!llr_c) { perror("malloc"); exit(-1); @@ -267,7 +267,7 @@ int main(int argc, char **argv) { mean_usec = (float) mean_usec * 0.9 + (float) tdata[0].tv_usec * 0.1; /* check errors */ - errors[j] += bit_diff(data_tx, data_rx, frame_length); + errors[j] += srslte_bit_diff(data_tx, data_rx, frame_length); if (j < MAX_ITERATIONS) { ber[j][i] = (float) errors[j] / (frame_cnt * frame_length); } diff --git a/srslte/lib/fec/test/turbodecoder_test_mex.c b/srslte/lib/fec/test/turbodecoder_test_mex.c index 8cda8dd38..ebf817875 100644 --- a/srslte/lib/fec/test/turbodecoder_test_mex.c +++ b/srslte/lib/fec/test/turbodecoder_test_mex.c @@ -84,7 +84,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } // allocate memory for output bits - output_data = vec_malloc(nof_bits * sizeof(uint8_t)); + output_data = srslte_vec_malloc(nof_bits * sizeof(uint8_t)); if (srslte_tdec_init(&tdec, nof_bits)) { mexErrMsgTxt("Error initiating Turbo decoder\n"); diff --git a/srslte/lib/fec/test/viterbi_test.c b/srslte/lib/fec/test/viterbi_test.c index 3e92ead6f..25b267693 100644 --- a/srslte/lib/fec/test/viterbi_test.c +++ b/srslte/lib/fec/test/viterbi_test.c @@ -279,7 +279,7 @@ int main(int argc, char **argv) { } srslte_ch_awgn_f(llr, llr, var[i], coded_length[n]); - vec_quant_fuc(llr, llr_c, Gain, 127.5, 255, coded_length[n]); + srslte_vec_quant_fuc(llr, llr_c, Gain, 127.5, 255, coded_length[n]); /* decoder 1 */ srslte_viterbi_decode_uc(&dec[n], llr_c, data_rx[1+n], frame_length); @@ -287,7 +287,7 @@ int main(int argc, char **argv) { /* check errors */ for (j = 0; j < 1+ncods; j++) { - errors[j] += bit_diff(data_tx, data_rx[j], frame_length); + errors[j] += srslte_bit_diff(data_tx, data_rx[j], frame_length); } frame_cnt++; printf("Eb/No: %3.2f %10d/%d ", diff --git a/srslte/lib/fec/test/viterbi_test_mex.c b/srslte/lib/fec/test/viterbi_test_mex.c index 2356aeab1..874628d30 100644 --- a/srslte/lib/fec/test/viterbi_test_mex.c +++ b/srslte/lib/fec/test/viterbi_test_mex.c @@ -59,7 +59,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) // Read input symbols nof_bits = mexutils_read_f(INPUT, &input_llr); - output_data = vec_malloc(nof_bits * sizeof(uint8_t)); + output_data = srslte_vec_malloc(nof_bits * sizeof(uint8_t)); uint32_t poly[3] = { 0x6D, 0x4F, 0x57 }; if (srslte_viterbi_init(&viterbi, SRSLTE_VITERBI_37, poly, nof_bits/3, true)) { diff --git a/srslte/lib/filter/src/filter2d.c b/srslte/lib/filter/src/filter2d.c deleted file mode 100644 index b40afe9e3..000000000 --- a/srslte/lib/filter/src/filter2d.c +++ /dev/null @@ -1,194 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2014 The libLTE Developers. See the - * COPYRIGHT file at the top-level directory of this distribution. - * - * \section LICENSE - * - * This file is part of the libLTE library. - * - * libLTE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * libLTE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * A copy of the GNU Lesser General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - - -#include -#include -#include - -#include "srslte/utils/debug.h" - -#include "srslte/resampling/interp.h" -#include "srslte/filter/filter2d.h" -#include "srslte/utils/matrix.h" -#include "srslte/utils/vector.h" -#include "srslte/utils/debug.h" - -/* Useful macros */ -#define intceil(X, Y) ((X-1)/Y+1) - -#define idx(a, b) ((a)*(q->szfreq+q->nfreq)+b) - -int srslte_filter2d_init(srslte_filter2d_t* q, float **taps, uint32_t ntime, uint32_t nfreq, uint32_t sztime, - uint32_t szfreq) { - - int ret = -1; - bzero(q, sizeof(srslte_filter2d_t)); - - if (matrix_init((void***)&q->taps, ntime, nfreq, sizeof(float))) { - goto free_and_exit; - } - - matrix_copy((void**) q->taps, (void**) taps, ntime, nfreq, sizeof(float)); - - q->output = vec_malloc((ntime+sztime)*(szfreq+nfreq)*sizeof(cf_t)); - if (!q->output) { - goto free_and_exit; - } - - bzero(q->output, (ntime+sztime)*(szfreq+nfreq)*sizeof(cf_t)); - - q->nfreq = nfreq; - q->ntime = ntime; - q->szfreq = szfreq; - q->sztime = sztime; - - q->norm = 0.0; - for (int i = 0; i < ntime; i++) { - for (int j = 0; j < nfreq; j++) { - q->norm += q->taps[i][j]; - } - } - ret = 0; - - free_and_exit: if (ret == -1) { - srslte_filter2d_free(q); - } - return ret; -} - -void srslte_filter2d_free(srslte_filter2d_t *q) { - - matrix_free((void**) q->taps, q->ntime); - if (q->output) { - free(q->output); - } - bzero(q, sizeof(srslte_filter2d_t)); -} - -int srslte_filter2d_init_ones(srslte_filter2d_t* q, uint32_t ntime, uint32_t nfreq, uint32_t sztime, - uint32_t szfreq) -{ - - int i, j; - float **taps; - int ret = -1; - - if (matrix_init((void***) &taps, ntime, nfreq, sizeof(float))) { - goto free_and_exit; - } - /* Compute the default 2-D interpolation mesh */ - for (i = 0; i < ntime; i++) { - for (j = 0; j < nfreq; j++) { - taps[i][j] = 1.0/(i+1); - } - } - - INFO("Using all-ones interpolation matrix of size %dx%d\n", ntime, nfreq); - if (verbose >= VERBOSE_INFO) { - matrix_fprintf_f(stdout, taps, ntime, nfreq); - } - - if (srslte_filter2d_init(q, taps, ntime, nfreq, sztime, szfreq)) { - goto free_and_exit; - } - - ret = 0; -free_and_exit: - matrix_free((void**) taps, ntime); - return ret; -} - -/* Moves the last ntime symbols to the start and clears the remaining of the output. - * Should be called, for instance, before filtering each OFDM frame. - */ -void srslte_filter2d_step(srslte_filter2d_t *q) { - int i; - - for (i = 0; i < q->ntime; i++) { - memcpy(&q->output[idx(i,0)], &q->output[idx(q->sztime + i,0)], - sizeof(cf_t) * (q->szfreq+q->nfreq)); - } - - for (; i < q->ntime + q->sztime; i++) { - memset(&q->output[idx(i,0)], 0, sizeof(cf_t) * (q->szfreq+q->nfreq)); - } -} - -void srslte_filter2d_reset(srslte_filter2d_t *q) { - bzero(q->output, (q->ntime+q->sztime)*(q->szfreq+q->nfreq)*sizeof(cf_t)); -} - -/** Adds samples x to the from the given time/freq indexes to the filter - * and computes the output. - */ -void srslte_filter2d_add(srslte_filter2d_t *q, cf_t x, uint32_t time_idx, uint32_t freq_idx) { - int i, j; - - uint32_t ntime = q->ntime; - uint32_t nfreq = q->nfreq; - - if (freq_idx < q->szfreq && time_idx < q->sztime) { - DEBUG("Adding %f+%fi to %d:%d\n",__real__ x,__imag__ x,time_idx,freq_idx); - - for (i = 0; i < ntime; i++) { - for (j = 0; j < nfreq; j++) { - q->output[idx(i+time_idx, j+freq_idx)] += x * (cf_t)(q->taps[i][j])/q->norm; - } - } - } -} - -void srslte_filter2d_add_out(srslte_filter2d_t *q, cf_t x, int time_idx, int freq_idx) { - int i, j; - - uint32_t ntime = q->ntime; - uint32_t nfreq = q->nfreq; - float norm=0; - for (i = 0; i < ntime; i++) { - for (j = 0; j < nfreq; j++) { - if (i+time_idx >= 0 && j+freq_idx >= 0 && - i+time_idx < q->ntime+q->sztime && j+freq_idx < q->nfreq + q->szfreq) - { - norm += q->taps[i][j]; - } - } - } - for (i = 0; i < ntime; i++) { - for (j = 0; j < nfreq; j++) { - if (i+time_idx >= 0 && j+freq_idx >= 0 && - i+time_idx < q->ntime+q->sztime && j+freq_idx < q->nfreq + q->szfreq) - { - q->output[idx(i+time_idx, j+freq_idx)] += x * (cf_t)(q->taps[i][j])/q->norm; - } - } - } -} - -void srslte_filter2d_get_symbol(srslte_filter2d_t *q, uint32_t nsymbol, cf_t *output) { - memcpy(output, &q->output[idx(nsymbol,q->nfreq/2)], sizeof(cf_t) * (q->szfreq)); -} diff --git a/srslte/lib/io/src/binsource.c b/srslte/lib/io/src/binsource.c index 2bd57da25..c5bf28b19 100644 --- a/srslte/lib/io/src/binsource.c +++ b/srslte/lib/io/src/binsource.c @@ -106,9 +106,9 @@ static int int_2_bits(uint32_t* src, uint8_t* dst, int nbits) { int n; n=nbits/32; for (int i=0;ih_mod = vec_malloc(sizeof(cf_t) * max_frame_len); + q->h_mod = srslte_vec_malloc(sizeof(cf_t) * max_frame_len); if (!q->h_mod) { perror("malloc"); goto clean_exit; } - q->tmp1 = vec_malloc(sizeof(cf_t) * max_frame_len); + q->tmp1 = srslte_vec_malloc(sizeof(cf_t) * max_frame_len); if (!q->tmp1) { perror("malloc"); goto clean_exit; } - q->tmp2 = vec_malloc(sizeof(cf_t) * max_frame_len); + q->tmp2 = srslte_vec_malloc(sizeof(cf_t) * max_frame_len); if (!q->tmp2) { perror("malloc"); goto clean_exit; } - q->tmp3 = vec_malloc(sizeof(cf_t) * max_frame_len); + q->tmp3 = srslte_vec_malloc(sizeof(cf_t) * max_frame_len); if (!q->tmp3) { perror("malloc"); goto clean_exit; } - q->y_mod = vec_malloc(sizeof(float) * max_frame_len); + q->y_mod = srslte_vec_malloc(sizeof(float) * max_frame_len); if (!q->y_mod) { perror("malloc"); goto clean_exit; } - q->z_real = vec_malloc(sizeof(float) * max_frame_len); + q->z_real = srslte_vec_malloc(sizeof(float) * max_frame_len); if (!q->z_real) { perror("malloc"); goto clean_exit; } - q->z_imag = vec_malloc(sizeof(float) * max_frame_len); + q->z_imag = srslte_vec_malloc(sizeof(float) * max_frame_len); if (!q->z_imag) { perror("malloc"); goto clean_exit; @@ -87,11 +87,11 @@ int precoding_init(precoding_t *q, uint32_t max_frame_len) { return SRSLTE_ERROR_INVALID_INPUTS; } clean_exit: - precoding_free(q); + srslte_precoding_free(q); return SRSLTE_ERROR; } -void precoding_free(precoding_t *q) { +void srslte_precoding_free(srslte_precoding_t *q) { if (q->tmp1) { free(q->tmp1); @@ -114,22 +114,22 @@ void precoding_free(precoding_t *q) { if (q->z_imag) { free(q->z_imag); } - bzero(q, sizeof(precoding_t)); + bzero(q, sizeof(srslte_precoding_t)); } /* ZF/MMSE SISO equalizer x=y(h'h+no)^(-1)h' (ZF if n0=0.0)*/ -int predecoding_single(precoding_t *q, cf_t *y, cf_t *h, cf_t *x, int nof_symbols, float noise_estimate) { +int srslte_predecoding_single(srslte_precoding_t *q, cf_t *y, cf_t *h, cf_t *x, int nof_symbols, float noise_estimate) { if (nof_symbols <= q->max_frame_len) { // h'h - vec_abs_square_cf(h, q->y_mod, nof_symbols); + srslte_vec_abs_square_cf(h, q->y_mod, nof_symbols); if (noise_estimate > 0.0) { // (h'h + n0) - vec_sc_add_fff(q->y_mod, noise_estimate, q->y_mod, nof_symbols); + srslte_vec_sc_add_fff(q->y_mod, noise_estimate, q->y_mod, nof_symbols); } // y*h' - vec_prod_conj_ccc(y, h, x, nof_symbols); + srslte_vec_prod_conj_ccc(y, h, x, nof_symbols); // divide by (h'h+no) - vec_div_cfc(x,q->y_mod,x,q->z_real,q->z_imag, nof_symbols); + srslte_vec_div_cfc(x,q->y_mod,x,q->z_real,q->z_imag, nof_symbols); return nof_symbols; } else { return SRSLTE_ERROR; @@ -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[SRSLTE_MAX_LAYERS], +int srslte_predecoding_diversity(srslte_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; @@ -166,27 +166,27 @@ int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf } // Compute common dividend and store in y_mod - vec_abs_square_cf(h0, modh0, nof_symbols/2); - vec_abs_square_cf(h1, modh1, nof_symbols/2); - vec_sum_fff(modh0, modh1, modhh, nof_symbols/2); + srslte_vec_abs_square_cf(h0, modh0, nof_symbols/2); + srslte_vec_abs_square_cf(h1, modh1, nof_symbols/2); + srslte_vec_sum_fff(modh0, modh1, modhh, nof_symbols/2); //if (noise_estimate > 0.0) { // (H'H + n0) - //vec_sc_add_fff(modhh, noise_estimate, modhh, nof_symbols/2); + //srslte_vec_sc_add_fff(modhh, noise_estimate, modhh, nof_symbols/2); //} - vec_sc_prod_fff(modhh, 1/sqrt(2), modhh, nof_symbols/2); + srslte_vec_sc_prod_fff(modhh, 1/sqrt(2), modhh, nof_symbols/2); // x[0] = r0·h0*/(|h0|+|h1|)+r1*·h1/(|h0|+|h1|) - vec_prod_conj_ccc(r0,h0,q->tmp1, nof_symbols/2); - vec_prod_conj_ccc(h1,r1,q->tmp2, nof_symbols/2); - vec_sum_ccc(q->tmp1, q->tmp2, x[0], nof_symbols/2); - vec_div_cfc(x[0], modhh, x[0], q->z_real, q->z_imag, nof_symbols/2); + srslte_vec_prod_conj_ccc(r0,h0,q->tmp1, nof_symbols/2); + srslte_vec_prod_conj_ccc(h1,r1,q->tmp2, nof_symbols/2); + srslte_vec_sum_ccc(q->tmp1, q->tmp2, x[0], nof_symbols/2); + srslte_vec_div_cfc(x[0], modhh, x[0], q->z_real, q->z_imag, nof_symbols/2); // x[1] = r1·h0*/(|h0|+|h1|)-r0*·h1/(|h0|+|h1|) - vec_prod_conj_ccc(r1,h0,q->tmp1, nof_symbols/2); - vec_prod_conj_ccc(h1,r0,q->tmp2, nof_symbols/2); - vec_sub_ccc(q->tmp1, q->tmp2, x[1], nof_symbols/2); - vec_div_cfc(x[1], modhh, x[1], q->z_real, q->z_imag, nof_symbols/2); + srslte_vec_prod_conj_ccc(r1,h0,q->tmp1, nof_symbols/2); + srslte_vec_prod_conj_ccc(h1,r0,q->tmp2, nof_symbols/2); + srslte_vec_sub_ccc(q->tmp1, q->tmp2, x[1], nof_symbols/2); + srslte_vec_div_cfc(x[1], modhh, x[1], q->z_real, q->z_imag, nof_symbols/2); #else cf_t h0, h1, h2, h3, r0, r1, r2, r3; @@ -240,7 +240,7 @@ 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[SRSLTE_MAX_LAYERS], +int srslte_predecoding_type(srslte_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) { @@ -255,25 +255,25 @@ int predecoding_type(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x } switch (type) { - case SINGLE_ANTENNA: + case SRSLTE_MIMO_TYPE_SINGLE_ANTENNA: if (nof_ports == 1 && nof_layers == 1) { - return predecoding_single(q, y, h[0], x[0], nof_symbols, noise_estimate); + return srslte_predecoding_single(q, y, h[0], x[0], nof_symbols, noise_estimate); } else { fprintf(stderr, "Number of ports and layers must be 1 for transmission on single antenna ports\n"); return -1; } break; - case TX_DIVERSITY: + case SRSLTE_MIMO_TYPE_TX_DIVERSITY: if (nof_ports == nof_layers) { - return predecoding_diversity(q, y, h, x, nof_ports, nof_symbols, noise_estimate); + return srslte_predecoding_diversity(q, y, h, x, nof_ports, nof_symbols, noise_estimate); } else { fprintf(stderr, "Error number of layers must equal number of ports in transmit diversity\n"); return -1; } break; - case SPATIAL_MULTIPLEX: + case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX: fprintf(stderr, "Spatial multiplexing not supported\n"); return -1; } @@ -291,11 +291,11 @@ int predecoding_type(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x * **************************************************/ -int precoding_single(precoding_t *q, cf_t *x, cf_t *y, int nof_symbols) { +int srslte_precoding_single(srslte_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[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_ports, +int srslte_precoding_diversity(srslte_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) { @@ -306,8 +306,8 @@ int precoding_diversity(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSL y[1][2 * i + 1] = conjf(x[0][i]); } // normalize - vec_sc_prod_cfc(y[0], 1.0/sqrtf(2), y[0], 2*nof_symbols); - vec_sc_prod_cfc(y[1], 1.0/sqrtf(2), y[1], 2*nof_symbols); + srslte_vec_sc_prod_cfc(y[0], 1.0/sqrtf(2), y[0], 2*nof_symbols); + srslte_vec_sc_prod_cfc(y[1], 1.0/sqrtf(2), y[1], 2*nof_symbols); return 2 * i; } else if (nof_ports == 4) { //int m_ap = (nof_symbols%4)?(nof_symbols*4-2):nof_symbols*4; @@ -341,7 +341,7 @@ int precoding_diversity(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSL } /* 36.211 v10.3.0 Section 6.3.4 */ -int precoding_type(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_layers, +int srslte_precoding_type(srslte_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) { @@ -356,24 +356,24 @@ int precoding_type(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MA } switch (type) { - case SINGLE_ANTENNA: + case SRSLTE_MIMO_TYPE_SINGLE_ANTENNA: if (nof_ports == 1 && nof_layers == 1) { - return precoding_single(q, x[0], y[0], nof_symbols); + return srslte_precoding_single(q, x[0], y[0], nof_symbols); } else { fprintf(stderr, "Number of ports and layers must be 1 for transmission on single antenna ports\n"); return -1; } break; - case TX_DIVERSITY: + case SRSLTE_MIMO_TYPE_TX_DIVERSITY: if (nof_ports == nof_layers) { - return precoding_diversity(q, x, y, nof_ports, nof_symbols); + return srslte_precoding_diversity(q, x, y, nof_ports, nof_symbols); } else { fprintf(stderr, "Error number of layers must equal number of ports in transmit diversity\n"); return -1; } - case SPATIAL_MULTIPLEX: + case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX: fprintf(stderr, "Spatial multiplexing not supported\n"); return -1; } diff --git a/srslte/lib/mimo/test/precoding_test.c b/srslte/lib/mimo/test/precoding_test.c index e9e7128b9..a744f5e67 100644 --- a/srslte/lib/mimo/test/precoding_test.c +++ b/srslte/lib/mimo/test/precoding_test.c @@ -82,7 +82,7 @@ int main(int argc, char **argv) { 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; + srslte_precoding_t precoding; parse_args(argc, argv); @@ -97,35 +97,35 @@ int main(int argc, char **argv) { } for (i = 0; i < nof_layers; i++) { - x[i] = vec_malloc(sizeof(cf_t) * nof_symbols); + x[i] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols); if (!x[i]) { - perror("vec_malloc"); + perror("srslte_vec_malloc"); exit(-1); } xr[i] = calloc(1,sizeof(cf_t) * nof_symbols); if (!xr[i]) { - perror("vec_malloc"); + perror("srslte_vec_malloc"); exit(-1); } } for (i = 0; i < nof_ports; i++) { - y[i] = vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers); + y[i] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers); // TODO: The number of symbols per port is different in spatial multiplexing. if (!y[i]) { - perror("vec_malloc"); + perror("srslte_vec_malloc"); exit(-1); } - h[i] = vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers); + h[i] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers); if (!h[i]) { - perror("vec_malloc"); + perror("srslte_vec_malloc"); exit(-1); } } /* only 1 receiver antenna supported now */ - r[0] = vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers); + r[0] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers); if (!r[0]) { - perror("vec_malloc"); + perror("srslte_vec_malloc"); exit(-1); } @@ -136,13 +136,13 @@ int main(int argc, char **argv) { } } - if (precoding_init(&precoding, nof_symbols * nof_layers)) { + if (srslte_precoding_init(&precoding, nof_symbols * nof_layers)) { fprintf(stderr, "Error initializing precoding\n"); exit(-1); } /* precoding */ - if (precoding_type(&precoding, x, y, nof_layers, nof_ports, nof_symbols, type) < 0) { + if (srslte_precoding_type(&precoding, x, y, nof_layers, nof_ports, nof_symbols, type) < 0) { fprintf(stderr, "Error layer mapper encoder\n"); exit(-1); } @@ -173,7 +173,7 @@ int main(int argc, char **argv) { /* predecoding / equalization */ struct timeval t[3]; gettimeofday(&t[1], NULL); - if (predecoding_type(&precoding, r[0], h, xr, nof_ports, nof_layers, + if (srslte_predecoding_type(&precoding, r[0], h, xr, nof_ports, nof_layers, nof_symbols * nof_layers, type, 0) < 0) { fprintf(stderr, "Error layer mapper encoder\n"); exit(-1); @@ -206,7 +206,7 @@ int main(int argc, char **argv) { free(r[0]); - precoding_free(&precoding); + srslte_precoding_free(&precoding); printf("Ok\n"); exit(0); diff --git a/srslte/lib/modem/src/demod_hard.c b/srslte/lib/modem/src/demod_hard.c index 81341d9a4..e331d513e 100644 --- a/srslte/lib/modem/src/demod_hard.c +++ b/srslte/lib/modem/src/demod_hard.c @@ -33,31 +33,31 @@ #include "hard_demod_lte.h" -void demod_hard_init(demod_hard_t* q) { - bzero((void*) q, sizeof(demod_hard_t)); +void srslte_demod_hard_init(srslte_demod_hard_t* q) { + bzero((void*) q, sizeof(srslte_demod_hard_t)); } -void demod_hard_table_set(demod_hard_t* q, srslte_mod_t mod) { +void srslte_demod_hard_table_set(srslte_demod_hard_t* q, srslte_mod_t mod) { q->mod = mod; } -int demod_hard_demodulate(demod_hard_t* q, cf_t* symbols, uint8_t *bits, uint32_t nsymbols) { +int srslte_demod_hard_demodulate(srslte_demod_hard_t* q, cf_t* symbols, uint8_t *bits, uint32_t nsymbols) { int nbits=-1; switch(q->mod) { - case LTE_BPSK: + case SRSLTE_MOD_BPSK: hard_bpsk_demod(symbols,bits,nsymbols); nbits=nsymbols; break; - case LTE_QPSK: + case SRSLTE_MOD_QPSK: hard_qpsk_demod(symbols,bits,nsymbols); nbits=nsymbols*2; break; - case LTE_QAM16: + case SRSLTE_MOD_16QAM: hard_qam16_demod(symbols,bits,nsymbols); nbits=nsymbols*4; break; - case LTE_QAM64: + case SRSLTE_MOD_64QAM: hard_qam64_demod(symbols,bits,nsymbols); nbits=nsymbols*6; break; @@ -66,20 +66,20 @@ int demod_hard_demodulate(demod_hard_t* q, cf_t* symbols, uint8_t *bits, uint32_ } -int demod_hard_initialize(demod_hard_hl* hl) { - demod_hard_init(&hl->obj); - demod_hard_table_set(&hl->obj,hl->init.std); +int srslte_demod_hard_initialize(srslte_demod_hard_hl* hl) { + srslte_demod_hard_init(&hl->obj); + srslte_demod_hard_table_set(&hl->obj,hl->init.std); return 0; } -int demod_hard_work(demod_hard_hl* hl) { - int ret = demod_hard_demodulate(&hl->obj,hl->input,hl->output,hl->in_len); +int srslte_demod_hard_work(srslte_demod_hard_hl* hl) { + int ret = srslte_demod_hard_demodulate(&hl->obj,hl->input,hl->output,hl->in_len); hl->out_len = ret; return 0; } -int demod_hard_stop(demod_hard_hl* hl) { +int srslte_demod_hard_stop(srslte_demod_hard_hl* hl) { return 0; } diff --git a/srslte/lib/modem/src/demod_soft.c b/srslte/lib/modem/src/demod_soft.c index a3c243b8f..ae837154c 100644 --- a/srslte/lib/modem/src/demod_soft.c +++ b/srslte/lib/modem/src/demod_soft.c @@ -35,17 +35,17 @@ #include "soft_algs.h" -int demod_soft_init(demod_soft_t *q, uint32_t max_symbols) { +int srslte_demod_soft_init(srslte_demod_soft_t *q, uint32_t max_symbols) { int ret = SRSLTE_ERROR; - bzero((void*)q,sizeof(demod_soft_t)); + bzero((void*)q,sizeof(srslte_demod_soft_t)); q->sigma = 1.0; - q->zones = vec_malloc(sizeof(uint32_t) * max_symbols); + q->zones = srslte_vec_malloc(sizeof(uint32_t) * max_symbols); if (!q->zones) { perror("malloc"); goto clean_exit; } - q->dd = vec_malloc(sizeof(float*) * max_symbols * 7); + q->dd = srslte_vec_malloc(sizeof(float*) * max_symbols * 7); if (!q->dd) { perror("malloc"); goto clean_exit; @@ -56,40 +56,40 @@ int demod_soft_init(demod_soft_t *q, uint32_t max_symbols) { clean_exit: if (ret != SRSLTE_SUCCESS) { - demod_soft_free(q); + srslte_demod_soft_free(q); } return ret; } -void demod_soft_free(demod_soft_t *q) { +void srslte_demod_soft_free(srslte_demod_soft_t *q) { if (q->zones) { free(q->zones); } if (q->dd) { free(q->dd); } - bzero((void*)q,sizeof(demod_soft_t)); + bzero((void*)q,sizeof(srslte_demod_soft_t)); } -void demod_soft_table_set(demod_soft_t *q, modem_table_t *table) { +void srslte_demod_soft_table_set(srslte_demod_soft_t *q, srslte_srslte_modem_table_t *table) { q->table = table; } -void demod_soft_alg_set(demod_soft_t *q, enum alg alg_type) { +void srslte_demod_soft_alg_set(srslte_demod_soft_t *q, srslte_demod_soft_alg_t alg_type) { q->alg_type = alg_type; } -void demod_soft_sigma_set(demod_soft_t *q, float sigma) { +void srslte_demod_soft_sigma_set(srslte_demod_soft_t *q, float sigma) { q->sigma = 2*sigma; } -int demod_soft_demodulate(demod_soft_t *q, const cf_t* symbols, float* llr, int nsymbols) { +int srslte_demod_soft_demodulate(srslte_demod_soft_t *q, const cf_t* symbols, float* llr, int nsymbols) { switch(q->alg_type) { - case EXACT: + case SRSLTE_DEMOD_SOFT_ALG_EXACT: llr_exact(symbols, llr, nsymbols, q->table->nsymbols, q->table->nbits_x_symbol, q->table->symbol_table, q->table->soft_table.idx, q->sigma); break; - case APPROX: + case SRSLTE_DEMOD_SOFT_ALG_APPROX: if (nsymbols <= q->max_symbols) { llr_approx(symbols, llr, nsymbols, q->table->nsymbols, q->table->nbits_x_symbol, @@ -109,26 +109,26 @@ int demod_soft_demodulate(demod_soft_t *q, const cf_t* symbols, float* llr, int /* High-Level API */ -int demod_soft_initialize(demod_soft_hl* hl) { - modem_table_init(&hl->table); - if (modem_table_lte(&hl->table,hl->init.std,true)) { +int srslte_demod_soft_initialize(srslte_demod_soft_hl* hl) { + srslte_modem_table_init(&hl->table); + if (srslte_modem_table_lte(&hl->table,hl->init.std,true)) { return -1; } - demod_soft_init(&hl->obj, 10000); + srslte_demod_soft_init(&hl->obj, 10000); hl->obj.table = &hl->table; return 0; } -int demod_soft_work(demod_soft_hl* hl) { +int srslte_demod_soft_work(srslte_demod_soft_hl* hl) { hl->obj.sigma = hl->ctrl_in.sigma; hl->obj.alg_type = hl->ctrl_in.alg_type; - int ret = demod_soft_demodulate(&hl->obj,hl->input,hl->output,hl->in_len); + int ret = srslte_demod_soft_demodulate(&hl->obj,hl->input,hl->output,hl->in_len); hl->out_len = ret; return 0; } -int demod_soft_stop(demod_soft_hl* hl) { - modem_table_free(&hl->table); +int srslte_demod_soft_stop(srslte_demod_soft_hl* hl) { + srslte_modem_table_free(&hl->table); return 0; } diff --git a/srslte/lib/modem/src/lte_tables.c b/srslte/lib/modem/src/lte_tables.c index d15622a71..461c82df3 100644 --- a/srslte/lib/modem/src/lte_tables.c +++ b/srslte/lib/modem/src/lte_tables.c @@ -34,11 +34,11 @@ #include "srslte/modem/modem_table.h" #include "lte_tables.h" -void LLR_approx_params(const cf_t* table, soft_table_t *soft_table, int B); +void LLR_approx_params(const cf_t* table, srslte_soft_table_t *soft_table, int B); /** * Set the BPSK modulation table */ -void set_BPSKtable(cf_t* table, soft_table_t *soft_table, bool compute_soft_demod) +void set_BPSKtable(cf_t* table, srslte_soft_table_t *soft_table, bool compute_soft_demod) { // LTE-BPSK constellation: // Q @@ -71,7 +71,7 @@ void set_BPSKtable(cf_t* table, soft_table_t *soft_table, bool compute_soft_demo /** * Set the QPSK modulation table */ -void set_QPSKtable(cf_t* table, soft_table_t *soft_table, bool compute_soft_demod) +void set_QPSKtable(cf_t* table, srslte_soft_table_t *soft_table, bool compute_soft_demod) { uint32_t i,j; @@ -111,7 +111,7 @@ void set_QPSKtable(cf_t* table, soft_table_t *soft_table, bool compute_soft_demo /** * Set the 16QAM modulation table */ -void set_16QAMtable(cf_t* table, soft_table_t *soft_table, bool compute_soft_demod) +void set_16QAMtable(cf_t* table, srslte_soft_table_t *soft_table, bool compute_soft_demod) { uint32_t i,j; // LTE-16QAM constellation: @@ -178,7 +178,7 @@ void set_16QAMtable(cf_t* table, soft_table_t *soft_table, bool compute_soft_dem /** * Set the 64QAM modulation table */ -void set_64QAMtable(cf_t* table, soft_table_t *soft_table, bool compute_soft_demod) +void set_64QAMtable(cf_t* table, srslte_soft_table_t *soft_table, bool compute_soft_demod) { uint32_t i,j; // LTE-64QAM constellation: @@ -300,7 +300,7 @@ void set_64QAMtable(cf_t* table, soft_table_t *soft_table, bool compute_soft_dem } /* Precompute two tables for calculating the distances based on the received symbol location relative to the constellation points */ -void LLR_approx_params(const cf_t* table, soft_table_t *soft_table, int B) { +void LLR_approx_params(const cf_t* table, srslte_soft_table_t *soft_table, int B) { int i, j, b, k; float x, y, d0, d1, min_d0, min_d1; diff --git a/srslte/lib/modem/src/lte_tables.h b/srslte/lib/modem/src/lte_tables.h index 3698945fc..c1f1b03fc 100644 --- a/srslte/lib/modem/src/lte_tables.h +++ b/srslte/lib/modem/src/lte_tables.h @@ -54,17 +54,17 @@ void set_BPSKtable(cf_t* table, - soft_table_t *soft_table, + srslte_soft_table_t *soft_table, bool compute_soft_demod); void set_QPSKtable(cf_t* table, - soft_table_t *soft_table, + srslte_soft_table_t *soft_table, bool compute_soft_demod); void set_16QAMtable(cf_t* table, - soft_table_t *soft_table, + srslte_soft_table_t *soft_table, bool compute_soft_demod); void set_64QAMtable(cf_t* table, - soft_table_t *soft_table, + srslte_soft_table_t *soft_table, bool compute_soft_demod); diff --git a/srslte/lib/modem/src/mod.c b/srslte/lib/modem/src/mod.c index b65701d09..ed0b6afaf 100644 --- a/srslte/lib/modem/src/mod.c +++ b/srslte/lib/modem/src/mod.c @@ -35,12 +35,12 @@ /** Low-level API */ -int mod_modulate(modem_table_t* q, const uint8_t *bits, cf_t* symbols, uint32_t nbits) { +int srslte_mod_modulate(srslte_srslte_modem_table_t* q, uint8_t *bits, cf_t* symbols, uint32_t nbits) { uint32_t i,j,idx; uint8_t *b_ptr=(uint8_t*) bits; j=0; for (i=0;inbits_x_symbol) { - idx = bit_unpack(&b_ptr,q->nbits_x_symbol); + idx = srslte_bit_unpack(&b_ptr,q->nbits_x_symbol); if (idx < q->nsymbols) { symbols[j] = q->symbol_table[idx]; } else { @@ -53,23 +53,23 @@ int mod_modulate(modem_table_t* q, const uint8_t *bits, cf_t* symbols, uint32_t /* High-Level API */ -int mod_initialize(mod_hl* hl) { - modem_table_init(&hl->obj); - if (modem_table_lte(&hl->obj,hl->init.std,false)) { +int mod_initialize(srslte_mod_hl* hl) { + srslte_modem_table_init(&hl->obj); + if (srslte_modem_table_lte(&hl->obj,hl->init.std,false)) { return -1; } return 0; } -int mod_work(mod_hl* hl) { - int ret = mod_modulate(&hl->obj,hl->input,hl->output,hl->in_len); +int mod_work(srslte_mod_hl* hl) { + int ret = srslte_mod_modulate(&hl->obj,hl->input,hl->output,hl->in_len); hl->out_len = ret; return 0; } -int mod_stop(mod_hl* hl) { - modem_table_free(&hl->obj); +int mod_stop(srslte_mod_hl* hl) { + srslte_modem_table_free(&hl->obj); return 0; } diff --git a/srslte/lib/modem/src/modem_table.c b/srslte/lib/modem/src/modem_table.c index 5dfde43bc..1fb671172 100644 --- a/srslte/lib/modem/src/modem_table.c +++ b/srslte/lib/modem/src/modem_table.c @@ -38,26 +38,26 @@ #include "lte_tables.h" /** Internal functions */ -static int table_create(modem_table_t* q) { +static int table_create(srslte_srslte_modem_table_t* q) { q->symbol_table = malloc(q->nsymbols*sizeof(cf_t)); return q->symbol_table==NULL; } -void modem_table_init(modem_table_t* q) { - bzero((void*)q,sizeof(modem_table_t)); +void srslte_modem_table_init(srslte_srslte_modem_table_t* q) { + bzero((void*)q,sizeof(srslte_srslte_modem_table_t)); } -void modem_table_free(modem_table_t* q) { +void srslte_modem_table_free(srslte_srslte_modem_table_t* q) { if (q->symbol_table) { free(q->symbol_table); } - bzero(q, sizeof(modem_table_t)); + bzero(q, sizeof(srslte_srslte_modem_table_t)); } -void modem_table_reset(modem_table_t* q) { - modem_table_free(q); - modem_table_init(q); +void srslte_modem_table_reset(srslte_srslte_modem_table_t* q) { + srslte_modem_table_free(q); + srslte_modem_table_init(q); } -int modem_table_set(modem_table_t* q, cf_t* table, soft_table_t *soft_table, uint32_t nsymbols, uint32_t nbits_x_symbol) { +int srslte_modem_table_set(srslte_srslte_modem_table_t* q, cf_t* table, srslte_soft_table_t *soft_table, uint32_t nsymbols, uint32_t nbits_x_symbol) { if (q->nsymbols) { return SRSLTE_ERROR; } @@ -66,14 +66,14 @@ int modem_table_set(modem_table_t* q, cf_t* table, soft_table_t *soft_table, uin return SRSLTE_ERROR; } memcpy(q->symbol_table,table,q->nsymbols*sizeof(cf_t)); - memcpy(&q->soft_table,soft_table,sizeof(soft_table_t)); + memcpy(&q->soft_table,soft_table,sizeof(srslte_soft_table_t)); q->nbits_x_symbol = nbits_x_symbol; return SRSLTE_SUCCESS; } -int modem_table_lte(modem_table_t* q, srslte_mod_t modulation, bool compute_soft_demod) { +int srslte_modem_table_lte(srslte_srslte_modem_table_t* q, srslte_mod_t modulation, bool compute_soft_demod) { switch(modulation) { - case LTE_BPSK: + case SRSLTE_MOD_BPSK: q->nbits_x_symbol = 1; q->nsymbols = 2; if (table_create(q)) { @@ -81,7 +81,7 @@ int modem_table_lte(modem_table_t* q, srslte_mod_t modulation, bool compute_soft } set_BPSKtable(q->symbol_table, &q->soft_table, compute_soft_demod); break; - case LTE_QPSK: + case SRSLTE_MOD_QPSK: q->nbits_x_symbol = 2; q->nsymbols = 4; if (table_create(q)) { @@ -89,7 +89,7 @@ int modem_table_lte(modem_table_t* q, srslte_mod_t modulation, bool compute_soft } set_QPSKtable(q->symbol_table, &q->soft_table, compute_soft_demod); break; - case LTE_QAM16: + case SRSLTE_MOD_16QAM: q->nbits_x_symbol = 4; q->nsymbols = 16; if (table_create(q)) { @@ -97,7 +97,7 @@ int modem_table_lte(modem_table_t* q, srslte_mod_t modulation, bool compute_soft } set_16QAMtable(q->symbol_table, &q->soft_table, compute_soft_demod); break; - case LTE_QAM64: + case SRSLTE_MOD_64QAM: q->nbits_x_symbol = 6; q->nsymbols = 64; if (table_create(q)) { diff --git a/srslte/lib/modem/src/soft_algs.c b/srslte/lib/modem/src/soft_algs.c index 3cdf29c9d..c4d9064d5 100644 --- a/srslte/lib/modem/src/soft_algs.c +++ b/srslte/lib/modem/src/soft_algs.c @@ -45,9 +45,9 @@ typedef _Complex float cf_t; // There are 3 implemenations: 1 - based on zones; 2 - using volk, 3 - straightforward C -#define LLR_APPROX_IMPLEMENTATION 1 +#define LLR_SRSLTE_DEMOD_SOFT_ALG_APPROX_IMPLEMENTATION 1 -#if LLR_APPROX_IMPLEMENTATION == 1 +#if LLR_SRSLTE_DEMOD_SOFT_ALG_APPROX_IMPLEMENTATION == 1 /** @@ -475,7 +475,7 @@ static void compute_square_dist(uint32_t *zone, float *dd, const cf_t * in, cf_t symbols_extract[b] = symbols[idx[zone[s]][b]]; /* only subset of distances to constellation points needed for LLR approx */ } - vec_square_dist(in[s], symbols_extract, d_ptr, B + 1); /* B+1 distances to be computed */ + srslte_vec_square_dist(in[s], symbols_extract, d_ptr, B + 1); /* B+1 distances to be computed */ } } @@ -502,7 +502,7 @@ void llr_approx(const _Complex float *in, float *out, int N, int M, int B, } } -#elif LLR_APPROX_IMPLEMENTATION == 2 +#elif LLR_SRSLTE_DEMOD_SOFT_ALG_APPROX_IMPLEMENTATION == 2 float d[10000][64]; float num[10000], den[10000]; @@ -513,7 +513,7 @@ static void compute_square_dist(const cf_t * in, cf_t * symbols, int N, int M) float *d_ptr; for (s = 0; s < N; s++) { d_ptr = d[s]; - vec_square_dist(in[s], symbols, d_ptr, M); + srslte_vec_square_dist(in[s], symbols, d_ptr, M); } } diff --git a/srslte/lib/modem/test/modem_test.c b/srslte/lib/modem/test/modem_test.c index 6a513a193..d2cdd5662 100644 --- a/srslte/lib/modem/test/modem_test.c +++ b/srslte/lib/modem/test/modem_test.c @@ -67,16 +67,16 @@ void parse_args(int argc, char **argv) { case 'm': switch(atoi(argv[optind])) { case 1: - modulation = LTE_BPSK; + modulation = SRSLTE_MOD_BPSK; break; case 2: - modulation = LTE_QPSK; + modulation = SRSLTE_MOD_QPSK; break; case 4: - modulation = LTE_QAM16; + modulation = SRSLTE_MOD_16QAM; break; case 6: - modulation = LTE_QAM64; + modulation = SRSLTE_MOD_64QAM; break; default: fprintf(stderr, "Invalid modulation %d. Possible values: " @@ -94,9 +94,9 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { int i; - modem_table_t mod; - demod_hard_t demod_hard; - demod_soft_t demod_soft; + srslte_srslte_modem_table_t mod; + srslte_demod_hard_t demod_hard; + srslte_demod_soft_t demod_soft; uint8_t *input, *output; cf_t *symbols; float *llr; @@ -108,7 +108,7 @@ int main(int argc, char **argv) { parse_args(argc, argv); /* initialize objects */ - if (modem_table_lte(&mod, modulation, soft_output)) { + if (srslte_modem_table_lte(&mod, modulation, soft_output)) { fprintf(stderr, "Error initializing modem table\n"); exit(-1); } @@ -120,12 +120,12 @@ int main(int argc, char **argv) { } if (soft_output) { - demod_soft_init(&demod_soft, num_bits / mod.nbits_x_symbol); - demod_soft_table_set(&demod_soft, &mod); - demod_soft_alg_set(&demod_soft, soft_exact?EXACT:APPROX); + srslte_demod_soft_init(&demod_soft, num_bits / mod.nbits_x_symbol); + srslte_demod_soft_table_set(&demod_soft, &mod); + srslte_demod_soft_alg_set(&demod_soft, soft_exact?SRSLTE_DEMOD_SOFT_ALG_EXACT:SRSLTE_DEMOD_SOFT_ALG_APPROX); } else { - demod_hard_init(&demod_hard); - demod_hard_table_set(&demod_hard, modulation); + srslte_demod_hard_init(&demod_hard); + srslte_demod_hard_table_set(&demod_hard, modulation); } /* allocate buffers */ @@ -158,13 +158,13 @@ int main(int argc, char **argv) { } /* modulate */ - mod_modulate(&mod, input, symbols, num_bits); + srslte_mod_modulate(&mod, input, symbols, num_bits); /* demodulate */ if (soft_output) { gettimeofday(&x, NULL); - demod_soft_demodulate(&demod_soft, symbols, llr, num_bits / mod.nbits_x_symbol); + srslte_demod_soft_demodulate(&demod_soft, symbols, llr, num_bits / mod.nbits_x_symbol); gettimeofday(&y, NULL); printf("\nElapsed time [ns]: %d\n", (int) y.tv_usec - (int) x.tv_usec); @@ -172,7 +172,7 @@ int main(int argc, char **argv) { output[i] = llr[i]>=0 ? 1 : 0; } } else { - demod_hard_demodulate(&demod_hard, symbols, output, num_bits / mod.nbits_x_symbol); + srslte_demod_hard_demodulate(&demod_hard, symbols, output, num_bits / mod.nbits_x_symbol); } /* check errors */ @@ -188,9 +188,9 @@ int main(int argc, char **argv) { free(output); free(input); - modem_table_free(&mod); + srslte_modem_table_free(&mod); if (soft_output) { - demod_soft_free(&demod_soft); + srslte_demod_soft_free(&demod_soft); } printf("Ok\n"); diff --git a/srslte/lib/modem/test/soft_demod_test.c b/srslte/lib/modem/test/soft_demod_test.c index 1c7d37af0..398fd9262 100644 --- a/srslte/lib/modem/test/soft_demod_test.c +++ b/srslte/lib/modem/test/soft_demod_test.c @@ -44,7 +44,7 @@ void usage(char *prog) { printf("Usage: %s [nfv] -m modulation (1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64)\n", prog); printf("\t-n num_bits [Default %d]\n", num_bits); printf("\t-f nof_frames [Default %d]\n", nof_frames); - printf("\t-v verbose [Default None]\n"); + printf("\t-v srslte_verbose [Default None]\n"); } void parse_args(int argc, char **argv) { @@ -58,21 +58,21 @@ void parse_args(int argc, char **argv) { nof_frames = atoi(argv[optind]); break; case 'v': - verbose++; + srslte_verbose++; break; case 'm': switch(atoi(argv[optind])) { case 1: - modulation = LTE_BPSK; + modulation = SRSLTE_MOD_BPSK; break; case 2: - modulation = LTE_QPSK; + modulation = SRSLTE_MOD_QPSK; break; case 4: - modulation = LTE_QAM16; + modulation = SRSLTE_MOD_16QAM; break; case 6: - modulation = LTE_QAM64; + modulation = SRSLTE_MOD_64QAM; break; default: fprintf(stderr, "Invalid modulation %d. Possible values: " @@ -93,13 +93,13 @@ void parse_args(int argc, char **argv) { float mse_threshold() { switch(modulation) { - case LTE_BPSK: + case SRSLTE_MOD_BPSK: return 1.0e-6; - case LTE_QPSK: + case SRSLTE_MOD_QPSK: return 1.0e-6; - case LTE_QAM16: + case SRSLTE_MOD_16QAM: return 0.11; - case LTE_QAM64: + case SRSLTE_MOD_64QAM: return 0.19; default: return -1.0; @@ -108,8 +108,8 @@ float mse_threshold() { int main(int argc, char **argv) { int i; - modem_table_t mod; - demod_soft_t demod_soft; + srslte_srslte_modem_table_t mod; + srslte_demod_soft_t demod_soft; uint8_t *input, *output; cf_t *symbols; float *llr_exact, *llr_approx; @@ -117,7 +117,7 @@ int main(int argc, char **argv) { parse_args(argc, argv); /* initialize objects */ - if (modem_table_lte(&mod, modulation, true)) { + if (srslte_modem_table_lte(&mod, modulation, true)) { fprintf(stderr, "Error initializing modem table\n"); exit(-1); } @@ -125,9 +125,9 @@ int main(int argc, char **argv) { /* check that num_bits is multiple of num_bits x symbol */ num_bits = mod.nbits_x_symbol * (num_bits / mod.nbits_x_symbol); - demod_soft_init(&demod_soft, num_bits / mod.nbits_x_symbol); - demod_soft_table_set(&demod_soft, &mod); - demod_soft_sigma_set(&demod_soft, 2.0 / mod.nbits_x_symbol); + srslte_demod_soft_init(&demod_soft, num_bits / mod.nbits_x_symbol); + srslte_demod_soft_table_set(&demod_soft, &mod); + srslte_demod_soft_sigma_set(&demod_soft, 2.0 / mod.nbits_x_symbol); /* allocate buffers */ @@ -172,24 +172,24 @@ int main(int argc, char **argv) { } /* modulate */ - mod_modulate(&mod, input, symbols, num_bits); + srslte_mod_modulate(&mod, input, symbols, num_bits); /* add noise */ srslte_ch_awgn_c(symbols, symbols, srslte_ch_awgn_get_variance(5.0, mod.nbits_x_symbol), num_bits / mod.nbits_x_symbol); /* Compare exact with approximation algorithms */ - demod_soft_alg_set(&demod_soft, EXACT); - demod_soft_demodulate(&demod_soft, symbols, llr_exact, num_bits / mod.nbits_x_symbol); + srslte_demod_soft_alg_set(&demod_soft, SRSLTE_DEMOD_SOFT_ALG_EXACT); + srslte_demod_soft_demodulate(&demod_soft, symbols, llr_exact, num_bits / mod.nbits_x_symbol); - demod_soft_alg_set(&demod_soft, APPROX); + srslte_demod_soft_alg_set(&demod_soft, SRSLTE_DEMOD_SOFT_ALG_APPROX); gettimeofday(&t[1], NULL); - demod_soft_demodulate(&demod_soft, symbols, llr_approx, num_bits / mod.nbits_x_symbol); + srslte_demod_soft_demodulate(&demod_soft, symbols, llr_approx, num_bits / mod.nbits_x_symbol); gettimeofday(&t[2], NULL); get_time_interval(t); /* compute exponentially averaged execution time */ if (n > 0) { - mean_texec = VEC_CMA((float) t[0].tv_usec, mean_texec, n-1); + mean_texec = SRSLTE_VEC_CMA((float) t[0].tv_usec, mean_texec, n-1); } /* check MSE */ @@ -200,12 +200,12 @@ int main(int argc, char **argv) { } mse/=num_bits; - if (VERBOSE_ISDEBUG()) { + if (SRSLTE_VERBOSE_ISDEBUG()) { printf("exact="); - vec_fprint_f(stdout, llr_exact, num_bits); + srslte_vec_fprint_f(stdout, llr_exact, num_bits); printf("approx="); - vec_fprint_f(stdout, llr_approx, num_bits); + srslte_vec_fprint_f(stdout, llr_approx, num_bits); } if (mse > mse_threshold()) { @@ -221,8 +221,8 @@ clean_exit: free(output); free(input); - modem_table_free(&mod); - demod_soft_free(&demod_soft); + srslte_modem_table_free(&mod); + srslte_demod_soft_free(&demod_soft); if (ret == 0) { printf("Ok Mean Throughput: %.2f. Mbps ExTime: %.2f us\n", num_bits/mean_texec, mean_texec); diff --git a/srslte/lib/phch/src/cqi.c b/srslte/lib/phch/src/cqi.c index f761253fc..275461df8 100644 --- a/srslte/lib/phch/src/cqi.c +++ b/srslte/lib/phch/src/cqi.c @@ -41,37 +41,37 @@ #include "srslte/utils/debug.h" -int cqi_hl_subband_pack(cqi_hl_subband_t *msg, uint32_t N, uint8_t *buff, uint32_t buff_len) +int srslte_cqi_hl_subband_pack(srslte_cqi_hl_subband_t *msg, uint32_t N, uint8_t *buff, uint32_t buff_len) { uint8_t *body_ptr = buff; - bit_pack(msg->wideband_cqi, &body_ptr, 4); - bit_pack(msg->subband_diff_cqi, &body_ptr, 2*N); + srslte_bit_pack(msg->wideband_cqi, &body_ptr, 4); + srslte_bit_pack(msg->subband_diff_cqi, &body_ptr, 2*N); return 4+2*N; } -int cqi_ue_subband_pack(cqi_ue_subband_t *msg, uint32_t L, uint8_t *buff, uint32_t buff_len) +int srslte_cqi_ue_subband_pack(srslte_cqi_ue_subband_t *msg, uint32_t L, uint8_t *buff, uint32_t buff_len) { uint8_t *body_ptr = buff; - bit_pack(msg->wideband_cqi, &body_ptr, 4); - bit_pack(msg->subband_diff_cqi, &body_ptr, 2); - bit_pack(msg->subband_diff_cqi, &body_ptr, L); + srslte_bit_pack(msg->wideband_cqi, &body_ptr, 4); + srslte_bit_pack(msg->subband_diff_cqi, &body_ptr, 2); + srslte_bit_pack(msg->subband_diff_cqi, &body_ptr, L); return 4+2+L; } -int cqi_format2_wideband_pack(cqi_format2_wideband_t *msg, uint8_t *buff, uint32_t buff_len) +int srslte_cqi_format2_wideband_pack(srslte_cqi_format2_wideband_t *msg, uint8_t *buff, uint32_t buff_len) { uint8_t *body_ptr = buff; - bit_pack(msg->wideband_cqi, &body_ptr, 4); + srslte_bit_pack(msg->wideband_cqi, &body_ptr, 4); return 4; } -int cqi_format2_subband_pack(cqi_format2_subband_t *msg, uint8_t *buff, uint32_t buff_len) +int srslte_cqi_format2_subband_pack(srslte_cqi_format2_subband_t *msg, uint8_t *buff, uint32_t buff_len) { uint8_t *body_ptr = buff; - bit_pack(msg->subband_cqi, &body_ptr, 4); - bit_pack(msg->subband_label, &body_ptr, 1); + srslte_bit_pack(msg->subband_cqi, &body_ptr, 4); + srslte_bit_pack(msg->subband_label, &body_ptr, 1); return 4+1; } diff --git a/srslte/lib/phch/src/dci.c b/srslte/lib/phch/src/dci.c index b5c0a59e9..abceb7378 100644 --- a/srslte/lib/phch/src/dci.c +++ b/srslte/lib/phch/src/dci.c @@ -43,9 +43,9 @@ /* Creates the DL PDSCH resource allocation grant from a DCI message */ -int dci_msg_to_ra_dl(dci_msg_t *msg, uint16_t msg_rnti, +int srslte_dci_msg_to_ra_dl(srslte_dci_msg_t *msg, uint16_t msg_rnti, srslte_cell_t cell, uint32_t cfi, - ra_pdsch_t *ra_dl) + srslte_ra_pdsch_t *ra_dl) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -57,43 +57,43 @@ int dci_msg_to_ra_dl(dci_msg_t *msg, uint16_t msg_rnti, { ret = SRSLTE_ERROR; - dci_msg_type_t type; - if (dci_msg_get_type(msg, &type, cell.nof_prb, msg_rnti)) { + srslte_dci_msg_type_t type; + if (srslte_dci_msg_get_type(msg, &type, cell.nof_prb, msg_rnti)) { fprintf(stderr, "Can't get DCI message type\n"); return ret; } - if (VERBOSE_ISINFO()) { + if (SRSLTE_VERBOSE_ISINFO()) { INFO("",0); - dci_msg_type_fprint(stdout, type); + srslte_dci_msg_type_fprint(stdout, type); } - if (type.type == PDSCH_SCHED) { - bzero(ra_dl, sizeof(ra_pdsch_t)); + if (type.type == SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED) { + bzero(ra_dl, sizeof(srslte_ra_pdsch_t)); bool srslte_crc_is_crnti = false; if (msg_rnti >= SRSLTE_CRNTI_START && msg_rnti <= SRSLTE_CRNTI_END) { srslte_crc_is_crnti = true; } - if (dci_msg_unpack_pdsch(msg, ra_dl, cell.nof_prb, srslte_crc_is_crnti)) { + if (srslte_dci_msg_unpack_pdsch(msg, ra_dl, cell.nof_prb, srslte_crc_is_crnti)) { fprintf(stderr, "Can't unpack PDSCH message\n"); return ret; } - if (VERBOSE_ISINFO()) { - ra_pdsch_fprint(stdout, ra_dl, cell.nof_prb); + if (SRSLTE_VERBOSE_ISINFO()) { + srslte_ra_pdsch_fprint(stdout, ra_dl, cell.nof_prb); } - if (ra_dl_alloc(&ra_dl->prb_alloc, ra_dl, cell.nof_prb)) { + if (srslte_ra_dl_alloc(&ra_dl->prb_alloc, ra_dl, cell.nof_prb)) { fprintf(stderr, "Error computing resource allocation\n"); return ret; } - ra_dl_alloc_re(&ra_dl->prb_alloc, cell.nof_prb, cell.nof_ports, cell.nof_prb<10?(cfi+1):cfi, cell.cp); + srslte_ra_dl_alloc_re(&ra_dl->prb_alloc, cell.nof_prb, cell.nof_ports, cell.nof_prb<10?(cfi+1):cfi, cell.cp); ret = SRSLTE_SUCCESS; } else { fprintf(stderr, "Unsupported message type: "); - dci_msg_type_fprint(stderr, type); + srslte_dci_msg_type_fprint(stderr, type); } } return ret; @@ -101,10 +101,10 @@ int dci_msg_to_ra_dl(dci_msg_t *msg, uint16_t msg_rnti, /* Creates the UL PUSCH resource allocation grant from the random access respone message */ -int dci_rar_to_ra_ul(uint32_t rba, uint32_t trunc_mcs, bool hopping_flag, uint32_t nof_prb, ra_pusch_t *ra) { - bzero(ra, sizeof(ra_pusch_t)); +int srslte_dci_rar_to_ra_ul(uint32_t rba, uint32_t trunc_mcs, bool hopping_flag, uint32_t nof_prb, srslte_ra_pusch_t *ra) { + bzero(ra, sizeof(srslte_ra_pusch_t)); if (!hopping_flag) { - ra->freq_hop_fl = hop_disabled; + ra->freq_hop_fl = SRSLTE_RA_PUSCH_HOP_DISABLED; } else { fprintf(stderr, "FIXME: Frequency hopping in RAR not implemented\n"); ra->freq_hop_fl = 1; @@ -119,16 +119,16 @@ int dci_rar_to_ra_ul(uint32_t rba, uint32_t trunc_mcs, bool hopping_flag, uint32 ra->type2_alloc.riv = riv; ra->mcs_idx = trunc_mcs; - ra_type2_from_riv(riv, &ra->type2_alloc.L_crb, &ra->type2_alloc.RB_start, + srslte_ra_type2_from_riv(riv, &ra->type2_alloc.L_crb, &ra->type2_alloc.RB_start, nof_prb, nof_prb); - ra_mcs_from_idx_ul(ra->mcs_idx, ra_nprb_ul(ra, nof_prb), &ra->mcs); + srslte_ra_mcs_from_idx_ul(ra->mcs_idx, srslte_ra_nprb_ul(ra, nof_prb), &ra->mcs); return SRSLTE_SUCCESS; } /* Creates the UL PUSCH resource allocation grant from a DCI format 0 message */ -int dci_msg_to_ra_ul(dci_msg_t *msg, uint32_t nof_prb, uint32_t n_rb_ho, ra_pusch_t *ra_ul) +int srslte_dci_msg_to_ra_ul(srslte_dci_msg_t *msg, uint32_t nof_prb, uint32_t n_rb_ho, srslte_ra_pusch_t *ra_ul) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -137,18 +137,18 @@ int dci_msg_to_ra_ul(dci_msg_t *msg, uint32_t nof_prb, uint32_t n_rb_ho, ra_pusc { ret = SRSLTE_ERROR; - bzero(ra_ul, sizeof(ra_pusch_t)); + bzero(ra_ul, sizeof(srslte_ra_pusch_t)); - if (dci_msg_unpack_pusch(msg, ra_ul, nof_prb)) { + if (srslte_dci_msg_unpack_pusch(msg, ra_ul, nof_prb)) { fprintf(stderr, "Can't unpack PDSCH message\n"); return ret; } - if (VERBOSE_ISINFO()) { - ra_pusch_fprint(stdout, ra_ul, nof_prb); + if (SRSLTE_VERBOSE_ISINFO()) { + srslte_ra_pusch_fprint(stdout, ra_ul, nof_prb); } - if (ra_ul_alloc(&ra_ul->prb_alloc, ra_ul, n_rb_ho, nof_prb)) { + if (srslte_ra_ul_alloc(&ra_ul->prb_alloc, ra_ul, n_rb_ho, nof_prb)) { fprintf(stderr, "Error computing resource allocation\n"); return ret; } @@ -158,7 +158,7 @@ int dci_msg_to_ra_ul(dci_msg_t *msg, uint32_t nof_prb, uint32_t n_rb_ho, ra_pusc return ret; } -int dci_location_set(dci_location_t *c, uint32_t L, uint32_t nCCE) { +int srslte_dci_location_set(srslte_dci_location_t *c, uint32_t L, uint32_t nCCE) { if (L <= 3) { c->L = L; } else { @@ -174,7 +174,7 @@ int dci_location_set(dci_location_t *c, uint32_t L, uint32_t nCCE) { return SRSLTE_SUCCESS; } -bool dci_location_isvalid(dci_location_t *c) { +bool srslte_dci_location_isvalid(srslte_dci_location_t *c) { if (c->L <= 3 && c->ncce <= 87) { return true; } else { @@ -227,7 +227,7 @@ uint32_t dci_format0_sizeof(uint32_t nof_prb) { uint32_t dci_format1_sizeof(uint32_t nof_prb) { - uint32_t n = (uint32_t) ceilf((float) nof_prb / ra_type0_P(nof_prb)) + 5 + 3 + 1 + 2 + uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb)) + 5 + 3 + 1 + 2 + 2; if (nof_prb > 10) { n++; @@ -240,8 +240,8 @@ uint32_t dci_format1_sizeof(uint32_t nof_prb) { } uint32_t dci_format1C_sizeof(uint32_t nof_prb) { - uint32_t n_vrb_dl_gap1 = ra_type2_n_vrb_dl(nof_prb, true); - uint32_t n_step = ra_type2_n_rb_step(nof_prb); + uint32_t n_vrb_dl_gap1 = srslte_ra_type2_n_vrb_dl(nof_prb, true); + uint32_t n_step = srslte_ra_type2_n_rb_step(nof_prb); uint32_t n = riv_nbits((uint32_t) n_vrb_dl_gap1 / n_step) + 5; if (nof_prb >= 50) { n++; @@ -249,15 +249,15 @@ uint32_t dci_format1C_sizeof(uint32_t nof_prb) { return n; } -uint32_t dci_format_sizeof(dci_format_t format, uint32_t nof_prb) { +uint32_t srslte_dci_format_sizeof(srslte_dci_format_t format, uint32_t nof_prb) { switch (format) { - case Format0: + case SRSLTE_DCI_FORMAT0: return dci_format0_sizeof(nof_prb); - case Format1: + case SRSLTE_DCI_FORMAT1: return dci_format1_sizeof(nof_prb); - case Format1A: + case SRSLTE_DCI_FORMAT1A: return dci_format1A_sizeof(nof_prb); - case Format1C: + case SRSLTE_DCI_FORMAT1C: return dci_format1C_sizeof(nof_prb); default: return SRSLTE_ERROR; @@ -273,14 +273,14 @@ uint32_t dci_format_sizeof(dci_format_t format, uint32_t nof_prb) { * * TODO: TPC and cyclic shift for DM RS not implemented */ -int dci_format0_pack(ra_pusch_t *data, dci_msg_t *msg, uint32_t nof_prb) { +int dci_format0_pack(srslte_ra_pusch_t *data, srslte_dci_msg_t *msg, uint32_t nof_prb) { /* pack bits */ uint8_t *y = msg->data; uint32_t n_ul_hop; *y++ = 0; // format differentiation - if (data->freq_hop_fl == hop_disabled) { // frequency hopping + if (data->freq_hop_fl == SRSLTE_RA_PUSCH_HOP_DISABLED) { // frequency hopping *y++ = 0; n_ul_hop = 0; } else { @@ -298,15 +298,15 @@ int dci_format0_pack(ra_pusch_t *data, dci_msg_t *msg, uint32_t nof_prb) { /* pack RIV according to 8.1 of 36.213 */ uint32_t riv; if (data->type2_alloc.L_crb) { - riv = ra_type2_to_riv(data->type2_alloc.L_crb, data->type2_alloc.RB_start, + riv = srslte_ra_type2_to_riv(data->type2_alloc.L_crb, data->type2_alloc.RB_start, nof_prb); } else { riv = data->type2_alloc.riv; } - bit_pack(riv, &y, riv_nbits(nof_prb) - n_ul_hop); + srslte_bit_pack(riv, &y, riv_nbits(nof_prb) - n_ul_hop); /* pack MCS according to 8.6.1 of 36.213 */ - bit_pack(data->mcs_idx, &y, 5); + srslte_bit_pack(data->mcs_idx, &y, 5); *y++ = data->ndi; @@ -335,24 +335,24 @@ int dci_format0_pack(ra_pusch_t *data, dci_msg_t *msg, uint32_t nof_prb) { * * TODO: TPC and cyclic shift for DM RS not implemented */ -int dci_format0_unpack(dci_msg_t *msg, ra_pusch_t *data, uint32_t nof_prb) { +int dci_format0_unpack(srslte_dci_msg_t *msg, srslte_ra_pusch_t *data, uint32_t nof_prb) { /* pack bits */ uint8_t *y = msg->data; uint32_t n_ul_hop; - /* Make sure it's a Format0 message */ - if (msg->nof_bits != dci_format_sizeof(Format0, nof_prb)) { + /* Make sure it's a SRSLTE_DCI_FORMAT0 message */ + if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT0, nof_prb)) { fprintf(stderr, "Invalid message length for format 0\n"); return SRSLTE_ERROR; } if (*y++ != 0) { fprintf(stderr, - "Invalid format differentiation field value. This is Format1A\n"); + "Invalid format differentiation field value. This is SRSLTE_DCI_FORMAT1A\n"); return SRSLTE_ERROR; } if (*y++ == 0) { - data->freq_hop_fl = hop_disabled; + data->freq_hop_fl = SRSLTE_RA_PUSCH_HOP_DISABLED; n_ul_hop = 0; } else { if (nof_prb < 50) { @@ -365,13 +365,13 @@ int dci_format0_unpack(dci_msg_t *msg, ra_pusch_t *data, uint32_t nof_prb) { } } /* unpack RIV according to 8.1 of 36.213 */ - uint32_t riv = bit_unpack(&y, riv_nbits(nof_prb) - n_ul_hop); - ra_type2_from_riv(riv, &data->type2_alloc.L_crb, &data->type2_alloc.RB_start, + uint32_t riv = srslte_bit_unpack(&y, riv_nbits(nof_prb) - n_ul_hop); + srslte_ra_type2_from_riv(riv, &data->type2_alloc.L_crb, &data->type2_alloc.RB_start, nof_prb, nof_prb); data->type2_alloc.riv = riv; /* unpack MCS according to 8.6 of 36.213 */ - data->mcs_idx = bit_unpack(&y, 5); + data->mcs_idx = srslte_bit_unpack(&y, 5); data->ndi = *y++ ? true : false; @@ -383,10 +383,10 @@ int dci_format0_unpack(dci_msg_t *msg, ra_pusch_t *data, uint32_t nof_prb) { // 8.6.2 First paragraph if (data->mcs_idx <= 28) { - ra_mcs_from_idx_ul(data->mcs_idx, ra_nprb_ul(data, nof_prb), &data->mcs); - } else if (data->mcs_idx == 29 && data->cqi_request && ra_nprb_ul(data, nof_prb) <= 4) { + srslte_ra_mcs_from_idx_ul(data->mcs_idx, srslte_ra_nprb_ul(data, nof_prb), &data->mcs); + } else if (data->mcs_idx == 29 && data->cqi_request && srslte_ra_nprb_ul(data, nof_prb) <= 4) { // 8.6.1 and 8.6.2 36.213 second paragraph - data->mcs.mod = LTE_QPSK; + data->mcs.mod = SRSLTE_MOD_QPSK; data->mcs.tbs = 0; } else if (data->mcs_idx >= 29) { // Else leave TBS and use the previously used PUSCH modulation @@ -403,7 +403,7 @@ int dci_format0_unpack(dci_msg_t *msg, ra_pusch_t *data, uint32_t nof_prb) { * TODO: TPC commands */ -int dci_format1_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb) { +int dci_format1_pack(srslte_ra_pdsch_t *data, srslte_dci_msg_t *msg, uint32_t nof_prb) { /* pack bits */ uint8_t *y = msg->data; @@ -413,16 +413,16 @@ int dci_format1_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb) { } /* Resource allocation: type0 or type 1 */ - uint32_t P = ra_type0_P(nof_prb); + uint32_t P = srslte_ra_type0_P(nof_prb); uint32_t alloc_size = (uint32_t) ceilf((float) nof_prb / P); switch (data->alloc_type) { - case alloc_type0: - bit_pack((uint32_t) data->type0_alloc.rbg_bitmask, &y, alloc_size); + case SRSLTE_RA_ALLOC_TYPE0: + srslte_bit_pack((uint32_t) data->type0_alloc.rbg_bitmask, &y, alloc_size); break; - case alloc_type1: - bit_pack((uint32_t) data->type1_alloc.rbg_subset, &y, (int) ceilf(log2f(P))); + case SRSLTE_RA_ALLOC_TYPE1: + srslte_bit_pack((uint32_t) data->type1_alloc.rbg_subset, &y, (int) ceilf(log2f(P))); *y++ = data->type1_alloc.shift ? 1 : 0; - bit_pack((uint32_t) data->type1_alloc.vrb_bitmask, &y, + srslte_bit_pack((uint32_t) data->type1_alloc.vrb_bitmask, &y, alloc_size - (int) ceilf(log2f(P)) - 1); break; default: @@ -432,15 +432,15 @@ int dci_format1_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb) { } /* pack MCS */ - bit_pack(data->mcs_idx, &y, 5); + srslte_bit_pack(data->mcs_idx, &y, 5); /* harq process number */ - bit_pack(data->harq_process, &y, 3); + srslte_bit_pack(data->harq_process, &y, 3); *y++ = data->ndi; // rv version - bit_pack(data->rv_idx, &y, 2); + srslte_bit_pack(data->rv_idx, &y, 2); // TPC not implemented *y++ = 0; @@ -456,13 +456,13 @@ int dci_format1_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb) { return SRSLTE_SUCCESS; } -int dci_format1_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb) { +int dci_format1_unpack(srslte_dci_msg_t *msg, srslte_ra_pdsch_t *data, uint32_t nof_prb) { /* pack bits */ uint8_t *y = msg->data; - /* Make sure it's a Format1 message */ - if (msg->nof_bits != dci_format_sizeof(Format1, nof_prb)) { + /* Make sure it's a SRSLTE_DCI_FORMAT1 message */ + if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1, nof_prb)) { fprintf(stderr, "Invalid message length for format 1\n"); return SRSLTE_ERROR; } @@ -470,20 +470,20 @@ int dci_format1_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb) { if (nof_prb > 10) { data->alloc_type = *y++; } else { - data->alloc_type = alloc_type0; + data->alloc_type = SRSLTE_RA_ALLOC_TYPE0; } /* Resource allocation: type0 or type 1 */ - uint32_t P = ra_type0_P(nof_prb); + uint32_t P = srslte_ra_type0_P(nof_prb); uint32_t alloc_size = (uint32_t) ceilf((float) nof_prb / P); switch (data->alloc_type) { - case alloc_type0: - data->type0_alloc.rbg_bitmask = bit_unpack(&y, alloc_size); + case SRSLTE_RA_ALLOC_TYPE0: + data->type0_alloc.rbg_bitmask = srslte_bit_unpack(&y, alloc_size); break; - case alloc_type1: - data->type1_alloc.rbg_subset = bit_unpack(&y, (int) ceilf(log2f(P))); + case SRSLTE_RA_ALLOC_TYPE1: + data->type1_alloc.rbg_subset = srslte_bit_unpack(&y, (int) ceilf(log2f(P))); data->type1_alloc.shift = *y++ ? true : false; - data->type1_alloc.vrb_bitmask = bit_unpack(&y, + data->type1_alloc.vrb_bitmask = srslte_bit_unpack(&y, alloc_size - (int) ceilf(log2f(P)) - 1); break; default: @@ -492,19 +492,19 @@ int dci_format1_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb) { } /* unpack MCS according to 7.1.7 of 36.213 */ - data->mcs_idx = bit_unpack(&y, 5); - if (ra_mcs_from_idx_dl(data->mcs_idx, ra_nprb_dl(data, nof_prb), &data->mcs)) { + data->mcs_idx = srslte_bit_unpack(&y, 5); + if (srslte_ra_mcs_from_idx_dl(data->mcs_idx, srslte_ra_nprb_dl(data, nof_prb), &data->mcs)) { fprintf(stderr, "Error getting MCS\n"); return SRSLTE_ERROR; } /* harq process number */ - data->harq_process = bit_unpack(&y, 3); + data->harq_process = srslte_bit_unpack(&y, 3); data->ndi = *y++ ? true : false; // rv version - data->rv_idx = bit_unpack(&y, 2); + data->rv_idx = srslte_bit_unpack(&y, 2); // TPC not implemented @@ -515,7 +515,7 @@ int dci_format1_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb) { * * TODO: RA procedure initiated by PDCCH, TPC commands */ -int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb, +int dci_format1As_pack(srslte_ra_pdsch_t *data, srslte_dci_msg_t *msg, uint32_t nof_prb, bool srslte_crc_is_crnti) { /* pack bits */ @@ -523,14 +523,14 @@ int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb, *y++ = 1; // format differentiation - if (data->alloc_type != alloc_type2) { + if (data->alloc_type != SRSLTE_RA_ALLOC_TYPE2) { fprintf(stderr, "Format 1A accepts type2 resource allocation only\n"); return SRSLTE_ERROR; } *y++ = data->type2_alloc.mode; // localized or distributed VRB assignment - if (data->type2_alloc.mode == t2_loc) { + if (data->type2_alloc.mode == SRSLTE_RA_TYPE2_LOC) { if (data->type2_alloc.L_crb > nof_prb) { fprintf(stderr, "L_CRB=%d can not exceed system BW for localized type2\n", data->type2_alloc.L_crb); @@ -541,7 +541,7 @@ int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb, if (srslte_crc_is_crnti && nof_prb > 50) { n_vrb_dl = 16; } else { - n_vrb_dl = ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == t2_ng1); + n_vrb_dl = srslte_ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1); } if (data->type2_alloc.L_crb > n_vrb_dl) { fprintf(stderr, @@ -553,31 +553,31 @@ int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb, /* pack RIV according to 7.1.6.3 of 36.213 */ uint32_t riv; if (data->type2_alloc.L_crb) { - riv = ra_type2_to_riv(data->type2_alloc.L_crb, data->type2_alloc.RB_start, + riv = srslte_ra_type2_to_riv(data->type2_alloc.L_crb, data->type2_alloc.RB_start, nof_prb); } else { riv = data->type2_alloc.riv; } uint32_t nb_gap = 0; - if (srslte_crc_is_crnti && data->type2_alloc.mode == t2_dist && nof_prb >= 50) { + if (srslte_crc_is_crnti && data->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST && nof_prb >= 50) { nb_gap = 1; *y++ = data->type2_alloc.n_gap; } - bit_pack(riv, &y, riv_nbits(nof_prb) - nb_gap); + srslte_bit_pack(riv, &y, riv_nbits(nof_prb) - nb_gap); // in format1A, MCS = TBS according to 7.1.7.2 of 36.213 - bit_pack(data->mcs_idx, &y, 5); + srslte_bit_pack(data->mcs_idx, &y, 5); - bit_pack(data->harq_process, &y, 3); + srslte_bit_pack(data->harq_process, &y, 3); - if (!srslte_crc_is_crnti && nof_prb >= 50 && data->type2_alloc.mode == t2_dist) { + if (!srslte_crc_is_crnti && nof_prb >= 50 && data->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST) { *y++ = data->type2_alloc.n_gap; } else { y++; // bit reserved } // rv version - bit_pack(data->rv_idx, &y, 2); + srslte_bit_pack(data->rv_idx, &y, 2); if (srslte_crc_is_crnti) { // TPC not implemented @@ -601,59 +601,59 @@ int dci_format1As_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb, /* Unpacks DCI format 1A for compact scheduling of PDSCH words according to 36.212 5.3.3.1.3 * */ -int dci_format1As_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb, +int dci_format1As_unpack(srslte_dci_msg_t *msg, srslte_ra_pdsch_t *data, uint32_t nof_prb, bool srslte_crc_is_crnti) { /* pack bits */ uint8_t *y = msg->data; - /* Make sure it's a Format0 message */ - if (msg->nof_bits != dci_format_sizeof(Format1A, nof_prb)) { + /* Make sure it's a SRSLTE_DCI_FORMAT0 message */ + if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1A, nof_prb)) { fprintf(stderr, "Invalid message length for format 1A\n"); return SRSLTE_ERROR; } if (*y++ != 1) { - fprintf(stderr, "Invalid format differentiation field value. This is Format0\n"); + fprintf(stderr, "Invalid format differentiation field value. This is SRSLTE_DCI_FORMAT0\n"); return SRSLTE_ERROR; } - data->alloc_type = alloc_type2; + data->alloc_type = SRSLTE_RA_ALLOC_TYPE2; data->type2_alloc.mode = *y++; // by default, set N_gap to 1 - data->type2_alloc.n_gap = t2_ng1; + data->type2_alloc.n_gap = SRSLTE_RA_TYPE2_NG1; /* unpack RIV according to 7.1.6.3 of 36.213 */ uint32_t nb_gap = 0; - if (srslte_crc_is_crnti && data->type2_alloc.mode == t2_dist && nof_prb >= 50) { + if (srslte_crc_is_crnti && data->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST && nof_prb >= 50) { nb_gap = 1; data->type2_alloc.n_gap = *y++; } uint32_t nof_vrb; - if (data->type2_alloc.mode == t2_loc) { + if (data->type2_alloc.mode == SRSLTE_RA_TYPE2_LOC) { nof_vrb = nof_prb; } else { - nof_vrb = ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == t2_ng1); + nof_vrb = srslte_ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1); } - uint32_t riv = bit_unpack(&y, riv_nbits(nof_prb) - nb_gap); - ra_type2_from_riv(riv, &data->type2_alloc.L_crb, &data->type2_alloc.RB_start, + uint32_t riv = srslte_bit_unpack(&y, riv_nbits(nof_prb) - nb_gap); + srslte_ra_type2_from_riv(riv, &data->type2_alloc.L_crb, &data->type2_alloc.RB_start, nof_prb, nof_vrb); data->type2_alloc.riv = riv; // unpack MCS - data->mcs_idx = bit_unpack(&y, 5); + data->mcs_idx = srslte_bit_unpack(&y, 5); - data->harq_process = bit_unpack(&y, 3); + data->harq_process = srslte_bit_unpack(&y, 3); - if (!srslte_crc_is_crnti && nof_prb >= 50 && data->type2_alloc.mode == t2_dist) { + if (!srslte_crc_is_crnti && nof_prb >= 50 && data->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST) { data->type2_alloc.n_gap = *y++; } else { y++; // bit reserved } // rv version - bit_pack(data->rv_idx, &y, 2); + srslte_bit_pack(data->rv_idx, &y, 2); if (srslte_crc_is_crnti) { // TPC not implemented @@ -666,12 +666,12 @@ int dci_format1As_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb, uint32_t n_prb; if (srslte_crc_is_crnti) { - n_prb = ra_nprb_dl(data, nof_prb); + n_prb = srslte_ra_nprb_dl(data, nof_prb); } else { - n_prb = data->type2_alloc.n_prb1a == nprb1a_2 ? 2 : 3; + n_prb = data->type2_alloc.n_prb1a == SRSLTE_RA_TYPE2_NPRB1A_2 ? 2 : 3; } - data->mcs.tbs = ra_tbs_from_idx(data->mcs_idx, n_prb); - data->mcs.mod = LTE_QPSK; + data->mcs.tbs = srslte_ra_tbs_from_idx(data->mcs_idx, n_prb); + data->mcs.mod = SRSLTE_MOD_QPSK; return SRSLTE_SUCCESS; } @@ -679,12 +679,12 @@ int dci_format1As_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb, /* Format 1C for compact scheduling of PDSCH words * */ -int dci_format1Cs_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb) { +int dci_format1Cs_pack(srslte_ra_pdsch_t *data, srslte_dci_msg_t *msg, uint32_t nof_prb) { /* pack bits */ uint8_t *y = msg->data; - if (data->alloc_type != alloc_type2 || data->type2_alloc.mode != t2_dist) { + if (data->alloc_type != SRSLTE_RA_ALLOC_TYPE2 || data->type2_alloc.mode != SRSLTE_RA_TYPE2_DIST) { fprintf(stderr, "Format 1C accepts distributed type2 resource allocation only\n"); return SRSLTE_ERROR; @@ -693,8 +693,8 @@ int dci_format1Cs_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb) { if (nof_prb >= 50) { *y++ = data->type2_alloc.n_gap; } - uint32_t n_step = ra_type2_n_rb_step(nof_prb); - uint32_t n_vrb_dl = ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == t2_ng1); + uint32_t n_step = srslte_ra_type2_n_rb_step(nof_prb); + uint32_t n_vrb_dl = srslte_ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1); if (data->type2_alloc.L_crb > ((uint32_t) n_vrb_dl / n_step) * n_step) { fprintf(stderr, "L_CRB=%d can not exceed N_vrb_dl=%d for distributed type2\n", @@ -715,173 +715,173 @@ int dci_format1Cs_pack(ra_pdsch_t *data, dci_msg_t *msg, uint32_t nof_prb) { uint32_t riv; if (data->type2_alloc.L_crb) { - riv = ra_type2_to_riv(L_p, RB_p, n_vrb_p); + riv = srslte_ra_type2_to_riv(L_p, RB_p, n_vrb_p); } else { riv = data->type2_alloc.riv; } - bit_pack(riv, &y, riv_nbits((int) n_vrb_dl / n_step)); + srslte_bit_pack(riv, &y, riv_nbits((int) n_vrb_dl / n_step)); // in format1C, MCS = TBS according to 7.1.7.2 of 36.213 - bit_pack(data->mcs_idx, &y, 5); + srslte_bit_pack(data->mcs_idx, &y, 5); msg->nof_bits = (y - msg->data); return SRSLTE_SUCCESS; } -int dci_format1Cs_unpack(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb) { +int dci_format1Cs_unpack(srslte_dci_msg_t *msg, srslte_ra_pdsch_t *data, uint32_t nof_prb) { uint32_t L_p, RB_p; /* pack bits */ uint8_t *y = msg->data; - if (msg->nof_bits != dci_format_sizeof(Format1C, nof_prb)) { + if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1C, nof_prb)) { fprintf(stderr, "Invalid message length for format 1C\n"); return SRSLTE_ERROR; } - data->alloc_type = alloc_type2; - data->type2_alloc.mode = t2_dist; + data->alloc_type = SRSLTE_RA_ALLOC_TYPE2; + data->type2_alloc.mode = SRSLTE_RA_TYPE2_DIST; if (nof_prb >= 50) { data->type2_alloc.n_gap = *y++; } - uint32_t n_step = ra_type2_n_rb_step(nof_prb); - uint32_t n_vrb_dl = ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == t2_ng1); + uint32_t n_step = srslte_ra_type2_n_rb_step(nof_prb); + uint32_t n_vrb_dl = srslte_ra_type2_n_vrb_dl(nof_prb, data->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1); - uint32_t riv = bit_unpack(&y, riv_nbits((int) n_vrb_dl / n_step)); + uint32_t riv = srslte_bit_unpack(&y, riv_nbits((int) n_vrb_dl / n_step)); uint32_t n_vrb_p = (uint32_t) n_vrb_dl / n_step; - ra_type2_from_riv(riv, &L_p, &RB_p, n_vrb_p, n_vrb_p); + srslte_ra_type2_from_riv(riv, &L_p, &RB_p, n_vrb_p, n_vrb_p); data->type2_alloc.L_crb = L_p * n_step; data->type2_alloc.RB_start = RB_p * n_step; data->type2_alloc.riv = riv; - data->mcs_idx = bit_unpack(&y, 5); - data->mcs.tbs = ra_tbs_from_idx_format1c(data->mcs_idx); - data->mcs.mod = LTE_QPSK; + data->mcs_idx = srslte_bit_unpack(&y, 5); + data->mcs.tbs = srslte_srslte_ra_tbs_from_idx_format1c(data->mcs_idx); + data->mcs.mod = SRSLTE_MOD_QPSK; msg->nof_bits = (y - msg->data); return SRSLTE_SUCCESS; } -int dci_msg_pack_pdsch(ra_pdsch_t *data, dci_msg_t *msg, dci_format_t format, +int srslte_dci_msg_pack_pdsch(srslte_ra_pdsch_t *data, srslte_dci_msg_t *msg, srslte_dci_format_t format, uint32_t nof_prb, bool srslte_crc_is_crnti) { switch (format) { - case Format1: + case SRSLTE_DCI_FORMAT1: return dci_format1_pack(data, msg, nof_prb); - case Format1A: + case SRSLTE_DCI_FORMAT1A: return dci_format1As_pack(data, msg, nof_prb, srslte_crc_is_crnti); - case Format1C: + case SRSLTE_DCI_FORMAT1C: return dci_format1Cs_pack(data, msg, nof_prb); default: fprintf(stderr, "Invalid DCI format %s for PDSCH resource allocation\n", - dci_format_string(format)); + srslte_dci_format_string(format)); return SRSLTE_ERROR; } } -int dci_msg_unpack_pdsch(dci_msg_t *msg, ra_pdsch_t *data, uint32_t nof_prb, +int srslte_dci_msg_unpack_pdsch(srslte_dci_msg_t *msg, srslte_ra_pdsch_t *data, uint32_t nof_prb, bool srslte_crc_is_crnti) { - if (msg->nof_bits == dci_format_sizeof(Format1, nof_prb)) { + if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1, nof_prb)) { return dci_format1_unpack(msg, data, nof_prb); - } else if (msg->nof_bits == dci_format_sizeof(Format1A, nof_prb)) { + } else if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1A, nof_prb)) { return dci_format1As_unpack(msg, data, nof_prb, srslte_crc_is_crnti); - } else if (msg->nof_bits == dci_format_sizeof(Format1C, nof_prb)) { + } else if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1C, nof_prb)) { return dci_format1Cs_unpack(msg, data, nof_prb); } else { return SRSLTE_ERROR; } } -int dci_msg_pack_pusch(ra_pusch_t *data, dci_msg_t *msg, uint32_t nof_prb) { +int srslte_dci_msg_pack_pusch(srslte_ra_pusch_t *data, srslte_dci_msg_t *msg, uint32_t nof_prb) { return dci_format0_pack(data, msg, nof_prb); } -int dci_msg_unpack_pusch(dci_msg_t *msg, ra_pusch_t *data, uint32_t nof_prb) { +int srslte_dci_msg_unpack_pusch(srslte_dci_msg_t *msg, srslte_ra_pusch_t *data, uint32_t nof_prb) { return dci_format0_unpack(msg, data, nof_prb); } -dci_format_t dci_format_from_string(char *str) { - if (!strcmp(str, "Format0")) { - return Format0; - } else if (!strcmp(str, "Format1")) { - return Format1; - } else if (!strcmp(str, "Format1A")) { - return Format1A; - } else if (!strcmp(str, "Format1C")) { - return Format1C; +srslte_dci_format_t srslte_dci_format_from_string(char *str) { + if (!strcmp(str, "SRSLTE_DCI_FORMAT0")) { + return SRSLTE_DCI_FORMAT0; + } else if (!strcmp(str, "SRSLTE_DCI_FORMAT1")) { + return SRSLTE_DCI_FORMAT1; + } else if (!strcmp(str, "SRSLTE_DCI_FORMAT1A")) { + return SRSLTE_DCI_FORMAT1A; + } else if (!strcmp(str, "SRSLTE_DCI_FORMAT1C")) { + return SRSLTE_DCI_FORMAT1C; } else { - return FormatError; + return SRSLTE_DCI_FORMAT_ERROR; } } -char* dci_format_string(dci_format_t format) { +char* srslte_dci_format_string(srslte_dci_format_t format) { switch (format) { - case Format0: - return "Format0"; - case Format1: - return "Format1"; - case Format1A: - return "Format1A"; - case Format1C: - return "Format1C"; + case SRSLTE_DCI_FORMAT0: + return "SRSLTE_DCI_FORMAT0"; + case SRSLTE_DCI_FORMAT1: + return "SRSLTE_DCI_FORMAT1"; + case SRSLTE_DCI_FORMAT1A: + return "SRSLTE_DCI_FORMAT1A"; + case SRSLTE_DCI_FORMAT1C: + return "SRSLTE_DCI_FORMAT1C"; default: return "N/A"; // fatal error } } -void dci_msg_type_fprint(FILE *f, dci_msg_type_t type) { +void srslte_dci_msg_type_fprint(FILE *f, srslte_dci_msg_type_t type) { switch (type.type) { - case PUSCH_SCHED: - fprintf(f, "%s PUSCH Scheduling\n", dci_format_string(type.format)); + case SRSLTE_DCI_MSG_TYPE_PUSCH_SCHED: + fprintf(f, "%s PUSCH Scheduling\n", srslte_dci_format_string(type.format)); break; - case PDSCH_SCHED: - fprintf(f, "%s PDSCH Scheduling\n", dci_format_string(type.format)); + case SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED: + fprintf(f, "%s PDSCH Scheduling\n", srslte_dci_format_string(type.format)); break; - case RA_PROC_PDCCH: + case SRSLTE_DCI_MSG_TYPE_RA_PROC_PDCCH: fprintf(f, "%s Random access initiated by PDCCH\n", - dci_format_string(type.format)); + srslte_dci_format_string(type.format)); break; - case MCCH_CHANGE: - fprintf(f, "%s MCCH change notification\n", dci_format_string(type.format)); + case SRSLTE_DCI_MSG_TYPE_MCCH_CHANGE: + fprintf(f, "%s MCCH change notification\n", srslte_dci_format_string(type.format)); break; - case TPC_COMMAND: - fprintf(f, "%s TPC command\n", dci_format_string(type.format)); + case SRSLTE_DCI_MSG_TYPE_TPC_COMMAND: + fprintf(f, "%s TPC command\n", srslte_dci_format_string(type.format)); break; } } -int dci_msg_get_type(dci_msg_t *msg, dci_msg_type_t *type, uint32_t nof_prb, +int srslte_dci_msg_get_type(srslte_dci_msg_t *msg, srslte_dci_msg_type_t *type, uint32_t nof_prb, uint16_t msg_rnti) { DEBUG("Get message type: nof_bits=%d, msg_rnti=0x%x\n", msg->nof_bits, msg_rnti); - if (msg->nof_bits == dci_format_sizeof(Format0, nof_prb) + if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT0, nof_prb) && !msg->data[0]) { - type->type = PUSCH_SCHED; - type->format = Format0; + type->type = SRSLTE_DCI_MSG_TYPE_PUSCH_SCHED; + type->format = SRSLTE_DCI_FORMAT0; return SRSLTE_SUCCESS; - } else if (msg->nof_bits == dci_format_sizeof(Format1, nof_prb)) { - type->type = PDSCH_SCHED; // only these 2 types supported - type->format = Format1; + } else if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1, nof_prb)) { + type->type = SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED; // only these 2 types supported + type->format = SRSLTE_DCI_FORMAT1; return SRSLTE_SUCCESS; - } else if (msg->nof_bits == dci_format_sizeof(Format1A, nof_prb)) { + } else if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1A, nof_prb)) { /* The RNTI is not the only condition. Also some fields in the packet. * if (msg_rnti >= SRSLTE_CRNTI_START && msg_rnti <= SRSLTE_CRNTI_END) { - type->type = RA_PROC_PDCCH; - type->format = Format1A; + type->type = SRSLTE_DCI_MSG_TYPE_RA_PROC_PDCCH; + type->format = SRSLTE_DCI_FORMAT1A; } else { */ - type->type = PDSCH_SCHED; // only these 2 types supported - type->format = Format1A; + type->type = SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED; // only these 2 types supported + type->format = SRSLTE_DCI_FORMAT1A; //} return SRSLTE_SUCCESS; - } else if (msg->nof_bits == dci_format_sizeof(Format1C, nof_prb)) { + } else if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1C, nof_prb)) { if (msg_rnti == SRSLTE_MRNTI) { - type->type = MCCH_CHANGE; - type->format = Format1C; + type->type = SRSLTE_DCI_MSG_TYPE_MCCH_CHANGE; + type->format = SRSLTE_DCI_FORMAT1C; } else { - type->type = PDSCH_SCHED; // only these 2 types supported - type->format = Format1C; + type->type = SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED; // only these 2 types supported + type->format = SRSLTE_DCI_FORMAT1C; } return SRSLTE_SUCCESS; } diff --git a/srslte/lib/phch/src/harq.c b/srslte/lib/phch/src/harq.c index 0a5e98d67..9322d0c80 100644 --- a/srslte/lib/phch/src/harq.c +++ b/srslte/lib/phch/src/harq.c @@ -45,12 +45,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) { +int srslte_harq_codeblock_segmentation(srslte_harq_cbsegm_t *s, uint32_t tbs) { uint32_t Bp, B, idx1; int ret; if (tbs == 0) { - bzero(s, sizeof(struct cb_segm)); + bzero(s, sizeof(srslte_harq_cbsegm_t)); ret = SRSLTE_SUCCESS; } else { B = tbs + 24; @@ -93,26 +93,26 @@ int codeblock_segmentation(struct cb_segm *s, uint32_t tbs) { return ret; } -int harq_init(harq_t *q, srslte_cell_t cell) { +int srslte_harq_init(srslte_harq_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL) { uint32_t i; - bzero(q, sizeof(harq_t)); + bzero(q, sizeof(srslte_harq_t)); memcpy(&q->cell, &cell, sizeof(srslte_cell_t)); - ret = ra_tbs_from_idx(26, cell.nof_prb); + ret = srslte_ra_tbs_from_idx(26, cell.nof_prb); if (ret != SRSLTE_ERROR) { q->max_cb = (uint32_t) ret / (MAX_LONG_CB - 24) + 1; - q->pdsch_w_buff_f = vec_malloc(sizeof(float*) * q->max_cb); + q->pdsch_w_buff_f = srslte_vec_malloc(sizeof(float*) * q->max_cb); if (!q->pdsch_w_buff_f) { perror("malloc"); return SRSLTE_ERROR; } - q->pdsch_w_buff_c = vec_malloc(sizeof(uint8_t*) * q->max_cb); + q->pdsch_w_buff_c = srslte_vec_malloc(sizeof(uint8_t*) * q->max_cb); if (!q->pdsch_w_buff_c) { perror("malloc"); return SRSLTE_ERROR; @@ -121,12 +121,12 @@ int harq_init(harq_t *q, srslte_cell_t cell) { // FIXME: Use HARQ buffer limitation based on UE category q->w_buff_size = cell.nof_prb * MAX_PDSCH_RE(cell.cp) * 6 * 10; for (i=0;imax_cb;i++) { - q->pdsch_w_buff_f[i] = vec_malloc(sizeof(float) * q->w_buff_size); + q->pdsch_w_buff_f[i] = srslte_vec_malloc(sizeof(float) * q->w_buff_size); if (!q->pdsch_w_buff_f[i]) { perror("malloc"); return SRSLTE_ERROR; } - q->pdsch_w_buff_c[i] = vec_malloc(sizeof(uint8_t) * q->w_buff_size); + q->pdsch_w_buff_c[i] = srslte_vec_malloc(sizeof(uint8_t) * q->w_buff_size); if (!q->pdsch_w_buff_c[i]) { perror("malloc"); return SRSLTE_ERROR; @@ -139,7 +139,7 @@ int harq_init(harq_t *q, srslte_cell_t cell) { return ret; } -void harq_free(harq_t *q) { +void srslte_harq_free(srslte_harq_t *q) { if (q) { uint32_t i; if (q->pdsch_w_buff_f) { @@ -158,11 +158,11 @@ void harq_free(harq_t *q) { } free(q->pdsch_w_buff_c); } - bzero(q, sizeof(harq_t)); + bzero(q, sizeof(srslte_harq_t)); } } -void harq_reset(harq_t *q) { +void srslte_harq_reset(srslte_harq_t *q) { int i; if (q->pdsch_w_buff_f) { for (i=0;imax_cb;i++) { @@ -178,14 +178,14 @@ void harq_reset(harq_t *q) { } } } - bzero(&q->mcs, sizeof(ra_mcs_t)); - bzero(&q->cb_segm, sizeof(struct cb_segm)); - bzero(&q->dl_alloc, sizeof(ra_dl_alloc_t)); + bzero(&q->mcs, sizeof(srslte_ra_mcs_t)); + bzero(&q->cb_segm, sizeof(srslte_harq_cbsegm_t)); + bzero(&q->dl_alloc, sizeof(srslte_srslte_ra_dl_alloc_t)); } -static int harq_setup_common(harq_t *q, ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx) { +static int harq_setup_common(srslte_harq_t *q, srslte_ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx) { if (mcs.tbs != q->mcs.tbs) { - codeblock_segmentation(&q->cb_segm, mcs.tbs); + srslte_harq_codeblock_segmentation(&q->cb_segm, mcs.tbs); if (q->cb_segm.C > q->max_cb) { fprintf(stderr, "Codeblock segmentation returned more CBs (%d) than allocated (%d)\n", q->cb_segm.C, q->max_cb); @@ -199,7 +199,7 @@ static int harq_setup_common(harq_t *q, ra_mcs_t mcs, uint32_t rv, uint32_t sf_i return SRSLTE_SUCCESS; } -int harq_setup_dl(harq_t *q, ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx, ra_dl_alloc_t *dl_alloc) { +int srslte_harq_setup_dl(srslte_harq_t *q, srslte_ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx, srslte_srslte_ra_dl_alloc_t *dl_alloc) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && @@ -210,7 +210,7 @@ int harq_setup_dl(harq_t *q, ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx, ra_dl_a if (ret) { return ret; } - memcpy(&q->dl_alloc, dl_alloc, sizeof(ra_dl_alloc_t)); + memcpy(&q->dl_alloc, dl_alloc, sizeof(srslte_srslte_ra_dl_alloc_t)); // Number of symbols, RE and bits per subframe for DL q->nof_re = q->dl_alloc.re_sf[q->sf_idx]; @@ -223,7 +223,7 @@ int harq_setup_dl(harq_t *q, ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx, ra_dl_a return ret; } -int harq_setup_ul(harq_t *q, ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx, ra_ul_alloc_t *ul_alloc) { +int srslte_harq_setup_ul(srslte_harq_t *q, srslte_ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx, srslte_srslte_ra_ul_alloc_t *ul_alloc) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && @@ -234,7 +234,7 @@ int harq_setup_ul(harq_t *q, ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx, ra_ul_a if (ret) { return ret; } - memcpy(&q->ul_alloc, ul_alloc, sizeof(ra_ul_alloc_t)); + memcpy(&q->ul_alloc, ul_alloc, sizeof(srslte_srslte_ra_ul_alloc_t)); // Number of symbols, RE and bits per subframe for UL q->nof_symb = 2*(SRSLTE_CP_NSYMB(q->cell.cp)-1); diff --git a/srslte/lib/phch/src/pbch.c b/srslte/lib/phch/src/pbch.c index 6b57eeef8..97f22b86f 100644 --- a/srslte/lib/phch/src/pbch.c +++ b/srslte/lib/phch/src/pbch.c @@ -47,13 +47,13 @@ const uint8_t srslte_crc_mask[4][16] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 } }; -bool pbch_exists(int nframe, int nslot) { +bool srslte_pbch_exists(int nframe, int nslot) { return (!(nframe % 5) && nslot == 1); } cf_t *offset_original; -int pbch_cp(cf_t *input, cf_t *output, srslte_cell_t cell, bool put) { +int srslte_pbch_cp(cf_t *input, cf_t *output, srslte_cell_t cell, bool put) { int i; cf_t *ptr; @@ -109,8 +109,8 @@ int pbch_cp(cf_t *input, cf_t *output, srslte_cell_t cell, bool put) { * * 36.211 10.3 section 6.6.4 */ -int pbch_put(cf_t *pbch, cf_t *slot1_data, srslte_cell_t cell) { - return pbch_cp(pbch, slot1_data, cell, true); +int srslte_pbch_put(cf_t *pbch, cf_t *slot1_data, srslte_cell_t cell) { + return srslte_pbch_cp(pbch, slot1_data, cell, true); } /** @@ -120,15 +120,15 @@ int pbch_put(cf_t *pbch, cf_t *slot1_data, srslte_cell_t cell) { * * 36.211 10.3 section 6.6.4 */ -int pbch_get(cf_t *slot1_data, cf_t *pbch, srslte_cell_t cell) { - return pbch_cp(slot1_data, pbch, cell, false); +int srslte_pbch_get(cf_t *slot1_data, cf_t *pbch, srslte_cell_t cell) { + return srslte_pbch_cp(slot1_data, pbch, cell, false); } /** Initializes the PBCH transmitter and receiver. * At the receiver, the field nof_ports in the cell structure indicates the * maximum number of BS transmitter ports to look for. */ -int pbch_init(pbch_t *q, srslte_cell_t cell) { +int srslte_pbch_init(srslte_pbch_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && @@ -136,22 +136,22 @@ int pbch_init(pbch_t *q, srslte_cell_t cell) { { ret = SRSLTE_ERROR; - bzero(q, sizeof(pbch_t)); + bzero(q, sizeof(srslte_pbch_t)); q->cell = cell; 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, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (srslte_precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); } - if (modem_table_lte(&q->mod, LTE_QPSK, true)) { + if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK, true)) { goto clean; } - demod_soft_init(&q->demod, q->nof_symbols); - demod_soft_table_set(&q->demod, &q->mod); - demod_soft_alg_set(&q->demod, APPROX); + srslte_demod_soft_init(&q->demod, q->nof_symbols); + srslte_demod_soft_table_set(&q->demod, &q->mod); + srslte_demod_soft_alg_set(&q->demod, SRSLTE_DEMOD_SOFT_ALG_APPROX); - if (srslte_sequence_pbch(&q->seq_pbch, q->cell.cp, q->cell.id)) { + if (srslte_sequence_pbch(&q->seq, q->cell.cp, q->cell.id)) { goto clean; } @@ -167,78 +167,78 @@ int pbch_init(pbch_t *q, srslte_cell_t cell) { q->encoder.tail_biting = true; memcpy(q->encoder.poly, poly, 3 * sizeof(int)); - q->pbch_d = vec_malloc(sizeof(cf_t) * q->nof_symbols); - if (!q->pbch_d) { + q->d = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols); + if (!q->d) { goto clean; } int i; for (i = 0; i < q->cell.nof_ports; i++) { - q->ce[i] = vec_malloc(sizeof(cf_t) * q->nof_symbols); + q->ce[i] = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols); if (!q->ce[i]) { goto clean; } - q->pbch_x[i] = vec_malloc(sizeof(cf_t) * q->nof_symbols); - if (!q->pbch_x[i]) { + q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols); + if (!q->x[i]) { goto clean; } - q->pbch_symbols[i] = vec_malloc(sizeof(cf_t) * q->nof_symbols); - if (!q->pbch_symbols[i]) { + q->symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols); + if (!q->symbols[i]) { goto clean; } } - q->pbch_llr = vec_malloc(sizeof(float) * q->nof_symbols * 4 * 2); - if (!q->pbch_llr) { + q->llr = srslte_vec_malloc(sizeof(float) * q->nof_symbols * 4 * 2); + if (!q->llr) { goto clean; } - q->temp = vec_malloc(sizeof(float) * q->nof_symbols * 4 * 2); + q->temp = srslte_vec_malloc(sizeof(float) * q->nof_symbols * 4 * 2); if (!q->temp) { goto clean; } - q->pbch_rm_b = vec_malloc(sizeof(float) * q->nof_symbols * 4 * 2); - if (!q->pbch_rm_b) { + q->rm_b = srslte_vec_malloc(sizeof(float) * q->nof_symbols * 4 * 2); + if (!q->rm_b) { goto clean; } ret = SRSLTE_SUCCESS; } clean: if (ret == SRSLTE_ERROR) { - pbch_free(q); + srslte_pbch_free(q); } return ret; } -void pbch_free(pbch_t *q) { - if (q->pbch_d) { - free(q->pbch_d); +void srslte_pbch_free(srslte_pbch_t *q) { + if (q->d) { + free(q->d); } int i; for (i = 0; i < q->cell.nof_ports; i++) { if (q->ce[i]) { free(q->ce[i]); } - if (q->pbch_x[i]) { - free(q->pbch_x[i]); + if (q->x[i]) { + free(q->x[i]); } - if (q->pbch_symbols[i]) { - free(q->pbch_symbols[i]); + if (q->symbols[i]) { + free(q->symbols[i]); } } - if (q->pbch_llr) { - free(q->pbch_llr); + if (q->llr) { + free(q->llr); } if (q->temp) { free(q->temp); } - if (q->pbch_rm_b) { - free(q->pbch_rm_b); + if (q->rm_b) { + free(q->rm_b); } - precoding_free(&q->precoding); - srslte_sequence_free(&q->seq_pbch); - modem_table_free(&q->mod); + srslte_precoding_free(&q->precoding); + srslte_sequence_free(&q->seq); + srslte_modem_table_free(&q->mod); srslte_viterbi_free(&q->decoder); - demod_soft_free(&q->demod); + srslte_demod_soft_free(&q->demod); - bzero(q, sizeof(pbch_t)); + bzero(q, sizeof(srslte_pbch_t)); } @@ -246,10 +246,10 @@ void pbch_free(pbch_t *q) { /** Unpacks MIB from PBCH message. * msg buffer must be 24 byte length at least */ -void pbch_mib_unpack(uint8_t *msg, srslte_cell_t *cell, uint32_t *sfn) { +void srslte_pbch_mib_unpack(uint8_t *msg, srslte_cell_t *cell, uint32_t *sfn) { int phich_res; - cell->bw_idx = bit_unpack(&msg, 3); + cell->bw_idx = srslte_bit_unpack(&msg, 3); switch (cell->bw_idx) { case 0: cell->nof_prb = 6; @@ -268,7 +268,7 @@ void pbch_mib_unpack(uint8_t *msg, srslte_cell_t *cell, uint32_t *sfn) { } msg++; - phich_res = bit_unpack(&msg, 2); + phich_res = srslte_bit_unpack(&msg, 2); switch (phich_res) { case 0: cell->phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_6; @@ -284,14 +284,14 @@ void pbch_mib_unpack(uint8_t *msg, srslte_cell_t *cell, uint32_t *sfn) { break; } if (sfn) { - *sfn = bit_unpack(&msg, 8) << 2; + *sfn = srslte_bit_unpack(&msg, 8) << 2; } } /** Unpacks MIB from PBCH message. * msg buffer must be 24 byte length at least */ -void pbch_mib_pack(srslte_cell_t *cell, uint32_t sfn, uint8_t *msg) { +void srslte_pbch_mib_pack(srslte_cell_t *cell, uint32_t sfn, uint8_t *msg) { int bw, phich_res = 0; bzero(msg, 24); @@ -303,7 +303,7 @@ void pbch_mib_pack(srslte_cell_t *cell, uint32_t sfn, uint8_t *msg) { } else { bw = 1 + cell->nof_prb / 25; } - bit_pack(bw, &msg, 3); + srslte_bit_pack(bw, &msg, 3); *msg = cell->phich_length == SRSLTE_PHICH_EXT; msg++; @@ -322,11 +322,11 @@ void pbch_mib_pack(srslte_cell_t *cell, uint32_t sfn, uint8_t *msg) { phich_res = 3; break; } - bit_pack(phich_res, &msg, 2); - bit_pack(sfn >> 2, &msg, 8); + srslte_bit_pack(phich_res, &msg, 2); + srslte_bit_pack(sfn >> 2, &msg, 8); } -void pbch_mib_fprint(FILE *stream, srslte_cell_t *cell, uint32_t sfn, uint32_t cell_id) { +void srslte_pbch_mib_fprint(FILE *stream, srslte_cell_t *cell, uint32_t sfn, uint32_t cell_id) { printf(" - Cell ID: %d\n", cell_id); printf(" - Nof ports: %d\n", cell->nof_ports); printf(" - PRB: %d\n", cell->nof_prb); @@ -352,7 +352,7 @@ void pbch_mib_fprint(FILE *stream, srslte_cell_t *cell, uint32_t sfn, uint32_t c } -void pbch_decode_reset(pbch_t *q) { +void srslte_pbch_decode_reset(srslte_pbch_t *q) { q->frame_idx = 0; } @@ -370,7 +370,7 @@ void srslte_crc_set_mask(uint8_t *data, int nof_ports) { * * Returns 0 if the data is correct, -1 otherwise */ -uint32_t pbch_srslte_crc_check(pbch_t *q, uint8_t *bits, uint32_t nof_ports) { +uint32_t srslte_pbch_crc_check(srslte_pbch_t *q, uint8_t *bits, uint32_t nof_ports) { uint8_t data[BCH_PAYLOADCRC_LEN]; memcpy(data, bits, BCH_PAYLOADCRC_LEN * sizeof(uint8_t)); srslte_crc_set_mask(data, nof_ports); @@ -390,17 +390,17 @@ uint32_t pbch_srslte_crc_check(pbch_t *q, uint8_t *bits, uint32_t nof_ports) { } } -int pbch_decode_frame(pbch_t *q, uint32_t src, uint32_t dst, uint32_t n, +int decode_frame(srslte_pbch_t *q, uint32_t src, uint32_t dst, uint32_t n, uint32_t nof_bits, uint32_t nof_ports) { int j; DEBUG("Trying to decode PBCH %d bits, %d ports, src: %d, dst: %d, n=%d\n", nof_bits, nof_ports, src, dst, n); - memcpy(&q->temp[dst * nof_bits], &q->pbch_llr[src * nof_bits], + memcpy(&q->temp[dst * nof_bits], &q->llr[src * nof_bits], n * nof_bits * sizeof(float)); /* descramble */ - scrambling_f_offset(&q->seq_pbch, &q->temp[dst * nof_bits], dst * nof_bits, + srslte_scrambling_f_offset(&q->seq, &q->temp[dst * nof_bits], dst * nof_bits, n * nof_bits); for (j = 0; j < dst * nof_bits; j++) { @@ -411,12 +411,12 @@ int pbch_decode_frame(pbch_t *q, uint32_t src, uint32_t dst, uint32_t n, } /* unrate matching */ - srslte_rm_conv_rx(q->temp, 4 * nof_bits, q->pbch_rm_f, BCH_ENCODED_LEN); + srslte_rm_conv_rx(q->temp, 4 * nof_bits, q->rm_f, BCH_ENCODED_LEN); /* decode */ - srslte_viterbi_decode_f(&q->decoder, q->pbch_rm_f, q->data, BCH_PAYLOADCRC_LEN); + srslte_viterbi_decode_f(&q->decoder, q->rm_f, q->data, BCH_PAYLOADCRC_LEN); - if (!pbch_srslte_crc_check(q, q->data, nof_ports)) { + if (!srslte_pbch_crc_check(q, q->data, nof_ports)) { return 1; } else { return SRSLTE_SUCCESS; @@ -431,7 +431,7 @@ int pbch_decode_frame(pbch_t *q, uint32_t src, uint32_t dst, uint32_t n, * * Returns 1 if successfully decoded MIB, 0 if not and -1 on error */ -int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS], float noise_estimate, +int srslte_pbch_decode(srslte_pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS], float noise_estimate, uint8_t bch_payload[BCH_PAYLOAD_LEN], uint32_t *nof_tx_ports, uint32_t *sfn_offset) { uint32_t src, dst, nb; @@ -456,19 +456,19 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS] /* number of layers equals number of ports */ for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - x[i] = q->pbch_x[i]; + x[i] = q->x[i]; } 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)) { + if (q->nof_symbols != srslte_pbch_get(slot1_symbols, q->symbols[0], q->cell)) { fprintf(stderr, "There was an error getting the PBCH symbols\n"); return SRSLTE_ERROR; } /* extract channel estimates */ for (i = 0; i < q->cell.nof_ports; i++) { - if (q->nof_symbols != pbch_get(ce_slot1[i], q->ce[i], q->cell)) { + if (q->nof_symbols != srslte_pbch_get(ce_slot1[i], q->ce[i], q->cell)) { fprintf(stderr, "There was an error getting the PBCH symbols\n"); return SRSLTE_ERROR; } @@ -485,18 +485,18 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS] /* in conctrol channels, only diversity is supported */ if (nant == 1) { /* no need for layer demapping */ - predecoding_single(&q->precoding, q->pbch_symbols[0], q->ce[0], q->pbch_d, + srslte_predecoding_single(&q->precoding, q->symbols[0], q->ce[0], q->d, q->nof_symbols, noise_estimate); } else { - predecoding_diversity(&q->precoding, q->pbch_symbols[0], q->ce, x, nant, + srslte_predecoding_diversity(&q->precoding, q->symbols[0], q->ce, x, nant, q->nof_symbols, noise_estimate); - srslte_layerdemap_diversity(x, q->pbch_d, nant, q->nof_symbols / nant); + srslte_layerdemap_diversity(x, q->d, nant, q->nof_symbols / nant); } /* demodulate symbols */ - demod_soft_sigma_set(&q->demod, 1.0); - demod_soft_demodulate(&q->demod, q->pbch_d, - &q->pbch_llr[nof_bits * (q->frame_idx - 1)], q->nof_symbols); + srslte_demod_soft_sigma_set(&q->demod, 1.0); + srslte_demod_soft_demodulate(&q->demod, q->d, + &q->llr[nof_bits * (q->frame_idx - 1)], q->nof_symbols); /* We don't know where the 40 ms begin, so we try all combinations. E.g. if we received * 4 frames, try 1,2,3,4 individually, 12, 23, 34 in pairs, 123, 234 and finally 1234. @@ -508,7 +508,7 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS] for (nb = 0; nb < q->frame_idx && !ret; nb++) { for (dst = 0; (dst < 4 - nb) && !ret; dst++) { for (src = 0; src < q->frame_idx - nb && !ret; src++) { - ret = pbch_decode_frame(q, src, dst, nb + 1, nof_bits, nant); + ret = decode_frame(q, src, dst, nb + 1, nof_bits, nant); if (ret == 1) { if (sfn_offset) { *sfn_offset = dst - src; @@ -528,7 +528,7 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS] /* If not found, make room for the next packet of radio frame symbols */ if (q->frame_idx == 4) { - memmove(q->pbch_llr, &q->pbch_llr[nof_bits], nof_bits * 3 * sizeof(float)); + memmove(q->llr, &q->llr[nof_bits], nof_bits * 3 * sizeof(float)); q->frame_idx = 3; } } @@ -537,7 +537,7 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS] /** Converts the MIB message to symbols mapped to SLOT #1 ready for transmission */ -int pbch_encode(pbch_t *q, uint8_t bch_payload[BCH_PAYLOAD_LEN], cf_t *slot1_symbols[SRSLTE_MAX_PORTS]) { +int srslte_pbch_encode(srslte_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[SRSLTE_MAX_LAYERS]; @@ -555,7 +555,7 @@ int pbch_encode(pbch_t *q, uint8_t bch_payload[BCH_PAYLOAD_LEN], cf_t *slot1_sym /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { - x[i] = q->pbch_x[i]; + x[i] = q->x[i]; } memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); @@ -568,27 +568,27 @@ int pbch_encode(pbch_t *q, uint8_t bch_payload[BCH_PAYLOAD_LEN], cf_t *slot1_sym srslte_convcoder_encode(&q->encoder, q->data, q->data_enc, BCH_PAYLOADCRC_LEN); - srslte_rm_conv_tx(q->data_enc, BCH_ENCODED_LEN, q->pbch_rm_b, 4 * nof_bits); + srslte_rm_conv_tx(q->data_enc, BCH_ENCODED_LEN, q->rm_b, 4 * nof_bits); } - scrambling_b_offset(&q->seq_pbch, &q->pbch_rm_b[q->frame_idx * nof_bits], + srslte_scrambling_b_offset(&q->seq, &q->rm_b[q->frame_idx * nof_bits], q->frame_idx * nof_bits, nof_bits); - mod_modulate(&q->mod, &q->pbch_rm_b[q->frame_idx * nof_bits], q->pbch_d, + srslte_mod_modulate(&q->mod, &q->rm_b[q->frame_idx * nof_bits], q->d, nof_bits); /* layer mapping & precoding */ if (q->cell.nof_ports > 1) { - srslte_layermap_diversity(q->pbch_d, x, q->cell.nof_ports, q->nof_symbols); - precoding_diversity(&q->precoding, x, q->pbch_symbols, q->cell.nof_ports, + srslte_layermap_diversity(q->d, x, q->cell.nof_ports, q->nof_symbols); + srslte_precoding_diversity(&q->precoding, x, q->symbols, q->cell.nof_ports, q->nof_symbols / q->cell.nof_ports); } else { - memcpy(q->pbch_symbols[0], q->pbch_d, q->nof_symbols * sizeof(cf_t)); + memcpy(q->symbols[0], q->d, q->nof_symbols * sizeof(cf_t)); } /* mapping to resource elements */ for (i = 0; i < q->cell.nof_ports; i++) { - pbch_put(q->pbch_symbols[i], slot1_symbols[i], q->cell); + srslte_pbch_put(q->symbols[i], slot1_symbols[i], q->cell); } q->frame_idx++; if (q->frame_idx == 4) { diff --git a/srslte/lib/phch/src/pcfich.c b/srslte/lib/phch/src/pcfich.c index 1ebc4b94c..dbcd081ad 100644 --- a/srslte/lib/phch/src/pcfich.c +++ b/srslte/lib/phch/src/pcfich.c @@ -54,14 +54,14 @@ static uint8_t cfi_table[4][PCFICH_CFI_LEN] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } // reserved }; -bool pcfich_exists(int nframe, int nslot) { +bool srslte_pcfich_exists(int nframe, int nslot) { return true; } /** Initializes the pcfich channel receiver. * On error, returns -1 and frees the structrure */ -int pcfich_init(pcfich_t *q, regs_t *regs, srslte_cell_t cell) { +int srslte_pcfich_init(srslte_pcfich_t *q, srslte_regs_t *regs, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && @@ -70,25 +70,25 @@ int pcfich_init(pcfich_t *q, regs_t *regs, srslte_cell_t cell) { { ret = SRSLTE_ERROR; - bzero(q, sizeof(pcfich_t)); + bzero(q, sizeof(srslte_pcfich_t)); q->cell = cell; q->regs = regs; q->nof_symbols = PCFICH_RE; - if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (srslte_precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); } - if (modem_table_lte(&q->mod, LTE_QPSK, true)) { + if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK, true)) { goto clean; } - demod_soft_init(&q->demod, q->nof_symbols); - demod_soft_table_set(&q->demod, &q->mod); - demod_soft_alg_set(&q->demod, APPROX); + srslte_demod_soft_init(&q->demod, q->nof_symbols); + srslte_demod_soft_table_set(&q->demod, &q->mod); + srslte_demod_soft_alg_set(&q->demod, SRSLTE_DEMOD_SOFT_ALG_APPROX); for (int nsf = 0; nsf < SRSLTE_NSUBFRAMES_X_FRAME; nsf++) { - if (srslte_sequence_pcfich(&q->seq_pcfich[nsf], 2 * nsf, q->cell.id)) { + if (srslte_sequence_pcfich(&q->seq[nsf], 2 * nsf, q->cell.id)) { goto clean; } } @@ -105,32 +105,32 @@ int pcfich_init(pcfich_t *q, regs_t *regs, srslte_cell_t cell) { clean: if (ret == SRSLTE_ERROR) { - pcfich_free(q); + srslte_pcfich_free(q); } return ret; } -void pcfich_free(pcfich_t *q) { +void srslte_pcfich_free(srslte_pcfich_t *q) { for (int ns = 0; ns < SRSLTE_NSUBFRAMES_X_FRAME; ns++) { - srslte_sequence_free(&q->seq_pcfich[ns]); + srslte_sequence_free(&q->seq[ns]); } - modem_table_free(&q->mod); - precoding_free(&q->precoding); - demod_soft_free(&q->demod); + srslte_modem_table_free(&q->mod); + srslte_precoding_free(&q->precoding); + srslte_demod_soft_free(&q->demod); - bzero(q, sizeof(pcfich_t)); + bzero(q, sizeof(srslte_pcfich_t)); } /** Finds the CFI with minimum distance with the vector of received 32 bits. * Saves the CFI value in the cfi pointer and returns the distance. */ -float pcfich_cfi_decode(pcfich_t *q, uint32_t *cfi) { +float srslte_pcfich_cfi_decode(srslte_pcfich_t *q, uint32_t *cfi) { int i; int index = 0; float max_corr = 0; for (i = 0; i < 3; i++) { - float corr = fabsf(vec_dot_prod_fff(q->cfi_table_float[i], q->data_f, PCFICH_CFI_LEN)); + float corr = fabsf(srslte_vec_dot_prod_fff(q->cfi_table_float[i], q->data_f, PCFICH_CFI_LEN)); if (corr > max_corr) { max_corr = corr; index = i; @@ -145,7 +145,7 @@ float pcfich_cfi_decode(pcfich_t *q, uint32_t *cfi) { /** Encodes the CFI producing a vector of 32 bits. * 36.211 10.3 section 5.3.4 */ -int pcfich_cfi_encode(int cfi, uint8_t bits[PCFICH_CFI_LEN]) { +int srslte_pcfich_cfi_encode(int cfi, uint8_t bits[PCFICH_CFI_LEN]) { if (cfi < 1 || cfi > 3) { return SRSLTE_ERROR_INVALID_INPUTS; } else{ @@ -158,7 +158,7 @@ int pcfich_cfi_encode(int cfi, uint8_t bits[PCFICH_CFI_LEN]) { * * Returns 1 if successfully decoded the CFI, 0 if not and -1 on error */ -int pcfich_decode(pcfich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, +int srslte_pcfich_decode(srslte_pcfich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, uint32_t nsubframe, uint32_t *cfi, float *corr_result) { @@ -174,7 +174,7 @@ int pcfich_decode(pcfich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], f /* number of layers equals number of ports */ for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - x[i] = q->pcfich_x[i]; + x[i] = q->x[i]; } for (i = 0; i < SRSLTE_MAX_PORTS; i++) { ce_precoding[i] = q->ce[i]; @@ -182,14 +182,14 @@ int pcfich_decode(pcfich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], f /* extract symbols */ if (q->nof_symbols - != regs_pcfich_get(q->regs, slot_symbols, q->pcfich_symbols[0])) { + != srslte_regs_pcfich_get(q->regs, slot_symbols, q->symbols[0])) { fprintf(stderr, "There was an error getting the PCFICH symbols\n"); return SRSLTE_ERROR; } /* extract channel estimates */ for (i = 0; i < q->cell.nof_ports; i++) { - if (q->nof_symbols != regs_pcfich_get(q->regs, ce[i], q->ce[i])) { + if (q->nof_symbols != srslte_regs_pcfich_get(q->regs, ce[i], q->ce[i])) { fprintf(stderr, "There was an error getting the PCFICH symbols\n"); return SRSLTE_ERROR; } @@ -198,24 +198,24 @@ int pcfich_decode(pcfich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], f /* in control channels, only diversity is supported */ if (q->cell.nof_ports == 1) { /* no need for layer demapping */ - predecoding_single(&q->precoding, q->pcfich_symbols[0], q->ce[0], q->pcfich_d, + srslte_predecoding_single(&q->precoding, q->symbols[0], q->ce[0], q->d, q->nof_symbols, noise_estimate); } else { - predecoding_diversity(&q->precoding, q->pcfich_symbols[0], ce_precoding, x, + srslte_predecoding_diversity(&q->precoding, q->symbols[0], ce_precoding, x, q->cell.nof_ports, q->nof_symbols, noise_estimate); - srslte_layerdemap_diversity(x, q->pcfich_d, q->cell.nof_ports, + srslte_layerdemap_diversity(x, q->d, q->cell.nof_ports, q->nof_symbols / q->cell.nof_ports); } /* demodulate symbols */ - demod_soft_sigma_set(&q->demod, 1.0); - demod_soft_demodulate(&q->demod, q->pcfich_d, q->data_f, q->nof_symbols); + srslte_demod_soft_sigma_set(&q->demod, 1.0); + srslte_demod_soft_demodulate(&q->demod, q->d, q->data_f, q->nof_symbols); /* Scramble with the sequence for slot nslot */ - scrambling_f(&q->seq_pcfich[nsubframe], q->data_f); + srslte_scrambling_f(&q->seq[nsubframe], q->data_f); /* decode CFI */ - float corr = pcfich_cfi_decode(q, cfi); + float corr = srslte_pcfich_cfi_decode(q, cfi); if (corr_result) { *corr_result = corr; } @@ -228,7 +228,7 @@ int pcfich_decode(pcfich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], f /** Encodes CFI and maps symbols to the slot */ -int pcfich_encode(pcfich_t *q, uint32_t cfi, cf_t *slot_symbols[SRSLTE_MAX_PORTS], +int srslte_pcfich_encode(srslte_pcfich_t *q, uint32_t cfi, cf_t *slot_symbols[SRSLTE_MAX_PORTS], uint32_t subframe) { int i; @@ -244,32 +244,32 @@ int pcfich_encode(pcfich_t *q, uint32_t cfi, cf_t *slot_symbols[SRSLTE_MAX_PORTS /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { - x[i] = q->pcfich_x[i]; + x[i] = q->x[i]; } for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - symbols_precoding[i] = q->pcfich_symbols[i]; + symbols_precoding[i] = q->symbols[i]; } /* pack CFI */ - pcfich_cfi_encode(cfi, q->data); + srslte_pcfich_cfi_encode(cfi, q->data); /* scramble for slot sequence nslot */ - scrambling_b(&q->seq_pcfich[subframe], q->data); + srslte_scrambling_b(&q->seq[subframe], q->data); - mod_modulate(&q->mod, q->data, q->pcfich_d, PCFICH_CFI_LEN); + srslte_mod_modulate(&q->mod, q->data, q->d, PCFICH_CFI_LEN); /* layer mapping & precoding */ if (q->cell.nof_ports > 1) { - srslte_layermap_diversity(q->pcfich_d, x, q->cell.nof_ports, q->nof_symbols); - precoding_diversity(&q->precoding, x, symbols_precoding, q->cell.nof_ports, + srslte_layermap_diversity(q->d, x, q->cell.nof_ports, q->nof_symbols); + srslte_precoding_diversity(&q->precoding, x, symbols_precoding, q->cell.nof_ports, q->nof_symbols / q->cell.nof_ports); } else { - memcpy(q->pcfich_symbols[0], q->pcfich_d, q->nof_symbols * sizeof(cf_t)); + memcpy(q->symbols[0], q->d, q->nof_symbols * sizeof(cf_t)); } /* mapping to resource elements */ for (i = 0; i < q->cell.nof_ports; i++) { - if (regs_pcfich_put(q->regs, q->pcfich_symbols[i], slot_symbols[i]) < 0) { + if (srslte_regs_pcfich_put(q->regs, q->symbols[i], slot_symbols[i]) < 0) { fprintf(stderr, "Error putting PCHICH resource elements\n"); return SRSLTE_ERROR; } diff --git a/srslte/lib/phch/src/pdcch.c b/srslte/lib/phch/src/pdcch.c index aa73ea2ac..563d0e8be 100644 --- a/srslte/lib/phch/src/pdcch.c +++ b/srslte/lib/phch/src/pdcch.c @@ -46,16 +46,16 @@ #define PDCCH_FORMAT_NOF_REGS(i) ((1< 0 && cfi < 4) { - q->nof_regs = (regs_pdcch_nregs(q->regs, cfi) / 9) * 9; + q->nof_regs = (srslte_regs_pdcch_nregs(q->regs, cfi) / 9) * 9; q->nof_cce = q->nof_regs / 9; } } /** Initializes the PDCCH transmitter and receiver */ -int pdcch_init(pdcch_t *q, regs_t *regs, srslte_cell_t cell) { +int srslte_pdcch_init(srslte_pdcch_t *q, srslte_regs_t *regs, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; uint32_t i; @@ -64,35 +64,35 @@ int pdcch_init(pdcch_t *q, regs_t *regs, srslte_cell_t cell) { srslte_cell_isvalid(&cell)) { ret = SRSLTE_ERROR; - bzero(q, sizeof(pdcch_t)); + bzero(q, sizeof(srslte_pdcch_t)); q->cell = cell; q->regs = regs; - if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (srslte_precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); } /* Allocate memory for the maximum number of PDCCH bits (CFI=3) */ - q->max_bits = (regs_pdcch_nregs(q->regs, 3) / 9) * 72; + q->max_bits = (srslte_regs_pdcch_nregs(q->regs, 3) / 9) * 72; INFO("Init PDCCH: Max bits: %d, %d ports.\n", q->max_bits, q->cell.nof_ports); - if (modem_table_lte(&q->mod, LTE_QPSK, true)) { + if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK, true)) { goto clean; } if (srslte_crc_init(&q->crc, SRSLTE_LTE_CRC16, 16)) { goto clean; } - demod_soft_init(&q->demod, q->max_bits / 2); - demod_soft_table_set(&q->demod, &q->mod); - demod_soft_alg_set(&q->demod, APPROX); + srslte_demod_soft_init(&q->demod, q->max_bits / 2); + srslte_demod_soft_table_set(&q->demod, &q->mod); + srslte_demod_soft_alg_set(&q->demod, SRSLTE_DEMOD_SOFT_ALG_APPROX); for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { // we need to pregenerate the sequence for the maximum number of bits, which is 8 times // the maximum number of REGs (for CFI=3) - if (srslte_sequence_pdcch(&q->seq_pdcch[i], 2 * i, q->cell.id, 8*regs_pdcch_nregs(q->regs, 3))) { + if (srslte_sequence_pdcch(&q->seq[i], 2 * i, q->cell.id, 8*srslte_regs_pdcch_nregs(q->regs, 3))) { goto clean; } } @@ -102,34 +102,34 @@ int pdcch_init(pdcch_t *q, regs_t *regs, srslte_cell_t cell) { goto clean; } - q->pdcch_e = vec_malloc(sizeof(uint8_t) * q->max_bits); - if (!q->pdcch_e) { + q->e = srslte_vec_malloc(sizeof(uint8_t) * q->max_bits); + if (!q->e) { goto clean; } - q->pdcch_llr = vec_malloc(sizeof(float) * q->max_bits); - if (!q->pdcch_llr) { + q->llr = srslte_vec_malloc(sizeof(float) * q->max_bits); + if (!q->llr) { goto clean; } - bzero(q->pdcch_llr, sizeof(float) * q->max_bits); + bzero(q->llr, sizeof(float) * q->max_bits); - q->pdcch_d = vec_malloc(sizeof(cf_t) * q->max_bits / 2); - if (!q->pdcch_d) { + q->d = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2); + if (!q->d) { goto clean; } for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->ce[i] = vec_malloc(sizeof(cf_t) * q->max_bits / 2); + q->ce[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2); if (!q->ce[i]) { goto clean; } - q->pdcch_x[i] = vec_malloc(sizeof(cf_t) * q->max_bits / 2); - if (!q->pdcch_x[i]) { + q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2); + if (!q->x[i]) { goto clean; } - q->pdcch_symbols[i] = vec_malloc(sizeof(cf_t) * q->max_bits / 2); - if (!q->pdcch_symbols[i]) { + q->symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2); + if (!q->symbols[i]) { goto clean; } } @@ -138,46 +138,46 @@ int pdcch_init(pdcch_t *q, regs_t *regs, srslte_cell_t cell) { } clean: if (ret == SRSLTE_ERROR) { - pdcch_free(q); + srslte_pdcch_free(q); } return ret; } -void pdcch_free(pdcch_t *q) { +void srslte_pdcch_free(srslte_pdcch_t *q) { int i; - if (q->pdcch_e) { - free(q->pdcch_e); + if (q->e) { + free(q->e); } - if (q->pdcch_llr) { - free(q->pdcch_llr); + if (q->llr) { + free(q->llr); } - if (q->pdcch_d) { - free(q->pdcch_d); + if (q->d) { + free(q->d); } for (i = 0; i < SRSLTE_MAX_PORTS; i++) { if (q->ce[i]) { free(q->ce[i]); } - if (q->pdcch_x[i]) { - free(q->pdcch_x[i]); + if (q->x[i]) { + free(q->x[i]); } - if (q->pdcch_symbols[i]) { - free(q->pdcch_symbols[i]); + if (q->symbols[i]) { + free(q->symbols[i]); } } for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - srslte_sequence_free(&q->seq_pdcch[i]); + srslte_sequence_free(&q->seq[i]); } - demod_soft_free(&q->demod); + srslte_demod_soft_free(&q->demod); - precoding_free(&q->precoding); - modem_table_free(&q->mod); + srslte_precoding_free(&q->precoding); + srslte_modem_table_free(&q->mod); srslte_viterbi_free(&q->decoder); - bzero(q, sizeof(pdcch_t)); + bzero(q, sizeof(srslte_pdcch_t)); } @@ -186,7 +186,7 @@ void pdcch_free(pdcch_t *q) { * in the structure pointed by c. * Returns the number of candidates saved in the array c. */ -uint32_t pdcch_ue_locations(pdcch_t *q, dci_location_t *c, uint32_t max_candidates, +uint32_t srslte_pdcch_ue_locations(srslte_pdcch_t *q, srslte_dci_location_t *c, uint32_t max_candidates, uint32_t nsubframe, uint32_t cfi, uint16_t rnti) { int l; // this must be int because of the for(;;--) loop @@ -207,7 +207,7 @@ uint32_t pdcch_ue_locations(pdcch_t *q, dci_location_t *c, uint32_t max_candidat for (l = 3; l >= 0; l--) { L = (1 << l); // For all possible ncce offset - for (i = 0; i < MIN(q->nof_cce / L, S[l]/PDCCH_FORMAT_NOF_CCE(l)); i++) { + for (i = 0; i < SRSLTE_MIN(q->nof_cce / L, S[l]/PDCCH_FORMAT_NOF_CCE(l)); i++) { ncce = L * ((Yk + i) % (q->nof_cce / L)); if (k < max_candidates && ncce + PDCCH_FORMAT_NOF_CCE(l) <= q->nof_cce) @@ -236,7 +236,7 @@ uint32_t pdcch_ue_locations(pdcch_t *q, dci_location_t *c, uint32_t max_candidat * for DCI messages and saves them in the structure pointed by c. * Returns the number of candidates saved in the array c. */ -uint32_t pdcch_common_locations(pdcch_t *q, dci_location_t *c, uint32_t max_candidates, +uint32_t srslte_pdcch_common_locations(srslte_pdcch_t *q, srslte_dci_location_t *c, uint32_t max_candidates, uint32_t cfi) { uint32_t i, l, L, k; @@ -246,7 +246,7 @@ uint32_t pdcch_common_locations(pdcch_t *q, dci_location_t *c, uint32_t max_cand k = 0; for (l = 3; l > 1; l--) { L = (1 << l); - for (i = 0; i < MIN(q->nof_cce, 16) / (L); i++) { + for (i = 0; i < SRSLTE_MIN(q->nof_cce, 16) / (L); i++) { if (k < max_candidates) { c[k].L = l; c[k].ncce = (L) * (i % (q->nof_cce / (L))); @@ -273,7 +273,7 @@ uint32_t pdcch_common_locations(pdcch_t *q, dci_location_t *c, uint32_t max_cand * * TODO: UE transmit antenna selection CRC mask */ -static int dci_decode(pdcch_t *q, float *e, uint8_t *data, uint32_t E, uint32_t nof_bits, uint16_t *crc) { +static int dci_decode(srslte_pdcch_t *q, float *e, uint8_t *data, uint32_t E, uint32_t nof_bits, uint16_t *crc) { uint16_t p_bits, srslte_crc_res; uint8_t *x; @@ -285,27 +285,27 @@ static int dci_decode(pdcch_t *q, float *e, uint8_t *data, uint32_t E, uint32_t { DEBUG("Rm input: ", 0); - if (VERBOSE_ISDEBUG()) { - vec_fprint_f(stdout, e, E); + if (SRSLTE_VERBOSE_ISDEBUG()) { + srslte_vec_fprint_f(stdout, e, E); } /* unrate matching */ - srslte_rm_conv_rx(e, E, q->pdcch_rm_f, 3 * (nof_bits + 16)); + srslte_rm_conv_rx(e, E, q->rm_f, 3 * (nof_bits + 16)); DEBUG("Viterbi input: ", 0); - if (VERBOSE_ISDEBUG()) { - vec_fprint_f(stdout, q->pdcch_rm_f, 3 * (nof_bits + 16)); + if (SRSLTE_VERBOSE_ISDEBUG()) { + srslte_vec_fprint_f(stdout, q->rm_f, 3 * (nof_bits + 16)); } /* viterbi decoder */ - srslte_viterbi_decode_f(&q->decoder, q->pdcch_rm_f, data, nof_bits + 16); + srslte_viterbi_decode_f(&q->decoder, q->rm_f, data, nof_bits + 16); - if (VERBOSE_ISDEBUG()) { - bit_fprint(stdout, data, nof_bits + 16); + if (SRSLTE_VERBOSE_ISDEBUG()) { + srslte_bit_fprint(stdout, data, nof_bits + 16); } x = &data[nof_bits]; - p_bits = (uint16_t) bit_unpack(&x, 16); + p_bits = (uint16_t) srslte_bit_unpack(&x, 16); srslte_crc_res = ((uint16_t) srslte_crc_checksum(&q->crc, data, nof_bits) & 0xffff); INFO("p_bits: 0x%x, srslte_crc_checksum: 0x%x, srslte_crc_rem: 0x%x\n", p_bits, srslte_crc_res, p_bits ^ srslte_crc_res); @@ -320,17 +320,17 @@ static int dci_decode(pdcch_t *q, float *e, uint8_t *data, uint32_t E, uint32_t } } -/** Tries to decode a DCI message from the LLRs stored in the pdcch_t structure by the function - * pdcch_extract_llr(). This function can be called multiple times. +/** Tries to decode a DCI message from the LLRs stored in the srslte_pdcch_t structure by the function + * srslte_pdcch_extract_llr(). This function can be called multiple times. * The decoded message is stored in msg and the CRC remainder in srslte_crc_rem pointer * */ -int pdcch_decode_msg(pdcch_t *q, dci_msg_t *msg, dci_location_t *location, dci_format_t format, uint16_t *srslte_crc_rem) +int srslte_pdcch_decode_msg(srslte_pdcch_t *q, srslte_dci_msg_t *msg, srslte_dci_location_t *location, srslte_dci_format_t format, uint16_t *srslte_crc_rem) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && msg != NULL && - dci_location_isvalid(location) && + srslte_dci_location_isvalid(location) && srslte_crc_rem != NULL) { if (location->ncce * 72 + PDCCH_FORMAT_NOF_BITS(location->L) > @@ -338,13 +338,13 @@ int pdcch_decode_msg(pdcch_t *q, dci_msg_t *msg, dci_location_t *location, dci_f fprintf(stderr, "Invalid location: nCCE: %d, L: %d, NofCCE: %d\n", location->ncce, location->L, q->nof_cce); } else { - uint32_t nof_bits = dci_format_sizeof(format, q->cell.nof_prb); + uint32_t nof_bits = srslte_dci_format_sizeof(format, q->cell.nof_prb); uint32_t e_bits = PDCCH_FORMAT_NOF_BITS(location->L); INFO("Decoding DCI offset %d, e_bits: %d, msg_len %d (nCCE: %d, L: %d)\n", location->ncce * 72, e_bits, nof_bits, location->ncce, location->L); - ret = dci_decode(q, &q->pdcch_llr[location->ncce * 72], + ret = dci_decode(q, &q->llr[location->ncce * 72], msg->data, e_bits, nof_bits, srslte_crc_rem); if (ret == SRSLTE_SUCCESS) { msg->nof_bits = nof_bits; @@ -354,12 +354,12 @@ int pdcch_decode_msg(pdcch_t *q, dci_msg_t *msg, dci_location_t *location, dci_f return ret; } -/** Extracts the LLRs from dci_location_t location of the subframe and stores them in the pdcch_t structure. - * DCI messages can be extracted from this location calling the function pdcch_decode_msg(). +/** Extracts the LLRs from srslte_dci_location_t location of the subframe and stores them in the srslte_pdcch_t structure. + * DCI messages can be extracted from this location calling the function srslte_pdcch_decode_msg(). * Every time this function is called (with a different location), the last demodulated symbols are overwritten and * new messages from other locations can be decoded */ -int pdcch_extract_llr(pdcch_t *q, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, +int srslte_pdcch_extract_llr(srslte_pdcch_t *q, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, uint32_t nsubframe, uint32_t cfi) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -384,12 +384,12 @@ int pdcch_extract_llr(pdcch_t *q, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { - x[i] = q->pdcch_x[i]; + x[i] = q->x[i]; } 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]); + int n = srslte_regs_pdcch_get(q->regs, sf_symbols, q->symbols[0]); if (nof_symbols != n) { fprintf(stderr, "Expected %d PDCCH symbols but got %d symbols\n", nof_symbols, n); return ret; @@ -397,7 +397,7 @@ int pdcch_extract_llr(pdcch_t *q, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], /* extract channel estimates */ for (i = 0; i < q->cell.nof_ports; i++) { - n = regs_pdcch_get(q->regs, ce[i], q->ce[i]); + n = srslte_regs_pdcch_get(q->regs, ce[i], q->ce[i]); if (nof_symbols != n) { fprintf(stderr, "Expected %d PDCCH symbols but got %d symbols\n", nof_symbols, n); return ret; @@ -407,27 +407,27 @@ int pdcch_extract_llr(pdcch_t *q, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], /* in control channels, only diversity is supported */ if (q->cell.nof_ports == 1) { /* no need for layer demapping */ - predecoding_single(&q->precoding, q->pdcch_symbols[0], q->ce[0], q->pdcch_d, nof_symbols, noise_estimate); + srslte_predecoding_single(&q->precoding, q->symbols[0], q->ce[0], q->d, nof_symbols, noise_estimate); } else { - predecoding_diversity(&q->precoding, q->pdcch_symbols[0], q->ce, x, q->cell.nof_ports, nof_symbols, noise_estimate); - srslte_layerdemap_diversity(x, q->pdcch_d, q->cell.nof_ports, nof_symbols / q->cell.nof_ports); + srslte_predecoding_diversity(&q->precoding, q->symbols[0], q->ce, x, q->cell.nof_ports, nof_symbols, noise_estimate); + srslte_layerdemap_diversity(x, q->d, q->cell.nof_ports, nof_symbols / q->cell.nof_ports); } DEBUG("pdcch d symbols: ", 0); - if (VERBOSE_ISDEBUG()) { - vec_fprint_c(stdout, q->pdcch_d, nof_symbols); + if (SRSLTE_VERBOSE_ISDEBUG()) { + srslte_vec_fprint_c(stdout, q->d, nof_symbols); } /* demodulate symbols */ - demod_soft_sigma_set(&q->demod, 1.0); - demod_soft_demodulate(&q->demod, q->pdcch_d, q->pdcch_llr, nof_symbols); + srslte_demod_soft_sigma_set(&q->demod, 1.0); + srslte_demod_soft_demodulate(&q->demod, q->d, q->llr, nof_symbols); /* descramble */ - scrambling_f_offset(&q->seq_pdcch[nsubframe], q->pdcch_llr, 0, e_bits); + srslte_scrambling_f_offset(&q->seq[nsubframe], q->llr, 0, e_bits); DEBUG("llr: ", 0); - if (VERBOSE_ISDEBUG()) { - vec_fprint_f(stdout, q->pdcch_llr, e_bits); + if (SRSLTE_VERBOSE_ISDEBUG()) { + srslte_vec_fprint_f(stdout, q->llr, e_bits); } ret = SRSLTE_SUCCESS; @@ -444,7 +444,7 @@ static void srslte_crc_set_mask_rnti(uint8_t *crc, uint16_t rnti) { INFO("Mask CRC with RNTI 0x%x\n", rnti); - bit_pack(rnti, &r, 16); + srslte_bit_pack(rnti, &r, 16); for (i = 0; i < 16; i++) { crc[i] = (crc[i] + mask[i]) % 2; } @@ -453,7 +453,7 @@ static void srslte_crc_set_mask_rnti(uint8_t *crc, uint16_t rnti) { /** 36.212 5.3.3.2 to 5.3.3.4 * TODO: UE transmit antenna selection CRC mask */ -static int dci_encode(pdcch_t *q, uint8_t *data, uint8_t *e, uint32_t nof_bits, uint32_t E, +static int dci_encode(srslte_pdcch_t *q, uint8_t *data, uint8_t *e, uint32_t nof_bits, uint32_t E, uint16_t rnti) { srslte_convcoder_t encoder; uint8_t tmp[3 * (DCI_MAX_BITS + 16)]; @@ -477,8 +477,8 @@ static int dci_encode(pdcch_t *q, uint8_t *data, uint8_t *e, uint32_t nof_bits, srslte_convcoder_encode(&encoder, data, tmp, nof_bits + 16); DEBUG("CConv output: ", 0); - if (VERBOSE_ISDEBUG()) { - vec_fprint_b(stdout, tmp, 3 * (nof_bits + 16)); + if (SRSLTE_VERBOSE_ISDEBUG()) { + srslte_vec_fprint_b(stdout, tmp, 3 * (nof_bits + 16)); } srslte_rm_conv_tx(tmp, 3 * (nof_bits + 16), e, E); @@ -489,7 +489,7 @@ static int dci_encode(pdcch_t *q, uint8_t *data, uint8_t *e, uint32_t nof_bits, } } -/** Encodes ONE DCI message and allocates the encoded bits to the dci_location_t indicated by +/** Encodes ONE DCI message and allocates the encoded bits to the srslte_dci_location_t indicated by * the parameter location. The CRC is scrambled with the RNTI parameter. * This function can be called multiple times and encoded DCI messages will be allocated to the * sf_symbols buffer ready for transmission. @@ -497,8 +497,9 @@ static int dci_encode(pdcch_t *q, uint8_t *data, uint8_t *e, uint32_t nof_bits, * * @TODO: Use a bitmask and CFI to ensure message locations are valid and old messages are not overwritten. */ -int pdcch_encode(pdcch_t *q, dci_msg_t *msg, dci_location_t location, uint16_t rnti, - cf_t *sf_symbols[SRSLTE_MAX_PORTS], uint32_t nsubframe, uint32_t cfi) { +int srslte_pdcch_encode(srslte_pdcch_t *q, srslte_dci_msg_t *msg, srslte_dci_location_t location, uint16_t rnti, + cf_t *sf_symbols[SRSLTE_MAX_PORTS], uint32_t nsubframe, uint32_t cfi) +{ int ret = SRSLTE_ERROR_INVALID_INPUTS; uint32_t i; @@ -510,7 +511,7 @@ int pdcch_encode(pdcch_t *q, dci_msg_t *msg, dci_location_t location, uint16_t r nsubframe < 10 && cfi > 0 && cfi < 4 && - dci_location_isvalid(&location)) + srslte_dci_location_isvalid(&location)) { set_cfi(q, cfi); @@ -525,34 +526,34 @@ int pdcch_encode(pdcch_t *q, dci_msg_t *msg, dci_location_t location, uint16_t r INFO("Encoding DCI: Nbits: %d, E: %d, nCCE: %d, L: %d, RNTI: 0x%x\n", msg->nof_bits, e_bits, location.ncce, location.L, rnti); - dci_encode(q, msg->data, q->pdcch_e, msg->nof_bits, e_bits, rnti); + dci_encode(q, msg->data, q->e, msg->nof_bits, e_bits, rnti); /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { - x[i] = q->pdcch_x[i]; + x[i] = q->x[i]; } 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); + srslte_scrambling_b_offset(&q->seq[nsubframe], q->e, 72 * location.ncce, e_bits); DEBUG("Scrambling output: ", 0); - if (VERBOSE_ISDEBUG()) { - vec_fprint_b(stdout, q->pdcch_e, e_bits); + if (SRSLTE_VERBOSE_ISDEBUG()) { + srslte_vec_fprint_b(stdout, q->e, e_bits); } - mod_modulate(&q->mod, q->pdcch_e, q->pdcch_d, e_bits); + srslte_mod_modulate(&q->mod, q->e, q->d, e_bits); /* layer mapping & precoding */ if (q->cell.nof_ports > 1) { - srslte_layermap_diversity(q->pdcch_d, x, q->cell.nof_ports, nof_symbols); - precoding_diversity(&q->precoding, x, q->pdcch_symbols, q->cell.nof_ports, nof_symbols / q->cell.nof_ports); + srslte_layermap_diversity(q->d, x, q->cell.nof_ports, nof_symbols); + srslte_precoding_diversity(&q->precoding, x, q->symbols, q->cell.nof_ports, nof_symbols / q->cell.nof_ports); } else { - memcpy(q->pdcch_symbols[0], q->pdcch_d, nof_symbols * sizeof(cf_t)); + memcpy(q->symbols[0], q->d, nof_symbols * sizeof(cf_t)); } /* mapping to resource elements */ for (i = 0; i < q->cell.nof_ports; i++) { - regs_pdcch_put_offset(q->regs, q->pdcch_symbols[i], sf_symbols[i], + srslte_regs_pdcch_put_offset(q->regs, q->symbols[i], sf_symbols[i], location.ncce * 9, PDCCH_FORMAT_NOF_REGS(location.L)); } diff --git a/srslte/lib/phch/src/pdsch.c b/srslte/lib/phch/src/pdsch.c index cf0a18031..c80a0829b 100644 --- a/srslte/lib/phch/src/pdsch.c +++ b/srslte/lib/phch/src/pdsch.c @@ -47,7 +47,7 @@ const static srslte_mod_t modulations[4] = - { LTE_BPSK, LTE_QPSK, LTE_QAM16, LTE_QAM64 }; + { SRSLTE_MOD_BPSK, SRSLTE_MOD_QPSK, SRSLTE_MOD_16QAM, SRSLTE_MOD_64QAM }; //#define DEBUG_IDX @@ -58,7 +58,7 @@ extern int indices_ptr; #endif -int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc, +int srslte_pdsch_cp(srslte_pdsch_t *q, cf_t *input, cf_t *output, srslte_srslte_ra_dl_alloc_t *prb_alloc, uint32_t nsubframe, bool put) { uint32_t s, n, l, lp, lstart, lend, nof_refs; bool is_pbch, is_sss; @@ -178,9 +178,9 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc, * * 36.211 10.3 section 6.3.5 */ -int pdsch_put(pdsch_t *q, cf_t *pdsch_symbols, cf_t *sf_symbols, - ra_dl_alloc_t *prb_alloc, uint32_t subframe) { - return pdsch_cp(q, pdsch_symbols, sf_symbols, prb_alloc, subframe, true); +int srslte_pdsch_put(srslte_pdsch_t *q, cf_t *symbols, cf_t *sf_symbols, + srslte_srslte_ra_dl_alloc_t *prb_alloc, uint32_t subframe) { + return srslte_pdsch_cp(q, symbols, sf_symbols, prb_alloc, subframe, true); } /** @@ -190,13 +190,13 @@ int pdsch_put(pdsch_t *q, cf_t *pdsch_symbols, cf_t *sf_symbols, * * 36.211 10.3 section 6.3.5 */ -int pdsch_get(pdsch_t *q, cf_t *sf_symbols, cf_t *pdsch_symbols, - ra_dl_alloc_t *prb_alloc, uint32_t subframe) { - return pdsch_cp(q, sf_symbols, pdsch_symbols, prb_alloc, subframe, false); +int srslte_pdsch_get(srslte_pdsch_t *q, cf_t *sf_symbols, cf_t *symbols, + srslte_srslte_ra_dl_alloc_t *prb_alloc, uint32_t subframe) { + return srslte_pdsch_cp(q, sf_symbols, symbols, prb_alloc, subframe, false); } /** Initializes the PDCCH transmitter and receiver */ -int pdsch_init(pdsch_t *q, srslte_cell_t cell) { +int srslte_pdsch_init(srslte_pdsch_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; int i; @@ -204,7 +204,7 @@ int pdsch_init(pdsch_t *q, srslte_cell_t cell) { srslte_cell_isvalid(&cell)) { - bzero(q, sizeof(pdsch_t)); + bzero(q, sizeof(srslte_pdsch_t)); ret = SRSLTE_ERROR; q->cell = cell; @@ -213,46 +213,46 @@ 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, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (srslte_precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); goto clean; } for (i = 0; i < 4; i++) { - if (modem_table_lte(&q->mod[i], modulations[i], true)) { + if (srslte_modem_table_lte(&q->mod[i], modulations[i], true)) { goto clean; } } - demod_soft_init(&q->demod, q->max_re); - demod_soft_alg_set(&q->demod, APPROX); + srslte_demod_soft_init(&q->demod, q->max_re); + srslte_demod_soft_alg_set(&q->demod, SRSLTE_DEMOD_SOFT_ALG_APPROX); - sch_init(&q->dl_sch); + srslte_sch_init(&q->dl_sch); q->rnti_is_set = false; // Allocate floats for reception (LLRs) - q->pdsch_e = vec_malloc(sizeof(float) * q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64)); - if (!q->pdsch_e) { + q->e = srslte_vec_malloc(sizeof(float) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM)); + if (!q->e) { goto clean; } - q->pdsch_d = vec_malloc(sizeof(cf_t) * q->max_re); - if (!q->pdsch_d) { + q->d = srslte_vec_malloc(sizeof(cf_t) * q->max_re); + if (!q->d) { goto clean; } for (i = 0; i < q->cell.nof_ports; i++) { - q->ce[i] = vec_malloc(sizeof(cf_t) * q->max_re); + q->ce[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re); if (!q->ce[i]) { goto clean; } - q->pdsch_x[i] = vec_malloc(sizeof(cf_t) * q->max_re); - if (!q->pdsch_x[i]) { + q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re); + if (!q->x[i]) { goto clean; } - q->pdsch_symbols[i] = vec_malloc(sizeof(cf_t) * q->max_re); - if (!q->pdsch_symbols[i]) { + q->symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re); + if (!q->symbols[i]) { goto clean; } } @@ -261,56 +261,56 @@ int pdsch_init(pdsch_t *q, srslte_cell_t cell) { } clean: if (ret == SRSLTE_ERROR) { - pdsch_free(q); + srslte_pdsch_free(q); } return ret; } -void pdsch_free(pdsch_t *q) { +void srslte_pdsch_free(srslte_pdsch_t *q) { int i; - if (q->pdsch_e) { - free(q->pdsch_e); + if (q->e) { + free(q->e); } - if (q->pdsch_d) { - free(q->pdsch_d); + if (q->d) { + free(q->d); } for (i = 0; i < q->cell.nof_ports; i++) { if (q->ce[i]) { free(q->ce[i]); } - if (q->pdsch_x[i]) { - free(q->pdsch_x[i]); + if (q->x[i]) { + free(q->x[i]); } - if (q->pdsch_symbols[i]) { - free(q->pdsch_symbols[i]); + if (q->symbols[i]) { + free(q->symbols[i]); } } for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - srslte_sequence_free(&q->seq_pdsch[i]); + srslte_sequence_free(&q->seq[i]); } for (i = 0; i < 4; i++) { - modem_table_free(&q->mod[i]); + srslte_modem_table_free(&q->mod[i]); } - demod_soft_free(&q->demod); - precoding_free(&q->precoding); - sch_free(&q->dl_sch); + srslte_demod_soft_free(&q->demod); + srslte_precoding_free(&q->precoding); + srslte_sch_free(&q->dl_sch); - bzero(q, sizeof(pdsch_t)); + bzero(q, sizeof(srslte_pdsch_t)); } /* Precalculate the PUSCH scramble sequences for a given RNTI. This function takes a while * to execute, so shall be called once the final C-RNTI has been allocated for the session. - * For the connection procedure, use pusch_encode_rnti() or pusch_decode_rnti() functions + * For the connection procedure, use srslte_pusch_encode_rnti() or srslte_pusch_decode_rnti() functions */ -int pdsch_set_rnti(pdsch_t *q, uint16_t rnti) { +int srslte_pdsch_set_rnti(srslte_pdsch_t *q, uint16_t rnti) { uint32_t i; for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - if (srslte_sequence_pdsch(&q->seq_pdsch[i], rnti, 0, 2 * i, q->cell.id, - q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64))) { + if (srslte_sequence_pdsch(&q->seq[i], rnti, 0, 2 * i, q->cell.id, + q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { return SRSLTE_ERROR; } } @@ -319,16 +319,16 @@ int pdsch_set_rnti(pdsch_t *q, uint16_t rnti) { return SRSLTE_SUCCESS; } -int pdsch_decode(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, uint8_t *data) { +int srslte_pdsch_decode(srslte_pdsch_t *q, srslte_harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, uint8_t *data) { if (q != NULL && sf_symbols != NULL && data != NULL && harq != NULL) { if (q->rnti_is_set) { - return pdsch_decode_rnti(q, harq, sf_symbols, ce, noise_estimate, q->rnti, data); + return srslte_pdsch_decode_rnti(q, harq, sf_symbols, ce, noise_estimate, q->rnti, data); } else { - fprintf(stderr, "Must call pdsch_set_rnti() before calling pdsch_decode()\n"); + fprintf(stderr, "Must call srslte_pdsch_set_rnti() before calling srslte_pdsch_decode()\n"); return SRSLTE_ERROR; } } else { @@ -338,7 +338,7 @@ int pdsch_decode(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX /** Decodes the PDSCH from the received symbols */ -int pdsch_decode_rnti(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], +int srslte_pdsch_decode_rnti(srslte_pdsch_t *q, srslte_harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, uint16_t rnti, uint8_t *data) { @@ -357,12 +357,12 @@ int pdsch_decode_rnti(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLT /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { - x[i] = q->pdsch_x[i]; + x[i] = q->x[i]; } 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); + n = srslte_pdsch_get(q, sf_symbols, q->symbols[0], &harq->dl_alloc, harq->sf_idx); if (n != harq->nof_re) { fprintf(stderr, "Error expecting %d symbols but got %d\n", harq->nof_re, n); return SRSLTE_ERROR; @@ -370,7 +370,7 @@ int pdsch_decode_rnti(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLT /* extract channel estimates */ for (i = 0; i < q->cell.nof_ports; i++) { - n = pdsch_get(q, ce[i], q->ce[i], &harq->dl_alloc, harq->sf_idx); + n = srslte_pdsch_get(q, ce[i], q->ce[i], &harq->dl_alloc, harq->sf_idx); if (n != harq->nof_re) { fprintf(stderr, "Error expecting %d symbols but got %d\n", harq->nof_re, n); return SRSLTE_ERROR; @@ -380,12 +380,12 @@ int pdsch_decode_rnti(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLT /* TODO: only diversity is supported */ if (q->cell.nof_ports == 1) { /* no need for layer demapping */ - predecoding_single(&q->precoding, q->pdsch_symbols[0], q->ce[0], q->pdsch_d, + srslte_predecoding_single(&q->precoding, q->symbols[0], q->ce[0], q->d, harq->nof_re, noise_estimate); } else { - predecoding_diversity(&q->precoding, q->pdsch_symbols[0], q->ce, x, q->cell.nof_ports, + srslte_predecoding_diversity(&q->precoding, q->symbols[0], q->ce, x, q->cell.nof_ports, harq->nof_re, noise_estimate); - srslte_layerdemap_diversity(x, q->pdsch_d, q->cell.nof_ports, + srslte_layerdemap_diversity(x, q->d, q->cell.nof_ports, harq->nof_re / q->cell.nof_ports); } @@ -393,9 +393,9 @@ int pdsch_decode_rnti(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLT * The MAX-log-MAP algorithm used in turbo decoding is unsensitive to SNR estimation, * thus we don't need tot set it in the LLRs normalization */ - demod_soft_sigma_set(&q->demod, sqrt(0.5)); - demod_soft_table_set(&q->demod, &q->mod[harq->mcs.mod]); - demod_soft_demodulate(&q->demod, q->pdsch_d, q->pdsch_e, harq->nof_re); + srslte_demod_soft_sigma_set(&q->demod, sqrt(0.5)); + srslte_demod_soft_table_set(&q->demod, &q->mod[harq->mcs.mod]); + srslte_demod_soft_demodulate(&q->demod, q->d, q->e, harq->nof_re); /* descramble */ if (rnti != q->rnti) { @@ -403,29 +403,29 @@ int pdsch_decode_rnti(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLT if (srslte_sequence_pdsch(&seq, rnti, 0, 2 * harq->sf_idx, q->cell.id, harq->nof_bits)) { return SRSLTE_ERROR; } - scrambling_f_offset(&seq, q->pdsch_e, 0, harq->nof_bits); + srslte_scrambling_f_offset(&seq, q->e, 0, harq->nof_bits); srslte_sequence_free(&seq); } else { - scrambling_f_offset(&q->seq_pdsch[harq->sf_idx], q->pdsch_e, 0, harq->nof_bits); + srslte_scrambling_f_offset(&q->seq[harq->sf_idx], q->e, 0, harq->nof_bits); } - return dlsch_decode(&q->dl_sch, harq, q->pdsch_e, data); + return srslte_dlsch_decode(&q->dl_sch, harq, q->e, data); } else { return SRSLTE_ERROR_INVALID_INPUTS; } } -int pdsch_encode(pdsch_t *q, harq_t *harq, uint8_t *data, cf_t *sf_symbols[SRSLTE_MAX_PORTS]) +int srslte_pdsch_encode(srslte_pdsch_t *q, srslte_harq_t *harq, uint8_t *data, cf_t *sf_symbols[SRSLTE_MAX_PORTS]) { if (q != NULL && data != NULL && harq != NULL) { if (q->rnti_is_set) { - return pdsch_encode_rnti(q, harq, data, q->rnti, sf_symbols); + return srslte_pdsch_encode_rnti(q, harq, data, q->rnti, sf_symbols); } else { - fprintf(stderr, "Must call pdsch_set_rnti() to set the encoder/decoder RNTI\n"); + fprintf(stderr, "Must call srslte_pdsch_set_rnti() to set the encoder/decoder RNTI\n"); return SRSLTE_ERROR; } } else { @@ -435,7 +435,7 @@ int pdsch_encode(pdsch_t *q, harq_t *harq, uint8_t *data, cf_t *sf_symbols[SRSLT /** Converts the PDSCH data bits to symbols mapped to the slot ready for transmission */ -int pdsch_encode_rnti(pdsch_t *q, harq_t *harq, uint8_t *data, uint16_t rnti, cf_t *sf_symbols[SRSLTE_MAX_PORTS]) +int srslte_pdsch_encode_rnti(srslte_pdsch_t *q, srslte_harq_t *harq, uint8_t *data, uint16_t rnti, cf_t *sf_symbols[SRSLTE_MAX_PORTS]) { int i; /* Set pointers for layermapping & precoding */ @@ -474,11 +474,11 @@ int pdsch_encode_rnti(pdsch_t *q, harq_t *harq, uint8_t *data, uint16_t rnti, cf /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { - x[i] = q->pdsch_x[i]; + x[i] = q->x[i]; } 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)) { + if (srslte_dlsch_encode(&q->dl_sch, harq, data, q->e)) { fprintf(stderr, "Error encoding TB\n"); return SRSLTE_ERROR; } @@ -488,26 +488,26 @@ int pdsch_encode_rnti(pdsch_t *q, harq_t *harq, uint8_t *data, uint16_t rnti, cf if (srslte_sequence_pdsch(&seq, rnti, 0, 2 * harq->sf_idx, q->cell.id, harq->nof_bits)) { return SRSLTE_ERROR; } - scrambling_b_offset(&seq, (uint8_t*) q->pdsch_e, 0, harq->nof_bits); + srslte_scrambling_b_offset(&seq, (uint8_t*) q->e, 0, harq->nof_bits); srslte_sequence_free(&seq); } else { - scrambling_b_offset(&q->seq_pdsch[harq->sf_idx], (uint8_t*) q->pdsch_e, 0, harq->nof_bits); + srslte_scrambling_b_offset(&q->seq[harq->sf_idx], (uint8_t*) q->e, 0, harq->nof_bits); } - mod_modulate(&q->mod[harq->mcs.mod], (uint8_t*) q->pdsch_e, q->pdsch_d, harq->nof_bits); + srslte_mod_modulate(&q->mod[harq->mcs.mod], (uint8_t*) q->e, q->d, harq->nof_bits); /* TODO: only diversity supported */ if (q->cell.nof_ports > 1) { - srslte_layermap_diversity(q->pdsch_d, x, q->cell.nof_ports, harq->nof_re); - precoding_diversity(&q->precoding, x, q->pdsch_symbols, q->cell.nof_ports, + srslte_layermap_diversity(q->d, x, q->cell.nof_ports, harq->nof_re); + srslte_precoding_diversity(&q->precoding, x, q->symbols, q->cell.nof_ports, harq->nof_re / q->cell.nof_ports); } else { - memcpy(q->pdsch_symbols[0], q->pdsch_d, harq->nof_re * sizeof(cf_t)); + memcpy(q->symbols[0], q->d, harq->nof_re * sizeof(cf_t)); } /* mapping to resource elements */ for (i = 0; i < q->cell.nof_ports; i++) { - pdsch_put(q, q->pdsch_symbols[i], sf_symbols[i], &harq->dl_alloc, harq->sf_idx); + srslte_pdsch_put(q, q->symbols[i], sf_symbols[i], &harq->dl_alloc, harq->sf_idx); } ret = SRSLTE_SUCCESS; } diff --git a/srslte/lib/phch/src/phich.c b/srslte/lib/phch/src/phich.c index f0967745c..d1c8fd283 100644 --- a/srslte/lib/phch/src/phich.c +++ b/srslte/lib/phch/src/phich.c @@ -49,19 +49,19 @@ const cf_t w_ext[SRSLTE_PHICH_EXT_NSEQUENCES][2] = { { 1, 1 }, { 1, -1 }, { I, I I, -I } }; -uint32_t phich_ngroups(phich_t *q) { - return regs_phich_ngroups(q->regs); +uint32_t srslte_phich_ngroups(srslte_phich_t *q) { + return srslte_regs_phich_ngroups(q->regs); } -void phich_reset(phich_t *q, cf_t *slot_symbols[SRSLTE_MAX_PORTS]) { +void srslte_phich_reset(srslte_phich_t *q, cf_t *slot_symbols[SRSLTE_MAX_PORTS]) { int i; for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - regs_phich_reset(q->regs, slot_symbols[i]); + srslte_regs_phich_reset(q->regs, slot_symbols[i]); } } /** Initializes the phich channel receiver */ -int phich_init(phich_t *q, regs_t *regs, srslte_cell_t cell) { +int srslte_phich_init(srslte_phich_t *q, srslte_regs_t *regs, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && @@ -69,25 +69,25 @@ int phich_init(phich_t *q, regs_t *regs, srslte_cell_t cell) { srslte_cell_isvalid(&cell)) { - bzero(q, sizeof(phich_t)); + bzero(q, sizeof(srslte_phich_t)); ret = SRSLTE_ERROR; q->cell = cell; q->regs = regs; - if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (srslte_precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); } - if (modem_table_lte(&q->mod, LTE_BPSK, false)) { + if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_BPSK, false)) { goto clean; } - demod_hard_init(&q->demod); - demod_hard_table_set(&q->demod, LTE_BPSK); + srslte_demod_hard_init(&q->demod); + srslte_demod_hard_table_set(&q->demod, SRSLTE_MOD_BPSK); for (int nsf = 0; nsf < SRSLTE_NSUBFRAMES_X_FRAME; nsf++) { - if (srslte_sequence_phich(&q->seq_phich[nsf], 2 * nsf, q->cell.id)) { + if (srslte_sequence_phich(&q->seq[nsf], 2 * nsf, q->cell.id)) { goto clean; } } @@ -95,30 +95,30 @@ int phich_init(phich_t *q, regs_t *regs, srslte_cell_t cell) { } clean: if (ret == SRSLTE_ERROR) { - phich_free(q); + srslte_phich_free(q); } return ret; } -void phich_free(phich_t *q) { +void srslte_phich_free(srslte_phich_t *q) { for (int ns = 0; ns < SRSLTE_NSUBFRAMES_X_FRAME; ns++) { - srslte_sequence_free(&q->seq_phich[ns]); + srslte_sequence_free(&q->seq[ns]); } - modem_table_free(&q->mod); - precoding_free(&q->precoding); + srslte_modem_table_free(&q->mod); + srslte_precoding_free(&q->precoding); - bzero(q, sizeof(phich_t)); + bzero(q, sizeof(srslte_phich_t)); } /* Decodes ACK * */ -uint8_t phich_ack_decode(uint8_t bits[PHICH_NBITS], uint32_t *distance) { +uint8_t srslte_phich_ack_decode(uint8_t bits[SRSLTE_PHICH_NBITS], uint32_t *distance) { int i, n; n = 0; - for (i = 0; i < PHICH_NBITS; i++) { + for (i = 0; i < SRSLTE_PHICH_NBITS; i++) { n += bits[i]; } INFO("PHICH decoder: %d, %d, %d\n", bits[0], bits[1], bits[2]); @@ -138,7 +138,7 @@ uint8_t phich_ack_decode(uint8_t bits[PHICH_NBITS], uint32_t *distance) { /** Encodes the ACK * 36.212 */ -void phich_ack_encode(uint8_t ack, uint8_t bits[PHICH_NBITS]) { +void srslte_phich_ack_encode(uint8_t ack, uint8_t bits[SRSLTE_PHICH_NBITS]) { memset(bits, ack, 3 * sizeof(uint8_t)); } @@ -146,7 +146,7 @@ void phich_ack_encode(uint8_t ack, uint8_t bits[PHICH_NBITS]) { * * Returns 1 if successfully decoded the CFI, 0 if not and -1 on error */ -int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, +int srslte_phich_decode(srslte_phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, uint32_t ngroup, uint32_t nseq, uint32_t subframe, uint8_t *ack, uint32_t *distance) { /* Set pointers for layermapping & precoding */ @@ -174,7 +174,7 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo return SRSLTE_ERROR_INVALID_INPUTS; } } - if (ngroup >= regs_phich_ngroups(q->regs)) { + if (ngroup >= srslte_regs_phich_ngroups(q->regs)) { fprintf(stderr, "Invalid ngroup %d\n", ngroup); return SRSLTE_ERROR_INVALID_INPUTS; } @@ -183,22 +183,22 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo /* number of layers equals number of ports */ for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - x[i] = q->phich_x[i]; + x[i] = q->x[i]; } for (i = 0; i < SRSLTE_MAX_PORTS; i++) { ce_precoding[i] = q->ce[i]; } /* extract symbols */ - if (PHICH_SRSLTE_MAX_NSYMB - != regs_phich_get(q->regs, slot_symbols, q->phich_symbols[0], ngroup)) { + if (SRSLTE_PHICH_MAX_NSYMB + != srslte_regs_phich_get(q->regs, slot_symbols, q->symbols[0], ngroup)) { fprintf(stderr, "There was an error getting the phich symbols\n"); return SRSLTE_ERROR; } /* extract channel estimates */ for (i = 0; i < q->cell.nof_ports; i++) { - if (PHICH_SRSLTE_MAX_NSYMB != regs_phich_get(q->regs, ce[i], q->ce[i], ngroup)) { + if (SRSLTE_PHICH_MAX_NSYMB != srslte_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; } @@ -207,77 +207,77 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo /* in control channels, only diversity is supported */ 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_SRSLTE_MAX_NSYMB, noise_estimate); + srslte_predecoding_single(&q->precoding, q->symbols[0], q->ce[0], q->d0, + SRSLTE_PHICH_MAX_NSYMB, noise_estimate); } else { - predecoding_diversity(&q->precoding, q->phich_symbols[0], ce_precoding, x, - q->cell.nof_ports, PHICH_SRSLTE_MAX_NSYMB, noise_estimate); - srslte_layerdemap_diversity(x, q->phich_d0, q->cell.nof_ports, - PHICH_SRSLTE_MAX_NSYMB / q->cell.nof_ports); + srslte_predecoding_diversity(&q->precoding, q->symbols[0], ce_precoding, x, + q->cell.nof_ports, SRSLTE_PHICH_MAX_NSYMB, noise_estimate); + srslte_layerdemap_diversity(x, q->d0, q->cell.nof_ports, + SRSLTE_PHICH_MAX_NSYMB / q->cell.nof_ports); } DEBUG("Recv!!: \n", 0); DEBUG("d0: ", 0); - if (VERBOSE_ISDEBUG()) - vec_fprint_c(stdout, q->phich_d0, PHICH_SRSLTE_MAX_NSYMB); + if (SRSLTE_VERBOSE_ISDEBUG()) + srslte_vec_fprint_c(stdout, q->d0, SRSLTE_PHICH_MAX_NSYMB); if (SRSLTE_CP_ISEXT(q->cell.cp)) { if (ngroup % 2) { 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]; + q->d[2 * i + 0] = q->d0[4 * i + 2]; + q->d[2 * i + 1] = q->d0[4 * i + 3]; } } else { 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]; + q->d[2 * i + 0] = q->d0[4 * i]; + q->d[2 * i + 1] = q->d0[4 * i + 1]; } } } else { - memcpy(q->phich_d, q->phich_d0, PHICH_SRSLTE_MAX_NSYMB * sizeof(cf_t)); + memcpy(q->d, q->d0, SRSLTE_PHICH_MAX_NSYMB * sizeof(cf_t)); } DEBUG("d: ", 0); - if (VERBOSE_ISDEBUG()) - vec_fprint_c(stdout, q->phich_d, SRSLTE_PHICH_EXT_MSYMB); + if (SRSLTE_VERBOSE_ISDEBUG()) + srslte_vec_fprint_c(stdout, q->d, SRSLTE_PHICH_EXT_MSYMB); - scrambling_c(&q->seq_phich[subframe], q->phich_d); + srslte_scrambling_c(&q->seq[subframe], q->d); /* De-spreading */ if (SRSLTE_CP_ISEXT(q->cell.cp)) { - for (i = 0; i < PHICH_NBITS; i++) { - q->phich_z[i] = 0; + for (i = 0; i < SRSLTE_PHICH_NBITS; i++) { + q->z[i] = 0; for (j = 0; j < SRSLTE_PHICH_EXT_NSF; j++) { - q->phich_z[i] += conjf(w_ext[nseq][j]) - * q->phich_d[i * SRSLTE_PHICH_EXT_NSF + j] / SRSLTE_PHICH_EXT_NSF; + q->z[i] += conjf(w_ext[nseq][j]) + * q->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 (i = 0; i < SRSLTE_PHICH_NBITS; i++) { + q->z[i] = 0; for (j = 0; j < SRSLTE_PHICH_NORM_NSF; j++) { - q->phich_z[i] += conjf(w_normal[nseq][j]) - * q->phich_d[i * SRSLTE_PHICH_NORM_NSF + j] / SRSLTE_PHICH_NORM_NSF; + q->z[i] += conjf(w_normal[nseq][j]) + * q->d[i * SRSLTE_PHICH_NORM_NSF + j] / SRSLTE_PHICH_NORM_NSF; } } } DEBUG("z: ", 0); - if (VERBOSE_ISDEBUG()) - vec_fprint_c(stdout, q->phich_z, PHICH_NBITS); + if (SRSLTE_VERBOSE_ISDEBUG()) + srslte_vec_fprint_c(stdout, q->z, SRSLTE_PHICH_NBITS); - demod_hard_demodulate(&q->demod, q->phich_z, q->data, PHICH_NBITS); + srslte_demod_hard_demodulate(&q->demod, q->z, q->data, SRSLTE_PHICH_NBITS); if (ack) { - *ack = phich_ack_decode(q->data, distance); + *ack = srslte_phich_ack_decode(q->data, distance); } return SRSLTE_SUCCESS; } /** Encodes ACK/NACK bits, modulates and inserts into resource. - * The parameter ack is an array of phich_ngroups() pointers to buffers of nof_sequences uint8_ts + * The parameter ack is an array of srslte_phich_ngroups() pointers to buffers of nof_sequences uint8_ts */ -int phich_encode(phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32_t subframe, +int srslte_phich_encode(srslte_phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32_t subframe, cf_t *slot_symbols[SRSLTE_MAX_PORTS]) { int i; @@ -301,7 +301,7 @@ int phich_encode(phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32 return SRSLTE_ERROR_INVALID_INPUTS; } } - if (ngroup >= regs_phich_ngroups(q->regs)) { + if (ngroup >= srslte_regs_phich_ngroups(q->regs)) { fprintf(stderr, "Invalid ngroup %d\n", ngroup); return SRSLTE_ERROR_INVALID_INPUTS; } @@ -313,78 +313,78 @@ int phich_encode(phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32 /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { - x[i] = q->phich_x[i]; + x[i] = q->x[i]; } for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - symbols_precoding[i] = q->phich_symbols[i]; + symbols_precoding[i] = q->symbols[i]; } /* encode ACK/NACK bit */ - phich_ack_encode(ack, q->data); + srslte_phich_ack_encode(ack, q->data); - mod_modulate(&q->mod, q->data, q->phich_z, PHICH_NBITS); + srslte_mod_modulate(&q->mod, q->data, q->z, SRSLTE_PHICH_NBITS); DEBUG("data: ", 0); - if (VERBOSE_ISDEBUG()) - vec_fprint_c(stdout, q->phich_z, PHICH_NBITS); + if (SRSLTE_VERBOSE_ISDEBUG()) + srslte_vec_fprint_c(stdout, q->z, SRSLTE_PHICH_NBITS); /* Spread with w */ 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]; + q->d[i] = w_ext[nseq][i % SRSLTE_PHICH_EXT_NSF] + * q->z[i / SRSLTE_PHICH_EXT_NSF]; } } else { 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]; + q->d[i] = w_normal[nseq][i % SRSLTE_PHICH_NORM_NSF] + * q->z[i / SRSLTE_PHICH_NORM_NSF]; } } DEBUG("d: ", 0); - if (VERBOSE_ISDEBUG()) - vec_fprint_c(stdout, q->phich_d, SRSLTE_PHICH_EXT_MSYMB); + if (SRSLTE_VERBOSE_ISDEBUG()) + srslte_vec_fprint_c(stdout, q->d, SRSLTE_PHICH_EXT_MSYMB); - scrambling_c(&q->seq_phich[subframe], q->phich_d); + srslte_scrambling_c(&q->seq[subframe], q->d); /* align to REG */ if (SRSLTE_CP_ISEXT(q->cell.cp)) { if (ngroup % 2) { 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]; + q->d0[4 * i + 0] = 0; + q->d0[4 * i + 1] = 0; + q->d0[4 * i + 2] = q->d[2 * i]; + q->d0[4 * i + 3] = q->d[2 * i + 1]; } } else { 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; - q->phich_d0[4 * i + 3] = 0; + q->d0[4 * i + 0] = q->d[2 * i]; + q->d0[4 * i + 1] = q->d[2 * i + 1]; + q->d0[4 * i + 2] = 0; + q->d0[4 * i + 3] = 0; } } } else { - memcpy(q->phich_d0, q->phich_d, PHICH_SRSLTE_MAX_NSYMB * sizeof(cf_t)); + memcpy(q->d0, q->d, SRSLTE_PHICH_MAX_NSYMB * sizeof(cf_t)); } DEBUG("d0: ", 0); - if (VERBOSE_ISDEBUG()) - vec_fprint_c(stdout, q->phich_d0, PHICH_SRSLTE_MAX_NSYMB); + if (SRSLTE_VERBOSE_ISDEBUG()) + srslte_vec_fprint_c(stdout, q->d0, SRSLTE_PHICH_MAX_NSYMB); /* layer mapping & precoding */ if (q->cell.nof_ports > 1) { - srslte_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_SRSLTE_MAX_NSYMB / q->cell.nof_ports); + srslte_layermap_diversity(q->d0, x, q->cell.nof_ports, SRSLTE_PHICH_MAX_NSYMB); + srslte_precoding_diversity(&q->precoding, x, symbols_precoding, q->cell.nof_ports, + SRSLTE_PHICH_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_SRSLTE_MAX_NSYMB * sizeof(cf_t)); + memcpy(q->symbols[0], q->d0, SRSLTE_PHICH_MAX_NSYMB * sizeof(cf_t)); } /* mapping to resource elements */ for (i = 0; i < q->cell.nof_ports; i++) { - if (regs_phich_add(q->regs, q->phich_symbols[i], ngroup, slot_symbols[i]) + if (srslte_regs_phich_add(q->regs, q->symbols[i], ngroup, slot_symbols[i]) < 0) { fprintf(stderr, "Error putting PCHICH resource elements\n"); return SRSLTE_ERROR; diff --git a/srslte/lib/phch/src/prach.c b/srslte/lib/phch/src/prach.c index f5b72882f..c32305dbd 100644 --- a/srslte/lib/phch/src/prach.c +++ b/srslte/lib/phch/src/prach.c @@ -31,6 +31,10 @@ #include "srslte/utils/debug.h" #include "srslte/utils/vector.h" + +//PRACH detection threshold is PRACH_DETECT_FACTOR*average +#define PRACH_DETECT_FACTOR 10 + #define N_SEQS 64 // Number of prach sequences available #define N_RB_SC 12 // Number of subcarriers per resource block #define DELTA_F 15000 // Normal subcarrier spacing @@ -178,7 +182,7 @@ uint32_t prach_get_rb_ul(uint32_t N_ifft_ul) } } -int prach_gen_seqs(prach_t *p) +int srslte_prach_gen_seqs(srslte_prach_t *p) { uint32_t u = 0; uint32_t v = 1; @@ -273,7 +277,7 @@ int prach_gen_seqs(prach_t *p) return 0; } -int prach_init(prach_t *p, +int srslte_prach_init(srslte_prach_t *p, uint32_t N_ifft_ul, uint32_t preamble_format, uint32_t root_seq_index, @@ -307,32 +311,32 @@ int prach_init(prach_t *p, } // Set up containers - p->prach_bins = vec_malloc(sizeof(cf_t)*p->N_zc); - p->corr_spec = vec_malloc(sizeof(cf_t)*p->N_zc); - p->corr = vec_malloc(sizeof(float)*p->N_zc); + p->prach_bins = srslte_vec_malloc(sizeof(cf_t)*p->N_zc); + p->corr_spec = srslte_vec_malloc(sizeof(cf_t)*p->N_zc); + p->corr = srslte_vec_malloc(sizeof(float)*p->N_zc); // Set up ZC FFTS - p->zc_fft = (srslte_dft_plan_t*)vec_malloc(sizeof(srslte_dft_plan_t)); - if(dft_plan(p->zc_fft, p->N_zc, FORWARD, COMPLEX)){ + p->zc_fft = (srslte_dft_plan_t*)srslte_vec_malloc(sizeof(srslte_dft_plan_t)); + if(srslte_dft_plan(p->zc_fft, p->N_zc, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)){ return SRSLTE_ERROR; } - dft_plan_set_mirror(p->zc_fft, false); - dft_plan_set_norm(p->zc_fft, false); + srslte_dft_plan_set_mirror(p->zc_fft, false); + srslte_dft_plan_set_norm(p->zc_fft, false); - p->zc_ifft = (srslte_dft_plan_t*)vec_malloc(sizeof(srslte_dft_plan_t)); - if(dft_plan(p->zc_ifft, p->N_zc, BACKWARD, COMPLEX)){ + p->zc_ifft = (srslte_dft_plan_t*)srslte_vec_malloc(sizeof(srslte_dft_plan_t)); + if(srslte_dft_plan(p->zc_ifft, p->N_zc, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)){ return SRSLTE_ERROR; } - dft_plan_set_mirror(p->zc_ifft, false); - dft_plan_set_norm(p->zc_ifft, false); + srslte_dft_plan_set_mirror(p->zc_ifft, false); + srslte_dft_plan_set_norm(p->zc_ifft, false); // Generate our 64 sequences p->N_roots = 0; - prach_gen_seqs(p); + srslte_prach_gen_seqs(p); // Generate sequence FFTs for(int i=0;izc_fft, p->seqs[i], p->dft_seqs[i]); + srslte_dft_run(p->zc_fft, p->seqs[i], p->dft_seqs[i]); } // Create our FFT objects and buffers @@ -343,21 +347,21 @@ int prach_init(prach_t *p, p->N_ifft_prach = p->N_ifft_ul * DELTA_F/DELTA_F_RA; } - p->ifft_in = (cf_t*)vec_malloc(p->N_ifft_prach*sizeof(cf_t)); - p->ifft_out = (cf_t*)vec_malloc(p->N_ifft_prach*sizeof(cf_t)); - p->ifft = (srslte_dft_plan_t*)vec_malloc(sizeof(srslte_dft_plan_t)); - if(dft_plan(p->ifft, p->N_ifft_prach, BACKWARD, COMPLEX)){ + p->ifft_in = (cf_t*)srslte_vec_malloc(p->N_ifft_prach*sizeof(cf_t)); + p->ifft_out = (cf_t*)srslte_vec_malloc(p->N_ifft_prach*sizeof(cf_t)); + p->ifft = (srslte_dft_plan_t*)srslte_vec_malloc(sizeof(srslte_dft_plan_t)); + if(srslte_dft_plan(p->ifft, p->N_ifft_prach, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)){ return -1; } - dft_plan_set_mirror(p->ifft, true); - dft_plan_set_norm(p->ifft, true); + srslte_dft_plan_set_mirror(p->ifft, true); + srslte_dft_plan_set_norm(p->ifft, true); - p->fft = (srslte_dft_plan_t*)vec_malloc(sizeof(srslte_dft_plan_t)); - if(dft_plan(p->fft, p->N_ifft_prach, FORWARD, COMPLEX)){ + p->fft = (srslte_dft_plan_t*)srslte_vec_malloc(sizeof(srslte_dft_plan_t)); + if(srslte_dft_plan(p->fft, p->N_ifft_prach, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)){ return -1; } - dft_plan_set_mirror(p->fft, true); - dft_plan_set_norm(p->fft, true); + srslte_dft_plan_set_mirror(p->fft, true); + srslte_dft_plan_set_norm(p->fft, true); p->N_seq = prach_Tseq[p->f]*p->N_ifft_ul/2048; p->N_cp = prach_Tcp[p->f]*p->N_ifft_ul/2048; @@ -368,7 +372,7 @@ int prach_init(prach_t *p, return ret; } -int prach_gen(prach_t *p, +int srslte_prach_gen(srslte_prach_t *p, uint32_t seq_index, uint32_t freq_offset, float beta_prach, @@ -391,7 +395,7 @@ int prach_gen(prach_t *p, memcpy(&p->ifft_in[begin], p->dft_seqs[seq_index], p->N_zc * sizeof(cf_t)); memset(&p->ifft_in[begin+p->N_zc], 0, (p->N_ifft_prach - begin - p->N_zc) * sizeof(cf_t)); - dft_run(p->ifft, p->ifft_in, p->ifft_out); + srslte_dft_run(p->ifft, p->ifft_in, p->ifft_out); // Copy CP into buffer memcpy(signal, &p->ifft_out[p->N_ifft_prach-p->N_cp], p->N_cp*sizeof(cf_t)); @@ -402,7 +406,7 @@ int prach_gen(prach_t *p, } // Normalize - vec_sc_prod_cfc(signal, beta_prach, signal, (p->N_cp + p->N_seq)); + srslte_vec_sc_prod_cfc(signal, beta_prach, signal, (p->N_cp + p->N_seq)); ret = SRSLTE_SUCCESS; } @@ -411,7 +415,7 @@ int prach_gen(prach_t *p, } -int prach_detect(prach_t *p, +int srslte_prach_detect(srslte_prach_t *p, uint32_t freq_offset, cf_t *signal, uint32_t sig_len, @@ -425,12 +429,12 @@ int prach_detect(prach_t *p, indices != NULL) { if(sig_len != p->N_ifft_prach){ - INFO("prach_detect: Signal is not of length %d", p->N_ifft_prach); + INFO("srslte_prach_detect: Signal is not of length %d", p->N_ifft_prach); return SRSLTE_ERROR_INVALID_INPUTS; } // FFT incoming signal - dft_run(p->fft, signal, signal); + srslte_dft_run(p->fft, signal, signal); memset(p->prach_bins, 0, sizeof(cf_t)*p->N_zc); *n_indices = 0; @@ -457,7 +461,7 @@ int prach_detect(prach_t *p, p->corr_spec[j] = p->prach_bins[j]*conjf(root_spec[j]); } - dft_run(p->zc_ifft, p->corr_spec, p->corr_spec); + srslte_dft_run(p->zc_ifft, p->corr_spec, p->corr_spec); float norm = sqrtf(p->N_zc); for(int j=0;jN_zc;j++){ @@ -494,27 +498,27 @@ int prach_detect(prach_t *p, return ret; } -int prach_free(prach_t *p) { +int srslte_prach_free(srslte_prach_t *p) { free(p->prach_bins); free(p->corr_spec); free(p->corr); - dft_plan_free(p->ifft); + srslte_dft_plan_free(p->ifft); free(p->ifft); free(p->ifft_in); free(p->ifft_out); - dft_plan_free(p->fft); + srslte_dft_plan_free(p->fft); free(p->fft); - dft_plan_free(p->zc_fft); + srslte_dft_plan_free(p->zc_fft); free(p->zc_fft); - dft_plan_free(p->zc_ifft); + srslte_dft_plan_free(p->zc_ifft); free(p->zc_ifft); - bzero(p, sizeof(prach_t)); + bzero(p, sizeof(srslte_prach_t)); return 0; } -int prach_print_seqs(prach_t *p) +int srslte_prach_print_seqs(srslte_prach_t *p) { for(int i=0; icell = cell; - if (generate_n_cs_cell(q->cell, q->n_cs_cell)) { + if (srslte_generate_n_cs_cell(q->cell, q->n_cs_cell)) { return SRSLTE_ERROR; } @@ -136,13 +136,13 @@ int pucch_init(pucch_t *q, srslte_cell_t cell) { return ret; } -void pucch_free(pucch_t *q) { - bzero(q, sizeof(pucch_t)); +void srslte_pucch_free(srslte_pucch_t *q) { + bzero(q, sizeof(srslte_pucch_t)); } /** Decodes the PUSCH from the received symbols */ -int pucch_decode(pucch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce, float noise_estimate, uint8_t *data) +int pucch_decode(srslte_pucch_t *q, srslte_harq_t *harq, cf_t *sf_symbols, cf_t *ce, float noise_estimate, uint8_t *data) { return SRSLTE_ERROR_INVALID_INPUTS; } @@ -171,18 +171,18 @@ static cf_t uci_encode_format1b(uint8_t bits[2]) { } } -static void uci_mod_bits(pucch_t *q, pucch_cfg_t *cfg, uint8_t bits[PUCCH_MAX_BITS]) +static void uci_mod_bits(srslte_pucch_t *q, srslte_pucch_cfg_t *cfg, uint8_t bits[SRSLTE_PUCCH_MAX_BITS]) { cf_t d_0 = 0; uint8_t tmp[2]; switch(cfg->format) { - case PUCCH_FORMAT_1: + case SRSLTE_PUCCH_FORMAT_1: d_0 = uci_encode_format1(); break; - case PUCCH_FORMAT_1A: + case SRSLTE_PUCCH_FORMAT_1A: d_0 = uci_encode_format1a(bits[0]); break; - case PUCCH_FORMAT_1B: + case SRSLTE_PUCCH_FORMAT_1B: tmp[0] = bits[0]; tmp[1] = bits[1]; d_0 = uci_encode_format1b(tmp); @@ -191,13 +191,13 @@ static void uci_mod_bits(pucch_t *q, pucch_cfg_t *cfg, uint8_t bits[PUCCH_MAX_BI return; } /* - for (uint32_t n=0;ny[n] = d_0+ } */ } -int pucch_encode(pucch_t *q, pucch_cfg_t *cfg, uint8_t bits[PUCCH_MAX_BITS], cf_t *sf_symbols) +int srslte_pucch_encode(srslte_pucch_t *q, srslte_pucch_cfg_t *cfg, uint8_t bits[SRSLTE_PUCCH_MAX_BITS], cf_t *sf_symbols) { uci_mod_bits(q, cfg, bits); return SRSLTE_ERROR; diff --git a/srslte/lib/phch/src/pusch.c b/srslte/lib/phch/src/pusch.c index 7263545f2..ce3597989 100644 --- a/srslte/lib/phch/src/pusch.c +++ b/srslte/lib/phch/src/pusch.c @@ -40,16 +40,16 @@ #include "srslte/utils/bit.h" #include "srslte/utils/debug.h" #include "srslte/utils/vector.h" -#include "srslte/filter/dft_precoding.h" +#include "srslte/dft/dft_precoding.h" #define MAX_PUSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12) const static srslte_mod_t modulations[4] = - { LTE_BPSK, LTE_QPSK, LTE_QAM16, LTE_QAM64 }; + { SRSLTE_MOD_BPSK, SRSLTE_MOD_QPSK, SRSLTE_MOD_16QAM, SRSLTE_MOD_64QAM }; -static int f_hop_sum(pusch_t *q, uint32_t i) { +static int f_hop_sum(srslte_pusch_t *q, uint32_t i) { uint32_t sum = 0; for (uint32_t k=i*10+1;kseq_type2_fo.c[k]<<(k-(i*10+1))); @@ -57,7 +57,7 @@ static int f_hop_sum(pusch_t *q, uint32_t i) { return sum; } -static int f_hop(pusch_t *q, pusch_hopping_cfg_t *hopping, int i) { +static int f_hop(srslte_pusch_t *q, srslte_pusch_hopping_cfg_t *hopping, int i) { if (i == -1) { return 0; } else { @@ -71,9 +71,9 @@ static int f_hop(pusch_t *q, pusch_hopping_cfg_t *hopping, int i) { } } -static int f_m(pusch_t *q, pusch_hopping_cfg_t *hopping, uint32_t i) { +static int f_m(srslte_pusch_t *q, srslte_pusch_hopping_cfg_t *hopping, uint32_t i) { if (hopping->n_sb == 1) { - if (hopping->hop_mode == hop_mode_inter_sf) { + if (hopping->hop_mode == SRSLTE_PUSCH_HOP_MODE_INTER_SF) { return hopping->current_tx_nb%2; } else { return i%2; @@ -83,11 +83,11 @@ static int f_m(pusch_t *q, pusch_hopping_cfg_t *hopping, uint32_t i) { } } -int pusch_cp(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output, bool advance_input) +int pusch_cp(srslte_pusch_t *q, srslte_harq_t *harq, cf_t *input, cf_t *output, bool advance_input) { cf_t *in_ptr = input; cf_t *out_ptr = output; - pusch_hopping_cfg_t *hopping = &q->hopping_cfg; + srslte_pusch_hopping_cfg_t *hopping = &q->hopping_cfg; uint32_t L_ref = 3; if (SRSLTE_CP_ISEXT(q->cell.cp)) { @@ -97,7 +97,7 @@ int pusch_cp(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output, bool advance_i for (uint32_t slot=0;slot<2;slot++) { uint32_t n_prb_tilde = harq->ul_alloc.n_prb[slot]; if (harq->ul_alloc.freq_hopping == 1) { - if (hopping->hop_mode == hop_mode_inter_sf) { + if (hopping->hop_mode == SRSLTE_PUSCH_HOP_MODE_INTER_SF) { n_prb_tilde = harq->ul_alloc.n_prb[hopping->current_tx_nb%2]; } else { n_prb_tilde = harq->ul_alloc.n_prb[slot]; @@ -110,7 +110,7 @@ int pusch_cp(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output, bool advance_i n_vrb_tilde -= (hopping->hopping_offset-1)/2+1; } int i=0; - if (hopping->hop_mode == hop_mode_inter_sf) { + if (hopping->hop_mode == SRSLTE_PUSCH_HOP_MODE_INTER_SF) { i = harq->sf_idx; } else { i = 2*harq->sf_idx+slot; @@ -152,17 +152,17 @@ int pusch_cp(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output, bool advance_i return SRSLTE_NRE*harq->ul_alloc.L_prb; } -int pusch_put(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output) { +int pusch_put(srslte_pusch_t *q, srslte_harq_t *harq, cf_t *input, cf_t *output) { return pusch_cp(q, harq, input, output, true); } -int pusch_get(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output) { +int get(srslte_pusch_t *q, srslte_harq_t *harq, cf_t *input, cf_t *output) { return pusch_cp(q, harq, input, output, false); } /** Initializes the PDCCH transmitter and receiver */ -int pusch_init(pusch_t *q, srslte_cell_t cell) { +int srslte_pusch_init(srslte_pusch_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; int i; @@ -170,7 +170,7 @@ int pusch_init(pusch_t *q, srslte_cell_t cell) { srslte_cell_isvalid(&cell)) { - bzero(q, sizeof(pusch_t)); + bzero(q, sizeof(srslte_pusch_t)); ret = SRSLTE_ERROR; q->cell = cell; @@ -180,7 +180,7 @@ int pusch_init(pusch_t *q, srslte_cell_t cell) { q->cell.nof_prb, q->max_re); for (i = 0; i < 4; i++) { - if (modem_table_lte(&q->mod[i], modulations[i], true)) { + if (srslte_modem_table_lte(&q->mod[i], modulations[i], true)) { goto clean; } } @@ -191,18 +191,18 @@ int pusch_init(pusch_t *q, srslte_cell_t cell) { goto clean; } - demod_soft_init(&q->demod, q->max_re); - demod_soft_alg_set(&q->demod, APPROX); + srslte_demod_soft_init(&q->demod, q->max_re); + srslte_demod_soft_alg_set(&q->demod, SRSLTE_DEMOD_SOFT_ALG_APPROX); - sch_init(&q->dl_sch); + srslte_sch_init(&q->dl_sch); - if (srslte_srslte_dft_precoding_init(&q->srslte_dft_precoding, cell.nof_prb)) { + if (srslte_dft_precoding_init(&q->dft_precoding, cell.nof_prb)) { fprintf(stderr, "Error initiating DFT transform precoding\n"); goto clean; } /* This is for equalization at receiver */ - if (precoding_init(&q->equalizer, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { + if (srslte_precoding_init(&q->equalizer, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); goto clean; } @@ -210,27 +210,27 @@ 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 * srslte_mod_bits_x_symbol(LTE_QAM64)); - if (!q->pusch_q) { + q->q = srslte_vec_malloc(sizeof(float) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM)); + if (!q->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 * srslte_mod_bits_x_symbol(LTE_QAM64)); - if (!q->pusch_g) { + q->g = srslte_vec_malloc(sizeof(float) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM)); + if (!q->g) { goto clean; } - q->pusch_d = vec_malloc(sizeof(cf_t) * q->max_re); - if (!q->pusch_d) { + q->d = srslte_vec_malloc(sizeof(cf_t) * q->max_re); + if (!q->d) { goto clean; } - q->ce = vec_malloc(sizeof(cf_t) * q->max_re); + q->ce = srslte_vec_malloc(sizeof(cf_t) * q->max_re); if (!q->ce) { goto clean; } - q->pusch_z = vec_malloc(sizeof(cf_t) * q->max_re); - if (!q->pusch_z) { + q->z = srslte_vec_malloc(sizeof(cf_t) * q->max_re); + if (!q->z) { goto clean; } @@ -238,62 +238,62 @@ int pusch_init(pusch_t *q, srslte_cell_t cell) { } clean: if (ret == SRSLTE_ERROR) { - pusch_free(q); + srslte_pusch_free(q); } return ret; } -void pusch_free(pusch_t *q) { +void srslte_pusch_free(srslte_pusch_t *q) { int i; - if (q->pusch_q) { - free(q->pusch_q); + if (q->q) { + free(q->q); } - if (q->pusch_d) { - free(q->pusch_d); + if (q->d) { + free(q->d); } - if (q->pusch_g) { - free(q->pusch_g); + if (q->g) { + free(q->g); } if (q->ce) { free(q->ce); } - if (q->pusch_z) { - free(q->pusch_z); + if (q->z) { + free(q->z); } - srslte_srslte_dft_precoding_free(&q->srslte_dft_precoding); + srslte_dft_precoding_free(&q->dft_precoding); - precoding_free(&q->equalizer); + srslte_precoding_free(&q->equalizer); for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - srslte_sequence_free(&q->seq_pusch[i]); + srslte_sequence_free(&q->seq[i]); } for (i = 0; i < 4; i++) { - modem_table_free(&q->mod[i]); + srslte_modem_table_free(&q->mod[i]); } - demod_soft_free(&q->demod); - sch_free(&q->dl_sch); + srslte_demod_soft_free(&q->demod); + srslte_sch_free(&q->dl_sch); - bzero(q, sizeof(pusch_t)); + bzero(q, sizeof(srslte_pusch_t)); } -void pusch_set_hopping_cfg(pusch_t *q, pusch_hopping_cfg_t *cfg) +void srslte_pusch_set_hopping_cfg(srslte_pusch_t *q, srslte_pusch_hopping_cfg_t *cfg) { - memcpy(&q->hopping_cfg, cfg, sizeof(pusch_hopping_cfg_t)); + memcpy(&q->hopping_cfg, cfg, sizeof(srslte_pusch_hopping_cfg_t)); } /* Precalculate the PUSCH scramble sequences for a given RNTI. This function takes a while * to execute, so shall be called once the final C-RNTI has been allocated for the session. - * For the connection procedure, use pusch_encode_rnti() or pusch_decode_rnti() functions */ -int pusch_set_rnti(pusch_t *q, uint16_t rnti) { + * For the connection procedure, use srslte_pusch_encode_rnti() or srslte_pusch_decode_rnti() functions */ +int srslte_pusch_set_rnti(srslte_pusch_t *q, uint16_t rnti) { uint32_t i; for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - if (srslte_sequence_pusch(&q->seq_pusch[i], rnti, 2 * i, q->cell.id, - q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64))) { + if (srslte_sequence_pusch(&q->seq[i], rnti, 2 * i, q->cell.id, + q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { return SRSLTE_ERROR; } } @@ -304,7 +304,7 @@ int pusch_set_rnti(pusch_t *q, uint16_t rnti) { /** Decodes the PUSCH from the received symbols */ -int pusch_decode(pusch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce, float noise_estimate, uint8_t *data) +int srslte_pusch_decode(srslte_pusch_t *q, srslte_harq_t *harq, cf_t *sf_symbols, cf_t *ce, float noise_estimate, uint8_t *data) { uint32_t n; @@ -320,39 +320,39 @@ int pusch_decode(pusch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce, float noi 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); + n = get(q, harq, sf_symbols, q->d); if (n != harq->nof_re) { fprintf(stderr, "Error expecting %d symbols but got %d\n", harq->nof_re, n); return SRSLTE_ERROR; } /* extract channel estimates */ - n = pusch_get(q, harq, ce, q->ce); + n = get(q, harq, ce, q->ce); if (n != harq->nof_re) { fprintf(stderr, "Error expecting %d symbols but got %d\n", harq->nof_re, n); return SRSLTE_ERROR; } - predecoding_single(&q->equalizer, q->pusch_d, q->ce, q->pusch_z, + srslte_predecoding_single(&q->equalizer, q->d, q->ce, q->z, harq->nof_re, noise_estimate); - srslte_dft_predecoding(&q->srslte_dft_precoding, q->pusch_z, q->pusch_d, + srslte_dft_predecoding(&q->dft_precoding, q->z, q->d, harq->ul_alloc.L_prb, harq->nof_symb); /* demodulate symbols * The MAX-log-MAP algorithm used in turbo decoding is unsensitive to SNR estimation, * thus we don't need tot set it in the LLRs normalization */ - demod_soft_sigma_set(&q->demod, sqrt(0.5)); - demod_soft_table_set(&q->demod, &q->mod[harq->mcs.mod]); - demod_soft_demodulate(&q->demod, q->pusch_d, q->pusch_q, harq->nof_re); + srslte_demod_soft_sigma_set(&q->demod, sqrt(0.5)); + srslte_demod_soft_table_set(&q->demod, &q->mod[harq->mcs.mod]); + srslte_demod_soft_demodulate(&q->demod, q->d, q->q, harq->nof_re); /* descramble */ - scrambling_f_offset(&q->seq_pusch[harq->sf_idx], q->pusch_q, 0, harq->nof_bits); + srslte_scrambling_f_offset(&q->seq[harq->sf_idx], q->q, 0, harq->nof_bits); - return ulsch_decode(&q->dl_sch, harq, q->pusch_q, data); + return srslte_ulsch_decode(&q->dl_sch, harq, q->q, data); } else { - fprintf(stderr, "Must call pusch_set_rnti() before calling pusch_decode()\n"); + fprintf(stderr, "Must call srslte_pusch_set_rnti() before calling srslte_pusch_decode()\n"); return SRSLTE_ERROR; } } else { @@ -360,38 +360,38 @@ int pusch_decode(pusch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce, float noi } } -int pusch_encode_rnti(pusch_t *q, harq_t *harq_process, uint8_t *data, uint16_t rnti, cf_t *sf_symbols) +int srslte_pusch_encode_rnti(srslte_pusch_t *q, srslte_harq_t *harq_process, uint8_t *data, uint16_t rnti, cf_t *sf_symbols) { - uci_data_t uci_data; - bzero(&uci_data, sizeof(uci_data_t)); - return pusch_uci_encode_rnti(q, harq_process, data, uci_data, rnti, sf_symbols); + srslte_uci_data_t uci_data; + bzero(&uci_data, sizeof(srslte_uci_data_t)); + return srslte_pusch_uci_encode_rnti(q, harq_process, data, uci_data, rnti, sf_symbols); } -int pusch_encode(pusch_t *q, harq_t *harq_process, uint8_t *data, cf_t *sf_symbols) +int srslte_pusch_encode(srslte_pusch_t *q, srslte_harq_t *harq_process, uint8_t *data, cf_t *sf_symbols) { if (q->rnti_is_set) { - uci_data_t uci_data; - bzero(&uci_data, sizeof(uci_data_t)); - return pusch_uci_encode_rnti(q, harq_process, data, uci_data, q->rnti, sf_symbols); + srslte_uci_data_t uci_data; + bzero(&uci_data, sizeof(srslte_uci_data_t)); + return srslte_pusch_uci_encode_rnti(q, harq_process, data, uci_data, q->rnti, sf_symbols); } else { - fprintf(stderr, "Must call pusch_set_rnti() to set the encoder/decoder RNTI\n"); + fprintf(stderr, "Must call srslte_pusch_set_rnti() to set the encoder/decoder RNTI\n"); return SRSLTE_ERROR; } } -int pusch_uci_encode(pusch_t *q, harq_t *harq, uint8_t *data, uci_data_t uci_data, cf_t *sf_symbols) +int srslte_pusch_uci_encode(srslte_pusch_t *q, srslte_harq_t *harq, uint8_t *data, srslte_uci_data_t uci_data, cf_t *sf_symbols) { if (q->rnti_is_set) { - return pusch_uci_encode_rnti(q, harq, data, uci_data, q->rnti, sf_symbols); + return srslte_pusch_uci_encode_rnti(q, harq, data, uci_data, q->rnti, sf_symbols); } else { - fprintf(stderr, "Must call pusch_set_rnti() to set the encoder/decoder RNTI\n"); + fprintf(stderr, "Must call srslte_pusch_set_rnti() to set the encoder/decoder RNTI\n"); return SRSLTE_ERROR; } } /** Converts the PUSCH data bits to symbols mapped to the slot ready for transmission */ -int pusch_uci_encode_rnti(pusch_t *q, harq_t *harq, uint8_t *data, uci_data_t uci_data, uint16_t rnti, cf_t *sf_symbols) +int srslte_pusch_uci_encode_rnti(srslte_pusch_t *q, srslte_harq_t *harq, uint8_t *data, srslte_uci_data_t uci_data, uint16_t rnti, cf_t *sf_symbols) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -413,8 +413,8 @@ 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, 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)) { + bzero(q->q, harq->nof_bits); + if (srslte_ulsch_uci_encode(&q->dl_sch, harq, data, uci_data, q->g, q->q)) { fprintf(stderr, "Error encoding TB\n"); return SRSLTE_ERROR; } @@ -424,19 +424,19 @@ int pusch_uci_encode_rnti(pusch_t *q, harq_t *harq, uint8_t *data, uci_data_t uc if (srslte_sequence_pusch(&seq, rnti, 2 * harq->sf_idx, q->cell.id, harq->nof_bits)) { return SRSLTE_ERROR; } - scrambling_b_offset_pusch(&seq, (uint8_t*) q->pusch_q, 0, harq->nof_bits); + srslte_scrambling_b_offset_pusch(&seq, (uint8_t*) q->q, 0, harq->nof_bits); srslte_sequence_free(&seq); } else { - scrambling_b_offset_pusch(&q->seq_pusch[harq->sf_idx], (uint8_t*) q->pusch_q, 0, harq->nof_bits); + srslte_scrambling_b_offset_pusch(&q->seq[harq->sf_idx], (uint8_t*) q->q, 0, harq->nof_bits); } - mod_modulate(&q->mod[harq->mcs.mod], (uint8_t*) q->pusch_q, q->pusch_d, harq->nof_bits); + srslte_mod_modulate(&q->mod[harq->mcs.mod], (uint8_t*) q->q, q->d, harq->nof_bits); - srslte_dft_precoding(&q->srslte_dft_precoding, q->pusch_d, q->pusch_z, + srslte_dft_precoding(&q->dft_precoding, q->d, q->z, harq->ul_alloc.L_prb, harq->nof_symb); /* mapping to resource elements */ - pusch_put(q, harq, q->pusch_z, sf_symbols); + pusch_put(q, harq, q->z, sf_symbols); ret = SRSLTE_SUCCESS; } diff --git a/srslte/lib/phch/src/ra.c b/srslte/lib/phch/src/ra.c index b81f4fe8b..8c9794b5c 100644 --- a/srslte/lib/phch/src/ra.c +++ b/srslte/lib/phch/src/ra.c @@ -108,7 +108,7 @@ uint32_t ra_re_x_prb(uint32_t subframe, uint32_t slot, uint32_t prb_idx, uint32_ return re; } -void ra_prb_fprint(FILE *f, ra_prb_slot_t *prb, uint32_t nof_prb) { +void srslte_ra_prb_fprint(FILE *f, srslte_ra_prb_slot_t *prb, uint32_t nof_prb) { int i; if (prb->nof_prb > 0) { for (i=0;iL_prb = ra->type2_alloc.L_crb; uint32_t n_prb_1 = ra->type2_alloc.RB_start; uint32_t n_rb_pusch = 0; @@ -133,14 +133,14 @@ int ra_ul_alloc(ra_ul_alloc_t *prb_dist, ra_pusch_t *ra, uint32_t n_rb_ho, uint3 n_rb_ho++; } - if (ra->freq_hop_fl == hop_disabled || ra->freq_hop_fl == hop_type_2) { + if (ra->freq_hop_fl == SRSLTE_RA_PUSCH_HOP_DISABLED || ra->freq_hop_fl == SRSLTE_RA_PUSCH_HOP_TYPE2) { /* For no freq hopping or type2 freq hopping, n_prb is the same * n_prb_tilde is calculated during resource mapping */ for (uint32_t i=0;i<2;i++) { prb_dist->n_prb[i] = n_prb_1; } - if (ra->freq_hop_fl == hop_disabled) { + if (ra->freq_hop_fl == SRSLTE_RA_PUSCH_HOP_DISABLED) { prb_dist->freq_hopping = 0; } else { prb_dist->freq_hopping = 2; @@ -161,17 +161,17 @@ int ra_ul_alloc(ra_ul_alloc_t *prb_dist, ra_pusch_t *ra, uint32_t n_rb_ho, uint3 // prb idx for slot 1 switch(ra->freq_hop_fl) { - case hop_quart: + case SRSLTE_RA_PUSCH_HOP_QUART: prb_dist->n_prb[1] = (n_rb_pusch/4+ n_prb_1_tilde)%n_rb_pusch; break; - case hop_quart_neg: + case SRSLTE_RA_PUSCH_HOP_QUART_NEG: if (n_prb_1 < n_rb_pusch/4) { prb_dist->n_prb[1] = (n_rb_pusch+ n_prb_1_tilde -n_rb_pusch/4); } else { prb_dist->n_prb[1] = (n_prb_1_tilde -n_rb_pusch/4); } break; - case hop_half: + case SRSLTE_RA_PUSCH_HOP_HALF: prb_dist->n_prb[1] = (n_rb_pusch/2+ n_prb_1_tilde)%n_rb_pusch; break; default: @@ -184,7 +184,7 @@ int ra_ul_alloc(ra_ul_alloc_t *prb_dist, ra_pusch_t *ra, uint32_t n_rb_ho, uint3 } /* Computes the number of RE for each PRB in the prb_dist structure */ -void ra_dl_alloc_re(ra_dl_alloc_t *prb_dist, uint32_t nof_prb, uint32_t nof_ports, +void srslte_ra_dl_alloc_re(srslte_srslte_ra_dl_alloc_t *prb_dist, uint32_t nof_prb, uint32_t nof_ports, uint32_t nof_ctrl_symbols, srslte_cp_t cp) { uint32_t i, j, s; @@ -205,15 +205,15 @@ void ra_dl_alloc_re(ra_dl_alloc_t *prb_dist, uint32_t nof_prb, uint32_t nof_port } /** Compute PRB allocation for Downlink as defined in 7.1.6 of 36.213 */ -int ra_dl_alloc(ra_dl_alloc_t *prb_dist, ra_pdsch_t *ra, uint32_t nof_prb) { +int srslte_ra_dl_alloc(srslte_srslte_ra_dl_alloc_t *prb_dist, srslte_ra_pdsch_t *ra, uint32_t nof_prb) { int i, j; uint32_t bitmask; - uint32_t P = ra_type0_P(nof_prb); + uint32_t P = srslte_ra_type0_P(nof_prb); uint32_t n_rb_rbg_subset, n_rb_type1; - bzero(prb_dist, sizeof(ra_dl_alloc_t)); + bzero(prb_dist, sizeof(srslte_srslte_ra_dl_alloc_t)); switch (ra->alloc_type) { - case alloc_type0: + case SRSLTE_RA_ALLOC_TYPE0: bitmask = ra->type0_alloc.rbg_bitmask; int nb = (int) ceilf((float) nof_prb / P); for (i = 0; i < nb; i++) { @@ -226,10 +226,10 @@ int ra_dl_alloc(ra_dl_alloc_t *prb_dist, ra_pdsch_t *ra, uint32_t nof_prb) { } } } - memcpy(&prb_dist->slot[1], &prb_dist->slot[0], sizeof(ra_prb_slot_t)); + memcpy(&prb_dist->slot[1], &prb_dist->slot[0], sizeof(srslte_ra_prb_slot_t)); break; - case alloc_type1: - n_rb_type1 = ra_type1_N_rb(nof_prb); + case SRSLTE_RA_ALLOC_TYPE1: + n_rb_type1 = srslte_ra_type1_N_rb(nof_prb); if (ra->type1_alloc.rbg_subset < (nof_prb / P) % P) { n_rb_rbg_subset = ((nof_prb - 1) / (P * P)) * P + P; } else if (ra->type1_alloc.rbg_subset == ((nof_prb / P) % P)) { @@ -246,15 +246,15 @@ int ra_dl_alloc(ra_dl_alloc_t *prb_dist, ra_pdsch_t *ra, uint32_t nof_prb) { prb_dist->slot[0].nof_prb++; } } - memcpy(&prb_dist->slot[1], &prb_dist->slot[0], sizeof(ra_prb_slot_t)); + memcpy(&prb_dist->slot[1], &prb_dist->slot[0], sizeof(srslte_ra_prb_slot_t)); break; - case alloc_type2: - if (ra->type2_alloc.mode == t2_loc) { + case SRSLTE_RA_ALLOC_TYPE2: + if (ra->type2_alloc.mode == SRSLTE_RA_TYPE2_LOC) { for (i = 0; i < ra->type2_alloc.L_crb; i++) { prb_dist->slot[0].prb_idx[i + ra->type2_alloc.RB_start] = true; prb_dist->slot[0].nof_prb++; } - memcpy(&prb_dist->slot[1], &prb_dist->slot[0], sizeof(ra_prb_slot_t)); + memcpy(&prb_dist->slot[1], &prb_dist->slot[0], sizeof(srslte_ra_prb_slot_t)); } else { /* Mapping of Virtual to Physical RB for distributed type is defined in * 6.2.3.2 of 36.211 @@ -262,12 +262,12 @@ int ra_dl_alloc(ra_dl_alloc_t *prb_dist, ra_pdsch_t *ra, uint32_t nof_prb) { int N_gap, N_tilde_vrb, n_tilde_vrb, n_tilde_prb, n_tilde2_prb, N_null, N_row, n_vrb; int n_tilde_prb_odd, n_tilde_prb_even; - if (ra->type2_alloc.n_gap == t2_ng1) { - N_tilde_vrb = ra_type2_n_vrb_dl(nof_prb, true); - N_gap = ra_type2_ngap(nof_prb, true); + if (ra->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1) { + N_tilde_vrb = srslte_ra_type2_n_vrb_dl(nof_prb, true); + N_gap = srslte_ra_type2_ngap(nof_prb, true); } else { - N_tilde_vrb = 2 * ra_type2_n_vrb_dl(nof_prb, true); - N_gap = ra_type2_ngap(nof_prb, false); + N_tilde_vrb = 2 * srslte_ra_type2_n_vrb_dl(nof_prb, true); + N_gap = srslte_ra_type2_ngap(nof_prb, false); } N_row = (int) ceilf((float) N_tilde_vrb / (4 * P)) * P; N_null = 4 * N_row - N_tilde_vrb; @@ -319,19 +319,19 @@ int ra_dl_alloc(ra_dl_alloc_t *prb_dist, ra_pdsch_t *ra, uint32_t nof_prb) { } /* Returns the number of allocated PRB for Uplink */ -uint32_t ra_nprb_ul(ra_pusch_t *ra, uint32_t nof_prb) { +uint32_t srslte_ra_nprb_ul(srslte_ra_pusch_t *ra, uint32_t nof_prb) { return ra->type2_alloc.L_crb; } /* Returns the number of allocated PRB for Downlink */ -uint32_t ra_nprb_dl(ra_pdsch_t *ra, uint32_t nof_prb) { +uint32_t srslte_ra_nprb_dl(srslte_ra_pdsch_t *ra, uint32_t nof_prb) { uint32_t nprb; uint32_t nof_rbg, P; switch (ra->alloc_type) { - case alloc_type0: + case SRSLTE_RA_ALLOC_TYPE0: // Get the number of allocated RBG except the last RBG - nof_rbg = bit_count(ra->type0_alloc.rbg_bitmask & 0xFFFFFFFE); - P = ra_type0_P(nof_prb); + nof_rbg = srslte_bit_count(ra->type0_alloc.rbg_bitmask & 0xFFFFFFFE); + P = srslte_ra_type0_P(nof_prb); if (nof_rbg > (uint32_t) ceilf((float) nof_prb / P)) { nof_rbg = (uint32_t) ceilf((float) nof_prb / P) - 1; } @@ -343,15 +343,15 @@ uint32_t ra_nprb_dl(ra_pdsch_t *ra, uint32_t nof_prb) { P_last = P; nprb += P_last * (ra->type0_alloc.rbg_bitmask & 1); break; - case alloc_type1: - nprb = bit_count(ra->type1_alloc.vrb_bitmask); - if (nprb > ra_type1_N_rb(nof_prb)) { + case SRSLTE_RA_ALLOC_TYPE1: + nprb = srslte_bit_count(ra->type1_alloc.vrb_bitmask); + if (nprb > srslte_ra_type1_N_rb(nof_prb)) { fprintf(stderr, "Number of RB (%d) can not exceed %d\n", nprb, - ra_type1_N_rb(nof_prb)); + srslte_ra_type1_N_rb(nof_prb)); return SRSLTE_ERROR; } break; - case alloc_type2: + case SRSLTE_RA_ALLOC_TYPE2: nprb = ra->type2_alloc.L_crb; break; default: @@ -361,7 +361,7 @@ uint32_t ra_nprb_dl(ra_pdsch_t *ra, uint32_t nof_prb) { } /* RBG size for type0 scheduling as in table 7.1.6.1-1 of 36.213 */ -uint32_t ra_type0_P(uint32_t nof_prb) { +uint32_t srslte_ra_type0_P(uint32_t nof_prb) { if (nof_prb <= 10) { return 1; } else if (nof_prb <= 26) { @@ -374,13 +374,13 @@ uint32_t ra_type0_P(uint32_t nof_prb) { } /* Returns N_rb_type1 according to section 7.1.6.2 */ -uint32_t ra_type1_N_rb(uint32_t nof_prb) { - uint32_t P = ra_type0_P(nof_prb); +uint32_t srslte_ra_type1_N_rb(uint32_t nof_prb) { + uint32_t P = srslte_ra_type0_P(nof_prb); return (uint32_t) ceilf((float) nof_prb / P) - (uint32_t) ceilf(log2f((float) P)) - 1; } /* Convert Type2 scheduling L_crb and RB_start to RIV value */ -uint32_t ra_type2_to_riv(uint32_t L_crb, uint32_t RB_start, uint32_t nof_prb) { +uint32_t srslte_ra_type2_to_riv(uint32_t L_crb, uint32_t RB_start, uint32_t nof_prb) { uint32_t riv; if (L_crb <= nof_prb / 2) { riv = nof_prb * (L_crb - 1) + RB_start; @@ -391,7 +391,7 @@ uint32_t ra_type2_to_riv(uint32_t L_crb, uint32_t RB_start, uint32_t nof_prb) { } /* Convert Type2 scheduling RIV value to L_crb and RB_start values */ -void ra_type2_from_riv(uint32_t riv, uint32_t *L_crb, uint32_t *RB_start, +void srslte_ra_type2_from_riv(uint32_t riv, uint32_t *L_crb, uint32_t *RB_start, uint32_t nof_prb, uint32_t nof_vrb) { *L_crb = (uint32_t) (riv / nof_prb) + 1; *RB_start = (uint32_t) (riv % nof_prb); @@ -402,7 +402,7 @@ void ra_type2_from_riv(uint32_t riv, uint32_t *L_crb, uint32_t *RB_start, } /* Table 6.2.3.2-1 in 36.211 */ -uint32_t ra_type2_ngap(uint32_t nof_prb, bool ngap_is_1) { +uint32_t srslte_ra_type2_ngap(uint32_t nof_prb, bool ngap_is_1) { if (nof_prb <= 10) { return nof_prb / 2; } else if (nof_prb == 11) { @@ -425,7 +425,7 @@ uint32_t ra_type2_ngap(uint32_t nof_prb, bool ngap_is_1) { } /* Table 7.1.6.3-1 in 36.213 */ -uint32_t ra_type2_n_rb_step(uint32_t nof_prb) { +uint32_t srslte_ra_type2_n_rb_step(uint32_t nof_prb) { if (nof_prb < 50) { return 2; } else { @@ -434,8 +434,8 @@ uint32_t ra_type2_n_rb_step(uint32_t nof_prb) { } /* as defined in 6.2.3.2 of 36.211 */ -uint32_t ra_type2_n_vrb_dl(uint32_t nof_prb, bool ngap_is_1) { - uint32_t ngap = ra_type2_ngap(nof_prb, ngap_is_1); +uint32_t srslte_ra_type2_n_vrb_dl(uint32_t nof_prb, bool ngap_is_1) { + uint32_t ngap = srslte_ra_type2_ngap(nof_prb, ngap_is_1); if (ngap_is_1) { return 2 * (ngap < (nof_prb - ngap) ? ngap : nof_prb - ngap); } else { @@ -443,25 +443,25 @@ uint32_t ra_type2_n_vrb_dl(uint32_t nof_prb, bool ngap_is_1) { } } -/* Converts MCS index to ra_mcs_t structure for Downlink as defined inTable 7.1.7.1-1 on 36.213 */ -int ra_mcs_from_idx_dl(uint32_t mcs_idx, uint32_t nof_prb, ra_mcs_t *mcs) { +/* Converts MCS index to srslte_ra_mcs_t structure for Downlink as defined inTable 7.1.7.1-1 on 36.213 */ +int srslte_ra_mcs_from_idx_dl(uint32_t mcs_idx, uint32_t nof_prb, srslte_ra_mcs_t *mcs) { if (mcs_idx < 10) { - mcs->mod = LTE_QPSK; - mcs->tbs = ra_tbs_from_idx(mcs_idx, nof_prb); + mcs->mod = SRSLTE_MOD_QPSK; + mcs->tbs = srslte_ra_tbs_from_idx(mcs_idx, nof_prb); } else if (mcs_idx < 17) { - mcs->mod = LTE_QAM16; - mcs->tbs = ra_tbs_from_idx(mcs_idx - 1, nof_prb); + mcs->mod = SRSLTE_MOD_16QAM; + mcs->tbs = srslte_ra_tbs_from_idx(mcs_idx - 1, nof_prb); } else if (mcs_idx < 29) { - mcs->mod = LTE_QAM64; - mcs->tbs = ra_tbs_from_idx(mcs_idx - 2, nof_prb); + mcs->mod = SRSLTE_MOD_64QAM; + mcs->tbs = srslte_ra_tbs_from_idx(mcs_idx - 2, nof_prb); } else if (mcs_idx == 29) { - mcs->mod = LTE_QPSK; + mcs->mod = SRSLTE_MOD_QPSK; mcs->tbs = 0; } else if (mcs_idx == 30) { - mcs->mod = LTE_QAM16; + mcs->mod = SRSLTE_MOD_16QAM; mcs->tbs = 0; } else if (mcs_idx == 31) { - mcs->mod = LTE_QAM64; + mcs->mod = SRSLTE_MOD_64QAM; mcs->tbs = 0; } else { return SRSLTE_ERROR; @@ -469,17 +469,17 @@ int ra_mcs_from_idx_dl(uint32_t mcs_idx, uint32_t nof_prb, ra_mcs_t *mcs) { return SRSLTE_SUCCESS; } -/* Converts MCS index to ra_mcs_t structure for Uplink as defined in Table 8.6.1-1 on 36.213 */ -int ra_mcs_from_idx_ul(uint32_t mcs_idx, uint32_t nof_prb, ra_mcs_t *mcs) { +/* Converts MCS index to srslte_ra_mcs_t structure for Uplink as defined in Table 8.6.1-1 on 36.213 */ +int srslte_ra_mcs_from_idx_ul(uint32_t mcs_idx, uint32_t nof_prb, srslte_ra_mcs_t *mcs) { if (mcs_idx < 11) { - mcs->mod = LTE_QPSK; - mcs->tbs = ra_tbs_from_idx(mcs_idx, nof_prb); + mcs->mod = SRSLTE_MOD_QPSK; + mcs->tbs = srslte_ra_tbs_from_idx(mcs_idx, nof_prb); } else if (mcs_idx < 21) { - mcs->mod = LTE_QAM16; - mcs->tbs = ra_tbs_from_idx(mcs_idx - 1, nof_prb); + mcs->mod = SRSLTE_MOD_16QAM; + mcs->tbs = srslte_ra_tbs_from_idx(mcs_idx - 1, nof_prb); } else if (mcs_idx < 29) { - mcs->mod = LTE_QAM64; - mcs->tbs = ra_tbs_from_idx(mcs_idx - 2, nof_prb); + mcs->mod = SRSLTE_MOD_64QAM; + mcs->tbs = srslte_ra_tbs_from_idx(mcs_idx - 2, nof_prb); } else { return SRSLTE_ERROR; } @@ -487,7 +487,7 @@ int ra_mcs_from_idx_ul(uint32_t mcs_idx, uint32_t nof_prb, ra_mcs_t *mcs) { } /* Downlink Transport Block size for Format 1C as defined in 7.1.7.2.2-1 on 36.213 */ -int ra_tbs_from_idx_format1c(uint32_t tbs_idx) { +int srslte_srslte_ra_tbs_from_idx_format1c(uint32_t tbs_idx) { if (tbs_idx < 32) { return tbs_format1c_table[tbs_idx]; } else { @@ -496,7 +496,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) { +int srslte_ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb) { if (tbs_idx < 27 && n_prb > 0 && n_prb <= SRSLTE_MAX_PRB) { return tbs_table[tbs_idx][n_prb - 1]; } else { @@ -507,7 +507,7 @@ int ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb) { /* Returns lowest nearest index of TBS value in table 7.1.7.2 on 36.213 * or -1 if the TBS value is not within the valid TBS values */ -int ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb) { +int srslte_ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb) { uint32_t idx; if (n_prb > 0 && n_prb <= SRSLTE_MAX_PRB) { return SRSLTE_ERROR; @@ -523,31 +523,31 @@ int ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb) { return SRSLTE_ERROR; } -void ra_pusch_fprint(FILE *f, ra_pusch_t *ra, uint32_t nof_prb) { +void srslte_ra_pusch_fprint(FILE *f, srslte_ra_pusch_t *ra, uint32_t nof_prb) { fprintf(f, " - Resource Allocation Type 2 mode :\t%s\n", - ra->type2_alloc.mode == t2_loc ? "Localized" : "Distributed"); + ra->type2_alloc.mode == SRSLTE_RA_TYPE2_LOC ? "Localized" : "Distributed"); fprintf(f, " + Frequency Hopping:\t\t\t"); - if (ra->freq_hop_fl == hop_disabled) { + if (ra->freq_hop_fl == SRSLTE_RA_PUSCH_HOP_DISABLED) { fprintf(f, "No\n"); } else { fprintf(f, "Yes\n"); } fprintf(f, " + Resource Indicator Value:\t\t%d\n", ra->type2_alloc.riv); - if (ra->type2_alloc.mode == t2_loc) { + if (ra->type2_alloc.mode == SRSLTE_RA_TYPE2_LOC) { fprintf(f, " + VRB Assignment:\t\t\t%d VRB starting with VRB %d\n", ra->type2_alloc.L_crb, ra->type2_alloc.RB_start); } else { fprintf(f, " + VRB Assignment:\t\t\t%d VRB starting with VRB %d\n", ra->type2_alloc.L_crb, ra->type2_alloc.RB_start); fprintf(f, " + VRB gap selection:\t\t\tGap %d\n", - ra->type2_alloc.n_gap == t2_ng1 ? 1 : 2); + ra->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1 ? 1 : 2); fprintf(f, " + VRB gap:\t\t\t\t%d\n", - ra_type2_ngap(nof_prb, ra->type2_alloc.n_gap == t2_ng1)); + srslte_ra_type2_ngap(nof_prb, ra->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1)); } - fprintf(f, " - Number of PRBs:\t\t\t%d\n", ra_nprb_ul(ra, nof_prb)); + fprintf(f, " - Number of PRBs:\t\t\t%d\n", srslte_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", srslte_mod_string(ra->mcs.mod)); fprintf(f, " - Transport block size:\t\t%d\n", ra->mcs.tbs); @@ -556,13 +556,13 @@ void ra_pusch_fprint(FILE *f, ra_pusch_t *ra, uint32_t nof_prb) { fprintf(f, " - TPC command for PUCCH:\t\t--\n"); } -char *ra_type_string(ra_type_t alloc_type) { +char *ra_type_string(srslte_ra_type_t alloc_type) { switch (alloc_type) { - case alloc_type0: + case SRSLTE_RA_ALLOC_TYPE0: return "Type 0"; - case alloc_type1: + case SRSLTE_RA_ALLOC_TYPE1: return "Type 1"; - case alloc_type2: + case SRSLTE_RA_ALLOC_TYPE2: return "Type 2"; default: return "N/A"; @@ -570,47 +570,47 @@ char *ra_type_string(ra_type_t alloc_type) { } -void ra_pdsch_fprint(FILE *f, ra_pdsch_t *ra, uint32_t nof_prb) { +void srslte_ra_pdsch_fprint(FILE *f, srslte_ra_pdsch_t *ra, uint32_t nof_prb) { fprintf(f, " - Resource Allocation Type:\t\t%s\n", ra_type_string(ra->alloc_type)); switch (ra->alloc_type) { - case alloc_type0: - fprintf(f, " + Resource Block Group Size:\t\t%d\n", ra_type0_P(nof_prb)); + case SRSLTE_RA_ALLOC_TYPE0: + fprintf(f, " + Resource Block Group Size:\t\t%d\n", srslte_ra_type0_P(nof_prb)); fprintf(f, " + RBG Bitmap:\t\t\t0x%x\n", ra->type0_alloc.rbg_bitmask); break; - case alloc_type1: - fprintf(f, " + Resource Block Group Size:\t\t%d\n", ra_type0_P(nof_prb)); + case SRSLTE_RA_ALLOC_TYPE1: + fprintf(f, " + Resource Block Group Size:\t\t%d\n", srslte_ra_type0_P(nof_prb)); fprintf(f, " + RBG Bitmap:\t\t\t0x%x\n", ra->type1_alloc.vrb_bitmask); fprintf(f, " + RBG Subset:\t\t\t%d\n", ra->type1_alloc.rbg_subset); fprintf(f, " + RBG Shift:\t\t\t\t%s\n", ra->type1_alloc.shift ? "Yes" : "No"); break; - case alloc_type2: + case SRSLTE_RA_ALLOC_TYPE2: fprintf(f, " + Type:\t\t\t\t%s\n", - ra->type2_alloc.mode == t2_loc ? "Localized" : "Distributed"); + ra->type2_alloc.mode == SRSLTE_RA_TYPE2_LOC ? "Localized" : "Distributed"); fprintf(f, " + Resource Indicator Value:\t\t%d\n", ra->type2_alloc.riv); - if (ra->type2_alloc.mode == t2_loc) { + if (ra->type2_alloc.mode == SRSLTE_RA_TYPE2_LOC) { fprintf(f, " + VRB Assignment:\t\t\t%d VRB starting with VRB %d\n", ra->type2_alloc.L_crb, ra->type2_alloc.RB_start); } else { fprintf(f, " + VRB Assignment:\t\t\t%d VRB starting with VRB %d\n", ra->type2_alloc.L_crb, ra->type2_alloc.RB_start); fprintf(f, " + VRB gap selection:\t\t\tGap %d\n", - ra->type2_alloc.n_gap == t2_ng1 ? 1 : 2); + ra->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1 ? 1 : 2); fprintf(f, " + VRB gap:\t\t\t\t%d\n", - ra_type2_ngap(nof_prb, ra->type2_alloc.n_gap == t2_ng1)); + srslte_ra_type2_ngap(nof_prb, ra->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1)); } break; } - ra_dl_alloc_t alloc; - ra_dl_alloc(&alloc, ra, nof_prb); + srslte_srslte_ra_dl_alloc_t alloc; + srslte_ra_dl_alloc(&alloc, ra, nof_prb); for (int s = 0; s < 2; s++) { fprintf(f, " - PRB Bitmap Assignment %dst slot:\n", s); - ra_prb_fprint(f, &alloc.slot[s], nof_prb); + srslte_ra_prb_fprint(f, &alloc.slot[s], nof_prb); } - fprintf(f, " - Number of PRBs:\t\t\t%d\n", ra_nprb_dl(ra, nof_prb)); + fprintf(f, " - Number of PRBs:\t\t\t%d\n", srslte_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", srslte_mod_string(ra->mcs.mod)); fprintf(f, " - Transport block size:\t\t%d\n", ra->mcs.tbs); diff --git a/srslte/lib/phch/src/regs.c b/srslte/lib/phch/src/regs.c index d4116219f..0843409d7 100644 --- a/srslte/lib/phch/src/regs.c +++ b/srslte/lib/phch/src/regs.c @@ -37,23 +37,23 @@ #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); -int regs_put_reg(regs_reg_t *reg, +srslte_regs_reg_t *regs_find_reg(srslte_regs_t *h, uint32_t k, uint32_t l); +int regs_put_reg(srslte_regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint32_t nof_prb); -int regs_add_reg(regs_reg_t *reg, +int regs_add_reg(srslte_regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint32_t nof_prb); -int regs_get_reg(regs_reg_t *reg, +int regs_get_reg(srslte_regs_reg_t *reg, cf_t *slot_symbols, cf_t *reg_data, uint32_t nof_prb); -int regs_reset_reg(regs_reg_t *reg, cf_t *slot_symbols, uint32_t nof_prb); +int regs_reset_reg(srslte_regs_reg_t *reg, cf_t *slot_symbols, uint32_t nof_prb); /*************************************************************** @@ -62,7 +62,7 @@ int regs_reset_reg(regs_reg_t *reg, cf_t *slot_symbols, uint32_t nof_prb); * ***************************************************************/ -void regs_pdcch_free(regs_t *h) { +void regs_pdcch_free(srslte_regs_t *h) { int i; for (i=0;i<3;i++) { if (h->pdcch[i].regs) { @@ -80,14 +80,14 @@ const uint8_t PDCCH_PERM[PDCCH_NCOLS] = /** Initialize REGs for PDCCH * 36.211 10.3 section 6.8.5 */ -int regs_pdcch_init(regs_t *h) { +int regs_pdcch_init(srslte_regs_t *h) { int i, m, cfi, nof_ctrl_symbols; int ret = SRSLTE_ERROR; int nrows, ndummy, j; uint32_t k, kp; - regs_reg_t **tmp = NULL; + srslte_regs_reg_t **tmp = NULL; - bzero(&h->pdcch, sizeof(regs_ch_t)); + bzero(&h->pdcch, sizeof(srslte_regs_ch_t)); for (cfi=0;cfi<3;cfi++) { if (h->cell.nof_prb < 10) { @@ -96,7 +96,7 @@ int regs_pdcch_init(regs_t *h) { nof_ctrl_symbols = cfi+1; } - tmp = malloc(sizeof(regs_reg_t*) * h->nof_regs); + tmp = malloc(sizeof(srslte_regs_reg_t*) * h->nof_regs); if (!tmp) { perror("malloc"); goto clean_and_exit; @@ -113,7 +113,7 @@ int regs_pdcch_init(regs_t *h) { h->pdcch[cfi].nof_regs = m; - h->pdcch[cfi].regs = malloc(sizeof(regs_reg_t*) * h->pdcch[cfi].nof_regs); + h->pdcch[cfi].regs = malloc(sizeof(srslte_regs_reg_t*) * h->pdcch[cfi].nof_regs); if (!h->pdcch[cfi].regs) { perror("malloc"); goto clean_and_exit; @@ -159,7 +159,7 @@ clean_and_exit: return ret; } -int regs_pdcch_nregs(regs_t *h, uint32_t cfi) { +int srslte_regs_pdcch_nregs(srslte_regs_t *h, uint32_t cfi) { if (cfi < 1 || cfi > 3) { fprintf(stderr, "Invalid CFI=%d\n", cfi); return SRSLTE_ERROR; @@ -172,13 +172,13 @@ int regs_pdcch_nregs(regs_t *h, uint32_t cfi) { * second part of 6.8.5 in 36.211 */ -int regs_pdcch_put_offset(regs_t *h, cf_t *pdcch_symbols, cf_t *slot_symbols, uint32_t start_reg, uint32_t nof_regs) { +int srslte_regs_pdcch_put_offset(srslte_regs_t *h, cf_t *d, cf_t *slot_symbols, uint32_t start_reg, uint32_t nof_regs) { if (h->cfi_initiated) { if (start_reg + nof_regs <= h->pdcch[h->cfi].nof_regs) { uint32_t i, k; k = 0; for (i=start_reg;ipdcch[h->cfi].regs[i], &pdcch_symbols[k], slot_symbols, h->cell.nof_prb); + regs_put_reg(h->pdcch[h->cfi].regs[i], &d[k], slot_symbols, h->cell.nof_prb); k += 4; } return k; @@ -187,22 +187,22 @@ int regs_pdcch_put_offset(regs_t *h, cf_t *pdcch_symbols, cf_t *slot_symbols, ui return SRSLTE_ERROR; } } else { - fprintf(stderr, "Must call regs_set_cfi() first\n"); + fprintf(stderr, "Must call srslte_regs_set_cfi() first\n"); return SRSLTE_ERROR; } } -int regs_pdcch_put(regs_t *h, cf_t *pdcch_symbols, cf_t *slot_symbols) { - return regs_pdcch_put_offset(h, pdcch_symbols, slot_symbols, 0, h->pdcch[h->cfi].nof_regs); +int srslte_regs_pdcch_put(srslte_regs_t *h, cf_t *d, cf_t *slot_symbols) { + return srslte_regs_pdcch_put_offset(h, d, slot_symbols, 0, h->pdcch[h->cfi].nof_regs); } -int regs_pdcch_get_offset(regs_t *h, cf_t *slot_symbols, cf_t *pdcch_symbols, uint32_t start_reg, uint32_t nof_regs) { +int srslte_regs_pdcch_get_offset(srslte_regs_t *h, cf_t *slot_symbols, cf_t *d, uint32_t start_reg, uint32_t nof_regs) { if (h->cfi_initiated) { if (start_reg + nof_regs <= h->pdcch[h->cfi].nof_regs) { uint32_t i, k; k = 0; for (i=start_reg;ipdcch[h->cfi].regs[i], slot_symbols, &pdcch_symbols[k], h->cell.nof_prb); + regs_get_reg(h->pdcch[h->cfi].regs[i], slot_symbols, &d[k], h->cell.nof_prb); k += 4; } return k; @@ -211,14 +211,14 @@ int regs_pdcch_get_offset(regs_t *h, cf_t *slot_symbols, cf_t *pdcch_symbols, ui return SRSLTE_ERROR; } } else { - fprintf(stderr, "Must call regs_set_cfi() first\n"); + fprintf(stderr, "Must call srslte_regs_set_cfi() first\n"); return SRSLTE_ERROR; } } -int regs_pdcch_get(regs_t *h, cf_t *slot_symbols, cf_t *pdcch_symbols) { - return regs_pdcch_get_offset(h, slot_symbols, pdcch_symbols, 0, h->pdcch[h->cfi].nof_regs); +int srslte_regs_pdcch_get(srslte_regs_t *h, cf_t *slot_symbols, cf_t *d) { + return srslte_regs_pdcch_get_offset(h, slot_symbols, d, 0, h->pdcch[h->cfi].nof_regs); } @@ -233,10 +233,10 @@ int regs_pdcch_get(regs_t *h, cf_t *slot_symbols, cf_t *pdcch_symbols) { /** Initialize REGs for PHICH * 36.211 10.3 section 6.9.3 */ -int regs_phich_init(regs_t *h) { +int regs_phich_init(srslte_regs_t *h) { float ng; uint32_t i, ni, li, n[3], nreg, mi; - regs_reg_t **regs_phich[3]; + srslte_regs_reg_t **regs_phich[3]; int ret = SRSLTE_ERROR; switch(h->phich_res) { @@ -257,7 +257,7 @@ int regs_phich_init(regs_t *h) { break; } h->ngroups_phich = (int) ceilf(ng * ((float) h->cell.nof_prb/8)); - h->phich = malloc(sizeof(regs_ch_t) * h->ngroups_phich); + h->phich = malloc(sizeof(srslte_regs_ch_t) * h->ngroups_phich); if (!h->phich) { perror("malloc"); return -1; @@ -266,7 +266,7 @@ int regs_phich_init(regs_t *h) { 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); + h->phich[i].regs = malloc(sizeof(srslte_regs_reg_t*) * REGS_PHICH_REGS_X_GROUP); if (!h->phich[i].regs) { perror("malloc"); goto clean_and_exit; @@ -283,9 +283,9 @@ int regs_phich_init(regs_t *h) { } } - bzero(regs_phich, sizeof(regs_reg_t*) * 3); + bzero(regs_phich, sizeof(srslte_regs_reg_t*) * 3); for (i=0;i<3;i++) { - regs_phich[i] = malloc(n[i] * sizeof(regs_reg_t*)); + regs_phich[i] = malloc(n[i] * sizeof(srslte_regs_reg_t*)); if (!regs_phich[i]) { perror("malloc"); goto clean_and_exit; @@ -339,7 +339,7 @@ clean_and_exit: return ret; } -void regs_phich_free(regs_t *h) { +void regs_phich_free(srslte_regs_t *h) { uint32_t i; if (h->phich) { if (SRSLTE_CP_ISEXT(h->cell.cp)) { @@ -356,7 +356,7 @@ void regs_phich_free(regs_t *h) { } } -uint32_t regs_phich_nregs(regs_t *h) { +uint32_t srslte_regs_phich_nregs(srslte_regs_t *h) { uint32_t i; uint32_t n; n=0; @@ -367,18 +367,18 @@ uint32_t regs_phich_nregs(regs_t *h) { } -uint32_t regs_phich_ngroups(regs_t *h) { +uint32_t srslte_regs_phich_ngroups(srslte_regs_t *h) { return h->ngroups_phich; } /** * Adds the PHICH symbols to the resource grid pointed by slot_symbols. * - * Each subframe, the user shall call the regs_phich_reset function before adding PHICH symbols. + * Each subframe, the user shall call the srslte_v function before adding PHICH symbols. * * Returns the number of written symbols, or -1 on error */ -int regs_phich_add(regs_t *h, cf_t phich_symbols[REGS_PHICH_NSYM], uint32_t ngroup, cf_t *slot_symbols) { +int srslte_regs_phich_add(srslte_regs_t *h, cf_t symbols[REGS_PHICH_NSYM], uint32_t ngroup, cf_t *slot_symbols) { uint32_t i; if (ngroup >= h->ngroups_phich) { fprintf(stderr, "Error invalid ngroup %d\n", ngroup); @@ -387,9 +387,9 @@ int regs_phich_add(regs_t *h, cf_t phich_symbols[REGS_PHICH_NSYM], uint32_t ngro if (SRSLTE_CP_ISEXT(h->cell.cp)) { ngroup /= 2; } - regs_ch_t *rch = &h->phich[ngroup]; + srslte_regs_ch_t *rch = &h->phich[ngroup]; for (i = 0; i < rch->nof_regs && i*REGS_RE_X_REG < REGS_PHICH_NSYM; i++) { - regs_add_reg(rch->regs[i], &phich_symbols[i*REGS_RE_X_REG], slot_symbols, h->cell.nof_prb); + regs_add_reg(rch->regs[i], &symbols[i*REGS_RE_X_REG], slot_symbols, h->cell.nof_prb); } return i*REGS_RE_X_REG; } @@ -399,7 +399,7 @@ int regs_phich_add(regs_t *h, cf_t phich_symbols[REGS_PHICH_NSYM], uint32_t ngro * * Returns the number of written symbols, or -1 on error */ -int regs_phich_reset(regs_t *h, cf_t *slot_symbols) { +int srslte_regs_phich_reset(srslte_regs_t *h, cf_t *slot_symbols) { uint32_t i; uint32_t ngroup, ng; for (ngroup = 0;ngroup < h->ngroups_phich;SRSLTE_CP_ISEXT(h->cell.cp)?ngroup+=2:ngroup++) { @@ -408,7 +408,7 @@ int regs_phich_reset(regs_t *h, cf_t *slot_symbols) { } else { ng = ngroup; } - regs_ch_t *rch = &h->phich[ng]; + srslte_regs_ch_t *rch = &h->phich[ng]; for (i = 0; i < rch->nof_regs && i*REGS_RE_X_REG < REGS_PHICH_NSYM; i++) { regs_reset_reg(rch->regs[i], slot_symbols, h->cell.nof_prb); } @@ -421,7 +421,7 @@ int regs_phich_reset(regs_t *h, cf_t *slot_symbols) { * * Returns the number of written symbols, or -1 on error */ -int regs_phich_get(regs_t *h, cf_t *slot_symbols, cf_t phich_symbols[REGS_PHICH_NSYM], uint32_t ngroup) { +int srslte_regs_phich_get(srslte_regs_t *h, cf_t *slot_symbols, cf_t symbols[REGS_PHICH_NSYM], uint32_t ngroup) { uint32_t i; if (ngroup >= h->ngroups_phich) { fprintf(stderr, "Error invalid ngroup %d\n", ngroup); @@ -430,9 +430,9 @@ int regs_phich_get(regs_t *h, cf_t *slot_symbols, cf_t phich_symbols[REGS_PHICH_ if (SRSLTE_CP_ISEXT(h->cell.cp)) { ngroup /= 2; } - regs_ch_t *rch = &h->phich[ngroup]; + srslte_regs_ch_t *rch = &h->phich[ngroup]; for (i = 0; i < rch->nof_regs && i*REGS_RE_X_REG < REGS_PHICH_NSYM; i++) { - regs_get_reg(rch->regs[i], slot_symbols, &phich_symbols[i*REGS_RE_X_REG], h->cell.nof_prb); + regs_get_reg(rch->regs[i], slot_symbols, &symbols[i*REGS_RE_X_REG], h->cell.nof_prb); } return i*REGS_RE_X_REG; } @@ -456,12 +456,12 @@ int regs_phich_get(regs_t *h, cf_t *slot_symbols, cf_t phich_symbols[REGS_PHICH_ /** Initialize REGs for PCFICH * 36.211 10.3 section 6.7.4 */ -int regs_pcfich_init(regs_t *h) { +int regs_pcfich_init(srslte_regs_t *h) { uint32_t i; uint32_t k_hat, k; - regs_ch_t *ch = &h->pcfich; + srslte_regs_ch_t *ch = &h->pcfich; - ch->regs = malloc(sizeof(regs_reg_t*) * REGS_PCFICH_NREGS); + ch->regs = malloc(sizeof(srslte_regs_reg_t*) * REGS_PCFICH_NREGS); if (!ch->regs) { perror("malloc"); return SRSLTE_ERROR; @@ -493,14 +493,14 @@ int regs_pcfich_init(regs_t *h) { return SRSLTE_SUCCESS; } -void regs_pcfich_free(regs_t *h) { +void regs_pcfich_free(srslte_regs_t *h) { if (h->pcfich.regs) { free(h->pcfich.regs); h->pcfich.regs = NULL; } } -uint32_t regs_pcfich_nregs(regs_t *h) { +uint32_t srslte_regs_pcfich_nregs(srslte_regs_t *h) { return h->pcfich.nof_regs; } @@ -509,12 +509,12 @@ uint32_t regs_pcfich_nregs(regs_t *h) { * * Returns the number of written symbols, or -1 on error */ -int regs_pcfich_put(regs_t *h, cf_t pcfich_symbols[REGS_PCFICH_NSYM], cf_t *slot_symbols) { - regs_ch_t *rch = &h->pcfich; +int srslte_regs_pcfich_put(srslte_regs_t *h, cf_t symbols[REGS_PCFICH_NSYM], cf_t *slot_symbols) { + srslte_regs_ch_t *rch = &h->pcfich; uint32_t i; for (i = 0; i < rch->nof_regs && i*REGS_RE_X_REG < REGS_PCFICH_NSYM; i++) { - regs_put_reg(rch->regs[i], &pcfich_symbols[i*REGS_RE_X_REG], slot_symbols, h->cell.nof_prb); + regs_put_reg(rch->regs[i], &symbols[i*REGS_RE_X_REG], slot_symbols, h->cell.nof_prb); } return i*REGS_RE_X_REG; } @@ -524,8 +524,8 @@ int regs_pcfich_put(regs_t *h, cf_t pcfich_symbols[REGS_PCFICH_NSYM], cf_t *slot * * Returns the number of written symbols, or -1 on error */ -int regs_pcfich_get(regs_t *h, cf_t *slot_symbols, cf_t ch_data[REGS_PCFICH_NSYM]) { - regs_ch_t *rch = &h->pcfich; +int srslte_regs_pcfich_get(srslte_regs_t *h, cf_t *slot_symbols, cf_t ch_data[REGS_PCFICH_NSYM]) { + srslte_regs_ch_t *rch = &h->pcfich; uint32_t i; for (i = 0; i < rch->nof_regs && i*REGS_RE_X_REG < REGS_PCFICH_NSYM; i++) { regs_get_reg(rch->regs[i], slot_symbols, &ch_data[i*REGS_RE_X_REG], h->cell.nof_prb); @@ -552,7 +552,7 @@ int regs_pcfich_get(regs_t *h, cf_t *slot_symbols, cf_t ch_data[REGS_PCFICH_NSYM * ***************************************************************/ -regs_reg_t *regs_find_reg(regs_t *h, uint32_t k, uint32_t l) { +srslte_regs_reg_t *regs_find_reg(srslte_regs_t *h, uint32_t k, uint32_t l) { uint32_t i; for (i=0;inof_regs;i++) { if (h->regs[i].l == l && h->regs[i].k0 == k) { @@ -601,7 +601,7 @@ int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, srslte_cp_t cp) { * Initializes the indices of a REG * 36.211 Section 6.2.4 */ -int regs_reg_init(regs_reg_t *reg, uint32_t symbol, uint32_t nreg, uint32_t k0, uint32_t maxreg, uint32_t vo) { +int regs_reg_init(srslte_regs_reg_t *reg, uint32_t symbol, uint32_t nreg, uint32_t k0, uint32_t maxreg, uint32_t vo) { uint32_t i, j, z; reg->l = symbol; @@ -645,7 +645,7 @@ int regs_reg_init(regs_reg_t *reg, uint32_t symbol, uint32_t nreg, uint32_t k0, return SRSLTE_SUCCESS; } -void regs_free(regs_t *h) { +void srslte_regs_free(srslte_regs_t *h) { if (h->regs) { free(h->regs); } @@ -653,12 +653,12 @@ void regs_free(regs_t *h) { regs_phich_free(h); regs_pdcch_free(h); - bzero(h, sizeof(regs_t)); + bzero(h, sizeof(srslte_regs_t)); } /** Sets the CFI value for this subframe (CFI must be in the range 1..3). */ -int regs_set_cfi(regs_t *h, uint32_t cfi) { +int srslte_regs_set_cfi(srslte_regs_t *h, uint32_t cfi) { if (cfi > 0 && cfi <= 3) { if (h->phich_len == SRSLTE_PHICH_EXT && ((h->cell.nof_prb < 10 && cfi < 2) || (h->cell.nof_prb >= 10 && cfi < 3))) { @@ -680,7 +680,7 @@ int regs_set_cfi(regs_t *h, uint32_t cfi) { * Sets all REG indices and initializes PCFICH, PHICH and PDCCH REGs * Returns 0 if OK, -1 on error */ -int regs_init(regs_t *h, srslte_cell_t cell) { +int srslte_regs_init(srslte_regs_t *h, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; uint32_t i, k; uint32_t j[4], jmax, prb; @@ -690,7 +690,7 @@ int regs_init(regs_t *h, srslte_cell_t cell) { if (h != NULL && srslte_cell_isvalid(&cell)) { - bzero(h, sizeof(regs_t)); + bzero(h, sizeof(srslte_regs_t)); ret = SRSLTE_ERROR; max_ctrl_symbols = cell.nof_prb<10?4:3; @@ -711,7 +711,7 @@ int regs_init(regs_t *h, srslte_cell_t cell) { } INFO("Indexing %d REGs. CellId: %d, %d PRB, CP: %s\n", h->nof_regs, h->cell.id, h->cell.nof_prb, SRSLTE_CP_ISNORM(h->cell.cp)?"Normal":"Extended"); - h->regs = malloc(sizeof(regs_reg_t) * h->nof_regs); + h->regs = malloc(sizeof(srslte_regs_reg_t) * h->nof_regs); if (!h->regs) { perror("malloc"); goto clean_and_exit; @@ -761,7 +761,7 @@ int regs_init(regs_t *h, srslte_cell_t cell) { } clean_and_exit: if (ret != SRSLTE_SUCCESS) { - regs_free(h); + srslte_regs_free(h); } return ret; } @@ -769,7 +769,7 @@ clean_and_exit: /** * Puts one REG data (4 symbols) in the slot symbols array */ -int regs_put_reg(regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint32_t nof_prb) { +int regs_put_reg(srslte_regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint32_t nof_prb) { uint32_t i; for (i = 0; i < REGS_RE_X_REG; i++) { slot_symbols[REG_IDX(reg, i, nof_prb)] = reg_data[i]; @@ -781,7 +781,7 @@ int regs_put_reg(regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint32_t n * Adds one REG data (4 symbols) in the slot symbols array * Used by PHICH */ -int regs_add_reg(regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint32_t nof_prb) { +int regs_add_reg(srslte_regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint32_t nof_prb) { uint32_t i; for (i = 0; i < REGS_RE_X_REG; i++) { slot_symbols[REG_IDX(reg, i, nof_prb)] += reg_data[i]; @@ -793,7 +793,7 @@ int regs_add_reg(regs_reg_t *reg, cf_t *reg_data, cf_t *slot_symbols, uint32_t n /** * Reset REG data (4 symbols) in the slot symbols array */ -int regs_reset_reg(regs_reg_t *reg, cf_t *slot_symbols, uint32_t nof_prb) { +int regs_reset_reg(srslte_regs_reg_t *reg, cf_t *slot_symbols, uint32_t nof_prb) { uint32_t i; for (i = 0; i < REGS_RE_X_REG; i++) { slot_symbols[REG_IDX(reg, i, nof_prb)] = 0; @@ -804,7 +804,7 @@ int regs_reset_reg(regs_reg_t *reg, cf_t *slot_symbols, uint32_t nof_prb) { /** * Gets one REG data (4 symbols) from the slot symbols array */ -int regs_get_reg(regs_reg_t *reg, cf_t *slot_symbols, cf_t *reg_data, uint32_t nof_prb) { +int regs_get_reg(srslte_regs_reg_t *reg, cf_t *slot_symbols, cf_t *reg_data, uint32_t nof_prb) { uint32_t i; for (i = 0; i < REGS_RE_X_REG; i++) { reg_data[i] = slot_symbols[REG_IDX(reg, i, nof_prb)]; diff --git a/srslte/lib/phch/src/sch.c b/srslte/lib/phch/src/sch.c index 97b82f75f..0945ae65c 100644 --- a/srslte/lib/phch/src/sch.c +++ b/srslte/lib/phch/src/sch.c @@ -43,10 +43,10 @@ #include "srslte/utils/vector.h" -int sch_init(sch_t *q) { +int srslte_sch_init(srslte_sch_t *q) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q) { - bzero(q, sizeof(sch_t)); + bzero(q, sizeof(srslte_sch_t)); if (srslte_crc_init(&q->srslte_crc_tb, SRSLTE_LTE_CRC24A, 24)) { fprintf(stderr, "Error initiating CRC\n"); @@ -67,16 +67,16 @@ int sch_init(sch_t *q) { } // Allocate floats for reception (LLRs) - q->cb_in = vec_malloc(sizeof(uint8_t) * MAX_LONG_CB); + q->cb_in = srslte_vec_malloc(sizeof(uint8_t) * MAX_LONG_CB); if (!q->cb_in) { goto clean; } - q->cb_out = vec_malloc(sizeof(float) * (3 * MAX_LONG_CB + 12)); + q->cb_out = srslte_vec_malloc(sizeof(float) * (3 * MAX_LONG_CB + 12)); if (!q->cb_out) { goto clean; } - if (uci_cqi_init(&q->uci_cqi)) { + if (srslte_uci_cqi_init(&q->uci_cqi)) { goto clean; } @@ -84,12 +84,12 @@ int sch_init(sch_t *q) { } clean: if (ret == SRSLTE_ERROR) { - sch_free(q); + srslte_sch_free(q); } return ret; } -void sch_free(sch_t *q) { +void srslte_sch_free(srslte_sch_t *q) { if (q->cb_in) { free(q->cb_in); } @@ -98,16 +98,16 @@ void sch_free(sch_t *q) { } srslte_tdec_free(&q->decoder); srslte_tcod_free(&q->encoder); - uci_cqi_free(&q->uci_cqi); - bzero(q, sizeof(sch_t)); + srslte_uci_cqi_free(&q->uci_cqi); + bzero(q, sizeof(srslte_sch_t)); } -float sch_average_noi(sch_t *q) { +float srslte_sch_average_noi(srslte_sch_t *q) { return q->average_nof_iterations; } -uint32_t sch_last_noi(sch_t *q) { +uint32_t srslte_sch_last_noi(srslte_sch_t *q) { return q->nof_iterations; } @@ -116,7 +116,7 @@ uint32_t sch_last_noi(sch_t *q) { /* Encode a transport block according to 36.212 5.3.2 * */ -static int encode_tb(sch_t *q, harq_t *harq, uint8_t *data, uint8_t *e_bits, uint32_t nof_e_bits) +static int encode_tb(srslte_sch_t *q, srslte_harq_t *harq, uint8_t *data, uint8_t *e_bits, uint32_t nof_e_bits) { uint8_t parity[24]; uint8_t *p_parity = parity; @@ -143,13 +143,13 @@ static int encode_tb(sch_t *q, harq_t *harq, uint8_t *data, uint8_t *e_bits, uin par = srslte_crc_checksum(&q->srslte_crc_tb, data, harq->mcs.tbs); /* parity bits will be appended later */ - bit_pack(par, &p_parity, 24); + srslte_bit_pack(par, &p_parity, 24); - if (VERBOSE_ISDEBUG()) { + if (SRSLTE_VERBOSE_ISDEBUG()) { DEBUG("DATA: ", 0); - vec_fprint_b(stdout, data, harq->mcs.tbs); + srslte_vec_fprint_b(stdout, data, harq->mcs.tbs); DEBUG("PARITY: ", 0); - vec_fprint_b(stdout, parity, 24); + srslte_vec_fprint_b(stdout, parity, 24); } } @@ -207,9 +207,9 @@ static int encode_tb(sch_t *q, harq_t *harq, uint8_t *data, uint8_t *e_bits, uin for (int j = 0; j < F; j++) { q->cb_in[j] = SRSLTE_TX_NULL; } - if (VERBOSE_ISDEBUG()) { + if (SRSLTE_VERBOSE_ISDEBUG()) { DEBUG("CB#%d: ", i); - vec_fprint_b(stdout, q->cb_in, cb_len); + srslte_vec_fprint_b(stdout, q->cb_in, cb_len); } /* Turbo Encoding */ @@ -239,7 +239,7 @@ static int encode_tb(sch_t *q, harq_t *harq, uint8_t *data, uint8_t *e_bits, uin /* Decode a transport block according to 36.212 5.3.2 * */ -static int decode_tb(sch_t *q, harq_t *harq, float *e_bits, uint8_t *data, uint32_t nof_e_bits) +static int decode_tb(srslte_sch_t *q, srslte_harq_t *harq, float *e_bits, uint8_t *data, uint32_t nof_e_bits) { uint8_t parity[24]; uint8_t *p_parity = parity; @@ -304,9 +304,9 @@ static int decode_tb(sch_t *q, harq_t *harq, float *e_bits, uint8_t *data, uint3 return SRSLTE_ERROR; } - if (VERBOSE_ISDEBUG()) { + if (SRSLTE_VERBOSE_ISDEBUG()) { DEBUG("CB#%d RMOUT: ", i); - vec_fprint_f(stdout, q->cb_out, 3*cb_len+12); + srslte_vec_fprint_f(stdout, q->cb_out, 3*cb_len+12); } /* Turbo Decoding with CRC-based early stopping */ @@ -339,12 +339,12 @@ static int decode_tb(sch_t *q, harq_t *harq, float *e_bits, uint8_t *data, uint3 early_stop = true; } - } while (q->nof_iterations < TDEC_MAX_ITERATIONS && !early_stop); - q->average_nof_iterations = VEC_EMA((float) q->nof_iterations, q->average_nof_iterations, 0.2); + } while (q->nof_iterations < SRSLTE_PDSCH_MAX_TDEC_ITERS && !early_stop); + q->average_nof_iterations = SRSLTE_VEC_EMA((float) q->nof_iterations, q->average_nof_iterations, 0.2); - if (VERBOSE_ISDEBUG()) { + if (SRSLTE_VERBOSE_ISDEBUG()) { DEBUG("CB#%d IN: ", i); - vec_fprint_b(stdout, q->cb_in, cb_len); + srslte_vec_fprint_b(stdout, q->cb_in, cb_len); } // If CB CRC is not correct, early_stop will be false and wont continue with rest of CBs @@ -376,7 +376,7 @@ static int decode_tb(sch_t *q, harq_t *harq, float *e_bits, uint8_t *data, uint3 par_rx = srslte_crc_checksum(&q->srslte_crc_tb, data, harq->mcs.tbs); // check parity bits - par_tx = bit_unpack(&p_parity, 24); + par_tx = srslte_bit_unpack(&p_parity, 24); if (!par_rx) { INFO("\n\tCAUTION!! Received all-zero transport block\n\n", 0); @@ -396,16 +396,16 @@ static int decode_tb(sch_t *q, harq_t *harq, float *e_bits, uint8_t *data, uint3 } } -int dlsch_decode(sch_t *q, harq_t *harq, float *e_bits, uint8_t *data) +int srslte_dlsch_decode(srslte_sch_t *q, srslte_harq_t *harq, float *e_bits, uint8_t *data) { return decode_tb(q, harq, e_bits, data, harq->nof_bits); } -int dlsch_encode(sch_t *q, harq_t *harq, uint8_t *data, uint8_t *e_bits) { +int srslte_dlsch_encode(srslte_sch_t *q, srslte_harq_t *harq, uint8_t *data, uint8_t *e_bits) { return encode_tb(q, harq, data, e_bits, harq->nof_bits); } -int ulsch_decode(sch_t *q, harq_t *harq, float *e_bits, uint8_t *data) +int srslte_ulsch_decode(srslte_sch_t *q, srslte_harq_t *harq, float *e_bits, uint8_t *data) { return decode_tb(q, harq, e_bits, data, harq->nof_bits); } @@ -434,15 +434,15 @@ void ulsch_interleave(uint8_t *g_bits, uint32_t Q_m, uint32_t H_prime_total, uin } -int ulsch_encode(sch_t *q, harq_t *harq, uint8_t *data, uint8_t *g_bits, uint8_t *q_bits) +int srslte_ulsch_encode(srslte_sch_t *q, srslte_harq_t *harq, uint8_t *data, uint8_t *g_bits, uint8_t *q_bits) { - uci_data_t uci_data; - bzero(&uci_data, sizeof(uci_data_t)); - return ulsch_uci_encode(q, harq, data, uci_data, g_bits, q_bits); + srslte_uci_data_t uci_data; + bzero(&uci_data, sizeof(srslte_uci_data_t)); + return srslte_ulsch_uci_encode(q, harq, data, uci_data, g_bits, q_bits); } -int ulsch_uci_encode(sch_t *q, harq_t *harq, uint8_t *data, uci_data_t uci_data, uint8_t *g_bits, uint8_t *q_bits) +int srslte_ulsch_uci_encode(srslte_sch_t *q, srslte_harq_t *harq, uint8_t *data, srslte_uci_data_t uci_data, uint8_t *g_bits, uint8_t *q_bits) { int ret; @@ -463,7 +463,7 @@ int ulsch_uci_encode(sch_t *q, harq_t *harq, uint8_t *data, uci_data_t uci_data, if (harq->mcs.tbs == 0) { beta /= uci_data.beta_cqi; } - ret = uci_encode_ri(uci_data.uci_ri, uci_data.uci_cqi_len, beta, harq, nb_q/Q_m, q_bits); + ret = srslte_uci_encode_ri(uci_data.uci_ri, uci_data.uci_cqi_len, beta, harq, nb_q/Q_m, q_bits); if (ret < 0) { return ret; } @@ -473,7 +473,7 @@ int ulsch_uci_encode(sch_t *q, harq_t *harq, uint8_t *data, uci_data_t uci_data, // Encode CQI if (uci_data.uci_cqi_len > 0) { - ret = uci_encode_cqi_pusch(&q->uci_cqi, uci_data.uci_cqi, uci_data.uci_cqi_len, uci_data.beta_cqi, + ret = srslte_uci_encode_cqi_pusch(&q->uci_cqi, uci_data.uci_cqi, uci_data.uci_cqi_len, uci_data.beta_cqi, Q_prime_ri, harq, g_bits); if (ret < 0) { return ret; @@ -501,7 +501,7 @@ int ulsch_uci_encode(sch_t *q, harq_t *harq, uint8_t *data, uci_data_t uci_data, if (harq->mcs.tbs == 0) { beta /= uci_data.beta_cqi; } - ret = uci_encode_ack(uci_data.uci_ack, uci_data.uci_cqi_len, beta, harq, nb_q/Q_m, q_bits); + ret = srslte_uci_encode_ack(uci_data.uci_ack, uci_data.uci_cqi_len, beta, harq, nb_q/Q_m, q_bits); if (ret < 0) { return ret; } diff --git a/srslte/lib/phch/src/uci.c b/srslte/lib/phch/src/uci.c index 64b152059..01e45f697 100644 --- a/srslte/lib/phch/src/uci.c +++ b/srslte/lib/phch/src/uci.c @@ -44,7 +44,7 @@ #include "srslte/utils/debug.h" /* Table 5.2.2.6.4-1: Basis sequence for (32, O) code */ -static uint8_t M_basis_seq_pusch[32][11]={ +static uint8_t M_basis_seq[32][11]={ {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, {1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1 }, {1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1 }, @@ -103,18 +103,18 @@ static uint8_t M_basis_seq_pucch[20][13]={ {1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0}, }; -int uci_cqi_init(uci_cqi_pusch_t *q) { +int srslte_uci_cqi_init(srslte_uci_cqi_pusch_t *q) { if (srslte_crc_init(&q->crc, SRSLTE_LTE_CRC8, 8)) { return SRSLTE_ERROR; } return SRSLTE_SUCCESS; } -void uci_cqi_free(uci_cqi_pusch_t *q) { +void srslte_uci_cqi_free(srslte_uci_cqi_pusch_t *q) { } -static uint32_t Q_prime_cqi(uint32_t O, float beta, uint32_t Q_prime_ri, harq_t *harq) { +static uint32_t Q_prime_cqi(uint32_t O, float beta, uint32_t Q_prime_ri, srslte_harq_t *harq) { uint32_t M_sc = harq->ul_alloc.L_prb * SRSLTE_NRE; uint32_t K = harq->cb_segm.C1*harq->cb_segm.K1 + @@ -126,7 +126,7 @@ static uint32_t Q_prime_cqi(uint32_t O, float beta, uint32_t Q_prime_ri, harq_t 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); + Q_prime = SRSLTE_MIN(x, M_sc * harq->nof_symb - Q_prime_ri); } else { Q_prime = 12*harq->ul_alloc.L_prb*SRSLTE_NRE - Q_prime_ri; } @@ -136,9 +136,9 @@ static uint32_t Q_prime_cqi(uint32_t O, float beta, uint32_t Q_prime_ri, harq_t /* Encode UCI CQI/PMI for payloads equal or lower to 11 bits (Sec 5.2.2.6.4) */ -int encode_cqi_short(uci_cqi_pusch_t *q, uint8_t *data, uint32_t nof_bits, uint8_t *q_bits, uint32_t Q) +int encode_cqi_short(srslte_uci_cqi_pusch_t *q, uint8_t *data, uint32_t nof_bits, uint8_t *q_bits, uint32_t Q) { - if (nof_bits < MAX_CQI_LEN_PUSCH && + if (nof_bits < SRSLTE_UCI_MAX_CQI_LEN_PUSCH && q != NULL && data != NULL && q_bits != NULL) @@ -146,7 +146,7 @@ int encode_cqi_short(uci_cqi_pusch_t *q, uint8_t *data, uint32_t nof_bits, uint8 for (int i=0;i<32;i++) { q->encoded_cqi[i] = 0; for (int n=0;nencoded_cqi[i] += (data[n] * M_basis_seq_pusch[i][n]); + q->encoded_cqi[i] += (data[n] * M_basis_seq[i][n]); } } @@ -161,11 +161,11 @@ int encode_cqi_short(uci_cqi_pusch_t *q, uint8_t *data, uint32_t nof_bits, uint8 /* Encode UCI CQI/PMI for payloads greater than 11 bits (go through CRC, conv coder and rate match) */ -int encode_cqi_long(uci_cqi_pusch_t *q, uint8_t *data, uint32_t nof_bits, uint8_t *q_bits, uint32_t Q) +int encode_cqi_long(srslte_uci_cqi_pusch_t *q, uint8_t *data, uint32_t nof_bits, uint8_t *q_bits, uint32_t Q) { srslte_convcoder_t encoder; - if (nof_bits + 8 < MAX_CQI_LEN_PUSCH && + if (nof_bits + 8 < SRSLTE_UCI_MAX_CQI_LEN_PUSCH && q != NULL && data != NULL && q_bits != NULL) @@ -185,8 +185,8 @@ int encode_cqi_long(uci_cqi_pusch_t *q, uint8_t *data, uint32_t nof_bits, uint8_ DEBUG("CConv output: ", 0); - if (VERBOSE_ISDEBUG()) { - vec_fprint_b(stdout, q->encoded_cqi, 3 * (nof_bits + 8)); + if (SRSLTE_VERBOSE_ISDEBUG()) { + srslte_vec_fprint_b(stdout, q->encoded_cqi, 3 * (nof_bits + 8)); } srslte_rm_conv_tx(q->encoded_cqi, 3 * (nof_bits + 8), q_bits, Q); @@ -199,10 +199,10 @@ int encode_cqi_long(uci_cqi_pusch_t *q, uint8_t *data, uint32_t nof_bits, uint8_ /* Encode UCI CQI/PMI as described in 5.2.3.3 of 36.212 */ -int uci_encode_cqi_pucch(uint8_t *cqi_data, uint32_t cqi_len, uint8_t b_bits[CQI_CODED_PUCCH_B]) +int srslte_uci_encode_cqi_pucch(uint8_t *cqi_data, uint32_t cqi_len, uint8_t b_bits[SRSLTE_UCI_CQI_CODED_PUCCH_B]) { - if (cqi_len <= MAX_CQI_LEN_PUCCH) { - for (uint32_t i=0;iul_alloc.L_prb * SRSLTE_NRE; uint32_t K = harq->cb_segm.C1*harq->cb_segm.K1 + @@ -305,7 +305,7 @@ static uint32_t Q_prime_ri_ack(uint32_t O, uint32_t O_cqi, float beta, harq_t *h uint32_t x = (uint32_t) ceilf((float) O*M_sc_init*harq->nof_symb*beta/K); - uint32_t Q_prime = MIN(x, 4*M_sc); + uint32_t Q_prime = SRSLTE_MIN(x, 4*M_sc); return Q_prime; } @@ -321,7 +321,7 @@ static void encode_ri_ack(uint8_t data, uint8_t q_encoded_bits[6], uint8_t Q_m) /* Encode UCI HARQ/ACK bits as described in 5.2.2.6 of 36.212 * Currently only supporting 1-bit HARQ */ -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) +int srslte_uci_encode_ack(uint8_t data, uint32_t O_cqi, float beta, srslte_harq_t *harq, uint32_t H_prime_total, uint8_t *q_bits) { uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Qprime = Q_prime_ri_ack(1, O_cqi, beta, harq); @@ -340,7 +340,7 @@ int uci_encode_ack(uint8_t data, uint32_t O_cqi, float beta, harq_t *harq, uint3 /* Encode UCI RI bits as described in 5.2.2.6 of 36.212 * Currently only supporting 1-bit RI */ -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) +int srslte_uci_encode_ri(uint8_t data, uint32_t O_cqi, float beta, srslte_harq_t *harq, uint32_t H_prime_total, uint8_t *q_bits) { uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Qprime = Q_prime_ri_ack(1, O_cqi, beta, harq); diff --git a/srslte/lib/phch/test/dci_unpacking.c b/srslte/lib/phch/test/dci_unpacking.c index 8c5e0ffb7..05477ad24 100644 --- a/srslte/lib/phch/test/dci_unpacking.c +++ b/srslte/lib/phch/test/dci_unpacking.c @@ -38,8 +38,8 @@ void usage(char *prog) { } int main(int argc, char **argv) { - dci_msg_t msg; - ra_pdsch_t ra_dl; + srslte_dci_msg_t msg; + srslte_ra_pdsch_t ra_dl; int len, rlen; int nof_prb; int nwords; @@ -67,9 +67,9 @@ int main(int argc, char **argv) { for (i = 0; i < nwords; i++) { x = strtoul(argv[i + 3], NULL, 16); if (len - rlen < 32) { - bit_pack(x, &y, len - rlen); + srslte_bit_pack(x, &y, len - rlen); } else { - bit_pack(x, &y, 32); + srslte_bit_pack(x, &y, 32); } } @@ -80,20 +80,20 @@ int main(int argc, char **argv) { } printf("\n"); - dci_msg_type_t dci_type; + srslte_dci_msg_type_t dci_type; msg.nof_bits = len; - if (dci_msg_get_type(&msg, &dci_type, nof_prb, SRSLTE_SIRNTI)) { + if (srslte_dci_msg_get_type(&msg, &dci_type, nof_prb, SRSLTE_SIRNTI)) { fprintf(stderr, "Can't obtain DCI message type\n"); exit(-1); } printf("\n"); printf("Message type:"); - dci_msg_type_fprint(stdout, dci_type); + srslte_dci_msg_type_fprint(stdout, dci_type); switch (dci_type.type) { - case PDSCH_SCHED: - bzero(&ra_dl, sizeof(ra_pdsch_t)); - dci_msg_unpack_pdsch(&msg, &ra_dl, nof_prb, false); - ra_pdsch_fprint(stdout, &ra_dl, nof_prb); + case SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED: + bzero(&ra_dl, sizeof(srslte_ra_pdsch_t)); + srslte_dci_msg_unpack_pdsch(&msg, &ra_dl, nof_prb, false); + srslte_ra_pdsch_fprint(stdout, &ra_dl, nof_prb); break; default: printf("Error expected PDSCH\n"); diff --git a/srslte/lib/phch/test/dlsch_encode_test_mex.c b/srslte/lib/phch/test/dlsch_encode_test_mex.c index 04dea351f..3faa625f7 100644 --- a/srslte/lib/phch/test/dlsch_encode_test_mex.c +++ b/srslte/lib/phch/test/dlsch_encode_test_mex.c @@ -44,11 +44,11 @@ void help() /* the gateway function */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { - sch_t dlsch; + srslte_sch_t dlsch; uint8_t *trblkin; - ra_mcs_t mcs; - ra_dl_alloc_t prb_alloc; - harq_t harq_process; + srslte_ra_mcs_t mcs; + srslte_srslte_ra_dl_alloc_t prb_alloc; + srslte_harq_t harq_process; uint32_t rv; if (nrhs < NOF_INPUTS) { @@ -56,14 +56,14 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } - if (sch_init(&dlsch)) { + if (srslte_sch_init(&dlsch)) { mexErrMsgTxt("Error initiating DL-SCH\n"); return; } srslte_cell_t cell; cell.nof_prb = 100; cell.id=1; - if (harq_init(&harq_process, cell)) { + if (srslte_harq_init(&harq_process, cell)) { mexErrMsgTxt("Error initiating HARQ\n"); return; } @@ -82,11 +82,11 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) char *mod_str = mexutils_get_char_struct(PUSCHCFG, "Modulation"); if (!strcmp(mod_str, "QPSK")) { - mcs.mod = LTE_QPSK; + mcs.mod = SRSLTE_MOD_QPSK; } else if (!strcmp(mod_str, "16QAM")) { - mcs.mod = LTE_QAM16; + mcs.mod = SRSLTE_MOD_16QAM; } else if (!strcmp(mod_str, "64QAM")) { - mcs.mod = LTE_QAM64; + mcs.mod = SRSLTE_MOD_64QAM; } else { mexErrMsgTxt("Unknown modulation\n"); return; @@ -94,18 +94,18 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mxFree(mod_str); - if (harq_setup_dl(&harq_process, mcs, rv, 0, &prb_alloc)) { + if (srslte_harq_setup_dl(&harq_process, mcs, rv, 0, &prb_alloc)) { mexErrMsgTxt("Error configuring HARQ process\n"); return; } harq_process.nof_bits = mxGetScalar(OUTLEN); - uint8_t *e_bits = vec_malloc(harq_process.nof_bits* sizeof(uint8_t)); + uint8_t *e_bits = srslte_vec_malloc(harq_process.nof_bits* sizeof(uint8_t)); if (!e_bits) { return; } - if (dlsch_encode(&dlsch, &harq_process, trblkin, e_bits)) { + if (srslte_dlsch_encode(&dlsch, &harq_process, trblkin, e_bits)) { mexErrMsgTxt("Error encoding TB\n"); return; } @@ -114,7 +114,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexutils_write_uint8(e_bits, &plhs[0], harq_process.nof_bits, 1); } - sch_free(&dlsch); + srslte_sch_free(&dlsch); free(trblkin); free(e_bits); diff --git a/srslte/lib/phch/test/pbch_file_test.c b/srslte/lib/phch/test/pbch_file_test.c index fb58eb561..a929efd31 100644 --- a/srslte/lib/phch/test/pbch_file_test.c +++ b/srslte/lib/phch/test/pbch_file_test.c @@ -38,7 +38,8 @@ char *input_file_name = NULL; srslte_cell_t cell = { 6, // nof_prb 2, // nof_ports - 150, // cell_id + 0, // bw_idx + 150, // cell_id SRSLTE_SRSLTE_CP_NORM, // cyclic prefix SRSLTE_PHICH_R_1, // PHICH resources SRSLTE_PHICH_NORM // PHICH length @@ -52,8 +53,8 @@ uint8_t bch_payload_file[BCH_PAYLOAD_LEN] = {0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, srslte_filesource_t fsrc; cf_t *input_buffer, *fft_buffer, *ce[SRSLTE_MAX_PORTS]; -pbch_t pbch; -srslte_fft_t fft; +srslte_pbch_t pbch; +srslte_ofdm_t fft; srslte_chest_dl_t chest; void usage(char *prog) { @@ -62,7 +63,7 @@ void usage(char *prog) { printf("\t-p nof_prb [Default %d]\n", cell.nof_prb); printf("\t-e Set extended prefix [Default Normal]\n"); printf("\t-n nof_frames [Default %d]\n", nof_frames); - printf("\t-v [set verbose to debug, default none]\n"); + printf("\t-v [set srslte_verbose to debug, default none]\n"); } void parse_args(int argc, char **argv) { @@ -83,7 +84,7 @@ void parse_args(int argc, char **argv) { nof_frames = atoi(argv[optind]); break; case 'v': - verbose++; + srslte_verbose++; break; case 'e': cell.cp = SRSLTE_SRSLTE_CP_EXT; @@ -137,12 +138,12 @@ int base_init() { return -1; } - if (srslte_fft_init(&fft, cell.cp, cell.nof_prb)) { + if (srslte_ofdm_tx_init(&fft, cell.cp, cell.nof_prb)) { fprintf(stderr, "Error initializing FFT\n"); return -1; } - if (pbch_init(&pbch, cell)) { + if (srslte_pbch_init(&pbch, cell)) { fprintf(stderr, "Error initiating PBCH\n"); return -1; } @@ -164,9 +165,9 @@ void base_free() { free(ce[i]); } srslte_chest_dl_free(&chest); - srslte_fft_free(&fft); + srslte_ofdm_tx_free(&fft); - pbch_free(&pbch); + srslte_pbch_free(&pbch); } int main(int argc, char **argv) { @@ -195,7 +196,7 @@ int main(int argc, char **argv) { if (nread > 0) { // process 1st subframe only - srslte_fft_run_sf(&fft, input_buffer, fft_buffer); + srslte_ofdm_tx_sf(&fft, input_buffer, fft_buffer); /* Get channel estimates for each port */ srslte_chest_dl_estimate(&chest, fft_buffer, ce, 0); @@ -206,8 +207,8 @@ int main(int argc, char **argv) { ce_slot1[i] = &ce[i][SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)]; } - pbch_decode_reset(&pbch); - n = pbch_decode(&pbch, &fft_buffer[SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)], + srslte_pbch_decode_reset(&pbch); + n = srslte_pbch_decode(&pbch, &fft_buffer[SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)], ce_slot1, srslte_chest_dl_get_noise_estimate(&chest), bch_payload, &nof_tx_ports, &sfn_offset); if (n == 1) { @@ -230,7 +231,7 @@ int main(int argc, char **argv) { exit(-1); } else { printf("MIB decoded OK. Nof ports: %d. SFN offset: %d Payload: ", nof_tx_ports, sfn_offset); - vec_fprint_hex(stdout, bch_payload, BCH_PAYLOAD_LEN); + srslte_vec_fprint_hex(stdout, bch_payload, BCH_PAYLOAD_LEN); if (nof_tx_ports == 2 && sfn_offset == 0 && !memcmp(bch_payload, bch_payload_file, BCH_PAYLOAD_LEN)) { printf("This is the signal.1.92M.dat file\n"); exit(0); diff --git a/srslte/lib/phch/test/pbch_test.c b/srslte/lib/phch/test/pbch_test.c index 649bca34c..b5a3b783c 100644 --- a/srslte/lib/phch/test/pbch_test.c +++ b/srslte/lib/phch/test/pbch_test.c @@ -48,7 +48,7 @@ void usage(char *prog) { printf("\t-c cell id [Default %d]\n", cell.id); printf("\t-p cell.nof_ports [Default %d]\n", cell.nof_ports); printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); - printf("\t-v [set verbose to debug, default none]\n"); + printf("\t-v [set srslte_verbose to debug, default none]\n"); } void parse_args(int argc, char **argv) { @@ -65,7 +65,7 @@ void parse_args(int argc, char **argv) { cell.id = atoi(argv[optind]); break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(argv[0]); @@ -76,7 +76,7 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { - pbch_t pbch; + srslte_pbch_t pbch; uint8_t bch_payload_tx[BCH_PAYLOAD_LEN], bch_payload_rx[BCH_PAYLOAD_LEN]; int i, j; cf_t *ce[SRSLTE_MAX_PORTS]; @@ -105,7 +105,7 @@ int main(int argc, char **argv) { } } - if (pbch_init(&pbch, cell)) { + if (srslte_pbch_init(&pbch, cell)) { fprintf(stderr, "Error creating PBCH object\n"); exit(-1); } @@ -115,7 +115,7 @@ int main(int argc, char **argv) { bch_payload_tx[i] = rand()%2; } - pbch_encode(&pbch, bch_payload_tx, slot1_symbols); + srslte_pbch_encode(&pbch, bch_payload_tx, slot1_symbols); /* combine outputs */ for (i=1;i NOF_INPUTS) { cf_t *cearray; @@ -117,7 +117,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } uint32_t nof_ports; - int n = pbch_decode(&pbch, &input_fft[SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)], + int n = srslte_pbch_decode(&pbch, &input_fft[SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)], ce_slot, noise_power, NULL, &nof_ports, NULL); @@ -129,10 +129,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } } if (nlhs >= 2) { - mexutils_write_cf(pbch.pbch_d, &plhs[1], pbch.nof_symbols, 1); + mexutils_write_cf(pbch.d, &plhs[1], pbch.nof_symbols, 1); } if (nlhs >= 3) { - mexutils_write_f(pbch.pbch_llr, &plhs[2], 2*pbch.nof_symbols, 1); + mexutils_write_f(pbch.llr, &plhs[2], 2*pbch.nof_symbols, 1); } if (nlhs >= 4) { mexutils_write_cf(ce[0], &plhs[3], SRSLTE_SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14); @@ -141,15 +141,15 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 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); + mexutils_write_cf(pbch.symbols[0], &plhs[5], pbch.nof_symbols, 1); } if (nlhs >= 7) { mexutils_write_cf(pbch.ce[0], &plhs[6], pbch.nof_symbols, 1); } srslte_chest_dl_free(&chest); - srslte_fft_free(&fft); - pbch_free(&pbch); + srslte_ofdm_tx_free(&fft); + srslte_pbch_free(&pbch); for (i=0;i NOF_INPUTS) { cf_t *cearray; @@ -126,7 +126,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) uint32_t cfi; float corr_res; - int n = pcfich_decode(&pcfich, input_fft, ce, noise_power, sf_idx, &cfi, &corr_res); + int n = srslte_pcfich_decode(&pcfich, input_fft, ce, noise_power, sf_idx, &cfi, &corr_res); if (nlhs >= 1) { if (n < 0) { @@ -136,16 +136,16 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } } if (nlhs >= 2) { - mexutils_write_cf(pcfich.pcfich_d, &plhs[1], 16, 1); + mexutils_write_cf(pcfich.d, &plhs[1], 16, 1); } if (nlhs >= 3) { - mexutils_write_cf(pcfich.pcfich_symbols[0], &plhs[2], 16, 1); + mexutils_write_cf(pcfich.symbols[0], &plhs[2], 16, 1); } srslte_chest_dl_free(&chest); - srslte_fft_free(&fft); - pcfich_free(&pcfich); - regs_free(®s); + srslte_ofdm_tx_free(&fft); + srslte_pcfich_free(&pcfich); + srslte_regs_free(®s); for (i=0;i= 1234 && srslte_crc_rem < 1234 + nof_dcis) { srslte_crc_rem -= 1234; - memcpy(&dci_rx[srslte_crc_rem], &dci_tmp, sizeof(dci_msg_t)); + memcpy(&dci_rx[srslte_crc_rem], &dci_tmp, sizeof(srslte_dci_msg_t)); } else { printf("Received invalid DCI CRC 0x%x\n", srslte_crc_rem); goto quit; @@ -217,8 +217,8 @@ int main(int argc, char **argv) { ret = 0; quit: - pdcch_free(&pdcch); - regs_free(®s); + srslte_pdcch_free(&pdcch); + srslte_regs_free(®s); for (i = 0; i < SRSLTE_MAX_PORTS; i++) { free(ce[i]); diff --git a/srslte/lib/phch/test/pdcch_test_mex.c b/srslte/lib/phch/test/pdcch_test_mex.c index 899b1a7d4..ad5f84628 100644 --- a/srslte/lib/phch/test/pdcch_test_mex.c +++ b/srslte/lib/phch/test/pdcch_test_mex.c @@ -40,10 +40,10 @@ #define MAX_CANDIDATES 64 -dci_format_t ue_formats[] = {Format1A,Format1}; // Format1B should go here also +srslte_dci_format_t ue_formats[] = {SRSLTE_DCI_FORMAT1A,SRSLTE_DCI_FORMAT1}; // SRSLTE_DCI_FORMAT1B should go here also const uint32_t nof_ue_formats = 2; -dci_format_t common_formats[] = {Format1A,Format1C}; +srslte_dci_format_t common_formats[] = {SRSLTE_DCI_FORMAT1A,SRSLTE_DCI_FORMAT1C}; const uint32_t nof_common_formats = 2; @@ -58,17 +58,17 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int i; srslte_cell_t cell; - pdcch_t pdcch; + srslte_pdcch_t pdcch; srslte_chest_dl_t chest; - srslte_fft_t fft; - regs_t regs; - dci_location_t locations[MAX_CANDIDATES]; + srslte_ofdm_t fft; + srslte_regs_t regs; + srslte_dci_location_t locations[MAX_CANDIDATES]; uint32_t cfi, sf_idx; uint16_t rnti; cf_t *input_fft, *input_signal; int nof_re; uint32_t nof_formats; - dci_format_t *formats = NULL; + srslte_dci_format_t *formats = NULL; if (nrhs != NOF_INPUTS) { help(); @@ -94,24 +94,24 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } - if (srslte_fft_init(&fft, cell.cp, cell.nof_prb)) { + if (srslte_ofdm_tx_init(&fft, cell.cp, cell.nof_prb)) { fprintf(stderr, "Error initializing FFT\n"); return; } rnti = (uint16_t) mxGetScalar(RNTI); - if (regs_init(®s, cell)) { + if (srslte_regs_init(®s, cell)) { mexErrMsgTxt("Error initiating regs\n"); return; } - if (regs_set_cfi(®s, cfi)) { + if (srslte_regs_set_cfi(®s, cfi)) { fprintf(stderr, "Error setting CFI\n"); exit(-1); } - if (pdcch_init(&pdcch, ®s, cell)) { + if (srslte_pdcch_init(&pdcch, ®s, cell)) { mexErrMsgTxt("Error initiating channel estimator\n"); return; } @@ -121,15 +121,15 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexErrMsgTxt("Error reading input signal\n"); return; } - input_fft = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); + input_fft = srslte_vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); // Set Channel estimates to 1.0 (ignore fading) cf_t *ce[SRSLTE_MAX_PORTS]; for (i=0;i NOF_INPUTS) { cf_t *cearray; @@ -150,25 +150,25 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) noise_power = srslte_chest_dl_get_noise_estimate(&chest); } - pdcch_extract_llr(&pdcch, input_fft, ce, noise_power, sf_idx, cfi); + srslte_pdcch_extract_llr(&pdcch, input_fft, ce, noise_power, sf_idx, cfi); uint32_t nof_locations; if (rnti == SRSLTE_SIRNTI) { - nof_locations = pdcch_common_locations(&pdcch, locations, MAX_CANDIDATES, cfi); + nof_locations = srslte_pdcch_common_locations(&pdcch, locations, MAX_CANDIDATES, cfi); formats = common_formats; nof_formats = nof_common_formats; } else { - nof_locations = pdcch_ue_locations(&pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti); + nof_locations = srslte_pdcch_ue_locations(&pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti); formats = ue_formats; nof_formats = nof_ue_formats; } uint16_t srslte_crc_rem=0; - dci_msg_t dci_msg; - bzero(&dci_msg, sizeof(dci_msg_t)); + srslte_dci_msg_t dci_msg; + bzero(&dci_msg, sizeof(srslte_dci_msg_t)); for (int f=0;f= 1) { plhs[0] = mxCreateLogicalScalar(srslte_crc_rem == rnti); } - int nof_bits = (regs_pdcch_nregs(®s, cfi) / 9) * 72; + int nof_bits = (srslte_regs_pdcch_nregs(®s, cfi) / 9) * 72; if (nlhs >= 2) { - mexutils_write_f(pdcch.pdcch_llr, &plhs[1], nof_bits, 1); + mexutils_write_f(pdcch.llr, &plhs[1], nof_bits, 1); } if (nlhs >= 3) { - mexutils_write_cf(pdcch.pdcch_symbols[0], &plhs[2], 36*pdcch.nof_cce, 1); + mexutils_write_cf(pdcch.symbols[0], &plhs[2], 36*pdcch.nof_cce, 1); } srslte_chest_dl_free(&chest); - srslte_fft_free(&fft); - pdcch_free(&pdcch); - regs_free(®s); + srslte_ofdm_tx_free(&fft); + srslte_pdcch_free(&pdcch); + srslte_regs_free(®s); for (i=0;i 0) { - if (harq_setup_dl(&harq_process, ra_dl.mcs, ra_dl.rv_idx, sf_idx, &ra_dl.prb_alloc)) { + if (srslte_harq_setup_dl(&harq_process, ra_dl.mcs, ra_dl.rv_idx, sf_idx, &ra_dl.prb_alloc)) { fprintf(stderr, "Error configuring HARQ process\n"); goto goout; } - if (pdsch_decode(&pdsch, &harq_process, fft_buffer, ce, srslte_chest_dl_get_noise_estimate(&chest), data)) { + if (srslte_pdsch_decode(&pdsch, &harq_process, fft_buffer, ce, srslte_chest_dl_get_noise_estimate(&chest), data)) { fprintf(stderr, "Error decoding PDSCH\n"); goto goout; } else { diff --git a/srslte/lib/phch/test/pdsch_test.c b/srslte/lib/phch/test/pdsch_test.c index eaac078c5..6a0740b9e 100644 --- a/srslte/lib/phch/test/pdsch_test.c +++ b/srslte/lib/phch/test/pdsch_test.c @@ -47,7 +47,7 @@ uint32_t cfi = 2; uint32_t tbs = 0; uint32_t nof_tbs = 0; uint32_t subframe = 1; -srslte_mod_t modulation = LTE_BPSK; +srslte_mod_t modulation = SRSLTE_MOD_BPSK; uint32_t rv_idx = 0; void usage(char *prog) { @@ -60,7 +60,7 @@ void usage(char *prog) { printf("\t-f cfi [Default %d]\n", cfi); printf("\t-p cell.nof_ports [Default %d]\n", cell.nof_ports); printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); - printf("\t-v [set verbose to debug, default none]\n"); + printf("\t-v [set srslte_verbose to debug, default none]\n"); } void parse_args(int argc, char **argv) { @@ -70,16 +70,16 @@ void parse_args(int argc, char **argv) { case 'm': switch(atoi(argv[optind])) { case 1: - modulation = LTE_BPSK; + modulation = SRSLTE_MOD_BPSK; break; case 2: - modulation = LTE_QPSK; + modulation = SRSLTE_MOD_QPSK; break; case 4: - modulation = LTE_QAM16; + modulation = SRSLTE_MOD_16QAM; break; case 6: - modulation = LTE_QAM64; + modulation = SRSLTE_MOD_64QAM; break; default: fprintf(stderr, "Invalid modulation %d. Possible values: " @@ -109,7 +109,7 @@ void parse_args(int argc, char **argv) { cell.id = atoi(argv[optind]); break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(argv[0]); @@ -123,7 +123,7 @@ void parse_args(int argc, char **argv) { } int main(int argc, char **argv) { - pdsch_t pdsch; + srslte_pdsch_t pdsch; uint32_t i, j; uint8_t *data = NULL; cf_t *ce[SRSLTE_MAX_PORTS]; @@ -131,15 +131,15 @@ int main(int argc, char **argv) { cf_t *slot_symbols[SRSLTE_MAX_PORTS]; int ret = -1; struct timeval t[3]; - ra_mcs_t mcs; - ra_dl_alloc_t prb_alloc; - harq_t harq_process; + srslte_ra_mcs_t mcs; + srslte_srslte_ra_dl_alloc_t prb_alloc; + srslte_harq_t harq_process; uint32_t rv; parse_args(argc,argv); - bzero(&pdsch, sizeof(pdsch_t)); - bzero(&harq_process, sizeof(harq_t)); + bzero(&pdsch, sizeof(srslte_pdsch_t)); + bzero(&harq_process, sizeof(srslte_harq_t)); bzero(ce, sizeof(cf_t*)*SRSLTE_MAX_PORTS); bzero(slot_symbols, sizeof(cf_t*)*SRSLTE_MAX_PORTS); @@ -151,9 +151,9 @@ int main(int argc, char **argv) { for (i=0;i NOF_INPUTS) { cf_t *cearray = NULL; @@ -209,7 +209,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } - int r = pdsch_decode(&pdsch, &harq_process, input_fft, ce, noise_power, data); + int r = srslte_pdsch_decode(&pdsch, &harq_process, input_fft, ce, noise_power, data); if (nlhs >= 1) { @@ -219,18 +219,18 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexutils_write_uint8(data, &plhs[1], mcs.tbs, 1); } if (nlhs >= 3) { - mexutils_write_cf(pdsch.pdsch_symbols[0], &plhs[2], harq_process.dl_alloc.re_sf[sf_idx], 1); + mexutils_write_cf(pdsch.symbols[0], &plhs[2], harq_process.dl_alloc.re_sf[sf_idx], 1); } if (nlhs >= 4) { - mexutils_write_cf(pdsch.pdsch_d, &plhs[3], harq_process.dl_alloc.re_sf[sf_idx], 1); + mexutils_write_cf(pdsch.d, &plhs[3], harq_process.dl_alloc.re_sf[sf_idx], 1); } if (nlhs >= 5) { - mexutils_write_f(pdsch.pdsch_e, &plhs[4], harq_process.dl_alloc.re_sf[sf_idx] * srslte_mod_bits_x_symbol(mcs.mod), 1); + mexutils_write_f(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); - srslte_fft_free(&fft); - pdsch_free(&pdsch); + srslte_ofdm_tx_free(&fft); + srslte_pdsch_free(&pdsch); for (i=0;iN_seq; if(preamble_format == 2 || preamble_format == 3) prach_len /= 2; - prach_detect(p, 0, &preamble[p->N_cp], prach_len, indices, &n_indices); + srslte_prach_detect(p, 0, &preamble[p->N_cp], prach_len, indices, &n_indices); if(n_indices != 1 || indices[0] != seq_index) return -1; } - prach_free(p); + srslte_prach_free(p); free(p); printf("Done\n"); diff --git a/srslte/lib/phch/test/prach_test_mex.c b/srslte/lib/phch/test/prach_test_mex.c index 14d5207cc..5c279d6c2 100644 --- a/srslte/lib/phch/test/prach_test_mex.c +++ b/srslte/lib/phch/test/prach_test_mex.c @@ -83,21 +83,21 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) uint32_t frequency_offset = 0; mexutils_read_uint32_struct(PRACHCFG, "FreqOffset", &frequency_offset); - prach_t prach; - if (prach_init(&prach, N_ifft_ul, preamble_format, root_seq_idx, high_speed_flag, zero_corr_zone)) { + srslte_prach_t prach; + if (srslte_prach_init(&prach, N_ifft_ul, preamble_format, root_seq_idx, high_speed_flag, zero_corr_zone)) { mexErrMsgTxt("Error initiating PRACH\n"); return; } uint32_t nof_samples = srslte_sampling_freq_hz(n_ul_rb) * 0.003; - cf_t *signal = vec_malloc(sizeof(cf_t) * nof_samples); + cf_t *signal = srslte_vec_malloc(sizeof(cf_t) * nof_samples); if (!signal) { mexErrMsgTxt("malloc"); return; } bzero(signal, sizeof(cf_t) * nof_samples); - if (prach_gen(&prach, seq_idx, frequency_offset, 0.2, signal)) { + if (srslte_prach_gen(&prach, seq_idx, frequency_offset, 0.2, signal)) { mexErrMsgTxt("Error generating PRACH\n"); return; } @@ -109,7 +109,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) free(signal); - prach_free(&prach); + srslte_prach_free(&prach); return; } diff --git a/srslte/lib/phch/test/prach_test_multi.c b/srslte/lib/phch/test/prach_test_multi.c index b62908ab2..8b3e54c2f 100644 --- a/srslte/lib/phch/test/prach_test_multi.c +++ b/srslte/lib/phch/test/prach_test_multi.c @@ -55,7 +55,7 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { parse_args(argc, argv); - prach_t *p = (prach_t*)malloc(sizeof(prach_t)); + srslte_prach_t *p = (srslte_prach_t*)malloc(sizeof(srslte_prach_t)); bool high_speed_flag = false; @@ -64,7 +64,7 @@ int main(int argc, char **argv) { cf_t preamble_sum[MAX_LEN]; memset(preamble_sum, 0, sizeof(cf_t)*MAX_LEN); - prach_init(p, + srslte_prach_init(p, N_ifft_ul, preamble_format, root_seq_idx, @@ -81,7 +81,7 @@ int main(int argc, char **argv) { for(seq_index=0;seq_indexN_seq; if(preamble_format == 2 || preamble_format == 3) prach_len /= 2; - prach_detect(p, 0, &preamble_sum[p->N_cp], prach_len, indices, &n_indices); + srslte_prach_detect(p, 0, &preamble_sum[p->N_cp], prach_len, indices, &n_indices); if(n_indices != n_seqs) return -1; @@ -107,7 +107,7 @@ int main(int argc, char **argv) { return -1; } - prach_free(p); + srslte_prach_free(p); free(p); printf("Done\n"); diff --git a/srslte/lib/phch/test/pusch_encode_test_mex.c b/srslte/lib/phch/test/pusch_encode_test_mex.c index 04fb13195..1512676a8 100644 --- a/srslte/lib/phch/test/pusch_encode_test_mex.c +++ b/srslte/lib/phch/test/pusch_encode_test_mex.c @@ -43,7 +43,7 @@ void help() { mexErrMsgTxt - ("sym=srslte_pusch_encode(ue, chs, trblkin, cqi, ri, ack)\n\n"); + ("sym=srslte_srslte_pusch_encode(ue, chs, trblkin, cqi, ri, ack)\n\n"); } /* the gateway function */ @@ -66,8 +66,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexErrMsgTxt("Field NULRB not found in UE config\n"); return; } - pusch_t pusch; - if (pusch_init(&pusch, cell)) { + srslte_pusch_t pusch; + if (srslte_pusch_init(&pusch, cell)) { mexErrMsgTxt("Error initiating PUSCH\n"); return; } @@ -76,7 +76,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexErrMsgTxt("Field RNTI not found in pusch config\n"); return; } - pusch_set_rnti(&pusch, (uint16_t) (rnti32 & 0xffff)); + srslte_pusch_set_rnti(&pusch, (uint16_t) (rnti32 & 0xffff)); @@ -86,14 +86,14 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexErrMsgTxt("Field NSubframe not found in UE config\n"); return; } - ra_mcs_t mcs; + srslte_ra_mcs_t mcs; char *mod_str = mexutils_get_char_struct(PUSCHCFG, "Modulation"); if (!strcmp(mod_str, "QPSK")) { - mcs.mod = LTE_QPSK; + mcs.mod = SRSLTE_MOD_QPSK; } else if (!strcmp(mod_str, "16QAM")) { - mcs.mod = LTE_QAM16; + mcs.mod = SRSLTE_MOD_16QAM; } else if (!strcmp(mod_str, "64QAM")) { - mcs.mod = LTE_QAM64; + mcs.mod = SRSLTE_MOD_64QAM; } else { mexErrMsgTxt("Unknown modulation\n"); return; @@ -109,8 +109,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } - ra_ul_alloc_t prb_alloc; - bzero(&prb_alloc, sizeof(ra_ul_alloc_t)); + srslte_srslte_ra_ul_alloc_t prb_alloc; + bzero(&prb_alloc, sizeof(srslte_srslte_ra_ul_alloc_t)); prb_alloc.L_prb = mexutils_read_f(p, &prbset); prb_alloc.n_prb[0] = prbset[0]; prb_alloc.n_prb[1] = prbset[0]; @@ -121,18 +121,18 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) uint8_t *trblkin = NULL; mcs.tbs = mexutils_read_uint8(TRBLKIN, &trblkin); - harq_t harq_process; - if (harq_init(&harq_process, cell)) { + srslte_harq_t harq_process; + if (srslte_harq_init(&harq_process, cell)) { mexErrMsgTxt("Error initiating HARQ process\n"); return; } - if (harq_setup_ul(&harq_process, mcs, 0, sf_idx, &prb_alloc)) { + if (srslte_harq_setup_ul(&harq_process, mcs, 0, sf_idx, &prb_alloc)) { mexErrMsgTxt("Error configuring HARQ process\n"); return; } uint32_t nof_re = SRSLTE_NRE*cell.nof_prb*2*SRSLTE_CP_NSYMB(cell.cp); - cf_t *sf_symbols = vec_malloc(sizeof(cf_t) * nof_re); + cf_t *sf_symbols = srslte_vec_malloc(sizeof(cf_t) * nof_re); if (!sf_symbols) { mexErrMsgTxt("malloc"); return; @@ -140,8 +140,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) bzero(sf_symbols, sizeof(cf_t) * nof_re); - uci_data_t uci_data; - bzero(&uci_data, sizeof(uci_data_t)); + srslte_uci_data_t uci_data; + bzero(&uci_data, sizeof(srslte_uci_data_t)); uci_data.uci_cqi_len = mexutils_read_uint8(CQI, &uci_data.uci_cqi); uint8_t *tmp; uci_data.uci_ri_len = mexutils_read_uint8(RI, &tmp); @@ -172,7 +172,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexPrintf("NofRE: %d, NofBits: %d, TBS: %d\n", harq_process.nof_re, harq_process.nof_bits, harq_process.mcs.tbs); - int r = pusch_uci_encode(&pusch, &harq_process, trblkin, uci_data, sf_symbols); + int r = srslte_pusch_uci_encode(&pusch, &harq_process, trblkin, uci_data, sf_symbols); if (r < 0) { mexErrMsgTxt("Error encoding PUSCH\n"); return; @@ -183,27 +183,27 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } if (rv > 0) { - if (harq_setup_ul(&harq_process, mcs, rv, sf_idx, &prb_alloc)) { + if (srslte_harq_setup_ul(&harq_process, mcs, rv, sf_idx, &prb_alloc)) { mexErrMsgTxt("Error configuring HARQ process\n"); return; } - r = pusch_uci_encode(&pusch, &harq_process, trblkin, uci_data, sf_symbols); + r = srslte_pusch_uci_encode(&pusch, &harq_process, trblkin, uci_data, sf_symbols); if (r < 0) { mexErrMsgTxt("Error encoding PUSCH\n"); return; } } - cf_t *scfdma = vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); + cf_t *scfdma = srslte_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, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb); - srslte_fft_set_normalize(&fft, true); - srslte_fft_set_freq_shift(&fft, 0.5); - lte_ifft_run_sf(&fft, sf_symbols, scfdma); + srslte_ofdm_t fft; + srslte_ofdm_rx_init(&fft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb); + srslte_ofdm_set_normalize(&fft, true); + srslte_ofdm_set_freq_shift(&fft, 0.5); + srslte_ofdm_rx_sf(&fft, sf_symbols, scfdma); // Matlab toolbox expects further normalization - vec_sc_prod_cfc(scfdma, 1.0/sqrtf(srslte_symbol_sz(cell.nof_prb)), scfdma, SRSLTE_SF_LEN_PRB(cell.nof_prb)); + srslte_vec_sc_prod_cfc(scfdma, 1.0/sqrtf(srslte_symbol_sz(cell.nof_prb)), scfdma, SRSLTE_SF_LEN_PRB(cell.nof_prb)); if (nlhs >= 1) { mexutils_write_cf(scfdma, &plhs[0], SRSLTE_SF_LEN_PRB(cell.nof_prb), 1); @@ -212,9 +212,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexutils_write_cf(sf_symbols, &plhs[1], nof_re, 1); } if (nlhs >= 3) { - mexutils_write_cf(pusch.pusch_z, &plhs[2], harq_process.nof_re, 1); + mexutils_write_cf(pusch.z, &plhs[2], harq_process.nof_re, 1); } - pusch_free(&pusch); + srslte_pusch_free(&pusch); free(trblkin); free(uci_data.uci_cqi); free(sf_symbols); diff --git a/srslte/lib/phch/test/pusch_test.c b/srslte/lib/phch/test/pusch_test.c index 71d19b99e..730c7395b 100644 --- a/srslte/lib/phch/test/pusch_test.c +++ b/srslte/lib/phch/test/pusch_test.c @@ -46,7 +46,7 @@ srslte_cell_t cell = { uint32_t cfi = 2; uint32_t tbs = 0; uint32_t subframe = 1; -srslte_mod_t modulation = LTE_QPSK; +srslte_mod_t modulation = SRSLTE_MOD_QPSK; uint32_t rv_idx = 0; uint32_t L_prb = 2; uint32_t n_prb = 0; @@ -65,7 +65,7 @@ void usage(char *prog) { printf("\t-r rv_idx [Default %d]\n", rv_idx); printf("\t-f cfi [Default %d]\n", cfi); printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); - printf("\t-v [set verbose to debug, default none]\n"); + printf("\t-v [set srslte_verbose to debug, default none]\n"); } void parse_args(int argc, char **argv) { @@ -75,16 +75,16 @@ void parse_args(int argc, char **argv) { case 'm': switch(atoi(argv[optind])) { case 1: - modulation = LTE_BPSK; + modulation = SRSLTE_MOD_BPSK; break; case 2: - modulation = LTE_QPSK; + modulation = SRSLTE_MOD_QPSK; break; case 4: - modulation = LTE_QAM16; + modulation = SRSLTE_MOD_16QAM; break; case 6: - modulation = LTE_QAM64; + modulation = SRSLTE_MOD_64QAM; break; default: fprintf(stderr, "Invalid modulation %d. Possible values: " @@ -120,7 +120,7 @@ void parse_args(int argc, char **argv) { cell.id = atoi(argv[optind]); break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(argv[0]); @@ -130,29 +130,29 @@ void parse_args(int argc, char **argv) { } int main(int argc, char **argv) { - pusch_t pusch; + srslte_pusch_t pusch; uint8_t *data = NULL; cf_t *sf_symbols = NULL; int ret = -1; struct timeval t[3]; - ra_mcs_t mcs; - ra_ul_alloc_t prb_alloc; - harq_t harq_process; + srslte_ra_mcs_t mcs; + srslte_srslte_ra_ul_alloc_t prb_alloc; + srslte_harq_t harq_process; parse_args(argc,argv); mcs.tbs = tbs; mcs.mod = modulation; - bzero(&prb_alloc, sizeof(ra_ul_alloc_t)); + bzero(&prb_alloc, sizeof(srslte_srslte_ra_ul_alloc_t)); - if (pusch_init(&pusch, cell)) { + if (srslte_pusch_init(&pusch, cell)) { fprintf(stderr, "Error creating PDSCH object\n"); goto quit; } - pusch_set_rnti(&pusch, 1234); + srslte_pusch_set_rnti(&pusch, 1234); - if (harq_init(&harq_process, cell)) { + if (srslte_harq_init(&harq_process, cell)) { fprintf(stderr, "Error initiating HARQ process\n"); goto quit; } @@ -163,8 +163,8 @@ int main(int argc, char **argv) { for (uint32_t i=0;i<20;i++) { tmp[i] = 1; } - uci_data_t uci_data; - bzero(&uci_data, sizeof(uci_data_t)); + srslte_uci_data_t uci_data; + bzero(&uci_data, sizeof(srslte_uci_data_t)); uci_data.beta_cqi = 2.0; uci_data.beta_ri = 2.0; uci_data.beta_ack = 2.0; @@ -177,30 +177,30 @@ int main(int argc, char **argv) { uci_data.uci_ri = 1; uci_data.uci_ack = 1; - ra_pusch_t pusch_dci; - pusch_dci.freq_hop_fl = freq_hop; + srslte_ra_pusch_t dci; + dci.freq_hop_fl = freq_hop; if (riv < 0) { - pusch_dci.type2_alloc.L_crb = L_prb; - pusch_dci.type2_alloc.RB_start = n_prb; + dci.type2_alloc.L_crb = L_prb; + dci.type2_alloc.RB_start = n_prb; } else { - ra_type2_from_riv((uint32_t) riv, &pusch_dci.type2_alloc.L_crb, &pusch_dci.type2_alloc.RB_start, cell.nof_prb, cell.nof_prb); + srslte_ra_type2_from_riv((uint32_t) riv, &dci.type2_alloc.L_crb, &dci.type2_alloc.RB_start, cell.nof_prb, cell.nof_prb); } - ra_ul_alloc(&prb_alloc, &pusch_dci, 0, cell.nof_prb); + srslte_ra_ul_alloc(&prb_alloc, &dci, 0, cell.nof_prb); - if (harq_setup_ul(&harq_process, mcs, 0, subframe, &prb_alloc)) { + if (srslte_harq_setup_ul(&harq_process, mcs, 0, subframe, &prb_alloc)) { fprintf(stderr, "Error configuring HARQ process\n"); goto quit; } - pusch_hopping_cfg_t ul_hopping; + srslte_pusch_hopping_cfg_t ul_hopping; ul_hopping.n_sb = 1; ul_hopping.hopping_offset = 0; - ul_hopping.hop_mode = hop_mode_inter_sf; + ul_hopping.hop_mode = SRSLTE_PUSCH_HOP_MODE_INTER_SF; ul_hopping.current_tx_nb = 0; - pusch_set_hopping_cfg(&pusch, &ul_hopping); + srslte_pusch_set_hopping_cfg(&pusch, &ul_hopping); uint32_t nof_re = SRSLTE_NRE*cell.nof_prb*2*SRSLTE_CP_NSYMB(cell.cp); - sf_symbols = vec_malloc(sizeof(cf_t) * nof_re); + sf_symbols = srslte_vec_malloc(sizeof(cf_t) * nof_re); if (!sf_symbols) { perror("malloc"); goto quit; @@ -216,33 +216,33 @@ int main(int argc, char **argv) { data[i] = 1; } - if (pusch_uci_encode(&pusch, &harq_process, data, uci_data, sf_symbols)) { + if (srslte_pusch_uci_encode(&pusch, &harq_process, data, uci_data, sf_symbols)) { fprintf(stderr, "Error encoding TB\n"); exit(-1); } if (rv_idx > 0) { - if (harq_setup_ul(&harq_process, mcs, rv_idx, subframe, &prb_alloc)) { + if (srslte_harq_setup_ul(&harq_process, mcs, rv_idx, subframe, &prb_alloc)) { fprintf(stderr, "Error configuring HARQ process\n"); goto quit; } - if (pusch_uci_encode(&pusch, &harq_process, data, uci_data, sf_symbols)) { + if (srslte_pusch_uci_encode(&pusch, &harq_process, data, uci_data, sf_symbols)) { fprintf(stderr, "Error encoding TB\n"); exit(-1); } } - cf_t *scfdma = vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); + cf_t *scfdma = srslte_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, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb); - srslte_fft_set_freq_shift(&fft, 0.5); - lte_ifft_run_sf(&fft, sf_symbols, scfdma); + srslte_ofdm_t fft; + srslte_ofdm_rx_init(&fft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb); + srslte_ofdm_set_freq_shift(&fft, 0.5); + srslte_ofdm_rx_sf(&fft, sf_symbols, scfdma); gettimeofday(&t[1], NULL); - //int r = pusch_decode(&pusch, slot_symbols[0], ce, 0, data, subframe, &harq_process, rv); + //int r = srslte_pusch_decode(&pusch, slot_symbols[0], ce, 0, data, subframe, &harq_process, rv); int r = 0; gettimeofday(&t[2], NULL); get_time_interval(t); @@ -256,8 +256,8 @@ int main(int argc, char **argv) { ret = 0; quit: - pusch_free(&pusch); - harq_free(&harq_process); + srslte_pusch_free(&pusch); + srslte_harq_free(&harq_process); if (sf_symbols) { free(sf_symbols); diff --git a/srslte/lib/phch/test/ulsch_encode_test_mex.c b/srslte/lib/phch/test/ulsch_encode_test_mex.c index c137c365a..e17b33d7f 100644 --- a/srslte/lib/phch/test/ulsch_encode_test_mex.c +++ b/srslte/lib/phch/test/ulsch_encode_test_mex.c @@ -40,26 +40,26 @@ void help() { mexErrMsgTxt - ("[cwout] = srslte_pusch_encode(ue, chs, trblkin, cqi, ri, ack)\n\n"); + ("[cwout] = srslte_srslte_pusch_encode(ue, chs, trblkin, cqi, ri, ack)\n\n"); } /* the gateway function */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { - sch_t ulsch; + srslte_sch_t ulsch; uint8_t *trblkin; - ra_mcs_t mcs; - ra_ul_alloc_t prb_alloc; - harq_t harq_process; + srslte_ra_mcs_t mcs; + srslte_srslte_ra_ul_alloc_t prb_alloc; + srslte_harq_t harq_process; uint32_t rv; - uci_data_t uci_data; - bzero(&uci_data, sizeof(uci_data_t)); + srslte_uci_data_t uci_data; + bzero(&uci_data, sizeof(srslte_uci_data_t)); if (nrhs < NOF_INPUTS) { help(); return; } - if (sch_init(&ulsch)) { + if (srslte_sch_init(&ulsch)) { mexErrMsgTxt("Error initiating ULSCH\n"); return; } @@ -67,7 +67,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) cell.nof_prb = 100; cell.id=1; cell.cp=SRSLTE_SRSLTE_CP_NORM; - if (harq_init(&harq_process, cell)) { + if (srslte_harq_init(&harq_process, cell)) { mexErrMsgTxt("Error initiating HARQ\n"); return; } @@ -110,11 +110,11 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) char *mod_str = mexutils_get_char_struct(PUSCHCFG, "Modulation"); if (!strcmp(mod_str, "QPSK")) { - mcs.mod = LTE_QPSK; + mcs.mod = SRSLTE_MOD_QPSK; } else if (!strcmp(mod_str, "16QAM")) { - mcs.mod = LTE_QAM16; + mcs.mod = SRSLTE_MOD_16QAM; } else if (!strcmp(mod_str, "64QAM")) { - mcs.mod = LTE_QAM64; + mcs.mod = SRSLTE_MOD_64QAM; } else { mexErrMsgTxt("Unknown modulation\n"); return; @@ -137,31 +137,31 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 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)) { + if (srslte_harq_setup_ul(&harq_process, mcs, 0, 0, &prb_alloc)) { mexErrMsgTxt("Error configuring HARQ process\n"); return; } - uint8_t *q_bits = vec_malloc(harq_process.nof_bits * sizeof(uint8_t)); + uint8_t *q_bits = srslte_vec_malloc(harq_process.nof_bits * sizeof(uint8_t)); if (!q_bits) { return; } - uint8_t *g_bits = vec_malloc(harq_process.nof_bits * sizeof(uint8_t)); + uint8_t *g_bits = srslte_vec_malloc(harq_process.nof_bits * sizeof(uint8_t)); if (!g_bits) { return; } - if (ulsch_uci_encode(&ulsch, &harq_process, trblkin, uci_data, g_bits, q_bits)) + if (srslte_ulsch_uci_encode(&ulsch, &harq_process, trblkin, uci_data, g_bits, q_bits)) { mexErrMsgTxt("Error encoding TB\n"); return; } if (rv > 0) { - if (harq_setup_ul(&harq_process, mcs, rv, 0, &prb_alloc)) { + if (srslte_harq_setup_ul(&harq_process, mcs, rv, 0, &prb_alloc)) { mexErrMsgTxt("Error configuring HARQ process\n"); return; } - if (ulsch_uci_encode(&ulsch, &harq_process, trblkin, uci_data, g_bits, q_bits)) { + if (srslte_ulsch_uci_encode(&ulsch, &harq_process, trblkin, uci_data, g_bits, q_bits)) { mexErrMsgTxt("Error encoding TB\n"); return; } @@ -171,8 +171,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexutils_write_uint8(q_bits, &plhs[0], harq_process.nof_bits, 1); } - sch_free(&ulsch); - harq_free(&harq_process); + srslte_sch_free(&ulsch); + srslte_harq_free(&harq_process); free(trblkin); free(g_bits); diff --git a/srslte/lib/resampling/src/decim.c b/srslte/lib/resampling/src/decim.c index 9398e500a..6767c3a2f 100644 --- a/srslte/lib/resampling/src/decim.c +++ b/srslte/lib/resampling/src/decim.c @@ -32,7 +32,7 @@ /* Performs integer linear decimation by a factor of M */ -void decim_c(cf_t *input, cf_t *output, int M, int len) { +void srslte_decim_c(cf_t *input, cf_t *output, int M, int len) { int i; for (i=0;idiff_vec = vec_malloc(vector_len * sizeof(cf_t)); + q->diff_vec = srslte_vec_malloc(vector_len * sizeof(cf_t)); if (!q->diff_vec) { perror("malloc"); return SRSLTE_ERROR; @@ -114,24 +114,24 @@ int srslte_interp_linear_vector_init(srslte_interp_linvec_t *q, uint32_t vector_ return ret; } -void srslte_interp_linear_vector_free(srslte_interp_linvec_t *q) { +void srslte_interp_linear_vector_free(srslte_interp_linsrslte_vec_t *q) { if (q->diff_vec) { free(q->diff_vec); } - bzero(q, sizeof(srslte_interp_linvec_t)); + bzero(q, sizeof(srslte_interp_linsrslte_vec_t)); } -void srslte_interp_linear_vector(srslte_interp_linvec_t *q, cf_t *in0, cf_t *in1, cf_t *between, uint32_t M) +void srslte_interp_linear_vector(srslte_interp_linsrslte_vec_t *q, cf_t *in0, cf_t *in1, cf_t *between, uint32_t M) { uint32_t i; - vec_sub_ccc(in1, in0, q->diff_vec, q->vector_len); - vec_sc_prod_cfc(q->diff_vec, (float) 1/M, q->diff_vec, q->vector_len); - vec_sum_ccc(in0, q->diff_vec, between, q->vector_len); + srslte_vec_sub_ccc(in1, in0, q->diff_vec, q->vector_len); + srslte_vec_sc_prod_cfc(q->diff_vec, (float) 1/M, q->diff_vec, q->vector_len); + srslte_vec_sum_ccc(in0, q->diff_vec, between, q->vector_len); for (i=0;idiff_vec, &between[q->vector_len], q->vector_len); + srslte_vec_sum_ccc(between, q->diff_vec, &between[q->vector_len], q->vector_len); between += q->vector_len; } } @@ -142,18 +142,18 @@ int srslte_interp_linear_init(srslte_interp_lin_t *q, uint32_t vector_len, uint3 if (q) { bzero(q, sizeof(srslte_interp_lin_t)); ret = SRSLTE_SUCCESS; - q->diff_vec = vec_malloc(vector_len * sizeof(cf_t)); + q->diff_vec = srslte_vec_malloc(vector_len * sizeof(cf_t)); if (!q->diff_vec) { perror("malloc"); return SRSLTE_ERROR; } - q->diff_vec2 = vec_malloc(M * vector_len * sizeof(cf_t)); + q->diff_vec2 = srslte_vec_malloc(M * vector_len * sizeof(cf_t)); if (!q->diff_vec2) { perror("malloc"); free(q->diff_vec); return SRSLTE_ERROR; } - q->ramp = vec_malloc(M * sizeof(float)); + q->ramp = srslte_vec_malloc(M * sizeof(float)); if (!q->ramp) { perror("malloc"); free(q->ramp); @@ -196,16 +196,16 @@ void srslte_interp_linear_offset(srslte_interp_lin_t *q, cf_t *input, cf_t *outp for (j=0;jM; } - vec_sub_ccc(&input[1], input, q->diff_vec, (q->vector_len-1)); - vec_sc_prod_cfc(q->diff_vec, (float) 1/q->M, q->diff_vec, q->vector_len-1); + srslte_vec_sub_ccc(&input[1], input, q->diff_vec, (q->vector_len-1)); + srslte_vec_sc_prod_cfc(q->diff_vec, (float) 1/q->M, q->diff_vec, q->vector_len-1); for (i=0;ivector_len-1;i++) { for (j=0;jM;j++) { output[i*q->M+j+off_st] = input[i]; q->diff_vec2[i*q->M+j] = q->diff_vec[i]; } - vec_prod_cfc(&q->diff_vec2[i*q->M],q->ramp,&q->diff_vec2[i*q->M],q->M); + srslte_vec_prod_cfc(&q->diff_vec2[i*q->M],q->ramp,&q->diff_vec2[i*q->M],q->M); } - vec_sum_ccc(&output[off_st], q->diff_vec2, &output[off_st], q->M*(q->vector_len-1)); + srslte_vec_sum_ccc(&output[off_st], q->diff_vec2, &output[off_st], q->M*(q->vector_len-1)); if (q->vector_len > 1) { diff = input[q->vector_len-1]-input[q->vector_len-2]; diff --git a/srslte/lib/resampling/src/resample_arb.c b/srslte/lib/resampling/src/resample_arb.c index d8e5c29f4..4798e1c1f 100644 --- a/srslte/lib/resampling/src/resample_arb.c +++ b/srslte/lib/resampling/src/resample_arb.c @@ -30,7 +30,7 @@ #include "srslte/resampling/resample_arb.h" #include "srslte/utils/debug.h" -float resample_arb_polyfilt[RESAMPLE_ARB_N][RESAMPLE_ARB_M] = +float srslte_resample_arb_polyfilt[SRSLTE_RESAMPLE_ARB_N][SRSLTE_RESAMPLE_ARB_M] = {{0,0.002400347599485495,-0.006922416132556366,0.0179104136912176,0.99453086623794,-0.008521087756729117,0.0008598969867484128,0.0004992625165376107}, {-0.001903604727400391,0.004479591950094871,-0.01525319260830623,0.04647449496926549,0.9910477342662829,-0.03275243420114668,0.008048813755373533,-0.001216900416836847}, {-0.001750442300940216,0.006728826416921727,-0.02407540632178267,0.07708575473589654,0.9841056525667189,-0.05473739187922162,0.01460652754040275,-0.002745266140572769}, @@ -66,7 +66,7 @@ float resample_arb_polyfilt[RESAMPLE_ARB_N][RESAMPLE_ARB_M] = // TODO: use lte/utils/vector.h and Volk -cf_t resample_arb_dot_prod(cf_t* x, float *y, int len) +cf_t srslte_resample_arb_dot_prod(cf_t* x, float *y, int len) { cf_t res = 0+0*I; for(int i=0;ireg[1], &q->reg[0], (RESAMPLE_ARB_M-1)*sizeof(cf_t)); + memmove(&q->reg[1], &q->reg[0], (SRSLTE_RESAMPLE_ARB_M-1)*sizeof(cf_t)); q->reg[0] = x; } // Initialize our struct -void resample_arb_init(resample_arb_t *q, float rate){ - memset(q->reg, 0, RESAMPLE_ARB_M*sizeof(cf_t)); +void srslte_resample_arb_init(srslte_resample_arb_t *q, float rate){ + memset(q->reg, 0, SRSLTE_RESAMPLE_ARB_M*sizeof(cf_t)); q->acc = 0.0; q->rate = rate; - q->step = (1/rate)*RESAMPLE_ARB_N; + q->step = (1/rate)*SRSLTE_RESAMPLE_ARB_N; } // Resample a block of input data -int resample_arb_compute(resample_arb_t *q, cf_t *input, cf_t *output, int n_in){ +int srslte_resample_arb_compute(srslte_resample_arb_t *q, cf_t *input, cf_t *output, int n_in){ int cnt = 0; int n_out = 0; int idx = 0; while(cnt < n_in) { - *output = resample_arb_dot_prod(q->reg, resample_arb_polyfilt[idx], RESAMPLE_ARB_M); + *output = srslte_resample_arb_dot_prod(q->reg, srslte_resample_arb_polyfilt[idx], SRSLTE_RESAMPLE_ARB_M); output++; n_out++; q->acc += q->step; idx = (int)roundf(q->acc); - while(idx >= RESAMPLE_ARB_N){ - q->acc -= RESAMPLE_ARB_N; - idx -= RESAMPLE_ARB_N; + while(idx >= SRSLTE_RESAMPLE_ARB_N){ + q->acc -= SRSLTE_RESAMPLE_ARB_N; + idx -= SRSLTE_RESAMPLE_ARB_N; if(cnt < n_in) - resample_arb_push(q, input[cnt++]); + srslte_resample_arb_push(q, input[cnt++]); } } return n_out; diff --git a/srslte/lib/resampling/test/resample_arb_bench.c b/srslte/lib/resampling/test/resample_arb_bench.c index 47e23b897..9c94344f5 100644 --- a/srslte/lib/resampling/test/resample_arb_bench.c +++ b/srslte/lib/resampling/test/resample_arb_bench.c @@ -19,11 +19,11 @@ int main(int argc, char **argv) { for(int i=0;i #include "srslte/scrambling/scrambling.h" -void scrambling_f(srslte_sequence_t *s, float *data) { - scrambling_f_offset(s, data, 0, s->len); +void srslte_scrambling_f(srslte_sequence_t *s, float *data) { + srslte_scrambling_f_offset(s, data, 0, s->len); } -void scrambling_f_offset(srslte_sequence_t *s, float *data, int offset, int len) { +void srslte_scrambling_f_offset(srslte_sequence_t *s, float *data, int offset, int len) { int i; assert (len + offset <= s->len); @@ -44,11 +44,11 @@ void scrambling_f_offset(srslte_sequence_t *s, float *data, int offset, int len) } } -void scrambling_c(srslte_sequence_t *s, cf_t *data) { - scrambling_c_offset(s, data, 0, s->len); +void srslte_scrambling_c(srslte_sequence_t *s, cf_t *data) { + srslte_scrambling_c_offset(s, data, 0, s->len); } -void scrambling_c_offset(srslte_sequence_t *s, cf_t *data, int offset, int len) { +void srslte_scrambling_c_offset(srslte_sequence_t *s, cf_t *data, int offset, int len) { int i; assert (len + offset <= s->len); @@ -57,7 +57,7 @@ void scrambling_c_offset(srslte_sequence_t *s, cf_t *data, int offset, int len) } } -void scrambling_b(srslte_sequence_t *s, uint8_t *data) { +void srslte_scrambling_b(srslte_sequence_t *s, uint8_t *data) { int i; for (i = 0; i < s->len; i++) { @@ -65,7 +65,7 @@ void scrambling_b(srslte_sequence_t *s, uint8_t *data) { } } -void scrambling_b_offset(srslte_sequence_t *s, uint8_t *data, int offset, int len) { +void srslte_scrambling_b_offset(srslte_sequence_t *s, uint8_t *data, int offset, int len) { int i; assert (len + offset <= s->len); for (i = 0; i < len; i++) { @@ -74,7 +74,7 @@ void scrambling_b_offset(srslte_sequence_t *s, uint8_t *data, int offset, int le } /* As defined in 36.211 5.3.1 */ -void scrambling_b_offset_pusch(srslte_sequence_t *s, uint8_t *data, int offset, int len) { +void srslte_scrambling_b_offset_pusch(srslte_sequence_t *s, uint8_t *data, int offset, int len) { int i; assert (len + offset <= s->len); for (i = 0; i < len; i++) { @@ -90,73 +90,3 @@ void scrambling_b_offset_pusch(srslte_sequence_t *s, uint8_t *data, int offset, } } -/** High-level API */ - -int compute_sequences(scrambling_hl* h) { - - switch (h->init.channel) { - case SCRAMBLING_PBCH: - return srslte_sequence_pbch(&h->obj.seq[0], - 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++) { - srslte_sequence_pdsch(&h->obj.seq[ns], h->init.nrnti, 0, 2 * ns, h->init.cell_id, - SRSLTE_NSOFT_BITS); - } - return 0; - case SCRAMBLING_PCFICH: - for (int ns = 0; ns < SRSLTE_NSUBFRAMES_X_FRAME; ns++) { - srslte_sequence_pcfich(&h->obj.seq[ns], 2 * ns, h->init.cell_id); - } - return 0; - case SCRAMBLING_PDCCH: - for (int ns = 0; ns < SRSLTE_NSUBFRAMES_X_FRAME; ns++) { - srslte_sequence_pdcch(&h->obj.seq[ns], 2 * ns, h->init.cell_id, SRSLTE_NSOFT_BITS); - } - return 0; - case SCRAMBLING_PMCH: - case SCRAMBLING_PUCCH: - fprintf(stderr, "Not implemented\n"); - return -1; - default: - fprintf(stderr, "Invalid channel %d\n", h->init.channel); - return -1; - } -} - -int scrambling_initialize(scrambling_hl* h) { - - bzero(&h->obj, sizeof(scrambling_t)); - - return compute_sequences(h); -} - -/** This function can be called in a subframe (1ms) basis for LTE */ -int scrambling_work(scrambling_hl* hl) { - int sf; - if (hl->init.channel == SCRAMBLING_PBCH) { - sf = 0; - } else { - sf = hl->ctrl_in.subframe; - } - srslte_sequence_t *seq = &hl->obj.seq[sf]; - - if (hl->init.hard) { - memcpy(hl->output, hl->input, sizeof(uint8_t) * hl->in_len); - scrambling_b(seq, hl->output); - } else { - memcpy(hl->output, hl->input, sizeof(float) * hl->in_len); - scrambling_f(seq, hl->output); - } - hl->out_len = hl->in_len; - return 0; -} - -int scrambling_stop(scrambling_hl* hl) { - int i; - for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { - srslte_sequence_free(&hl->obj.seq[i]); - } - return 0; -} - diff --git a/srslte/lib/scrambling/test/scrambling_test.c b/srslte/lib/scrambling/test/scrambling_test.c index d8bffae86..24333118e 100644 --- a/srslte/lib/scrambling/test/scrambling_test.c +++ b/srslte/lib/scrambling/test/scrambling_test.c @@ -118,8 +118,8 @@ int main(int argc, char **argv) { scrambled_b[i] = input_b[i]; } - scrambling_b(&seq, scrambled_b); - scrambling_b(&seq, scrambled_b); + srslte_scrambling_b(&seq, scrambled_b); + srslte_scrambling_b(&seq, scrambled_b); for (i=0;itab, CFO_CEXPTAB_SIZE)) { + if (srslte_cexptab_init(&h->tab, SRSLTE_CFO_CEXPTAB_SIZE)) { goto clean; } - h->cur_cexp = vec_malloc(sizeof(cf_t) * nsamples); + h->cur_cexp = srslte_vec_malloc(sizeof(cf_t) * nsamples); if (!h->cur_cexp) { goto clean; } - h->tol = CFO_TOLERANCE; + h->tol = SRSLTE_CFO_TOLERANCE; h->last_freq = 0; h->nsamples = nsamples; - cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, h->nsamples); + srslte_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, h->nsamples); ret = SRSLTE_SUCCESS; clean: if (ret == SRSLTE_ERROR) { - cfo_free(h); + srslte_cfo_free(h); } return ret; } -void cfo_free(cfo_t *h) { - cexptab_free(&h->tab); +void srslte_cfo_free(srslte_cfo_t *h) { + srslte_cexptab_free(&h->tab); if (h->cur_cexp) { free(h->cur_cexp); } bzero(h, sizeof(cf_t)); } -void cfo_set_tol(cfo_t *h, float tol) { +void srslte_cfo_set_tol(srslte_cfo_t *h, float tol) { h->tol = tol; } -int cfo_realloc(cfo_t *h, uint32_t samples) { +int srslte_cfo_realloc(srslte_cfo_t *h, uint32_t samples) { h->cur_cexp = realloc(h->cur_cexp, sizeof(cf_t) * samples); if (!h->cur_cexp) { perror("realloc"); return SRSLTE_ERROR; } - cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, samples); + srslte_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, samples); h->nsamples = samples; return SRSLTE_SUCCESS; } -void cfo_correct(cfo_t *h, cf_t *input, cf_t *output, float freq) { +void srslte_cfo_correct(srslte_cfo_t *h, cf_t *input, cf_t *output, float freq) { if (fabs(h->last_freq - freq) > h->tol) { h->last_freq = freq; - cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, h->nsamples); + srslte_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, h->nsamples); DEBUG("CFO generating new table for frequency %.4f\n", freq); } - vec_prod_ccc(h->cur_cexp, input, output, h->nsamples); + srslte_vec_prod_ccc(h->cur_cexp, input, output, h->nsamples); } diff --git a/srslte/lib/sync/src/find_sss.c b/srslte/lib/sync/src/find_sss.c index 0a3b0c1c7..5f3f0fa4d 100644 --- a/srslte/lib/sync/src/find_sss.c +++ b/srslte/lib/sync/src/find_sss.c @@ -36,62 +36,62 @@ #define MAX_M 3 -static void corr_all_zs(cf_t z[N_SSS], float s[N_SSS][N_SSS-1], float output[N_SSS]) { +static void corr_all_zs(cf_t z[SRSLTE_SSS_N], float s[SRSLTE_SSS_N][SRSLTE_SSS_N-1], float output[SRSLTE_SSS_N]) { uint32_t m; - cf_t tmp[N_SSS]; + cf_t tmp[SRSLTE_SSS_N]; - for (m = 0; m < N_SSS; m++) { - tmp[m] = vec_dot_prod_cfc(z, s[m], N_SSS - 1); + for (m = 0; m < SRSLTE_SSS_N; m++) { + tmp[m] = srslte_vec_dot_prod_cfc(z, s[m], SRSLTE_SSS_N - 1); } - vec_abs_square_cf(tmp, output, N_SSS); + srslte_vec_abs_square_cf(tmp, output, SRSLTE_SSS_N); } -static void corr_all_sz_partial(cf_t z[N_SSS], float s[N_SSS][N_SSS], uint32_t M, float output[N_SSS]) { - uint32_t Nm = N_SSS/M; - cf_t tmp[N_SSS]; - float tmp_abs[MAX_M-1][N_SSS]; +static void corr_all_sz_partial(cf_t z[SRSLTE_SSS_N], float s[SRSLTE_SSS_N][SRSLTE_SSS_N], uint32_t M, float output[SRSLTE_SSS_N]) { + uint32_t Nm = SRSLTE_SSS_N/M; + cf_t tmp[SRSLTE_SSS_N]; + float tmp_abs[MAX_M-1][SRSLTE_SSS_N]; int j, m; float *ptr; for (j=0;jdftp_input, input, input_fft); + srslte_dft_run_c(&q->dftp_input, input, input_fft); if (ce) { - vec_prod_conj_ccc(&input_fft[q->fft_size/2-N_SSS], ce, &input_fft[q->fft_size/2-N_SSS], 2*N_SSS); + srslte_vec_prod_conj_ccc(&input_fft[q->fft_size/2-SRSLTE_SSS_N], ce, &input_fft[q->fft_size/2-SRSLTE_SSS_N], 2*SRSLTE_SSS_N); } - for (int i = 0; i < N_SSS; i++) { - y[0][i] = input_fft[q->fft_size/2-N_SSS + 2 * i]; - y[1][i] = input_fft[q->fft_size/2-N_SSS + 2 * i + 1]; + for (int i = 0; i < SRSLTE_SSS_N; i++) { + y[0][i] = input_fft[q->fft_size/2-SRSLTE_SSS_N + 2 * i]; + y[1][i] = input_fft[q->fft_size/2-SRSLTE_SSS_N + 2 * i + 1]; } - vec_prod_cfc(y[0], q->fc_tables[q->N_id_2].c[0], y[0], N_SSS); - vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].c[1], y[1], N_SSS); + srslte_vec_prod_cfc(y[0], q->fc_tables[q->N_id_2].c[0], y[0], SRSLTE_SSS_N); + srslte_vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].c[1], y[1], SRSLTE_SSS_N); } -int sss_synch_m0m1_diff(sss_synch_t *q, cf_t *input, uint32_t *m0, float *m0_value, +int srslte_sss_synch_m0m1_diff(srslte_sss_synch_t *q, cf_t *input, uint32_t *m0, float *m0_value, uint32_t *m1, float *m1_value) { - return sss_synch_m0m1_diff_coh(q, input, NULL, m0, m0_value, m1, m1_value); + return srslte_sss_synch_m0m1_diff_coh(q, input, NULL, m0, m0_value, m1, m1_value); } /* Differential SSS estimation. @@ -102,7 +102,7 @@ int sss_synch_m0m1_diff(sss_synch_t *q, cf_t *input, uint32_t *m0, float *m0_val * */ -int sss_synch_m0m1_diff_coh(sss_synch_t *q, cf_t *input, cf_t ce[2*N_SSS], uint32_t *m0, float *m0_value, +int srslte_sss_synch_m0m1_diff_coh(srslte_sss_synch_t *q, cf_t *input, cf_t ce[2*SRSLTE_SSS_N], uint32_t *m0, float *m0_value, uint32_t *m1, float *m1_value) { @@ -114,22 +114,22 @@ int sss_synch_m0m1_diff_coh(sss_synch_t *q, cf_t *input, cf_t ce[2*N_SSS], uint3 m1 != NULL) { - cf_t yprod[N_SSS]; - cf_t y[2][N_SSS]; + cf_t yprod[SRSLTE_SSS_N]; + cf_t y[2][SRSLTE_SSS_N]; extract_pair_sss(q, input, ce, y); - vec_prod_conj_ccc(&y[0][1], y[0], yprod, N_SSS - 1); + srslte_vec_prod_conj_ccc(&y[0][1], y[0], yprod, SRSLTE_SSS_N - 1); corr_all_zs(yprod, q->fc_tables[q->N_id_2].sd, q->corr_output_m0); - *m0 = vec_max_fi(q->corr_output_m0, N_SSS); + *m0 = srslte_vec_max_fi(q->corr_output_m0, SRSLTE_SSS_N); if (m0_value) { *m0_value = q->corr_output_m0[*m0]; } - vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].z1[*m0], y[1], N_SSS); - vec_prod_conj_ccc(&y[1][1], y[1], yprod, N_SSS - 1); + srslte_vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].z1[*m0], y[1], SRSLTE_SSS_N); + srslte_vec_prod_conj_ccc(&y[1][1], y[1], yprod, SRSLTE_SSS_N - 1); corr_all_zs(yprod, q->fc_tables[q->N_id_2].sd, q->corr_output_m1); - *m1 = vec_max_fi(q->corr_output_m1, N_SSS); + *m1 = srslte_vec_max_fi(q->corr_output_m1, SRSLTE_SSS_N); if (m1_value) { *m1_value = q->corr_output_m1[*m1]; } @@ -145,7 +145,7 @@ int sss_synch_m0m1_diff_coh(sss_synch_t *q, cf_t *input, cf_t ce[2*N_SSS], uint3 * Jung-In Kim, Jung-Su Han, Hee-Jin Roh and Hyung-Jin Choi */ -int sss_synch_m0m1_partial(sss_synch_t *q, cf_t *input, uint32_t M, cf_t ce[2*N_SSS], uint32_t *m0, float *m0_value, +int srslte_sss_synch_m0m1_partial(srslte_sss_synch_t *q, cf_t *input, uint32_t M, cf_t ce[2*SRSLTE_SSS_N], uint32_t *m0, float *m0_value, uint32_t *m1, float *m1_value) { @@ -157,18 +157,18 @@ int sss_synch_m0m1_partial(sss_synch_t *q, cf_t *input, uint32_t M, cf_t ce[2*N_ m1 != NULL && M <= MAX_M) { - cf_t y[2][N_SSS]; + cf_t y[2][SRSLTE_SSS_N]; extract_pair_sss(q, input, ce, y); corr_all_sz_partial(y[0], q->fc_tables[q->N_id_2].s, M, q->corr_output_m0); - *m0 = vec_max_fi(q->corr_output_m0, N_SSS); + *m0 = srslte_vec_max_fi(q->corr_output_m0, SRSLTE_SSS_N); if (m0_value) { *m0_value = q->corr_output_m0[*m0]; } - vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].z1[*m0], y[1], N_SSS); + srslte_vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].z1[*m0], y[1], SRSLTE_SSS_N); corr_all_sz_partial(y[1], q->fc_tables[q->N_id_2].s, M, q->corr_output_m1); - *m1 = vec_max_fi(q->corr_output_m1, N_SSS); + *m1 = srslte_vec_max_fi(q->corr_output_m1, SRSLTE_SSS_N); if (m1_value) { *m1_value = q->corr_output_m1[*m1]; } @@ -177,26 +177,26 @@ int sss_synch_m0m1_partial(sss_synch_t *q, cf_t *input, uint32_t M, cf_t ce[2*N_ return ret; } -void convert_tables(struct fc_tables *fc_tables, struct sss_tables *in) { +void convert_tables(srslte_sss_fc_tables_t *fc_tables, srslte_sss_tables_t *in) { uint32_t i, j; - for (i = 0; i < N_SSS; i++) { - for (j = 0; j < N_SSS; j++) { + for (i = 0; i < SRSLTE_SSS_N; i++) { + for (j = 0; j < SRSLTE_SSS_N; j++) { fc_tables->z1[i][j] = (float) in->z1[i][j]; } } - for (i = 0; i < N_SSS; i++) { - for (j = 0; j < N_SSS; j++) { + for (i = 0; i < SRSLTE_SSS_N; i++) { + for (j = 0; j < SRSLTE_SSS_N; j++) { fc_tables->s[i][j] = (float) in->s[i][j]; } } - for (i = 0; i < N_SSS; i++) { - for (j = 0; j < N_SSS - 1; j++) { + for (i = 0; i < SRSLTE_SSS_N; i++) { + for (j = 0; j < SRSLTE_SSS_N - 1; j++) { fc_tables->sd[i][j] = (float) in->s[i][j + 1] * in->s[i][j]; } } for (i = 0; i < 2; i++) { - for (j = 0; j < N_SSS; j++) { + for (j = 0; j < SRSLTE_SSS_N; j++) { fc_tables->c[i][j] = (float) in->c[i][j]; } } diff --git a/srslte/lib/sync/src/gen_sss.c b/srslte/lib/sync/src/gen_sss.c index ab5681d69..b2305b934 100644 --- a/srslte/lib/sync/src/gen_sss.c +++ b/srslte/lib/sync/src/gen_sss.c @@ -38,32 +38,32 @@ void generate_zsc_tilde(int *z_tilde, int *s_tilde, int *c_tilde) { int i; - int x[N_SSS]; - bzero(x, sizeof(int) * N_SSS); + int x[SRSLTE_SSS_N]; + bzero(x, sizeof(int) * SRSLTE_SSS_N); x[4] = 1; for (i = 0; i < 26; i++) x[i + 5] = (x[i + 2] + x[i]) % 2; - for (i = 0; i < N_SSS; i++) + for (i = 0; i < SRSLTE_SSS_N; i++) s_tilde[i] = 1 - 2 * x[i]; for (i = 0; i < 26; i++) x[i + 5] = (x[i + 3] + x[i]) % 2; - for (i = 0; i < N_SSS; i++) + for (i = 0; i < SRSLTE_SSS_N; i++) c_tilde[i] = 1 - 2 * x[i]; for (i = 0; i < 26; i++) x[i + 5] = (x[i + 4] + x[i + 2] + x[i + 1] + x[i]) % 2; - for (i = 0; i < N_SSS; i++) + for (i = 0; i < SRSLTE_SSS_N; i++) z_tilde[i] = 1 - 2 * x[i]; } void generate_m0m1(uint32_t N_id_1, uint32_t *m0, uint32_t *m1) { - uint32_t q_prime = N_id_1 / (N_SSS - 1); - uint32_t q = (N_id_1 + (q_prime * (q_prime + 1) / 2)) / (N_SSS - 1); + uint32_t q_prime = N_id_1 / (SRSLTE_SSS_N - 1); + uint32_t q = (N_id_1 + (q_prime * (q_prime + 1) / 2)) / (SRSLTE_SSS_N - 1); uint32_t m_prime = N_id_1 + (q * (q + 1) / 2); - *m0 = m_prime % N_SSS; - *m1 = (*m0 + m_prime / N_SSS + 1) % N_SSS; + *m0 = m_prime % SRSLTE_SSS_N; + *m1 = (*m0 + m_prime / SRSLTE_SSS_N + 1) % SRSLTE_SSS_N; } @@ -80,42 +80,42 @@ void generate_N_id_1_table(uint32_t table[30][30]) { void generate_s(int *s, int *s_tilde, uint32_t m0_m1) { uint32_t i; - for (i = 0; i < N_SSS; i++) { - s[i] = s_tilde[(i + m0_m1) % N_SSS]; + for (i = 0; i < SRSLTE_SSS_N; i++) { + s[i] = s_tilde[(i + m0_m1) % SRSLTE_SSS_N]; } } -void generate_s_all(int s[N_SSS][N_SSS], int *s_tilde) { +void generate_s_all(int s[SRSLTE_SSS_N][SRSLTE_SSS_N], int *s_tilde) { uint32_t i; - for (i = 0; i < N_SSS; i++) { + for (i = 0; i < SRSLTE_SSS_N; i++) { generate_s(s[i], s_tilde, i); } } void generate_c(int *c, int *c_tilde, uint32_t N_id_2, bool is_c0) { uint32_t i; - for (i = 0; i < N_SSS; i++) { - c[i] = c_tilde[(i + N_id_2 + (is_c0 ? 3 : 0)) % N_SSS]; + for (i = 0; i < SRSLTE_SSS_N; i++) { + c[i] = c_tilde[(i + N_id_2 + (is_c0 ? 3 : 0)) % SRSLTE_SSS_N]; } } void generate_z(int *z, int *z_tilde, uint32_t m0_m1) { uint32_t i; - for (i = 0; i < N_SSS; i++) { - z[i] = z_tilde[(i + (m0_m1 % 8)) % N_SSS]; + for (i = 0; i < SRSLTE_SSS_N; i++) { + z[i] = z_tilde[(i + (m0_m1 % 8)) % SRSLTE_SSS_N]; } } -void generate_z_all(int z[N_SSS][N_SSS], int *z_tilde) { +void generate_z_all(int z[SRSLTE_SSS_N][SRSLTE_SSS_N], int *z_tilde) { uint32_t i; - for (i = 0; i < N_SSS; i++) { + for (i = 0; i < SRSLTE_SSS_N; i++) { generate_z(z[i], z_tilde, i); } } -void generate_sss_all_tables(struct sss_tables *tables, uint32_t N_id_2) { +void generate_sss_all_tables(srslte_sss_tables_t *tables, uint32_t N_id_2) { uint32_t i; - int s_t[N_SSS], c_t[N_SSS], z_t[N_SSS]; + int s_t[SRSLTE_SSS_N], c_t[SRSLTE_SSS_N], z_t[SRSLTE_SSS_N]; generate_zsc_tilde(z_t, s_t, c_t); generate_s_all(tables->s, s_t); @@ -125,15 +125,15 @@ void generate_sss_all_tables(struct sss_tables *tables, uint32_t N_id_2) { } } -void sss_generate(float *signal0, float *signal5, uint32_t cell_id) { +void srslte_sss_generate(float *signal0, float *signal5, uint32_t cell_id) { uint32_t i; uint32_t id1 = cell_id / 3; uint32_t id2 = cell_id % 3; uint32_t m0; uint32_t m1; - int s_t[N_SSS], c_t[N_SSS], z_t[N_SSS]; - int s0[N_SSS], s1[N_SSS], c0[N_SSS], c1[N_SSS], z1_0[N_SSS], z1_1[N_SSS]; + int s_t[SRSLTE_SSS_N], c_t[SRSLTE_SSS_N], z_t[SRSLTE_SSS_N]; + int s0[SRSLTE_SSS_N], s1[SRSLTE_SSS_N], c0[SRSLTE_SSS_N], c1[SRSLTE_SSS_N], z1_0[SRSLTE_SSS_N], z1_1[SRSLTE_SSS_N]; generate_m0m1(id1, &m0, &m1); generate_zsc_tilde(z_t, s_t, c_t); @@ -147,13 +147,13 @@ void sss_generate(float *signal0, float *signal5, uint32_t cell_id) { generate_z(z1_0, z_t, m0); generate_z(z1_1, z_t, m1); - for (i = 0; i < N_SSS; i++) { + for (i = 0; i < SRSLTE_SSS_N; i++) { /** Even Resource Elements: Sub-frame 0*/ signal0[2 * i] = (float) (s0[i] * c0[i]); /** Odd Resource Elements: Sub-frame 0*/ signal0[2 * i + 1] = (float) (s1[i] * c1[i] * z1_0[i]); } - for (i = 0; i < N_SSS; i++) { + for (i = 0; i < SRSLTE_SSS_N; i++) { /** Even Resource Elements: Sub-frame 5*/ signal5[2 * i] = (float) (s1[i] * c0[i]); /** Odd Resource Elements: Sub-frame 5*/ diff --git a/srslte/lib/sync/src/pss.c b/srslte/lib/sync/src/pss.c index 6a00fe9b9..a23b5f75b 100644 --- a/srslte/lib/sync/src/pss.c +++ b/srslte/lib/sync/src/pss.c @@ -33,13 +33,13 @@ #include #include "srslte/sync/pss.h" -#include "srslte/utils/dft.h" +#include "srslte/dft/dft.h" #include "srslte/utils/vector.h" #include "srslte/utils/convolution.h" #include "srslte/utils/debug.h" -int pss_synch_init_N_id_2(cf_t *pss_signal_time, cf_t *pss_signal_freq, uint32_t N_id_2, uint32_t fft_size) { +int srslte_pss_synch_init_N_id_2(cf_t *pss_signal_time, cf_t *pss_signal_freq, uint32_t N_id_2, uint32_t fft_size) { srslte_dft_plan_t plan; cf_t pss_signal_pad[2048]; int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -48,25 +48,25 @@ int pss_synch_init_N_id_2(cf_t *pss_signal_time, cf_t *pss_signal_freq, uint32_t fft_size <= 2048) { - pss_generate(pss_signal_time, N_id_2); + srslte_pss_generate(pss_signal_time, N_id_2); bzero(pss_signal_pad, fft_size * sizeof(cf_t)); bzero(pss_signal_freq, fft_size * sizeof(cf_t)); - memcpy(&pss_signal_pad[(fft_size-PSS_LEN)/2], pss_signal_time, PSS_LEN * sizeof(cf_t)); + memcpy(&pss_signal_pad[(fft_size-SRSLTE_PSS_LEN)/2], pss_signal_time, SRSLTE_PSS_LEN * sizeof(cf_t)); - if (dft_plan(&plan, fft_size, BACKWARD, COMPLEX)) { + if (srslte_dft_plan(&plan, fft_size, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { return SRSLTE_ERROR; } - dft_plan_set_mirror(&plan, true); - dft_plan_set_dc(&plan, true); - dft_plan_set_norm(&plan, true); - dft_run_c(&plan, pss_signal_pad, pss_signal_freq); + srslte_dft_plan_set_mirror(&plan, true); + srslte_dft_plan_set_dc(&plan, true); + srslte_dft_plan_set_norm(&plan, true); + srslte_dft_run_c(&plan, pss_signal_pad, pss_signal_freq); - vec_conj_cc(pss_signal_freq, pss_signal_freq, fft_size); - vec_sc_prod_cfc(pss_signal_freq, 1.0/PSS_LEN, pss_signal_freq, fft_size); + srslte_vec_conj_cc(pss_signal_freq, pss_signal_freq, fft_size); + srslte_vec_sc_prod_cfc(pss_signal_freq, 1.0/SRSLTE_PSS_LEN, pss_signal_freq, fft_size); - dft_plan_free(&plan); + srslte_dft_plan_free(&plan); ret = SRSLTE_SUCCESS; } @@ -75,22 +75,22 @@ int pss_synch_init_N_id_2(cf_t *pss_signal_time, cf_t *pss_signal_freq, uint32_t /* Initializes the PSS synchronization object with fft_size=128 */ -int pss_synch_init(pss_synch_t *q, uint32_t frame_size) { - return pss_synch_init_fft(q, frame_size, 128); +int srslte_pss_synch_init(srslte_pss_synch_t *q, uint32_t frame_size) { + return srslte_pss_synch_init_fft(q, frame_size, 128); } /* Initializes the PSS synchronization object. * * It correlates a signal of frame_size samples with the PSS sequence in the frequency * domain. The PSS sequence is transformed using fft_size samples. */ -int pss_synch_init_fft(pss_synch_t *q, uint32_t frame_size, uint32_t fft_size) { +int srslte_pss_synch_init_fft(srslte_pss_synch_t *q, uint32_t frame_size, uint32_t fft_size) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL) { uint32_t N_id_2; uint32_t buffer_size; - bzero(q, sizeof(pss_synch_t)); + bzero(q, sizeof(srslte_pss_synch_t)); q->N_id_2 = 10; q->fft_size = fft_size; @@ -100,15 +100,15 @@ int pss_synch_init_fft(pss_synch_t *q, uint32_t frame_size, uint32_t fft_size) { buffer_size = fft_size + frame_size + 1; - if (dft_plan(&q->dftp_input, fft_size, FORWARD, COMPLEX)) { + if (srslte_dft_plan(&q->dftp_input, fft_size, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { fprintf(stderr, "Error creating DFT plan \n"); goto clean_and_exit; } - dft_plan_set_mirror(&q->dftp_input, true); - dft_plan_set_dc(&q->dftp_input, true); - dft_plan_set_norm(&q->dftp_input, true); + srslte_dft_plan_set_mirror(&q->dftp_input, true); + srslte_dft_plan_set_dc(&q->dftp_input, true); + srslte_dft_plan_set_norm(&q->dftp_input, true); - q->tmp_input = vec_malloc(buffer_size * sizeof(cf_t)); + q->tmp_input = srslte_vec_malloc(buffer_size * sizeof(cf_t)); if (!q->tmp_input) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; @@ -116,20 +116,20 @@ int pss_synch_init_fft(pss_synch_t *q, uint32_t frame_size, uint32_t fft_size) { bzero(&q->tmp_input[q->frame_size], q->fft_size * sizeof(cf_t)); - q->conv_output = vec_malloc(buffer_size * sizeof(cf_t)); + q->conv_output = srslte_vec_malloc(buffer_size * sizeof(cf_t)); if (!q->conv_output) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } bzero(q->conv_output, sizeof(cf_t) * buffer_size); - q->conv_output_avg = vec_malloc(buffer_size * sizeof(float)); + q->conv_output_avg = srslte_vec_malloc(buffer_size * sizeof(float)); if (!q->conv_output_avg) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } bzero(q->conv_output_avg, sizeof(float) * buffer_size); -#ifdef PSS_ACCUMULATE_ABS - q->conv_output_abs = vec_malloc(buffer_size * sizeof(float)); +#ifdef SRSLTE_PSS_ACCUMULATE_ABS + q->conv_output_abs = srslte_vec_malloc(buffer_size * sizeof(float)); if (!q->conv_output_abs) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; @@ -138,13 +138,13 @@ int pss_synch_init_fft(pss_synch_t *q, uint32_t frame_size, uint32_t fft_size) { #endif for (N_id_2=0;N_id_2<3;N_id_2++) { - q->pss_signal_freq[N_id_2] = vec_malloc(buffer_size * sizeof(cf_t)); + q->pss_signal_freq[N_id_2] = srslte_vec_malloc(buffer_size * sizeof(cf_t)); if (!q->pss_signal_freq[N_id_2]) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } /* The PSS is translated into the frequency domain for each N_id_2 */ - if (pss_synch_init_N_id_2(q->pss_signal_time[N_id_2], q->pss_signal_freq[N_id_2], N_id_2, fft_size)) { + if (srslte_pss_synch_init_N_id_2(q->pss_signal_time[N_id_2], q->pss_signal_freq[N_id_2], N_id_2, fft_size)) { fprintf(stderr, "Error initiating PSS detector for N_id_2=%d fft_size=%d\n", N_id_2, fft_size); goto clean_and_exit; } @@ -152,25 +152,25 @@ int pss_synch_init_fft(pss_synch_t *q, uint32_t frame_size, uint32_t fft_size) { } #ifdef CONVOLUTION_FFT - if (conv_fft_cc_init(&q->conv_fft, frame_size, fft_size)) { + if (srslte_conv_fft_cc_init(&q->conv_fft, frame_size, fft_size)) { fprintf(stderr, "Error initiating convolution FFT\n"); goto clean_and_exit; } #endif - pss_synch_reset(q); + srslte_pss_synch_reset(q); ret = SRSLTE_SUCCESS; } clean_and_exit: if (ret == SRSLTE_ERROR) { - pss_synch_free(q); + srslte_pss_synch_free(q); } return ret; } -void pss_synch_free(pss_synch_t *q) { +void srslte_pss_synch_free(srslte_pss_synch_t *q) { uint32_t i; if (q) { @@ -180,7 +180,7 @@ void pss_synch_free(pss_synch_t *q) { } } #ifdef CONVOLUTION_FFT - conv_fft_cc_free(&q->conv_fft); + srslte_conv_fft_cc_free(&q->conv_fft); #endif if (q->tmp_input) { @@ -196,11 +196,11 @@ void pss_synch_free(pss_synch_t *q) { free(q->conv_output_avg); } - bzero(q, sizeof(pss_synch_t)); + bzero(q, sizeof(srslte_pss_synch_t)); } } -void pss_synch_reset(pss_synch_t *q) { +void srslte_pss_synch_reset(srslte_pss_synch_t *q) { uint32_t buffer_size = q->fft_size + q->frame_size + 1; bzero(q->conv_output_avg, sizeof(float) * buffer_size); } @@ -209,7 +209,7 @@ void pss_synch_reset(pss_synch_t *q) { * This function calculates the Zadoff-Chu sequence. * @param signal Output array. */ -int pss_generate(cf_t *signal, uint32_t N_id_2) { +int srslte_pss_generate(cf_t *signal, uint32_t N_id_2) { int i; float arg; const float root_value[] = { 25.0, 29.0, 34.0 }; @@ -224,13 +224,13 @@ int pss_generate(cf_t *signal, uint32_t N_id_2) { root_idx = N_id_2; - for (i = 0; i < PSS_LEN / 2; i++) { + for (i = 0; i < SRSLTE_PSS_LEN / 2; i++) { arg = (float) sign * M_PI * root_value[root_idx] * ((float) i * ((float) i + 1.0)) / 63.0; __real__ signal[i] = cosf(arg); __imag__ signal[i] = sinf(arg); } - for (i = PSS_LEN / 2; i < PSS_LEN; i++) { + for (i = SRSLTE_PSS_LEN / 2; i < SRSLTE_PSS_LEN; i++) { arg = (float) sign * M_PI * root_value[root_idx] * (((float) i + 2.0) * ((float) i + 1.0)) / 63.0; __real__ signal[i] = cosf(arg); @@ -241,18 +241,18 @@ int pss_generate(cf_t *signal, uint32_t N_id_2) { /** 36.211 10.3 section 6.11.1.2 */ -void pss_put_slot(cf_t *pss_signal, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp) { +void srslte_pss_put_slot(cf_t *pss_signal, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp) { int k; 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)); + memcpy(&slot[k], pss_signal, SRSLTE_PSS_LEN * sizeof(cf_t)); + memset(&slot[k + SRSLTE_PSS_LEN], 0, 5 * sizeof(cf_t)); } /** 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) { +int srslte_pss_synch_set_N_id_2(srslte_pss_synch_t *q, uint32_t 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; @@ -264,7 +264,7 @@ int pss_synch_set_N_id_2(pss_synch_t *q, uint32_t N_id_2) { /* Sets the weight factor alpha for the exponential moving average of the PSS correlation output */ -void pss_synch_set_ema_alpha(pss_synch_t *q, float alpha) { +void srslte_pss_synch_set_ema_alpha(srslte_pss_synch_t *q, float alpha) { q->ema_alpha = alpha; } @@ -275,7 +275,7 @@ void pss_synch_set_ema_alpha(pss_synch_t *q, float alpha) { * * Input buffer must be subframe_size long. */ -int pss_synch_find_pss(pss_synch_t *q, cf_t *input, float *corr_peak_value) +int srslte_pss_synch_find_pss(srslte_pss_synch_t *q, cf_t *input, float *corr_peak_value) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -296,37 +296,37 @@ int pss_synch_find_pss(pss_synch_t *q, cf_t *input, float *corr_peak_value) #ifdef CONVOLUTION_FFT memcpy(q->tmp_input, input, q->frame_size * sizeof(cf_t)); - conv_output_len = conv_fft_cc_run(&q->conv_fft, q->tmp_input, + conv_output_len = srslte_conv_fft_cc_run(&q->conv_fft, q->tmp_input, q->pss_signal_freq[q->N_id_2], q->conv_output); #else - conv_output_len = conv_cc(input, q->pss_signal_freq[q->N_id_2], q->conv_output, q->frame_size, q->fft_size); + conv_output_len = srslte_conv_cc(input, q->pss_signal_freq[q->N_id_2], q->conv_output, q->frame_size, q->fft_size); #endif } else { for (int i=0;iframe_size;i++) { - q->conv_output[i] = vec_dot_prod_ccc(q->pss_signal_freq[q->N_id_2], &input[i], q->fft_size); + q->conv_output[i] = srslte_vec_dot_prod_ccc(q->pss_signal_freq[q->N_id_2], &input[i], q->fft_size); } conv_output_len = q->frame_size; } - #ifdef PSS_ABS_SQUARE - vec_abs_square_cf(q->conv_output, q->conv_output_abs, conv_output_len-1); + #ifdef SRSLTE_PSS_ABS_SQUARE + srslte_vec_abs_square_cf(q->conv_output, q->conv_output_abs, conv_output_len-1); #else - vec_abs_cf(q->conv_output, q->conv_output_abs, conv_output_len-1); + srslte_vec_abs_cf(q->conv_output, q->conv_output_abs, conv_output_len-1); #endif - vec_sc_prod_fff(q->conv_output_abs, q->ema_alpha, q->conv_output_abs, conv_output_len-1); - vec_sc_prod_fff(q->conv_output_avg, 1-q->ema_alpha, q->conv_output_avg, conv_output_len-1); + srslte_vec_sc_prod_fff(q->conv_output_abs, q->ema_alpha, q->conv_output_abs, conv_output_len-1); + srslte_vec_sc_prod_fff(q->conv_output_avg, 1-q->ema_alpha, q->conv_output_avg, conv_output_len-1); - vec_sum_fff(q->conv_output_abs, q->conv_output_avg, q->conv_output_avg, conv_output_len-1); + srslte_vec_sum_fff(q->conv_output_abs, q->conv_output_avg, q->conv_output_avg, conv_output_len-1); /* Find maximum of the absolute value of the correlation */ - corr_peak_pos = vec_max_fi(q->conv_output_avg, conv_output_len-1); + corr_peak_pos = srslte_vec_max_fi(q->conv_output_avg, conv_output_len-1); // save absolute value q->peak_value = q->conv_output_avg[corr_peak_pos]; -#ifdef PSS_RETURN_PSR +#ifdef SRSLTE_PSS_RETURN_PSR // Find second side lobe // Find end of peak lobe to the right @@ -351,9 +351,9 @@ int pss_synch_find_pss(pss_synch_t *q, cf_t *input, float *corr_peak_value) } int sl_distance_left = pl_lb; - int sl_right = pl_ub+vec_max_fi(&q->conv_output_avg[pl_ub], sl_distance_right); - int sl_left = vec_max_fi(q->conv_output_avg, sl_distance_left); - float side_lobe_value = MAX(q->conv_output_avg[sl_right], q->conv_output_avg[sl_left]); + int sl_right = pl_ub+srslte_vec_max_fi(&q->conv_output_avg[pl_ub], sl_distance_right); + int sl_left = srslte_vec_max_fi(q->conv_output_avg, sl_distance_left); + float side_lobe_value = SRSLTE_MAX(q->conv_output_avg[sl_right], q->conv_output_avg[sl_left]); if (corr_peak_value) { *corr_peak_value = q->conv_output_avg[corr_peak_pos]/side_lobe_value; @@ -386,7 +386,7 @@ SRSLTE_API cf_t *tmp2; * input signal is in the time-domain. * ce is the returned frequency-domain channel estimates. */ -int pss_synch_chest(pss_synch_t *q, cf_t *input, cf_t ce[PSS_LEN]) { +int srslte_pss_synch_chest(srslte_pss_synch_t *q, cf_t *input, cf_t ce[SRSLTE_PSS_LEN]) { int ret = SRSLTE_ERROR_INVALID_INPUTS; cf_t input_fft[SRSLTE_SYMBOL_SZ_MAX]; @@ -402,10 +402,10 @@ int pss_synch_chest(pss_synch_t *q, cf_t *input, cf_t ce[PSS_LEN]) { tmp2 = input_fft; /* Transform to frequency-domain */ - dft_run_c(&q->dftp_input, input, input_fft); + srslte_dft_run_c(&q->dftp_input, input, input_fft); /* Compute channel estimate taking the PSS sequence as reference */ - vec_prod_conj_ccc(&input_fft[(q->fft_size-PSS_LEN)/2], q->pss_signal_time[q->N_id_2], ce, PSS_LEN); + srslte_vec_prod_conj_ccc(&input_fft[(q->fft_size-SRSLTE_PSS_LEN)/2], q->pss_signal_time[q->N_id_2], ce, SRSLTE_PSS_LEN); ret = SRSLTE_SUCCESS; } @@ -417,11 +417,11 @@ int pss_synch_chest(pss_synch_t *q, cf_t *input, cf_t ce[PSS_LEN]) { * Source: An Efficient CFO Estimation Algorithm for the Downlink of 3GPP-LTE * Feng Wang and Yu Zhu */ -float pss_synch_cfo_compute(pss_synch_t* q, cf_t *pss_recv) { +float srslte_pss_synch_cfo_compute(srslte_pss_synch_t* q, cf_t *pss_recv) { cf_t y0, y1, yr; - y0 = vec_dot_prod_ccc(q->pss_signal_freq[q->N_id_2], pss_recv, q->fft_size/2); - y1 = vec_dot_prod_ccc(&q->pss_signal_freq[q->N_id_2][q->fft_size/2], &pss_recv[q->fft_size/2], q->fft_size/2); + y0 = srslte_vec_dot_prod_ccc(q->pss_signal_freq[q->N_id_2], pss_recv, q->fft_size/2); + y1 = srslte_vec_dot_prod_ccc(&q->pss_signal_freq[q->N_id_2][q->fft_size/2], &pss_recv[q->fft_size/2], q->fft_size/2); yr = conjf(y0) * y1; diff --git a/srslte/lib/sync/src/sfo.c b/srslte/lib/sync/src/sfo.c index f5a7a0554..9ec473921 100644 --- a/srslte/lib/sync/src/sfo.c +++ b/srslte/lib/sync/src/sfo.c @@ -33,7 +33,7 @@ /* Estimate SFO based on the array of time estimates t0 * of length len. The parameter period is the time between t0 samples */ -float sfo_estimate(int *t0, int len, float period) { +float srslte_sfo_estimate(int *t0, int len, float period) { int i; float sfo=0.0; for (i=1;i #include "srslte/sync/sss.h" -#include "srslte/utils/dft.h" +#include "srslte/dft/dft.h" #include "srslte/utils/convolution.h" #include "srslte/utils/vector.h" -void generate_sss_all_tables(struct sss_tables *tables, uint32_t N_id_2); -void convert_tables(struct fc_tables *fc_tables, struct sss_tables *in); +void generate_sss_all_tables(srslte_sss_tables_t *tables, uint32_t N_id_2); +void convert_tables(srslte_sss_fc_tables_t *fc_tables, srslte_sss_tables_t *in); void generate_N_id_1_table(uint32_t table[30][30]); -int sss_synch_init(sss_synch_t *q, uint32_t fft_size) { +int srslte_sss_synch_init(srslte_sss_synch_t *q, uint32_t fft_size) { if (q != NULL && fft_size <= 2048) { uint32_t N_id_2; - struct sss_tables sss_tables; + srslte_sss_tables_t sss_tables; - bzero(q, sizeof(sss_synch_t)); + bzero(q, sizeof(srslte_sss_synch_t)); - if (dft_plan(&q->dftp_input, fft_size, FORWARD, COMPLEX)) { - sss_synch_free(q); + if (srslte_dft_plan(&q->dftp_input, fft_size, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { + srslte_sss_synch_free(q); return SRSLTE_ERROR; } - dft_plan_set_mirror(&q->dftp_input, true); - dft_plan_set_dc(&q->dftp_input, true); + srslte_dft_plan_set_mirror(&q->dftp_input, true); + srslte_dft_plan_set_dc(&q->dftp_input, true); q->fft_size = fft_size; @@ -72,18 +72,18 @@ int sss_synch_init(sss_synch_t *q, uint32_t fft_size) { return SRSLTE_ERROR_INVALID_INPUTS; } -int sss_synch_realloc(sss_synch_t *q, uint32_t fft_size) { +int srslte_sss_synch_realloc(srslte_sss_synch_t *q, uint32_t fft_size) { if (q != NULL && fft_size <= 2048) { - dft_plan_free(&q->dftp_input); - if (dft_plan(&q->dftp_input, fft_size, FORWARD, COMPLEX)) { - sss_synch_free(q); + srslte_dft_plan_free(&q->dftp_input); + if (srslte_dft_plan(&q->dftp_input, fft_size, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { + srslte_sss_synch_free(q); return SRSLTE_ERROR; } - dft_plan_set_mirror(&q->dftp_input, true); - dft_plan_set_norm(&q->dftp_input, true); - dft_plan_set_dc(&q->dftp_input, true); + srslte_dft_plan_set_mirror(&q->dftp_input, true); + srslte_dft_plan_set_norm(&q->dftp_input, true); + srslte_dft_plan_set_dc(&q->dftp_input, true); q->fft_size = fft_size; return SRSLTE_SUCCESS; @@ -91,13 +91,13 @@ int sss_synch_realloc(sss_synch_t *q, uint32_t fft_size) { return SRSLTE_ERROR_INVALID_INPUTS; } -void sss_synch_free(sss_synch_t *q) { - dft_plan_free(&q->dftp_input); - bzero(q, sizeof(sss_synch_t)); +void srslte_sss_synch_free(srslte_sss_synch_t *q) { + srslte_dft_plan_free(&q->dftp_input); + bzero(q, sizeof(srslte_sss_synch_t)); } /** Sets the N_id_2 to search for */ -int sss_synch_set_N_id_2(sss_synch_t *q, uint32_t N_id_2) { +int srslte_sss_synch_set_N_id_2(srslte_sss_synch_t *q, uint32_t 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; @@ -109,28 +109,28 @@ int sss_synch_set_N_id_2(sss_synch_t *q, uint32_t N_id_2) { /** 36.211 10.3 section 6.11.2.2 */ -void sss_put_slot(float *sss, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp) { +void srslte_sss_put_slot(float *sss, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp) { uint32_t i, k; 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)); - for (i = 0; i < SSS_LEN; i++) { + for (i = 0; i < SRSLTE_SSS_LEN; i++) { __real__ slot[k + i] = sss[i]; __imag__ slot[k + i] = 0; } - memset(&slot[k + SSS_LEN], 0, 5 * sizeof(cf_t)); + memset(&slot[k + SRSLTE_SSS_LEN], 0, 5 * sizeof(cf_t)); } } /** Sets the SSS correlation peak detection threshold */ -void sss_synch_set_threshold(sss_synch_t *q, float threshold) { +void srslte_sss_synch_set_threshold(srslte_sss_synch_t *q, float threshold) { q->corr_peak_threshold = threshold; } /** Returns the subframe index based on the m0 and m1 values */ -uint32_t sss_synch_subframe(uint32_t m0, uint32_t m1) { +uint32_t srslte_sss_synch_subframe(uint32_t m0, uint32_t m1) { if (m1 > m0) { return 0; } else { @@ -139,7 +139,7 @@ uint32_t sss_synch_subframe(uint32_t m0, uint32_t m1) { } /** Returns the N_id_1 value based on the m0 and m1 values */ -int sss_synch_N_id_1(sss_synch_t *q, uint32_t m0, uint32_t m1) { +int srslte_sss_synch_N_id_1(srslte_sss_synch_t *q, uint32_t m0, uint32_t m1) { if (m0==m1 || m0 > 29 || m1 > 29) { return SRSLTE_ERROR; } @@ -154,27 +154,27 @@ int sss_synch_N_id_1(sss_synch_t *q, uint32_t m0, uint32_t m1) { /** High-level API */ -int sss_synch_initialize(sss_synch_hl* h) { +int srslte_sss_synch_initialize(srslte_sss_synch_hl* h) { - if (sss_synch_init(&h->obj, 128)) { + if (srslte_sss_synch_init(&h->obj, 128)) { return SRSLTE_ERROR; } - sss_synch_set_N_id_2(&h->obj, h->init.N_id_2); + srslte_sss_synch_set_N_id_2(&h->obj, h->init.N_id_2); return SRSLTE_SUCCESS; } -int sss_synch_work(sss_synch_hl* hl) { +int srslte_sss_synch_work(srslte_sss_synch_hl* hl) { if (hl->ctrl_in.correlation_threshold) { - sss_synch_set_threshold(&hl->obj, hl->ctrl_in.correlation_threshold); + srslte_sss_synch_set_threshold(&hl->obj, hl->ctrl_in.correlation_threshold); } return SRSLTE_SUCCESS; } -int sss_synch_stop(sss_synch_hl* hl) { - sss_synch_free(&hl->obj); +int srslte_sss_synch_stop(srslte_sss_synch_hl* hl) { + srslte_sss_synch_free(&hl->obj); return SRSLTE_SUCCESS; } diff --git a/srslte/lib/sync/src/sync.c b/srslte/lib/sync/src/sync.c index 75041cf49..af298feb0 100644 --- a/srslte/lib/sync/src/sync.c +++ b/srslte/lib/sync/src/sync.c @@ -40,14 +40,14 @@ #define CP_EMA_ALPHA 0.2 static bool fft_size_isvalid(uint32_t fft_size) { - if (fft_size >= FFT_SIZE_MIN && fft_size <= FFT_SIZE_MAX && (fft_size%64) == 0) { + if (fft_size >= SRSLTE_SYNC_FFT_SZ_MIN && fft_size <= SRSLTE_SYNC_FFT_SZ_MAX && (fft_size%64) == 0) { return true; } else { return false; } } -int sync_init(sync_t *q, uint32_t frame_size, uint32_t fft_size) { +int srslte_sync_init(srslte_sync_t *q, uint32_t frame_size, uint32_t fft_size) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -57,7 +57,7 @@ int sync_init(sync_t *q, uint32_t frame_size, uint32_t fft_size) { { ret = SRSLTE_ERROR; - bzero(q, sizeof(sync_t)); + bzero(q, sizeof(srslte_sync_t)); q->detect_cp = true; q->cp = SRSLTE_SRSLTE_CP_NORM; q->mean_peak_value = 0.0; @@ -70,16 +70,16 @@ int sync_init(sync_t *q, uint32_t frame_size, uint32_t fft_size) { q->frame_size = frame_size; q->sss_alg = SSS_PARTIAL_3; - if (pss_synch_init_fft(&q->pss, frame_size, fft_size)) { + if (srslte_pss_synch_init_fft(&q->pss, frame_size, fft_size)) { fprintf(stderr, "Error initializing PSS object\n"); goto clean_exit; } - if (sss_synch_init(&q->sss, fft_size)) { + if (srslte_sss_synch_init(&q->sss, fft_size)) { fprintf(stderr, "Error initializing SSS object\n"); goto clean_exit; } - if (cfo_init(&q->cfocorr, frame_size)) { + if (srslte_cfo_init(&q->cfocorr, frame_size)) { fprintf(stderr, "Error initiating CFO\n"); goto clean_exit; } @@ -93,32 +93,32 @@ int sync_init(sync_t *q, uint32_t frame_size, uint32_t fft_size) { clean_exit: if (ret == SRSLTE_ERROR) { - sync_free(q); + srslte_sync_free(q); } return ret; } -void sync_free(sync_t *q) { +void srslte_sync_free(srslte_sync_t *q) { if (q) { - pss_synch_free(&q->pss); - sss_synch_free(&q->sss); - cfo_free(&q->cfocorr); + srslte_pss_synch_free(&q->pss); + srslte_sss_synch_free(&q->sss); + srslte_cfo_free(&q->cfocorr); } } -void sync_set_threshold(sync_t *q, float threshold) { +void srslte_sync_set_threshold(srslte_sync_t *q, float threshold) { q->threshold = threshold; } -void sync_sss_en(sync_t *q, bool enabled) { +void srslte_sync_sss_en(srslte_sync_t *q, bool enabled) { q->sss_en = enabled; } -bool sync_sss_detected(sync_t *q) { +bool srslte_sync_sss_detected(srslte_sync_t *q) { return srslte_N_id_1_isvalid(q->N_id_1); } -int sync_get_cell_id(sync_t *q) { +int srslte_sync_get_cell_id(srslte_sync_t *q) { 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 { @@ -126,7 +126,7 @@ int sync_get_cell_id(sync_t *q) { } } -int sync_set_N_id_2(sync_t *q, uint32_t N_id_2) { +int srslte_sync_set_N_id_2(srslte_sync_t *q, uint32_t N_id_2) { if (srslte_N_id_2_isvalid(N_id_2)) { q->N_id_2 = N_id_2; return SRSLTE_SUCCESS; @@ -136,46 +136,46 @@ int sync_set_N_id_2(sync_t *q, uint32_t N_id_2) { } } -uint32_t sync_get_sf_idx(sync_t *q) { +uint32_t srslte_sync_get_sf_idx(srslte_sync_t *q) { return q->sf_idx; } -float sync_get_cfo(sync_t *q) { +float srslte_sync_get_cfo(srslte_sync_t *q) { return q->mean_cfo; } -float sync_get_last_peak_value(sync_t *q) { +float srslte_sync_get_last_peak_value(srslte_sync_t *q) { return q->peak_value; } -float sync_get_peak_value(sync_t *q) { +float srslte_sync_get_peak_value(srslte_sync_t *q) { return q->mean_peak_value; } -void sync_correct_cfo(sync_t *q, bool enabled) { +void srslte_sync_correct_cfo(srslte_sync_t *q, bool enabled) { q->correct_cfo = enabled; } -void sync_cp_en(sync_t *q, bool enabled) { +void srslte_sync_cp_en(srslte_sync_t *q, bool enabled) { q->detect_cp = enabled; } -bool sync_sss_is_en(sync_t *q) { +bool srslte_sync_sss_is_en(srslte_sync_t *q) { return q->sss_en; } -void sync_set_em_alpha(sync_t *q, float alpha) { - pss_synch_set_ema_alpha(&q->pss, alpha); +void srslte_sync_set_em_alpha(srslte_sync_t *q, float alpha) { + srslte_pss_synch_set_ema_alpha(&q->pss, alpha); } -srslte_cp_t sync_get_cp(sync_t *q) { +srslte_cp_t srslte_sync_get_cp(srslte_sync_t *q) { return q->cp; } -void sync_set_cp(sync_t *q, srslte_cp_t cp) { +void srslte_sync_set_cp(srslte_sync_t *q, srslte_cp_t cp) { q->cp = cp; } -void sync_set_sss_algorithm(sync_t *q, sss_alg_t alg) { +void srslte_sync_set_sss_algorithm(srslte_sync_t *q, sss_alg_t alg) { q->sss_alg = alg; } @@ -183,7 +183,7 @@ void sync_set_sss_algorithm(sync_t *q, sss_alg_t alg) { * "SSS Detection Method for Initial Cell Search in 3GPP LTE FDD/TDD Dual Mode Receiver" * by Jung-In Kim et al. */ -srslte_cp_t sync_detect_cp(sync_t *q, cf_t *input, uint32_t peak_pos) +srslte_cp_t srslte_sync_detect_cp(srslte_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; @@ -195,24 +195,24 @@ srslte_cp_t sync_detect_cp(sync_t *q, cf_t *input, uint32_t peak_pos) cf_t *input_cp_ext = &input[peak_pos-2*(q->fft_size+cp_ext_len)]; for (int i=0;i<2;i++) { - R_norm = crealf(vec_dot_prod_conj_ccc(&input_cp_norm[q->fft_size], input_cp_norm, cp_norm_len)); - C_norm = cp_norm_len * vec_avg_power_cf(input_cp_norm, cp_norm_len); + R_norm = crealf(srslte_vec_dot_prod_conj_ccc(&input_cp_norm[q->fft_size], input_cp_norm, cp_norm_len)); + C_norm = cp_norm_len * srslte_vec_avg_power_cf(input_cp_norm, cp_norm_len); input_cp_norm += q->fft_size+cp_norm_len; M_norm += R_norm/C_norm; } - q->M_norm_avg = VEC_EMA(M_norm/2, q->M_norm_avg, CP_EMA_ALPHA); + q->M_norm_avg = SRSLTE_VEC_EMA(M_norm/2, q->M_norm_avg, CP_EMA_ALPHA); for (int i=0;i<2;i++) { - R_ext = crealf(vec_dot_prod_conj_ccc(&input_cp_ext[q->fft_size], input_cp_ext, cp_ext_len)); - C_ext = cp_ext_len * vec_avg_power_cf(input_cp_ext, cp_ext_len); + R_ext = crealf(srslte_vec_dot_prod_conj_ccc(&input_cp_ext[q->fft_size], input_cp_ext, cp_ext_len)); + C_ext = cp_ext_len * srslte_vec_avg_power_cf(input_cp_ext, cp_ext_len); input_cp_ext += q->fft_size+cp_ext_len; if (C_ext > 0) { M_ext += R_ext/C_ext; } } - q->M_ext_avg = VEC_EMA(M_ext/2, q->M_ext_avg, CP_EMA_ALPHA); + q->M_ext_avg = SRSLTE_VEC_EMA(M_ext/2, q->M_ext_avg, CP_EMA_ALPHA); if (q->M_norm_avg > q->M_ext_avg) { return SRSLTE_SRSLTE_CP_NORM; @@ -230,10 +230,10 @@ srslte_cp_t sync_detect_cp(sync_t *q, cf_t *input, uint32_t peak_pos) /* Returns 1 if the SSS is found, 0 if not and -1 if there is not enough space * to correlate */ -int sync_sss(sync_t *q, cf_t *input, uint32_t peak_pos, srslte_cp_t cp) { +int sync_sss(srslte_sync_t *q, cf_t *input, uint32_t peak_pos, srslte_cp_t cp) { int sss_idx, ret; - sss_synch_set_N_id_2(&q->sss, q->N_id_2); + srslte_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-SRSLTE_CP(q->fft_size, (SRSLTE_CP_ISNORM(q->cp)?SRSLTE_SRSLTE_CP_NORM_LEN:SRSLTE_SRSLTE_CP_EXT_LEN)); @@ -245,18 +245,18 @@ int sync_sss(sync_t *q, cf_t *input, uint32_t peak_pos, srslte_cp_t cp) { switch(q->sss_alg) { case SSS_DIFF: - sss_synch_m0m1_diff(&q->sss, &input[sss_idx], &q->m0, &q->m0_value, &q->m1, &q->m1_value); + srslte_sss_synch_m0m1_diff(&q->sss, &input[sss_idx], &q->m0, &q->m0_value, &q->m1, &q->m1_value); break; case SSS_PARTIAL_3: - sss_synch_m0m1_partial(&q->sss, &input[sss_idx], 3, NULL, &q->m0, &q->m0_value, &q->m1, &q->m1_value); + srslte_sss_synch_m0m1_partial(&q->sss, &input[sss_idx], 3, NULL, &q->m0, &q->m0_value, &q->m1, &q->m1_value); break; case SSS_FULL: - sss_synch_m0m1_partial(&q->sss, &input[sss_idx], 1, NULL, &q->m0, &q->m0_value, &q->m1, &q->m1_value); + srslte_sss_synch_m0m1_partial(&q->sss, &input[sss_idx], 1, NULL, &q->m0, &q->m0_value, &q->m1, &q->m1_value); break; } - q->sf_idx = sss_synch_subframe(q->m0, q->m1); - ret = sss_synch_N_id_1(&q->sss, q->m0, q->m1); + q->sf_idx = srslte_sss_synch_subframe(q->m0, q->m1); + ret = srslte_sss_synch_N_id_1(&q->sss, q->m0, q->m1); if (ret >= 0) { q->N_id_1 = (uint32_t) ret; DEBUG("SSS detected N_id_1=%d, sf_idx=%d, %s CP\n", @@ -269,14 +269,14 @@ int sync_sss(sync_t *q, cf_t *input, uint32_t peak_pos, srslte_cp_t cp) { } -/** Finds the PSS sequence previously defined by a call to sync_set_N_id_2() +/** Finds the PSS sequence previously defined by a call to srslte_sync_set_N_id_2() * around the position find_offset in the buffer input. - * Returns 1 if the correlation peak exceeds the threshold set by sync_set_threshold() + * Returns 1 if the correlation peak exceeds the threshold set by srslte_sync_set_threshold() * or 0 otherwise. Returns a negative number on error (if N_id_2 has not been set) * * The maximum of the correlation peak is always stored in *peak_position */ -int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_position) +int srslte_sync_find(srslte_sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_position) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -294,14 +294,14 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit *peak_position = 0; } - pss_synch_set_N_id_2(&q->pss, q->N_id_2); + srslte_pss_synch_set_N_id_2(&q->pss, q->N_id_2); - peak_pos = pss_synch_find_pss(&q->pss, &input[find_offset], &q->peak_value); + peak_pos = srslte_pss_synch_find_pss(&q->pss, &input[find_offset], &q->peak_value); if (peak_pos < 0) { fprintf(stderr, "Error calling finding PSS sequence\n"); return SRSLTE_ERROR; } - q->mean_peak_value = VEC_EMA(q->peak_value, q->mean_peak_value, MEANPEAK_EMA_ALPHA); + q->mean_peak_value = SRSLTE_VEC_EMA(q->peak_value, q->mean_peak_value, MEANPEAK_EMA_ALPHA); if (peak_position) { *peak_position = (uint32_t) peak_pos; @@ -312,17 +312,17 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit // Make sure we have enough space to estimate CFO if (peak_pos + find_offset >= q->fft_size) { - float cfo = pss_synch_cfo_compute(&q->pss, &input[find_offset+peak_pos-q->fft_size]); + float cfo = srslte_pss_synch_cfo_compute(&q->pss, &input[find_offset+peak_pos-q->fft_size]); /* compute cumulative moving average CFO */ - q->mean_cfo = VEC_EMA(cfo, q->mean_cfo, CFO_EMA_ALPHA); + q->mean_cfo = SRSLTE_VEC_EMA(cfo, q->mean_cfo, CFO_EMA_ALPHA); } else { INFO("No space for CFO computation. Frame starts at \n",peak_pos); } if (q->detect_cp) { 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); + q->cp = srslte_sync_detect_cp(q, input, peak_pos + find_offset); } else { INFO("Not enough room to detect CP length. Peak position: %d\n", peak_pos); } @@ -332,7 +332,7 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit if (q->sss_en) { /* Correct CFO with the averaged CFO estimation */ if (q->mean_cfo && q->correct_cfo) { - cfo_correct(&q->cfocorr, input, input, -q->mean_cfo / q->fft_size); + srslte_cfo_correct(&q->cfocorr, input, input, -q->mean_cfo / q->fft_size); } // Set an invalid N_id_1 indicating SSS is yet to be detected @@ -352,14 +352,14 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit ret, q->N_id_2, find_offset, peak_pos, q->peak_value, q->threshold, q->sf_idx, 15*q->mean_cfo); } else if (srslte_N_id_2_isvalid(q->N_id_2)) { - fprintf(stderr, "Must call sync_set_N_id_2() first!\n"); + fprintf(stderr, "Must call srslte_sync_set_N_id_2() first!\n"); } return ret; } -void sync_reset(sync_t *q) { +void srslte_sync_reset(srslte_sync_t *q) { q->M_ext_avg = 0; q->M_norm_avg = 0; - pss_synch_reset(&q->pss); + srslte_pss_synch_reset(&q->pss); } diff --git a/srslte/lib/sync/test/cfo_test.c b/srslte/lib/sync/test/cfo_test.c index bc2c67526..79dcc1418 100644 --- a/srslte/lib/sync/test/cfo_test.c +++ b/srslte/lib/sync/test/cfo_test.c @@ -65,7 +65,7 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { int i; cf_t *input, *output; - cfo_t cfocorr; + srslte_cfo_t cfocorr; float mse; if (argc < 5) { @@ -91,20 +91,20 @@ int main(int argc, char **argv) { output[i] = input[i]; } - if (cfo_init(&cfocorr, num_samples)) { + if (srslte_cfo_init(&cfocorr, num_samples)) { fprintf(stderr, "Error initiating CFO\n"); return -1; } - cfo_correct(&cfocorr, output, output, freq); - cfo_correct(&cfocorr, output, output, -freq); + srslte_cfo_correct(&cfocorr, output, output, freq); + srslte_cfo_correct(&cfocorr, output, output, -freq); mse = 0; for (i=0;i= 1) { plhs[0] = mxCreateLogicalScalar(peak_idx); @@ -87,7 +87,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mexutils_write_cf(pss.conv_output, &plhs[1], frame_len, 1); } - pss_synch_free(&pss); + srslte_pss_synch_free(&pss); free(input_symbols); return; diff --git a/srslte/lib/sync/test/pss_usrp.c b/srslte/lib/sync/test/pss_usrp.c index 5775dc722..efc19a241 100644 --- a/srslte/lib/sync/test/pss_usrp.c +++ b/srslte/lib/sync/test/pss_usrp.c @@ -41,7 +41,7 @@ #ifndef DISABLE_GRAPHICS void init_plots(); -void do_plots(float *corr, float energy, uint32_t size, cf_t ce[PSS_LEN]); +void do_plots(float *corr, float energy, uint32_t size, cf_t ce[SRSLTE_PSS_LEN]); void do_plots_sss(float *corr_m0, float *corr_m1); #endif @@ -70,7 +70,7 @@ void usage(char *prog) { #else printf("\t plots are disabled. Graphics library not available\n"); #endif - printf("\t-v verbose\n"); + printf("\t-v srslte_verbose\n"); } void parse_args(int argc, char **argv) { @@ -108,7 +108,7 @@ void parse_args(int argc, char **argv) { disable_plots = true; break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(argv[0]); @@ -126,15 +126,15 @@ int main(int argc, char **argv) { cf_t *buffer; int frame_cnt, n; void *uhd; - pss_synch_t pss; - cfo_t cfocorr, cfocorr64; - sss_synch_t sss; + srslte_pss_synch_t pss; + srslte_cfo_t cfocorr, cfocorr64; + srslte_sss_synch_t sss; int32_t flen; int peak_idx, last_peak; float peak_value; float mean_peak; uint32_t nof_det, nof_nodet, nof_nopeak, nof_nopeakdet; - cf_t ce[PSS_LEN]; + cf_t ce[SRSLTE_PSS_LEN]; parse_args(argc, argv); @@ -157,25 +157,25 @@ int main(int argc, char **argv) { exit(-1); } - if (pss_synch_init_fft(&pss, flen, fft_size)) { + if (srslte_pss_synch_init_fft(&pss, flen, fft_size)) { fprintf(stderr, "Error initiating PSS\n"); exit(-1); } - if (pss_synch_set_N_id_2(&pss, N_id_2_sync)) { + if (srslte_pss_synch_set_N_id_2(&pss, N_id_2_sync)) { fprintf(stderr, "Error setting N_id_2=%d\n",N_id_2_sync); exit(-1); } - cfo_init(&cfocorr, flen); - cfo_init(&cfocorr64, flen); + srslte_cfo_init(&cfocorr, flen); + srslte_cfo_init(&cfocorr64, flen); - if (sss_synch_init(&sss, fft_size)) { + if (srslte_sss_synch_init(&sss, fft_size)) { fprintf(stderr, "Error initializing SSS object\n"); return SRSLTE_ERROR; } - sss_synch_set_N_id_2(&sss, N_id_2); + srslte_sss_synch_set_N_id_2(&sss, N_id_2); printf("Opening UHD device...\n"); if (cuhd_open(uhd_args, &uhd)) { @@ -203,8 +203,8 @@ int main(int argc, char **argv) { uint32_t sss_error1 = 0, sss_error2 = 0, sss_error3 = 0; uint32_t cp_is_norm = 0; - sync_t ssync; - bzero(&ssync, sizeof(sync_t)); + srslte_sync_t ssync; + bzero(&ssync, sizeof(srslte_sync_t)); ssync.fft_size = fft_size; while(frame_cnt < nof_frames || nof_frames == -1) { @@ -214,13 +214,13 @@ int main(int argc, char **argv) { exit(-1); } - peak_idx = pss_synch_find_pss(&pss, buffer, &peak_value); + peak_idx = srslte_pss_synch_find_pss(&pss, buffer, &peak_value); if (peak_idx < 0) { fprintf(stderr, "Error finding PSS peak\n"); exit(-1); } - mean_peak = VEC_CMA(peak_value, mean_peak, frame_cnt); + mean_peak = SRSLTE_VEC_CMA(peak_value, mean_peak, frame_cnt); if (peak_value >= threshold) { nof_det++; @@ -228,14 +228,14 @@ int main(int argc, char **argv) { if (peak_idx >= fft_size) { // Estimate CFO - cfo = pss_synch_cfo_compute(&pss, &buffer[peak_idx-fft_size]); - mean_cfo = VEC_CMA(cfo, mean_cfo, frame_cnt); + cfo = srslte_pss_synch_cfo_compute(&pss, &buffer[peak_idx-fft_size]); + mean_cfo = SRSLTE_VEC_CMA(cfo, mean_cfo, frame_cnt); // Correct CFO - cfo_correct(&cfocorr, buffer, buffer, -mean_cfo / fft_size); + srslte_cfo_correct(&cfocorr, buffer, buffer, -mean_cfo / fft_size); // Estimate channel - if (pss_synch_chest(&pss, &buffer[peak_idx-fft_size], ce)) { + if (srslte_pss_synch_chest(&pss, &buffer[peak_idx-fft_size], ce)) { fprintf(stderr, "Error computing channel estimation\n"); exit(-1); } @@ -243,26 +243,26 @@ int main(int argc, char **argv) { // Find SSS 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) { + srslte_sss_synch_m0m1_partial(&sss, &buffer[sss_idx], 3, NULL, &m0, &m0_value, &m1, &m1_value); + if (srslte_sss_synch_N_id_1(&sss, m0, m1) != N_id_1) { sss_error2++; } - INFO("Partial N_id_1: %d\n", sss_synch_N_id_1(&sss, m0, m1)); - sss_synch_m0m1_diff(&sss, &buffer[sss_idx], &m0, &m0_value, &m1, &m1_value); - if (sss_synch_N_id_1(&sss, m0, m1) != N_id_1) { + INFO("Partial N_id_1: %d\n", srslte_sss_synch_N_id_1(&sss, m0, m1)); + srslte_sss_synch_m0m1_diff(&sss, &buffer[sss_idx], &m0, &m0_value, &m1, &m1_value); + if (srslte_sss_synch_N_id_1(&sss, m0, m1) != N_id_1) { sss_error3++; } - INFO("Diff N_id_1: %d\n", sss_synch_N_id_1(&sss, m0, m1)); - sss_synch_m0m1_partial(&sss, &buffer[sss_idx], 1, NULL, &m0, &m0_value, &m1, &m1_value); - if (sss_synch_N_id_1(&sss, m0, m1) != N_id_1) { + INFO("Diff N_id_1: %d\n", srslte_sss_synch_N_id_1(&sss, m0, m1)); + srslte_sss_synch_m0m1_partial(&sss, &buffer[sss_idx], 1, NULL, &m0, &m0_value, &m1, &m1_value); + if (srslte_sss_synch_N_id_1(&sss, m0, m1) != N_id_1) { sss_error1++; } - INFO("Full N_id_1: %d\n", sss_synch_N_id_1(&sss, m0, m1)); + INFO("Full N_id_1: %d\n", srslte_sss_synch_N_id_1(&sss, m0, m1)); } // Estimate CP if (peak_idx > 2*(fft_size + SRSLTE_CP_EXT(fft_size))) { - srslte_cp_t cp = sync_detect_cp(&ssync, buffer, peak_idx); + srslte_cp_t cp = srslte_sync_detect_cp(&ssync, buffer, peak_idx); if (SRSLTE_CP_ISNORM(cp)) { cp_is_norm++; } @@ -272,7 +272,7 @@ int main(int argc, char **argv) { INFO("No space for CFO computation. Frame starts at \n",peak_idx); } - if(sss_synch_subframe(m0,m1) == 0) + if(srslte_sss_synch_subframe(m0,m1) == 0) { #ifndef DISABLE_GRAPHICS if (!disable_plots) @@ -305,7 +305,7 @@ int main(int argc, char **argv) { (float) sss_error1/nof_det,(float) sss_error2/nof_det,(float) sss_error3/nof_det, (float) cp_is_norm/nof_det * 100); - if (VERBOSE_ISINFO()) { + if (SRSLTE_VERBOSE_ISINFO()) { printf("\n"); } @@ -318,7 +318,7 @@ int main(int argc, char **argv) { } - pss_synch_free(&pss); + srslte_pss_synch_free(&pss); free(buffer); cuhd_close(uhd); @@ -342,7 +342,7 @@ plot_real_t pssout; plot_real_t psss1;//, psss2; float tmp[100000]; -cf_t tmpce[PSS_LEN]; +cf_t tmpce[SRSLTE_PSS_LEN]; void init_plots() { @@ -376,24 +376,24 @@ void init_plots() { } -void do_plots(float *corr, float energy, uint32_t size, cf_t ce[PSS_LEN]) { - vec_sc_prod_fff(corr,1./energy,tmp, size); +void do_plots(float *corr, float energy, uint32_t size, cf_t ce[SRSLTE_PSS_LEN]) { + srslte_vec_sc_prod_fff(corr,1./energy,tmp, size); plot_real_setNewData(&pssout, tmp, size); -// float norm = vec_avg_power_cf(ce, PSS_LEN); - // vec_sc_prod_cfc(ce, 1.0/sqrt(norm), tmpce, PSS_LEN); +// float norm = srslte_vec_avg_power_cf(ce, SRSLTE_PSS_LEN); + // srslte_vec_sc_prod_cfc(ce, 1.0/sqrt(norm), tmpce, SRSLTE_PSS_LEN); - //plot_complex_setNewData(&pce, tmpce, PSS_LEN); + //plot_complex_setNewData(&pce, tmpce, SRSLTE_PSS_LEN); } void do_plots_sss(float *corr_m0, float *corr_m1) { if (m0_value > 0) - vec_sc_prod_fff(corr_m0,1./m0_value,corr_m0, N_SSS); - plot_real_setNewData(&psss1, corr_m0, N_SSS); + srslte_vec_sc_prod_fff(corr_m0,1./m0_value,corr_m0, SRSLTE_SSS_N); + plot_real_setNewData(&psss1, corr_m0, SRSLTE_SSS_N); // if (m1_value > 0) -// vec_sc_prod_fff(corr_m1,1./m1_value,corr_m1, N_SSS); -// plot_real_setNewData(&psss2, corr_m1, N_SSS); +// srslte_vec_sc_prod_fff(corr_m1,1./m1_value,corr_m1, SRSLTE_SSS_N); +// plot_real_setNewData(&psss2, corr_m1, SRSLTE_SSS_N); } #endif diff --git a/srslte/lib/sync/test/sss_mex.c b/srslte/lib/sync/test/sss_mex.c index 3462a4d6c..da8291adf 100644 --- a/srslte/lib/sync/test/sss_mex.c +++ b/srslte/lib/sync/test/sss_mex.c @@ -51,7 +51,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { srslte_cell_t cell; - sss_synch_t sss; + srslte_sss_synch_t sss; cf_t *input_symbols; int frame_len; uint32_t m0, m1; @@ -81,12 +81,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } - if (sss_synch_init(&sss, srslte_symbol_sz(cell.nof_prb))) { + if (srslte_sss_synch_init(&sss, srslte_symbol_sz(cell.nof_prb))) { mexErrMsgTxt("Error initializing SSS object\n"); return; } - sss_synch_set_N_id_2(&sss, cell.id%3); + srslte_sss_synch_set_N_id_2(&sss, cell.id%3); // Find SSS uint32_t sss_idx = SRSLTE_SLOT_IDX_CPNORM(5,srslte_symbol_sz(cell.nof_prb)); @@ -96,31 +96,31 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } //mexPrintf("SSS begins at %d/%d. Running algorithm %s\n", sss_idx, frame_len, alg); if (!strcmp(alg, "partial")) { - sss_synch_m0m1_partial(&sss, &input_symbols[sss_idx], 3, NULL, &m0, &m0_value, &m1, &m1_value); + srslte_sss_synch_m0m1_partial(&sss, &input_symbols[sss_idx], 3, NULL, &m0, &m0_value, &m1, &m1_value); } else if (!strcmp(alg, "diff")) { - sss_synch_m0m1_diff(&sss, &input_symbols[sss_idx], &m0, &m0_value, &m1, &m1_value); + srslte_sss_synch_m0m1_diff(&sss, &input_symbols[sss_idx], &m0, &m0_value, &m1, &m1_value); } else if (!strcmp(alg, "full")) { - sss_synch_m0m1_partial(&sss, &input_symbols[sss_idx], 1, NULL, &m0, &m0_value, &m1, &m1_value); + srslte_sss_synch_m0m1_partial(&sss, &input_symbols[sss_idx], 1, NULL, &m0, &m0_value, &m1, &m1_value); } else { mexErrMsgTxt("Unsupported algorithm type\n"); return; } - //mexPrintf("m0: %d, m1: %d, N_id_1: %d\n", m0, m1, sss_synch_N_id_1(&sss, m0, m1)); + //mexPrintf("m0: %d, m1: %d, N_id_1: %d\n", m0, m1, srslte_sss_synch_N_id_1(&sss, m0, m1)); if (nlhs >= 1) { - plhs[0] = mxCreateDoubleScalar(sss_synch_N_id_1(&sss, m0, m1)); + plhs[0] = mxCreateDoubleScalar(srslte_sss_synch_N_id_1(&sss, m0, m1)); } if (nlhs >= 2) { - plhs[1] = mxCreateDoubleScalar(sss_synch_subframe(m0, m1)); + plhs[1] = mxCreateDoubleScalar(srslte_sss_synch_subframe(m0, m1)); } if (nlhs >= 3) { - mexutils_write_f(sss.corr_output_m0, &plhs[2], N_SSS, 1); + mexutils_write_f(sss.corr_output_m0, &plhs[2], SRSLTE_SSS_N, 1); } if (nlhs >= 4) { - mexutils_write_f(sss.corr_output_m1, &plhs[3], N_SSS, 1); + mexutils_write_f(sss.corr_output_m1, &plhs[3], SRSLTE_SSS_N, 1); } - sss_synch_free(&sss); + srslte_sss_synch_free(&sss); free(input_symbols); return; diff --git a/srslte/lib/sync/test/sync_test.c b/srslte/lib/sync/test/sync_test.c index 312a397b8..47ef05a34 100644 --- a/srslte/lib/sync/test/sync_test.c +++ b/srslte/lib/sync/test/sync_test.c @@ -49,7 +49,7 @@ void usage(char *prog) { printf("\t-p nof_prb [Default %d]\n", nof_prb); printf("\t-o offset [Default %d]\n", offset); printf("\t-e extended CP [Default normal]\n"); - printf("\t-v verbose\n"); + printf("\t-v srslte_verbose\n"); } void parse_args(int argc, char **argv) { @@ -69,7 +69,7 @@ void parse_args(int argc, char **argv) { cp = SRSLTE_SRSLTE_CP_EXT; break; case 'v': - verbose++; + srslte_verbose++; break; default: usage(argv[0]); @@ -81,13 +81,13 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { int N_id_2, ns, find_ns; cf_t *buffer, *fft_buffer; - cf_t pss_signal[PSS_LEN]; - float sss_signal0[SSS_LEN]; // for subframe 0 - float sss_signal5[SSS_LEN]; // for subframe 5 + cf_t pss_signal[SRSLTE_PSS_LEN]; + float sss_signal0[SRSLTE_SSS_LEN]; // for subframe 0 + float sss_signal5[SRSLTE_SSS_LEN]; // for subframe 5 int cid, max_cid; uint32_t find_idx; - sync_t sync; - srslte_fft_t ifft; + srslte_sync_t sync; + srslte_ofdm_t ifft; int fft_size; parse_args(argc, argv); @@ -110,19 +110,19 @@ int main(int argc, char **argv) { exit(-1); } - if (lte_ifft_init(&ifft, cp, nof_prb)) { + if (srslte_ofdm_rx_init(&ifft, cp, nof_prb)) { fprintf(stderr, "Error creating iFFT object\n"); exit(-1); } - if (sync_init(&sync, FLEN, fft_size)) { + if (srslte_sync_init(&sync, FLEN, fft_size)) { fprintf(stderr, "Error initiating PSS/SSS\n"); return -1; } /* Set a very high threshold to make sure the correlation is ok */ - sync_set_threshold(&sync, 5.0); - sync_set_sss_algorithm(&sync, SSS_PARTIAL_3); + srslte_sync_set_threshold(&sync, 5.0); + srslte_sync_set_sss_algorithm(&sync, SSS_PARTIAL_3); if (cell_id == -1) { cid = 0; @@ -135,25 +135,25 @@ int main(int argc, char **argv) { N_id_2 = cid%3; /* Generate PSS/SSS signals */ - pss_generate(pss_signal, N_id_2); - sss_generate(sss_signal0, sss_signal5, cid); + srslte_pss_generate(pss_signal, N_id_2); + srslte_sss_generate(sss_signal0, sss_signal5, cid); - sync_set_N_id_2(&sync, N_id_2); + srslte_sync_set_N_id_2(&sync, N_id_2); for (ns=0;ns<2;ns++) { memset(buffer, 0, sizeof(cf_t) * FLEN); - pss_put_slot(pss_signal, buffer, nof_prb, cp); - sss_put_slot(ns?sss_signal5:sss_signal0, buffer, nof_prb, cp); + srslte_pss_put_slot(pss_signal, buffer, nof_prb, cp); + srslte_sss_put_slot(ns?sss_signal5:sss_signal0, buffer, nof_prb, cp); /* Transform to OFDM symbols */ memset(fft_buffer, 0, sizeof(cf_t) * FLEN); - lte_ifft_run_slot(&ifft, buffer, &fft_buffer[offset]); + srslte_ofdm_rx_slot(&ifft, buffer, &fft_buffer[offset]); - if (sync_find(&sync, fft_buffer, 0, &find_idx) < 0) { - fprintf(stderr, "Error running sync_find\n"); + if (srslte_sync_find(&sync, fft_buffer, 0, &find_idx) < 0) { + fprintf(stderr, "Error running srslte_sync_find\n"); exit(-1); } - find_ns = 2*sync_get_sf_idx(&sync); + find_ns = 2*srslte_sync_get_sf_idx(&sync); printf("cell_id: %d find: %d, offset: %d, ns=%d find_ns=%d\n", cid, find_idx, offset, ns, find_ns); if (find_idx != offset + FLEN/2) { @@ -164,7 +164,7 @@ int main(int argc, char **argv) { printf("ns != find_ns\n", 10 * ns, find_ns); exit(-1); } - if (sync_get_cp(&sync) != cp) { + if (srslte_sync_get_cp(&sync) != cp) { printf("Detected CP should be %s\n", SRSLTE_CP_ISNORM(cp)?"Normal":"Extended"); exit(-1); } @@ -175,8 +175,8 @@ int main(int argc, char **argv) { free(fft_buffer); free(buffer); - sync_free(&sync); - lte_ifft_free(&ifft); + srslte_sync_free(&sync); + srslte_ofdm_rx_free(&ifft); printf("Ok\n"); exit(0); diff --git a/srslte/lib/ue/src/ue_cell_search.c b/srslte/lib/ue/src/ue_cell_search.c index 930e4675d..b5cdd813e 100644 --- a/srslte/lib/ue/src/ue_cell_search.c +++ b/srslte/lib/ue/src/ue_cell_search.c @@ -39,12 +39,12 @@ float tmp_pss_corr[32*10000]; float tmp_sss_corr[31*10000]; -int ue_cell_search_init(ue_cell_search_t * q, int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*), void *stream_handler) +int srslte_ue_cellsearch_init(srslte_ue_cellsearch_t * q, int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*), void *stream_handler) { - return ue_cell_search_init_max(q, CS_DEFAULT_MAXFRAMES_TOTAL, recv_callback, stream_handler); + return srslte_ue_cellsearch_init_max(q, SRSLTE_CS_DEFAULT_MAXFRAMES_TOTAL, recv_callback, stream_handler); } -int ue_cell_search_init_max(ue_cell_search_t * q, uint32_t max_frames, +int srslte_ue_cellsearch_init_max(srslte_ue_cellsearch_t * q, uint32_t max_frames, int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*), void *stream_handler) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -53,18 +53,18 @@ int ue_cell_search_init_max(ue_cell_search_t * q, uint32_t max_frames, ret = SRSLTE_ERROR; srslte_cell_t cell; - bzero(q, sizeof(ue_cell_search_t)); + bzero(q, sizeof(srslte_ue_cellsearch_t)); bzero(&cell, sizeof(srslte_cell_t)); cell.id = SRSLTE_CELL_ID_UNKNOWN; - cell.nof_prb = CS_NOF_PRB; + cell.nof_prb = SRSLTE_CS_NOF_PRB; - if (ue_sync_init(&q->ue_sync, cell, recv_callback, stream_handler)) { + if (srslte_ue_sync_init(&q->ue_sync, cell, recv_callback, stream_handler)) { fprintf(stderr, "Error initiating ue_sync\n"); goto clean_exit; } - q->candidates = calloc(sizeof(ue_cell_search_result_t), max_frames); + q->candidates = calloc(sizeof(srslte_ue_cellsearch_result_t), max_frames); if (!q->candidates) { perror("malloc"); goto clean_exit; @@ -81,19 +81,19 @@ int ue_cell_search_init_max(ue_cell_search_t * q, uint32_t max_frames, } q->max_frames = max_frames; - q->nof_frames_to_scan = CS_DEFAULT_NOFFRAMES_TOTAL; + q->nof_frames_to_scan = SRSLTE_CS_DEFAULT_NOFFRAMES_TOTAL; ret = SRSLTE_SUCCESS; } clean_exit: if (ret == SRSLTE_ERROR) { - ue_cell_search_free(q); + srslte_ue_cellsearch_free(q); } return ret; } -void ue_cell_search_free(ue_cell_search_t * q) +void srslte_ue_cellsearch_free(srslte_ue_cellsearch_t * q) { if (q->candidates) { free(q->candidates); @@ -104,18 +104,18 @@ void ue_cell_search_free(ue_cell_search_t * q) if (q->mode_ntimes) { free(q->mode_ntimes); } - ue_sync_free(&q->ue_sync); + srslte_ue_sync_free(&q->ue_sync); - bzero(q, sizeof(ue_cell_search_t)); + bzero(q, sizeof(srslte_ue_cellsearch_t)); } -void ue_cell_search_set_threshold(ue_cell_search_t * q, float threshold) +void srslte_ue_cellsearch_set_threshold(srslte_ue_cellsearch_t * q, float threshold) { q->detect_threshold = threshold; } -int ue_cell_search_set_nof_frames_to_scan(ue_cell_search_t * q, uint32_t nof_frames) +int srslte_ue_cellsearch_set_nof_frames_to_scan(srslte_ue_cellsearch_t * q, uint32_t nof_frames) { if (nof_frames <= q->max_frames) { q->nof_frames_to_scan = nof_frames; @@ -126,7 +126,7 @@ int ue_cell_search_set_nof_frames_to_scan(ue_cell_search_t * q, uint32_t nof_fra } /* Decide the most likely cell based on the mode */ -static void get_cell(ue_cell_search_t * q, uint32_t nof_detected_frames, ue_cell_search_result_t *found_cell) +static void get_cell(srslte_ue_cellsearch_t * q, uint32_t nof_detected_frames, srslte_ue_cellsearch_result_t *found_cell) { uint32_t i, j; @@ -182,13 +182,13 @@ static void get_cell(ue_cell_search_t * q, uint32_t nof_detected_frames, ue_cell * Saves in the pointer max_N_id_2 the N_id_2 index of the cell with the highest PSR * Returns the number of found cells or a negative number if error */ -int ue_cell_search_scan(ue_cell_search_t * q, ue_cell_search_result_t found_cells[3], uint32_t *max_N_id_2) +int srslte_ue_cellsearch_scan(srslte_ue_cellsearch_t * q, srslte_ue_cellsearch_result_t found_cells[3], uint32_t *max_N_id_2) { int ret = 0; float max_peak_value = -1.0; uint32_t nof_detected_cells = 0; for (uint32_t N_id_2=0;N_id_2<3 && ret >= 0;N_id_2++) { - ret = ue_cell_search_scan_N_id_2(q, N_id_2, &found_cells[N_id_2]); + ret = srslte_ue_cellsearch_scan_N_id_2(q, N_id_2, &found_cells[N_id_2]); if (ret < 0) { fprintf(stderr, "Error searching cell\n"); return ret; @@ -207,7 +207,7 @@ int ue_cell_search_scan(ue_cell_search_t * q, ue_cell_search_result_t found_cell /** Finds a cell for a given N_id_2 and stores ID and CP in the structure pointed by found_cell. * Returns 1 if the cell is found, 0 if not or -1 on error */ -int ue_cell_search_scan_N_id_2(ue_cell_search_t * q, uint32_t N_id_2, ue_cell_search_result_t *found_cell) +int srslte_ue_cellsearch_scan_N_id_2(srslte_ue_cellsearch_t * q, uint32_t N_id_2, srslte_ue_cellsearch_result_t *found_cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; cf_t *sf_buffer = NULL; @@ -218,23 +218,23 @@ int ue_cell_search_scan_N_id_2(ue_cell_search_t * q, uint32_t N_id_2, ue_cell_se { ret = SRSLTE_SUCCESS; - ue_sync_set_N_id_2(&q->ue_sync, N_id_2); - ue_sync_reset(&q->ue_sync); + ue_srslte_sync_set_N_id_2(&q->ue_sync, N_id_2); + srslte_ue_sync_reset(&q->ue_sync); do { - ret = ue_sync_get_buffer(&q->ue_sync, &sf_buffer); + ret = srslte_ue_sync_get_buffer(&q->ue_sync, &sf_buffer); if (ret < 0) { - fprintf(stderr, "Error calling ue_sync_work()\n"); + fprintf(stderr, "Error calling srslte_ue_sync_work()\n"); break; } else if (ret == 1) { /* This means a peak was found and ue_sync is now in tracking state */ - ret = sync_get_cell_id(&q->ue_sync.strack); + ret = srslte_sync_get_cell_id(&q->ue_sync.strack); if (ret >= 0) { /* Save cell id, cp and peak */ q->candidates[nof_detected_frames].cell_id = (uint32_t) ret; - q->candidates[nof_detected_frames].cp = sync_get_cp(&q->ue_sync.strack); + q->candidates[nof_detected_frames].cp = srslte_sync_get_cp(&q->ue_sync.strack); q->candidates[nof_detected_frames].peak = q->ue_sync.strack.pss.peak_value; - q->candidates[nof_detected_frames].psr = sync_get_peak_value(&q->ue_sync.strack); + q->candidates[nof_detected_frames].psr = srslte_sync_get_peak_value(&q->ue_sync.strack); INFO ("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, @@ -254,14 +254,14 @@ int ue_cell_search_scan_N_id_2(ue_cell_search_t * q, uint32_t N_id_2, ue_cell_se nof_scanned_frames++; - } while ((sync_get_peak_value(&q->ue_sync.strack) < q->detect_threshold || + } while ((srslte_sync_get_peak_value(&q->ue_sync.strack) < q->detect_threshold || nof_detected_frames < 4) && nof_scanned_frames < q->nof_frames_to_scan); /* - vec_save_file("sss_corr",tmp_sss_corr, nof_detected_frames*sizeof(float)*31); - vec_save_file("track_corr",tmp_pss_corr, nof_detected_frames*sizeof(float)*32); - vec_save_file("find_corr",q->ue_sync.sfind.pss.conv_output_avg, + srslte_vec_save_file("sss_corr",tmp_sss_corr, nof_detected_frames*sizeof(float)*31); + srslte_vec_save_file("track_corr",tmp_pss_corr, nof_detected_frames*sizeof(float)*32); + srslte_vec_save_file("find_corr",q->ue_sync.sfind.pss.conv_output_avg, sizeof(float)*(9600+127)); */ diff --git a/srslte/lib/ue/src/ue_dl.c b/srslte/lib/ue/src/ue_dl.c index 5706abc44..b7d0d5241 100644 --- a/srslte/lib/ue/src/ue_dl.c +++ b/srslte/lib/ue/src/ue_dl.c @@ -38,7 +38,7 @@ #define MAX_CANDIDATES 64 -int ue_dl_init(ue_dl_t *q, +int srs_ue_dl_init(srs_ue_dl_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -48,13 +48,13 @@ int ue_dl_init(ue_dl_t *q, { ret = SRSLTE_ERROR; - bzero(q, sizeof(ue_dl_t)); + bzero(q, sizeof(srs_ue_dl_t)); q->cell = cell; q->pkt_errors = 0; q->pkts_total = 0; - if (srslte_fft_init(&q->fft, q->cell.cp, q->cell.nof_prb)) { + if (srslte_ofdm_tx_init(&q->fft, q->cell.cp, q->cell.nof_prb)) { fprintf(stderr, "Error initiating FFT\n"); goto clean_exit; } @@ -62,37 +62,37 @@ int ue_dl_init(ue_dl_t *q, fprintf(stderr, "Error initiating channel estimator\n"); goto clean_exit; } - if (regs_init(&q->regs, q->cell)) { + if (srslte_regs_init(&q->regs, q->cell)) { fprintf(stderr, "Error initiating REGs\n"); goto clean_exit; } - if (pcfich_init(&q->pcfich, &q->regs, q->cell)) { + if (srslte_pcfich_init(&q->pcfich, &q->regs, q->cell)) { fprintf(stderr, "Error creating PCFICH object\n"); goto clean_exit; } - if (pdcch_init(&q->pdcch, &q->regs, q->cell)) { + if (srslte_pdcch_init(&q->pdcch, &q->regs, q->cell)) { fprintf(stderr, "Error creating PDCCH object\n"); goto clean_exit; } - if (pdsch_init(&q->pdsch, q->cell)) { + if (srslte_pdsch_init(&q->pdsch, q->cell)) { fprintf(stderr, "Error creating PDSCH object\n"); goto clean_exit; } - for (uint32_t i=0;iharq_process[i], q->cell)) { + for (uint32_t i=0;iharq_process[i], q->cell)) { fprintf(stderr, "Error initiating HARQ process\n"); goto clean_exit; } } - q->sf_symbols = vec_malloc(CURRENT_SFLEN_RE * sizeof(cf_t)); + q->sf_symbols = srslte_vec_malloc(CURRENT_SFLEN_RE * sizeof(cf_t)); if (!q->sf_symbols) { perror("malloc"); goto clean_exit; } for (uint32_t i=0;icell.nof_ports;i++) { - q->ce[i] = vec_malloc(CURRENT_SFLEN_RE * sizeof(cf_t)); + q->ce[i] = srslte_vec_malloc(CURRENT_SFLEN_RE * sizeof(cf_t)); if (!q->ce[i]) { perror("malloc"); goto clean_exit; @@ -107,21 +107,21 @@ int ue_dl_init(ue_dl_t *q, clean_exit: if (ret == SRSLTE_ERROR) { - ue_dl_free(q); + srs_ue_dl_free(q); } return ret; } -void ue_dl_free(ue_dl_t *q) { +void srs_ue_dl_free(srs_ue_dl_t *q) { if (q) { - srslte_fft_free(&q->fft); + srslte_ofdm_tx_free(&q->fft); srslte_chest_dl_free(&q->chest); - regs_free(&q->regs); - pcfich_free(&q->pcfich); - pdcch_free(&q->pdcch); - pdsch_free(&q->pdsch); - for (uint32_t i=0;iharq_process[i]); + srslte_regs_free(&q->regs); + srslte_pcfich_free(&q->pcfich); + srslte_pdcch_free(&q->pdcch); + srslte_pdsch_free(&q->pdsch); + for (uint32_t i=0;iharq_process[i]); } if (q->sf_symbols) { free(q->sf_symbols); @@ -132,57 +132,57 @@ void ue_dl_free(ue_dl_t *q) { } } - bzero(q, sizeof(ue_dl_t)); + bzero(q, sizeof(srs_ue_dl_t)); } } /* Precalculate the PDSCH scramble sequences for a given RNTI. This function takes a while * to execute, so shall be called once the final C-RNTI has been allocated for the session. - * For the connection procedure, use pusch_encode_rnti() or pusch_decode_rnti() functions + * For the connection procedure, use srslte_pusch_encode_rnti() or srslte_pusch_decode_rnti() functions */ -void ue_dl_set_rnti(ue_dl_t *q, uint16_t rnti) { +void srs_ue_dl_set_rnti(srs_ue_dl_t *q, uint16_t rnti) { q->current_rnti = rnti; - pdsch_set_rnti(&q->pdsch, rnti); + srslte_pdsch_set_rnti(&q->pdsch, rnti); } -void ue_dl_reset(ue_dl_t *q) { - harq_reset(&q->harq_process[0]); +void srs_ue_dl_reset(srs_ue_dl_t *q) { + srslte_harq_reset(&q->harq_process[0]); } -dci_format_t ue_formats[] = {Format1,Format1A}; // Format1B should go here also +srslte_dci_format_t ue_formats[] = {SRSLTE_DCI_FORMAT1,SRSLTE_DCI_FORMAT1A}; // SRSLTE_DCI_FORMAT1B should go here also const uint32_t nof_ue_formats = 2; -dci_format_t common_formats[] = {Format1A,Format1C}; +srslte_dci_format_t common_formats[] = {SRSLTE_DCI_FORMAT1A,SRSLTE_DCI_FORMAT1C}; const uint32_t nof_common_formats = 2; /** Applies the following operations to a subframe of synchronized samples: * - OFDM demodulation * - Channel estimation * - PCFICH decoding - * - PDCCH decoding: Find DCI for RNTI given by previous call to ue_dl_set_rnti() - * - PDSCH decoding: Decode TB scrambling with RNTI given by ue_dl_set_rnti() + * - PDCCH decoding: Find DCI for RNTI given by previous call to srs_ue_dl_set_rnti() + * - PDSCH decoding: Decode TB scrambling with RNTI given by srs_ue_dl_set_rnti() */ -int ue_dl_decode(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx) { - return ue_dl_decode_rnti_rv(q, input, data, sf_idx, q->current_rnti, 0); +int srs_ue_dl_decode(srs_ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx) { + return srs_ue_dl_decode_rnti_rv(q, input, data, sf_idx, q->current_rnti, 0); } -int ue_dl_decode_rnti(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint16_t rnti) { - return ue_dl_decode_rnti_rv(q, input, data, sf_idx, rnti, 0); +int srs_ue_dl_decode_rnti(srs_ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint16_t rnti) { + return srs_ue_dl_decode_rnti_rv(q, input, data, sf_idx, rnti, 0); } -int ue_dl_decode_fft_estimate(ue_dl_t *q, cf_t *input, uint32_t sf_idx, uint32_t *cfi) { +int srs_ue_dl_decode_fft_estimate(srs_ue_dl_t *q, cf_t *input, uint32_t sf_idx, uint32_t *cfi) { float cfi_corr; if (input && q && cfi && sf_idx < SRSLTE_NSUBFRAMES_X_FRAME) { /* Run FFT for all subframe data */ - srslte_fft_run_sf(&q->fft, input, q->sf_symbols); + srslte_ofdm_tx_sf(&q->fft, input, q->sf_symbols); /* Get channel estimates for each port */ srslte_chest_dl_estimate(&q->chest, q->sf_symbols, q->ce, sf_idx); /* First decode PCFICH and obtain CFI */ - if (pcfich_decode(&q->pcfich, q->sf_symbols, q->ce, + if (srslte_pcfich_decode(&q->pcfich, q->sf_symbols, q->ce, srslte_chest_dl_get_noise_estimate(&q->chest), sf_idx, cfi, &cfi_corr)<0) { fprintf(stderr, "Error decoding PCFICH\n"); return SRSLTE_ERROR; @@ -190,13 +190,13 @@ int ue_dl_decode_fft_estimate(ue_dl_t *q, cf_t *input, uint32_t sf_idx, uint32_t INFO("Decoded CFI=%d with correlation %.2f\n", *cfi, cfi_corr); - if (regs_set_cfi(&q->regs, *cfi)) { + if (srslte_regs_set_cfi(&q->regs, *cfi)) { fprintf(stderr, "Error setting CFI\n"); return SRSLTE_ERROR; } /* Extract all PDCCH symbols and get LLRs */ - if (pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, srslte_chest_dl_get_noise_estimate(&q->chest), sf_idx, *cfi)) { + if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, srslte_chest_dl_get_noise_estimate(&q->chest), sf_idx, *cfi)) { fprintf(stderr, "Error extracting LLRs\n"); return SRSLTE_ERROR; } @@ -208,13 +208,13 @@ int ue_dl_decode_fft_estimate(ue_dl_t *q, cf_t *input, uint32_t sf_idx, uint32_t } } -int ue_dl_decode_rnti_rv_packet(ue_dl_t *q, dci_msg_t *dci_msg, uint8_t *data, +int srs_ue_dl_decode_rnti_rv_packet(srs_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint8_t *data, uint32_t cfi, uint32_t sf_idx, uint16_t rnti, uint32_t rvidx) { int ret = SRSLTE_ERROR; - q->nof_pdcch_detected++; - if (dci_msg_to_ra_dl(dci_msg, rnti, q->cell, cfi, &q->ra_dl)) { + q->nof_detected++; + if (srslte_dci_msg_to_ra_dl(dci_msg, rnti, q->cell, cfi, &q->ra_dl)) { fprintf(stderr, "Error unpacking PDSCH scheduling DCI message\n"); return SRSLTE_ERROR; } @@ -222,22 +222,22 @@ int ue_dl_decode_rnti_rv_packet(ue_dl_t *q, dci_msg_t *dci_msg, uint8_t *data, 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)) { + if (srslte_harq_setup_dl(&q->harq_process[0], q->ra_dl.mcs, rvidx, sf_idx, &q->ra_dl.prb_alloc)) { fprintf(stderr, "Error configuring HARQ process\n"); return SRSLTE_ERROR; } if (q->harq_process[0].mcs.mod > 0 && q->harq_process[0].mcs.tbs >= 0) { - ret = pdsch_decode_rnti(&q->pdsch, &q->harq_process[0], q->sf_symbols, + ret = srslte_pdsch_decode_rnti(&q->pdsch, &q->harq_process[0], q->sf_symbols, q->ce, srslte_chest_dl_get_noise_estimate(&q->chest), rnti, data); if (ret == SRSLTE_ERROR) { q->pkt_errors++; } else if (ret == SRSLTE_ERROR_INVALID_INPUTS) { - fprintf(stderr, "Error calling pdsch_decode()\n"); + fprintf(stderr, "Error calling srslte_pdsch_decode()\n"); } else if (ret == SRSLTE_SUCCESS) { - if (VERBOSE_ISINFO()) { + if (SRSLTE_VERBOSE_ISINFO()) { INFO("Decoded Message: ", 0); - vec_fprint_hex(stdout, data, q->ra_dl.mcs.tbs); + srslte_vec_fprint_hex(stdout, data, q->ra_dl.mcs.tbs); } } q->pkts_total++; @@ -245,13 +245,13 @@ int ue_dl_decode_rnti_rv_packet(ue_dl_t *q, dci_msg_t *dci_msg, uint8_t *data, return ret; } -int ue_dl_find_ul_dci(ue_dl_t *q, dci_msg_t *dci_msg, uint32_t cfi, uint32_t sf_idx, uint16_t rnti) +int srs_ue_dl_find_ul_dci(srs_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint32_t cfi, uint32_t sf_idx, uint16_t rnti) { - dci_location_t locations[MAX_CANDIDATES]; - uint32_t nof_locations = pdcch_ue_locations(&q->pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti); + srslte_dci_location_t locations[MAX_CANDIDATES]; + uint32_t nof_locations = srslte_pdcch_ue_locations(&q->pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti); uint16_t srslte_crc_rem = 0; for (uint32_t i=0;ipdcch, dci_msg, &locations[i], Format0, &srslte_crc_rem)) { + if (srslte_pdcch_decode_msg(&q->pdcch, dci_msg, &locations[i], SRSLTE_DCI_FORMAT0, &srslte_crc_rem)) { fprintf(stderr, "Error decoding DCI msg\n"); return SRSLTE_ERROR; } @@ -260,28 +260,28 @@ int ue_dl_find_ul_dci(ue_dl_t *q, dci_msg_t *dci_msg, uint32_t cfi, uint32_t sf_ return srslte_crc_rem == rnti; } -int ue_dl_decode_rnti_rv(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint16_t rnti, uint32_t rvidx) +int srs_ue_dl_decode_rnti_rv(srs_ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint16_t rnti, uint32_t rvidx) { uint32_t cfi, i; - dci_msg_t dci_msg; - dci_location_t locations[MAX_CANDIDATES]; + srslte_dci_msg_t dci_msg; + srslte_dci_location_t locations[MAX_CANDIDATES]; uint32_t nof_locations; uint16_t srslte_crc_rem; int ret = SRSLTE_ERROR; uint32_t nof_formats; - dci_format_t *formats = NULL; + srslte_dci_format_t *formats = NULL; - if ((ret = ue_dl_decode_fft_estimate(q, input, sf_idx, &cfi)) < 0) { + if ((ret = srs_ue_dl_decode_fft_estimate(q, input, sf_idx, &cfi)) < 0) { return ret; } /* Generate PDCCH candidates */ if (rnti == SRSLTE_SIRNTI) { - nof_locations = pdcch_common_locations(&q->pdcch, locations, MAX_CANDIDATES, cfi); + nof_locations = srslte_pdcch_common_locations(&q->pdcch, locations, MAX_CANDIDATES, cfi); formats = common_formats; nof_formats = nof_common_formats; } else { - nof_locations = pdcch_ue_locations(&q->pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti); + nof_locations = srslte_pdcch_ue_locations(&q->pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti); formats = ue_formats; nof_formats = nof_ue_formats; } @@ -290,9 +290,9 @@ int ue_dl_decode_rnti_rv(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx srslte_crc_rem = 0; uint32_t found_dci = 0; for (int f=0;fpdcch, &dci_msg, &locations[i], formats[f], &srslte_crc_rem)) { + if (srslte_pdcch_decode_msg(&q->pdcch, &dci_msg, &locations[i], formats[f], &srslte_crc_rem)) { fprintf(stderr, "Error decoding DCI msg\n"); return SRSLTE_ERROR; } @@ -300,7 +300,7 @@ int ue_dl_decode_rnti_rv(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx if (srslte_crc_rem == rnti) { found_dci++; - ret = ue_dl_decode_rnti_rv_packet(q, &dci_msg, data, cfi, sf_idx, rnti, rvidx); + ret = srs_ue_dl_decode_rnti_rv_packet(q, &dci_msg, data, cfi, sf_idx, rnti, rvidx); } } } diff --git a/srslte/lib/ue/src/ue_mib.c b/srslte/lib/ue/src/ue_mib.c index 3230228c2..cd44a600b 100644 --- a/srslte/lib/ue/src/ue_mib.c +++ b/srslte/lib/ue/src/ue_mib.c @@ -36,33 +36,33 @@ #include "srslte/utils/debug.h" #include "srslte/utils/vector.h" -int ue_mib_init(ue_mib_t * q, +int srslte_ue_mib_init(srslte_ue_mib_t * q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && - cell.nof_ports <= MIB_SRSLTE_MAX_PORTS) + cell.nof_ports <= SRSLTE_UE_MIB_MAX_PORTS) { ret = SRSLTE_ERROR; - bzero(q, sizeof(ue_mib_t)); + bzero(q, sizeof(srslte_ue_mib_t)); - q->sf_symbols = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); + q->sf_symbols = srslte_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(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); + q->ce[i] = srslte_vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); if (!q->ce[i]) { perror("malloc"); goto clean_exit; } } - if (srslte_fft_init(&q->fft, cell.cp, cell.nof_prb)) { + if (srslte_ofdm_tx_init(&q->fft, cell.cp, cell.nof_prb)) { fprintf(stderr, "Error initializing FFT\n"); goto clean_exit; } @@ -70,56 +70,56 @@ int ue_mib_init(ue_mib_t * q, fprintf(stderr, "Error initializing reference signal\n"); goto clean_exit; } - if (pbch_init(&q->pbch, cell)) { + if (srslte_pbch_init(&q->pbch, cell)) { fprintf(stderr, "Error initiating PBCH\n"); goto clean_exit; } - ue_mib_reset(q); + srslte_ue_mib_reset(q); ret = SRSLTE_SUCCESS; } clean_exit: if (ret == SRSLTE_ERROR) { - ue_mib_free(q); + srslte_ue_mib_free(q); } return ret; } -void ue_mib_free(ue_mib_t * q) +void srslte_ue_mib_free(srslte_ue_mib_t * q) { if (q->sf_symbols) { free(q->sf_symbols); } - for (int i=0;ice[i]) { free(q->ce[i]); } } - sync_free(&q->sfind); + srslte_sync_free(&q->sfind); srslte_chest_dl_free(&q->chest); - pbch_free(&q->pbch); - srslte_fft_free(&q->fft); + srslte_pbch_free(&q->pbch); + srslte_ofdm_tx_free(&q->fft); - bzero(q, sizeof(ue_mib_t)); + bzero(q, sizeof(srslte_ue_mib_t)); } -void ue_mib_reset(ue_mib_t * q) +void srslte_ue_mib_reset(srslte_ue_mib_t * q) { q->frame_cnt = 0; - pbch_decode_reset(&q->pbch); + srslte_pbch_decode_reset(&q->pbch); } -int ue_mib_decode(ue_mib_t * q, cf_t *input, +int srslte_ue_mib_decode(srslte_ue_mib_t * q, cf_t *input, uint8_t bch_payload[BCH_PAYLOAD_LEN], uint32_t *nof_tx_ports, uint32_t *sfn_offset) { int ret = SRSLTE_SUCCESS; cf_t *ce_slot1[SRSLTE_MAX_PORTS]; /* Run FFT for the slot symbols */ - srslte_fft_run_sf(&q->fft, input, q->sf_symbols); + srslte_ofdm_tx_sf(&q->fft, input, q->sf_symbols); /* Get channel estimates of sf idx #0 for each port */ ret = srslte_chest_dl_estimate(&q->chest, q->sf_symbols, q->ce, 0); @@ -129,7 +129,7 @@ int ue_mib_decode(ue_mib_t * q, cf_t *input, /* Reset decoder if we missed a frame */ if (q->frame_cnt > 8) { INFO("Resetting PBCH decoder after %d frames\n", q->frame_cnt); - ue_mib_reset(q); + srslte_ue_mib_reset(q); } for (int i=0;ipbch, &q->sf_symbols[SRSLTE_SLOT_LEN_RE(q->chest.cell.nof_prb, q->chest.cell.cp)], + ret = srslte_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) { fprintf(stderr, "Error decoding PBCH (%d)\n", ret); } else if (ret == 1) { INFO("MIB decoded: %u\n", q->frame_cnt); - ue_mib_reset(q); - ret = MIB_FOUND; + srslte_ue_mib_reset(q); + ret = SRSLTE_UE_MIB_FOUND; } else { INFO("MIB not decoded: %u\n", q->frame_cnt); q->frame_cnt++; - ret = MIB_NOTFOUND; + ret = SRSLTE_UE_MIB_NOTFOUND; } return ret; } -int ue_mib_sync_init(ue_mib_sync_t *q, +int srslte_ue_mib_sync_init(srslte_ue_mib_sync_t *q, uint32_t cell_id, srslte_cp_t cp, int (recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*), void *stream_handler) { srslte_cell_t cell; - cell.nof_ports = MIB_SRSLTE_MAX_PORTS; + cell.nof_ports = SRSLTE_UE_MIB_MAX_PORTS; cell.id = cell_id; cell.cp = cp; - cell.nof_prb = MIB_NOF_PRB; + cell.nof_prb = SRSLTE_UE_MIB_NOF_PRB; - if (ue_mib_init(&q->ue_mib, cell)) { + if (srslte_ue_mib_init(&q->ue_mib, cell)) { fprintf(stderr, "Error initiating ue_mib\n"); return SRSLTE_ERROR; } - if (ue_sync_init(&q->ue_sync, cell, recv_callback, stream_handler)) { + if (srslte_ue_sync_init(&q->ue_sync, cell, recv_callback, stream_handler)) { fprintf(stderr, "Error initiating ue_sync\n"); - ue_mib_free(&q->ue_mib); + srslte_ue_mib_free(&q->ue_mib); return SRSLTE_ERROR; } - ue_sync_decode_sss_on_track(&q->ue_sync, true); + srslte_ue_sync_decode_sss_on_track(&q->ue_sync, true); return SRSLTE_SUCCESS; } -void ue_mib_sync_free(ue_mib_sync_t *q) { - ue_mib_free(&q->ue_mib); - ue_sync_free(&q->ue_sync); +void srslte_ue_mib_sync_free(srslte_ue_mib_sync_t *q) { + srslte_ue_mib_free(&q->ue_mib); + srslte_ue_sync_free(&q->ue_sync); } -void ue_mib_sync_reset(ue_mib_sync_t * q) { - ue_mib_reset(&q->ue_mib); - ue_sync_reset(&q->ue_sync); +void srslte_ue_mib_sync_reset(srslte_ue_mib_sync_t * q) { + srslte_ue_mib_reset(&q->ue_mib); + srslte_ue_sync_reset(&q->ue_sync); } -int ue_mib_sync_decode(ue_mib_sync_t * q, +int srslte_ue_mib_sync_decode(srslte_ue_mib_sync_t * q, uint32_t max_frames_timeout, uint8_t bch_payload[BCH_PAYLOAD_LEN], uint32_t *nof_tx_ports, @@ -201,27 +201,27 @@ int ue_mib_sync_decode(ue_mib_sync_t * q, int ret = SRSLTE_ERROR_INVALID_INPUTS; cf_t *sf_buffer = NULL; uint32_t nof_frames = 0; - int mib_ret = MIB_NOTFOUND; + int mib_ret = SRSLTE_UE_MIB_NOTFOUND; if (q != NULL) { ret = SRSLTE_SUCCESS; do { - mib_ret = MIB_NOTFOUND; - ret = ue_sync_get_buffer(&q->ue_sync, &sf_buffer); + mib_ret = SRSLTE_UE_MIB_NOTFOUND; + ret = srslte_ue_sync_get_buffer(&q->ue_sync, &sf_buffer); if (ret < 0) { - fprintf(stderr, "Error calling ue_sync_work()\n"); + fprintf(stderr, "Error calling srslte_ue_sync_work()\n"); break; - } else if (ue_sync_get_sfidx(&q->ue_sync) == 0) { + } else if (srslte_ue_sync_get_sfidx(&q->ue_sync) == 0) { if (ret == 1) { - mib_ret = ue_mib_decode(&q->ue_mib, sf_buffer, bch_payload, nof_tx_ports, sfn_offset); + mib_ret = srslte_ue_mib_decode(&q->ue_mib, sf_buffer, bch_payload, nof_tx_ports, sfn_offset); } else { INFO("Resetting PBCH decoder after %d frames\n", q->ue_mib.frame_cnt); - ue_mib_reset(&q->ue_mib); + srslte_ue_mib_reset(&q->ue_mib); } nof_frames++; } - } while (mib_ret == MIB_NOTFOUND && ret >= 0 && nof_frames < max_frames_timeout); + } while (mib_ret == SRSLTE_UE_MIB_NOTFOUND && ret >= 0 && nof_frames < max_frames_timeout); if (mib_ret < 0) { ret = mib_ret; } diff --git a/srslte/lib/ue/src/ue_sync.c b/srslte/lib/ue/src/ue_sync.c index 8b2acdb00..4a9cb99c2 100644 --- a/srslte/lib/ue/src/ue_sync.c +++ b/srslte/lib/ue/src/ue_sync.c @@ -46,7 +46,7 @@ cf_t dummy[MAX_TIME_OFFSET]; #define TRACK_FRAME_SIZE 32 #define FIND_NOF_AVG_FRAMES 2 -int ue_sync_init_file(ue_sync_t *q, uint32_t nof_prb, char *file_name) { +int srslte_ue_sync_init_file(srslte_ue_sync_t *q, uint32_t nof_prb, char *file_name) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && @@ -54,7 +54,7 @@ int ue_sync_init_file(ue_sync_t *q, uint32_t nof_prb, char *file_name) { srslte_nofprb_isvalid(nof_prb)) { ret = SRSLTE_ERROR; - bzero(q, sizeof(ue_sync_t)); + bzero(q, sizeof(srslte_ue_sync_t)); q->file_mode = true; q->sf_len = SRSLTE_SF_LEN(srslte_symbol_sz(nof_prb)); @@ -63,24 +63,24 @@ int ue_sync_init_file(ue_sync_t *q, uint32_t nof_prb, char *file_name) { goto clean_exit; } - q->input_buffer = vec_malloc(q->sf_len * sizeof(cf_t)); + q->input_buffer = srslte_vec_malloc(q->sf_len * sizeof(cf_t)); if (!q->input_buffer) { perror("malloc"); goto clean_exit; } - ue_sync_reset(q); + srslte_ue_sync_reset(q); ret = SRSLTE_SUCCESS; } clean_exit: if (ret == SRSLTE_ERROR) { - ue_sync_free(q); + srslte_ue_sync_free(q); } return ret; } -int ue_sync_init(ue_sync_t *q, +int srslte_ue_sync_init(srslte_ue_sync_t *q, srslte_cell_t cell, int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*), void *stream_handler) @@ -94,7 +94,7 @@ int ue_sync_init(ue_sync_t *q, { ret = SRSLTE_ERROR; - bzero(q, sizeof(ue_sync_t)); + bzero(q, sizeof(srslte_ue_sync_t)); q->stream = stream_handler; q->recv_callback = recv_callback; @@ -118,130 +118,130 @@ int ue_sync_init(ue_sync_t *q, q->frame_len = q->nof_recv_sf*q->sf_len; - if(sync_init(&q->sfind, q->frame_len, q->fft_size)) { + if(srslte_sync_init(&q->sfind, q->frame_len, q->fft_size)) { fprintf(stderr, "Error initiating sync find\n"); goto clean_exit; } - if(sync_init(&q->strack, TRACK_FRAME_SIZE, q->fft_size)) { + if(srslte_sync_init(&q->strack, TRACK_FRAME_SIZE, q->fft_size)) { fprintf(stderr, "Error initiating sync track\n"); goto clean_exit; } if (cell.id == 1000) { /* If the cell id is unknown, enable CP detection on find */ - sync_cp_en(&q->sfind, true); - sync_cp_en(&q->strack, true); + srslte_sync_cp_en(&q->sfind, true); + srslte_sync_cp_en(&q->strack, true); /* Correct CFO in all cases because both states are called always. */ - sync_correct_cfo(&q->sfind, true); - sync_correct_cfo(&q->strack, true); + srslte_sync_correct_cfo(&q->sfind, true); + srslte_sync_correct_cfo(&q->strack, true); - sync_set_threshold(&q->sfind, 1.3); - sync_set_em_alpha(&q->sfind, 0.01); + srslte_sync_set_threshold(&q->sfind, 1.3); + srslte_sync_set_em_alpha(&q->sfind, 0.01); q->nof_avg_find_frames = FIND_NOF_AVG_FRAMES; - sync_set_threshold(&q->strack, 1.0); + srslte_sync_set_threshold(&q->strack, 1.0); } else { - sync_set_N_id_2(&q->sfind, cell.id%3); - sync_set_N_id_2(&q->strack, cell.id%3); + srslte_sync_set_N_id_2(&q->sfind, cell.id%3); + srslte_sync_set_N_id_2(&q->strack, cell.id%3); q->sfind.cp = cell.cp; q->strack.cp = cell.cp; - sync_cp_en(&q->sfind, false); - sync_cp_en(&q->strack, false); + srslte_sync_cp_en(&q->sfind, false); + srslte_sync_cp_en(&q->strack, false); /* In find phase and if the cell is known, do not average pss correlation * because we only capture 1 subframe and do not know where the peak is. */ - sync_set_em_alpha(&q->sfind, 1); + srslte_sync_set_em_alpha(&q->sfind, 1); q->nof_avg_find_frames = 1; - sync_set_threshold(&q->sfind, 4.0); - sync_set_threshold(&q->strack, 1.3); + srslte_sync_set_threshold(&q->sfind, 4.0); + srslte_sync_set_threshold(&q->strack, 1.3); /* Correct CFO in the find state but not in the track state, since is called only - * 1 every 5 subframes. Will do it in the ue_sync_get_buffer() function. + * 1 every 5 subframes. Will do it in the srslte_ue_sync_get_buffer() function. */ - sync_correct_cfo(&q->sfind, true); - sync_correct_cfo(&q->strack, false); + srslte_sync_correct_cfo(&q->sfind, true); + srslte_sync_correct_cfo(&q->strack, false); } - q->input_buffer = vec_malloc(2*q->frame_len * sizeof(cf_t)); + q->input_buffer = srslte_vec_malloc(2*q->frame_len * sizeof(cf_t)); if (!q->input_buffer) { perror("malloc"); goto clean_exit; } - ue_sync_reset(q); + srslte_ue_sync_reset(q); ret = SRSLTE_SUCCESS; } clean_exit: if (ret == SRSLTE_ERROR) { - ue_sync_free(q); + srslte_ue_sync_free(q); } return ret; } -uint32_t ue_sync_sf_len(ue_sync_t *q) { +uint32_t srslte_ue_sync_sf_len(srslte_ue_sync_t *q) { return q->frame_len; } -void ue_sync_free(ue_sync_t *q) { +void srslte_ue_sync_free(srslte_ue_sync_t *q) { if (q->input_buffer) { free(q->input_buffer); } if (!q->file_mode) { - sync_free(&q->sfind); - sync_free(&q->strack); + srslte_sync_free(&q->sfind); + srslte_sync_free(&q->strack); } else { srslte_filesource_free(&q->file_source); } - bzero(q, sizeof(ue_sync_t)); + bzero(q, sizeof(srslte_ue_sync_t)); } -void ue_sync_get_last_timestamp(ue_sync_t *q, srslte_timestamp_t *timestamp) { +void srslte_ue_sync_get_last_timestamp(srslte_ue_sync_t *q, srslte_timestamp_t *timestamp) { memcpy(timestamp, &q->last_timestamp, sizeof(srslte_timestamp_t)); } -uint32_t ue_sync_peak_idx(ue_sync_t *q) { +uint32_t srslte_ue_sync_peak_idx(srslte_ue_sync_t *q) { return q->peak_idx; } -ue_sync_state_t ue_sync_get_state(ue_sync_t *q) { +srslte_ue_sync_state_t srslte_ue_sync_get_state(srslte_ue_sync_t *q) { return q->state; } -uint32_t ue_sync_get_sfidx(ue_sync_t *q) { +uint32_t srslte_ue_sync_get_sfidx(srslte_ue_sync_t *q) { return q->sf_idx; } -float ue_sync_get_cfo(ue_sync_t *q) { - return 15000 * sync_get_cfo(&q->strack); +float srslte_ue_sync_get_cfo(srslte_ue_sync_t *q) { + return 15000 * srslte_sync_get_cfo(&q->strack); } -float ue_sync_get_sfo(ue_sync_t *q) { +float srslte_ue_sync_get_sfo(srslte_ue_sync_t *q) { return 5000*q->mean_time_offset; } -void ue_sync_decode_sss_on_track(ue_sync_t *q, bool enabled) { +void srslte_ue_sync_decode_sss_on_track(srslte_ue_sync_t *q, bool enabled) { q->decode_sss_on_track = enabled; } -void ue_sync_set_N_id_2(ue_sync_t *q, uint32_t N_id_2) { +void ue_srslte_sync_set_N_id_2(srslte_ue_sync_t *q, uint32_t N_id_2) { if (!q->file_mode) { - ue_sync_reset(q); - sync_set_N_id_2(&q->strack, N_id_2); - sync_set_N_id_2(&q->sfind, N_id_2); + srslte_ue_sync_reset(q); + srslte_sync_set_N_id_2(&q->strack, N_id_2); + srslte_sync_set_N_id_2(&q->sfind, N_id_2); } } -static int find_peak_ok(ue_sync_t *q) { +static int find_peak_ok(srslte_ue_sync_t *q) { - if (sync_sss_detected(&q->sfind)) { + if (srslte_sync_sss_detected(&q->sfind)) { /* Get the subframe index (0 or 5) */ - q->sf_idx = sync_get_sf_idx(&q->sfind) + q->nof_recv_sf; + q->sf_idx = srslte_sync_get_sf_idx(&q->sfind) + q->nof_recv_sf; } else { INFO("Found peak at %d, SSS not detected\n", q->peak_idx); } @@ -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, srslte_cp_string(q->cell.cp)); + srslte_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); @@ -276,15 +276,15 @@ static int find_peak_ok(ue_sync_t *q) { return 0; } -static int track_peak_ok(ue_sync_t *q, uint32_t track_idx) { +static int track_peak_ok(srslte_ue_sync_t *q, uint32_t track_idx) { /* Make sure subframe idx is what we expect */ - if ((q->sf_idx != sync_get_sf_idx(&q->strack)) && q->decode_sss_on_track) { - if (sync_get_cell_id(&q->strack) == q->cell.id) { + if ((q->sf_idx != srslte_sync_get_sf_idx(&q->strack)) && q->decode_sss_on_track) { + if (srslte_sync_get_cell_id(&q->strack) == q->cell.id) { INFO("Warning: Expected SF idx %d but got %d (%d,%g - %d,%g)!\n", - q->sf_idx, sync_get_sf_idx(&q->strack), + q->sf_idx, srslte_sync_get_sf_idx(&q->strack), q->strack.m0, q->strack.m0_value, q->strack.m1, q->strack.m1_value); - q->sf_idx = sync_get_sf_idx(&q->strack); + q->sf_idx = srslte_sync_get_sf_idx(&q->strack); } } @@ -296,7 +296,7 @@ static int track_peak_ok(ue_sync_t *q, uint32_t track_idx) { } /* compute cumulative moving average time offset */ - q->mean_time_offset = (float) VEC_CMA((float) q->time_offset, q->mean_time_offset, q->frame_total_cnt); + q->mean_time_offset = (float) SRSLTE_VEC_CMA((float) q->time_offset, q->mean_time_offset, q->frame_total_cnt); /* If the PSS peak is beyond the frame (we sample too slowly), discard the offseted samples to align next frame */ @@ -316,7 +316,7 @@ static int track_peak_ok(ue_sync_t *q, uint32_t track_idx) { return 1; } -static int track_peak_no(ue_sync_t *q) { +static int track_peak_no(srslte_ue_sync_t *q) { /* if we missed too many PSS go back to FIND */ q->frame_no_cnt++; @@ -325,13 +325,13 @@ static int track_peak_no(ue_sync_t *q) { q->state = SF_FIND; } else { INFO("Tracking peak not found. Peak %.3f, %d lost\n", - sync_get_last_peak_value(&q->strack), (int) q->frame_no_cnt); + srslte_sync_get_last_peak_value(&q->strack), (int) q->frame_no_cnt); } return 1; } -static int receive_samples(ue_sync_t *q) { +static int receive_samples(srslte_ue_sync_t *q) { /* A negative time offset means there are samples in our buffer for the next subframe, because we are sampling too fast. @@ -353,7 +353,7 @@ static int receive_samples(ue_sync_t *q) { bool first_track = true; -int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) { +int srslte_ue_sync_get_buffer(srslte_ue_sync_t *q, cf_t **sf_symbols) { int ret = SRSLTE_ERROR_INVALID_INPUTS; uint32_t track_idx; @@ -392,7 +392,7 @@ int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) { switch (q->state) { case SF_FIND: - ret = sync_find(&q->sfind, q->input_buffer, 0, &q->peak_idx); + ret = srslte_sync_find(&q->sfind, q->input_buffer, 0, &q->peak_idx); if (ret < 0) { fprintf(stderr, "Error finding correlation peak (%d)\n", ret); return SRSLTE_ERROR; @@ -405,7 +405,7 @@ int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) { case SF_TRACK: ret = 1; - sync_sss_en(&q->strack, q->decode_sss_on_track); + srslte_sync_sss_en(&q->strack, q->decode_sss_on_track); q->sf_idx = (q->sf_idx + q->nof_recv_sf) % 10; @@ -420,7 +420,7 @@ int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) { track_idx = 0; /* track PSS/SSS around the expected PSS position */ - ret = sync_find(&q->strack, q->input_buffer, + ret = srslte_sync_find(&q->strack, q->input_buffer, q->frame_len - q->sf_len/2 - q->fft_size - q->strack.frame_size/2, &track_idx); if (ret < 0) { @@ -431,7 +431,7 @@ int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) { #ifdef MEASURE_EXEC_TIME gettimeofday(&t[2], NULL); get_time_interval(t); - q->mean_exec_time = (float) VEC_CMA((float) t[0].tv_usec, q->mean_exec_time, q->frame_total_cnt); + q->mean_exec_time = (float) SRSLTE_VEC_CMA((float) t[0].tv_usec, q->mean_exec_time, q->frame_total_cnt); #endif if (ret == 1) { @@ -450,10 +450,10 @@ int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) { /* Do CFO Correction if not done in track and deliver the frame */ if (!q->strack.correct_cfo) { - cfo_correct(&q->sfind.cfocorr, + srslte_cfo_correct(&q->sfind.cfocorr, q->input_buffer, q->input_buffer, - -sync_get_cfo(&q->strack) / q->fft_size); + -srslte_sync_get_cfo(&q->strack) / q->fft_size); } /* @@ -473,10 +473,10 @@ int ue_sync_get_buffer(ue_sync_t *q, cf_t **sf_symbols) { return ret; } -void ue_sync_reset(ue_sync_t *q) { +void srslte_ue_sync_reset(srslte_ue_sync_t *q) { if (!q->file_mode) { - sync_reset(&q->strack); + srslte_sync_reset(&q->strack); } else { q->sf_idx = 9; } diff --git a/srslte/lib/ue/src/ue_ul.c b/srslte/lib/ue/src/ue_ul.c index ac6121c70..ed166c2f7 100644 --- a/srslte/lib/ue/src/ue_ul.c +++ b/srslte/lib/ue/src/ue_ul.c @@ -38,7 +38,7 @@ #define CURRENT_SFLEN_RE SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp) -int ue_ul_init(ue_ul_t *q, +int srslte_ue_ul_init(srslte_ue_ul_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; @@ -48,30 +48,30 @@ int ue_ul_init(ue_ul_t *q, { ret = SRSLTE_ERROR; - bzero(q, sizeof(ue_ul_t)); + bzero(q, sizeof(srslte_ue_ul_t)); q->cell = cell; - if (lte_ifft_init(&q->fft, q->cell.cp, q->cell.nof_prb)) { + if (srslte_ofdm_rx_init(&q->fft, q->cell.cp, q->cell.nof_prb)) { fprintf(stderr, "Error initiating FFT\n"); goto clean_exit; } - srslte_fft_set_freq_shift(&q->fft, 0.5); - srslte_fft_set_normalize(&q->fft, true); + srslte_ofdm_set_freq_shift(&q->fft, 0.5); + srslte_ofdm_set_normalize(&q->fft, true); q->normalize_en = true; - if (cfo_init(&q->cfo, CURRENT_SFLEN)) { + if (srslte_cfo_init(&q->cfo, CURRENT_SFLEN)) { fprintf(stderr, "Error creating CFO object\n"); goto clean_exit; } - if (pusch_init(&q->pusch, q->cell)) { + if (srslte_pusch_init(&q->pusch, q->cell)) { fprintf(stderr, "Error creating PUSCH object\n"); goto clean_exit; } - for (uint32_t i=0;iharq_process[i], q->cell)) { + for (uint32_t i=0;iharq_process[i], q->cell)) { fprintf(stderr, "Error initiating HARQ process\n"); goto clean_exit; } @@ -80,12 +80,12 @@ int ue_ul_init(ue_ul_t *q, fprintf(stderr, "Error initiating srslte_refsignal_ul\n"); goto clean_exit; } - q->sf_symbols = vec_malloc(CURRENT_SFLEN_RE * sizeof(cf_t)); + q->sf_symbols = srslte_vec_malloc(CURRENT_SFLEN_RE * sizeof(cf_t)); if (!q->sf_symbols) { perror("malloc"); goto clean_exit; } - q->refsignal = vec_malloc(2 * SRSLTE_NRE * q->cell.nof_prb * sizeof(cf_t)); + q->refsignal = srslte_vec_malloc(2 * SRSLTE_NRE * q->cell.nof_prb * sizeof(cf_t)); if (!q->refsignal) { perror("malloc"); goto clean_exit; @@ -99,19 +99,19 @@ int ue_ul_init(ue_ul_t *q, clean_exit: if (ret == SRSLTE_ERROR) { - ue_ul_free(q); + srslte_ue_ul_free(q); } return ret; } -void ue_ul_free(ue_ul_t *q) { +void srslte_ue_ul_free(srslte_ue_ul_t *q) { if (q) { - srslte_fft_free(&q->fft); - pusch_free(&q->pusch); - for (uint32_t i=0;iharq_process[i]); + srslte_ofdm_tx_free(&q->fft); + srslte_pusch_free(&q->pusch); + for (uint32_t i=0;iharq_process[i]); } - cfo_free(&q->cfo); + srslte_cfo_free(&q->cfo); srslte_refsignal_ul_free(&q->drms); if (q->sf_symbols) { @@ -120,58 +120,58 @@ void ue_ul_free(ue_ul_t *q) { if (q->refsignal) { free(q->refsignal); } - bzero(q, sizeof(ue_ul_t)); + bzero(q, sizeof(srslte_ue_ul_t)); } } -void ue_ul_set_cfo(ue_ul_t *q, float cur_cfo) { +void srslte_ue_ul_set_cfo(srslte_ue_ul_t *q, float cur_cfo) { q->current_cfo = cur_cfo; } -void ue_ul_set_normalization(ue_ul_t *q, bool enabled) +void srslte_ue_ul_set_normalization(srslte_ue_ul_t *q, bool enabled) { q->normalize_en = enabled; } /* Precalculate the PDSCH scramble sequences for a given RNTI. This function takes a while * to execute, so shall be called once the final C-RNTI has been allocated for the session. - * For the connection procedure, use pusch_encode_rnti() or pusch_decode_rnti() functions + * For the connection procedure, use srslte_pusch_encode_rnti() or srslte_pusch_decode_rnti() functions */ -void ue_ul_set_rnti(ue_ul_t *q, uint16_t rnti) { +void srslte_ue_ul_set_rnti(srslte_ue_ul_t *q, uint16_t rnti) { q->current_rnti = rnti; - pusch_set_rnti(&q->pusch, rnti); + srslte_pusch_set_rnti(&q->pusch, rnti); } -void ue_ul_reset(ue_ul_t *q) { - harq_reset(&q->harq_process[0]); +void srslte_ue_ul_reset(srslte_ue_ul_t *q) { + srslte_harq_reset(&q->harq_process[0]); } -void ue_ul_set_pusch_cfg(ue_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *pusch_drms_cfg, pusch_hopping_cfg_t *pusch_hopping_cfg) +void srslte_ue_ul_set_pusch_cfg(srslte_ue_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *drms_cfg, srslte_pusch_hopping_cfg_t *pusch_hopping_cfg) { - memcpy(&q->pusch_drms_cfg, pusch_drms_cfg, sizeof(srslte_refsignal_drms_pusch_cfg_t)); - pusch_set_hopping_cfg(&q->pusch, pusch_hopping_cfg); + memcpy(&q->drms_cfg, drms_cfg, sizeof(srslte_refsignal_drms_pusch_cfg_t)); + srslte_pusch_set_hopping_cfg(&q->pusch, pusch_hopping_cfg); } -int ue_ul_pusch_encode(ue_ul_t *q, ra_pusch_t *ra_ul, uint8_t *data, uint32_t sf_idx, cf_t *output_signal) +int srslte_ue_ul_srslte_pusch_encode(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, uint32_t sf_idx, cf_t *output_signal) { - uci_data_t uci_data; - bzero(&uci_data, sizeof(uci_data_t)); - return ue_ul_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, q->current_rnti, output_signal); + srslte_uci_data_t uci_data; + bzero(&uci_data, sizeof(srslte_uci_data_t)); + return srslte_ue_ul_srslte_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, q->current_rnti, output_signal); } -int ue_ul_pusch_encode_rnti(ue_ul_t *q, ra_pusch_t *ra_ul, uint8_t *data, uint32_t sf_idx, uint16_t rnti, cf_t *output_signal) +int srslte_ue_ul_srslte_pusch_encode_rnti(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, uint32_t sf_idx, uint16_t rnti, cf_t *output_signal) { - uci_data_t uci_data; - bzero(&uci_data, sizeof(uci_data_t)); - return ue_ul_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, rnti, output_signal); + srslte_uci_data_t uci_data; + bzero(&uci_data, sizeof(srslte_uci_data_t)); + return srslte_ue_ul_srslte_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, rnti, output_signal); } -int ue_ul_pusch_uci_encode(ue_ul_t *q, ra_pusch_t *ra_ul, uint8_t *data, uci_data_t uci_data, uint32_t sf_idx, cf_t *output_signal) +int srslte_ue_ul_srslte_pusch_uci_encode(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, srslte_uci_data_t uci_data, uint32_t sf_idx, cf_t *output_signal) { - return ue_ul_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, q->current_rnti, output_signal); + return srslte_ue_ul_srslte_pusch_uci_encode_rnti(q, ra_ul, data, uci_data, sf_idx, q->current_rnti, output_signal); } -int ue_ul_pusch_uci_encode_rnti(ue_ul_t *q, ra_pusch_t *ra_ul, uint8_t *data, uci_data_t uci_data, +int srslte_ue_ul_srslte_pusch_uci_encode_rnti(srslte_ue_ul_t *q, srslte_ra_pusch_t *ra_ul, uint8_t *data, srslte_uci_data_t uci_data, uint32_t sf_idx, uint16_t rnti, cf_t *output_signal) { @@ -190,35 +190,35 @@ int ue_ul_pusch_uci_encode_rnti(ue_ul_t *q, ra_pusch_t *ra_ul, uint8_t *data, uc ret = SRSLTE_ERROR; - if (harq_setup_ul(&q->harq_process[0], ra_ul->mcs, ra_ul->rv_idx, sf_idx, &ra_ul->prb_alloc)) { + if (srslte_harq_setup_ul(&q->harq_process[0], ra_ul->mcs, ra_ul->rv_idx, sf_idx, &ra_ul->prb_alloc)) { fprintf(stderr, "Error configuring HARQ process\n"); return ret; } printf("sf_idx: %d, rnti: %d\n", sf_idx, rnti); - if (pusch_encode_rnti(&q->pusch, &q->harq_process[0], data, rnti, q->sf_symbols)) { + if (srslte_pusch_encode_rnti(&q->pusch, &q->harq_process[0], data, rnti, q->sf_symbols)) { fprintf(stderr, "Error encoding TB\n"); return ret; } // FIXME: Pregenerate for all possible number of prb - if (srslte_refsignal_dmrs_pusch_gen(&q->drms, &q->pusch_drms_cfg, + if (srslte_refsignal_dmrs_gen(&q->drms, &q->drms_cfg, q->harq_process[0].ul_alloc.L_prb, sf_idx, q->refsignal)) { fprintf(stderr, "Error generating PUSCH DRMS signals\n"); return ret; } - srslte_refsignal_drms_pusch_put(&q->drms, &q->pusch_drms_cfg, q->refsignal, + srslte_refsignal_drms_pusch_put(&q->drms, &q->drms_cfg, q->refsignal, q->harq_process[0].ul_alloc.L_prb, q->harq_process[0].ul_alloc.n_prb_tilde, q->sf_symbols); - lte_ifft_run_sf(&q->fft, q->sf_symbols, output_signal); + srslte_ofdm_rx_sf(&q->fft, q->sf_symbols, output_signal); - //cfo_correct(&q->cfo, output_signal, output_signal, q->current_cfo / srslte_symbol_sz(q->cell.nof_prb)); + //srslte_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, SRSLTE_SF_LEN_PRB(q->cell.nof_prb)); + srslte_vec_sc_prod_cfc(output_signal, norm_factor, output_signal, SRSLTE_SF_LEN_PRB(q->cell.nof_prb)); } ret = SRSLTE_SUCCESS; diff --git a/srslte/lib/utils/src/bit.c b/srslte/lib/utils/src/bit.c index 63593338f..194585054 100644 --- a/srslte/lib/utils/src/bit.c +++ b/srslte/lib/utils/src/bit.c @@ -31,19 +31,19 @@ #include "srslte/utils/bit.h" -void bit_pack_vector(uint8_t *bits_unpacked, uint8_t *bits_packed, int nof_bits) +void srslte_bit_pack_vector(uint8_t *bits_unpacked, uint8_t *bits_packed, int nof_bits) { uint32_t i, nbytes; nbytes = nof_bits/8; for (i=0;isize = size; @@ -48,14 +48,14 @@ int cexptab_init(cexptab_t *h, uint32_t size) { } } -void cexptab_free(cexptab_t *h) { +void srslte_cexptab_free(srslte_cexptab_t *h) { if (h->tab) { free(h->tab); } - bzero(h, sizeof(cexptab_t)); + bzero(h, sizeof(srslte_cexptab_t)); } -void cexptab_gen(cexptab_t *h, cf_t *x, float freq, uint32_t len) { +void srslte_cexptab_gen(srslte_cexptab_t *h, cf_t *x, float freq, uint32_t len) { uint32_t i; uint32_t idx; float phase_inc = freq * h->size; @@ -75,7 +75,7 @@ void cexptab_gen(cexptab_t *h, cf_t *x, float freq, uint32_t len) { } } -void cexptab_gen_direct(cf_t *x, float freq, uint32_t len) { +void srslte_cexptab_gen_direct(cf_t *x, float freq, uint32_t len) { uint32_t i; for (i = 0; i < len; i++) { x[i] = cexpf(_Complex_I * 2 * M_PI * freq * i); diff --git a/srslte/lib/utils/src/convolution.c b/srslte/lib/utils/src/convolution.c index 61d100a01..af6ee9fb3 100644 --- a/srslte/lib/utils/src/convolution.c +++ b/srslte/lib/utils/src/convolution.c @@ -29,37 +29,37 @@ #include #include -#include "srslte/utils/dft.h" +#include "srslte/dft/dft.h" #include "srslte/utils/vector.h" #include "srslte/utils/convolution.h" -int conv_fft_cc_init(conv_fft_cc_t *q, uint32_t input_len, uint32_t filter_len) { +int srslte_conv_fft_cc_init(srslte_conv_fft_cc_t *q, uint32_t input_len, uint32_t filter_len) { q->input_len = input_len; q->filter_len = filter_len; q->output_len = input_len+filter_len; - q->input_fft = vec_malloc(sizeof(cf_t)*q->output_len); - q->filter_fft = vec_malloc(sizeof(cf_t)*q->output_len); - q->output_fft = vec_malloc(sizeof(cf_t)*q->output_len); + q->input_fft = srslte_vec_malloc(sizeof(cf_t)*q->output_len); + q->filter_fft = srslte_vec_malloc(sizeof(cf_t)*q->output_len); + q->output_fft = srslte_vec_malloc(sizeof(cf_t)*q->output_len); if (!q->input_fft || !q->filter_fft || !q->output_fft) { return SRSLTE_ERROR; } - if (dft_plan(&q->input_plan,q->output_len,FORWARD,COMPLEX)) { + if (srslte_dft_plan(&q->input_plan,q->output_len,SRSLTE_DFT_FORWARD,SRSLTE_DFT_COMPLEX)) { return SRSLTE_ERROR; } - if (dft_plan(&q->filter_plan,q->output_len,FORWARD,COMPLEX)) { + if (srslte_dft_plan(&q->filter_plan,q->output_len,SRSLTE_DFT_FORWARD,SRSLTE_DFT_COMPLEX)) { return SRSLTE_ERROR; } - if (dft_plan(&q->output_plan,q->output_len,BACKWARD,COMPLEX)) { + if (srslte_dft_plan(&q->output_plan,q->output_len,SRSLTE_DFT_BACKWARD,SRSLTE_DFT_COMPLEX)) { return SRSLTE_ERROR; } - dft_plan_set_norm(&q->input_plan, true); - dft_plan_set_norm(&q->filter_plan, true); - dft_plan_set_norm(&q->output_plan, false); + srslte_dft_plan_set_norm(&q->input_plan, true); + srslte_dft_plan_set_norm(&q->filter_plan, true); + srslte_dft_plan_set_norm(&q->output_plan, false); return SRSLTE_SUCCESS; } -void conv_fft_cc_free(conv_fft_cc_t *q) { +void srslte_conv_fft_cc_free(srslte_conv_fft_cc_t *q) { if (q->input_fft) { free(q->input_fft); } @@ -69,37 +69,37 @@ void conv_fft_cc_free(conv_fft_cc_t *q) { if (q->output_fft) { free(q->output_fft); } - dft_plan_free(&q->input_plan); - dft_plan_free(&q->filter_plan); - dft_plan_free(&q->output_plan); + srslte_dft_plan_free(&q->input_plan); + srslte_dft_plan_free(&q->filter_plan); + srslte_dft_plan_free(&q->output_plan); - bzero(q, sizeof(conv_fft_cc_t)); + bzero(q, sizeof(srslte_conv_fft_cc_t)); } -uint32_t conv_fft_cc_run(conv_fft_cc_t *q, cf_t *input, cf_t *filter, cf_t *output) { +uint32_t srslte_conv_fft_cc_run(srslte_conv_fft_cc_t *q, cf_t *input, cf_t *filter, cf_t *output) { - dft_run_c(&q->input_plan, input, q->input_fft); - dft_run_c(&q->filter_plan, filter, q->filter_fft); + srslte_dft_run_c(&q->input_plan, input, q->input_fft); + srslte_dft_run_c(&q->filter_plan, filter, q->filter_fft); - vec_prod_ccc(q->input_fft,q->filter_fft,q->output_fft,q->output_len); + srslte_vec_prod_ccc(q->input_fft,q->filter_fft,q->output_fft,q->output_len); - dft_run_c(&q->output_plan, q->output_fft, output); + srslte_dft_run_c(&q->output_plan, q->output_fft, output); return q->output_len-1; } -uint32_t conv_cc(cf_t *input, cf_t *filter, cf_t *output, uint32_t input_len, uint32_t filter_len) { +uint32_t srslte_conv_cc(cf_t *input, cf_t *filter, cf_t *output, uint32_t input_len, uint32_t filter_len) { uint32_t i; uint32_t M = filter_len; uint32_t N = input_len; for (i=0;i -#include -#include -#include - -#include "srslte/utils/matrix.h" - -int matrix_init(void ***q, int sz_x, int sz_y, int elem_sz) { - int i; - int ret = -1; - *q = malloc(sizeof(void*) * sz_x); - if (!*q) { - goto free_and_exit; - } - for (i=0;i -#include - -/** - * Multiplexes a signal from nof_inputs interfaces. - * Copies output_lengths[i] samples to the i-th interfaces, ignores output_padding_pre[i] samples - * from the beginning each input interface. - */ -void mux(void **input, void *output, int *input_lengths, int *input_padding_pre, int nof_inputs, - int sample_sz) { - int i,r; - uint8_t *out = (uint8_t*) output; - uint8_t **in = (uint8_t**) input; - - r=0; - for (i=0;i> (nof_bits-i-1)) & 0x1; - } - *bits += nof_bits; -} - -uint32_t unpack_bits(uint8_t **bits, int nof_bits) -{ - int i; - uint32_t value=0; - - for(i=0; i #include -#include "srslte/utils/dft.h" +#include "srslte/dft/dft.h" typedef _Complex float cf_t; @@ -67,13 +67,13 @@ int test_dft(cf_t* in){ srslte_dft_plan_t plan; if(forward){ - dft_plan(&plan, N, FORWARD, COMPLEX); + srslte_dft_plan(&plan, N, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX); } else { - dft_plan(&plan, N, BACKWARD, COMPLEX); + srslte_dft_plan(&plan, N, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX); } - dft_plan_set_mirror(&plan, mirror); - dft_plan_set_norm(&plan, norm); - dft_plan_set_dc(&plan, dc); + srslte_dft_plan_set_mirror(&plan, mirror); + srslte_dft_plan_set_norm(&plan, norm); + srslte_dft_plan_set_dc(&plan, dc); cf_t* out1 = malloc(sizeof(cf_t)*N); cf_t* out2 = malloc(sizeof(cf_t)*N); @@ -81,20 +81,20 @@ int test_dft(cf_t* in){ bzero(out2, sizeof(cf_t)*N); print(in, N); - dft_run(&plan, in, out1); + srslte_dft_run(&plan, in, out1); print(out1, N); srslte_dft_plan_t plan_rev; if(!forward){ - dft_plan(&plan_rev, N, FORWARD, COMPLEX); + srslte_dft_plan(&plan_rev, N, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX); } else { - dft_plan(&plan_rev, N, BACKWARD, COMPLEX); + srslte_dft_plan(&plan_rev, N, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX); } - dft_plan_set_mirror(&plan_rev, mirror); - dft_plan_set_norm(&plan_rev, norm); - dft_plan_set_dc(&plan_rev, dc); + srslte_dft_plan_set_mirror(&plan_rev, mirror); + srslte_dft_plan_set_norm(&plan_rev, norm); + srslte_dft_plan_set_dc(&plan_rev, dc); - dft_run(&plan_rev, out1, out2); + srslte_dft_run(&plan_rev, out1, out2); print(out2, N); if(!norm){ @@ -109,8 +109,8 @@ int test_dft(cf_t* in){ res = -1; } - dft_plan_free(&plan); - dft_plan_free(&plan_rev); + srslte_dft_plan_free(&plan); + srslte_dft_plan_free(&plan_rev); free(out1); free(out2);