Changed phy_common.h

master
ismagom 10 years ago
parent 8605b6d24c
commit 7eecf5be3b

@ -83,9 +83,9 @@ int mexutils_read_cell(const mxArray *ptr, srslte_cell_t *cell) {
return -1; return -1;
} }
// TODO // TODO
cell->cp = CPNORM; cell->cp = SRSLTE_SRSLTE_CP_NORM;
cell->phich_length = PHICH_NORM; cell->phich_length = SRSLTE_PHICH_NORM;
cell->phich_resources = R_1_6; cell->phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_6;
return 0; return 0;
} }

@ -178,7 +178,7 @@ int main(int argc, char **argv) {
} }
/* set sampling frequency */ /* set sampling frequency */
int srate = lte_sampling_freq_hz(cell.nof_prb); int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) { if (srate != -1) {
cuhd_set_rx_srate(uhd, (double) srate); cuhd_set_rx_srate(uhd, (double) srate);
} else { } else {
@ -204,7 +204,7 @@ int main(int argc, char **argv) {
} }
/* Configure downlink receiver for the SI-RNTI since will be the only one we'll use */ /* Configure downlink receiver for the SI-RNTI since will be the only one we'll use */
ue_dl_set_rnti(&ue_dl, SIRNTI); ue_dl_set_rnti(&ue_dl, SRSLTE_SIRNTI);
/* Initialize subframe counter */ /* Initialize subframe counter */
sf_cnt = 0; sf_cnt = 0;
@ -218,7 +218,7 @@ int main(int argc, char **argv) {
return -1; return -1;
} }
int sf_re = SF_LEN_RE(cell.nof_prb, cell.cp); int sf_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp);
cf_t *sf_symbols = vec_malloc(sf_re * sizeof(cf_t)); cf_t *sf_symbols = vec_malloc(sf_re * sizeof(cf_t));
@ -259,7 +259,7 @@ int main(int argc, char **argv) {
case DECODE_SIB: case DECODE_SIB:
/* We are looking for SI Blocks, search only in appropiate places */ /* We are looking for SI Blocks, search only in appropiate places */
if ((ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) { if ((ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) {
n = ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data, ue_sync_get_sfidx(&ue_sync), SIRNTI, n = ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data, ue_sync_get_sfidx(&ue_sync), SRSLTE_SIRNTI,
((int) ceilf((float)3*(((sfn)/2)%4)/2))%4); ((int) ceilf((float)3*(((sfn)/2)%4)/2))%4);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error decoding UE DL\n");fflush(stdout); fprintf(stderr, "Error decoding UE DL\n");fflush(stdout);
@ -293,7 +293,7 @@ int main(int argc, char **argv) {
srslte_chest_dl_estimate(&chest, sf_symbols, ce, ue_sync_get_sfidx(&ue_sync)); srslte_chest_dl_estimate(&chest, sf_symbols, ce, ue_sync_get_sfidx(&ue_sync));
rssi = VEC_CMA(vec_avg_power_cf(sf_buffer,SF_LEN(lte_symbol_sz(cell.nof_prb))),rssi,nframes); rssi = VEC_CMA(vec_avg_power_cf(sf_buffer,SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb))),rssi,nframes);
rssi_utra = VEC_CMA(srslte_chest_dl_get_rssi(&chest),rssi_utra,nframes); rssi_utra = VEC_CMA(srslte_chest_dl_get_rssi(&chest),rssi_utra,nframes);
rsrq = VEC_EMA(srslte_chest_dl_get_rsrq(&chest),rsrq,0.05); rsrq = VEC_EMA(srslte_chest_dl_get_rsrq(&chest),rsrq,0.05);
rsrp = VEC_EMA(srslte_chest_dl_get_rsrp(&chest),rsrp,0.05); rsrp = VEC_EMA(srslte_chest_dl_get_rsrp(&chest),rsrp,0.05);

@ -122,7 +122,7 @@ int main(int argc, char **argv) {
ue_cell_search_t cs; ue_cell_search_t cs;
ue_cell_search_result_t found_cells[3]; ue_cell_search_result_t found_cells[3];
int nof_freqs; int nof_freqs;
lte_earfcn_t channels[MAX_EARFCN]; srslte_earfcn_t channels[MAX_EARFCN];
uint32_t freq; uint32_t freq;
parse_args(argc, argv); parse_args(argc, argv);
@ -134,7 +134,7 @@ int main(int argc, char **argv) {
} }
cuhd_set_rx_gain(uhd, uhd_gain); cuhd_set_rx_gain(uhd, uhd_gain);
nof_freqs = lte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN); nof_freqs = srslte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN);
if (nof_freqs < 0) { if (nof_freqs < 0) {
fprintf(stderr, "Error getting EARFCN list\n"); fprintf(stderr, "Error getting EARFCN list\n");
exit(-1); exit(-1);

@ -61,7 +61,7 @@ int cuhd_mib_decoder(void *uhd, uint32_t max_nof_frames, srslte_cell_t *cell) {
goto clean_exit; goto clean_exit;
} }
int srate = lte_sampling_freq_hz(MIB_NOF_PRB); int srate = srslte_sampling_freq_hz(MIB_NOF_PRB);
INFO("Setting sampling frequency %.2f MHz for PSS search\n", (float) srate/1000000); INFO("Setting sampling frequency %.2f MHz for PSS search\n", (float) srate/1000000);
cuhd_set_rx_srate(uhd, (float) srate); cuhd_set_rx_srate(uhd, (float) srate);

@ -53,9 +53,9 @@ srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
1, // nof_ports 1, // nof_ports
1, // cell_id 1, // cell_id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1, // PHICH resources SRSLTE_PHICH_R_1, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
int net_port = -1; // -1 generates random data int net_port = -1; // -1 generates random data
@ -216,7 +216,7 @@ void base_init() {
} }
/* create ifft object */ /* create ifft object */
if (lte_ifft_init(&ifft, CPNORM, cell.nof_prb)) { if (lte_ifft_init(&ifft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb)) {
fprintf(stderr, "Error creating iFFT object\n"); fprintf(stderr, "Error creating iFFT object\n");
exit(-1); exit(-1);
} }
@ -325,7 +325,7 @@ int update_radl(uint32_t sf_idx) {
ra_dl.type0_alloc.rbg_bitmask = prbset_to_bitmask(); ra_dl.type0_alloc.rbg_bitmask = prbset_to_bitmask();
ra_dl_alloc(&prb_alloc, &ra_dl, cell.nof_prb); ra_dl_alloc(&prb_alloc, &ra_dl, cell.nof_prb);
ra_dl_alloc_re(&prb_alloc, cell.nof_prb, 1, cell.nof_prb<10?(cfi+1):cfi, CPNORM); ra_dl_alloc_re(&prb_alloc, cell.nof_prb, 1, cell.nof_prb<10?(cfi+1):cfi, SRSLTE_SRSLTE_CP_NORM);
ra_mcs_from_idx_dl(mcs_idx, prb_alloc.slot[0].nof_prb, &ra_dl.mcs); ra_mcs_from_idx_dl(mcs_idx, prb_alloc.slot[0].nof_prb, &ra_dl.mcs);
ra_pdsch_fprint(stdout, &ra_dl, cell.nof_prb); ra_pdsch_fprint(stdout, &ra_dl, cell.nof_prb);
@ -461,11 +461,11 @@ int main(int argc, char **argv) {
parse_args(argc, argv); parse_args(argc, argv);
N_id_2 = cell.id % 3; N_id_2 = cell.id % 3;
sf_n_re = 2 * SRSLTE_CPNORM_NSYMB * cell.nof_prb * RE_X_RB; sf_n_re = 2 * SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE;
sf_n_samples = 2 * SLOT_LEN(lte_symbol_sz(cell.nof_prb)); sf_n_samples = 2 * SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb));
cell.phich_length = PHICH_NORM; cell.phich_length = SRSLTE_PHICH_NORM;
cell.phich_resources = R_1; cell.phich_resources = SRSLTE_PHICH_R_1;
sfn = 0; sfn = 0;
prbset_num = (int) ceilf((float) cell.nof_prb / ra_type0_P(cell.nof_prb)); prbset_num = (int) ceilf((float) cell.nof_prb / ra_type0_P(cell.nof_prb));
@ -486,13 +486,13 @@ int main(int argc, char **argv) {
for (i = 0; i < SRSLTE_MAX_PORTS; i++) { // now there's only 1 port for (i = 0; i < SRSLTE_MAX_PORTS; i++) { // now there's only 1 port
sf_symbols[i] = sf_buffer; sf_symbols[i] = sf_buffer;
slot1_symbols[i] = &sf_buffer[SLOT_LEN_RE(cell.nof_prb, cell.cp)]; slot1_symbols[i] = &sf_buffer[SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)];
} }
#ifndef DISABLE_UHD #ifndef DISABLE_UHD
if (!output_file_name) { if (!output_file_name) {
printf("Set TX rate: %.2f MHz\n", printf("Set TX rate: %.2f MHz\n",
cuhd_set_tx_srate(uhd, lte_sampling_freq_hz(cell.nof_prb)) / 1000000); cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000);
printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain)); printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain));
printf("Set TX freq: %.2f MHz\n", printf("Set TX freq: %.2f MHz\n",
cuhd_set_tx_freq(uhd, uhd_freq) / 1000000); cuhd_set_tx_freq(uhd, uhd_freq) / 1000000);
@ -525,9 +525,9 @@ int main(int argc, char **argv) {
bzero(sf_buffer, sizeof(cf_t) * sf_n_re); bzero(sf_buffer, sizeof(cf_t) * sf_n_re);
if (sf_idx == 0 || sf_idx == 5) { if (sf_idx == 0 || sf_idx == 5) {
pss_put_slot(pss_signal, sf_buffer, cell.nof_prb, CPNORM); pss_put_slot(pss_signal, sf_buffer, cell.nof_prb, SRSLTE_SRSLTE_CP_NORM);
sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, sf_buffer, cell.nof_prb, sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, sf_buffer, cell.nof_prb,
CPNORM); SRSLTE_SRSLTE_CP_NORM);
} }
srslte_refsignal_cs_put_sf(cell, 0, est.csr_signal.pilots[0][sf_idx], sf_buffer); srslte_refsignal_cs_put_sf(cell, 0, est.csr_signal.pilots[0][sf_idx], sf_buffer);
@ -591,7 +591,7 @@ int main(int argc, char **argv) {
lte_ifft_run_sf(&ifft, sf_buffer, output_buffer); lte_ifft_run_sf(&ifft, sf_buffer, output_buffer);
float norm_factor = (float) cell.nof_prb/15/sqrtf(ra_dl.prb_alloc.slot[0].nof_prb); float norm_factor = (float) cell.nof_prb/15/sqrtf(ra_dl.prb_alloc.slot[0].nof_prb);
vec_sc_prod_cfc(output_buffer, uhd_amp*norm_factor, output_buffer, SF_LEN_PRB(cell.nof_prb)); vec_sc_prod_cfc(output_buffer, uhd_amp*norm_factor, output_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb));
/* send to file or usrp */ /* send to file or usrp */
if (output_file_name) { if (output_file_name) {

@ -93,7 +93,7 @@ typedef struct {
void args_default(prog_args_t *args) { void args_default(prog_args_t *args) {
args->nof_subframes = -1; args->nof_subframes = -1;
args->rnti = SIRNTI; args->rnti = SRSLTE_SIRNTI;
args->force_N_id_2 = -1; // Pick the best args->force_N_id_2 = -1; // Pick the best
args->input_file_name = NULL; args->input_file_name = NULL;
args->file_nof_prb = 6; args->file_nof_prb = 6;
@ -281,7 +281,7 @@ int main(int argc, char **argv) {
} }
/* set sampling frequency */ /* set sampling frequency */
int srate = lte_sampling_freq_hz(cell.nof_prb); int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) { if (srate != -1) {
cuhd_set_rx_srate(uhd, (double) srate); cuhd_set_rx_srate(uhd, (double) srate);
} else { } else {
@ -305,9 +305,9 @@ int main(int argc, char **argv) {
state = DECODE_PDSCH; state = DECODE_PDSCH;
/* preset cell configuration */ /* preset cell configuration */
cell.id = 1; cell.id = 1;
cell.cp = CPNORM; cell.cp = SRSLTE_SRSLTE_CP_NORM;
cell.phich_length = PHICH_NORM; cell.phich_length = SRSLTE_PHICH_NORM;
cell.phich_resources = R_1; cell.phich_resources = SRSLTE_PHICH_R_1;
cell.nof_ports = 1; cell.nof_ports = 1;
cell.nof_prb = prog_args.file_nof_prb; cell.nof_prb = prog_args.file_nof_prb;
@ -386,7 +386,7 @@ int main(int argc, char **argv) {
} }
break; break;
case DECODE_PDSCH: case DECODE_PDSCH:
if (prog_args.rnti != SIRNTI) { if (prog_args.rnti != SRSLTE_SIRNTI) {
decode_pdsch = true; decode_pdsch = true;
} else { } else {
/* We are looking for SIB1 Blocks, search only in appropiate places */ /* We are looking for SIB1 Blocks, search only in appropiate places */
@ -397,10 +397,10 @@ int main(int argc, char **argv) {
} }
} }
if (decode_pdsch) { if (decode_pdsch) {
if (prog_args.rnti != SIRNTI) { if (prog_args.rnti != SRSLTE_SIRNTI) {
n = ue_dl_decode(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync)); n = ue_dl_decode(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync));
} else { } else {
n = ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync), SIRNTI, n = ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync), SRSLTE_SIRNTI,
((int) ceilf((float)3*(((sfn)/2)%4)/2))%4); ((int) ceilf((float)3*(((sfn)/2)%4)/2))%4);
} }
if (n < 0) { if (n < 0) {
@ -520,13 +520,13 @@ int main(int argc, char **argv) {
plot_real_t p_sync, pce; plot_real_t p_sync, pce;
plot_scatter_t pscatequal, pscatequal_pdcch; plot_scatter_t pscatequal, pscatequal_pdcch;
float tmp_plot[SLOT_LEN_RE(MAX_PRB, CPNORM)]; float tmp_plot[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)];
float tmp_plot2[SLOT_LEN_RE(MAX_PRB, CPNORM)]; float tmp_plot2[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)];
float tmp_plot3[SLOT_LEN_RE(MAX_PRB, CPNORM)]; float tmp_plot3[SRSLTE_SLOT_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_SRSLTE_CP_NORM)];
void *plot_thread_run(void *arg) { void *plot_thread_run(void *arg) {
int i; int i;
uint32_t nof_re = SF_LEN_RE(ue_dl.cell.nof_prb, ue_dl.cell.cp); uint32_t nof_re = SRSLTE_SF_LEN_RE(ue_dl.cell.nof_prb, ue_dl.cell.cp);
while(1) { while(1) {
sem_wait(&plot_sem); sem_wait(&plot_sem);
@ -544,8 +544,8 @@ void *plot_thread_run(void *arg) {
tmp_plot2[i] = -80; tmp_plot2[i] = -80;
} }
} }
//for (i=0;i<CP_NSYMB(ue_dl.cell.cp);i++) { //for (i=0;i<SRSLTE_CP_NSYMB(ue_dl.cell.cp);i++) {
// plot_waterfall_appendNewData(&poutfft, &tmp_plot[i*RE_X_RB*ue_dl.cell.nof_prb], RE_X_RB*ue_dl.cell.nof_prb); // plot_waterfall_appendNewData(&poutfft, &tmp_plot[i*SRSLTE_NRE*ue_dl.cell.nof_prb], SRSLTE_NRE*ue_dl.cell.nof_prb);
//} //}
plot_real_setNewData(&pce, tmp_plot2, SRSLTE_REFSIGNAL_NUM_SF(ue_dl.cell.nof_prb,0)); plot_real_setNewData(&pce, tmp_plot2, SRSLTE_REFSIGNAL_NUM_SF(ue_dl.cell.nof_prb,0));
if (!prog_args.input_file_name) { if (!prog_args.input_file_name) {
@ -577,7 +577,7 @@ void init_plots() {
plot_init(); plot_init();
//plot_waterfall_init(&poutfft, RE_X_RB * ue_dl.cell.nof_prb, 1000); //plot_waterfall_init(&poutfft, SRSLTE_NRE * ue_dl.cell.nof_prb, 1000);
//plot_waterfall_setTitle(&poutfft, "Output FFT - Magnitude"); //plot_waterfall_setTitle(&poutfft, "Output FFT - Magnitude");
//plot_waterfall_setPlotYAxisScale(&poutfft, -40, 40); //plot_waterfall_setPlotYAxisScale(&poutfft, -40, 40);

@ -345,15 +345,15 @@ int main(int argc, char **argv) {
cell.id = 1; cell.id = 1;
cell.nof_ports = 1; cell.nof_ports = 1;
cell.nof_prb = 25; cell.nof_prb = 25;
cell.cp = CPNORM; cell.cp = SRSLTE_SRSLTE_CP_NORM;
cell.phich_length = PHICH_NORM; cell.phich_length = SRSLTE_PHICH_NORM;
cell.phich_resources = R_1; cell.phich_resources = SRSLTE_PHICH_R_1;
#endif #endif
#ifdef use_usrp #ifdef use_usrp
/* set sampling frequency */ /* set sampling frequency */
int srate = lte_sampling_freq_hz(cell.nof_prb); int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) { if (srate != -1) {
cuhd_set_rx_srate(uhd, (double) srate); cuhd_set_rx_srate(uhd, (double) srate);
cuhd_set_tx_srate(uhd, (double) srate); cuhd_set_tx_srate(uhd, (double) srate);
@ -373,7 +373,7 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
if (prach_init(&prach, lte_symbol_sz(cell.nof_prb), 0, 0, false, 1)) { if (prach_init(&prach, srslte_symbol_sz(cell.nof_prb), 0, 0, false, 1)) {
fprintf(stderr, "Error initializing PRACH\n"); fprintf(stderr, "Error initializing PRACH\n");
exit(-1); exit(-1);
} }
@ -406,12 +406,12 @@ int main(int argc, char **argv) {
drms_cfg.en_drms_2 = false; drms_cfg.en_drms_2 = false;
ue_ul_set_pusch_cfg(&ue_ul, &drms_cfg, &hop_cfg); ue_ul_set_pusch_cfg(&ue_ul, &drms_cfg, &hop_cfg);
cf_t *ul_signal = vec_malloc(sizeof(cf_t) * SF_LEN_PRB(cell.nof_prb)); cf_t *ul_signal = vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
if (!ul_signal) { if (!ul_signal) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);
} }
bzero(ul_signal, sizeof(cf_t) * SF_LEN_PRB(cell.nof_prb)); bzero(ul_signal, sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
if (ue_dl_init(&ue_dl, cell)) { if (ue_dl_init(&ue_dl, cell)) {
fprintf(stderr, "Error initiating UE downlink processing module\n"); fprintf(stderr, "Error initiating UE downlink processing module\n");
@ -544,9 +544,9 @@ int main(int argc, char **argv) {
bit_pack_vector((uint8_t*) conn_request_msg, data, ra_pusch.mcs.tbs); bit_pack_vector((uint8_t*) conn_request_msg, data, ra_pusch.mcs.tbs);
uint32_t n_ta = lte_N_ta_new_rar(rar_msg.timing_adv_cmd); 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); printf("ta: %d, n_ta: %d\n", rar_msg.timing_adv_cmd, n_ta);
float time_adv_sec = TA_OFFSET+((float) n_ta)*LTE_TS; float time_adv_sec = SRSLTE_TA_OFFSET+((float) n_ta)*SRSLTE_LTE_TS;
if (prog_args.ta_usec >= 0) { if (prog_args.ta_usec >= 0) {
time_adv_sec = prog_args.ta_usec*1e-6; time_adv_sec = prog_args.ta_usec*1e-6;
} }
@ -562,17 +562,17 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
vec_sc_prod_cfc(ul_signal, prog_args.beta_pusch, ul_signal, SF_LEN_PRB(cell.nof_prb)); vec_sc_prod_cfc(ul_signal, prog_args.beta_pusch, ul_signal, SRSLTE_SF_LEN_PRB(cell.nof_prb));
timestamp_copy(&next_tx_time, &uhd_time); timestamp_copy(&next_tx_time, &uhd_time);
timestamp_add(&next_tx_time, 0, 0.006 + i*0.008 - time_adv_sec); // send after 6 sub-frames (6 ms) timestamp_add(&next_tx_time, 0, 0.006 + i*0.008 - time_adv_sec); // send after 6 sub-frames (6 ms)
printf("Send %d samples PUSCH sfn: %d. RV_idx=%d, Last frame time = %.6f " printf("Send %d samples PUSCH sfn: %d. RV_idx=%d, Last frame time = %.6f "
"send PUSCH time = %.6f TA: %.1f us\n", "send PUSCH time = %.6f TA: %.1f us\n",
SF_LEN_PRB(cell.nof_prb), sfn, ra_pusch.rv_idx, SRSLTE_SF_LEN_PRB(cell.nof_prb), sfn, ra_pusch.rv_idx,
timestamp_real(&uhd_time), timestamp_real(&uhd_time),
timestamp_real(&next_tx_time), time_adv_sec*1000000); timestamp_real(&next_tx_time), time_adv_sec*1000000);
cuhd_send_timed(uhd, ul_signal, SF_LEN_PRB(cell.nof_prb), cuhd_send_timed(uhd, ul_signal, SRSLTE_SF_LEN_PRB(cell.nof_prb),
next_tx_time.full_secs, next_tx_time.frac_secs); next_tx_time.full_secs, next_tx_time.frac_secs);
//cuhd_start_rx_stream(uhd); //cuhd_start_rx_stream(uhd);
@ -611,14 +611,14 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
vec_save_file("pusch_tx", ul_signal, SF_LEN_PRB(cell.nof_prb)*sizeof(cf_t)); vec_save_file("pusch_tx", ul_signal, SRSLTE_SF_LEN_PRB(cell.nof_prb)*sizeof(cf_t));
#ifdef use_usrp #ifdef use_usrp
cuhd_recv_with_time(uhd, dummy, 4, 1, &uhd_time.full_secs, &uhd_time.frac_secs); cuhd_recv_with_time(uhd, dummy, 4, 1, &uhd_time.full_secs, &uhd_time.frac_secs);
timestamp_copy(&next_tx_time, &uhd_time); timestamp_copy(&next_tx_time, &uhd_time);
while(1) { while(1) {
timestamp_add(&next_tx_time, 0, 0.002); // send every 2 ms timestamp_add(&next_tx_time, 0, 0.002); // send every 2 ms
cuhd_send_timed(uhd, ul_signal, SF_LEN_PRB(cell.nof_prb), cuhd_send_timed(uhd, ul_signal, SRSLTE_SF_LEN_PRB(cell.nof_prb),
next_tx_time.full_secs, next_tx_time.frac_secs); next_tx_time.full_secs, next_tx_time.frac_secs);
} }
#else #else
@ -631,7 +631,7 @@ int main(int argc, char **argv) {
case RECV_CONNSETUP: case RECV_CONNSETUP:
if (ue_sync_get_sfidx(&ue_sync) == (ul_sf_idx+4)%10) { if (ue_sync_get_sfidx(&ue_sync) == (ul_sf_idx+4)%10) {
//verbose=VERBOSE_DEBUG; //verbose=VERBOSE_DEBUG;
vec_save_file("connsetup",sf_buffer,SF_LEN_PRB(cell.nof_prb)*sizeof(cf_t)); vec_save_file("connsetup",sf_buffer,SRSLTE_SF_LEN_PRB(cell.nof_prb)*sizeof(cf_t));
} else { } else {
//verbose=VERBOSE_NONE; //verbose=VERBOSE_NONE;
} }

@ -219,7 +219,7 @@ int main(int argc, char **argv) {
/* If peak detected */ /* If peak detected */
if (peak_value[N_id_2] > corr_peak_threshold) { if (peak_value[N_id_2] > corr_peak_threshold) {
sss_idx = peak_pos[N_id_2]-2*(symbol_sz+CP(symbol_sz,CPNORM_LEN)); sss_idx = peak_pos[N_id_2]-2*(symbol_sz+SRSLTE_CP(symbol_sz,SRSLTE_SRSLTE_CP_NORM_LEN));
if (sss_idx >= 0) { if (sss_idx >= 0) {
sss_synch_m0m1_diff(&sss[N_id_2], &input[sss_idx], sss_synch_m0m1_diff(&sss[N_id_2], &input[sss_idx],
&m0, &m0_value, &m1, &m1_value); &m0, &m0_value, &m1, &m1_value);

@ -61,7 +61,7 @@ typedef struct SRSLTE_API {
/** Uplink DeModulation Reference Signal (DMRS) */ /** Uplink DeModulation Reference Signal (DMRS) */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_cell_t cell; srslte_cell_t cell;
uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NSYMB]; uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB];
float *tmp_arg; float *tmp_arg;
uint32_t n_prs_pusch[SRSLTE_NOF_DELTA_SS][SRSLTE_NSLOTS_X_FRAME]; // We precompute n_prs needed for cyclic shift alpha at srslte_refsignal_dl_init() uint32_t n_prs_pusch[SRSLTE_NOF_DELTA_SS][SRSLTE_NSLOTS_X_FRAME]; // We precompute n_prs needed for cyclic shift alpha at srslte_refsignal_dl_init()
uint32_t f_gh[SRSLTE_NSLOTS_X_FRAME]; uint32_t f_gh[SRSLTE_NSLOTS_X_FRAME];

@ -39,92 +39,102 @@
#define SRSLTE_NSUBFRAMES_X_FRAME 10 #define SRSLTE_NSUBFRAMES_X_FRAME 10
#define SRSLTE_NSLOTS_X_FRAME (2*SRSLTE_NSUBFRAMES_X_FRAME) #define SRSLTE_NSLOTS_X_FRAME (2*SRSLTE_NSUBFRAMES_X_FRAME)
#define LTE_NSOFT_BITS 250368 // Soft buffer size for Category 1 UE #define SRSLTE_NSOFT_BITS 250368 // Soft buffer size for Category 1 UE
#define SRSLTE_MAX_PORTS 4 #define SRSLTE_MAX_PORTS 4
#define MAX_LAYERS 8 #define SRSLTE_MAX_LAYERS 8
#define MAX_CODEWORDS 2 #define SRSLTE_MAX_CODEWORDS 2
#define LTE_CRC24A 0x1864CFB #define SRSLTE_LTE_CRC24A 0x1864CFB
#define LTE_CRC24B 0X1800063 #define SRSLTE_LTE_CRC24B 0X1800063
#define LTE_CRC16 0x11021 #define SRSLTE_LTE_CRC16 0x11021
#define LTE_CRC8 0x19B #define SRSLTE_LTE_CRC8 0x19B
typedef enum {CPNORM, CPEXT} srslte_cp_t; typedef enum {SRSLTE_SRSLTE_CP_NORM, SRSLTE_SRSLTE_CP_EXT} srslte_cp_t;
#define CRNTI_START 0x003D #define SRSLTE_CRNTI_START 0x003D
#define CRNTI_END 0xFFF3 #define SRSLTE_CRNTI_END 0xFFF3
#define RARNTI_START 0x0001 #define SRSLTE_RARNTI_START 0x0001
#define RARNTI_END 0x003C #define SRSLTE_RARNTI_END 0x003C
#define SIRNTI 0xFFFF #define SRSLTE_SIRNTI 0xFFFF
#define PRNTI 0xFFFE #define SRSLTE_PRNTI 0xFFFE
#define MRNTI 0xFFFD #define SRSLTE_MRNTI 0xFFFD
#define CELL_ID_UNKNOWN 1000 #define SRSLTE_CELL_ID_UNKNOWN 1000
#define MAX_NSYMB 7 #define SRSLTE_MAX_NSYMB 7
#define MAX_PRB 110 #define SRSLTE_MAX_PRB 110
#define RE_X_RB 12 #define SRSLTE_NRE 12
#define SYMBOL_SZ_MAX 2048 #define SRSLTE_SYMBOL_SZ_MAX 2048
#define SRSLTE_CPNORM_NSYMB 7 #define SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB 7
#define CPNORM_SF_NSYMB (2*SRSLTE_CPNORM_NSYMB) #define SRSLTE_SRSLTE_CP_NORM_SF_NSYMB (2*SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB)
#define CPNORM_0_LEN 160 #define SRSLTE_SRSLTE_CP_NORM_0_LEN 160
#define CPNORM_LEN 144 #define SRSLTE_SRSLTE_CP_NORM_LEN 144
#define CPEXT_NSYMB 6 #define SRSLTE_SRSLTE_CP_EXT_NSYMB 6
#define CPEXT_SF_NSYMB (2*CPEXT_NSYMB) #define SRSLTE_SRSLTE_CP_EXT_SF_NSYMB (2*SRSLTE_SRSLTE_CP_EXT_NSYMB)
#define CPEXT_LEN 512 #define SRSLTE_SRSLTE_CP_EXT_LEN 512
#define CPEXT_7_5_LEN 1024 #define SRSLTE_SRSLTE_CP_EXT_7_5_LEN 1024
#define CP_ISNORM(cp) (cp==CPNORM) #define SRSLTE_CP_ISNORM(cp) (cp==SRSLTE_SRSLTE_CP_NORM)
#define CP_ISEXT(cp) (cp==CPEXT) #define SRSLTE_CP_ISEXT(cp) (cp==SRSLTE_SRSLTE_CP_EXT)
#define CP_NSYMB(cp) (CP_ISNORM(cp)?SRSLTE_CPNORM_NSYMB:CPEXT_NSYMB) #define SRSLTE_CP_NSYMB(cp) (SRSLTE_CP_ISNORM(cp)?SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB:SRSLTE_SRSLTE_CP_EXT_NSYMB)
#define CP(symbol_sz, c) ((int) ceil((((float) (c)*(symbol_sz))/2048))) #define SRSLTE_CP(symbol_sz, c) ((int) ceil((((float) (c)*(symbol_sz))/2048)))
#define CP_NORM(symbol, symbol_sz) ((symbol==0)?CP((symbol_sz),CPNORM_0_LEN):CP((symbol_sz),CPNORM_LEN)) #define SRSLTE_CP_NORM(symbol, symbol_sz) ((symbol==0)?SRSLTE_CP((symbol_sz),SRSLTE_SRSLTE_CP_NORM_0_LEN):SRSLTE_CP((symbol_sz),SRSLTE_SRSLTE_CP_NORM_LEN))
#define CP_EXT(symbol_sz) (CP((symbol_sz),CPEXT_LEN)) #define SRSLTE_CP_EXT(symbol_sz) (SRSLTE_CP((symbol_sz),SRSLTE_SRSLTE_CP_EXT_LEN))
#define SLOT_LEN(symbol_sz) (480*((symbol_sz)/64)) #define SRSLTE_SLOT_LEN(symbol_sz) (480*((symbol_sz)/64))
#define SF_LEN(symbol_sz) (2*SLOT_LEN(symbol_sz)) #define SRSLTE_SF_LEN(symbol_sz) (2*SRSLTE_SLOT_LEN(symbol_sz))
#define SF_LEN_MAX (SF_LEN(SYMBOL_SZ_MAX)) #define SRSLTE_SF_LEN_MAX (SRSLTE_SF_LEN(SRSLTE_SYMBOL_SZ_MAX))
#define SLOT_LEN_PRB(nof_prb) (SLOT_LEN(lte_symbol_sz(nof_prb))) #define SRSLTE_SLOT_LEN_PRB(nof_prb) (SRSLTE_SLOT_LEN(srslte_symbol_sz(nof_prb)))
#define SF_LEN_PRB(nof_prb) (SF_LEN(lte_symbol_sz(nof_prb))) #define SRSLTE_SF_LEN_PRB(nof_prb) (SRSLTE_SF_LEN(srslte_symbol_sz(nof_prb)))
#define SLOT_LEN_RE(nof_prb, cp) (nof_prb*RE_X_RB*CP_NSYMB(cp)) #define SRSLTE_SLOT_LEN_RE(nof_prb, cp) (nof_prb*SRSLTE_NRE*SRSLTE_CP_NSYMB(cp))
#define SF_LEN_RE(nof_prb, cp) (2*SLOT_LEN_RE(nof_prb, cp)) #define SRSLTE_SF_LEN_RE(nof_prb, cp) (2*SRSLTE_SLOT_LEN_RE(nof_prb, cp))
#define TA_OFFSET (10e-6) #define SRSLTE_TA_OFFSET (10e-6)
#define LTE_TS 1.0/(15000.0*2048) #define SRSLTE_LTE_TS 1.0/(15000.0*2048)
#define SLOT_IDX_CPNORM(symbol_idx, symbol_sz) (symbol_idx==0?0:(symbol_sz + CP(symbol_sz, CPNORM_0_LEN) + \ #define SRSLTE_SLOT_IDX_CPNORM(symbol_idx, symbol_sz) (symbol_idx==0?0:(symbol_sz + SRSLTE_CP(symbol_sz, SRSLTE_SRSLTE_CP_NORM_0_LEN) + \
(symbol_idx-1)*(symbol_sz+CP(symbol_sz, CPNORM_LEN)))) (symbol_idx-1)*(symbol_sz+SRSLTE_CP(symbol_sz, SRSLTE_SRSLTE_CP_NORM_LEN))))
#define SLOT_IDX_CPEXT(idx, symbol_sz) (idx*(symbol_sz+CP(symbol_sz, CPEXT_LEN))) #define SRSLTE_SLOT_IDX_CPEXT(idx, symbol_sz) (idx*(symbol_sz+SRSLTE_CP(symbol_sz, SRSLTE_SRSLTE_CP_EXT_LEN)))
#define RE_IDX(nof_prb, symbol_idx, sample_idx) ((symbol_idx)*(nof_prb)*(RE_X_RB) + sample_idx) #define SRSLTE_RE_IDX(nof_prb, symbol_idx, sample_idx) ((symbol_idx)*(nof_prb)*(SRSLTE_NRE) + sample_idx)
#define RS_VSHIFT(cell_id) (cell_id%6) #define SRSLTE_RS_VSHIFT(cell_id) (cell_id%6)
#define GUARD_RE(nof_prb) ((lte_symbol_sz(nof_prb)-nof_prb*RE_X_RB)/2) #define SRSLTE_GUARD_RE(nof_prb) ((srslte_symbol_sz(nof_prb)-nof_prb*SRSLTE_NRE)/2)
#define SYMBOL_HAS_REF(l, cp, nof_ports) ((l == 1 && nof_ports == 4) \ #define SRSLTE_SYMBOL_HAS_REF(l, cp, nof_ports) ((l == 1 && nof_ports == 4) \
|| l == 0 \ || l == 0 \
|| l == CP_NSYMB(cp) - 3) || l == SRSLTE_CP_NSYMB(cp) - 3)
#define NOF_LTE_BANDS 29 #define SRSLTE_NOF_LTE_BANDS 29
#define NOF_TC_CB_SIZES 188 #define SRSLTE_NOF_TC_CB_SIZES 188
typedef _Complex float cf_t; typedef _Complex float cf_t;
typedef enum SRSLTE_API { PHICH_NORM = 0, PHICH_EXT} phich_length_t; typedef enum SRSLTE_API {
typedef enum SRSLTE_API { R_1_6 = 0, R_1_2, R_1, R_2} phich_resources_t; SRSLTE_PHICH_NORM = 0,
SRSLTE_PHICH_EXT
} srslte_phich_length_t;
typedef enum SRSLTE_API {
SRSLTE_PHICH_SRSLTE_PHICH_R_1_6 = 0,
SRSLTE_PHICH_SRSLTE_PHICH_R_1_2,
SRSLTE_PHICH_R_1,
SRSLTE_PHICH_R_2
} srslte_phich_resources_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint32_t nof_prb; uint32_t nof_prb;
@ -132,97 +142,95 @@ typedef struct SRSLTE_API {
uint32_t bw_idx; uint32_t bw_idx;
uint32_t id; uint32_t id;
srslte_cp_t cp; srslte_cp_t cp;
phich_length_t phich_length; srslte_phich_length_t phich_length;
phich_resources_t phich_resources; srslte_phich_resources_t phich_resources;
}srslte_cell_t; }srslte_cell_t;
typedef enum SRSLTE_API { typedef enum SRSLTE_API {
SINGLE_ANTENNA,TX_DIVERSITY, SPATIAL_MULTIPLEX SINGLE_ANTENNA,TX_DIVERSITY, SPATIAL_MULTIPLEX
} lte_mimo_type_t; } srslte_mimo_type_t;
typedef enum SRSLTE_API { typedef enum SRSLTE_API {
LTE_BPSK = 0, LTE_QPSK = 1, LTE_QAM16 = 2, LTE_QAM64 = 3 LTE_BPSK = 0, LTE_QPSK = 1, LTE_QAM16 = 2, LTE_QAM64 = 3
} lte_mod_t; } srslte_mod_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
int id; int id;
float fd; float fd;
} lte_earfcn_t; } srslte_earfcn_t;
enum band_geographical_area { enum band_geographical_area {
ALL, NAR, APAC, EMEA, JAPAN, CALA, NA ALL, NAR, APAC, EMEA, JAPAN, CALA, NA
}; };
SRSLTE_API bool lte_cell_isvalid(srslte_cell_t *cell); SRSLTE_API bool srslte_cell_isvalid(srslte_cell_t *cell);
SRSLTE_API void lte_cell_fprint(FILE *stream, SRSLTE_API void srslte_cell_fprint(FILE *stream,
srslte_cell_t *cell); srslte_cell_t *cell);
SRSLTE_API bool lte_cellid_isvalid(uint32_t cell_id); SRSLTE_API bool srslte_cellid_isvalid(uint32_t cell_id);
SRSLTE_API bool lte_nofprb_isvalid(uint32_t nof_prb); SRSLTE_API bool srslte_nofprb_isvalid(uint32_t nof_prb);
SRSLTE_API bool lte_sfidx_isvalid(uint32_t sf_idx); SRSLTE_API bool srslte_sfidx_isvalid(uint32_t sf_idx);
SRSLTE_API bool lte_portid_isvalid(uint32_t port_id); SRSLTE_API bool srslte_portid_isvalid(uint32_t port_id);
SRSLTE_API bool lte_N_id_2_isvalid(uint32_t N_id_2); SRSLTE_API bool srslte_N_id_2_isvalid(uint32_t N_id_2);
SRSLTE_API bool lte_N_id_1_isvalid(uint32_t N_id_1); SRSLTE_API bool srslte_N_id_1_isvalid(uint32_t N_id_1);
SRSLTE_API bool lte_symbol_sz_isvalid(uint32_t symbol_sz); SRSLTE_API bool srssrslte_symbol_sz_isvalid(uint32_t symbol_sz);
SRSLTE_API int lte_symbol_sz(uint32_t nof_prb); SRSLTE_API int srslte_symbol_sz(uint32_t nof_prb);
SRSLTE_API int lte_sampling_freq_hz(uint32_t nof_prb); SRSLTE_API int srslte_sampling_freq_hz(uint32_t nof_prb);
SRSLTE_API uint32_t lte_re_x_prb(uint32_t ns, SRSLTE_API uint32_t srslte_re_x_prb(uint32_t ns,
uint32_t symbol, uint32_t symbol,
uint32_t nof_ports, uint32_t nof_ports,
uint32_t nof_symbols); uint32_t nof_symbols);
SRSLTE_API uint32_t lte_voffset(uint32_t symbol_id, SRSLTE_API uint32_t srslte_voffset(uint32_t symbol_id,
uint32_t cell_id, uint32_t cell_id,
uint32_t nof_ports); uint32_t nof_ports);
SRSLTE_API uint32_t lte_N_ta_new_rar(uint32_t ta); SRSLTE_API uint32_t srssrslte_N_ta_new_rar(uint32_t ta);
SRSLTE_API uint32_t lte_N_ta_new(uint32_t N_ta_old, SRSLTE_API uint32_t srslte_N_ta_new(uint32_t N_ta_old,
uint32_t ta); uint32_t ta);
SRSLTE_API int lte_cb_size(uint32_t index); SRSLTE_API int srslte_cb_size(uint32_t index);
SRSLTE_API bool lte_cb_size_isvalid(uint32_t size); SRSLTE_API bool srslte_cb_size_isvalid(uint32_t size);
SRSLTE_API char *lte_cp_string(srslte_cp_t cp); SRSLTE_API char *srslte_cp_string(srslte_cp_t cp);
SRSLTE_API char *lte_mod_string(lte_mod_t mod); SRSLTE_API char *srslte_mod_string(srslte_mod_t mod);
SRSLTE_API uint32_t lte_mod_bits_x_symbol(lte_mod_t mod); SRSLTE_API uint32_t srslte_mod_bits_x_symbol(srslte_mod_t mod);
SRSLTE_API int lte_find_cb_index(uint32_t long_cb); SRSLTE_API int srslte_find_cb_index(uint32_t long_cb);
SRSLTE_API float lte_band_fd(uint32_t earfcn); SRSLTE_API float srslte_band_fd(uint32_t earfcn);
SRSLTE_API int lte_band_get_fd_band(uint32_t band, SRSLTE_API int srslte_band_get_fd_band(uint32_t band,
lte_earfcn_t *earfcn, srslte_earfcn_t *earfcn,
int earfcn_start, int earfcn_start,
int earfcn_end, int earfcn_end,
uint32_t max_elems); uint32_t max_elems);
SRSLTE_API int lte_band_get_fd_band_all(uint32_t band, SRSLTE_API int srslte_band_get_fd_band_all(uint32_t band,
lte_earfcn_t *earfcn, srslte_earfcn_t *earfcn,
uint32_t max_nelems); uint32_t max_nelems);
SRSLTE_API int lte_band_get_fd_region(enum band_geographical_area region, SRSLTE_API int srslte_band_get_fd_region(enum band_geographical_area region,
lte_earfcn_t *earfcn, srslte_earfcn_t *earfcn,
uint32_t max_elems); uint32_t max_elems);
SRSLTE_API int lte_str2mimotype(char *mimo_type_str, SRSLTE_API int srslte_str2mimotype(char *mimo_type_str,
lte_mimo_type_t *type); srslte_mimo_type_t *type);
SRSLTE_API char *lte_mimotype2str(lte_mimo_type_t type);

@ -39,8 +39,8 @@ typedef _Complex float cf_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint32_t max_prb; uint32_t max_prb;
srslte_dft_plan_t dft_plan[MAX_PRB]; srslte_dft_plan_t dft_plan[SRSLTE_MAX_PRB];
srslte_dft_plan_t idft_plan[MAX_PRB]; srslte_dft_plan_t idft_plan[SRSLTE_MAX_PRB];
}dft_precoding_t; }dft_precoding_t;

@ -36,20 +36,20 @@ typedef _Complex float cf_t;
/* Generates the vector of layer-mapped symbols "x" based on the vector of data symbols "d" /* Generates the vector of layer-mapped symbols "x" based on the vector of data symbols "d"
*/ */
SRSLTE_API int layermap_single(cf_t *d, cf_t *x, int nof_symbols); SRSLTE_API int layermap_single(cf_t *d, cf_t *x, int nof_symbols);
SRSLTE_API int layermap_diversity(cf_t *d, cf_t *x[MAX_LAYERS], int nof_layers, int nof_symbols); SRSLTE_API int layermap_diversity(cf_t *d, cf_t *x[SRSLTE_MAX_LAYERS], int nof_layers, int nof_symbols);
SRSLTE_API int layermap_multiplex(cf_t *d[MAX_CODEWORDS], cf_t *x[MAX_LAYERS], int nof_cw, int nof_layers, SRSLTE_API int layermap_multiplex(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_LAYERS], int nof_cw, int nof_layers,
int nof_symbols[MAX_CODEWORDS]); int nof_symbols[SRSLTE_MAX_CODEWORDS]);
SRSLTE_API int layermap_type(cf_t *d[MAX_CODEWORDS], cf_t *x[MAX_LAYERS], int nof_cw, int nof_layers, SRSLTE_API int layermap_type(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_LAYERS], int nof_cw, int nof_layers,
int nof_symbols[MAX_CODEWORDS], lte_mimo_type_t type); int nof_symbols[SRSLTE_MAX_CODEWORDS], srslte_mimo_type_t type);
/* Generates the vector of data symbols "d" based on the vector of layer-mapped symbols "x" /* Generates the vector of data symbols "d" based on the vector of layer-mapped symbols "x"
*/ */
SRSLTE_API int layerdemap_single(cf_t *x, cf_t *d, int nof_symbols); SRSLTE_API int layerdemap_single(cf_t *x, cf_t *d, int nof_symbols);
SRSLTE_API int layerdemap_diversity(cf_t *x[MAX_LAYERS], cf_t *d, int nof_layers, int nof_layer_symbols); SRSLTE_API int layerdemap_diversity(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d, int nof_layers, int nof_layer_symbols);
SRSLTE_API int layerdemap_multiplex(cf_t *x[MAX_LAYERS], cf_t *d[MAX_CODEWORDS], int nof_layers, int nof_cw, SRSLTE_API int layerdemap_multiplex(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d[SRSLTE_MAX_CODEWORDS], int nof_layers, int nof_cw,
int nof_layer_symbols, int nof_symbols[MAX_CODEWORDS]); int nof_layer_symbols, int nof_symbols[SRSLTE_MAX_CODEWORDS]);
SRSLTE_API int layerdemap_type(cf_t *x[MAX_LAYERS], cf_t *d[MAX_CODEWORDS], int nof_layers, int nof_cw, SRSLTE_API int layerdemap_type(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d[SRSLTE_MAX_CODEWORDS], int nof_layers, int nof_cw,
int nof_layer_symbols, int nof_symbols[MAX_CODEWORDS], lte_mimo_type_t type); int nof_layer_symbols, int nof_symbols[SRSLTE_MAX_CODEWORDS], srslte_mimo_type_t type);
#endif // LAYERMAP_H_ #endif // LAYERMAP_H_

@ -63,17 +63,17 @@ SRSLTE_API int precoding_single(precoding_t *q,
int nof_symbols); int nof_symbols);
SRSLTE_API int precoding_diversity(precoding_t *q, SRSLTE_API int precoding_diversity(precoding_t *q,
cf_t *x[MAX_LAYERS], cf_t *x[SRSLTE_MAX_LAYERS],
cf_t *y[SRSLTE_MAX_PORTS], cf_t *y[SRSLTE_MAX_PORTS],
int nof_ports, int nof_symbols); int nof_ports, int nof_symbols);
SRSLTE_API int precoding_type(precoding_t *q, SRSLTE_API int precoding_type(precoding_t *q,
cf_t *x[MAX_LAYERS], cf_t *x[SRSLTE_MAX_LAYERS],
cf_t *y[SRSLTE_MAX_PORTS], cf_t *y[SRSLTE_MAX_PORTS],
int nof_layers, int nof_layers,
int nof_ports, int nof_ports,
int nof_symbols, int nof_symbols,
lte_mimo_type_t type); srslte_mimo_type_t type);
/* Estimates the vector "x" based on the received signal "y" and the channel estimates "h" /* Estimates the vector "x" based on the received signal "y" and the channel estimates "h"
*/ */
@ -87,7 +87,7 @@ SRSLTE_API int predecoding_single(precoding_t *q,
SRSLTE_API int predecoding_diversity(precoding_t *q, SRSLTE_API int predecoding_diversity(precoding_t *q,
cf_t *y, cf_t *y,
cf_t *h[SRSLTE_MAX_PORTS], cf_t *h[SRSLTE_MAX_PORTS],
cf_t *x[MAX_LAYERS], cf_t *x[SRSLTE_MAX_LAYERS],
int nof_ports, int nof_ports,
int nof_symbols, int nof_symbols,
float noise_estimate); float noise_estimate);
@ -95,11 +95,11 @@ SRSLTE_API int predecoding_diversity(precoding_t *q,
SRSLTE_API int predecoding_type(precoding_t *q, SRSLTE_API int predecoding_type(precoding_t *q,
cf_t *y, cf_t *y,
cf_t *h[SRSLTE_MAX_PORTS], cf_t *h[SRSLTE_MAX_PORTS],
cf_t *x[MAX_LAYERS], cf_t *x[SRSLTE_MAX_LAYERS],
int nof_ports, int nof_ports,
int nof_layers, int nof_layers,
int nof_symbols, int nof_symbols,
lte_mimo_type_t type, srslte_mimo_type_t type,
float noise_estimate); float noise_estimate);
#endif /* PRECODING_H_ */ #endif /* PRECODING_H_ */

@ -38,12 +38,12 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
lte_mod_t mod; /* In this implementation, mapping table is hard-coded */ srslte_mod_t mod; /* In this implementation, mapping table is hard-coded */
}demod_hard_t; }demod_hard_t;
SRSLTE_API void demod_hard_init(demod_hard_t* q); SRSLTE_API void demod_hard_init(demod_hard_t* q);
SRSLTE_API void demod_hard_table_set(demod_hard_t* q, lte_mod_t mod); SRSLTE_API void demod_hard_table_set(demod_hard_t* q, srslte_mod_t mod);
SRSLTE_API int demod_hard_demodulate(demod_hard_t* q, cf_t* symbols, uint8_t *bits, uint32_t nsymbols); SRSLTE_API int demod_hard_demodulate(demod_hard_t* q, cf_t* symbols, uint8_t *bits, uint32_t nsymbols);
@ -52,7 +52,7 @@ SRSLTE_API int demod_hard_demodulate(demod_hard_t* q, cf_t* symbols, uint8_t *bi
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
demod_hard_t obj; demod_hard_t obj;
struct demod_hard_init { struct demod_hard_init {
lte_mod_t std; // Symbol mapping standard (see modem_table.h) srslte_mod_t std; // Symbol mapping standard (see modem_table.h)
} init; } init;
cf_t* input; cf_t* input;

@ -60,7 +60,7 @@ typedef struct SRSLTE_API {
modem_table_t table; modem_table_t table;
struct demod_soft_init{ struct demod_soft_init{
lte_mod_t std; // symbol mapping standard (see modem_table.h) srslte_mod_t std; // symbol mapping standard (see modem_table.h)
} init; } init;
const cf_t* input; const cf_t* input;

@ -43,7 +43,7 @@ SRSLTE_API int mod_modulate(modem_table_t* table, const uint8_t *bits, cf_t* sym
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
modem_table_t obj; modem_table_t obj;
struct mod_init { struct mod_init {
lte_mod_t std; // symbol mapping standard (see modem_table.h) srslte_mod_t std; // symbol mapping standard (see modem_table.h)
} init; } init;
const uint8_t* input; const uint8_t* input;

@ -66,7 +66,7 @@ SRSLTE_API int modem_table_set(modem_table_t* q,
uint32_t nbits_x_symbol); uint32_t nbits_x_symbol);
SRSLTE_API int modem_table_lte(modem_table_t* q, SRSLTE_API int modem_table_lte(modem_table_t* q,
lte_mod_t modulation, srslte_mod_t modulation,
bool compute_soft_demod); bool compute_soft_demod);
#endif // MODEM_TABLE_ #endif // MODEM_TABLE_

@ -45,8 +45,8 @@
#define BCH_PAYLOADCRC_LEN (BCH_PAYLOAD_LEN+16) #define BCH_PAYLOADCRC_LEN (BCH_PAYLOAD_LEN+16)
#define BCH_ENCODED_LEN 3*(BCH_PAYLOADCRC_LEN) #define BCH_ENCODED_LEN 3*(BCH_PAYLOADCRC_LEN)
#define PBCH_RE_CPNORM 240 #define PBCH_RE_SRSLTE_SRSLTE_CP_NORM 240
#define PBCH_RE_CPEXT 216 #define PBCH_RE_SRSLTE_SRSLTE_CP_EXT 216
typedef _Complex float cf_t; typedef _Complex float cf_t;

@ -40,18 +40,18 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
#define PHICH_NORM_NSEQUENCES 8 #define SRSLTE_PHICH_NORM_NSEQUENCES 8
#define PHICH_EXT_NSEQUENCES 4 #define SRSLTE_PHICH_EXT_NSEQUENCES 4
#define PHICH_MAX_SEQUENCES PHICH_NORM_NSEQUENCES #define PHICH_MAX_SEQUENCES SRSLTE_PHICH_NORM_NSEQUENCES
#define PHICH_NBITS 3 #define PHICH_NBITS 3
#define PHICH_NORM_MSYMB PHICH_NBITS * 4 #define SRSLTE_PHICH_NORM_MSYMB PHICH_NBITS * 4
#define PHICH_EXT_MSYMB PHICH_NBITS * 2 #define SRSLTE_PHICH_EXT_MSYMB PHICH_NBITS * 2
#define PHICH_MAX_NSYMB PHICH_NORM_MSYMB #define PHICH_SRSLTE_MAX_NSYMB SRSLTE_PHICH_NORM_MSYMB
#define PHICH_NORM_C 1 #define SRSLTE_PHICH_NORM_C 1
#define PHICH_EXT_C 2 #define SRSLTE_PHICH_EXT_C 2
#define PHICH_NORM_NSF 4 #define SRSLTE_PHICH_NORM_NSF 4
#define PHICH_EXT_NSF 2 #define SRSLTE_PHICH_EXT_NSF 2
/* phich object */ /* phich object */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
@ -61,11 +61,11 @@ typedef struct SRSLTE_API {
regs_t *regs; regs_t *regs;
/* buffers */ /* buffers */
cf_t ce[SRSLTE_MAX_PORTS][PHICH_MAX_NSYMB]; cf_t ce[SRSLTE_MAX_PORTS][PHICH_SRSLTE_MAX_NSYMB];
cf_t phich_symbols[SRSLTE_MAX_PORTS][PHICH_MAX_NSYMB]; cf_t phich_symbols[SRSLTE_MAX_PORTS][PHICH_SRSLTE_MAX_NSYMB];
cf_t phich_x[SRSLTE_MAX_PORTS][PHICH_MAX_NSYMB]; cf_t phich_x[SRSLTE_MAX_PORTS][PHICH_SRSLTE_MAX_NSYMB];
cf_t phich_d[PHICH_MAX_NSYMB]; cf_t phich_d[PHICH_SRSLTE_MAX_NSYMB];
cf_t phich_d0[PHICH_MAX_NSYMB]; cf_t phich_d0[PHICH_SRSLTE_MAX_NSYMB];
cf_t phich_z[PHICH_NBITS]; cf_t phich_z[PHICH_NBITS];
/* bit message */ /* bit message */

@ -71,7 +71,7 @@ typedef struct SRSLTE_API {
srslte_cell_t cell; srslte_cell_t cell;
pucch_cfg_t pucch_cfg; pucch_cfg_t pucch_cfg;
uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NSYMB]; uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB];
float tmp_arg[PUCCH_N_SF_MAX*PUCCH_N_SEQ]; float tmp_arg[PUCCH_N_SF_MAX*PUCCH_N_SEQ];
float y[PUCCH_N_SEQ]; float y[PUCCH_N_SEQ];
}pucch_t; }pucch_t;
@ -93,7 +93,7 @@ SRSLTE_API int pucch_encode(pucch_t *q,
uint8_t bits[PUCCH_MAX_BITS], uint8_t bits[PUCCH_MAX_BITS],
cf_t *sf_symbols); cf_t *sf_symbols);
SRSLTE_API float pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NSYMB], SRSLTE_API float pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB],
pucch_cfg_t *cfg, pucch_cfg_t *cfg,
srslte_cp_t cp, srslte_cp_t cp,
bool is_drms, bool is_drms,
@ -102,7 +102,7 @@ SRSLTE_API float pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLT
uint32_t *n_oc); uint32_t *n_oc);
SRSLTE_API int generate_n_cs_cell(srslte_cell_t cell, SRSLTE_API int generate_n_cs_cell(srslte_cell_t cell,
uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NSYMB]); uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]);
SRSLTE_API bool pucch_cfg_isvalid(pucch_cfg_t *cfg); SRSLTE_API bool pucch_cfg_isvalid(pucch_cfg_t *cfg);

@ -38,7 +38,7 @@
*/ */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
lte_mod_t mod; srslte_mod_t mod;
int tbs; int tbs;
} ra_mcs_t; } ra_mcs_t;
@ -72,7 +72,7 @@ typedef struct SRSLTE_API {
} ra_type2_t; } ra_type2_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
bool prb_idx[MAX_PRB]; bool prb_idx[SRSLTE_MAX_PRB];
uint32_t nof_prb; uint32_t nof_prb;
} ra_prb_slot_t; } ra_prb_slot_t;

@ -63,8 +63,8 @@ typedef struct SRSLTE_API {
bool cfi_initiated; bool cfi_initiated;
uint32_t ngroups_phich; uint32_t ngroups_phich;
phich_resources_t phich_res; srslte_phich_resources_t phich_res;
phich_length_t phich_len; srslte_phich_length_t phich_len;
regs_ch_t pcfich; regs_ch_t pcfich;
regs_ch_t *phich; // there are several phich regs_ch_t *phich; // there are several phich

@ -59,7 +59,7 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && if (q != NULL &&
lte_cell_isvalid(&cell)) srslte_cell_isvalid(&cell))
{ {
bzero(q, sizeof(srslte_chest_dl_t)); bzero(q, sizeof(srslte_chest_dl_t));
@ -112,12 +112,12 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell)
} }
} }
if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, RE_X_RB*cell.nof_prb)) { if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, SRSLTE_NRE*cell.nof_prb)) {
fprintf(stderr, "Error initializing vector interpolator\n"); fprintf(stderr, "Error initializing vector interpolator\n");
goto clean_exit; goto clean_exit;
} }
if (srslte_interp_linear_init(&q->srslte_interp_lin, 2*cell.nof_prb, RE_X_RB/2)) { if (srslte_interp_linear_init(&q->srslte_interp_lin, 2*cell.nof_prb, SRSLTE_NRE/2)) {
fprintf(stderr, "Error initializing interpolator\n"); fprintf(stderr, "Error initializing interpolator\n");
goto clean_exit; goto clean_exit;
} }
@ -220,11 +220,11 @@ static float estimate_noise_port(srslte_chest_dl_t *q, uint32_t port_id, cf_t *a
/* Uses the 5 empty transmitted SC before and after the SSS and PSS sequences for noise estimation */ /* Uses the 5 empty transmitted SC before and after the SSS and PSS sequences for noise estimation */
static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) { static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) {
int k_sss = (CP_NSYMB(q->cell.cp) - 2) * q->cell.nof_prb * RE_X_RB + q->cell.nof_prb * RE_X_RB / 2 - 31; int k_sss = (SRSLTE_CP_NSYMB(q->cell.cp) - 2) * q->cell.nof_prb * SRSLTE_NRE + q->cell.nof_prb * SRSLTE_NRE / 2 - 31;
float noise_power = 0; 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-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 += vec_avg_power_cf(&input[k_sss+62], 5); // 5 empty SC after SSS
int k_pss = (CP_NSYMB(q->cell.cp) - 1) * q->cell.nof_prb * RE_X_RB + q->cell.nof_prb * RE_X_RB / 2 - 31; int k_pss = (SRSLTE_CP_NSYMB(q->cell.cp) - 1) * q->cell.nof_prb * SRSLTE_NRE + q->cell.nof_prb * SRSLTE_NRE / 2 - 31;
noise_power += vec_avg_power_cf(&input[k_pss-5], 5); // 5 empty SC before PSS noise_power += vec_avg_power_cf(&input[k_pss-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 += vec_avg_power_cf(&input[k_pss+62], 5); // 5 empty SC after PSS
@ -285,7 +285,7 @@ static void average_pilots(srslte_chest_dl_t *q, uint32_t port_id)
} }
#define cesymb(i) ce[RE_IDX(q->cell.nof_prb,i,0)] #define cesymb(i) ce[SRSLTE_RE_IDX(q->cell.nof_prb,i,0)]
static void interpolate_pilots(srslte_chest_dl_t *q, cf_t *ce, uint32_t port_id) static void interpolate_pilots(srslte_chest_dl_t *q, cf_t *ce, uint32_t port_id)
{ {
@ -297,12 +297,12 @@ static void interpolate_pilots(srslte_chest_dl_t *q, cf_t *ce, uint32_t port_id)
for (l=0;l<nsymbols;l++) { for (l=0;l<nsymbols;l++) {
uint32_t fidx_offset = srslte_refsignal_cs_fidx(q->cell, l, port_id, 0); uint32_t fidx_offset = srslte_refsignal_cs_fidx(q->cell, l, port_id, 0);
srslte_interp_linear_offset(&q->srslte_interp_lin, &pilot_avg(0), srslte_interp_linear_offset(&q->srslte_interp_lin, &pilot_avg(0),
&ce[srslte_refsignal_cs_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * RE_X_RB], &ce[srslte_refsignal_cs_nsymbol(l,q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE],
fidx_offset, RE_X_RB/2-fidx_offset); fidx_offset, SRSLTE_NRE/2-fidx_offset);
} }
/* Now interpolate in the time domain between symbols */ /* Now interpolate in the time domain between symbols */
if (CP_ISNORM(q->cell.cp)) { if (SRSLTE_CP_ISNORM(q->cell.cp)) {
if (nsymbols == 4) { if (nsymbols == 4) {
srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(4), &cesymb(1), 3); srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(4), &cesymb(1), 3);
srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(4), &cesymb(7), &cesymb(5), 2); srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(4), &cesymb(7), &cesymb(5), 2);
@ -333,8 +333,8 @@ float srslte_chest_dl_rssi(srslte_chest_dl_t *q, cf_t *input, uint32_t port_id)
float rssi = 0; float rssi = 0;
uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id);
for (l=0;l<nsymbols;l++) { for (l=0;l<nsymbols;l++) {
cf_t *tmp = &input[srslte_refsignal_cs_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * RE_X_RB]; cf_t *tmp = &input[srslte_refsignal_cs_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE];
rssi += vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * RE_X_RB); rssi += vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * SRSLTE_NRE);
} }
return rssi/nsymbols; return rssi/nsymbols;
} }
@ -394,7 +394,7 @@ int srslte_chest_dl_estimate(srslte_chest_dl_t *q, cf_t *input, cf_t *ce[SRSLTE_
float srslte_chest_dl_get_noise_estimate(srslte_chest_dl_t *q) { float 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 = vec_acc_ff(q->noise_estimate, q->cell.nof_ports)/q->cell.nof_ports;
#ifdef NOISE_POWER_USE_ESTIMATES #ifdef NOISE_POWER_USE_ESTIMATES
return noise*sqrtf(lte_symbol_sz(q->cell.nof_prb)); return noise*sqrtf(srslte_symbol_sz(q->cell.nof_prb));
#else #else
return noise; return noise;
#endif #endif
@ -407,7 +407,7 @@ float srslte_chest_dl_get_snr(srslte_chest_dl_t *q) {
} }
float srslte_chest_dl_get_rssi(srslte_chest_dl_t *q) { float srslte_chest_dl_get_rssi(srslte_chest_dl_t *q) {
return 4*q->rssi[0]/q->cell.nof_prb/RE_X_RB; return 4*q->rssi[0]/q->cell.nof_prb/SRSLTE_NRE;
} }
/* q->rssi[0] is the average power in all RE in all symbol containing references for port 0 . q->rssi[0]/q->cell.nof_prb is the average power per PRB /* q->rssi[0] is the average power in all RE in all symbol containing references for port 0 . q->rssi[0]/q->cell.nof_prb is the average power per PRB

@ -90,12 +90,12 @@ inline uint32_t srslte_refsignal_cs_fidx(srslte_cell_t cell, uint32_t l, uint32_
inline uint32_t srslte_refsignal_cs_nsymbol(uint32_t l, srslte_cp_t cp, uint32_t port_id) { inline uint32_t srslte_refsignal_cs_nsymbol(uint32_t l, srslte_cp_t cp, uint32_t port_id) {
if (port_id < 2) { if (port_id < 2) {
if (l % 2) { if (l % 2) {
return (l/2+1)*CP_NSYMB(cp) - 3; return (l/2+1)*SRSLTE_CP_NSYMB(cp) - 3;
} else { } else {
return (l/2)*CP_NSYMB(cp); return (l/2)*SRSLTE_CP_NSYMB(cp);
} }
} else { } else {
return 1+l*CP_NSYMB(cp); return 1+l*SRSLTE_CP_NSYMB(cp);
} }
} }
@ -113,17 +113,17 @@ int srslte_refsignal_cs_init(srslte_refsignal_cs_t * q, srslte_cell_t cell)
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && if (q != NULL &&
lte_cell_isvalid(&cell)) srslte_cell_isvalid(&cell))
{ {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
bzero(q, sizeof(srslte_refsignal_cs_t)); bzero(q, sizeof(srslte_refsignal_cs_t));
bzero(&seq, sizeof(sequence_t)); bzero(&seq, sizeof(sequence_t));
if (sequence_init(&seq, 2 * 2 * MAX_PRB)) { if (sequence_init(&seq, 2 * 2 * SRSLTE_MAX_PRB)) {
goto free_and_exit; goto free_and_exit;
} }
if (CP_ISNORM(cell.cp)) { if (SRSLTE_CP_ISNORM(cell.cp)) {
N_cp = 1; N_cp = 1;
} else { } else {
N_cp = 0; N_cp = 0;
@ -155,7 +155,7 @@ int srslte_refsignal_cs_init(srslte_refsignal_cs_t * q, srslte_cell_t cell)
/* Compute signal */ /* Compute signal */
for (i = 0; i < 2*q->cell.nof_prb; i++) { for (i = 0; i < 2*q->cell.nof_prb; i++) {
mp = i + MAX_PRB - cell.nof_prb; mp = i + SRSLTE_MAX_PRB - cell.nof_prb;
/* save signal */ /* save signal */
q->pilots[p][ns/2][SRSLTE_REFSIGNAL_PILOT_IDX(i,(ns%2)*nsymbols+l,q->cell)] = q->pilots[p][ns/2][SRSLTE_REFSIGNAL_PILOT_IDX(i,(ns%2)*nsymbols+l,q->cell)] =
(1 - 2 * (float) seq.c[2 * mp]) / sqrt(2) + (1 - 2 * (float) seq.c[2 * mp]) / sqrt(2) +
@ -198,8 +198,8 @@ int srslte_refsignal_cs_put_sf(srslte_cell_t cell, uint32_t port_id, cf_t *pilot
uint32_t i, l; uint32_t i, l;
uint32_t fidx; uint32_t fidx;
if (lte_cell_isvalid(&cell) && if (srslte_cell_isvalid(&cell) &&
lte_portid_isvalid(port_id) && srslte_portid_isvalid(port_id) &&
pilots != NULL && pilots != NULL &&
sf_symbols != NULL) sf_symbols != NULL)
{ {
@ -209,8 +209,8 @@ int srslte_refsignal_cs_put_sf(srslte_cell_t cell, uint32_t port_id, cf_t *pilot
/* Compute offset frequency index */ /* Compute offset frequency index */
fidx = ((srslte_refsignal_cs_v(port_id, l) + (cell.id % 6)) % 6); fidx = ((srslte_refsignal_cs_v(port_id, l) + (cell.id % 6)) % 6);
for (i = 0; i < 2*cell.nof_prb; i++) { for (i = 0; i < 2*cell.nof_prb; i++) {
sf_symbols[RE_IDX(cell.nof_prb, nsymbol, fidx)] = pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i,l,cell)]; sf_symbols[SRSLTE_RE_IDX(cell.nof_prb, nsymbol, fidx)] = pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i,l,cell)];
fidx += RE_X_RB/2; // 1 reference every 6 RE fidx += SRSLTE_NRE/2; // 1 reference every 6 RE
} }
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -228,8 +228,8 @@ int srslte_refsignal_cs_get_sf(srslte_cell_t cell, uint32_t port_id, cf_t *sf_sy
uint32_t i, l; uint32_t i, l;
uint32_t fidx; uint32_t fidx;
if (lte_cell_isvalid(&cell) && if (srslte_cell_isvalid(&cell) &&
lte_portid_isvalid(port_id) && srslte_portid_isvalid(port_id) &&
pilots != NULL && pilots != NULL &&
sf_symbols != NULL) sf_symbols != NULL)
{ {
@ -238,8 +238,8 @@ int srslte_refsignal_cs_get_sf(srslte_cell_t cell, uint32_t port_id, cf_t *sf_sy
/* Compute offset frequency index */ /* Compute offset frequency index */
fidx = ((srslte_refsignal_cs_v(port_id, l) + (cell.id % 6)) % 6); fidx = ((srslte_refsignal_cs_v(port_id, l) + (cell.id % 6)) % 6);
for (i = 0; i < 2*cell.nof_prb; i++) { for (i = 0; i < 2*cell.nof_prb; i++) {
pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i,l,cell)] = sf_symbols[RE_IDX(cell.nof_prb, nsymbol, fidx)]; pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i,l,cell)] = sf_symbols[SRSLTE_RE_IDX(cell.nof_prb, nsymbol, fidx)];
fidx += RE_X_RB/2; // 2 references per PRB fidx += SRSLTE_NRE/2; // 2 references per PRB
} }
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;

@ -73,13 +73,13 @@ static int generate_n_prs(srslte_refsignal_ul_t * q) {
for (uint32_t delta_ss=0;delta_ss<SRSLTE_NOF_DELTA_SS;delta_ss++) { for (uint32_t delta_ss=0;delta_ss<SRSLTE_NOF_DELTA_SS;delta_ss++) {
c_init = ((q->cell.id / 30) << 5) + (((q->cell.id % 30) + delta_ss) % 30); c_init = ((q->cell.id / 30) << 5) + (((q->cell.id % 30) + delta_ss) % 30);
if (sequence_LTE_pr(&seq, 8 * CP_NSYMB(q->cell.cp) * 20, c_init)) { if (sequence_LTE_pr(&seq, 8 * SRSLTE_CP_NSYMB(q->cell.cp) * 20, c_init)) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
for (uint32_t ns=0;ns<SRSLTE_NSLOTS_X_FRAME;ns++) { for (uint32_t ns=0;ns<SRSLTE_NSLOTS_X_FRAME;ns++) {
uint32_t n_prs = 0; uint32_t n_prs = 0;
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
n_prs += (seq.c[8 * CP_NSYMB(q->cell.cp) * ns + i] << i); n_prs += (seq.c[8 * SRSLTE_CP_NSYMB(q->cell.cp) * ns + i] << i);
} }
q->n_prs_pusch[delta_ss][ns] = n_prs; q->n_prs_pusch[delta_ss][ns] = n_prs;
} }
@ -135,13 +135,13 @@ int srslte_refsignal_ul_init(srslte_refsignal_ul_t * q, srslte_cell_t cell)
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && lte_cell_isvalid(&cell)) { if (q != NULL && srslte_cell_isvalid(&cell)) {
bzero(q, sizeof(srslte_refsignal_ul_t)); bzero(q, sizeof(srslte_refsignal_ul_t));
q->cell = cell; q->cell = cell;
// Allocate temporal buffer for computing signal argument // Allocate temporal buffer for computing signal argument
q->tmp_arg = vec_malloc(RE_X_RB * q->cell.nof_prb * sizeof(cf_t)); q->tmp_arg = vec_malloc(SRSLTE_NRE * q->cell.nof_prb * sizeof(cf_t));
if (!q->tmp_arg) { if (!q->tmp_arg) {
perror("malloc"); perror("malloc");
goto free_and_exit; goto free_and_exit;
@ -194,13 +194,13 @@ uint32_t largest_prime_lower_than(uint32_t x) {
} }
static void arg_r_uv_1prb(float *arg, uint32_t u) { static void arg_r_uv_1prb(float *arg, uint32_t u) {
for (int i = 0; i < RE_X_RB; i++) { for (int i = 0; i < SRSLTE_NRE; i++) {
arg[i] = phi_M_sc_12[u][i] * M_PI / 4; arg[i] = phi_M_sc_12[u][i] * M_PI / 4;
} }
} }
static void arg_r_uv_2prb(float *arg, uint32_t u) { static void arg_r_uv_2prb(float *arg, uint32_t u) {
for (int i = 0; i < 2*RE_X_RB; i++) { for (int i = 0; i < 2*SRSLTE_NRE; i++) {
arg[i] = phi_M_sc_24[u][i] * M_PI / 4; arg[i] = phi_M_sc_24[u][i] * M_PI / 4;
} }
} }
@ -238,7 +238,7 @@ static void compute_pusch_r_uv_arg(srslte_refsignal_ul_t *q, srslte_refsignal_dr
} else if (nof_prb == 2) { } else if (nof_prb == 2) {
arg_r_uv_2prb(q->tmp_arg, u); arg_r_uv_2prb(q->tmp_arg, u);
} else { } else {
arg_r_uv_mprb(q->tmp_arg, RE_X_RB*nof_prb, u, v); arg_r_uv_mprb(q->tmp_arg, SRSLTE_NRE*nof_prb, u, v);
} }
} }
@ -273,9 +273,9 @@ void srslte_refsignal_drms_pusch_put(srslte_refsignal_ul_t *q, srslte_refsignal_
{ {
for (uint32_t ns_idx=0;ns_idx<2;ns_idx++) { for (uint32_t ns_idx=0;ns_idx<2;ns_idx++) {
DEBUG("Putting DRMS to n_prb: %d, L: %d, ns_idx: %d\n", n_prb[ns_idx], nof_prb, ns_idx); DEBUG("Putting DRMS to n_prb: %d, L: %d, ns_idx: %d\n", n_prb[ns_idx], nof_prb, ns_idx);
uint32_t L = (ns_idx+1)*CP_NSYMB(q->cell.cp)-4; uint32_t L = (ns_idx+1)*SRSLTE_CP_NSYMB(q->cell.cp)-4;
memcpy(&sf_symbols[RE_IDX(q->cell.nof_prb, L, n_prb[ns_idx]*RE_X_RB)], memcpy(&sf_symbols[SRSLTE_RE_IDX(q->cell.nof_prb, L, n_prb[ns_idx]*SRSLTE_NRE)],
&r_pusch[ns_idx*RE_X_RB*nof_prb], nof_prb*RE_X_RB*sizeof(cf_t)); &r_pusch[ns_idx*SRSLTE_NRE*nof_prb], nof_prb*SRSLTE_NRE*sizeof(cf_t));
} }
} }
@ -308,15 +308,15 @@ int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t *q, srslte_refsignal_d
float alpha = pusch_get_alpha(q, cfg, ns); float alpha = pusch_get_alpha(q, cfg, ns);
if (verbose == VERBOSE_DEBUG) { if (verbose == VERBOSE_DEBUG) {
uint32_t N_sz = largest_prime_lower_than(nof_prb*RE_X_RB); uint32_t N_sz = largest_prime_lower_than(nof_prb*SRSLTE_NRE);
DEBUG("Generating PUSCH DRMS sequence with parameters:\n",0); DEBUG("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", DEBUG("\tbeta: %.1f, nof_prb: %d, u: %d, v: %d, alpha: %f, N_sc: %d, root q: %d, nprs: %d\n",
cfg->beta_pusch, nof_prb, u, v, alpha, N_sz, get_q(u,v,N_sz),q->n_prs_pusch[cfg->delta_ss][ns]); cfg->beta_pusch, nof_prb, u, v, alpha, N_sz, get_q(u,v,N_sz),q->n_prs_pusch[cfg->delta_ss][ns]);
} }
// Do complex exponential and adjust amplitude // Do complex exponential and adjust amplitude
for (int i=0;i<RE_X_RB*nof_prb;i++) { for (int i=0;i<SRSLTE_NRE*nof_prb;i++) {
r_pusch[(ns%2)*RE_X_RB*nof_prb+i] = cfg->beta_pusch * cexpf(I*(q->tmp_arg[i] + alpha*i)); r_pusch[(ns%2)*SRSLTE_NRE*nof_prb+i] = cfg->beta_pusch * cexpf(I*(q->tmp_arg[i] + alpha*i));
} }
} }
ret = 0; ret = 0;
@ -337,7 +337,7 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg,
case PUCCH_FORMAT_1: case PUCCH_FORMAT_1:
case PUCCH_FORMAT_1A: case PUCCH_FORMAT_1A:
case PUCCH_FORMAT_1B: case PUCCH_FORMAT_1B:
if (CP_ISNORM(q->cell.cp)) { if (SRSLTE_CP_ISNORM(q->cell.cp)) {
N_rs = 3; N_rs = 3;
pucch_symbol=pucch_symbol_format1_cpnorm; pucch_symbol=pucch_symbol_format1_cpnorm;
} else { } else {
@ -346,7 +346,7 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg,
} }
break; break;
case PUCCH_FORMAT_2: case PUCCH_FORMAT_2:
if (CP_ISNORM(q->cell.cp)) { if (SRSLTE_CP_ISNORM(q->cell.cp)) {
N_rs = 2; N_rs = 2;
pucch_symbol=pucch_symbol_format2_cpnorm; pucch_symbol=pucch_symbol_format2_cpnorm;
} else { } else {
@ -375,14 +375,14 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg,
case PUCCH_FORMAT_1: case PUCCH_FORMAT_1:
case PUCCH_FORMAT_1A: case PUCCH_FORMAT_1A:
case PUCCH_FORMAT_1B: case PUCCH_FORMAT_1B:
if (CP_ISNORM(q->cell.cp)) { if (SRSLTE_CP_ISNORM(q->cell.cp)) {
w=w_arg_pucch_format1_cpnorm[n_oc]; w=w_arg_pucch_format1_cpnorm[n_oc];
} else { } else {
w=w_arg_pucch_format1_cpext[n_oc]; w=w_arg_pucch_format1_cpext[n_oc];
} }
break; break;
case PUCCH_FORMAT_2: case PUCCH_FORMAT_2:
if (CP_ISNORM(q->cell.cp)) { if (SRSLTE_CP_ISNORM(q->cell.cp)) {
w=w_arg_pucch_format2_cpnorm; w=w_arg_pucch_format2_cpnorm;
} else { } else {
w=w_arg_pucch_format2_cpext; w=w_arg_pucch_format2_cpext;
@ -395,8 +395,8 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg,
} }
if (w) { if (w) {
for (uint32_t n=0;n<RE_X_RB*n_rb;n++) { for (uint32_t n=0;n<SRSLTE_NRE*n_rb;n++) {
r_pucch[(ns%2)*RE_X_RB*n_rb*N_rs+m*RE_X_RB*n_rb+n] = cfg->beta_pucch*cexpf(I*(w[m]+q->tmp_arg[n]+alpha*n)); r_pucch[(ns%2)*SRSLTE_NRE*n_rb*N_rs+m*SRSLTE_NRE*n_rb+n] = cfg->beta_pucch*cexpf(I*(w[m]+q->tmp_arg[n]+alpha*n));
} }
} else { } else {
return SRSLTE_ERROR; return SRSLTE_ERROR;

@ -37,7 +37,7 @@ srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
1, // nof_ports 1, // nof_ports
1000, // cell_id 1000, // cell_id
CPNORM // cyclic prefix SRSLTE_SRSLTE_CP_NORM // cyclic prefix
}; };
char *output_matlab = NULL; char *output_matlab = NULL;
@ -62,7 +62,7 @@ void parse_args(int argc, char **argv) {
cell.nof_prb = atoi(argv[optind]); cell.nof_prb = atoi(argv[optind]);
break; break;
case 'e': case 'e':
cell.cp = CPEXT; cell.cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
case 'c': case 'c':
cell.id = atoi(argv[optind]); cell.id = atoi(argv[optind]);
@ -100,7 +100,7 @@ int main(int argc, char **argv) {
} }
} }
num_re = 2 * cell.nof_prb * RE_X_RB * CP_NSYMB(cell.cp); num_re = 2 * cell.nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cell.cp);
input = malloc(num_re * sizeof(cf_t)); input = malloc(num_re * sizeof(cf_t));
if (!input) { if (!input) {
@ -154,11 +154,11 @@ int main(int argc, char **argv) {
srslte_refsignal_cs_put_sf(cell, n_port, srslte_refsignal_cs_put_sf(cell, n_port,
est.csr_signal.pilots[n_port/2][sf_idx], input); est.csr_signal.pilots[n_port/2][sf_idx], input);
for (i=0;i<2*CP_NSYMB(cell.cp);i++) { for (i=0;i<2*SRSLTE_CP_NSYMB(cell.cp);i++) {
for (j=0;j<cell.nof_prb * RE_X_RB;j++) { for (j=0;j<cell.nof_prb * SRSLTE_NRE;j++) {
float x = -1+(float) i/CP_NSYMB(cell.cp) + cosf(2 * M_PI * (float) j/cell.nof_prb/RE_X_RB); float x = -1+(float) i/SRSLTE_CP_NSYMB(cell.cp) + cosf(2 * M_PI * (float) j/cell.nof_prb/SRSLTE_NRE);
h[i*cell.nof_prb * RE_X_RB+j] = (3+x) * cexpf(I * x); h[i*cell.nof_prb * SRSLTE_NRE+j] = (3+x) * cexpf(I * x);
input[i*cell.nof_prb * RE_X_RB+j] *= h[i*cell.nof_prb * RE_X_RB+j]; input[i*cell.nof_prb * SRSLTE_NRE+j] *= h[i*cell.nof_prb * SRSLTE_NRE+j];
} }
} }

@ -65,7 +65,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
srslte_cell_t cell; srslte_cell_t cell;
srslte_chest_dl_t chest; srslte_chest_dl_t chest;
precoding_t cheq; precoding_t cheq;
cf_t *input_signal = NULL, *output_signal[MAX_LAYERS]; cf_t *input_signal = NULL, *output_signal[SRSLTE_MAX_LAYERS];
cf_t *output_signal2 = NULL; cf_t *output_signal2 = NULL;
cf_t *ce[SRSLTE_MAX_PORTS]; cf_t *ce[SRSLTE_MAX_PORTS];
double *outr0=NULL, *outi0=NULL; double *outr0=NULL, *outi0=NULL;
@ -85,12 +85,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
cell.id = (uint32_t) *((double*) mxGetPr(CELLID)); cell.id = (uint32_t) *((double*) mxGetPr(CELLID));
cell.nof_prb = mxGetM(INPUT)/RE_X_RB; cell.nof_prb = mxGetM(INPUT)/SRSLTE_NRE;
cell.nof_ports = (uint32_t) *((double*) mxGetPr(PORTS)); cell.nof_ports = (uint32_t) *((double*) mxGetPr(PORTS));
if ((mxGetN(INPUT)%14) == 0) { if ((mxGetN(INPUT)%14) == 0) {
cell.cp = CPNORM; cell.cp = SRSLTE_SRSLTE_CP_NORM;
} else if ((mxGetN(INPUT)%12)!=0) { } else if ((mxGetN(INPUT)%12)!=0) {
cell.cp = CPEXT; cell.cp = SRSLTE_SRSLTE_CP_EXT;
} else { } else {
mexErrMsgTxt("Invalid number of symbols\n"); mexErrMsgTxt("Invalid number of symbols\n");
help(); help();
@ -103,7 +103,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
int nsubframes; int nsubframes;
if (cell.cp == CPNORM) { if (cell.cp == SRSLTE_SRSLTE_CP_NORM) {
nsubframes = mxGetN(INPUT)/14; nsubframes = mxGetN(INPUT)/14;
} else { } else {
nsubframes = mxGetN(INPUT)/12; nsubframes = mxGetN(INPUT)/12;
@ -151,7 +151,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
double *ini=(double *)mxGetPi(INPUT); double *ini=(double *)mxGetPi(INPUT);
/** Allocate input buffers */ /** Allocate input buffers */
int nof_re = 2*CP_NSYMB(cell.cp)*cell.nof_prb*RE_X_RB; int nof_re = 2*SRSLTE_CP_NSYMB(cell.cp)*cell.nof_prb*SRSLTE_NRE;
for (i=0;i<SRSLTE_MAX_PORTS;i++) { for (i=0;i<SRSLTE_MAX_PORTS;i++) {
ce[i] = vec_malloc(nof_re * sizeof(cf_t)); ce[i] = vec_malloc(nof_re * sizeof(cf_t));
} }

@ -65,7 +65,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexErrMsgTxt("Field NCellID not found in UE config\n"); mexErrMsgTxt("Field NCellID not found in UE config\n");
return; return;
} }
cell.cp = CPNORM; cell.cp = SRSLTE_SRSLTE_CP_NORM;
cell.nof_ports = 1; cell.nof_ports = 1;
if (mexutils_read_uint32_struct(UECFG, "NSubframe", &sf_idx)) { if (mexutils_read_uint32_struct(UECFG, "NSubframe", &sf_idx)) {
@ -123,17 +123,17 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexPrintf("cyclic_shift_for_drms: %d, ",pusch_cfg.cyclic_shift_for_drms); mexPrintf("cyclic_shift_for_drms: %d, ",pusch_cfg.cyclic_shift_for_drms);
mexPrintf("delta_ss: %d, ",pusch_cfg.delta_ss); mexPrintf("delta_ss: %d, ",pusch_cfg.delta_ss);
cf_t *signal = vec_malloc(2*RE_X_RB*nof_prb*sizeof(cf_t)); cf_t *signal = vec_malloc(2*SRSLTE_NRE*nof_prb*sizeof(cf_t));
if (!signal) { if (!signal) {
perror("malloc"); perror("malloc");
return; return;
} }
cf_t *sf_symbols = vec_malloc(SF_LEN_RE(cell.nof_prb, cell.cp)*sizeof(cf_t)); cf_t *sf_symbols = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp)*sizeof(cf_t));
if (!sf_symbols) { if (!sf_symbols) {
perror("malloc"); perror("malloc");
return; return;
} }
bzero(sf_symbols, SF_LEN_RE(cell.nof_prb, cell.cp)*sizeof(cf_t)); 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); //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_pusch_gen(&refs, &pusch_cfg, nof_prb, sf_idx, signal);
uint32_t n_prb[2]; uint32_t n_prb[2];
@ -141,7 +141,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
n_prb[1] = prbset[0]; n_prb[1] = prbset[0];
srslte_refsignal_drms_pusch_put(&refs, &pusch_cfg, signal, nof_prb, n_prb, sf_symbols); srslte_refsignal_drms_pusch_put(&refs, &pusch_cfg, signal, nof_prb, n_prb, sf_symbols);
if (nlhs >= 1) { if (nlhs >= 1) {
mexutils_write_cf(sf_symbols, &plhs[0], SF_LEN_RE(cell.nof_prb, cell.cp), 1); mexutils_write_cf(sf_symbols, &plhs[0], SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp), 1);
} }
srslte_refsignal_ul_free(&refs); srslte_refsignal_ul_free(&refs);

@ -37,7 +37,7 @@ srslte_cell_t cell = {
100, // nof_prb 100, // nof_prb
SRSLTE_MAX_PORTS, // nof_ports SRSLTE_MAX_PORTS, // nof_ports
1, // cell_id 1, // cell_id
CPNORM // cyclic prefix SRSLTE_SRSLTE_CP_NORM // cyclic prefix
}; };
void usage(char *prog) { void usage(char *prog) {
@ -59,7 +59,7 @@ void parse_args(int argc, char **argv) {
cell.nof_prb = atoi(argv[optind]); cell.nof_prb = atoi(argv[optind]);
break; break;
case 'e': case 'e':
cell.cp = CPEXT; cell.cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
case 'c': case 'c':
cell.id = atoi(argv[optind]); cell.id = atoi(argv[optind]);
@ -82,7 +82,7 @@ int main(int argc, char **argv) {
parse_args(argc,argv); parse_args(argc,argv);
signal = malloc(2 * RE_X_RB * cell.nof_prb * sizeof(cf_t)); signal = malloc(2 * SRSLTE_NRE * cell.nof_prb * sizeof(cf_t));
if (!signal) { if (!signal) {
perror("malloc"); perror("malloc");
goto do_exit; goto do_exit;

@ -38,7 +38,7 @@
#include "srslte/utils/vector.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_fft_init_(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb, dft_dir_t dir) {
int symbol_sz = lte_symbol_sz(nof_prb); int symbol_sz = srslte_symbol_sz(nof_prb);
if (symbol_sz < 0) { if (symbol_sz < 0) {
fprintf(stderr, "Error: Invalid nof_prb=%d\n", nof_prb); fprintf(stderr, "Error: Invalid nof_prb=%d\n", nof_prb);
@ -58,16 +58,16 @@ int srslte_fft_init_(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb, dft_dir_
dft_plan_set_dc(&q->fft_plan, true); dft_plan_set_dc(&q->fft_plan, true);
q->symbol_sz = (uint32_t) symbol_sz; q->symbol_sz = (uint32_t) symbol_sz;
q->nof_symbols = CP_NSYMB(cp); q->nof_symbols = SRSLTE_CP_NSYMB(cp);
q->cp = cp; q->cp = cp;
q->freq_shift = false; q->freq_shift = false;
q->nof_re = nof_prb * RE_X_RB; q->nof_re = nof_prb * SRSLTE_NRE;
q->nof_guards = ((symbol_sz - q->nof_re) / 2); q->nof_guards = ((symbol_sz - q->nof_re) / 2);
q->slot_sz = SLOT_LEN(symbol_sz); q->slot_sz = SRSLTE_SLOT_LEN(symbol_sz);
DEBUG("Init %s symbol_sz=%d, nof_symbols=%d, cp=%s, nof_re=%d, nof_guards=%d\n", 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==FORWARD?"FFT":"iFFT", q->symbol_sz, q->nof_symbols,
q->cp==CPNORM?"Normal":"Extended", q->nof_re, q->nof_guards); q->cp==SRSLTE_SRSLTE_CP_NORM?"Normal":"Extended", q->nof_re, q->nof_guards);
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
@ -114,7 +114,7 @@ int lte_ifft_init(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb) {
* Caution: This function shall not be called during run-time * Caution: This function shall not be called during run-time
*/ */
int srslte_fft_set_freq_shift(srslte_fft_t *q, float freq_shift) { int srslte_fft_set_freq_shift(srslte_fft_t *q, float freq_shift) {
q->shift_buffer = vec_malloc(sizeof(cf_t) * SF_LEN(q->symbol_sz)); q->shift_buffer = vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN(q->symbol_sz));
if (!q->shift_buffer) { if (!q->shift_buffer) {
perror("malloc"); perror("malloc");
return -1; return -1;
@ -122,7 +122,7 @@ int srslte_fft_set_freq_shift(srslte_fft_t *q, float freq_shift) {
cf_t *ptr = q->shift_buffer; cf_t *ptr = q->shift_buffer;
for (uint32_t n=0;n<2;n++) { for (uint32_t n=0;n<2;n++) {
for (uint32_t i=0;i<q->nof_symbols;i++) { for (uint32_t i=0;i<q->nof_symbols;i++) {
uint32_t cplen = CP_ISNORM(q->cp)?CP_NORM(i, q->symbol_sz):CP_EXT(q->symbol_sz); uint32_t cplen = SRSLTE_CP_ISNORM(q->cp)?SRSLTE_CP_NORM(i, q->symbol_sz):SRSLTE_CP_EXT(q->symbol_sz);
for (uint32_t t=0;t<q->symbol_sz+cplen;t++) { for (uint32_t t=0;t<q->symbol_sz+cplen;t++) {
ptr[t] = cexpf(I*2*M_PI*((float) t-(float)cplen)*freq_shift/q->symbol_sz); ptr[t] = cexpf(I*2*M_PI*((float) t-(float)cplen)*freq_shift/q->symbol_sz);
} }
@ -148,7 +148,7 @@ void lte_ifft_free(srslte_fft_t *q) {
void srslte_fft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) { void srslte_fft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) {
uint32_t i; uint32_t i;
for (i=0;i<q->nof_symbols;i++) { for (i=0;i<q->nof_symbols;i++) {
input += CP_ISNORM(q->cp)?CP_NORM(i, q->symbol_sz):CP_EXT(q->symbol_sz); input += SRSLTE_CP_ISNORM(q->cp)?SRSLTE_CP_NORM(i, q->symbol_sz):SRSLTE_CP_EXT(q->symbol_sz);
dft_run_c(&q->fft_plan, input, q->tmp); dft_run_c(&q->fft_plan, input, q->tmp);
memcpy(output, &q->tmp[q->nof_guards], q->nof_re * sizeof(cf_t)); memcpy(output, &q->tmp[q->nof_guards], q->nof_re * sizeof(cf_t));
input += q->symbol_sz; input += q->symbol_sz;
@ -172,7 +172,7 @@ void srslte_fft_run_sf(srslte_fft_t *q, cf_t *input, cf_t *output) {
void lte_ifft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) { void lte_ifft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) {
uint32_t i, cp_len; uint32_t i, cp_len;
for (i=0;i<q->nof_symbols;i++) { for (i=0;i<q->nof_symbols;i++) {
cp_len = CP_ISNORM(q->cp)?CP_NORM(i, q->symbol_sz):CP_EXT(q->symbol_sz); cp_len = SRSLTE_CP_ISNORM(q->cp)?SRSLTE_CP_NORM(i, q->symbol_sz):SRSLTE_CP_EXT(q->symbol_sz);
memcpy(&q->tmp[q->nof_guards], input, q->nof_re * sizeof(cf_t)); memcpy(&q->tmp[q->nof_guards], input, q->nof_re * sizeof(cf_t));
dft_run_c(&q->fft_plan, q->tmp, &output[cp_len]); dft_run_c(&q->fft_plan, q->tmp, &output[cp_len]);
input += q->nof_re; input += q->nof_re;

@ -34,7 +34,7 @@
#include "srslte/common/phy_common.h" #include "srslte/common/phy_common.h"
const uint32_t tc_cb_sizes[NOF_TC_CB_SIZES] = { 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, const uint32_t tc_cb_sizes[SRSLTE_NOF_TC_CB_SIZES] = { 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120,
128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232,
240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328, 336, 344, 240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328, 336, 344,
352, 360, 368, 376, 384, 392, 400, 408, 416, 424, 432, 440, 448, 456, 352, 360, 368, 376, 384, 392, 400, 408, 416, 424, 432, 440, 448, 456,
@ -53,7 +53,7 @@ const uint32_t tc_cb_sizes[NOF_TC_CB_SIZES] = { 40, 48, 56, 64, 72, 80, 88, 96,
/* Returns true if the structure pointed by cell has valid parameters /* Returns true if the structure pointed by cell has valid parameters
*/ */
bool lte_cellid_isvalid(uint32_t cell_id) { bool srslte_cellid_isvalid(uint32_t cell_id) {
if (cell_id < 504) { if (cell_id < 504) {
return true; return true;
} else { } else {
@ -61,25 +61,25 @@ bool lte_cellid_isvalid(uint32_t cell_id) {
} }
} }
bool lte_nofprb_isvalid(uint32_t nof_prb) { bool srslte_nofprb_isvalid(uint32_t nof_prb) {
if (nof_prb >= 6 && nof_prb <= MAX_PRB) { if (nof_prb >= 6 && nof_prb <= SRSLTE_MAX_PRB) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
bool lte_cell_isvalid(srslte_cell_t *cell) { bool srslte_cell_isvalid(srslte_cell_t *cell) {
return lte_cellid_isvalid(cell->id) && return srslte_cellid_isvalid(cell->id) &&
lte_portid_isvalid(cell->nof_ports) && srslte_portid_isvalid(cell->nof_ports) &&
lte_nofprb_isvalid(cell->nof_prb); srslte_nofprb_isvalid(cell->nof_prb);
} }
void lte_cell_fprint(FILE *stream, srslte_cell_t *cell) { void srslte_cell_fprint(FILE *stream, srslte_cell_t *cell) {
fprintf(stream, "PCI: %d, CP: %s, PRB: %d, Ports: %d\n", cell->id, lte_cp_string(cell->cp), cell->nof_prb, cell->nof_ports); fprintf(stream, "PCI: %d, CP: %s, PRB: %d, Ports: %d\n", cell->id, srslte_cp_string(cell->cp), cell->nof_prb, cell->nof_ports);
} }
bool lte_sfidx_isvalid(uint32_t sf_idx) { bool srslte_sfidx_isvalid(uint32_t sf_idx) {
if (sf_idx <= SRSLTE_NSUBFRAMES_X_FRAME) { if (sf_idx <= SRSLTE_NSUBFRAMES_X_FRAME) {
return true; return true;
} else { } else {
@ -87,7 +87,7 @@ bool lte_sfidx_isvalid(uint32_t sf_idx) {
} }
} }
bool lte_portid_isvalid(uint32_t port_id) { bool srslte_portid_isvalid(uint32_t port_id) {
if (port_id <= SRSLTE_MAX_PORTS) { if (port_id <= SRSLTE_MAX_PORTS) {
return true; return true;
} else { } else {
@ -95,7 +95,7 @@ bool lte_portid_isvalid(uint32_t port_id) {
} }
} }
bool lte_N_id_2_isvalid(uint32_t N_id_2) { bool srslte_N_id_2_isvalid(uint32_t N_id_2) {
if (N_id_2 < 3) { if (N_id_2 < 3) {
return true; return true;
} else { } else {
@ -103,7 +103,7 @@ bool lte_N_id_2_isvalid(uint32_t N_id_2) {
} }
} }
bool lte_N_id_1_isvalid(uint32_t N_id_1) { bool srslte_N_id_1_isvalid(uint32_t N_id_1) {
if (N_id_1 < 169) { if (N_id_1 < 169) {
return true; return true;
} else { } else {
@ -115,16 +115,16 @@ bool lte_N_id_1_isvalid(uint32_t N_id_1) {
/* /*
* Returns Turbo coder interleaver size for Table 5.1.3-3 (36.212) index * Returns Turbo coder interleaver size for Table 5.1.3-3 (36.212) index
*/ */
int lte_cb_size(uint32_t index) { int srslte_cb_size(uint32_t index) {
if (index < NOF_TC_CB_SIZES) { if (index < SRSLTE_NOF_TC_CB_SIZES) {
return (int) tc_cb_sizes[index]; return (int) tc_cb_sizes[index];
} else { } else {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
bool lte_cb_size_isvalid(uint32_t size) { bool srslte_cb_size_isvalid(uint32_t size) {
for (int i=0;i<NOF_TC_CB_SIZES;i++) { for (int i=0;i<SRSLTE_NOF_TC_CB_SIZES;i++) {
if (tc_cb_sizes[i] == size) { if (tc_cb_sizes[i] == size) {
return true; return true;
} }
@ -132,7 +132,7 @@ bool lte_cb_size_isvalid(uint32_t size) {
return false; return false;
} }
char *lte_mod_string(lte_mod_t mod) { char *srslte_mod_string(srslte_mod_t mod) {
switch (mod) { switch (mod) {
case LTE_BPSK: case LTE_BPSK:
return "BPSK"; return "BPSK";
@ -147,7 +147,7 @@ char *lte_mod_string(lte_mod_t mod) {
} }
} }
uint32_t lte_mod_bits_x_symbol(lte_mod_t mod) { uint32_t srslte_mod_bits_x_symbol(srslte_mod_t mod) {
switch (mod) { switch (mod) {
case LTE_BPSK: case LTE_BPSK:
return 1; return 1;
@ -162,8 +162,8 @@ uint32_t lte_mod_bits_x_symbol(lte_mod_t mod) {
} }
} }
char *lte_cp_string(srslte_cp_t cp) { char *srslte_cp_string(srslte_cp_t cp) {
if (cp == CPNORM) { if (cp == SRSLTE_SRSLTE_CP_NORM) {
return "Normal"; return "Normal";
} else { } else {
return "Extended"; return "Extended";
@ -171,7 +171,7 @@ char *lte_cp_string(srslte_cp_t cp) {
} }
/* Returns the new time advance N_ta_new as specified in Section 4.2.3 of 36.213 */ /* Returns the new time advance N_ta_new as specified in Section 4.2.3 of 36.213 */
uint32_t lte_N_ta_new(uint32_t N_ta_old, uint32_t ta) { uint32_t srslte_N_ta_new(uint32_t N_ta_old, uint32_t ta) {
ta &= 63; ta &= 63;
int n_ta_new = N_ta_old + ((float) ta - 31) * 16; int n_ta_new = N_ta_old + ((float) ta - 31) * 16;
@ -188,7 +188,7 @@ uint32_t lte_N_ta_new(uint32_t N_ta_old, uint32_t ta) {
/* Returns the new time advance as indicated by the random access response /* Returns the new time advance as indicated by the random access response
* as specified in Section 4.2.3 of 36.213 */ * as specified in Section 4.2.3 of 36.213 */
uint32_t lte_N_ta_new_rar(uint32_t ta) { uint32_t srssrslte_N_ta_new_rar(uint32_t ta) {
if (ta > 1282) { if (ta > 1282) {
ta = 1282; ta = 1282;
} }
@ -198,21 +198,21 @@ uint32_t lte_N_ta_new_rar(uint32_t ta) {
/* /*
* Finds index of minimum K>=long_cb in Table 5.1.3-3 of 36.212 * Finds index of minimum K>=long_cb in Table 5.1.3-3 of 36.212
*/ */
int lte_find_cb_index(uint32_t long_cb) { int srslte_find_cb_index(uint32_t long_cb) {
int j = 0; int j = 0;
while (j < NOF_TC_CB_SIZES && tc_cb_sizes[j] < long_cb) { while (j < SRSLTE_NOF_TC_CB_SIZES && tc_cb_sizes[j] < long_cb) {
j++; j++;
} }
if (j == NOF_TC_CB_SIZES) { if (j == SRSLTE_NOF_TC_CB_SIZES) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} else { } else {
return j; return j;
} }
} }
int lte_sampling_freq_hz(uint32_t nof_prb) { int srslte_sampling_freq_hz(uint32_t nof_prb) {
int n = lte_symbol_sz(nof_prb); int n = srslte_symbol_sz(nof_prb);
if (n == -1) { if (n == -1) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} else { } else {
@ -220,7 +220,7 @@ int lte_sampling_freq_hz(uint32_t nof_prb) {
} }
} }
int lte_symbol_sz(uint32_t nof_prb) { int srslte_symbol_sz(uint32_t nof_prb) {
if (nof_prb<=0) { if (nof_prb<=0) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -240,7 +240,7 @@ int lte_symbol_sz(uint32_t nof_prb) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
bool lte_symbol_sz_isvalid(uint32_t symbol_sz) { bool srssrslte_symbol_sz_isvalid(uint32_t symbol_sz) {
if (symbol_sz == 128 || if (symbol_sz == 128 ||
symbol_sz == 256 || symbol_sz == 256 ||
symbol_sz == 512 || symbol_sz == 512 ||
@ -252,7 +252,7 @@ bool lte_symbol_sz_isvalid(uint32_t symbol_sz) {
} }
} }
uint32_t lte_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports) { uint32_t srslte_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports) {
if (nof_ports == 1 && symbol_id==0) { if (nof_ports == 1 && symbol_id==0) {
return (cell_id+3) % 6; return (cell_id+3) % 6;
} else { } else {
@ -261,33 +261,33 @@ uint32_t lte_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports) {
} }
/* Returns the number of available RE per PRB */ /* Returns the number of available RE per PRB */
uint32_t lte_re_x_prb(uint32_t ns, uint32_t symbol, uint32_t nof_ports, uint32_t nof_symbols) { uint32_t srslte_re_x_prb(uint32_t ns, uint32_t symbol, uint32_t nof_ports, uint32_t nof_symbols) {
if (symbol == 0) { if (symbol == 0) {
if (((ns % 2) == 0) || (ns == 1)) { if (((ns % 2) == 0) || (ns == 1)) {
return RE_X_RB - 4; return SRSLTE_NRE - 4;
} else { } else {
if (nof_ports == 1) { if (nof_ports == 1) {
return RE_X_RB - 2; return SRSLTE_NRE - 2;
} else { } else {
return RE_X_RB - 4; return SRSLTE_NRE - 4;
} }
} }
} else if (symbol == 1) { } else if (symbol == 1) {
if (ns == 1) { if (ns == 1) {
return RE_X_RB - 4; return SRSLTE_NRE - 4;
} else if (nof_ports == 4) { } else if (nof_ports == 4) {
return RE_X_RB - 4; return SRSLTE_NRE - 4;
} else { } else {
return RE_X_RB; return SRSLTE_NRE;
} }
} else if (symbol == nof_symbols - 3) { } else if (symbol == nof_symbols - 3) {
if (nof_ports == 1) { if (nof_ports == 1) {
return RE_X_RB - 2; return SRSLTE_NRE - 2;
} else { } else {
return RE_X_RB - 4; return SRSLTE_NRE - 4;
} }
} else { } else {
return RE_X_RB; return SRSLTE_NRE;
} }
} }
@ -300,7 +300,7 @@ struct lte_band {
enum band_geographical_area area; enum band_geographical_area area;
}; };
struct lte_band lte_bands[NOF_LTE_BANDS] = { struct lte_band lte_bands[SRSLTE_NOF_LTE_BANDS] = {
{1, 2110, 0, 599, ALL}, {1, 2110, 0, 599, ALL},
{2, 1930, 600, 1199, NAR}, {2, 1930, 600, 1199, NAR},
{3, 1805, 1200, 1949, ALL}, {3, 1805, 1200, 1949, ALL},
@ -333,7 +333,7 @@ struct lte_band lte_bands[NOF_LTE_BANDS] = {
}; };
#define EOF_BAND 9919 #define EOF_BAND 9919
int lte_str2mimotype(char *mimo_type_str, lte_mimo_type_t *type) { int srslte_str2mimotype(char *mimo_type_str, srslte_mimo_type_t *type) {
if (!strcmp(mimo_type_str, "single")) { if (!strcmp(mimo_type_str, "single")) {
*type = SINGLE_ANTENNA; *type = SINGLE_ANTENNA;
} else if (!strcmp(mimo_type_str, "diversity")) { } else if (!strcmp(mimo_type_str, "diversity")) {
@ -346,18 +346,6 @@ int lte_str2mimotype(char *mimo_type_str, lte_mimo_type_t *type) {
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
char *lte_mimotype2str(lte_mimo_type_t type) {
switch(type) {
case SINGLE_ANTENNA:
return "single";
case TX_DIVERSITY:
return "diversity";
case SPATIAL_MULTIPLEX:
return "multiplex";
}
return NULL;
}
float get_fd(struct lte_band *band, uint32_t earfcn) { float get_fd(struct lte_band *band, uint32_t earfcn) {
if (earfcn >= band->earfcn_offset) { if (earfcn >= band->earfcn_offset) {
return band->fd_low_mhz + 0.1*(earfcn - band->earfcn_offset); return band->fd_low_mhz + 0.1*(earfcn - band->earfcn_offset);
@ -366,31 +354,31 @@ float get_fd(struct lte_band *band, uint32_t earfcn) {
} }
} }
float lte_band_fd(uint32_t earfcn) { float srslte_band_fd(uint32_t earfcn) {
uint32_t i; uint32_t i;
i=0; i=0;
while(i < NOF_LTE_BANDS && lte_bands[i].earfcn_offset<earfcn) { while(i < SRSLTE_NOF_LTE_BANDS && lte_bands[i].earfcn_offset<earfcn) {
i++; i++;
} }
if (i == NOF_LTE_BANDS) { if (i == SRSLTE_NOF_LTE_BANDS) {
fprintf(stderr, "Error: EARFCN %d not found\n", earfcn); fprintf(stderr, "Error: EARFCN %d not found\n", earfcn);
return -1.0; return -1.0;
} }
return get_fd(&lte_bands[i], earfcn); return get_fd(&lte_bands[i], earfcn);
} }
int lte_band_get_fd_band_all(uint32_t band, lte_earfcn_t *earfcn, uint32_t max_elems) { int srslte_band_get_fd_band_all(uint32_t band, srslte_earfcn_t *earfcn, uint32_t max_elems) {
return lte_band_get_fd_band(band, earfcn, -1, -1, max_elems); return srslte_band_get_fd_band(band, earfcn, -1, -1, max_elems);
} }
int lte_band_get_fd_band(uint32_t band, lte_earfcn_t *earfcn, int start_earfcn, int end_earfcn, uint32_t max_elems) { int srslte_band_get_fd_band(uint32_t band, srslte_earfcn_t *earfcn, int start_earfcn, int end_earfcn, uint32_t max_elems) {
uint32_t i, j; uint32_t i, j;
uint32_t nof_earfcn; uint32_t nof_earfcn;
i=0; i=0;
while(i < NOF_LTE_BANDS && lte_bands[i].band != band) { while(i < SRSLTE_NOF_LTE_BANDS && lte_bands[i].band != band) {
i++; i++;
} }
if (i == NOF_LTE_BANDS) { if (i == SRSLTE_NOF_LTE_BANDS) {
fprintf(stderr, "Error: Invalid band %d\n", band); fprintf(stderr, "Error: Invalid band %d\n", band);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -422,13 +410,13 @@ int lte_band_get_fd_band(uint32_t band, lte_earfcn_t *earfcn, int start_earfcn,
return (int) j; return (int) j;
} }
int lte_band_get_fd_region(enum band_geographical_area region, lte_earfcn_t *earfcn, uint32_t max_elems) { int srslte_band_get_fd_region(enum band_geographical_area region, srslte_earfcn_t *earfcn, uint32_t max_elems) {
uint32_t i; uint32_t i;
int n; int n;
int nof_fd = 0; int nof_fd = 0;
for (i=0;i<NOF_LTE_BANDS && max_elems > 0;i++) { for (i=0;i<SRSLTE_NOF_LTE_BANDS && max_elems > 0;i++) {
if (lte_bands[i].area == region) { if (lte_bands[i].area == region) {
n = lte_band_get_fd_band(i, &earfcn[nof_fd], -1, -1, max_elems); n = srslte_band_get_fd_band(i, &earfcn[nof_fd], -1, -1, max_elems);
if (n != -1) { if (n != -1) {
nof_fd += n; nof_fd += n;
max_elems -= n; max_elems -= n;

@ -35,7 +35,7 @@
#include "srslte/srslte.h" #include "srslte/srslte.h"
int nof_prb = -1; int nof_prb = -1;
srslte_cp_t cp = CPNORM; srslte_cp_t cp = SRSLTE_SRSLTE_CP_NORM;
void usage(char *prog) { void usage(char *prog) {
printf("Usage: %s\n", prog); printf("Usage: %s\n", prog);
@ -51,7 +51,7 @@ void parse_args(int argc, char **argv) {
nof_prb = atoi(argv[optind]); nof_prb = atoi(argv[optind]);
break; break;
case 'e': case 'e':
cp = CPEXT; cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -78,7 +78,7 @@ int main(int argc, char **argv) {
max_prb = nof_prb; max_prb = nof_prb;
} }
while(n_prb <= max_prb) { while(n_prb <= max_prb) {
n_re = CP_NSYMB(cp) * n_prb * RE_X_RB; n_re = SRSLTE_CP_NSYMB(cp) * n_prb * SRSLTE_NRE;
printf("Running test for %d PRB, %d RE... ", n_prb, n_re);fflush(stdout); printf("Running test for %d PRB, %d RE... ", n_prb, n_re);fflush(stdout);
@ -87,7 +87,7 @@ int main(int argc, char **argv) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);
} }
outfft = malloc(sizeof(cf_t) * SLOT_LEN(lte_symbol_sz(n_prb))); outfft = malloc(sizeof(cf_t) * SRSLTE_SLOT_LEN(srslte_symbol_sz(n_prb)));
if (!outfft) { if (!outfft) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);

@ -40,7 +40,7 @@
* *
************************************************/ ************************************************/
const uint32_t f1_list[NOF_TC_CB_SIZES] = { 3, 7, 19, 7, 7, 11, 5, 11, 7, 41, 103, const uint32_t f1_list[SRSLTE_NOF_TC_CB_SIZES] = { 3, 7, 19, 7, 7, 11, 5, 11, 7, 41, 103,
15, 9, 17, 9, 21, 101, 21, 57, 23, 13, 27, 11, 27, 85, 29, 33, 15, 17, 33, 15, 9, 17, 9, 21, 101, 21, 57, 23, 13, 27, 11, 27, 85, 29, 33, 15, 17, 33,
103, 19, 19, 37, 19, 21, 21, 115, 193, 21, 133, 81, 45, 23, 243, 151, 155, 103, 19, 19, 37, 19, 21, 21, 115, 193, 21, 133, 81, 45, 23, 243, 151, 155,
25, 51, 47, 91, 29, 29, 247, 29, 89, 91, 157, 55, 31, 17, 35, 227, 65, 19, 25, 51, 47, 91, 29, 29, 247, 29, 89, 91, 157, 55, 31, 17, 35, 227, 65, 19,
@ -53,7 +53,7 @@ const uint32_t f1_list[NOF_TC_CB_SIZES] = { 3, 7, 19, 7, 7, 11, 5, 11, 7, 41, 10
39, 127, 39, 39, 31, 113, 41, 251, 43, 21, 43, 45, 45, 161, 89, 323, 47, 23, 39, 127, 39, 39, 31, 113, 41, 251, 43, 21, 43, 45, 45, 161, 89, 323, 47, 23,
47, 263 }; 47, 263 };
const uint32_t f2_list[NOF_TC_CB_SIZES] = { 10, 12, 42, 16, 18, 20, 22, 24, 26, 84, const uint32_t f2_list[SRSLTE_NOF_TC_CB_SIZES] = { 10, 12, 42, 16, 18, 20, 22, 24, 26, 84,
90, 32, 34, 108, 38, 120, 84, 44, 46, 48, 50, 52, 36, 56, 58, 60, 62, 32, 90, 32, 34, 108, 38, 120, 84, 44, 46, 48, 50, 52, 36, 56, 58, 60, 62, 32,
198, 68, 210, 36, 74, 76, 78, 120, 82, 84, 86, 44, 90, 46, 94, 48, 98, 40, 198, 68, 210, 36, 74, 76, 78, 120, 82, 84, 86, 44, 90, 46, 94, 48, 98, 40,
102, 52, 106, 72, 110, 168, 114, 58, 118, 180, 122, 62, 84, 64, 66, 68, 420, 102, 52, 106, 72, 110, 168, 114, 58, 118, 180, 122, 62, 84, 64, 66, 68, 420,
@ -76,7 +76,7 @@ int tc_interl_LTE_gen(tc_interl_t *h, uint32_t long_cb) {
return -1; return -1;
} }
cb_table_idx = lte_find_cb_index(long_cb); cb_table_idx = srslte_find_cb_index(long_cb);
if (cb_table_idx == -1) { if (cb_table_idx == -1) {
fprintf(stderr, "Can't find long_cb=%d in valid TC CB table\n", long_cb); fprintf(stderr, "Can't find long_cb=%d in valid TC CB table\n", long_cb);
return -1; return -1;

@ -40,10 +40,10 @@ typedef struct {
static expected_word_t expected_words[] = { static expected_word_t expected_words[] = {
{5001, 24, LTE_CRC24A, 1, 0x1C5C97}, // LTE CRC24A (36.212 Sec 5.1.1) {5001, 24, SRSLTE_LTE_CRC24A, 1, 0x1C5C97}, // LTE CRC24A (36.212 Sec 5.1.1)
{5001, 24, LTE_CRC24B, 1, 0x36D1F0}, // LTE CRC24B {5001, 24, SRSLTE_LTE_CRC24B, 1, 0x36D1F0}, // LTE CRC24B
{5001, 16, LTE_CRC16, 1, 0x7FF4}, // LTE CRC16: 0x7FF4 {5001, 16, SRSLTE_LTE_CRC16, 1, 0x7FF4}, // LTE CRC16: 0x7FF4
{5001, 8, LTE_CRC8, 1, 0xF0}, // LTE CRC8 0xF8 {5001, 8, SRSLTE_LTE_CRC8, 1, 0xF0}, // LTE CRC8 0xF8
{-1, -1, 0, 0, 0} {-1, -1, 0, 0, 0}
}; };

@ -152,7 +152,7 @@ int main(int argc, char **argv) {
if (test_known_data) { if (test_known_data) {
frame_length = KNOWN_DATA_LEN; frame_length = KNOWN_DATA_LEN;
} else { } else {
frame_length = lte_cb_size(lte_find_cb_index(frame_length)); frame_length = srslte_cb_size(srslte_find_cb_index(frame_length));
} }
coded_length = 3 * (frame_length) + TOTALTAIL; coded_length = 3 * (frame_length) + TOTALTAIL;

@ -66,7 +66,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
nof_bits = (nof_symbols-12)/3; nof_bits = (nof_symbols-12)/3;
if (!lte_cb_size_isvalid(nof_bits)) { if (!srslte_cb_size_isvalid(nof_bits)) {
mexErrMsgTxt("Invalid codeblock size\n"); mexErrMsgTxt("Invalid codeblock size\n");
return; return;
} }

@ -46,17 +46,17 @@ int dft_precoding_init(dft_precoding_t *q, uint32_t max_prb)
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
bzero(q, sizeof(dft_precoding_t)); bzero(q, sizeof(dft_precoding_t));
if (max_prb <= MAX_PRB) { if (max_prb <= SRSLTE_MAX_PRB) {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
for (uint32_t i=1;i<max_prb;i++) { for (uint32_t i=1;i<max_prb;i++) {
if(dft_precoding_valid_prb(i)) { if(dft_precoding_valid_prb(i)) {
DEBUG("Initiating DFT precoding plan for %d PRBs\n", i); DEBUG("Initiating DFT precoding plan for %d PRBs\n", i);
if (dft_plan_c(&q->dft_plan[i], i*RE_X_RB, FORWARD)) { if (dft_plan_c(&q->dft_plan[i], i*SRSLTE_NRE, FORWARD)) {
fprintf(stderr, "Error: Creating DFT plan %d\n",i); fprintf(stderr, "Error: Creating DFT plan %d\n",i);
goto clean_exit; goto clean_exit;
} }
dft_plan_set_norm(&q->dft_plan[i], true); dft_plan_set_norm(&q->dft_plan[i], true);
if (dft_plan_c(&q->idft_plan[i], i*RE_X_RB, BACKWARD)) { if (dft_plan_c(&q->idft_plan[i], i*SRSLTE_NRE, BACKWARD)) {
fprintf(stderr, "Error: Creating DFT plan %d\n",i); fprintf(stderr, "Error: Creating DFT plan %d\n",i);
goto clean_exit; goto clean_exit;
} }
@ -105,7 +105,7 @@ int dft_precoding(dft_precoding_t *q, cf_t *input, cf_t *output,
} }
for (uint32_t i=0;i<nof_symbols;i++) { for (uint32_t i=0;i<nof_symbols;i++) {
dft_run_c(&q->dft_plan[nof_prb], &input[i*RE_X_RB*nof_prb], &output[i*RE_X_RB*nof_prb]); dft_run_c(&q->dft_plan[nof_prb], &input[i*SRSLTE_NRE*nof_prb], &output[i*SRSLTE_NRE*nof_prb]);
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -120,7 +120,7 @@ int dft_predecoding(dft_precoding_t *q, cf_t *input, cf_t *output,
} }
for (uint32_t i=0;i<nof_symbols;i++) { for (uint32_t i=0;i<nof_symbols;i++) {
dft_run_c(&q->dft_plan[nof_prb], &input[i*RE_X_RB*nof_prb], &output[i*RE_X_RB*nof_prb]); dft_run_c(&q->dft_plan[nof_prb], &input[i*SRSLTE_NRE*nof_prb], &output[i*SRSLTE_NRE*nof_prb]);
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;

@ -40,7 +40,7 @@ int layermap_single(cf_t *d, cf_t *x, int nof_symbols) {
return nof_symbols; return nof_symbols;
} }
int layermap_diversity(cf_t *d, cf_t *x[MAX_LAYERS], int nof_layers, int nof_symbols) { int layermap_diversity(cf_t *d, cf_t *x[SRSLTE_MAX_LAYERS], int nof_layers, int nof_symbols) {
int i, j; int i, j;
for (i=0;i<nof_symbols/nof_layers;i++) { for (i=0;i<nof_symbols/nof_layers;i++) {
for (j=0;j<nof_layers;j++) { for (j=0;j<nof_layers;j++) {
@ -50,8 +50,8 @@ int layermap_diversity(cf_t *d, cf_t *x[MAX_LAYERS], int nof_layers, int nof_sym
return i; return i;
} }
int layermap_multiplex(cf_t *d[MAX_CODEWORDS], cf_t *x[MAX_LAYERS], int nof_cw, int nof_layers, int layermap_multiplex(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_LAYERS], int nof_cw, int nof_layers,
int nof_symbols[MAX_CODEWORDS]) { int nof_symbols[SRSLTE_MAX_CODEWORDS]) {
if (nof_cw == 1) { if (nof_cw == 1) {
return layermap_diversity(d[0], x, nof_layers, nof_symbols[0]); return layermap_diversity(d[0], x, nof_layers, nof_symbols[0]);
} else { } else {
@ -77,15 +77,15 @@ int layermap_multiplex(cf_t *d[MAX_CODEWORDS], cf_t *x[MAX_LAYERS], int nof_cw,
* Based on 36.211 6.3.3 * Based on 36.211 6.3.3
* Returns the number of symbols per layer (M_symb^layer in the specs) * Returns the number of symbols per layer (M_symb^layer in the specs)
*/ */
int layermap_type(cf_t *d[MAX_CODEWORDS], cf_t *x[MAX_LAYERS], int nof_cw, int nof_layers, int layermap_type(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_LAYERS], int nof_cw, int nof_layers,
int nof_symbols[MAX_CODEWORDS], lte_mimo_type_t type) { int nof_symbols[SRSLTE_MAX_CODEWORDS], srslte_mimo_type_t type) {
if (nof_cw > MAX_CODEWORDS) { if (nof_cw > SRSLTE_MAX_CODEWORDS) {
fprintf(stderr, "Maximum number of codewords is %d (nof_cw=%d)\n", MAX_CODEWORDS, nof_cw); fprintf(stderr, "Maximum number of codewords is %d (nof_cw=%d)\n", SRSLTE_MAX_CODEWORDS, nof_cw);
return -1; return -1;
} }
if (nof_layers > MAX_LAYERS) { if (nof_layers > SRSLTE_MAX_LAYERS) {
fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", MAX_LAYERS, nof_layers); fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", SRSLTE_MAX_LAYERS, nof_layers);
return -1; return -1;
} }
if (nof_layers < nof_cw) { if (nof_layers < nof_cw) {
@ -134,7 +134,7 @@ int layerdemap_single(cf_t *x, cf_t *d, int nof_symbols) {
memcpy(d, x, sizeof(cf_t) * nof_symbols); memcpy(d, x, sizeof(cf_t) * nof_symbols);
return nof_symbols; return nof_symbols;
} }
int layerdemap_diversity(cf_t *x[MAX_LAYERS], cf_t *d, int nof_layers, int nof_layer_symbols) { int layerdemap_diversity(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d, int nof_layers, int nof_layer_symbols) {
int i, j; int i, j;
for (i=0;i<nof_layer_symbols;i++) { for (i=0;i<nof_layer_symbols;i++) {
for (j=0;j<nof_layers;j++) { for (j=0;j<nof_layers;j++) {
@ -144,8 +144,8 @@ int layerdemap_diversity(cf_t *x[MAX_LAYERS], cf_t *d, int nof_layers, int nof_l
return nof_layer_symbols * nof_layers; return nof_layer_symbols * nof_layers;
} }
int layerdemap_multiplex(cf_t *x[MAX_LAYERS], cf_t *d[MAX_CODEWORDS], int nof_layers, int nof_cw, int layerdemap_multiplex(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d[SRSLTE_MAX_CODEWORDS], int nof_layers, int nof_cw,
int nof_layer_symbols, int nof_symbols[MAX_CODEWORDS]) { int nof_layer_symbols, int nof_symbols[SRSLTE_MAX_CODEWORDS]) {
if (nof_cw == 1) { if (nof_cw == 1) {
return layerdemap_diversity(x, d[0], nof_layers, nof_layer_symbols); return layerdemap_diversity(x, d[0], nof_layers, nof_layer_symbols);
} else { } else {
@ -166,15 +166,15 @@ int layerdemap_multiplex(cf_t *x[MAX_LAYERS], cf_t *d[MAX_CODEWORDS], int nof_la
* Returns 0 on ok and saves the number of symbols per codeword (M_symb^(q) in the specs) in * Returns 0 on ok and saves the number of symbols per codeword (M_symb^(q) in the specs) in
* nof_symbols. Returns -1 on error * nof_symbols. Returns -1 on error
*/ */
int layerdemap_type(cf_t *x[MAX_LAYERS], cf_t *d[MAX_CODEWORDS], int nof_layers, int nof_cw, int layerdemap_type(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d[SRSLTE_MAX_CODEWORDS], int nof_layers, int nof_cw,
int nof_layer_symbols, int nof_symbols[MAX_CODEWORDS], lte_mimo_type_t type) { int nof_layer_symbols, int nof_symbols[SRSLTE_MAX_CODEWORDS], srslte_mimo_type_t type) {
if (nof_cw > MAX_CODEWORDS) { if (nof_cw > SRSLTE_MAX_CODEWORDS) {
fprintf(stderr, "Maximum number of codewords is %d (nof_cw=%d)\n", MAX_CODEWORDS, nof_cw); fprintf(stderr, "Maximum number of codewords is %d (nof_cw=%d)\n", SRSLTE_MAX_CODEWORDS, nof_cw);
return -1; return -1;
} }
if (nof_layers > MAX_LAYERS) { if (nof_layers > SRSLTE_MAX_LAYERS) {
fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", MAX_LAYERS, nof_layers); fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", SRSLTE_MAX_LAYERS, nof_layers);
return -1; return -1;
} }
if (nof_layers < nof_cw) { if (nof_layers < nof_cw) {

@ -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) /* ZF/MMSE STBC equalizer x=y(H'H+n0·I)^(-1)H' (ZF is n0=0.0)
*/ */
int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x[MAX_LAYERS], int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x[SRSLTE_MAX_LAYERS],
int nof_ports, int nof_symbols, float noise_estimate) int nof_ports, int nof_symbols, float noise_estimate)
{ {
int i; int i;
@ -240,17 +240,17 @@ int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf
} }
/* 36.211 v10.3.0 Section 6.3.4 */ /* 36.211 v10.3.0 Section 6.3.4 */
int predecoding_type(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x[MAX_LAYERS], int 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, lte_mimo_type_t type, float noise_estimate) { int nof_ports, int nof_layers, int nof_symbols, srslte_mimo_type_t type, float noise_estimate) {
if (nof_ports > SRSLTE_MAX_PORTS) { if (nof_ports > SRSLTE_MAX_PORTS) {
fprintf(stderr, "Maximum number of ports is %d (nof_ports=%d)\n", SRSLTE_MAX_PORTS, fprintf(stderr, "Maximum number of ports is %d (nof_ports=%d)\n", SRSLTE_MAX_PORTS,
nof_ports); nof_ports);
return -1; return -1;
} }
if (nof_layers > MAX_LAYERS) { if (nof_layers > SRSLTE_MAX_LAYERS) {
fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n",
MAX_LAYERS, nof_layers); SRSLTE_MAX_LAYERS, nof_layers);
return -1; return -1;
} }
@ -295,7 +295,7 @@ int precoding_single(precoding_t *q, cf_t *x, cf_t *y, int nof_symbols) {
memcpy(y, x, nof_symbols * sizeof(cf_t)); memcpy(y, x, nof_symbols * sizeof(cf_t));
return nof_symbols; return nof_symbols;
} }
int precoding_diversity(precoding_t *q, cf_t *x[MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_ports, int precoding_diversity(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_ports,
int nof_symbols) { int nof_symbols) {
int i; int i;
if (nof_ports == 2) { if (nof_ports == 2) {
@ -341,17 +341,17 @@ int precoding_diversity(precoding_t *q, cf_t *x[MAX_LAYERS], cf_t *y[SRSLTE_MAX_
} }
/* 36.211 v10.3.0 Section 6.3.4 */ /* 36.211 v10.3.0 Section 6.3.4 */
int precoding_type(precoding_t *q, cf_t *x[MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_layers, int 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, lte_mimo_type_t type) { int nof_ports, int nof_symbols, srslte_mimo_type_t type) {
if (nof_ports > SRSLTE_MAX_PORTS) { if (nof_ports > SRSLTE_MAX_PORTS) {
fprintf(stderr, "Maximum number of ports is %d (nof_ports=%d)\n", SRSLTE_MAX_PORTS, fprintf(stderr, "Maximum number of ports is %d (nof_ports=%d)\n", SRSLTE_MAX_PORTS,
nof_ports); nof_ports);
return -1; return -1;
} }
if (nof_layers > MAX_LAYERS) { if (nof_layers > SRSLTE_MAX_LAYERS) {
fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n", fprintf(stderr, "Maximum number of layers is %d (nof_layers=%d)\n",
MAX_LAYERS, nof_layers); SRSLTE_MAX_LAYERS, nof_layers);
return -1; return -1;
} }

@ -74,14 +74,14 @@ void parse_args(int argc, char **argv) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
int i, j, num_errors, symbols_layer; int i, j, num_errors, symbols_layer;
cf_t *d[MAX_CODEWORDS], *x[MAX_LAYERS], *dp[MAX_CODEWORDS]; cf_t *d[SRSLTE_MAX_CODEWORDS], *x[SRSLTE_MAX_LAYERS], *dp[SRSLTE_MAX_CODEWORDS];
lte_mimo_type_t type; srslte_mimo_type_t type;
int nof_symb_cw[MAX_CODEWORDS]; int nof_symb_cw[SRSLTE_MAX_CODEWORDS];
int n[2]; int n[2];
parse_args(argc, argv); parse_args(argc, argv);
if (lte_str2mimotype(mimo_type_name, &type)) { if (srslte_str2mimotype(mimo_type_name, &type)) {
fprintf(stderr, "Invalid MIMO type %s\n", mimo_type_name); fprintf(stderr, "Invalid MIMO type %s\n", mimo_type_name);
exit(-1); exit(-1);
} }

@ -79,19 +79,19 @@ void parse_args(int argc, char **argv) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
int i, j; int i, j;
float mse; float mse;
cf_t *x[MAX_LAYERS], *r[SRSLTE_MAX_PORTS], *y[SRSLTE_MAX_PORTS], *h[SRSLTE_MAX_PORTS], cf_t *x[SRSLTE_MAX_LAYERS], *r[SRSLTE_MAX_PORTS], *y[SRSLTE_MAX_PORTS], *h[SRSLTE_MAX_PORTS],
*xr[MAX_LAYERS]; *xr[SRSLTE_MAX_LAYERS];
lte_mimo_type_t type; srslte_mimo_type_t type;
precoding_t precoding; precoding_t precoding;
parse_args(argc, argv); parse_args(argc, argv);
if (nof_ports > SRSLTE_MAX_PORTS || nof_layers > MAX_LAYERS) { if (nof_ports > SRSLTE_MAX_PORTS || nof_layers > SRSLTE_MAX_LAYERS) {
fprintf(stderr, "Invalid number of layers or ports\n"); fprintf(stderr, "Invalid number of layers or ports\n");
exit(-1); exit(-1);
} }
if (lte_str2mimotype(mimo_type_name, &type)) { if (srslte_str2mimotype(mimo_type_name, &type)) {
fprintf(stderr, "Invalid MIMO type %s\n", mimo_type_name); fprintf(stderr, "Invalid MIMO type %s\n", mimo_type_name);
exit(-1); exit(-1);
} }

@ -37,7 +37,7 @@ void demod_hard_init(demod_hard_t* q) {
bzero((void*) q, sizeof(demod_hard_t)); bzero((void*) q, sizeof(demod_hard_t));
} }
void demod_hard_table_set(demod_hard_t* q, lte_mod_t mod) { void demod_hard_table_set(demod_hard_t* q, srslte_mod_t mod) {
q->mod = mod; q->mod = mod;
} }

@ -71,7 +71,7 @@ int modem_table_set(modem_table_t* q, cf_t* table, soft_table_t *soft_table, uin
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
int modem_table_lte(modem_table_t* q, lte_mod_t modulation, bool compute_soft_demod) { int modem_table_lte(modem_table_t* q, srslte_mod_t modulation, bool compute_soft_demod) {
switch(modulation) { switch(modulation) {
case LTE_BPSK: case LTE_BPSK:
q->nbits_x_symbol = 1; q->nbits_x_symbol = 1;

@ -40,7 +40,7 @@ time_t start, finish;
struct timeval x, y; struct timeval x, y;
int num_bits = 1000; int num_bits = 1000;
lte_mod_t modulation; srslte_mod_t modulation;
bool soft_output = false, soft_exact = false; bool soft_output = false, soft_exact = false;
void usage(char *prog) { void usage(char *prog) {

@ -38,7 +38,7 @@
int nof_frames = 10; int nof_frames = 10;
int num_bits = 1000; int num_bits = 1000;
lte_mod_t modulation = 10; srslte_mod_t modulation = 10;
void usage(char *prog) { void usage(char *prog) {
printf("Usage: %s [nfv] -m modulation (1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64)\n", prog); printf("Usage: %s [nfv] -m modulation (1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64)\n", prog);

@ -51,7 +51,7 @@ int dci_msg_to_ra_dl(dci_msg_t *msg, uint16_t msg_rnti,
if (msg != NULL && if (msg != NULL &&
ra_dl != NULL && ra_dl != NULL &&
lte_cell_isvalid(&cell) && srslte_cell_isvalid(&cell) &&
cfi > 0 && cfi > 0 &&
cfi < 4) cfi < 4)
{ {
@ -71,7 +71,7 @@ int dci_msg_to_ra_dl(dci_msg_t *msg, uint16_t msg_rnti,
bzero(ra_dl, sizeof(ra_pdsch_t)); bzero(ra_dl, sizeof(ra_pdsch_t));
bool crc_is_crnti = false; bool crc_is_crnti = false;
if (msg_rnti >= CRNTI_START && msg_rnti <= CRNTI_END) { if (msg_rnti >= SRSLTE_CRNTI_START && msg_rnti <= SRSLTE_CRNTI_END) {
crc_is_crnti = true; crc_is_crnti = true;
} }
if (dci_msg_unpack_pdsch(msg, ra_dl, cell.nof_prb, crc_is_crnti)) { if (dci_msg_unpack_pdsch(msg, ra_dl, cell.nof_prb, crc_is_crnti)) {
@ -866,7 +866,7 @@ int dci_msg_get_type(dci_msg_t *msg, dci_msg_type_t *type, uint32_t nof_prb,
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else if (msg->nof_bits == dci_format_sizeof(Format1A, nof_prb)) { } else if (msg->nof_bits == dci_format_sizeof(Format1A, nof_prb)) {
/* The RNTI is not the only condition. Also some fields in the packet. /* The RNTI is not the only condition. Also some fields in the packet.
* if (msg_rnti >= CRNTI_START && msg_rnti <= CRNTI_END) { * if (msg_rnti >= SRSLTE_CRNTI_START && msg_rnti <= SRSLTE_CRNTI_END) {
type->type = RA_PROC_PDCCH; type->type = RA_PROC_PDCCH;
type->format = Format1A; type->format = Format1A;
} else { } else {
@ -876,7 +876,7 @@ int dci_msg_get_type(dci_msg_t *msg, dci_msg_type_t *type, uint32_t nof_prb,
//} //}
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else if (msg->nof_bits == dci_format_sizeof(Format1C, nof_prb)) { } else if (msg->nof_bits == dci_format_sizeof(Format1C, nof_prb)) {
if (msg_rnti == MRNTI) { if (msg_rnti == SRSLTE_MRNTI) {
type->type = MCCH_CHANGE; type->type = MCCH_CHANGE;
type->format = Format1C; type->format = Format1C;
} else { } else {

@ -42,7 +42,7 @@
#include "srslte/utils/debug.h" #include "srslte/utils/debug.h"
#define MAX_PDSCH_RE(cp) (2 * CP_NSYMB(cp) * 12) #define MAX_PDSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12)
/* Calculate Codeblock Segmentation as in Section 5.1.2 of 36.212 */ /* Calculate Codeblock Segmentation as in Section 5.1.2 of 36.212 */
int codeblock_segmentation(struct cb_segm *s, uint32_t tbs) { int codeblock_segmentation(struct cb_segm *s, uint32_t tbs) {
@ -63,14 +63,14 @@ int codeblock_segmentation(struct cb_segm *s, uint32_t tbs) {
s->C = (uint32_t) ceilf((float) B / (MAX_LONG_CB - 24)); s->C = (uint32_t) ceilf((float) B / (MAX_LONG_CB - 24));
Bp = B + 24 * s->C; Bp = B + 24 * s->C;
} }
ret = lte_find_cb_index((Bp-1) / s->C + 1); ret = srslte_find_cb_index((Bp-1) / s->C + 1);
if (ret != SRSLTE_ERROR) { if (ret != SRSLTE_ERROR) {
idx1 = (uint32_t) ret; idx1 = (uint32_t) ret;
ret = lte_cb_size(idx1); ret = srslte_cb_size(idx1);
if (ret != SRSLTE_ERROR) { if (ret != SRSLTE_ERROR) {
s->K1 = (uint32_t) ret; s->K1 = (uint32_t) ret;
if (idx1 > 0) { if (idx1 > 0) {
ret = lte_cb_size(idx1 - 1); ret = srslte_cb_size(idx1 - 1);
} }
if (ret != SRSLTE_ERROR) { if (ret != SRSLTE_ERROR) {
if (s->C == 1) { if (s->C == 1) {
@ -214,8 +214,8 @@ int harq_setup_dl(harq_t *q, ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx, ra_dl_a
// Number of symbols, RE and bits per subframe for DL // Number of symbols, RE and bits per subframe for DL
q->nof_re = q->dl_alloc.re_sf[q->sf_idx]; q->nof_re = q->dl_alloc.re_sf[q->sf_idx];
q->nof_symb = 2*CP_NSYMB(q->cell.cp)-q->dl_alloc.lstart; q->nof_symb = 2*SRSLTE_CP_NSYMB(q->cell.cp)-q->dl_alloc.lstart;
q->nof_bits = q->nof_re * lte_mod_bits_x_symbol(q->mcs.mod); q->nof_bits = q->nof_re * srslte_mod_bits_x_symbol(q->mcs.mod);
q->nof_prb = q->dl_alloc.slot[0].nof_prb; q->nof_prb = q->dl_alloc.slot[0].nof_prb;
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
@ -237,9 +237,9 @@ int harq_setup_ul(harq_t *q, ra_mcs_t mcs, uint32_t rv, uint32_t sf_idx, ra_ul_a
memcpy(&q->ul_alloc, ul_alloc, sizeof(ra_ul_alloc_t)); memcpy(&q->ul_alloc, ul_alloc, sizeof(ra_ul_alloc_t));
// Number of symbols, RE and bits per subframe for UL // Number of symbols, RE and bits per subframe for UL
q->nof_symb = 2*(CP_NSYMB(q->cell.cp)-1); q->nof_symb = 2*(SRSLTE_CP_NSYMB(q->cell.cp)-1);
q->nof_re = q->nof_symb*q->ul_alloc.L_prb*RE_X_RB; q->nof_re = q->nof_symb*q->ul_alloc.L_prb*SRSLTE_NRE;
q->nof_bits = q->nof_re * lte_mod_bits_x_symbol(q->mcs.mod); q->nof_bits = q->nof_re * srslte_mod_bits_x_symbol(q->mcs.mod);
q->nof_prb = q->ul_alloc.L_prb; q->nof_prb = q->ul_alloc.L_prb;
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;

@ -61,37 +61,37 @@ int pbch_cp(cf_t *input, cf_t *output, srslte_cell_t cell, bool put) {
if (put) { if (put) {
ptr = input; ptr = input;
output += cell.nof_prb * RE_X_RB / 2 - 36; output += cell.nof_prb * SRSLTE_NRE / 2 - 36;
} else { } else {
ptr = output; ptr = output;
input += cell.nof_prb * RE_X_RB / 2 - 36; input += cell.nof_prb * SRSLTE_NRE / 2 - 36;
} }
/* symbol 0 & 1 */ /* symbol 0 & 1 */
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
prb_cp_ref(&input, &output, cell.id % 3, 4, 4*6, put); prb_cp_ref(&input, &output, cell.id % 3, 4, 4*6, put);
if (put) { if (put) {
output += cell.nof_prb * RE_X_RB - 2*36 + (cell.id%3==2?1:0); output += cell.nof_prb * SRSLTE_NRE - 2*36 + (cell.id%3==2?1:0);
} else { } else {
input += cell.nof_prb * RE_X_RB - 2*36 + (cell.id%3==2?1:0); input += cell.nof_prb * SRSLTE_NRE - 2*36 + (cell.id%3==2?1:0);
} }
} }
/* symbols 2 & 3 */ /* symbols 2 & 3 */
if (CP_ISNORM(cell.cp)) { if (SRSLTE_CP_ISNORM(cell.cp)) {
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
prb_cp(&input, &output, 6); prb_cp(&input, &output, 6);
if (put) { if (put) {
output += cell.nof_prb * RE_X_RB - 2*36; output += cell.nof_prb * SRSLTE_NRE - 2*36;
} else { } else {
input += cell.nof_prb * RE_X_RB - 2*36; input += cell.nof_prb * SRSLTE_NRE - 2*36;
} }
} }
} else { } else {
prb_cp(&input, &output, 6); prb_cp(&input, &output, 6);
if (put) { if (put) {
output += cell.nof_prb * RE_X_RB - 2*36; output += cell.nof_prb * SRSLTE_NRE - 2*36;
} else { } else {
input += cell.nof_prb * RE_X_RB - 2*36; input += cell.nof_prb * SRSLTE_NRE - 2*36;
} }
prb_cp_ref(&input, &output, cell.id % 3, 4, 4*6, put); prb_cp_ref(&input, &output, cell.id % 3, 4, 4*6, put);
} }
@ -132,15 +132,15 @@ int pbch_init(pbch_t *q, srslte_cell_t cell) {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && if (q != NULL &&
lte_cell_isvalid(&cell)) srslte_cell_isvalid(&cell))
{ {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
bzero(q, sizeof(pbch_t)); bzero(q, sizeof(pbch_t));
q->cell = cell; q->cell = cell;
q->nof_symbols = (CP_ISNORM(q->cell.cp)) ? PBCH_RE_CPNORM : PBCH_RE_CPEXT; q->nof_symbols = (SRSLTE_CP_ISNORM(q->cell.cp)) ? PBCH_RE_SRSLTE_SRSLTE_CP_NORM : PBCH_RE_SRSLTE_SRSLTE_CP_EXT;
if (precoding_init(&q->precoding, SF_LEN_RE(cell.nof_prb, cell.cp))) { if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) {
fprintf(stderr, "Error initializing precoding\n"); fprintf(stderr, "Error initializing precoding\n");
} }
@ -159,7 +159,7 @@ int pbch_init(pbch_t *q, srslte_cell_t cell) {
if (viterbi_init(&q->decoder, viterbi_37, poly, 40, true)) { if (viterbi_init(&q->decoder, viterbi_37, poly, 40, true)) {
goto clean; goto clean;
} }
if (crc_init(&q->crc, LTE_CRC16, 16)) { if (crc_init(&q->crc, SRSLTE_LTE_CRC16, 16)) {
goto clean; goto clean;
} }
q->encoder.K = 7; q->encoder.K = 7;
@ -262,25 +262,25 @@ void pbch_mib_unpack(uint8_t *msg, srslte_cell_t *cell, uint32_t *sfn) {
break; break;
} }
if (*msg) { if (*msg) {
cell->phich_length = PHICH_EXT; cell->phich_length = SRSLTE_PHICH_EXT;
} else { } else {
cell->phich_length = PHICH_NORM; cell->phich_length = SRSLTE_PHICH_NORM;
} }
msg++; msg++;
phich_res = bit_unpack(&msg, 2); phich_res = bit_unpack(&msg, 2);
switch (phich_res) { switch (phich_res) {
case 0: case 0:
cell->phich_resources = R_1_6; cell->phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_6;
break; break;
case 1: case 1:
cell->phich_resources = R_1_2; cell->phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_2;
break; break;
case 2: case 2:
cell->phich_resources = R_1; cell->phich_resources = SRSLTE_PHICH_R_1;
break; break;
case 3: case 3:
cell->phich_resources = R_2; cell->phich_resources = SRSLTE_PHICH_R_2;
break; break;
} }
if (sfn) { if (sfn) {
@ -305,20 +305,20 @@ void pbch_mib_pack(srslte_cell_t *cell, uint32_t sfn, uint8_t *msg) {
} }
bit_pack(bw, &msg, 3); bit_pack(bw, &msg, 3);
*msg = cell->phich_length == PHICH_EXT; *msg = cell->phich_length == SRSLTE_PHICH_EXT;
msg++; msg++;
switch (cell->phich_resources) { switch (cell->phich_resources) {
case R_1_6: case SRSLTE_PHICH_SRSLTE_PHICH_R_1_6:
phich_res = 0; phich_res = 0;
break; break;
case R_1_2: case SRSLTE_PHICH_SRSLTE_PHICH_R_1_2:
phich_res = 1; phich_res = 1;
break; break;
case R_1: case SRSLTE_PHICH_R_1:
phich_res = 2; phich_res = 2;
break; break;
case R_2: case SRSLTE_PHICH_R_2:
phich_res = 3; phich_res = 3;
break; break;
} }
@ -331,19 +331,19 @@ void pbch_mib_fprint(FILE *stream, srslte_cell_t *cell, uint32_t sfn, uint32_t c
printf(" - Nof ports: %d\n", cell->nof_ports); printf(" - Nof ports: %d\n", cell->nof_ports);
printf(" - PRB: %d\n", cell->nof_prb); printf(" - PRB: %d\n", cell->nof_prb);
printf(" - PHICH Length: %s\n", printf(" - PHICH Length: %s\n",
cell->phich_length == PHICH_EXT ? "Extended" : "Normal"); cell->phich_length == SRSLTE_PHICH_EXT ? "Extended" : "Normal");
printf(" - PHICH Resources: "); printf(" - PHICH Resources: ");
switch (cell->phich_resources) { switch (cell->phich_resources) {
case R_1_6: case SRSLTE_PHICH_SRSLTE_PHICH_R_1_6:
printf("1/6"); printf("1/6");
break; break;
case R_1_2: case SRSLTE_PHICH_SRSLTE_PHICH_R_1_2:
printf("1/2"); printf("1/2");
break; break;
case R_1: case SRSLTE_PHICH_R_1:
printf("1"); printf("1");
break; break;
case R_2: case SRSLTE_PHICH_R_2:
printf("2"); printf("2");
break; break;
} }
@ -438,7 +438,7 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS]
uint32_t nant; uint32_t nant;
int i; int i;
int nof_bits; int nof_bits;
cf_t *x[MAX_LAYERS]; cf_t *x[SRSLTE_MAX_LAYERS];
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
@ -458,7 +458,7 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS]
for (i = 0; i < SRSLTE_MAX_PORTS; i++) { for (i = 0; i < SRSLTE_MAX_PORTS; i++) {
x[i] = q->pbch_x[i]; x[i] = q->pbch_x[i];
} }
memset(&x[SRSLTE_MAX_PORTS], 0, sizeof(cf_t*) * (MAX_LAYERS - SRSLTE_MAX_PORTS)); memset(&x[SRSLTE_MAX_PORTS], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - SRSLTE_MAX_PORTS));
/* extract symbols */ /* extract symbols */
if (q->nof_symbols != pbch_get(slot1_symbols, q->pbch_symbols[0], q->cell)) { if (q->nof_symbols != pbch_get(slot1_symbols, q->pbch_symbols[0], q->cell)) {
@ -540,7 +540,7 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRSLTE_MAX_PORTS]
int pbch_encode(pbch_t *q, uint8_t bch_payload[BCH_PAYLOAD_LEN], cf_t *slot1_symbols[SRSLTE_MAX_PORTS]) { int pbch_encode(pbch_t *q, uint8_t bch_payload[BCH_PAYLOAD_LEN], cf_t *slot1_symbols[SRSLTE_MAX_PORTS]) {
int i; int i;
int nof_bits; int nof_bits;
cf_t *x[MAX_LAYERS]; cf_t *x[SRSLTE_MAX_LAYERS];
if (q != NULL && if (q != NULL &&
bch_payload != NULL) bch_payload != NULL)
@ -557,7 +557,7 @@ int pbch_encode(pbch_t *q, uint8_t bch_payload[BCH_PAYLOAD_LEN], cf_t *slot1_sym
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
x[i] = q->pbch_x[i]; x[i] = q->pbch_x[i];
} }
memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports)); memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports));
if (q->frame_idx == 0) { if (q->frame_idx == 0) {
memcpy(q->data, bch_payload, sizeof(uint8_t) * BCH_PAYLOAD_LEN); memcpy(q->data, bch_payload, sizeof(uint8_t) * BCH_PAYLOAD_LEN);

@ -66,7 +66,7 @@ int pcfich_init(pcfich_t *q, regs_t *regs, srslte_cell_t cell) {
if (q != NULL && if (q != NULL &&
regs != NULL && regs != NULL &&
lte_cell_isvalid(&cell)) srslte_cell_isvalid(&cell))
{ {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
@ -75,7 +75,7 @@ int pcfich_init(pcfich_t *q, regs_t *regs, srslte_cell_t cell) {
q->regs = regs; q->regs = regs;
q->nof_symbols = PCFICH_RE; q->nof_symbols = PCFICH_RE;
if (precoding_init(&q->precoding, SF_LEN_RE(cell.nof_prb, cell.cp))) { if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) {
fprintf(stderr, "Error initializing precoding\n"); fprintf(stderr, "Error initializing precoding\n");
} }
@ -164,7 +164,7 @@ int pcfich_decode(pcfich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], f
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
int i; int i;
cf_t *x[MAX_LAYERS]; cf_t *x[SRSLTE_MAX_LAYERS];
cf_t *ce_precoding[SRSLTE_MAX_PORTS]; cf_t *ce_precoding[SRSLTE_MAX_PORTS];
if (q != NULL && if (q != NULL &&
@ -239,7 +239,7 @@ int pcfich_encode(pcfich_t *q, uint32_t cfi, cf_t *slot_symbols[SRSLTE_MAX_PORTS
{ {
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
cf_t *x[MAX_LAYERS]; cf_t *x[SRSLTE_MAX_LAYERS];
cf_t *symbols_precoding[SRSLTE_MAX_PORTS]; cf_t *symbols_precoding[SRSLTE_MAX_PORTS];
/* number of layers equals number of ports */ /* number of layers equals number of ports */

@ -61,14 +61,14 @@ int pdcch_init(pdcch_t *q, regs_t *regs, srslte_cell_t cell) {
if (q != NULL && if (q != NULL &&
regs != NULL && regs != NULL &&
lte_cell_isvalid(&cell)) srslte_cell_isvalid(&cell))
{ {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
bzero(q, sizeof(pdcch_t)); bzero(q, sizeof(pdcch_t));
q->cell = cell; q->cell = cell;
q->regs = regs; q->regs = regs;
if (precoding_init(&q->precoding, SF_LEN_RE(cell.nof_prb, cell.cp))) { if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) {
fprintf(stderr, "Error initializing precoding\n"); fprintf(stderr, "Error initializing precoding\n");
} }
@ -81,7 +81,7 @@ int pdcch_init(pdcch_t *q, regs_t *regs, srslte_cell_t cell) {
if (modem_table_lte(&q->mod, LTE_QPSK, true)) { if (modem_table_lte(&q->mod, LTE_QPSK, true)) {
goto clean; goto clean;
} }
if (crc_init(&q->crc, LTE_CRC16, 16)) { if (crc_init(&q->crc, SRSLTE_LTE_CRC16, 16)) {
goto clean; goto clean;
} }
@ -366,7 +366,7 @@ int pdcch_extract_llr(pdcch_t *q, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS],
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
uint32_t i, nof_symbols; uint32_t i, nof_symbols;
cf_t *x[MAX_LAYERS]; cf_t *x[SRSLTE_MAX_LAYERS];
if (q != NULL && if (q != NULL &&
nsubframe < 10 && nsubframe < 10 &&
@ -386,7 +386,7 @@ int pdcch_extract_llr(pdcch_t *q, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS],
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
x[i] = q->pdcch_x[i]; x[i] = q->pdcch_x[i];
} }
memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports)); memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports));
/* extract symbols */ /* extract symbols */
int n = regs_pdcch_get(q->regs, sf_symbols, q->pdcch_symbols[0]); int n = regs_pdcch_get(q->regs, sf_symbols, q->pdcch_symbols[0]);
@ -502,7 +502,7 @@ int pdcch_encode(pdcch_t *q, dci_msg_t *msg, dci_location_t location, uint16_t r
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
uint32_t i; uint32_t i;
cf_t *x[MAX_LAYERS]; cf_t *x[SRSLTE_MAX_LAYERS];
uint32_t nof_symbols; uint32_t nof_symbols;
if (q != NULL && if (q != NULL &&
@ -531,7 +531,7 @@ int pdcch_encode(pdcch_t *q, dci_msg_t *msg, dci_location_t location, uint16_t r
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
x[i] = q->pdcch_x[i]; x[i] = q->pdcch_x[i];
} }
memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports)); memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports));
scrambling_b_offset(&q->seq_pdcch[nsubframe], q->pdcch_e, 72 * location.ncce, e_bits); scrambling_b_offset(&q->seq_pdcch[nsubframe], q->pdcch_e, 72 * location.ncce, e_bits);

@ -42,11 +42,11 @@
#include "srslte/utils/vector.h" #include "srslte/utils/vector.h"
#define MAX_PDSCH_RE(cp) (2 * CP_NSYMB(cp) * 12) #define MAX_PDSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12)
const static lte_mod_t modulations[4] = const static srslte_mod_t modulations[4] =
{ LTE_BPSK, LTE_QPSK, LTE_QAM16, LTE_QAM64 }; { LTE_BPSK, LTE_QPSK, LTE_QAM16, LTE_QAM64 };
//#define DEBUG_IDX //#define DEBUG_IDX
@ -84,7 +84,7 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc,
} }
for (s = 0; s < 2; s++) { for (s = 0; s < 2; s++) {
for (l = 0; l < CP_NSYMB(q->cell.cp); l++) { for (l = 0; l < SRSLTE_CP_NSYMB(q->cell.cp); l++) {
for (n = 0; n < q->cell.nof_prb; n++) { for (n = 0; n < q->cell.nof_prb; n++) {
// If this PRB is assigned // If this PRB is assigned
@ -94,14 +94,14 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc,
} else { } else {
lstart = 0; lstart = 0;
} }
lend = CP_NSYMB(q->cell.cp); lend = SRSLTE_CP_NSYMB(q->cell.cp);
is_pbch = is_sss = false; is_pbch = is_sss = false;
// Skip PSS/SSS signals // Skip PSS/SSS signals
if (s == 0 && (nsubframe == 0 || nsubframe == 5)) { if (s == 0 && (nsubframe == 0 || nsubframe == 5)) {
if (n >= q->cell.nof_prb / 2 - 3 if (n >= q->cell.nof_prb / 2 - 3
&& n < q->cell.nof_prb / 2 + 3) { && n < q->cell.nof_prb / 2 + 3) {
lend = CP_NSYMB(q->cell.cp) - 2; lend = SRSLTE_CP_NSYMB(q->cell.cp) - 2;
is_sss = true; is_sss = true;
} }
} }
@ -113,17 +113,17 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc,
is_pbch = true; is_pbch = true;
} }
} }
lp = l + s * CP_NSYMB(q->cell.cp); lp = l + s * SRSLTE_CP_NSYMB(q->cell.cp);
if (put) { if (put) {
out_ptr = &output[(lp * q->cell.nof_prb + n) out_ptr = &output[(lp * q->cell.nof_prb + n)
* RE_X_RB]; * SRSLTE_NRE];
} else { } else {
in_ptr = &input[(lp * q->cell.nof_prb + n) in_ptr = &input[(lp * q->cell.nof_prb + n)
* RE_X_RB]; * SRSLTE_NRE];
} }
// This is a symbol in a normal PRB with or without references // This is a symbol in a normal PRB with or without references
if (l >= lstart && l < lend) { if (l >= lstart && l < lend) {
if (SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) { if (SRSLTE_SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) {
if (nof_refs == 2 && l != 0) { if (nof_refs == 2 && l != 0) {
offset = q->cell.id % 3 + 3; offset = q->cell.id % 3 + 3;
} else { } else {
@ -138,7 +138,7 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc,
// If the number or total PRB is odd, half of the the PBCH or SS will fall into the symbol // If the number or total PRB is odd, half of the the PBCH or SS will fall into the symbol
if ((q->cell.nof_prb % 2) && ((is_pbch && l < lstart) || (is_sss && l >= lend))) { if ((q->cell.nof_prb % 2) && ((is_pbch && l < lstart) || (is_sss && l >= lend))) {
if (n == q->cell.nof_prb / 2 - 3) { if (n == q->cell.nof_prb / 2 - 3) {
if (SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) { if (SRSLTE_SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) {
prb_cp_ref(&in_ptr, &out_ptr, offset, nof_refs, nof_refs/2, put); prb_cp_ref(&in_ptr, &out_ptr, offset, nof_refs, nof_refs/2, put);
} else { } else {
prb_cp_half(&in_ptr, &out_ptr, 1); prb_cp_half(&in_ptr, &out_ptr, 1);
@ -149,7 +149,7 @@ int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_dl_alloc_t *prb_alloc,
} else { } else {
in_ptr += 6; in_ptr += 6;
} }
if (SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) { if (SRSLTE_SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) {
prb_cp_ref(&in_ptr, &out_ptr, offset, nof_refs, nof_refs/2, put); prb_cp_ref(&in_ptr, &out_ptr, offset, nof_refs, nof_refs/2, put);
} else { } else {
prb_cp_half(&in_ptr, &out_ptr, 1); prb_cp_half(&in_ptr, &out_ptr, 1);
@ -201,7 +201,7 @@ int pdsch_init(pdsch_t *q, srslte_cell_t cell) {
int i; int i;
if (q != NULL && if (q != NULL &&
lte_cell_isvalid(&cell)) srslte_cell_isvalid(&cell))
{ {
bzero(q, sizeof(pdsch_t)); bzero(q, sizeof(pdsch_t));
@ -213,7 +213,7 @@ int pdsch_init(pdsch_t *q, srslte_cell_t cell) {
INFO("Init PDSCH: %d ports %d PRBs, max_symbols: %d\n", q->cell.nof_ports, INFO("Init PDSCH: %d ports %d PRBs, max_symbols: %d\n", q->cell.nof_ports,
q->cell.nof_prb, q->max_re); q->cell.nof_prb, q->max_re);
if (precoding_init(&q->precoding, SF_LEN_RE(cell.nof_prb, cell.cp))) { if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) {
fprintf(stderr, "Error initializing precoding\n"); fprintf(stderr, "Error initializing precoding\n");
goto clean; goto clean;
} }
@ -232,7 +232,7 @@ int pdsch_init(pdsch_t *q, srslte_cell_t cell) {
q->rnti_is_set = false; q->rnti_is_set = false;
// Allocate floats for reception (LLRs) // Allocate floats for reception (LLRs)
q->pdsch_e = vec_malloc(sizeof(float) * q->max_re * lte_mod_bits_x_symbol(LTE_QAM64)); q->pdsch_e = vec_malloc(sizeof(float) * q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64));
if (!q->pdsch_e) { if (!q->pdsch_e) {
goto clean; goto clean;
} }
@ -310,7 +310,7 @@ int pdsch_set_rnti(pdsch_t *q, uint16_t rnti) {
uint32_t i; uint32_t i;
for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) {
if (sequence_pdsch(&q->seq_pdsch[i], rnti, 0, 2 * i, q->cell.id, if (sequence_pdsch(&q->seq_pdsch[i], rnti, 0, 2 * i, q->cell.id,
q->max_re * lte_mod_bits_x_symbol(LTE_QAM64))) { q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64))) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -344,7 +344,7 @@ int pdsch_decode_rnti(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLT
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
uint32_t i, n; uint32_t i, n;
cf_t *x[MAX_LAYERS]; cf_t *x[SRSLTE_MAX_LAYERS];
if (q != NULL && if (q != NULL &&
sf_symbols != NULL && sf_symbols != NULL &&
@ -353,13 +353,13 @@ int pdsch_decode_rnti(pdsch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLT
{ {
INFO("Decoding PDSCH SF: %d, Mod %s, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", INFO("Decoding PDSCH SF: %d, Mod %s, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n",
harq->sf_idx, lte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); harq->sf_idx, srslte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv);
/* number of layers equals number of ports */ /* number of layers equals number of ports */
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
x[i] = q->pdsch_x[i]; x[i] = q->pdsch_x[i];
} }
memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports)); memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports));
/* extract symbols */ /* extract symbols */
n = pdsch_get(q, sf_symbols, q->pdsch_symbols[0], &harq->dl_alloc, harq->sf_idx); n = pdsch_get(q, sf_symbols, q->pdsch_symbols[0], &harq->dl_alloc, harq->sf_idx);
@ -439,7 +439,7 @@ int pdsch_encode_rnti(pdsch_t *q, harq_t *harq, uint8_t *data, uint16_t rnti, cf
{ {
int i; int i;
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
cf_t *x[MAX_LAYERS]; cf_t *x[SRSLTE_MAX_LAYERS];
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && if (q != NULL &&
@ -470,13 +470,13 @@ int pdsch_encode_rnti(pdsch_t *q, harq_t *harq, uint8_t *data, uint16_t rnti, cf
} }
INFO("Encoding PDSCH SF: %d, Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", INFO("Encoding PDSCH SF: %d, Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n",
harq->sf_idx, lte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); harq->sf_idx, srslte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv);
/* number of layers equals number of ports */ /* number of layers equals number of ports */
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
x[i] = q->pdsch_x[i]; x[i] = q->pdsch_x[i];
} }
memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports)); memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports));
if (dlsch_encode(&q->dl_sch, harq, data, q->pdsch_e)) { if (dlsch_encode(&q->dl_sch, harq, data, q->pdsch_e)) {
fprintf(stderr, "Error encoding TB\n"); fprintf(stderr, "Error encoding TB\n");

@ -42,10 +42,10 @@
#include "srslte/utils/debug.h" #include "srslte/utils/debug.h"
/** Table 6.9.1-2 */ /** Table 6.9.1-2 */
const cf_t w_normal[PHICH_NORM_NSEQUENCES][4] = { { 1, 1, 1, 1 }, const cf_t w_normal[SRSLTE_PHICH_NORM_NSEQUENCES][4] = { { 1, 1, 1, 1 },
{ 1, -1, 1, -1 }, { 1, 1, -1, -1 }, { 1, -1, -1, 1 }, { I, I, I, I }, { { 1, -1, 1, -1 }, { 1, 1, -1, -1 }, { 1, -1, -1, 1 }, { I, I, I, I }, {
I, -I, I, -I }, { I, I, -I, -I }, { I, -I, -I, I } }; I, -I, I, -I }, { I, I, -I, -I }, { I, -I, -I, I } };
const cf_t w_ext[PHICH_EXT_NSEQUENCES][2] = { { 1, 1 }, { 1, -1 }, { I, I }, { const cf_t w_ext[SRSLTE_PHICH_EXT_NSEQUENCES][2] = { { 1, 1 }, { 1, -1 }, { I, I }, {
I, -I } }; I, -I } };
@ -66,7 +66,7 @@ int phich_init(phich_t *q, regs_t *regs, srslte_cell_t cell) {
if (q != NULL && if (q != NULL &&
regs != NULL && regs != NULL &&
lte_cell_isvalid(&cell)) srslte_cell_isvalid(&cell))
{ {
bzero(q, sizeof(phich_t)); bzero(q, sizeof(phich_t));
@ -75,7 +75,7 @@ int phich_init(phich_t *q, regs_t *regs, srslte_cell_t cell) {
q->cell = cell; q->cell = cell;
q->regs = regs; q->regs = regs;
if (precoding_init(&q->precoding, SF_LEN_RE(cell.nof_prb, cell.cp))) { if (precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) {
fprintf(stderr, "Error initializing precoding\n"); fprintf(stderr, "Error initializing precoding\n");
} }
@ -151,7 +151,7 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
int i, j; int i, j;
cf_t *x[MAX_LAYERS]; cf_t *x[SRSLTE_MAX_LAYERS];
cf_t *ce_precoding[SRSLTE_MAX_PORTS]; cf_t *ce_precoding[SRSLTE_MAX_PORTS];
if (q == NULL || slot_symbols == NULL) { if (q == NULL || slot_symbols == NULL) {
@ -163,13 +163,13 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
if (CP_ISEXT(q->cell.cp)) { if (SRSLTE_CP_ISEXT(q->cell.cp)) {
if (nseq >= PHICH_EXT_NSEQUENCES) { if (nseq >= SRSLTE_PHICH_EXT_NSEQUENCES) {
fprintf(stderr, "Invalid nseq %d\n", nseq); fprintf(stderr, "Invalid nseq %d\n", nseq);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
} else { } else {
if (nseq >= PHICH_NORM_NSEQUENCES) { if (nseq >= SRSLTE_PHICH_NORM_NSEQUENCES) {
fprintf(stderr, "Invalid nseq %d\n", nseq); fprintf(stderr, "Invalid nseq %d\n", nseq);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
@ -190,7 +190,7 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo
} }
/* extract symbols */ /* extract symbols */
if (PHICH_MAX_NSYMB if (PHICH_SRSLTE_MAX_NSYMB
!= regs_phich_get(q->regs, slot_symbols, q->phich_symbols[0], ngroup)) { != regs_phich_get(q->regs, slot_symbols, q->phich_symbols[0], ngroup)) {
fprintf(stderr, "There was an error getting the phich symbols\n"); fprintf(stderr, "There was an error getting the phich symbols\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
@ -198,7 +198,7 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo
/* extract channel estimates */ /* extract channel estimates */
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
if (PHICH_MAX_NSYMB != regs_phich_get(q->regs, ce[i], q->ce[i], ngroup)) { if (PHICH_SRSLTE_MAX_NSYMB != regs_phich_get(q->regs, ce[i], q->ce[i], ngroup)) {
fprintf(stderr, "There was an error getting the phich symbols\n"); fprintf(stderr, "There was an error getting the phich symbols\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -208,55 +208,55 @@ int phich_decode(phich_t *q, cf_t *slot_symbols, cf_t *ce[SRSLTE_MAX_PORTS], flo
if (q->cell.nof_ports == 1) { if (q->cell.nof_ports == 1) {
/* no need for layer demapping */ /* no need for layer demapping */
predecoding_single(&q->precoding, q->phich_symbols[0], q->ce[0], q->phich_d0, predecoding_single(&q->precoding, q->phich_symbols[0], q->ce[0], q->phich_d0,
PHICH_MAX_NSYMB, noise_estimate); PHICH_SRSLTE_MAX_NSYMB, noise_estimate);
} else { } else {
predecoding_diversity(&q->precoding, q->phich_symbols[0], ce_precoding, x, predecoding_diversity(&q->precoding, q->phich_symbols[0], ce_precoding, x,
q->cell.nof_ports, PHICH_MAX_NSYMB, noise_estimate); q->cell.nof_ports, PHICH_SRSLTE_MAX_NSYMB, noise_estimate);
layerdemap_diversity(x, q->phich_d0, q->cell.nof_ports, layerdemap_diversity(x, q->phich_d0, q->cell.nof_ports,
PHICH_MAX_NSYMB / q->cell.nof_ports); PHICH_SRSLTE_MAX_NSYMB / q->cell.nof_ports);
} }
DEBUG("Recv!!: \n", 0); DEBUG("Recv!!: \n", 0);
DEBUG("d0: ", 0); DEBUG("d0: ", 0);
if (VERBOSE_ISDEBUG()) if (VERBOSE_ISDEBUG())
vec_fprint_c(stdout, q->phich_d0, PHICH_MAX_NSYMB); vec_fprint_c(stdout, q->phich_d0, PHICH_SRSLTE_MAX_NSYMB);
if (CP_ISEXT(q->cell.cp)) { if (SRSLTE_CP_ISEXT(q->cell.cp)) {
if (ngroup % 2) { if (ngroup % 2) {
for (i = 0; i < PHICH_EXT_MSYMB / 2; i++) { for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) {
q->phich_d[2 * i + 0] = q->phich_d0[4 * i + 2]; q->phich_d[2 * i + 0] = q->phich_d0[4 * i + 2];
q->phich_d[2 * i + 1] = q->phich_d0[4 * i + 3]; q->phich_d[2 * i + 1] = q->phich_d0[4 * i + 3];
} }
} else { } else {
for (i = 0; i < PHICH_EXT_MSYMB / 2; i++) { for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) {
q->phich_d[2 * i + 0] = q->phich_d0[4 * i]; q->phich_d[2 * i + 0] = q->phich_d0[4 * i];
q->phich_d[2 * i + 1] = q->phich_d0[4 * i + 1]; q->phich_d[2 * i + 1] = q->phich_d0[4 * i + 1];
} }
} }
} else { } else {
memcpy(q->phich_d, q->phich_d0, PHICH_MAX_NSYMB * sizeof(cf_t)); memcpy(q->phich_d, q->phich_d0, PHICH_SRSLTE_MAX_NSYMB * sizeof(cf_t));
} }
DEBUG("d: ", 0); DEBUG("d: ", 0);
if (VERBOSE_ISDEBUG()) if (VERBOSE_ISDEBUG())
vec_fprint_c(stdout, q->phich_d, PHICH_EXT_MSYMB); vec_fprint_c(stdout, q->phich_d, SRSLTE_PHICH_EXT_MSYMB);
scrambling_c(&q->seq_phich[subframe], q->phich_d); scrambling_c(&q->seq_phich[subframe], q->phich_d);
/* De-spreading */ /* De-spreading */
if (CP_ISEXT(q->cell.cp)) { if (SRSLTE_CP_ISEXT(q->cell.cp)) {
for (i = 0; i < PHICH_NBITS; i++) { for (i = 0; i < PHICH_NBITS; i++) {
q->phich_z[i] = 0; q->phich_z[i] = 0;
for (j = 0; j < PHICH_EXT_NSF; j++) { for (j = 0; j < SRSLTE_PHICH_EXT_NSF; j++) {
q->phich_z[i] += conjf(w_ext[nseq][j]) q->phich_z[i] += conjf(w_ext[nseq][j])
* q->phich_d[i * PHICH_EXT_NSF + j] / PHICH_EXT_NSF; * q->phich_d[i * SRSLTE_PHICH_EXT_NSF + j] / SRSLTE_PHICH_EXT_NSF;
} }
} }
} else { } else {
for (i = 0; i < PHICH_NBITS; i++) { for (i = 0; i < PHICH_NBITS; i++) {
q->phich_z[i] = 0; q->phich_z[i] = 0;
for (j = 0; j < PHICH_NORM_NSF; j++) { for (j = 0; j < SRSLTE_PHICH_NORM_NSF; j++) {
q->phich_z[i] += conjf(w_normal[nseq][j]) q->phich_z[i] += conjf(w_normal[nseq][j])
* q->phich_d[i * PHICH_NORM_NSF + j] / PHICH_NORM_NSF; * q->phich_d[i * SRSLTE_PHICH_NORM_NSF + j] / SRSLTE_PHICH_NORM_NSF;
} }
} }
} }
@ -290,13 +290,13 @@ int phich_encode(phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
if (CP_ISEXT(q->cell.cp)) { if (SRSLTE_CP_ISEXT(q->cell.cp)) {
if (nseq >= PHICH_EXT_NSEQUENCES) { if (nseq >= SRSLTE_PHICH_EXT_NSEQUENCES) {
fprintf(stderr, "Invalid nseq %d\n", nseq); fprintf(stderr, "Invalid nseq %d\n", nseq);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
} else { } else {
if (nseq >= PHICH_NORM_NSEQUENCES) { if (nseq >= SRSLTE_PHICH_NORM_NSEQUENCES) {
fprintf(stderr, "Invalid nseq %d\n", nseq); fprintf(stderr, "Invalid nseq %d\n", nseq);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
@ -308,7 +308,7 @@ int phich_encode(phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32
/* Set pointers for layermapping & precoding */ /* Set pointers for layermapping & precoding */
cf_t *x[MAX_LAYERS]; cf_t *x[SRSLTE_MAX_LAYERS];
cf_t *symbols_precoding[SRSLTE_MAX_PORTS]; cf_t *symbols_precoding[SRSLTE_MAX_PORTS];
/* number of layers equals number of ports */ /* number of layers equals number of ports */
@ -329,35 +329,35 @@ int phich_encode(phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32
vec_fprint_c(stdout, q->phich_z, PHICH_NBITS); vec_fprint_c(stdout, q->phich_z, PHICH_NBITS);
/* Spread with w */ /* Spread with w */
if (CP_ISEXT(q->cell.cp)) { if (SRSLTE_CP_ISEXT(q->cell.cp)) {
for (i = 0; i < PHICH_EXT_MSYMB; i++) { for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB; i++) {
q->phich_d[i] = w_ext[nseq][i % PHICH_EXT_NSF] q->phich_d[i] = w_ext[nseq][i % SRSLTE_PHICH_EXT_NSF]
* q->phich_z[i / PHICH_EXT_NSF]; * q->phich_z[i / SRSLTE_PHICH_EXT_NSF];
} }
} else { } else {
for (i = 0; i < PHICH_NORM_MSYMB; i++) { for (i = 0; i < SRSLTE_PHICH_NORM_MSYMB; i++) {
q->phich_d[i] = w_normal[nseq][i % PHICH_NORM_NSF] q->phich_d[i] = w_normal[nseq][i % SRSLTE_PHICH_NORM_NSF]
* q->phich_z[i / PHICH_NORM_NSF]; * q->phich_z[i / SRSLTE_PHICH_NORM_NSF];
} }
} }
DEBUG("d: ", 0); DEBUG("d: ", 0);
if (VERBOSE_ISDEBUG()) if (VERBOSE_ISDEBUG())
vec_fprint_c(stdout, q->phich_d, PHICH_EXT_MSYMB); vec_fprint_c(stdout, q->phich_d, SRSLTE_PHICH_EXT_MSYMB);
scrambling_c(&q->seq_phich[subframe], q->phich_d); scrambling_c(&q->seq_phich[subframe], q->phich_d);
/* align to REG */ /* align to REG */
if (CP_ISEXT(q->cell.cp)) { if (SRSLTE_CP_ISEXT(q->cell.cp)) {
if (ngroup % 2) { if (ngroup % 2) {
for (i = 0; i < PHICH_EXT_MSYMB / 2; i++) { for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) {
q->phich_d0[4 * i + 0] = 0; q->phich_d0[4 * i + 0] = 0;
q->phich_d0[4 * i + 1] = 0; q->phich_d0[4 * i + 1] = 0;
q->phich_d0[4 * i + 2] = q->phich_d[2 * i]; q->phich_d0[4 * i + 2] = q->phich_d[2 * i];
q->phich_d0[4 * i + 3] = q->phich_d[2 * i + 1]; q->phich_d0[4 * i + 3] = q->phich_d[2 * i + 1];
} }
} else { } else {
for (i = 0; i < PHICH_EXT_MSYMB / 2; i++) { for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) {
q->phich_d0[4 * i + 0] = q->phich_d[2 * i]; q->phich_d0[4 * i + 0] = q->phich_d[2 * i];
q->phich_d0[4 * i + 1] = q->phich_d[2 * i + 1]; q->phich_d0[4 * i + 1] = q->phich_d[2 * i + 1];
q->phich_d0[4 * i + 2] = 0; q->phich_d0[4 * i + 2] = 0;
@ -365,21 +365,21 @@ int phich_encode(phich_t *q, uint8_t ack, uint32_t ngroup, uint32_t nseq, uint32
} }
} }
} else { } else {
memcpy(q->phich_d0, q->phich_d, PHICH_MAX_NSYMB * sizeof(cf_t)); memcpy(q->phich_d0, q->phich_d, PHICH_SRSLTE_MAX_NSYMB * sizeof(cf_t));
} }
DEBUG("d0: ", 0); DEBUG("d0: ", 0);
if (VERBOSE_ISDEBUG()) if (VERBOSE_ISDEBUG())
vec_fprint_c(stdout, q->phich_d0, PHICH_MAX_NSYMB); vec_fprint_c(stdout, q->phich_d0, PHICH_SRSLTE_MAX_NSYMB);
/* layer mapping & precoding */ /* layer mapping & precoding */
if (q->cell.nof_ports > 1) { if (q->cell.nof_ports > 1) {
layermap_diversity(q->phich_d0, x, q->cell.nof_ports, PHICH_MAX_NSYMB); layermap_diversity(q->phich_d0, x, q->cell.nof_ports, PHICH_SRSLTE_MAX_NSYMB);
precoding_diversity(&q->precoding, x, symbols_precoding, q->cell.nof_ports, precoding_diversity(&q->precoding, x, symbols_precoding, q->cell.nof_ports,
PHICH_MAX_NSYMB / q->cell.nof_ports); PHICH_SRSLTE_MAX_NSYMB / q->cell.nof_ports);
/**FIXME: According to 6.9.2, Precoding for 4 tx ports is different! */ /**FIXME: According to 6.9.2, Precoding for 4 tx ports is different! */
} else { } else {
memcpy(q->phich_symbols[0], q->phich_d0, PHICH_MAX_NSYMB * sizeof(cf_t)); memcpy(q->phich_symbols[0], q->phich_d0, PHICH_SRSLTE_MAX_NSYMB * sizeof(cf_t));
} }
/* mapping to resource elements */ /* mapping to resource elements */

@ -53,7 +53,7 @@ void prb_cp_ref(cf_t **input, cf_t **output, int offset, int nof_refs,
int nof_intervals, bool advance_output) { int nof_intervals, bool advance_output) {
int i; int i;
int ref_interval = ((RE_X_RB / nof_refs) - 1); int ref_interval = ((SRSLTE_NRE / nof_refs) - 1);
memcpy(*output, *input, offset * sizeof(cf_t)); memcpy(*output, *input, offset * sizeof(cf_t));
print_indexes(*input, offset); print_indexes(*input, offset);
*input += offset; *input += offset;
@ -83,18 +83,18 @@ void prb_cp_ref(cf_t **input, cf_t **output, int offset, int nof_refs,
} }
void prb_cp(cf_t **input, cf_t **output, int nof_prb) { void prb_cp(cf_t **input, cf_t **output, int nof_prb) {
memcpy(*output, *input, sizeof(cf_t) * RE_X_RB * nof_prb); memcpy(*output, *input, sizeof(cf_t) * SRSLTE_NRE * nof_prb);
print_indexes(*input, RE_X_RB); print_indexes(*input, SRSLTE_NRE);
*input += nof_prb * RE_X_RB; *input += nof_prb * SRSLTE_NRE;
*output += nof_prb * RE_X_RB; *output += nof_prb * SRSLTE_NRE;
} }
void prb_cp_half(cf_t **input, cf_t **output, int nof_prb) { void prb_cp_half(cf_t **input, cf_t **output, int nof_prb) {
memcpy(*output, *input, sizeof(cf_t) * RE_X_RB * nof_prb / 2); memcpy(*output, *input, sizeof(cf_t) * SRSLTE_NRE * nof_prb / 2);
print_indexes(*input, RE_X_RB/2); print_indexes(*input, SRSLTE_NRE/2);
*input += nof_prb * RE_X_RB / 2; *input += nof_prb * SRSLTE_NRE / 2;
*output += nof_prb * RE_X_RB / 2; *output += nof_prb * SRSLTE_NRE / 2;
} }
void prb_put_ref_(cf_t **input, cf_t **output, int offset, int nof_refs, void prb_put_ref_(cf_t **input, cf_t **output, int offset, int nof_refs,

@ -42,7 +42,7 @@
#include "srslte/utils/vector.h" #include "srslte/utils/vector.h"
#include "srslte/filter/dft_precoding.h" #include "srslte/filter/dft_precoding.h"
#define MAX_PUSCH_RE(cp) (2 * CP_NSYMB(cp) * 12) #define MAX_PUSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12)
bool pucch_cfg_isvalid(pucch_cfg_t *cfg) { bool pucch_cfg_isvalid(pucch_cfg_t *cfg) {
return true; return true;
@ -50,18 +50,18 @@ bool pucch_cfg_isvalid(pucch_cfg_t *cfg) {
/* Generates n_cs_cell according to Sec 5.4 of 36.211 */ /* Generates n_cs_cell according to Sec 5.4 of 36.211 */
int generate_n_cs_cell(srslte_cell_t cell, uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NSYMB]) int generate_n_cs_cell(srslte_cell_t cell, uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB])
{ {
sequence_t seq; sequence_t seq;
bzero(&seq, sizeof(sequence_t)); bzero(&seq, sizeof(sequence_t));
sequence_LTE_pr(&seq, 8*CP_NSYMB(cell.cp)*SRSLTE_NSLOTS_X_FRAME, cell.id); sequence_LTE_pr(&seq, 8*SRSLTE_CP_NSYMB(cell.cp)*SRSLTE_NSLOTS_X_FRAME, cell.id);
for (uint32_t ns=0;ns<SRSLTE_NSLOTS_X_FRAME;ns++) { for (uint32_t ns=0;ns<SRSLTE_NSLOTS_X_FRAME;ns++) {
for (uint32_t l=0;l<CP_NSYMB(cell.cp);l++) { for (uint32_t l=0;l<SRSLTE_CP_NSYMB(cell.cp);l++) {
n_cs_cell[ns][l] = 0; n_cs_cell[ns][l] = 0;
for (uint32_t i=0;i<8;i++) { for (uint32_t i=0;i<8;i++) {
n_cs_cell[ns][l] += seq.c[8*CP_NSYMB(cell.cp)*ns+8*l+i]<<i; n_cs_cell[ns][l] += seq.c[8*SRSLTE_CP_NSYMB(cell.cp)*ns+8*l+i]<<i;
} }
} }
} }
@ -71,13 +71,13 @@ int generate_n_cs_cell(srslte_cell_t cell, uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FR
/* Calculates alpha according to 5.5.2.2.2 of 36.211 */ /* Calculates alpha according to 5.5.2.2.2 of 36.211 */
float pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NSYMB], float pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB],
pucch_cfg_t *cfg, pucch_cfg_t *cfg,
srslte_cp_t cp, bool is_drms, srslte_cp_t cp, bool is_drms,
uint32_t ns, uint32_t l, uint32_t ns, uint32_t l,
uint32_t *n_oc_ptr) uint32_t *n_oc_ptr)
{ {
uint32_t c = CP_ISNORM(cp)?3:2; uint32_t c = SRSLTE_CP_ISNORM(cp)?3:2;
uint32_t N_prime = (cfg->n_pucch < c*cfg->N_cs/cfg->delta_pucch_shift)?cfg->N_cs:12; uint32_t N_prime = (cfg->n_pucch < c*cfg->N_cs/cfg->delta_pucch_shift)?cfg->N_cs:12;
uint32_t n_prime = cfg->n_pucch; uint32_t n_prime = cfg->n_pucch;
@ -85,17 +85,17 @@ float pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CPNORM_NS
n_prime = (cfg->n_pucch-c*cfg->N_cs/cfg->delta_pucch_shift)%(cfg->N_cs/cfg->delta_pucch_shift); n_prime = (cfg->n_pucch-c*cfg->N_cs/cfg->delta_pucch_shift)%(cfg->N_cs/cfg->delta_pucch_shift);
} }
uint32_t n_oc_div = (!is_drms && CP_ISEXT(cp))?2:1; uint32_t n_oc_div = (!is_drms && SRSLTE_CP_ISEXT(cp))?2:1;
uint32_t n_oc = n_prime*cfg->delta_pucch_shift/N_prime; uint32_t n_oc = n_prime*cfg->delta_pucch_shift/N_prime;
if (!is_drms && CP_ISEXT(cp)) { if (!is_drms && SRSLTE_CP_ISEXT(cp)) {
n_oc *= 2; n_oc *= 2;
} }
if (n_oc_ptr) { if (n_oc_ptr) {
*n_oc_ptr = n_oc; *n_oc_ptr = n_oc;
} }
uint32_t n_cs = 0; uint32_t n_cs = 0;
if (CP_ISNORM(cp)) { if (SRSLTE_CP_ISNORM(cp)) {
n_cs = (n_cs_cell[ns][l]+(n_prime*cfg->delta_pucch_shift+(n_oc%cfg->delta_pucch_shift))%N_prime)%12; n_cs = (n_cs_cell[ns][l]+(n_prime*cfg->delta_pucch_shift+(n_oc%cfg->delta_pucch_shift))%N_prime)%12;
} else { } else {
n_cs = (n_cs_cell[ns][l]+(n_prime*cfg->delta_pucch_shift+n_oc/n_oc_div)%N_prime)%12; n_cs = (n_cs_cell[ns][l]+(n_prime*cfg->delta_pucch_shift+n_oc/n_oc_div)%N_prime)%12;
@ -121,7 +121,7 @@ int pucch_get(pucch_t *q, harq_t *harq, cf_t *input, cf_t *output) {
/** Initializes the PDCCH transmitter and receiver */ /** Initializes the PDCCH transmitter and receiver */
int pucch_init(pucch_t *q, srslte_cell_t cell) { int pucch_init(pucch_t *q, srslte_cell_t cell) {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && lte_cell_isvalid(&cell)) { if (q != NULL && srslte_cell_isvalid(&cell)) {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
bzero(q, sizeof(pucch_t)); bzero(q, sizeof(pucch_t));

@ -42,11 +42,11 @@
#include "srslte/utils/vector.h" #include "srslte/utils/vector.h"
#include "srslte/filter/dft_precoding.h" #include "srslte/filter/dft_precoding.h"
#define MAX_PUSCH_RE(cp) (2 * CP_NSYMB(cp) * 12) #define MAX_PUSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12)
const static lte_mod_t modulations[4] = const static srslte_mod_t modulations[4] =
{ LTE_BPSK, LTE_QPSK, LTE_QAM16, LTE_QAM64 }; { LTE_BPSK, LTE_QPSK, LTE_QAM16, LTE_QAM64 };
static int f_hop_sum(pusch_t *q, uint32_t i) { static int f_hop_sum(pusch_t *q, uint32_t i) {
@ -90,7 +90,7 @@ int pusch_cp(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output, bool advance_i
pusch_hopping_cfg_t *hopping = &q->hopping_cfg; pusch_hopping_cfg_t *hopping = &q->hopping_cfg;
uint32_t L_ref = 3; uint32_t L_ref = 3;
if (CP_ISEXT(q->cell.cp)) { if (SRSLTE_CP_ISEXT(q->cell.cp)) {
L_ref = 2; L_ref = 2;
} }
INFO("PUSCH Freq hopping: %d\n", harq->ul_alloc.freq_hopping); INFO("PUSCH Freq hopping: %d\n", harq->ul_alloc.freq_hopping);
@ -131,25 +131,25 @@ int pusch_cp(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output, bool advance_i
} }
harq->ul_alloc.n_prb_tilde[slot] = n_prb_tilde; harq->ul_alloc.n_prb_tilde[slot] = n_prb_tilde;
INFO("Allocating PUSCH %d PRB to index %d at slot %d\n",harq->ul_alloc.L_prb, n_prb_tilde,slot); INFO("Allocating PUSCH %d PRB to index %d at slot %d\n",harq->ul_alloc.L_prb, n_prb_tilde,slot);
for (uint32_t l=0;l<CP_NSYMB(q->cell.cp);l++) { for (uint32_t l=0;l<SRSLTE_CP_NSYMB(q->cell.cp);l++) {
if (l != L_ref) { if (l != L_ref) {
uint32_t idx = RE_IDX(q->cell.nof_prb, l+slot*CP_NSYMB(q->cell.cp), uint32_t idx = SRSLTE_RE_IDX(q->cell.nof_prb, l+slot*SRSLTE_CP_NSYMB(q->cell.cp),
n_prb_tilde*RE_X_RB); n_prb_tilde*SRSLTE_NRE);
if (advance_input) { if (advance_input) {
out_ptr = &output[idx]; out_ptr = &output[idx];
} else { } else {
in_ptr = &input[idx]; in_ptr = &input[idx];
} }
memcpy(out_ptr, in_ptr, harq->ul_alloc.L_prb * RE_X_RB * sizeof(cf_t)); memcpy(out_ptr, in_ptr, harq->ul_alloc.L_prb * SRSLTE_NRE * sizeof(cf_t));
if (advance_input) { if (advance_input) {
in_ptr += harq->ul_alloc.L_prb*RE_X_RB; in_ptr += harq->ul_alloc.L_prb*SRSLTE_NRE;
} else { } else {
out_ptr += harq->ul_alloc.L_prb*RE_X_RB; out_ptr += harq->ul_alloc.L_prb*SRSLTE_NRE;
} }
} }
} }
} }
return RE_X_RB*harq->ul_alloc.L_prb; return SRSLTE_NRE*harq->ul_alloc.L_prb;
} }
int pusch_put(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output) { int pusch_put(pusch_t *q, harq_t *harq, cf_t *input, cf_t *output) {
@ -167,7 +167,7 @@ int pusch_init(pusch_t *q, srslte_cell_t cell) {
int i; int i;
if (q != NULL && if (q != NULL &&
lte_cell_isvalid(&cell)) srslte_cell_isvalid(&cell))
{ {
bzero(q, sizeof(pusch_t)); bzero(q, sizeof(pusch_t));
@ -202,7 +202,7 @@ int pusch_init(pusch_t *q, srslte_cell_t cell) {
} }
/* This is for equalization at receiver */ /* This is for equalization at receiver */
if (precoding_init(&q->equalizer, SF_LEN_RE(cell.nof_prb, cell.cp))) { if (precoding_init(&q->equalizer, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) {
fprintf(stderr, "Error initializing precoding\n"); fprintf(stderr, "Error initializing precoding\n");
goto clean; goto clean;
} }
@ -210,13 +210,13 @@ int pusch_init(pusch_t *q, srslte_cell_t cell) {
q->rnti_is_set = false; q->rnti_is_set = false;
// Allocate floats for reception (LLRs). Buffer casted to uint8_t for transmission // Allocate floats for reception (LLRs). Buffer casted to uint8_t for transmission
q->pusch_q = vec_malloc(sizeof(float) * q->max_re * lte_mod_bits_x_symbol(LTE_QAM64)); q->pusch_q = vec_malloc(sizeof(float) * q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64));
if (!q->pusch_q) { if (!q->pusch_q) {
goto clean; goto clean;
} }
// Allocate floats for reception (LLRs). Buffer casted to uint8_t for transmission // Allocate floats for reception (LLRs). Buffer casted to uint8_t for transmission
q->pusch_g = vec_malloc(sizeof(float) * q->max_re * lte_mod_bits_x_symbol(LTE_QAM64)); q->pusch_g = vec_malloc(sizeof(float) * q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64));
if (!q->pusch_g) { if (!q->pusch_g) {
goto clean; goto clean;
} }
@ -293,7 +293,7 @@ int pusch_set_rnti(pusch_t *q, uint16_t rnti) {
for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) { for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) {
if (sequence_pusch(&q->seq_pusch[i], rnti, 2 * i, q->cell.id, if (sequence_pusch(&q->seq_pusch[i], rnti, 2 * i, q->cell.id,
q->max_re * lte_mod_bits_x_symbol(LTE_QAM64))) { q->max_re * srslte_mod_bits_x_symbol(LTE_QAM64))) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
} }
@ -317,7 +317,7 @@ int pusch_decode(pusch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce, float noi
if (q->rnti_is_set) { if (q->rnti_is_set) {
INFO("Decoding PUSCH SF: %d, Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", INFO("Decoding PUSCH SF: %d, Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n",
harq->sf_idx, lte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); harq->sf_idx, srslte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv);
/* extract symbols */ /* extract symbols */
n = pusch_get(q, harq, sf_symbols, q->pusch_d); n = pusch_get(q, harq, sf_symbols, q->pusch_d);
@ -411,7 +411,7 @@ int pusch_uci_encode_rnti(pusch_t *q, harq_t *harq, uint8_t *data, uci_data_t uc
} }
INFO("Encoding PUSCH SF: %d, Mod %s, RNTI: %d, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", INFO("Encoding PUSCH SF: %d, Mod %s, RNTI: %d, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n",
harq->sf_idx, lte_mod_string(harq->mcs.mod), rnti, harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); harq->sf_idx, srslte_mod_string(harq->mcs.mod), rnti, harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv);
bzero(q->pusch_q, harq->nof_bits); bzero(q->pusch_q, harq->nof_bits);
if (ulsch_uci_encode(&q->dl_sch, harq, data, uci_data, q->pusch_g, q->pusch_q)) { if (ulsch_uci_encode(&q->dl_sch, harq, data, uci_data, q->pusch_g, q->pusch_q)) {

@ -48,9 +48,9 @@ uint32_t ra_re_x_prb(uint32_t subframe, uint32_t slot, uint32_t prb_idx, uint32_
bool skip_refs = false; bool skip_refs = false;
if (slot == 0) { if (slot == 0) {
re = (CP_NSYMB(cp) - nof_ctrl_symbols) * RE_X_RB; re = (SRSLTE_CP_NSYMB(cp) - nof_ctrl_symbols) * SRSLTE_NRE;
} else { } else {
re = CP_NSYMB(cp) * RE_X_RB; re = SRSLTE_CP_NSYMB(cp) * SRSLTE_NRE;
} }
/* if it's the prb in the middle, there are less RE due to PBCH and PSS/SSS */ /* if it's the prb in the middle, there are less RE due to PBCH and PSS/SSS */
@ -58,27 +58,27 @@ uint32_t ra_re_x_prb(uint32_t subframe, uint32_t slot, uint32_t prb_idx, uint32_
&& (prb_idx >= nof_prb / 2 - 3 && prb_idx < nof_prb / 2 + 3)) { && (prb_idx >= nof_prb / 2 - 3 && prb_idx < nof_prb / 2 + 3)) {
if (subframe == 0) { if (subframe == 0) {
if (slot == 0) { if (slot == 0) {
re = (CP_NSYMB(cp) - nof_ctrl_symbols - 2) * RE_X_RB; re = (SRSLTE_CP_NSYMB(cp) - nof_ctrl_symbols - 2) * SRSLTE_NRE;
} else { } else {
if (CP_ISEXT(cp)) { if (SRSLTE_CP_ISEXT(cp)) {
re = (CP_NSYMB(cp) - 4) * RE_X_RB; re = (SRSLTE_CP_NSYMB(cp) - 4) * SRSLTE_NRE;
skip_refs = true; skip_refs = true;
} else { } else {
re = (CP_NSYMB(cp) - 4) * RE_X_RB + 2 * nof_ports; re = (SRSLTE_CP_NSYMB(cp) - 4) * SRSLTE_NRE + 2 * nof_ports;
} }
} }
} else if (subframe == 5) { } else if (subframe == 5) {
if (slot == 0) { if (slot == 0) {
re = (CP_NSYMB(cp) - nof_ctrl_symbols - 2) * RE_X_RB; re = (SRSLTE_CP_NSYMB(cp) - nof_ctrl_symbols - 2) * SRSLTE_NRE;
} }
} }
if ((nof_prb % 2) if ((nof_prb % 2)
&& (prb_idx == nof_prb / 2 - 3 || prb_idx == nof_prb / 2 + 3)) { && (prb_idx == nof_prb / 2 - 3 || prb_idx == nof_prb / 2 + 3)) {
if (slot == 0) { if (slot == 0) {
re += 2 * RE_X_RB / 2; re += 2 * SRSLTE_NRE / 2;
} else if (subframe == 0) { } else if (subframe == 0) {
re += 4 * RE_X_RB / 2 - nof_ports; re += 4 * SRSLTE_NRE / 2 - nof_ports;
if (CP_ISEXT(cp)) { if (SRSLTE_CP_ISEXT(cp)) {
re -= nof_ports > 2 ? 2 : nof_ports; re -= nof_ports > 2 ? 2 : nof_ports;
} }
} }
@ -497,7 +497,7 @@ int ra_tbs_from_idx_format1c(uint32_t tbs_idx) {
/* Downlink Transport Block size determination as defined in 7.1.7.2 on 36.213 */ /* 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 ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb) {
if (tbs_idx < 27 && n_prb > 0 && n_prb <= MAX_PRB) { if (tbs_idx < 27 && n_prb > 0 && n_prb <= SRSLTE_MAX_PRB) {
return tbs_table[tbs_idx][n_prb - 1]; return tbs_table[tbs_idx][n_prb - 1];
} else { } else {
return SRSLTE_ERROR; return SRSLTE_ERROR;
@ -509,7 +509,7 @@ int ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb) {
*/ */
int ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb) { int ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb) {
uint32_t idx; uint32_t idx;
if (n_prb > 0 && n_prb <= MAX_PRB) { if (n_prb > 0 && n_prb <= SRSLTE_MAX_PRB) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (tbs < tbs_table[0][n_prb]) { if (tbs < tbs_table[0][n_prb]) {
@ -549,7 +549,7 @@ void ra_pusch_fprint(FILE *f, ra_pusch_t *ra, uint32_t nof_prb) {
fprintf(f, " - Number of PRBs:\t\t\t%d\n", ra_nprb_ul(ra, nof_prb)); fprintf(f, " - Number of PRBs:\t\t\t%d\n", ra_nprb_ul(ra, nof_prb));
fprintf(f, " - Modulation and coding scheme index:\t%d\n", ra->mcs_idx); fprintf(f, " - Modulation and coding scheme index:\t%d\n", ra->mcs_idx);
fprintf(f, " - Modulation type:\t\t\t%s\n", lte_mod_string(ra->mcs.mod)); fprintf(f, " - Modulation type:\t\t\t%s\n", srslte_mod_string(ra->mcs.mod));
fprintf(f, " - Transport block size:\t\t%d\n", ra->mcs.tbs); fprintf(f, " - Transport block size:\t\t%d\n", ra->mcs.tbs);
fprintf(f, " - New data indicator:\t\t\t%s\n", ra->ndi ? "Yes" : "No"); fprintf(f, " - New data indicator:\t\t\t%s\n", ra->ndi ? "Yes" : "No");
fprintf(f, " - Redundancy version:\t\t\t%d\n", ra->rv_idx); fprintf(f, " - Redundancy version:\t\t\t%d\n", ra->rv_idx);
@ -612,7 +612,7 @@ void ra_pdsch_fprint(FILE *f, ra_pdsch_t *ra, uint32_t nof_prb) {
fprintf(f, " - Number of PRBs:\t\t\t%d\n", ra_nprb_dl(ra, nof_prb)); fprintf(f, " - Number of PRBs:\t\t\t%d\n", ra_nprb_dl(ra, nof_prb));
fprintf(f, " - Modulation and coding scheme index:\t%d\n", ra->mcs_idx); fprintf(f, " - Modulation and coding scheme index:\t%d\n", ra->mcs_idx);
fprintf(f, " - Modulation type:\t\t\t%s\n", lte_mod_string(ra->mcs.mod)); fprintf(f, " - Modulation type:\t\t\t%s\n", srslte_mod_string(ra->mcs.mod));
fprintf(f, " - Transport block size:\t\t%d\n", ra->mcs.tbs); fprintf(f, " - Transport block size:\t\t%d\n", ra->mcs.tbs);
fprintf(f, " - HARQ process:\t\t\t%d\n", ra->harq_process); fprintf(f, " - HARQ process:\t\t\t%d\n", ra->harq_process);
fprintf(f, " - New data indicator:\t\t\t%s\n", ra->ndi ? "Yes" : "No"); fprintf(f, " - New data indicator:\t\t\t%s\n", ra->ndi ? "Yes" : "No");

@ -34,7 +34,7 @@
#include "srslte/phch/regs.h" #include "srslte/phch/regs.h"
#include "srslte/utils/debug.h" #include "srslte/utils/debug.h"
#define REG_IDX(r, i, n) r->k[i]+r->l*n*RE_X_RB #define REG_IDX(r, i, n) r->k[i]+r->l*n*SRSLTE_NRE
regs_reg_t *regs_find_reg(regs_t *h, uint32_t k, uint32_t l); regs_reg_t *regs_find_reg(regs_t *h, uint32_t k, uint32_t l);
@ -240,16 +240,16 @@ int regs_phich_init(regs_t *h) {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
switch(h->phich_res) { switch(h->phich_res) {
case R_1_6: case SRSLTE_PHICH_SRSLTE_PHICH_R_1_6:
ng = (float) 1/6; ng = (float) 1/6;
break; break;
case R_1_2: case SRSLTE_PHICH_SRSLTE_PHICH_R_1_2:
ng = (float) 1/2; ng = (float) 1/2;
break; break;
case R_1: case SRSLTE_PHICH_R_1:
ng = 1; ng = 1;
break; break;
case R_2: case SRSLTE_PHICH_R_2:
ng = 2; ng = 2;
break; break;
default: default:
@ -263,7 +263,7 @@ int regs_phich_init(regs_t *h) {
return -1; return -1;
} }
INFO("Creating %d PHICH mapping units. %s length, Ng=%.2f\n",h->ngroups_phich, INFO("Creating %d PHICH mapping units. %s length, Ng=%.2f\n",h->ngroups_phich,
h->phich_len==PHICH_EXT?"Extended":"Normal",ng); h->phich_len==SRSLTE_PHICH_EXT?"Extended":"Normal",ng);
for (i=0;i<h->ngroups_phich;i++) { for (i=0;i<h->ngroups_phich;i++) {
h->phich[i].nof_regs = REGS_PHICH_REGS_X_GROUP; 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(regs_reg_t*) * REGS_PHICH_REGS_X_GROUP);
@ -304,7 +304,7 @@ int regs_phich_init(regs_t *h) {
nreg=0; nreg=0;
for (mi=0;mi<h->ngroups_phich;mi++) { // here ngroups is the number of mapping units for (mi=0;mi<h->ngroups_phich;mi++) { // here ngroups is the number of mapping units
for (i=0;i<3;i++) { for (i=0;i<3;i++) {
li=h->phich_len==PHICH_EXT?i:0; // Step 7 li=h->phich_len==SRSLTE_PHICH_EXT?i:0; // Step 7
ni=((h->cell.id*n[li]/n[0])+mi+i*n[li]/3) % n[li]; // Step 8 ni=((h->cell.id*n[li]/n[0])+mi+i*n[li]/3) % n[li]; // Step 8
h->phich[mi].regs[i] = regs_phich[li][ni]; h->phich[mi].regs[i] = regs_phich[li][ni];
h->phich[mi].regs[i]->assigned = true; h->phich[mi].regs[i]->assigned = true;
@ -315,7 +315,7 @@ int regs_phich_init(regs_t *h) {
// now the number of mapping units = number of groups for normal cp. For extended cp // now the number of mapping units = number of groups for normal cp. For extended cp
// ngroups = 2 * number mapping units // ngroups = 2 * number mapping units
if (CP_ISEXT(h->cell.cp)) { if (SRSLTE_CP_ISEXT(h->cell.cp)) {
h->ngroups_phich *= 2; h->ngroups_phich *= 2;
} }
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
@ -342,7 +342,7 @@ clean_and_exit:
void regs_phich_free(regs_t *h) { void regs_phich_free(regs_t *h) {
uint32_t i; uint32_t i;
if (h->phich) { if (h->phich) {
if (CP_ISEXT(h->cell.cp)) { if (SRSLTE_CP_ISEXT(h->cell.cp)) {
h->ngroups_phich /= 2; h->ngroups_phich /= 2;
} }
for (i=0;i<h->ngroups_phich;i++) { for (i=0;i<h->ngroups_phich;i++) {
@ -384,7 +384,7 @@ int regs_phich_add(regs_t *h, cf_t phich_symbols[REGS_PHICH_NSYM], uint32_t ngro
fprintf(stderr, "Error invalid ngroup %d\n", ngroup); fprintf(stderr, "Error invalid ngroup %d\n", ngroup);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
if (CP_ISEXT(h->cell.cp)) { if (SRSLTE_CP_ISEXT(h->cell.cp)) {
ngroup /= 2; ngroup /= 2;
} }
regs_ch_t *rch = &h->phich[ngroup]; regs_ch_t *rch = &h->phich[ngroup];
@ -402,8 +402,8 @@ int regs_phich_add(regs_t *h, cf_t phich_symbols[REGS_PHICH_NSYM], uint32_t ngro
int regs_phich_reset(regs_t *h, cf_t *slot_symbols) { int regs_phich_reset(regs_t *h, cf_t *slot_symbols) {
uint32_t i; uint32_t i;
uint32_t ngroup, ng; uint32_t ngroup, ng;
for (ngroup = 0;ngroup < h->ngroups_phich;CP_ISEXT(h->cell.cp)?ngroup+=2:ngroup++) { for (ngroup = 0;ngroup < h->ngroups_phich;SRSLTE_CP_ISEXT(h->cell.cp)?ngroup+=2:ngroup++) {
if (CP_ISEXT(h->cell.cp)) { if (SRSLTE_CP_ISEXT(h->cell.cp)) {
ng = ngroup/2; ng = ngroup/2;
} else { } else {
ng = ngroup; ng = ngroup;
@ -427,7 +427,7 @@ int regs_phich_get(regs_t *h, cf_t *slot_symbols, cf_t phich_symbols[REGS_PHICH_
fprintf(stderr, "Error invalid ngroup %d\n", ngroup); fprintf(stderr, "Error invalid ngroup %d\n", ngroup);
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
if (CP_ISEXT(h->cell.cp)) { if (SRSLTE_CP_ISEXT(h->cell.cp)) {
ngroup /= 2; ngroup /= 2;
} }
regs_ch_t *rch = &h->phich[ngroup]; regs_ch_t *rch = &h->phich[ngroup];
@ -470,11 +470,11 @@ int regs_pcfich_init(regs_t *h) {
INFO("PCFICH allocating %d regs. CellID: %d, PRB: %d\n", ch->nof_regs, h->cell.id, h->cell.nof_prb); INFO("PCFICH allocating %d regs. CellID: %d, PRB: %d\n", ch->nof_regs, h->cell.id, h->cell.nof_prb);
k_hat = (RE_X_RB / 2) * (h->cell.id % (2 * h->cell.nof_prb)); k_hat = (SRSLTE_NRE / 2) * (h->cell.id % (2 * h->cell.nof_prb));
for (i = 0; i < REGS_PCFICH_NREGS; i++) { for (i = 0; i < REGS_PCFICH_NREGS; i++) {
k = (k_hat + (i * h->cell.nof_prb / 2) * (RE_X_RB / 2)) k = (k_hat + (i * h->cell.nof_prb / 2) * (SRSLTE_NRE / 2))
% (h->cell.nof_prb * RE_X_RB); % (h->cell.nof_prb * SRSLTE_NRE);
ch->regs[i] = regs_find_reg(h, k, 0); ch->regs[i] = regs_find_reg(h, k, 0);
if (!ch->regs[i]) { if (!ch->regs[i]) {
fprintf(stderr, "Error allocating PCFICH: REG (%d,0) not found\n", fprintf(stderr, "Error allocating PCFICH: REG (%d,0) not found\n",
@ -586,7 +586,7 @@ int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, srslte_cp_t cp) {
case 2: case 2:
return 3; return 3;
case 3: case 3:
if (CP_ISNORM(cp)) { if (SRSLTE_CP_ISNORM(cp)) {
return 3; return 3;
} else { } else {
return 2; return 2;
@ -660,7 +660,7 @@ void regs_free(regs_t *h) {
*/ */
int regs_set_cfi(regs_t *h, uint32_t cfi) { int regs_set_cfi(regs_t *h, uint32_t cfi) {
if (cfi > 0 && cfi <= 3) { if (cfi > 0 && cfi <= 3) {
if (h->phich_len == PHICH_EXT && if (h->phich_len == SRSLTE_PHICH_EXT &&
((h->cell.nof_prb < 10 && cfi < 2) || (h->cell.nof_prb >= 10 && cfi < 3))) { ((h->cell.nof_prb < 10 && cfi < 2) || (h->cell.nof_prb >= 10 && cfi < 3))) {
fprintf(stderr, "PHICH length is extended. The number of control symbols should be at least 3.\n"); fprintf(stderr, "PHICH length is extended. The number of control symbols should be at least 3.\n");
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
@ -688,7 +688,7 @@ int regs_init(regs_t *h, srslte_cell_t cell) {
uint32_t max_ctrl_symbols; uint32_t max_ctrl_symbols;
if (h != NULL && if (h != NULL &&
lte_cell_isvalid(&cell)) srslte_cell_isvalid(&cell))
{ {
bzero(h, sizeof(regs_t)); bzero(h, sizeof(regs_t));
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
@ -710,7 +710,7 @@ int regs_init(regs_t *h, srslte_cell_t cell) {
h->nof_regs += h->cell.nof_prb * n[i]; h->nof_regs += h->cell.nof_prb * n[i];
} }
INFO("Indexing %d REGs. CellId: %d, %d PRB, CP: %s\n", h->nof_regs, h->cell.id, h->cell.nof_prb, INFO("Indexing %d REGs. CellId: %d, %d PRB, CP: %s\n", h->nof_regs, h->cell.id, h->cell.nof_prb,
CP_ISNORM(h->cell.cp)?"Normal":"Extended"); SRSLTE_CP_ISNORM(h->cell.cp)?"Normal":"Extended");
h->regs = malloc(sizeof(regs_reg_t) * h->nof_regs); h->regs = malloc(sizeof(regs_reg_t) * h->nof_regs);
if (!h->regs) { if (!h->regs) {
perror("malloc"); perror("malloc");
@ -722,7 +722,7 @@ int regs_init(regs_t *h, srslte_cell_t cell) {
k = i = prb = jmax = 0; k = i = prb = jmax = 0;
while (k < h->nof_regs) { while (k < h->nof_regs) {
if (n[i] == 3 || (n[i] == 2 && jmax != 1)) { if (n[i] == 3 || (n[i] == 2 && jmax != 1)) {
if (regs_reg_init(&h->regs[k], i, j[i], prb * RE_X_RB, n[i], vo)) { if (regs_reg_init(&h->regs[k], i, j[i], prb * SRSLTE_NRE, n[i], vo)) {
fprintf(stderr, "Error initializing REGs\n"); fprintf(stderr, "Error initializing REGs\n");
goto clean_and_exit; goto clean_and_exit;
} }

@ -48,11 +48,11 @@ int sch_init(sch_t *q) {
if (q) { if (q) {
bzero(q, sizeof(sch_t)); bzero(q, sizeof(sch_t));
if (crc_init(&q->crc_tb, LTE_CRC24A, 24)) { if (crc_init(&q->crc_tb, SRSLTE_LTE_CRC24A, 24)) {
fprintf(stderr, "Error initiating CRC\n"); fprintf(stderr, "Error initiating CRC\n");
goto clean; goto clean;
} }
if (crc_init(&q->crc_cb, LTE_CRC24B, 24)) { if (crc_init(&q->crc_cb, SRSLTE_LTE_CRC24B, 24)) {
fprintf(stderr, "Error initiating CRC\n"); fprintf(stderr, "Error initiating CRC\n");
goto clean; goto clean;
} }
@ -124,7 +124,7 @@ static int encode_tb(sch_t *q, harq_t *harq, uint8_t *data, uint8_t *e_bits, uin
uint32_t i; uint32_t i;
uint32_t cb_len, rp, wp, rlen, F, n_e; uint32_t cb_len, rp, wp, rlen, F, n_e;
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
uint32_t Qm = lte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Qm = srslte_mod_bits_x_symbol(harq->mcs.mod);
if (q != NULL && if (q != NULL &&
data != NULL && data != NULL &&
@ -246,7 +246,7 @@ static int decode_tb(sch_t *q, harq_t *harq, float *e_bits, uint8_t *data, uint3
uint32_t par_rx, par_tx; uint32_t par_rx, par_tx;
uint32_t i; uint32_t i;
uint32_t cb_len, rp, wp, rlen, F, n_e; uint32_t cb_len, rp, wp, rlen, F, n_e;
uint32_t Qm = lte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Qm = srslte_mod_bits_x_symbol(harq->mcs.mod);
if (q != NULL && if (q != NULL &&
data != NULL && data != NULL &&
@ -450,9 +450,9 @@ int ulsch_uci_encode(sch_t *q, harq_t *harq, uint8_t *data, uci_data_t uci_data,
uint32_t Q_prime_cqi = 0; uint32_t Q_prime_cqi = 0;
uint32_t Q_prime_ack = 0; uint32_t Q_prime_ack = 0;
uint32_t Q_prime_ri = 0; uint32_t Q_prime_ri = 0;
uint32_t Q_m = lte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod);
uint32_t nof_symbols = 12*harq->ul_alloc.L_prb*RE_X_RB; uint32_t nof_symbols = 12*harq->ul_alloc.L_prb*SRSLTE_NRE;
uint32_t nb_q = nof_symbols * Q_m; uint32_t nb_q = nof_symbols * Q_m;
bzero(q_bits, sizeof(uint8_t) * nb_q); bzero(q_bits, sizeof(uint8_t) * nb_q);

@ -35,7 +35,7 @@
*/ */
int sequence_pbch(sequence_t *seq, srslte_cp_t cp, uint32_t cell_id) { int sequence_pbch(sequence_t *seq, srslte_cp_t cp, uint32_t cell_id) {
bzero(seq, sizeof(sequence_t)); bzero(seq, sizeof(sequence_t));
return sequence_LTE_pr(seq, CP_ISNORM(cp)?1920:1728, cell_id); return sequence_LTE_pr(seq, SRSLTE_CP_ISNORM(cp)?1920:1728, cell_id);
} }
/** /**

@ -104,7 +104,7 @@ static uint8_t M_basis_seq_pucch[20][13]={
}; };
int uci_cqi_init(uci_cqi_pusch_t *q) { int uci_cqi_init(uci_cqi_pusch_t *q) {
if (crc_init(&q->crc, LTE_CRC8, 8)) { if (crc_init(&q->crc, SRSLTE_LTE_CRC8, 8)) {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -115,20 +115,20 @@ void uci_cqi_free(uci_cqi_pusch_t *q) {
} }
static uint32_t Q_prime_cqi(uint32_t O, float beta, uint32_t Q_prime_ri, harq_t *harq) { static uint32_t Q_prime_cqi(uint32_t O, float beta, uint32_t Q_prime_ri, harq_t *harq) {
uint32_t M_sc = harq->ul_alloc.L_prb * RE_X_RB; uint32_t M_sc = harq->ul_alloc.L_prb * SRSLTE_NRE;
uint32_t K = harq->cb_segm.C1*harq->cb_segm.K1 + uint32_t K = harq->cb_segm.C1*harq->cb_segm.K1 +
harq->cb_segm.C2*harq->cb_segm.K2; harq->cb_segm.C2*harq->cb_segm.K2;
uint32_t Q_prime = 0; uint32_t Q_prime = 0;
if (K > 0) { if (K > 0) {
uint32_t M_sc_init = harq->nof_prb * RE_X_RB; uint32_t M_sc_init = harq->nof_prb * SRSLTE_NRE;
uint32_t L = (O<11)?0:8; uint32_t L = (O<11)?0:8;
uint32_t x = (uint32_t) ceilf((float) (O+L)*M_sc_init*harq->nof_symb*beta/K); 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 = MIN(x, M_sc * harq->nof_symb - Q_prime_ri);
} else { } else {
Q_prime = 12*harq->ul_alloc.L_prb*RE_X_RB - Q_prime_ri; Q_prime = 12*harq->ul_alloc.L_prb*SRSLTE_NRE - Q_prime_ri;
} }
return Q_prime; return Q_prime;
@ -222,7 +222,7 @@ int uci_encode_cqi_pusch(uci_cqi_pusch_t *q, uint8_t *cqi_data, uint32_t cqi_len
{ {
uint32_t Q_prime = Q_prime_cqi(cqi_len, beta, Q_prime_ri, harq); uint32_t Q_prime = Q_prime_cqi(cqi_len, beta, Q_prime_ri, harq);
uint32_t Q_m = lte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod);
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
if (cqi_len <= 11) { if (cqi_len <= 11) {
@ -248,7 +248,7 @@ static int uci_ulsch_interleave_ack(uint8_t ack_coded_bits[6], uint32_t ack_q_bi
if (H_prime_total/N_pusch_symbs >= 1+ack_q_bit_idx/4) { if (H_prime_total/N_pusch_symbs >= 1+ack_q_bit_idx/4) {
uint32_t row = H_prime_total/N_pusch_symbs-1-ack_q_bit_idx/4; uint32_t row = H_prime_total/N_pusch_symbs-1-ack_q_bit_idx/4;
uint32_t colidx = (3*ack_q_bit_idx)%4; uint32_t colidx = (3*ack_q_bit_idx)%4;
uint32_t col = CP_ISNORM(cp)?ack_column_set_norm[colidx]:ack_column_set_ext[colidx]; uint32_t col = SRSLTE_CP_ISNORM(cp)?ack_column_set_norm[colidx]:ack_column_set_ext[colidx];
for(uint32_t k=0; k<Q_m; k++) { for(uint32_t k=0; k<Q_m; k++) {
q_bits[row *Q_m + q_bits[row *Q_m +
(H_prime_total/N_pusch_symbs)*col*Q_m + k] = ack_coded_bits[k]; (H_prime_total/N_pusch_symbs)*col*Q_m + k] = ack_coded_bits[k];
@ -272,7 +272,7 @@ static int uci_ulsch_interleave_ri(uint8_t ri_coded_bits[6], uint32_t ri_q_bit_i
if (H_prime_total/N_pusch_symbs >= 1+ri_q_bit_idx/4) { if (H_prime_total/N_pusch_symbs >= 1+ri_q_bit_idx/4) {
uint32_t row = H_prime_total/N_pusch_symbs-1-ri_q_bit_idx/4; uint32_t row = H_prime_total/N_pusch_symbs-1-ri_q_bit_idx/4;
uint32_t colidx = (3*ri_q_bit_idx)%4; uint32_t colidx = (3*ri_q_bit_idx)%4;
uint32_t col = CP_ISNORM(cp)?ri_column_set_norm[colidx]:ri_column_set_ext[colidx]; uint32_t col = SRSLTE_CP_ISNORM(cp)?ri_column_set_norm[colidx]:ri_column_set_ext[colidx];
printf("r=%d-%d\n",H_prime_total/N_pusch_symbs,1+ri_q_bit_idx/4); printf("r=%d-%d\n",H_prime_total/N_pusch_symbs,1+ri_q_bit_idx/4);
for(uint32_t k=0; k<Q_m; k++) { for(uint32_t k=0; k<Q_m; k++) {
q_bits[row *Q_m + (H_prime_total/N_pusch_symbs)*col*Q_m + k] = 10+ri_coded_bits[k]; q_bits[row *Q_m + (H_prime_total/N_pusch_symbs)*col*Q_m + k] = 10+ri_coded_bits[k];
@ -287,7 +287,7 @@ static int uci_ulsch_interleave_ri(uint8_t ri_coded_bits[6], uint32_t ri_q_bit_i
} }
static uint32_t Q_prime_ri_ack(uint32_t O, uint32_t O_cqi, float beta, harq_t *harq) { static uint32_t Q_prime_ri_ack(uint32_t O, uint32_t O_cqi, float beta, harq_t *harq) {
uint32_t M_sc = harq->ul_alloc.L_prb * RE_X_RB; uint32_t M_sc = harq->ul_alloc.L_prb * SRSLTE_NRE;
uint32_t K = harq->cb_segm.C1*harq->cb_segm.K1 + uint32_t K = harq->cb_segm.C1*harq->cb_segm.K1 +
harq->cb_segm.C2*harq->cb_segm.K2; harq->cb_segm.C2*harq->cb_segm.K2;
@ -301,7 +301,7 @@ static uint32_t Q_prime_ri_ack(uint32_t O, uint32_t O_cqi, float beta, harq_t *h
} }
} }
uint32_t M_sc_init = harq->nof_prb * RE_X_RB; uint32_t M_sc_init = harq->nof_prb * SRSLTE_NRE;
uint32_t x = (uint32_t) ceilf((float) O*M_sc_init*harq->nof_symb*beta/K); uint32_t x = (uint32_t) ceilf((float) O*M_sc_init*harq->nof_symb*beta/K);
@ -323,7 +323,7 @@ static void encode_ri_ack(uint8_t data, uint8_t q_encoded_bits[6], uint8_t Q_m)
*/ */
int uci_encode_ack(uint8_t data, uint32_t O_cqi, float beta, harq_t *harq, uint32_t H_prime_total, uint8_t *q_bits) int uci_encode_ack(uint8_t data, uint32_t O_cqi, float beta, harq_t *harq, uint32_t H_prime_total, uint8_t *q_bits)
{ {
uint32_t Q_m = lte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod);
uint32_t Qprime = Q_prime_ri_ack(1, O_cqi, beta, harq); uint32_t Qprime = Q_prime_ri_ack(1, O_cqi, beta, harq);
uint8_t q_encoded_bits[6]; uint8_t q_encoded_bits[6];
@ -342,7 +342,7 @@ int uci_encode_ack(uint8_t data, uint32_t O_cqi, float beta, harq_t *harq, uint3
*/ */
int uci_encode_ri(uint8_t data, uint32_t O_cqi, float beta, harq_t *harq, uint32_t H_prime_total, uint8_t *q_bits) int uci_encode_ri(uint8_t data, uint32_t O_cqi, float beta, harq_t *harq, uint32_t H_prime_total, uint8_t *q_bits)
{ {
uint32_t Q_m = lte_mod_bits_x_symbol(harq->mcs.mod); uint32_t Q_m = srslte_mod_bits_x_symbol(harq->mcs.mod);
uint32_t Qprime = Q_prime_ri_ack(1, O_cqi, beta, harq); uint32_t Qprime = Q_prime_ri_ack(1, O_cqi, beta, harq);
uint8_t q_encoded_bits[6]; uint8_t q_encoded_bits[6];

@ -82,7 +82,7 @@ int main(int argc, char **argv) {
dci_msg_type_t dci_type; dci_msg_type_t dci_type;
msg.nof_bits = len; msg.nof_bits = len;
if (dci_msg_get_type(&msg, &dci_type, nof_prb, SIRNTI)) { if (dci_msg_get_type(&msg, &dci_type, nof_prb, SRSLTE_SIRNTI)) {
fprintf(stderr, "Can't obtain DCI message type\n"); fprintf(stderr, "Can't obtain DCI message type\n");
exit(-1); exit(-1);
} }

@ -39,16 +39,16 @@ srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
2, // nof_ports 2, // nof_ports
150, // cell_id 150, // cell_id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1, // PHICH resources SRSLTE_PHICH_R_1, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
int nof_frames = 1; int nof_frames = 1;
uint8_t bch_payload_file[BCH_PAYLOAD_LEN] = {0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; uint8_t bch_payload_file[BCH_PAYLOAD_LEN] = {0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
#define FLEN (10*SF_LEN(lte_symbol_sz(cell.nof_prb))) #define FLEN (10*SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb)))
filesource_t fsrc; filesource_t fsrc;
cf_t *input_buffer, *fft_buffer, *ce[SRSLTE_MAX_PORTS]; cf_t *input_buffer, *fft_buffer, *ce[SRSLTE_MAX_PORTS];
@ -86,7 +86,7 @@ void parse_args(int argc, char **argv) {
verbose++; verbose++;
break; break;
case 'e': case 'e':
cell.cp = CPEXT; cell.cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -113,21 +113,21 @@ int base_init() {
exit(-1); exit(-1);
} }
fft_buffer = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); fft_buffer = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!fft_buffer) { if (!fft_buffer) {
perror("malloc"); perror("malloc");
return -1; return -1;
} }
for (i=0;i<cell.nof_ports;i++) { for (i=0;i<cell.nof_ports;i++) {
ce[i] = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); ce[i] = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!ce[i]) { if (!ce[i]) {
perror("malloc"); perror("malloc");
return -1; return -1;
} }
} }
if (!lte_cell_isvalid(&cell)) { if (!srslte_cell_isvalid(&cell)) {
fprintf(stderr, "Invalid cell properties\n"); fprintf(stderr, "Invalid cell properties\n");
return -1; return -1;
} }
@ -203,11 +203,11 @@ int main(int argc, char **argv) {
INFO("Decoding PBCH\n", 0); INFO("Decoding PBCH\n", 0);
for (int i=0;i<SRSLTE_MAX_PORTS;i++) { for (int i=0;i<SRSLTE_MAX_PORTS;i++) {
ce_slot1[i] = &ce[i][SLOT_LEN_RE(cell.nof_prb, cell.cp)]; ce_slot1[i] = &ce[i][SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)];
} }
pbch_decode_reset(&pbch); pbch_decode_reset(&pbch);
n = pbch_decode(&pbch, &fft_buffer[SLOT_LEN_RE(cell.nof_prb, cell.cp)], n = pbch_decode(&pbch, &fft_buffer[SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)],
ce_slot1, srslte_chest_dl_get_noise_estimate(&chest), ce_slot1, srslte_chest_dl_get_noise_estimate(&chest),
bch_payload, &nof_tx_ports, &sfn_offset); bch_payload, &nof_tx_ports, &sfn_offset);
if (n == 1) { if (n == 1) {

@ -38,9 +38,9 @@ srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
1, // nof_ports 1, // nof_ports
1, // cell_id 1, // cell_id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1, // PHICH resources SRSLTE_PHICH_R_1, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
void usage(char *prog) { void usage(char *prog) {
@ -86,7 +86,7 @@ int main(int argc, char **argv) {
parse_args(argc,argv); parse_args(argc,argv);
nof_re = SLOT_LEN_RE(cell.nof_prb, CPNORM); nof_re = SRSLTE_SLOT_LEN_RE(cell.nof_prb, SRSLTE_SRSLTE_CP_NORM);
/* init memory */ /* init memory */
for (i=0;i<cell.nof_ports;i++) { for (i=0;i<cell.nof_ports;i++) {

@ -68,7 +68,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
// Read input symbols // Read input symbols
mexutils_read_cf(INPUT, &input_symbols); mexutils_read_cf(INPUT, &input_symbols);
nof_re = SF_LEN_RE(cell.nof_prb, cell.cp); nof_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp);
// Allocate memory // Allocate memory
input_fft = vec_malloc(nof_re * sizeof(cf_t)); input_fft = vec_malloc(nof_re * sizeof(cf_t));
@ -113,11 +113,11 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
for (int i=0;i<SRSLTE_MAX_PORTS;i++) { for (int i=0;i<SRSLTE_MAX_PORTS;i++) {
ce_slot[i] = &ce[i][SLOT_LEN_RE(cell.nof_prb, cell.cp)]; ce_slot[i] = &ce[i][SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)];
} }
uint32_t nof_ports; uint32_t nof_ports;
int n = pbch_decode(&pbch, &input_fft[SLOT_LEN_RE(cell.nof_prb, cell.cp)], int n = pbch_decode(&pbch, &input_fft[SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)],
ce_slot, noise_power, ce_slot, noise_power,
NULL, &nof_ports, NULL); NULL, &nof_ports, NULL);
@ -135,10 +135,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexutils_write_f(pbch.pbch_llr, &plhs[2], 2*pbch.nof_symbols, 1); mexutils_write_f(pbch.pbch_llr, &plhs[2], 2*pbch.nof_symbols, 1);
} }
if (nlhs >= 4) { if (nlhs >= 4) {
mexutils_write_cf(ce[0], &plhs[3], SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14); mexutils_write_cf(ce[0], &plhs[3], SRSLTE_SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14);
} }
if (nlhs >= 5) { if (nlhs >= 5) {
mexutils_write_cf(ce[1], &plhs[4], SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14); mexutils_write_cf(ce[1], &plhs[4], SRSLTE_SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14);
} }
if (nlhs >= 6) { if (nlhs >= 6) {
mexutils_write_cf(pbch.pbch_symbols[0], &plhs[5], pbch.nof_symbols, 1); mexutils_write_cf(pbch.pbch_symbols[0], &plhs[5], pbch.nof_symbols, 1);

@ -41,9 +41,9 @@ srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
1, // nof_ports 1, // nof_ports
0, // cell_id 0, // cell_id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1, // PHICH resources SRSLTE_PHICH_R_1, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
int flen; int flen;
@ -90,7 +90,7 @@ void parse_args(int argc, char **argv) {
verbose++; verbose++;
break; break;
case 'e': case 'e':
cell.cp = CPEXT; cell.cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -121,7 +121,7 @@ int base_init() {
fmatlab = NULL; fmatlab = NULL;
} }
flen = SLOT_LEN(lte_symbol_sz(cell.nof_prb)); flen = SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb));
input_buffer = malloc(flen * sizeof(cf_t)); input_buffer = malloc(flen * sizeof(cf_t));
if (!input_buffer) { if (!input_buffer) {
@ -129,14 +129,14 @@ int base_init() {
exit(-1); exit(-1);
} }
fft_buffer = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); fft_buffer = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!fft_buffer) { if (!fft_buffer) {
perror("malloc"); perror("malloc");
return -1; return -1;
} }
for (i=0;i<SRSLTE_MAX_PORTS;i++) { for (i=0;i<SRSLTE_MAX_PORTS;i++) {
ce[i] = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); ce[i] = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!ce[i]) { if (!ce[i]) {
perror("malloc"); perror("malloc");
return -1; return -1;
@ -216,10 +216,10 @@ int main(int argc, char **argv) {
fprintf(fmatlab, ";\n"); fprintf(fmatlab, ";\n");
fprintf(fmatlab, "outfft="); fprintf(fmatlab, "outfft=");
vec_sc_prod_cfc(fft_buffer, 1000.0, fft_buffer, CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB); vec_sc_prod_cfc(fft_buffer, 1000.0, fft_buffer, SRSLTE_CP_NSYMB(cell.cp) * cell.nof_prb * SRSLTE_NRE);
vec_fprint_c(fmatlab, fft_buffer, CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB); vec_fprint_c(fmatlab, fft_buffer, SRSLTE_CP_NSYMB(cell.cp) * cell.nof_prb * SRSLTE_NRE);
fprintf(fmatlab, ";\n"); fprintf(fmatlab, ";\n");
vec_sc_prod_cfc(fft_buffer, 0.001, fft_buffer, CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB); vec_sc_prod_cfc(fft_buffer, 0.001, fft_buffer, SRSLTE_CP_NSYMB(cell.cp) * cell.nof_prb * SRSLTE_NRE);
} }
/* Get channel estimates for each port */ /* Get channel estimates for each port */

@ -38,9 +38,9 @@ srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
1, // nof_ports 1, // nof_ports
1000, // cell_id 1000, // cell_id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1, // PHICH resources SRSLTE_PHICH_R_1, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
void usage(char *prog) { void usage(char *prog) {
@ -88,7 +88,7 @@ int main(int argc, char **argv) {
parse_args(argc,argv); parse_args(argc,argv);
nof_re = SRSLTE_CPNORM_NSYMB * cell.nof_prb * RE_X_RB; nof_re = SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE;
/* init memory */ /* init memory */
for (i=0;i<SRSLTE_MAX_PORTS;i++) { for (i=0;i<SRSLTE_MAX_PORTS;i++) {

@ -94,12 +94,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexErrMsgTxt("Error reading input signal\n"); mexErrMsgTxt("Error reading input signal\n");
return; return;
} }
input_fft = vec_malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); input_fft = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
// Set Channel estimates to 1.0 (ignore fading) // Set Channel estimates to 1.0 (ignore fading)
cf_t *ce[SRSLTE_MAX_PORTS]; cf_t *ce[SRSLTE_MAX_PORTS];
for (i=0;i<cell.nof_ports;i++) { for (i=0;i<cell.nof_ports;i++) {
ce[i] = vec_malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); ce[i] = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
} }
srslte_fft_run_sf(&fft, input_signal, input_fft); srslte_fft_run_sf(&fft, input_signal, input_fft);
@ -108,7 +108,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
cf_t *cearray; cf_t *cearray;
mexutils_read_cf(prhs[NOF_INPUTS], &cearray); mexutils_read_cf(prhs[NOF_INPUTS], &cearray);
for (i=0;i<cell.nof_ports;i++) { for (i=0;i<cell.nof_ports;i++) {
for (int j=0;j<SF_LEN_RE(cell.nof_prb, cell.cp);j++) { for (int j=0;j<SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp);j++) {
ce[i][j] = *cearray; ce[i][j] = *cearray;
cearray++; cearray++;
} }

@ -41,14 +41,14 @@ srslte_cell_t cell = {
6, // cell.cell.cell.nof_prb 6, // cell.cell.cell.nof_prb
1, // cell.cell.nof_ports 1, // cell.cell.nof_ports
0, // cell.id 0, // cell.id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1, // PHICH resources SRSLTE_PHICH_R_1, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
uint32_t cfi = 2; uint32_t cfi = 2;
int flen; int flen;
uint16_t rnti = SIRNTI; uint16_t rnti = SRSLTE_SIRNTI;
int max_frames = 10; int max_frames = 10;
dci_format_t dci_format = Format1A; dci_format_t dci_format = Format1A;
@ -108,7 +108,7 @@ void parse_args(int argc, char **argv) {
verbose++; verbose++;
break; break;
case 'e': case 'e':
cell.cp = CPEXT; cell.cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -129,7 +129,7 @@ int base_init() {
exit(-1); exit(-1);
} }
flen = 2 * (SLOT_LEN(lte_symbol_sz(cell.nof_prb))); flen = 2 * (SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb)));
input_buffer = malloc(flen * sizeof(cf_t)); input_buffer = malloc(flen * sizeof(cf_t));
if (!input_buffer) { if (!input_buffer) {
@ -137,14 +137,14 @@ int base_init() {
exit(-1); exit(-1);
} }
fft_buffer = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); fft_buffer = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!fft_buffer) { if (!fft_buffer) {
perror("malloc"); perror("malloc");
return -1; return -1;
} }
for (i=0;i<SRSLTE_MAX_PORTS;i++) { for (i=0;i<SRSLTE_MAX_PORTS;i++) {
ce[i] = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); ce[i] = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!ce[i]) { if (!ce[i]) {
perror("malloc"); perror("malloc");
return -1; return -1;
@ -238,7 +238,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error extracting LLRs\n"); fprintf(stderr, "Error extracting LLRs\n");
return -1; return -1;
} }
if (rnti == SIRNTI) { if (rnti == SRSLTE_SIRNTI) {
INFO("Initializing common search space for SI-RNTI\n",0); INFO("Initializing common search space for SI-RNTI\n",0);
nof_locations = pdcch_common_locations(&pdcch, locations, MAX_CANDIDATES, cfi); nof_locations = pdcch_common_locations(&pdcch, locations, MAX_CANDIDATES, cfi);
} else { } else {
@ -264,7 +264,7 @@ int main(int argc, char **argv) {
switch(type.type) { switch(type.type) {
case PDSCH_SCHED: case PDSCH_SCHED:
bzero(&ra_dl, sizeof(ra_pdsch_t)); bzero(&ra_dl, sizeof(ra_pdsch_t));
if (dci_msg_unpack_pdsch(&dci_msg, &ra_dl, cell.nof_prb, rnti != SIRNTI)) { if (dci_msg_unpack_pdsch(&dci_msg, &ra_dl, cell.nof_prb, rnti != SRSLTE_SIRNTI)) {
fprintf(stderr, "Can't unpack PDSCH message\n"); fprintf(stderr, "Can't unpack PDSCH message\n");
} else { } else {
ra_pdsch_fprint(stdout, &ra_dl, cell.nof_prb); ra_pdsch_fprint(stdout, &ra_dl, cell.nof_prb);

@ -37,9 +37,9 @@ srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
1, // nof_ports 1, // nof_ports
1, // cell_id 1, // cell_id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1, // PHICH resources SRSLTE_PHICH_R_1, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
uint32_t cfi = 1; uint32_t cfi = 1;
@ -121,7 +121,7 @@ int main(int argc, char **argv) {
parse_args(argc, argv); parse_args(argc, argv);
nof_re = SRSLTE_CPNORM_NSYMB * cell.nof_prb * RE_X_RB; nof_re = SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE;
if (test_dci_payload_size()) { if (test_dci_payload_size()) {
exit(-1); exit(-1);

@ -121,12 +121,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexErrMsgTxt("Error reading input signal\n"); mexErrMsgTxt("Error reading input signal\n");
return; return;
} }
input_fft = vec_malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); input_fft = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
// Set Channel estimates to 1.0 (ignore fading) // Set Channel estimates to 1.0 (ignore fading)
cf_t *ce[SRSLTE_MAX_PORTS]; cf_t *ce[SRSLTE_MAX_PORTS];
for (i=0;i<cell.nof_ports;i++) { for (i=0;i<cell.nof_ports;i++) {
ce[i] = vec_malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); ce[i] = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
} }
srslte_fft_run_sf(&fft, input_signal, input_fft); srslte_fft_run_sf(&fft, input_signal, input_fft);
@ -153,7 +153,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
pdcch_extract_llr(&pdcch, input_fft, ce, noise_power, sf_idx, cfi); pdcch_extract_llr(&pdcch, input_fft, ce, noise_power, sf_idx, cfi);
uint32_t nof_locations; uint32_t nof_locations;
if (rnti == SIRNTI) { if (rnti == SRSLTE_SIRNTI) {
nof_locations = pdcch_common_locations(&pdcch, locations, MAX_CANDIDATES, cfi); nof_locations = pdcch_common_locations(&pdcch, locations, MAX_CANDIDATES, cfi);
formats = common_formats; formats = common_formats;
nof_formats = nof_common_formats; nof_formats = nof_common_formats;

@ -41,15 +41,15 @@ srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
1, // nof_ports 1, // nof_ports
0, // cell_id 0, // cell_id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1, // PHICH resources SRSLTE_PHICH_R_1, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
int flen; int flen;
uint32_t cfi = 2; uint32_t cfi = 2;
uint16_t rnti = SIRNTI; uint16_t rnti = SRSLTE_SIRNTI;
int max_frames = 10; int max_frames = 10;
uint32_t sf_idx = 0; uint32_t sf_idx = 0;
@ -117,7 +117,7 @@ void parse_args(int argc, char **argv) {
verbose++; verbose++;
break; break;
case 'e': case 'e':
cell.cp = CPEXT; cell.cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -138,7 +138,7 @@ int base_init() {
exit(-1); exit(-1);
} }
flen = 2 * (SLOT_LEN(lte_symbol_sz(cell.nof_prb))); flen = 2 * (SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb)));
input_buffer = malloc(flen * sizeof(cf_t)); input_buffer = malloc(flen * sizeof(cf_t));
if (!input_buffer) { if (!input_buffer) {
@ -146,14 +146,14 @@ int base_init() {
exit(-1); exit(-1);
} }
fft_buffer = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); fft_buffer = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!fft_buffer) { if (!fft_buffer) {
perror("malloc"); perror("malloc");
return -1; return -1;
} }
for (i=0;i<SRSLTE_MAX_PORTS;i++) { for (i=0;i<SRSLTE_MAX_PORTS;i++) {
ce[i] = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); ce[i] = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!ce[i]) { if (!ce[i]) {
perror("malloc"); perror("malloc");
return -1; return -1;
@ -245,7 +245,7 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
if (rnti == SIRNTI) { if (rnti == SRSLTE_SIRNTI) {
INFO("Initializing common search space for SI-RNTI\n",0); INFO("Initializing common search space for SI-RNTI\n",0);
nof_locations = pdcch_common_locations(&pdcch, locations, MAX_CANDIDATES, cfi); nof_locations = pdcch_common_locations(&pdcch, locations, MAX_CANDIDATES, cfi);
} }
@ -261,7 +261,7 @@ int main(int argc, char **argv) {
/* Get channel estimates for each port */ /* Get channel estimates for each port */
srslte_chest_dl_estimate(&chest, fft_buffer, ce, sf_idx); srslte_chest_dl_estimate(&chest, fft_buffer, ce, sf_idx);
if (rnti != SIRNTI) { if (rnti != SRSLTE_SIRNTI) {
INFO("Initializing user-specific search space for RNTI: 0x%x\n", rnti); INFO("Initializing user-specific search space for RNTI: 0x%x\n", rnti);
nof_locations = pdcch_ue_locations(&pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti); nof_locations = pdcch_ue_locations(&pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti);
} }

@ -38,16 +38,16 @@ srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
1, // nof_ports 1, // nof_ports
0, // cell_id 0, // cell_id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1_6, // PHICH resources SRSLTE_PHICH_SRSLTE_PHICH_R_1_6, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
uint32_t cfi = 2; uint32_t cfi = 2;
uint32_t tbs = 0; uint32_t tbs = 0;
uint32_t nof_tbs = 0; uint32_t nof_tbs = 0;
uint32_t subframe = 1; uint32_t subframe = 1;
lte_mod_t modulation = LTE_BPSK; srslte_mod_t modulation = LTE_BPSK;
uint32_t rv_idx = 0; uint32_t rv_idx = 0;
void usage(char *prog) { void usage(char *prog) {
@ -143,7 +143,7 @@ int main(int argc, char **argv) {
bzero(ce, sizeof(cf_t*)*SRSLTE_MAX_PORTS); bzero(ce, sizeof(cf_t*)*SRSLTE_MAX_PORTS);
bzero(slot_symbols, sizeof(cf_t*)*SRSLTE_MAX_PORTS); bzero(slot_symbols, sizeof(cf_t*)*SRSLTE_MAX_PORTS);
nof_re = 2 * SRSLTE_CPNORM_NSYMB * cell.nof_prb * RE_X_RB; nof_re = 2 * SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE;
mcs.mod = modulation; mcs.mod = modulation;

@ -109,7 +109,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
nof_re = 2 * SRSLTE_CPNORM_NSYMB * cell.nof_prb * RE_X_RB; nof_re = 2 * SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE;
mcs.tbs = mxGetScalar(TBS); mcs.tbs = mxGetScalar(TBS);
if (mcs.tbs == 0) { if (mcs.tbs == 0) {
@ -172,12 +172,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexErrMsgTxt("Error reading input signal\n"); mexErrMsgTxt("Error reading input signal\n");
return; return;
} }
input_fft = vec_malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); input_fft = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
// Set Channel estimates to 1.0 (ignore fading) // Set Channel estimates to 1.0 (ignore fading)
cf_t *ce[SRSLTE_MAX_PORTS]; cf_t *ce[SRSLTE_MAX_PORTS];
for (i=0;i<cell.nof_ports;i++) { for (i=0;i<cell.nof_ports;i++) {
ce[i] = vec_malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); ce[i] = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
} }
srslte_fft_run_sf(&fft, input_signal, input_fft); srslte_fft_run_sf(&fft, input_signal, input_fft);
@ -225,7 +225,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexutils_write_cf(pdsch.pdsch_d, &plhs[3], harq_process.dl_alloc.re_sf[sf_idx], 1); mexutils_write_cf(pdsch.pdsch_d, &plhs[3], harq_process.dl_alloc.re_sf[sf_idx], 1);
} }
if (nlhs >= 5) { if (nlhs >= 5) {
mexutils_write_f(pdsch.pdsch_e, &plhs[4], harq_process.dl_alloc.re_sf[sf_idx] * lte_mod_bits_x_symbol(mcs.mod), 1); mexutils_write_f(pdsch.pdsch_e, &plhs[4], harq_process.dl_alloc.re_sf[sf_idx] * srslte_mod_bits_x_symbol(mcs.mod), 1);
} }
srslte_chest_dl_free(&chest); srslte_chest_dl_free(&chest);

@ -40,9 +40,9 @@ srslte_cell_t cell = {
50, // cell.nof_prb 50, // cell.nof_prb
2, // cell.nof_ports 2, // cell.nof_ports
150, // cell.id 150, // cell.id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1, // PHICH resources SRSLTE_PHICH_R_1, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
int flen; int flen;
@ -89,19 +89,19 @@ void parse_args(int argc, char **argv) {
break; break;
case 'g': case 'g':
if (!strcmp(argv[optind], "1/6")) { if (!strcmp(argv[optind], "1/6")) {
cell.phich_resources = R_1_6; cell.phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_6;
} else if (!strcmp(argv[optind], "1/2")) { } else if (!strcmp(argv[optind], "1/2")) {
cell.phich_resources = R_1_2; cell.phich_resources = SRSLTE_PHICH_SRSLTE_PHICH_R_1_2;
} else if (!strcmp(argv[optind], "1")) { } else if (!strcmp(argv[optind], "1")) {
cell.phich_resources = R_1; cell.phich_resources = SRSLTE_PHICH_R_1;
} else if (!strcmp(argv[optind], "2")) { } else if (!strcmp(argv[optind], "2")) {
cell.phich_resources = R_2; cell.phich_resources = SRSLTE_PHICH_R_2;
} else { } else {
fprintf(stderr, "Invalid phich ng factor %s. Setting to default.\n", argv[optind]); fprintf(stderr, "Invalid phich ng factor %s. Setting to default.\n", argv[optind]);
} }
break; break;
case 'e': case 'e':
cell.phich_length = PHICH_EXT; cell.phich_length = SRSLTE_PHICH_EXT;
break; break;
case 'n': case 'n':
cell.nof_prb = atoi(argv[optind]); cell.nof_prb = atoi(argv[optind]);
@ -113,7 +113,7 @@ void parse_args(int argc, char **argv) {
verbose++; verbose++;
break; break;
case 'l': case 'l':
cell.cp = CPEXT; cell.cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -144,7 +144,7 @@ int base_init() {
fmatlab = NULL; fmatlab = NULL;
} }
flen = SLOT_LEN(lte_symbol_sz(cell.nof_prb)); flen = SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb));
input_buffer = malloc(flen * sizeof(cf_t)); input_buffer = malloc(flen * sizeof(cf_t));
if (!input_buffer) { if (!input_buffer) {
@ -152,14 +152,14 @@ int base_init() {
exit(-1); exit(-1);
} }
fft_buffer = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); fft_buffer = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!fft_buffer) { if (!fft_buffer) {
perror("malloc"); perror("malloc");
return -1; return -1;
} }
for (i=0;i<SRSLTE_MAX_PORTS;i++) { for (i=0;i<SRSLTE_MAX_PORTS;i++) {
ce[i] = malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); ce[i] = malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!ce[i]) { if (!ce[i]) {
perror("malloc"); perror("malloc");
return -1; return -1;
@ -225,7 +225,7 @@ int main(int argc, char **argv) {
parse_args(argc,argv); parse_args(argc,argv);
max_nseq = CP_ISNORM(cell.cp)?PHICH_NORM_NSEQUENCES:PHICH_EXT_NSEQUENCES; max_nseq = SRSLTE_CP_ISNORM(cell.cp)?SRSLTE_PHICH_NORM_NSEQUENCES:SRSLTE_PHICH_EXT_NSEQUENCES;
if (base_init()) { if (base_init()) {
fprintf(stderr, "Error initializing memory\n"); fprintf(stderr, "Error initializing memory\n");
@ -242,7 +242,7 @@ int main(int argc, char **argv) {
fprintf(fmatlab, ";\n"); fprintf(fmatlab, ";\n");
fprintf(fmatlab, "outfft="); fprintf(fmatlab, "outfft=");
vec_fprint_c(fmatlab, fft_buffer, CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB); vec_fprint_c(fmatlab, fft_buffer, SRSLTE_CP_NSYMB(cell.cp) * cell.nof_prb * SRSLTE_NRE);
fprintf(fmatlab, ";\n"); fprintf(fmatlab, ";\n");
} }

@ -38,13 +38,13 @@ srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
1, // nof_ports 1, // nof_ports
1000, // cell_id 1000, // cell_id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1, // PHICH resources SRSLTE_PHICH_R_1, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
phich_resources_t phich_res = R_1; srslte_phich_resources_t phich_res = SRSLTE_PHICH_R_1;
phich_length_t phich_length = PHICH_NORM; srslte_phich_length_t phich_length = SRSLTE_PHICH_NORM;
void usage(char *prog) { void usage(char *prog) {
printf("Usage: %s [cpvgel]\n", prog); printf("Usage: %s [cpvgel]\n", prog);
@ -72,22 +72,22 @@ void parse_args(int argc, char **argv) {
break; break;
case 'g': case 'g':
if (!strcmp(argv[optind], "1/6")) { if (!strcmp(argv[optind], "1/6")) {
phich_res = R_1_6; phich_res = SRSLTE_PHICH_SRSLTE_PHICH_R_1_6;
} else if (!strcmp(argv[optind], "1/2")) { } else if (!strcmp(argv[optind], "1/2")) {
phich_res = R_1_2; phich_res = SRSLTE_PHICH_SRSLTE_PHICH_R_1_2;
} else if (!strcmp(argv[optind], "1")) { } else if (!strcmp(argv[optind], "1")) {
phich_res = R_1; phich_res = SRSLTE_PHICH_R_1;
} else if (!strcmp(argv[optind], "2")) { } else if (!strcmp(argv[optind], "2")) {
phich_res = R_2; phich_res = SRSLTE_PHICH_R_2;
} else { } else {
fprintf(stderr, "Invalid phich ng factor %s. Setting to default.\n", argv[optind]); fprintf(stderr, "Invalid phich ng factor %s. Setting to default.\n", argv[optind]);
} }
break; break;
case 'e': case 'e':
phich_length = PHICH_EXT; phich_length = SRSLTE_PHICH_EXT;
break; break;
case 'l': case 'l':
cell.cp = CPEXT; cell.cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
case 'v': case 'v':
verbose++; verbose++;
@ -107,16 +107,16 @@ int main(int argc, char **argv) {
cf_t *ce[SRSLTE_MAX_PORTS]; cf_t *ce[SRSLTE_MAX_PORTS];
int nof_re; int nof_re;
cf_t *slot_symbols[SRSLTE_MAX_PORTS]; cf_t *slot_symbols[SRSLTE_MAX_PORTS];
uint8_t ack[50][PHICH_NORM_NSEQUENCES], ack_rx; uint8_t ack[50][SRSLTE_PHICH_NORM_NSEQUENCES], ack_rx;
uint32_t nsf, distance; uint32_t nsf, distance;
int cid, max_cid; int cid, max_cid;
uint32_t ngroup, nseq, max_nseq; uint32_t ngroup, nseq, max_nseq;
parse_args(argc,argv); parse_args(argc,argv);
max_nseq = CP_ISNORM(cell.cp)?PHICH_NORM_NSEQUENCES:PHICH_EXT_NSEQUENCES; max_nseq = SRSLTE_CP_ISNORM(cell.cp)?SRSLTE_PHICH_NORM_NSEQUENCES:SRSLTE_PHICH_EXT_NSEQUENCES;
nof_re = SRSLTE_CPNORM_NSYMB * cell.nof_prb * RE_X_RB; nof_re = SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE;
/* init memory */ /* init memory */
for (i=0;i<SRSLTE_MAX_PORTS;i++) { for (i=0;i<SRSLTE_MAX_PORTS;i++) {

@ -56,7 +56,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexErrMsgTxt("Field NULRB not found in UE config\n"); mexErrMsgTxt("Field NULRB not found in UE config\n");
return; return;
} }
int r = lte_symbol_sz(n_ul_rb); int r = srslte_symbol_sz(n_ul_rb);
if (r < 0) { if (r < 0) {
mexErrMsgTxt("Invalid NULRB\n"); mexErrMsgTxt("Invalid NULRB\n");
return; return;
@ -89,7 +89,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return; return;
} }
uint32_t nof_samples = lte_sampling_freq_hz(n_ul_rb) * 0.003; 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 = vec_malloc(sizeof(cf_t) * nof_samples);
if (!signal) { if (!signal) {

@ -131,7 +131,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return; return;
} }
uint32_t nof_re = RE_X_RB*cell.nof_prb*2*CP_NSYMB(cell.cp); uint32_t nof_re = SRSLTE_NRE*cell.nof_prb*2*SRSLTE_CP_NSYMB(cell.cp);
cf_t *sf_symbols = vec_malloc(sizeof(cf_t) * nof_re); cf_t *sf_symbols = vec_malloc(sizeof(cf_t) * nof_re);
if (!sf_symbols) { if (!sf_symbols) {
mexErrMsgTxt("malloc"); mexErrMsgTxt("malloc");
@ -194,19 +194,19 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
} }
cf_t *scfdma = vec_malloc(sizeof(cf_t) * SF_LEN_PRB(cell.nof_prb)); cf_t *scfdma = vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
bzero(scfdma, sizeof(cf_t) * SF_LEN_PRB(cell.nof_prb)); bzero(scfdma, sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
srslte_fft_t fft; srslte_fft_t fft;
lte_ifft_init(&fft, CPNORM, cell.nof_prb); lte_ifft_init(&fft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb);
srslte_fft_set_normalize(&fft, true); srslte_fft_set_normalize(&fft, true);
srslte_fft_set_freq_shift(&fft, 0.5); srslte_fft_set_freq_shift(&fft, 0.5);
lte_ifft_run_sf(&fft, sf_symbols, scfdma); lte_ifft_run_sf(&fft, sf_symbols, scfdma);
// Matlab toolbox expects further normalization // Matlab toolbox expects further normalization
vec_sc_prod_cfc(scfdma, 1.0/sqrtf(lte_symbol_sz(cell.nof_prb)), scfdma, SF_LEN_PRB(cell.nof_prb)); 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) { if (nlhs >= 1) {
mexutils_write_cf(scfdma, &plhs[0], SF_LEN_PRB(cell.nof_prb), 1); mexutils_write_cf(scfdma, &plhs[0], SRSLTE_SF_LEN_PRB(cell.nof_prb), 1);
} }
if (nlhs >= 2) { if (nlhs >= 2) {
mexutils_write_cf(sf_symbols, &plhs[1], nof_re, 1); mexutils_write_cf(sf_symbols, &plhs[1], nof_re, 1);

@ -38,15 +38,15 @@ srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
1, // nof_ports 1, // nof_ports
0, // cell_id 0, // cell_id
CPNORM, // cyclic prefix SRSLTE_SRSLTE_CP_NORM, // cyclic prefix
R_1_6, // PHICH resources SRSLTE_PHICH_SRSLTE_PHICH_R_1_6, // PHICH resources
PHICH_NORM // PHICH length SRSLTE_PHICH_NORM // PHICH length
}; };
uint32_t cfi = 2; uint32_t cfi = 2;
uint32_t tbs = 0; uint32_t tbs = 0;
uint32_t subframe = 1; uint32_t subframe = 1;
lte_mod_t modulation = LTE_QPSK; srslte_mod_t modulation = LTE_QPSK;
uint32_t rv_idx = 0; uint32_t rv_idx = 0;
uint32_t L_prb = 2; uint32_t L_prb = 2;
uint32_t n_prb = 0; uint32_t n_prb = 0;
@ -199,7 +199,7 @@ int main(int argc, char **argv) {
pusch_set_hopping_cfg(&pusch, &ul_hopping); pusch_set_hopping_cfg(&pusch, &ul_hopping);
uint32_t nof_re = RE_X_RB*cell.nof_prb*2*CP_NSYMB(cell.cp); uint32_t nof_re = SRSLTE_NRE*cell.nof_prb*2*SRSLTE_CP_NSYMB(cell.cp);
sf_symbols = vec_malloc(sizeof(cf_t) * nof_re); sf_symbols = vec_malloc(sizeof(cf_t) * nof_re);
if (!sf_symbols) { if (!sf_symbols) {
perror("malloc"); perror("malloc");
@ -234,10 +234,10 @@ int main(int argc, char **argv) {
} }
cf_t *scfdma = vec_malloc(sizeof(cf_t) * SF_LEN_PRB(cell.nof_prb)); cf_t *scfdma = vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
bzero(scfdma, sizeof(cf_t) * SF_LEN_PRB(cell.nof_prb)); bzero(scfdma, sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
srslte_fft_t fft; srslte_fft_t fft;
lte_ifft_init(&fft, CPNORM, cell.nof_prb); lte_ifft_init(&fft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb);
srslte_fft_set_freq_shift(&fft, 0.5); srslte_fft_set_freq_shift(&fft, 0.5);
lte_ifft_run_sf(&fft, sf_symbols, scfdma); lte_ifft_run_sf(&fft, sf_symbols, scfdma);

@ -66,7 +66,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
srslte_cell_t cell; srslte_cell_t cell;
cell.nof_prb = 100; cell.nof_prb = 100;
cell.id=1; cell.id=1;
cell.cp=CPNORM; cell.cp=SRSLTE_SRSLTE_CP_NORM;
if (harq_init(&harq_process, cell)) { if (harq_init(&harq_process, cell)) {
mexErrMsgTxt("Error initiating HARQ\n"); mexErrMsgTxt("Error initiating HARQ\n");
return; return;
@ -135,7 +135,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
prb_alloc.n_prb[1] = prbset[0]; prb_alloc.n_prb[1] = prbset[0];
free(prbset); free(prbset);
mexPrintf("Q_m: %d, NPRB: %d, RV: %d\n", lte_mod_bits_x_symbol(mcs.mod), prb_alloc.L_prb, rv); mexPrintf("Q_m: %d, NPRB: %d, RV: %d\n", srslte_mod_bits_x_symbol(mcs.mod), prb_alloc.L_prb, rv);
if (harq_setup_ul(&harq_process, mcs, 0, 0, &prb_alloc)) { if (harq_setup_ul(&harq_process, mcs, 0, 0, &prb_alloc)) {
mexErrMsgTxt("Error configuring HARQ process\n"); mexErrMsgTxt("Error configuring HARQ process\n");

@ -97,11 +97,11 @@ int compute_sequences(scrambling_hl* h) {
switch (h->init.channel) { switch (h->init.channel) {
case SCRAMBLING_PBCH: case SCRAMBLING_PBCH:
return sequence_pbch(&h->obj.seq[0], return sequence_pbch(&h->obj.seq[0],
h->init.nof_symbols == SRSLTE_CPNORM_NSYMB ? CPNORM : CPEXT, h->init.cell_id); h->init.nof_symbols == SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB ? SRSLTE_SRSLTE_CP_NORM : SRSLTE_SRSLTE_CP_EXT, h->init.cell_id);
case SCRAMBLING_PDSCH: case SCRAMBLING_PDSCH:
for (int ns = 0; ns < SRSLTE_NSUBFRAMES_X_FRAME; ns++) { for (int ns = 0; ns < SRSLTE_NSUBFRAMES_X_FRAME; ns++) {
sequence_pdsch(&h->obj.seq[ns], h->init.nrnti, 0, 2 * ns, h->init.cell_id, sequence_pdsch(&h->obj.seq[ns], h->init.nrnti, 0, 2 * ns, h->init.cell_id,
LTE_NSOFT_BITS); SRSLTE_NSOFT_BITS);
} }
return 0; return 0;
case SCRAMBLING_PCFICH: case SCRAMBLING_PCFICH:
@ -111,7 +111,7 @@ int compute_sequences(scrambling_hl* h) {
return 0; return 0;
case SCRAMBLING_PDCCH: case SCRAMBLING_PDCCH:
for (int ns = 0; ns < SRSLTE_NSUBFRAMES_X_FRAME; ns++) { for (int ns = 0; ns < SRSLTE_NSUBFRAMES_X_FRAME; ns++) {
sequence_pdcch(&h->obj.seq[ns], 2 * ns, h->init.cell_id, LTE_NSOFT_BITS); sequence_pdcch(&h->obj.seq[ns], 2 * ns, h->init.cell_id, SRSLTE_NSOFT_BITS);
} }
return 0; return 0;
case SCRAMBLING_PMCH: case SCRAMBLING_PMCH:

@ -38,7 +38,7 @@
char *sequence_name = NULL; char *sequence_name = NULL;
bool do_floats = false; bool do_floats = false;
srslte_cp_t cp = CPNORM; srslte_cp_t cp = SRSLTE_SRSLTE_CP_NORM;
int cell_id = -1; int cell_id = -1;
void usage(char *prog) { void usage(char *prog) {
@ -55,7 +55,7 @@ void parse_args(int argc, char **argv) {
cell_id = atoi(argv[optind]); cell_id = atoi(argv[optind]);
break; break;
case 'e': case 'e':
cp = CPEXT; cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
case 'f': case 'f':
do_floats = true; do_floats = true;

@ -70,7 +70,7 @@ static void corr_all_sz_partial(cf_t z[N_SSS], float s[N_SSS][N_SSS], uint32_t M
} }
static void extract_pair_sss(sss_synch_t *q, cf_t *input, cf_t *ce, cf_t y[2][N_SSS]) { static void extract_pair_sss(sss_synch_t *q, cf_t *input, cf_t *ce, cf_t y[2][N_SSS]) {
cf_t input_fft[SYMBOL_SZ_MAX]; cf_t input_fft[SRSLTE_SYMBOL_SZ_MAX];
dft_run_c(&q->dftp_input, input, input_fft); dft_run_c(&q->dftp_input, input, input_fft);

@ -44,7 +44,7 @@ int pss_synch_init_N_id_2(cf_t *pss_signal_time, cf_t *pss_signal_freq, uint32_t
cf_t pss_signal_pad[2048]; cf_t pss_signal_pad[2048];
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (lte_N_id_2_isvalid(N_id_2) && if (srslte_N_id_2_isvalid(N_id_2) &&
fft_size <= 2048) fft_size <= 2048)
{ {
@ -243,7 +243,7 @@ int pss_generate(cf_t *signal, uint32_t N_id_2) {
*/ */
void pss_put_slot(cf_t *pss_signal, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp) { void pss_put_slot(cf_t *pss_signal, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp) {
int k; int k;
k = (CP_NSYMB(cp) - 1) * nof_prb * RE_X_RB + nof_prb * RE_X_RB / 2 - 31; k = (SRSLTE_CP_NSYMB(cp) - 1) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31;
memset(&slot[k - 5], 0, 5 * sizeof(cf_t)); memset(&slot[k - 5], 0, 5 * sizeof(cf_t));
memcpy(&slot[k], pss_signal, PSS_LEN * sizeof(cf_t)); memcpy(&slot[k], pss_signal, PSS_LEN * sizeof(cf_t));
memset(&slot[k + PSS_LEN], 0, 5 * sizeof(cf_t)); memset(&slot[k + PSS_LEN], 0, 5 * sizeof(cf_t));
@ -253,7 +253,7 @@ void pss_put_slot(cf_t *pss_signal, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp
/** Sets the current N_id_2 value. Returns -1 on error, 0 otherwise /** 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 pss_synch_set_N_id_2(pss_synch_t *q, uint32_t N_id_2) {
if (!lte_N_id_2_isvalid((N_id_2))) { if (!srslte_N_id_2_isvalid((N_id_2))) {
fprintf(stderr, "Invalid N_id_2 %d\n", N_id_2); fprintf(stderr, "Invalid N_id_2 %d\n", N_id_2);
return -1; return -1;
} else { } else {
@ -286,7 +286,7 @@ int pss_synch_find_pss(pss_synch_t *q, cf_t *input, float *corr_peak_value)
uint32_t corr_peak_pos; uint32_t corr_peak_pos;
uint32_t conv_output_len; uint32_t conv_output_len;
if (!lte_N_id_2_isvalid(q->N_id_2)) { if (!srslte_N_id_2_isvalid(q->N_id_2)) {
fprintf(stderr, "Error finding PSS peak, Must set N_id_2 first\n"); fprintf(stderr, "Error finding PSS peak, Must set N_id_2 first\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -388,13 +388,13 @@ SRSLTE_API cf_t *tmp2;
*/ */
int pss_synch_chest(pss_synch_t *q, cf_t *input, cf_t ce[PSS_LEN]) { int pss_synch_chest(pss_synch_t *q, cf_t *input, cf_t ce[PSS_LEN]) {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
cf_t input_fft[SYMBOL_SZ_MAX]; cf_t input_fft[SRSLTE_SYMBOL_SZ_MAX];
if (q != NULL && if (q != NULL &&
input != NULL) input != NULL)
{ {
if (!lte_N_id_2_isvalid(q->N_id_2)) { if (!srslte_N_id_2_isvalid(q->N_id_2)) {
fprintf(stderr, "Error finding PSS peak, Must set N_id_2 first\n"); fprintf(stderr, "Error finding PSS peak, Must set N_id_2 first\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -98,7 +98,7 @@ void sss_synch_free(sss_synch_t *q) {
/** Sets the N_id_2 to search for */ /** 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 sss_synch_set_N_id_2(sss_synch_t *q, uint32_t N_id_2) {
if (!lte_N_id_2_isvalid(N_id_2)) { if (!srslte_N_id_2_isvalid(N_id_2)) {
fprintf(stderr, "Invalid N_id_2 %d\n", N_id_2); fprintf(stderr, "Invalid N_id_2 %d\n", N_id_2);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} else { } else {
@ -112,7 +112,7 @@ int sss_synch_set_N_id_2(sss_synch_t *q, uint32_t N_id_2) {
void sss_put_slot(float *sss, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp) { void sss_put_slot(float *sss, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp) {
uint32_t i, k; uint32_t i, k;
k = (CP_NSYMB(cp) - 2) * nof_prb * RE_X_RB + nof_prb * RE_X_RB / 2 - 31; k = (SRSLTE_CP_NSYMB(cp) - 2) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31;
if (k > 5) { if (k > 5) {
memset(&slot[k - 5], 0, 5 * sizeof(cf_t)); memset(&slot[k - 5], 0, 5 * sizeof(cf_t));

@ -59,7 +59,7 @@ int sync_init(sync_t *q, uint32_t frame_size, uint32_t fft_size) {
bzero(q, sizeof(sync_t)); bzero(q, sizeof(sync_t));
q->detect_cp = true; q->detect_cp = true;
q->cp = CPNORM; q->cp = SRSLTE_SRSLTE_CP_NORM;
q->mean_peak_value = 0.0; q->mean_peak_value = 0.0;
q->sss_en = true; q->sss_en = true;
q->correct_cfo = true; q->correct_cfo = true;
@ -115,11 +115,11 @@ void sync_sss_en(sync_t *q, bool enabled) {
} }
bool sync_sss_detected(sync_t *q) { bool sync_sss_detected(sync_t *q) {
return lte_N_id_1_isvalid(q->N_id_1); return srslte_N_id_1_isvalid(q->N_id_1);
} }
int sync_get_cell_id(sync_t *q) { int sync_get_cell_id(sync_t *q) {
if (lte_N_id_2_isvalid(q->N_id_2) && lte_N_id_1_isvalid(q->N_id_1)) { if (srslte_N_id_2_isvalid(q->N_id_2) && srslte_N_id_1_isvalid(q->N_id_1)) {
return q->N_id_1*3 + q->N_id_2; return q->N_id_1*3 + q->N_id_2;
} else { } else {
return -1; return -1;
@ -127,7 +127,7 @@ int sync_get_cell_id(sync_t *q) {
} }
int sync_set_N_id_2(sync_t *q, uint32_t N_id_2) { int sync_set_N_id_2(sync_t *q, uint32_t N_id_2) {
if (lte_N_id_2_isvalid(N_id_2)) { if (srslte_N_id_2_isvalid(N_id_2)) {
q->N_id_2 = N_id_2; q->N_id_2 = N_id_2;
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else { } else {
@ -188,8 +188,8 @@ srslte_cp_t sync_detect_cp(sync_t *q, cf_t *input, uint32_t peak_pos)
float R_norm, R_ext, C_norm, C_ext; float R_norm, R_ext, C_norm, C_ext;
float M_norm=0, M_ext=0; float M_norm=0, M_ext=0;
uint32_t cp_norm_len = CP_NORM(7, q->fft_size); uint32_t cp_norm_len = SRSLTE_CP_NORM(7, q->fft_size);
uint32_t cp_ext_len = CP_EXT(q->fft_size); uint32_t cp_ext_len = SRSLTE_CP_EXT(q->fft_size);
cf_t *input_cp_norm = &input[peak_pos-2*(q->fft_size+cp_norm_len)]; cf_t *input_cp_norm = &input[peak_pos-2*(q->fft_size+cp_norm_len)];
cf_t *input_cp_ext = &input[peak_pos-2*(q->fft_size+cp_ext_len)]; cf_t *input_cp_ext = &input[peak_pos-2*(q->fft_size+cp_ext_len)];
@ -215,14 +215,14 @@ srslte_cp_t sync_detect_cp(sync_t *q, cf_t *input, uint32_t peak_pos)
q->M_ext_avg = VEC_EMA(M_ext/2, q->M_ext_avg, CP_EMA_ALPHA); q->M_ext_avg = VEC_EMA(M_ext/2, q->M_ext_avg, CP_EMA_ALPHA);
if (q->M_norm_avg > q->M_ext_avg) { if (q->M_norm_avg > q->M_ext_avg) {
return CPNORM; return SRSLTE_SRSLTE_CP_NORM;
} else if (q->M_norm_avg < q->M_ext_avg) { } else if (q->M_norm_avg < q->M_ext_avg) {
return CPEXT; return SRSLTE_SRSLTE_CP_EXT;
} else { } else {
if (R_norm > R_ext) { if (R_norm > R_ext) {
return CPNORM; return SRSLTE_SRSLTE_CP_NORM;
} else { } else {
return CPEXT; return SRSLTE_SRSLTE_CP_EXT;
} }
} }
} }
@ -236,7 +236,7 @@ int sync_sss(sync_t *q, cf_t *input, uint32_t peak_pos, srslte_cp_t cp) {
sss_synch_set_N_id_2(&q->sss, q->N_id_2); sss_synch_set_N_id_2(&q->sss, q->N_id_2);
/* Make sure we have enough room to find SSS sequence */ /* Make sure we have enough room to find SSS sequence */
sss_idx = (int) peak_pos-2*q->fft_size-CP(q->fft_size, (CP_ISNORM(q->cp)?CPNORM_LEN:CPEXT_LEN)); sss_idx = (int) peak_pos-2*q->fft_size-SRSLTE_CP(q->fft_size, (SRSLTE_CP_ISNORM(q->cp)?SRSLTE_SRSLTE_CP_NORM_LEN:SRSLTE_SRSLTE_CP_EXT_LEN));
if (sss_idx < 0) { if (sss_idx < 0) {
INFO("Not enough room to decode CP SSS (sss_idx=%d, peak_pos=%d)\n", sss_idx, peak_pos); INFO("Not enough room to decode CP SSS (sss_idx=%d, peak_pos=%d)\n", sss_idx, peak_pos);
return SRSLTE_ERROR; return SRSLTE_ERROR;
@ -260,7 +260,7 @@ int sync_sss(sync_t *q, cf_t *input, uint32_t peak_pos, srslte_cp_t cp) {
if (ret >= 0) { if (ret >= 0) {
q->N_id_1 = (uint32_t) ret; q->N_id_1 = (uint32_t) ret;
DEBUG("SSS detected N_id_1=%d, sf_idx=%d, %s CP\n", DEBUG("SSS detected N_id_1=%d, sf_idx=%d, %s CP\n",
q->N_id_1, q->sf_idx, CP_ISNORM(q->cp)?"Normal":"Extended"); q->N_id_1, q->sf_idx, SRSLTE_CP_ISNORM(q->cp)?"Normal":"Extended");
return 1; return 1;
} else { } else {
q->N_id_1 = 1000; q->N_id_1 = 1000;
@ -283,7 +283,7 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit
if (q != NULL && if (q != NULL &&
input != NULL && input != NULL &&
lte_N_id_2_isvalid(q->N_id_2) && srslte_N_id_2_isvalid(q->N_id_2) &&
fft_size_isvalid(q->fft_size)) fft_size_isvalid(q->fft_size))
{ {
int peak_pos; int peak_pos;
@ -321,7 +321,7 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit
} }
if (q->detect_cp) { if (q->detect_cp) {
if (peak_pos + find_offset >= 2*(q->fft_size + CP_EXT(q->fft_size))) { if (peak_pos + find_offset >= 2*(q->fft_size + SRSLTE_CP_EXT(q->fft_size))) {
q->cp = sync_detect_cp(q, input, peak_pos + find_offset); q->cp = sync_detect_cp(q, input, peak_pos + find_offset);
} else { } else {
INFO("Not enough room to detect CP length. Peak position: %d\n", peak_pos); INFO("Not enough room to detect CP length. Peak position: %d\n", peak_pos);
@ -351,7 +351,7 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit
INFO("SYNC ret=%d N_id_2=%d find_offset=%d pos=%d peak=%.2f threshold=%.2f sf_idx=%d, CFO=%.3f KHz\n", INFO("SYNC ret=%d N_id_2=%d find_offset=%d pos=%d peak=%.2f threshold=%.2f sf_idx=%d, CFO=%.3f KHz\n",
ret, q->N_id_2, find_offset, peak_pos, q->peak_value, q->threshold, q->sf_idx, 15*q->mean_cfo); ret, q->N_id_2, find_offset, peak_pos, q->peak_value, q->threshold, q->sf_idx, 15*q->mean_cfo);
} else if (lte_N_id_2_isvalid(q->N_id_2)) { } else if (srslte_N_id_2_isvalid(q->N_id_2)) {
fprintf(stderr, "Must call sync_set_N_id_2() first!\n"); fprintf(stderr, "Must call sync_set_N_id_2() first!\n");
} }

@ -69,7 +69,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return; return;
} }
if (pss_synch_init_fft(&pss, frame_len, lte_symbol_sz(cell.nof_prb))) { if (pss_synch_init_fft(&pss, frame_len, srslte_symbol_sz(cell.nof_prb))) {
fprintf(stderr, "Error initiating PSS\n"); fprintf(stderr, "Error initiating PSS\n");
exit(-1); exit(-1);
} }

@ -54,7 +54,7 @@ int nof_frames = -1;
uint32_t fft_size=64; uint32_t fft_size=64;
float threshold = 0.4; float threshold = 0.4;
int N_id_2_sync = -1; int N_id_2_sync = -1;
srslte_cp_t cp=CPNORM; srslte_cp_t cp=SRSLTE_SRSLTE_CP_NORM;
void usage(char *prog) { void usage(char *prog) {
printf("Usage: %s [aedgtvnp] -f rx_frequency_hz -i cell_id\n", prog); printf("Usage: %s [aedgtvnp] -f rx_frequency_hz -i cell_id\n", prog);
@ -90,7 +90,7 @@ void parse_args(int argc, char **argv) {
threshold = atof(argv[optind]); threshold = atof(argv[optind]);
break; break;
case 'e': case 'e':
cp = CPEXT; cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
case 'i': case 'i':
cell_id = atoi(argv[optind]); cell_id = atoi(argv[optind]);
@ -241,7 +241,7 @@ int main(int argc, char **argv) {
} }
// Find SSS // Find SSS
int sss_idx = peak_idx-2*fft_size-(CP_ISNORM(cp)?CP(fft_size, CPNORM_LEN):CP(fft_size, CPEXT_LEN)); int sss_idx = peak_idx-2*fft_size-(SRSLTE_CP_ISNORM(cp)?SRSLTE_CP(fft_size, SRSLTE_SRSLTE_CP_NORM_LEN):SRSLTE_CP(fft_size, SRSLTE_SRSLTE_CP_EXT_LEN));
if (sss_idx >= 0 && sss_idx < flen-fft_size) { 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); 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) { if (sss_synch_N_id_1(&sss, m0, m1) != N_id_1) {
@ -261,9 +261,9 @@ int main(int argc, char **argv) {
} }
// Estimate CP // Estimate CP
if (peak_idx > 2*(fft_size + CP_EXT(fft_size))) { if (peak_idx > 2*(fft_size + SRSLTE_CP_EXT(fft_size))) {
srslte_cp_t cp = sync_detect_cp(&ssync, buffer, peak_idx); srslte_cp_t cp = sync_detect_cp(&ssync, buffer, peak_idx);
if (CP_ISNORM(cp)) { if (SRSLTE_CP_ISNORM(cp)) {
cp_is_norm++; cp_is_norm++;
} }
} }

@ -81,7 +81,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return; return;
} }
if (sss_synch_init(&sss, lte_symbol_sz(cell.nof_prb))) { if (sss_synch_init(&sss, srslte_symbol_sz(cell.nof_prb))) {
mexErrMsgTxt("Error initializing SSS object\n"); mexErrMsgTxt("Error initializing SSS object\n");
return; return;
} }
@ -89,7 +89,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
sss_synch_set_N_id_2(&sss, cell.id%3); sss_synch_set_N_id_2(&sss, cell.id%3);
// Find SSS // Find SSS
uint32_t sss_idx = SLOT_IDX_CPNORM(5,lte_symbol_sz(cell.nof_prb)); uint32_t sss_idx = SRSLTE_SLOT_IDX_CPNORM(5,srslte_symbol_sz(cell.nof_prb));
if (sss_idx > frame_len) { if (sss_idx > frame_len) {
mexErrMsgTxt("Error too few samples provided.\n"); mexErrMsgTxt("Error too few samples provided.\n");
return; return;

@ -38,10 +38,10 @@
#include "srslte/srslte.h" #include "srslte/srslte.h"
int cell_id = -1, offset = 0; int cell_id = -1, offset = 0;
srslte_cp_t cp = CPNORM; srslte_cp_t cp = SRSLTE_SRSLTE_CP_NORM;
uint32_t nof_prb=6; uint32_t nof_prb=6;
#define FLEN SF_LEN(fft_size) #define FLEN SRSLTE_SF_LEN(fft_size)
void usage(char *prog) { void usage(char *prog) {
printf("Usage: %s [cpoev]\n", prog); printf("Usage: %s [cpoev]\n", prog);
@ -66,7 +66,7 @@ void parse_args(int argc, char **argv) {
offset = atoi(argv[optind]); offset = atoi(argv[optind]);
break; break;
case 'e': case 'e':
cp = CPEXT; cp = SRSLTE_SRSLTE_CP_EXT;
break; break;
case 'v': case 'v':
verbose++; verbose++;
@ -92,7 +92,7 @@ int main(int argc, char **argv) {
parse_args(argc, argv); parse_args(argc, argv);
fft_size = lte_symbol_sz(nof_prb); fft_size = srslte_symbol_sz(nof_prb);
if (fft_size < 0) { if (fft_size < 0) {
fprintf(stderr, "Invalid nof_prb=%d\n", nof_prb); fprintf(stderr, "Invalid nof_prb=%d\n", nof_prb);
exit(-1); exit(-1);
@ -165,7 +165,7 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
if (sync_get_cp(&sync) != cp) { if (sync_get_cp(&sync) != cp) {
printf("Detected CP should be %s\n", CP_ISNORM(cp)?"Normal":"Extended"); printf("Detected CP should be %s\n", SRSLTE_CP_ISNORM(cp)?"Normal":"Extended");
exit(-1); exit(-1);
} }
} }

@ -56,7 +56,7 @@ int ue_cell_search_init_max(ue_cell_search_t * q, uint32_t max_frames,
bzero(q, sizeof(ue_cell_search_t)); bzero(q, sizeof(ue_cell_search_t));
bzero(&cell, sizeof(srslte_cell_t)); bzero(&cell, sizeof(srslte_cell_t));
cell.id = CELL_ID_UNKNOWN; cell.id = SRSLTE_CELL_ID_UNKNOWN;
cell.nof_prb = CS_NOF_PRB; cell.nof_prb = CS_NOF_PRB;
if (ue_sync_init(&q->ue_sync, cell, recv_callback, stream_handler)) { if (ue_sync_init(&q->ue_sync, cell, recv_callback, stream_handler)) {
@ -157,7 +157,7 @@ static void get_cell(ue_cell_search_t * q, uint32_t nof_detected_frames, ue_cell
found_cell->peak = 0; found_cell->peak = 0;
for (i=0;i<nof_detected_frames;i++) { for (i=0;i<nof_detected_frames;i++) {
if (q->candidates[i].cell_id == found_cell->cell_id) { if (q->candidates[i].cell_id == found_cell->cell_id) {
if (CP_ISNORM(q->candidates[i].cp)) { if (SRSLTE_CP_ISNORM(q->candidates[i].cp)) {
nof_normal++; nof_normal++;
} }
} }
@ -167,9 +167,9 @@ static void get_cell(ue_cell_search_t * q, uint32_t nof_detected_frames, ue_cell
found_cell->peak /= nof_detected_frames; found_cell->peak /= nof_detected_frames;
if (nof_normal > q->mode_ntimes[mode_pos]/2) { if (nof_normal > q->mode_ntimes[mode_pos]/2) {
found_cell->cp = CPNORM; found_cell->cp = SRSLTE_SRSLTE_CP_NORM;
} else { } else {
found_cell->cp = CPEXT; found_cell->cp = SRSLTE_SRSLTE_CP_EXT;
} }
found_cell->mode = (float) q->mode_ntimes[mode_pos]/nof_detected_frames; found_cell->mode = (float) q->mode_ntimes[mode_pos]/nof_detected_frames;
@ -239,7 +239,7 @@ int ue_cell_search_scan_N_id_2(ue_cell_search_t * q, uint32_t N_id_2, ue_cell_se
("CELL SEARCH: [%3d/%3d/%d]: Found peak PSR=%.3f, Cell_id: %d CP: %s\n", ("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, nof_detected_frames, nof_scanned_frames, q->nof_frames_to_scan,
q->candidates[nof_detected_frames].peak, q->candidates[nof_detected_frames].cell_id, q->candidates[nof_detected_frames].peak, q->candidates[nof_detected_frames].cell_id,
lte_cp_string(q->candidates[nof_detected_frames].cp)); srslte_cp_string(q->candidates[nof_detected_frames].cp));
memcpy(&tmp_pss_corr[nof_detected_frames*32], memcpy(&tmp_pss_corr[nof_detected_frames*32],
&q->ue_sync.strack.pss.conv_output_avg[128], 32*sizeof(float)); &q->ue_sync.strack.pss.conv_output_avg[128], 32*sizeof(float));
memcpy(&tmp_sss_corr[nof_detected_frames*31], memcpy(&tmp_sss_corr[nof_detected_frames*31],

@ -30,11 +30,11 @@
#include <complex.h> #include <complex.h>
#include <math.h> #include <math.h>
#define CURRENT_FFTSIZE lte_symbol_sz(q->cell.nof_prb) #define CURRENT_FFTSIZE srslte_symbol_sz(q->cell.nof_prb)
#define CURRENT_SFLEN SF_LEN(CURRENT_FFTSIZE) #define CURRENT_SFLEN SRSLTE_SF_LEN(CURRENT_FFTSIZE)
#define CURRENT_SLOTLEN_RE SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp) #define CURRENT_SLOTLEN_RE SRSLTE_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp)
#define CURRENT_SFLEN_RE SF_LEN_RE(q->cell.nof_prb, q->cell.cp) #define CURRENT_SFLEN_RE SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)
#define MAX_CANDIDATES 64 #define MAX_CANDIDATES 64
@ -44,7 +44,7 @@ int ue_dl_init(ue_dl_t *q,
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && if (q != NULL &&
lte_cell_isvalid(&cell)) srslte_cell_isvalid(&cell))
{ {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
@ -219,7 +219,7 @@ int ue_dl_decode_rnti_rv_packet(ue_dl_t *q, dci_msg_t *dci_msg, uint8_t *data,
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (rnti != SIRNTI) { if (rnti != SRSLTE_SIRNTI) {
rvidx = q->ra_dl.rv_idx; 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 (harq_setup_dl(&q->harq_process[0], q->ra_dl.mcs, rvidx, sf_idx, &q->ra_dl.prb_alloc)) {
@ -276,7 +276,7 @@ int ue_dl_decode_rnti_rv(ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx
} }
/* Generate PDCCH candidates */ /* Generate PDCCH candidates */
if (rnti == SIRNTI) { if (rnti == SRSLTE_SIRNTI) {
nof_locations = pdcch_common_locations(&q->pdcch, locations, MAX_CANDIDATES, cfi); nof_locations = pdcch_common_locations(&q->pdcch, locations, MAX_CANDIDATES, cfi);
formats = common_formats; formats = common_formats;
nof_formats = nof_common_formats; nof_formats = nof_common_formats;

@ -48,14 +48,14 @@ int ue_mib_init(ue_mib_t * q,
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
bzero(q, sizeof(ue_mib_t)); bzero(q, sizeof(ue_mib_t));
q->sf_symbols = vec_malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); q->sf_symbols = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!q->sf_symbols) { if (!q->sf_symbols) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
for (int i=0;i<cell.nof_ports;i++) { for (int i=0;i<cell.nof_ports;i++) {
q->ce[i] = vec_malloc(SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t)); q->ce[i] = vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp) * sizeof(cf_t));
if (!q->ce[i]) { if (!q->ce[i]) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
@ -133,11 +133,11 @@ int ue_mib_decode(ue_mib_t * q, cf_t *input,
} }
for (int i=0;i<SRSLTE_MAX_PORTS;i++) { for (int i=0;i<SRSLTE_MAX_PORTS;i++) {
ce_slot1[i] = &q->ce[i][SLOT_LEN_RE(q->chest.cell.nof_prb, q->chest.cell.cp)]; ce_slot1[i] = &q->ce[i][SRSLTE_SLOT_LEN_RE(q->chest.cell.nof_prb, q->chest.cell.cp)];
} }
/* Decode PBCH */ /* Decode PBCH */
ret = pbch_decode(&q->pbch, &q->sf_symbols[SLOT_LEN_RE(q->chest.cell.nof_prb, q->chest.cell.cp)], ret = pbch_decode(&q->pbch, &q->sf_symbols[SRSLTE_SLOT_LEN_RE(q->chest.cell.nof_prb, q->chest.cell.cp)],
ce_slot1, srslte_chest_dl_get_noise_estimate(&q->chest), ce_slot1, srslte_chest_dl_get_noise_estimate(&q->chest),
bch_payload, nof_tx_ports, sfn_offset); bch_payload, nof_tx_ports, sfn_offset);
if (ret < 0) { if (ret < 0) {

@ -51,12 +51,12 @@ int ue_sync_init_file(ue_sync_t *q, uint32_t nof_prb, char *file_name) {
if (q != NULL && if (q != NULL &&
file_name != NULL && file_name != NULL &&
lte_nofprb_isvalid(nof_prb)) srslte_nofprb_isvalid(nof_prb))
{ {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
bzero(q, sizeof(ue_sync_t)); bzero(q, sizeof(ue_sync_t));
q->file_mode = true; q->file_mode = true;
q->sf_len = SF_LEN(lte_symbol_sz(nof_prb)); q->sf_len = SRSLTE_SF_LEN(srslte_symbol_sz(nof_prb));
if (filesource_init(&q->file_source, file_name, COMPLEX_FLOAT_BIN)) { if (filesource_init(&q->file_source, file_name, COMPLEX_FLOAT_BIN)) {
fprintf(stderr, "Error opening file %s\n", file_name); fprintf(stderr, "Error opening file %s\n", file_name);
@ -89,7 +89,7 @@ int ue_sync_init(ue_sync_t *q,
if (q != NULL && if (q != NULL &&
stream_handler != NULL && stream_handler != NULL &&
lte_nofprb_isvalid(cell.nof_prb) && srslte_nofprb_isvalid(cell.nof_prb) &&
recv_callback != NULL) recv_callback != NULL)
{ {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
@ -99,8 +99,8 @@ int ue_sync_init(ue_sync_t *q,
q->stream = stream_handler; q->stream = stream_handler;
q->recv_callback = recv_callback; q->recv_callback = recv_callback;
q->cell = cell; q->cell = cell;
q->fft_size = lte_symbol_sz(q->cell.nof_prb); q->fft_size = srslte_symbol_sz(q->cell.nof_prb);
q->sf_len = SF_LEN(q->fft_size); q->sf_len = SRSLTE_SF_LEN(q->fft_size);
q->file_mode = false; q->file_mode = false;
if (cell.id == 1000) { if (cell.id == 1000) {
@ -249,7 +249,7 @@ static int find_peak_ok(ue_sync_t *q) {
q->frame_find_cnt++; q->frame_find_cnt++;
INFO("Found peak %d at %d, value %.3f, Cell_id: %d CP: %s\n", INFO("Found peak %d at %d, value %.3f, Cell_id: %d CP: %s\n",
q->frame_find_cnt, q->peak_idx, q->frame_find_cnt, q->peak_idx,
sync_get_last_peak_value(&q->sfind), q->cell.id, lte_cp_string(q->cell.cp)); sync_get_last_peak_value(&q->sfind), q->cell.id, srslte_cp_string(q->cell.cp));
if (q->frame_find_cnt >= q->nof_avg_find_frames || q->peak_idx < 2*q->fft_size) { 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); INFO("Realigning frame, reading %d samples\n", q->peak_idx+q->sf_len/2);

@ -31,11 +31,11 @@
#include "srslte/ue/ue_ul.h" #include "srslte/ue/ue_ul.h"
#define CURRENT_FFTSIZE lte_symbol_sz(q->cell.nof_prb) #define CURRENT_FFTSIZE srslte_symbol_sz(q->cell.nof_prb)
#define CURRENT_SFLEN SF_LEN(CURRENT_FFTSIZE) #define CURRENT_SFLEN SRSLTE_SF_LEN(CURRENT_FFTSIZE)
#define CURRENT_SLOTLEN_RE SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp) #define CURRENT_SLOTLEN_RE SRSLTE_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp)
#define CURRENT_SFLEN_RE SF_LEN_RE(q->cell.nof_prb, q->cell.cp) #define CURRENT_SFLEN_RE SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)
int ue_ul_init(ue_ul_t *q, int ue_ul_init(ue_ul_t *q,
@ -44,7 +44,7 @@ int ue_ul_init(ue_ul_t *q,
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && if (q != NULL &&
lte_cell_isvalid(&cell)) srslte_cell_isvalid(&cell))
{ {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
@ -85,7 +85,7 @@ int ue_ul_init(ue_ul_t *q,
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
q->refsignal = vec_malloc(2 * RE_X_RB * q->cell.nof_prb * sizeof(cf_t)); q->refsignal = vec_malloc(2 * SRSLTE_NRE * q->cell.nof_prb * sizeof(cf_t));
if (!q->refsignal) { if (!q->refsignal) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
@ -214,11 +214,11 @@ int ue_ul_pusch_uci_encode_rnti(ue_ul_t *q, ra_pusch_t *ra_ul, uint8_t *data, uc
lte_ifft_run_sf(&q->fft, q->sf_symbols, output_signal); lte_ifft_run_sf(&q->fft, q->sf_symbols, output_signal);
//cfo_correct(&q->cfo, output_signal, output_signal, q->current_cfo / lte_symbol_sz(q->cell.nof_prb)); //cfo_correct(&q->cfo, output_signal, output_signal, q->current_cfo / srslte_symbol_sz(q->cell.nof_prb));
if (q->normalize_en) { if (q->normalize_en) {
float norm_factor = (float) q->cell.nof_prb/10/sqrtf(q->harq_process[0].ul_alloc.L_prb); float norm_factor = (float) q->cell.nof_prb/10/sqrtf(q->harq_process[0].ul_alloc.L_prb);
vec_sc_prod_cfc(output_signal, norm_factor, output_signal, SF_LEN_PRB(q->cell.nof_prb)); vec_sc_prod_cfc(output_signal, norm_factor, output_signal, SRSLTE_SF_LEN_PRB(q->cell.nof_prb));
} }
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;

Loading…
Cancel
Save