Added prefix to all exported symbols

master
ismagom 10 years ago
parent 0d71c911fe
commit 6d51de5ed6

@ -64,9 +64,9 @@ int cuhd_rssi_scan(void *uhd, float *freqs, float *rssi, int nof_bands, double f
goto free_and_exit; goto free_and_exit;
} }
} }
rssi[i] = vec_avg_power_cf(buffer, nsamp); rssi[i] = srslte_vec_avg_power_cf(buffer, nsamp);
printf("[%3d]: Freq %4.1f Mhz - RSSI: %3.2f dBm\r", i, f/1000000, 10*log10f(rssi[i]) + 30); fflush(stdout); printf("[%3d]: Freq %4.1f Mhz - RSSI: %3.2f dBm\r", i, f/1000000, 10*log10f(rssi[i]) + 30); fflush(stdout);
if (VERBOSE_ISINFO()) { if (SRSLTE_VERBOSE_ISINFO()) {
printf("\n"); printf("\n");
} }
} }

@ -16,7 +16,7 @@ for i=1:nf
end end
fs=fs+960; fs=fs+960;
[sfo sfo_v]=sfo_estimate(fs, 5/1000); [sfo sfo_v]=srslte_sfo_estimate(fs, 5/1000);
subplot(1,3,1) subplot(1,3,1)
plot(1:nf,fs) plot(1:nf,fs)

@ -1,4 +1,4 @@
function [ sfo sfo_v ] = sfo_estimate( fs, T ) function [ sfo sfo_v ] = srslte_sfo_estimate( fs, T )
nanfs=fs(~isnan(fs)); nanfs=fs(~isnan(fs));

@ -43,7 +43,7 @@ cec.InterpWinSize = 1; % Interpolation window size
%% DCI Message Generation %% DCI Message Generation
% Generate a DCI message to be mapped to the PDCCH. % Generate a DCI message to be mapped to the PDCCH.
dciConfig.DCIFormat = 'Format1A'; % DCI message format dciConfig.DCIFormat = 'SRSLTE_DCI_FORMAT1A'; % DCI message format
dciConfig.Allocation.RIV = 26; % Resource indication value dciConfig.Allocation.RIV = 26; % Resource indication value
% Create DCI message for given configuration % Create DCI message for given configuration

@ -12,7 +12,7 @@ enb.NTotalSubframes=1;
enb.DuplexMode = 'FDD'; enb.DuplexMode = 'FDD';
dci.NDLRB = enb.NDLRB; dci.NDLRB = enb.NDLRB;
dci.DCIFormat = 'Format1C'; dci.DCIFormat = 'SRSLTE_DCI_FORMAT1C';
dci.AllocationType=1; dci.AllocationType=1;
%dci.Allocation.Bitmap='01111000011110000'; %dci.Allocation.Bitmap='01111000011110000';
%dci.Allocation.Subset=3; %dci.Allocation.Subset=3;

@ -51,7 +51,7 @@ for i=1:length(TBs)
subframe_mat(idx)=cw_mat; subframe_mat(idx)=cw_mat;
waveform = lteSCFDMAModulate(ueConfig,subframe_mat,0); waveform = lteSCFDMAModulate(ueConfig,subframe_mat,0);
[waveform_lib, subframe_lib, cwlib]=liblte_pusch_encode(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit); [waveform_lib, subframe_lib, cwlib]=liblte_srslte_pusch_encode(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit);
err=mean(abs(waveform-waveform_lib)); err=mean(abs(waveform-waveform_lib));
if (err > 10^-6) if (err > 10^-6)
disp(err) disp(err)

@ -91,7 +91,7 @@ int mexutils_read_cell(const mxArray *ptr, srslte_cell_t *cell) {
int mexutils_read_cf(const mxArray *ptr, cf_t **buffer) { int mexutils_read_cf(const mxArray *ptr, cf_t **buffer) {
int numelems = mxGetNumberOfElements(ptr); int numelems = mxGetNumberOfElements(ptr);
cf_t *tmp = vec_malloc(numelems * sizeof(cf_t)); cf_t *tmp = srslte_vec_malloc(numelems * sizeof(cf_t));
if (tmp) { if (tmp) {
double *inr=mxGetPr(ptr); double *inr=mxGetPr(ptr);
double *ini=mxGetPi(ptr); double *ini=mxGetPi(ptr);
@ -110,7 +110,7 @@ int mexutils_read_cf(const mxArray *ptr, cf_t **buffer) {
int mexutils_read_f(const mxArray *ptr, float **buffer) { int mexutils_read_f(const mxArray *ptr, float **buffer) {
int numelems = mxGetNumberOfElements(ptr); int numelems = mxGetNumberOfElements(ptr);
float *tmp = vec_malloc(numelems * sizeof(float)); float *tmp = srslte_vec_malloc(numelems * sizeof(float));
if (tmp) { if (tmp) {
double *inr=mxGetPr(ptr); double *inr=mxGetPr(ptr);
for (int i=0;i<numelems;i++) { for (int i=0;i<numelems;i++) {
@ -125,7 +125,7 @@ int mexutils_read_f(const mxArray *ptr, float **buffer) {
int mexutils_read_uint8(const mxArray *ptr, uint8_t **buffer) { int mexutils_read_uint8(const mxArray *ptr, uint8_t **buffer) {
int numelems = mxGetNumberOfElements(ptr); int numelems = mxGetNumberOfElements(ptr);
uint8_t *tmp = vec_malloc(numelems * sizeof(uint8_t)); uint8_t *tmp = srslte_vec_malloc(numelems * sizeof(uint8_t));
if (tmp) { if (tmp) {
double *inr=mxGetPr(ptr); double *inr=mxGetPr(ptr);
for (int i=0;i<numelems;i++) { for (int i=0;i<numelems;i++) {

@ -45,3 +45,4 @@ ADD_CUSTOM_TARGET (add_lte_phy_headers SOURCES ${HEADERS_ALL})
# Add subdirectories # Add subdirectories
######################################################################## ########################################################################
ADD_SUBDIRECTORY(lib) ADD_SUBDIRECTORY(lib)

@ -78,7 +78,7 @@ void usage(prog_args_t *args, char *prog) {
printf("\t-g UHD RX gain [Default %.2f dB]\n", args->uhd_gain); printf("\t-g UHD RX gain [Default %.2f dB]\n", args->uhd_gain);
printf("\t-l Force N_id_2 [Default best]\n"); printf("\t-l Force N_id_2 [Default best]\n");
printf("\t-n nof_subframes [Default %d]\n", args->nof_subframes); printf("\t-n nof_subframes [Default %d]\n", args->nof_subframes);
printf("\t-v [set verbose to debug, default none]\n"); printf("\t-v [set srslte_verbose to debug, default none]\n");
} }
int parse_args(prog_args_t *args, int argc, char **argv) { int parse_args(prog_args_t *args, int argc, char **argv) {
@ -102,7 +102,7 @@ int parse_args(prog_args_t *args, int argc, char **argv) {
args->force_N_id_2 = atoi(argv[optind]); args->force_N_id_2 = atoi(argv[optind]);
break; break;
case 'v': case 'v':
verbose++; srslte_verbose++;
break; break;
default: default:
usage(args, argv[0]); usage(args, argv[0]);
@ -136,11 +136,11 @@ int main(int argc, char **argv) {
prog_args_t prog_args; prog_args_t prog_args;
srslte_cell_t cell; srslte_cell_t cell;
int64_t sf_cnt; int64_t sf_cnt;
ue_sync_t ue_sync; srslte_ue_sync_t ue_sync;
ue_mib_t ue_mib; srslte_ue_mib_t ue_mib;
void *uhd; void *uhd;
ue_dl_t ue_dl; srs_ue_dl_t ue_dl;
srslte_fft_t fft; srslte_ofdm_t fft;
srslte_chest_dl_t chest; srslte_chest_dl_t chest;
uint32_t nframes=0; uint32_t nframes=0;
uint32_t nof_trials = 0; uint32_t nof_trials = 0;
@ -190,26 +190,26 @@ int main(int argc, char **argv) {
cuhd_stop_rx_stream(uhd); cuhd_stop_rx_stream(uhd);
cuhd_flush_buffer(uhd); cuhd_flush_buffer(uhd);
if (ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) { if (srslte_ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
return -1; return -1;
} }
if (ue_dl_init(&ue_dl, cell)) { if (srs_ue_dl_init(&ue_dl, cell)) {
fprintf(stderr, "Error initiating UE downlink processing module\n"); fprintf(stderr, "Error initiating UE downlink processing module\n");
return -1; return -1;
} }
if (ue_mib_init(&ue_mib, cell)) { if (srslte_ue_mib_init(&ue_mib, cell)) {
fprintf(stderr, "Error initaiting UE MIB decoder\n"); fprintf(stderr, "Error initaiting UE MIB decoder\n");
return -1; return -1;
} }
/* 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, SRSLTE_SIRNTI); srs_ue_dl_set_rnti(&ue_dl, SRSLTE_SIRNTI);
/* Initialize subframe counter */ /* Initialize subframe counter */
sf_cnt = 0; sf_cnt = 0;
if (srslte_fft_init(&fft, cell.cp, cell.nof_prb)) { if (srslte_ofdm_tx_init(&fft, cell.cp, cell.nof_prb)) {
fprintf(stderr, "Error initiating FFT\n"); fprintf(stderr, "Error initiating FFT\n");
return -1; return -1;
} }
@ -220,10 +220,10 @@ int main(int argc, char **argv) {
int sf_re = SRSLTE_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 = srslte_vec_malloc(sf_re * sizeof(cf_t));
for (int i=0;i<SRSLTE_MAX_PORTS;i++) { for (int i=0;i<SRSLTE_MAX_PORTS;i++) {
ce[i] = vec_malloc(sizeof(cf_t) * sf_re); ce[i] = srslte_vec_malloc(sizeof(cf_t) * sf_re);
} }
cuhd_start_rx_stream(uhd); cuhd_start_rx_stream(uhd);
@ -231,24 +231,24 @@ int main(int argc, char **argv) {
/* Main loop */ /* Main loop */
while (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1) { while (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1) {
ret = ue_sync_get_buffer(&ue_sync, &sf_buffer); ret = srslte_ue_sync_get_buffer(&ue_sync, &sf_buffer);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error calling ue_sync_work()\n"); fprintf(stderr, "Error calling srslte_ue_sync_work()\n");
} }
/* ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */ /* srslte_ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */
if (ret == 1) { if (ret == 1) {
switch (state) { switch (state) {
case DECODE_MIB: case DECODE_MIB:
if (ue_sync_get_sfidx(&ue_sync) == 0) { if (srslte_ue_sync_get_sfidx(&ue_sync) == 0) {
pbch_decode_reset(&ue_mib.pbch); decode_reset(&ue_mib.pbch);
n = ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset); n = srslte_ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error decoding UE MIB\n"); fprintf(stderr, "Error decoding UE MIB\n");
return -1; return -1;
} else if (n == MIB_FOUND) { } else if (n == SRSLTE_UE_MIB_FOUND) {
bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN); srslte_bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN);
bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn); bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn);
printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset); printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset);
sfn = (sfn + sfn_offset)%1024; sfn = (sfn + sfn_offset)%1024;
@ -258,20 +258,20 @@ int main(int argc, char **argv) {
break; break;
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 ((srslte_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), SRSLTE_SIRNTI, n = srs_ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data, srslte_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);
return -1; return -1;
} else if (n == 0) { } else if (n == 0) {
printf("CFO: %+6.4f KHz, SFO: %+6.4f Khz, NOI: %.2f, PDCCH-Det: %.3f\r", printf("CFO: %+6.4f KHz, SFO: %+6.4f Khz, NOI: %.2f, PDCCH-Det: %.3f\r",
ue_sync_get_cfo(&ue_sync)/1000, ue_sync_get_sfo(&ue_sync)/1000, srslte_ue_sync_get_cfo(&ue_sync)/1000, srslte_ue_sync_get_sfo(&ue_sync)/1000,
sch_average_noi(&ue_dl.pdsch.dl_sch), srslte_sch_average_noi(&ue_dl.pdsch.dl_sch),
(float) ue_dl.nof_pdcch_detected/nof_trials); (float) ue_dl.nof_detected/nof_trials);
nof_trials++; nof_trials++;
} else { } else {
bit_unpack_vector(data, data_unpacked, n); srslte_bit_unpack_vector(data, data_unpacked, n);
void *dlsch_msg = bcch_dlsch_unpack(data_unpacked, n); void *dlsch_msg = bcch_dlsch_unpack(data_unpacked, n);
if (dlsch_msg) { if (dlsch_msg) {
printf("\n");fflush(stdout); printf("\n");fflush(stdout);
@ -287,17 +287,17 @@ int main(int argc, char **argv) {
case MEASURE: case MEASURE:
if (ue_sync_get_sfidx(&ue_sync) == 5) { if (srslte_ue_sync_get_sfidx(&ue_sync) == 5) {
/* Run FFT for all subframe data */ /* Run FFT for all subframe data */
srslte_fft_run_sf(&fft, sf_buffer, sf_symbols); srslte_ofdm_tx_sf(&fft, sf_buffer, sf_symbols);
srslte_chest_dl_estimate(&chest, sf_symbols, ce, ue_sync_get_sfidx(&ue_sync)); srslte_chest_dl_estimate(&chest, sf_symbols, ce, srslte_ue_sync_get_sfidx(&ue_sync));
rssi = VEC_CMA(vec_avg_power_cf(sf_buffer,SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb))),rssi,nframes); rssi = SRSLTE_VEC_CMA(srslte_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 = SRSLTE_VEC_CMA(srslte_chest_dl_get_rssi(&chest),rssi_utra,nframes);
rsrq = VEC_EMA(srslte_chest_dl_get_rsrq(&chest),rsrq,0.05); rsrq = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrq(&chest),rsrq,0.05);
rsrp = VEC_EMA(srslte_chest_dl_get_rsrp(&chest),rsrp,0.05); rsrp = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrp(&chest),rsrp,0.05);
snr = VEC_EMA(srslte_chest_dl_get_snr(&chest),snr,0.05); snr = SRSLTE_VEC_EMA(srslte_chest_dl_get_snr(&chest),snr,0.05);
nframes++; nframes++;
} }
@ -305,18 +305,18 @@ int main(int argc, char **argv) {
if ((nframes%10) == 0) { if ((nframes%10) == 0) {
printf("CFO: %+8.4f KHz, SFO: %+8.4f Khz, RSSI: %5.1f dBm, RSSI/ref-symbol: %+5.1f dBm, " printf("CFO: %+8.4f KHz, SFO: %+8.4f Khz, RSSI: %5.1f dBm, RSSI/ref-symbol: %+5.1f dBm, "
"RSRP: %+5.1f dBm, RSRQ: %5.1f dB, SNR: %5.1f dB\r", "RSRP: %+5.1f dBm, RSRQ: %5.1f dB, SNR: %5.1f dB\r",
ue_sync_get_cfo(&ue_sync)/1000, ue_sync_get_sfo(&ue_sync)/1000, srslte_ue_sync_get_cfo(&ue_sync)/1000, srslte_ue_sync_get_sfo(&ue_sync)/1000,
10*log10(rssi*1000)-gain_offset, 10*log10(rssi*1000)-gain_offset,
10*log10(rssi_utra*1000)-gain_offset, 10*log10(rssi_utra*1000)-gain_offset,
10*log10(rsrp*1000)-gain_offset, 10*log10(rsrp*1000)-gain_offset,
10*log10(rsrq), 10*log10(snr)); 10*log10(rsrq), 10*log10(snr));
if (verbose != VERBOSE_NONE) { if (srslte_verbose != SRSLTE_VERBOSE_NONE) {
printf("\n"); printf("\n");
} }
} }
break; break;
} }
if (ue_sync_get_sfidx(&ue_sync) == 9) { if (srslte_ue_sync_get_sfidx(&ue_sync) == 9) {
sfn++; sfn++;
if (sfn == 1024) { if (sfn == 1024) {
sfn = 0; sfn = 0;
@ -324,7 +324,7 @@ int main(int argc, char **argv) {
} }
} else if (ret == 0) { } else if (ret == 0) {
printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r", printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r",
sync_get_peak_value(&ue_sync.sfind), srslte_sync_get_peak_value(&ue_sync.sfind),
ue_sync.frame_total_cnt, ue_sync.state); ue_sync.frame_total_cnt, ue_sync.state);
} }
@ -332,7 +332,7 @@ int main(int argc, char **argv) {
sf_cnt++; sf_cnt++;
} // Main loop } // Main loop
ue_sync_free(&ue_sync); srslte_ue_sync_free(&ue_sync);
cuhd_close(uhd); cuhd_close(uhd);
printf("\nBye\n"); printf("\nBye\n");
exit(0); exit(0);

@ -69,7 +69,7 @@ void usage(char *prog) {
printf("\t-e earfcn_end [Default All]\n"); printf("\t-e earfcn_end [Default All]\n");
printf("\t-n nof_frames_total [Default 100]\n"); printf("\t-n nof_frames_total [Default 100]\n");
printf("\t-t threshold [Default %.2f]\n",config.threshold); printf("\t-t threshold [Default %.2f]\n",config.threshold);
printf("\t-v [set verbose to debug, default none]\n"); printf("\t-v [set srslte_verbose to debug, default none]\n");
} }
void parse_args(int argc, char **argv) { void parse_args(int argc, char **argv) {
@ -98,7 +98,7 @@ void parse_args(int argc, char **argv) {
uhd_gain = atof(argv[optind]); uhd_gain = atof(argv[optind]);
break; break;
case 'v': case 'v':
verbose++; srslte_verbose++;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -119,8 +119,8 @@ int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t
int main(int argc, char **argv) { int main(int argc, char **argv) {
int n; int n;
void *uhd; void *uhd;
ue_cell_search_t cs; srslte_ue_cellsearch_t cs;
ue_cell_search_result_t found_cells[3]; srslte_ue_cellsearch_result_t found_cells[3];
int nof_freqs; int nof_freqs;
srslte_earfcn_t channels[MAX_EARFCN]; srslte_earfcn_t channels[MAX_EARFCN];
uint32_t freq; uint32_t freq;
@ -150,30 +150,30 @@ int main(int argc, char **argv) {
printf("[%3d/%d]: EARFCN %d Freq. %.2f MHz looking for PSS. \n", freq, nof_freqs, printf("[%3d/%d]: EARFCN %d Freq. %.2f MHz looking for PSS. \n", freq, nof_freqs,
channels[freq].id, channels[freq].fd); channels[freq].id, channels[freq].fd);
if (VERBOSE_ISINFO()) { if (SRSLTE_VERBOSE_ISINFO()) {
printf("\n"); printf("\n");
} }
bzero(found_cells, 3*sizeof(ue_cell_search_result_t)); bzero(found_cells, 3*sizeof(srslte_ue_cellsearch_result_t));
if (ue_cell_search_init(&cs, cuhd_recv_wrapper, uhd)) { if (srslte_ue_cellsearch_init(&cs, cuhd_recv_wrapper, uhd)) {
fprintf(stderr, "Error initiating UE cell detect\n"); fprintf(stderr, "Error initiating UE cell detect\n");
exit(-1); exit(-1);
} }
if (config.max_frames_pss) { if (config.max_frames_pss) {
ue_cell_search_set_nof_frames_to_scan(&cs, config.max_frames_pss); srslte_ue_cellsearch_set_nof_frames_to_scan(&cs, config.max_frames_pss);
} }
if (config.threshold) { if (config.threshold) {
ue_cell_search_set_threshold(&cs, config.threshold); srslte_ue_cellsearch_set_threshold(&cs, config.threshold);
} }
INFO("Setting sampling frequency %.2f MHz for PSS search\n", CS_SAMP_FREQ/1000); INFO("Setting sampling frequency %.2f MHz for PSS search\n", SRSLTE_CS_SAMP_FREQ/1000);
cuhd_set_rx_srate(uhd, CS_SAMP_FREQ); cuhd_set_rx_srate(uhd, SRSLTE_CS_SAMP_FREQ);
INFO("Starting receiver...\n", 0); INFO("Starting receiver...\n", 0);
cuhd_start_rx_stream(uhd); cuhd_start_rx_stream(uhd);
n = ue_cell_search_scan(&cs, found_cells, NULL); n = srslte_ue_cellsearch_scan(&cs, found_cells, NULL);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error searching cell\n"); fprintf(stderr, "Error searching cell\n");
exit(-1); exit(-1);
@ -188,7 +188,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error decoding MIB\n"); fprintf(stderr, "Error decoding MIB\n");
exit(-1); exit(-1);
} }
if (ret == MIB_FOUND) { if (ret == SRSLTE_UE_MIB_FOUND) {
printf("Found CELL ID %d. %d PRB, %d ports\n", printf("Found CELL ID %d. %d PRB, %d ports\n",
cell.id, cell.nof_prb, cell.nof_ports); cell.id, cell.nof_prb, cell.nof_ports);
} }

@ -53,15 +53,15 @@ int cuhd_recv_wrapper_cs(void *h, void *data, uint32_t nsamples, srslte_timestam
*/ */
int cuhd_mib_decoder(void *uhd, uint32_t max_nof_frames, srslte_cell_t *cell) { int cuhd_mib_decoder(void *uhd, uint32_t max_nof_frames, srslte_cell_t *cell) {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
ue_mib_sync_t ue_mib; srslte_ue_mib_sync_t ue_mib;
uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN]; uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN];
if (ue_mib_sync_init(&ue_mib, cell->id, cell->cp, cuhd_recv_wrapper_cs, uhd)) { if (srslte_ue_mib_sync_init(&ue_mib, cell->id, cell->cp, cuhd_recv_wrapper_cs, uhd)) {
fprintf(stderr, "Error initiating ue_mib_sync\n"); fprintf(stderr, "Error initiating srslte_ue_mib_sync\n");
goto clean_exit; goto clean_exit;
} }
int srate = srslte_sampling_freq_hz(MIB_NOF_PRB); int srate = srslte_sampling_freq_hz(SRSLTE_UE_MIB_NOF_PRB);
INFO("Setting sampling frequency %.2f MHz for PSS search\n", (float) srate/1000000); 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);
@ -69,20 +69,20 @@ int cuhd_mib_decoder(void *uhd, uint32_t max_nof_frames, srslte_cell_t *cell) {
cuhd_start_rx_stream(uhd); cuhd_start_rx_stream(uhd);
/* Find and decody MIB */ /* Find and decody MIB */
ret = ue_mib_sync_decode(&ue_mib, max_nof_frames, bch_payload, &cell->nof_ports, NULL); ret = srslte_ue_mib_sync_decode(&ue_mib, max_nof_frames, bch_payload, &cell->nof_ports, NULL);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error decoding MIB\n"); fprintf(stderr, "Error decoding MIB\n");
goto clean_exit; goto clean_exit;
} }
if (ret == 1) { if (ret == 1) {
bit_unpack_vector(bch_payload, bch_payload_unpacked, BCH_PAYLOAD_LEN); srslte_bit_unpack_vector(bch_payload, bch_payload_unpacked, BCH_PAYLOAD_LEN);
bcch_bch_unpack(bch_payload_unpacked, BCH_PAYLOAD_LEN, cell, NULL); bcch_bch_unpack(bch_payload_unpacked, BCH_PAYLOAD_LEN, cell, NULL);
} }
clean_exit: clean_exit:
cuhd_stop_rx_stream(uhd); cuhd_stop_rx_stream(uhd);
ue_mib_sync_free(&ue_mib); srslte_ue_mib_sync_free(&ue_mib);
return ret; return ret;
} }
@ -93,25 +93,25 @@ int cuhd_cell_search(void *uhd, cell_search_cfg_t *config,
int force_N_id_2, srslte_cell_t *cell) int force_N_id_2, srslte_cell_t *cell)
{ {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
ue_cell_search_t cs; srslte_ue_cellsearch_t cs;
ue_cell_search_result_t found_cells[3]; srslte_ue_cellsearch_result_t found_cells[3];
bzero(found_cells, 3*sizeof(ue_cell_search_result_t)); bzero(found_cells, 3*sizeof(srslte_ue_cellsearch_result_t));
if (ue_cell_search_init(&cs, cuhd_recv_wrapper_cs, uhd)) { if (srslte_ue_cellsearch_init(&cs, cuhd_recv_wrapper_cs, uhd)) {
fprintf(stderr, "Error initiating UE cell detect\n"); fprintf(stderr, "Error initiating UE cell detect\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (config->max_frames_pss) { if (config->max_frames_pss) {
ue_cell_search_set_nof_frames_to_scan(&cs, config->max_frames_pss); srslte_ue_cellsearch_set_nof_frames_to_scan(&cs, config->max_frames_pss);
} }
if (config->threshold) { if (config->threshold) {
ue_cell_search_set_threshold(&cs, config->threshold); srslte_ue_cellsearch_set_threshold(&cs, config->threshold);
} }
INFO("Setting sampling frequency %.2f MHz for PSS search\n", CS_SAMP_FREQ/1000000); INFO("Setting sampling frequency %.2f MHz for PSS search\n", SRSLTE_CS_SAMP_FREQ/1000000);
cuhd_set_rx_srate(uhd, CS_SAMP_FREQ); cuhd_set_rx_srate(uhd, SRSLTE_CS_SAMP_FREQ);
INFO("Starting receiver...\n", 0); INFO("Starting receiver...\n", 0);
cuhd_start_rx_stream(uhd); cuhd_start_rx_stream(uhd);
@ -119,10 +119,10 @@ int cuhd_cell_search(void *uhd, cell_search_cfg_t *config,
/* Find a cell in the given N_id_2 or go through the 3 of them to find the strongest */ /* Find a cell in the given N_id_2 or go through the 3 of them to find the strongest */
uint32_t max_peak_cell = 0; uint32_t max_peak_cell = 0;
if (force_N_id_2 >= 0) { if (force_N_id_2 >= 0) {
ret = ue_cell_search_scan_N_id_2(&cs, force_N_id_2, &found_cells[force_N_id_2]); ret = srslte_ue_cellsearch_scan_N_id_2(&cs, force_N_id_2, &found_cells[force_N_id_2]);
max_peak_cell = force_N_id_2; max_peak_cell = force_N_id_2;
} else { } else {
ret = ue_cell_search_scan(&cs, found_cells, &max_peak_cell); ret = srslte_ue_cellsearch_scan(&cs, found_cells, &max_peak_cell);
} }
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error searching cell\n"); fprintf(stderr, "Error searching cell\n");
@ -139,7 +139,7 @@ int cuhd_cell_search(void *uhd, cell_search_cfg_t *config,
} }
cuhd_stop_rx_stream(uhd); cuhd_stop_rx_stream(uhd);
ue_cell_search_free(&cs); srslte_ue_cellsearch_free(&cs);
return ret; return ret;
} }

@ -39,10 +39,10 @@ void usage(char *arg) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
srslte_binsource_hl bs; srslte_binsource_hl bs;
mod_hl mod; srslte_mod_hl mod;
srslte_ch_awgn_hl ch; srslte_ch_awgn_hl ch;
demod_soft_hl demod_s; srslte_demod_soft_hl demod_s;
demod_hard_hl demod_h; srslte_demod_hard_hl demod_h;
bzero(&bs,sizeof(bs)); bzero(&bs,sizeof(bs));
bzero(&mod,sizeof(mod)); bzero(&mod,sizeof(mod));
@ -65,7 +65,7 @@ int main(int argc, char **argv) {
bs.output = malloc(nbits); bs.output = malloc(nbits);
mod.in_len = nbits; mod.in_len = nbits;
mod.init.std = LTE_BPSK; mod.init.std = SRSLTE_MOD_BPSK;
mod.input = bs.output; mod.input = bs.output;
mod.output = malloc(nbits*sizeof(_Complex float)); mod.output = malloc(nbits*sizeof(_Complex float));
@ -75,22 +75,22 @@ int main(int argc, char **argv) {
ch.output = malloc(nbits*sizeof(_Complex float)); ch.output = malloc(nbits*sizeof(_Complex float));
demod_h.in_len = nbits; demod_h.in_len = nbits;
demod_h.init.std = LTE_BPSK; demod_h.init.std = SRSLTE_MOD_BPSK;
demod_h.input = ch.output; demod_h.input = ch.output;
demod_h.output = malloc(nbits); demod_h.output = malloc(nbits);
demod_s.in_len = nbits; demod_s.in_len = nbits;
demod_s.init.std = LTE_BPSK; demod_s.init.std = SRSLTE_MOD_BPSK;
demod_s.input = ch.output; demod_s.input = ch.output;
demod_s.output = malloc(sizeof(float)*nbits); demod_s.output = malloc(sizeof(float)*nbits);
demod_s.ctrl_in.alg_type = APPROX; demod_s.ctrl_in.alg_type = SRSLTE_DEMOD_SOFT_ALG_APPROX;
demod_s.ctrl_in.sigma = var; demod_s.ctrl_in.sigma = var;
if ( srslte_binsource_initialize(&bs) || if ( srslte_binsource_initialize(&bs) ||
mod_initialize(&mod) || mod_initialize(&mod) ||
srslte_ch_awgn_initialize(&ch) || srslte_ch_awgn_initialize(&ch) ||
demod_hard_initialize(&demod_h) || srslte_demod_hard_initialize(&demod_h) ||
demod_soft_initialize(&demod_s) srslte_demod_soft_initialize(&demod_s)
) { ) {
printf("Error initializing modules\n"); printf("Error initializing modules\n");
exit(-1); exit(-1);
@ -99,8 +99,8 @@ int main(int argc, char **argv) {
srslte_binsource_work(&bs); srslte_binsource_work(&bs);
mod_work(&mod); mod_work(&mod);
srslte_ch_awgn_work(&ch); srslte_ch_awgn_work(&ch);
demod_hard_work(&demod_h); srslte_demod_hard_work(&demod_h);
demod_soft_work(&demod_s); srslte_demod_soft_work(&demod_s);
/* hard decision for soft demodulation */ /* hard decision for soft demodulation */
uint8_t* tmp = malloc(nbits); uint8_t* tmp = malloc(nbits);
@ -108,8 +108,8 @@ int main(int argc, char **argv) {
tmp[i] = demod_s.output[i]>0?1:0; tmp[i] = demod_s.output[i]>0?1:0;
} }
printf("Hard errors: %u/%d\n",bit_diff(bs.output,demod_h.output,nbits),nbits); printf("Hard errors: %u/%d\n",srslte_bit_diff(bs.output,demod_h.output,nbits),nbits);
printf("Soft errors: %u/%d\n",bit_diff(bs.output,tmp,nbits),nbits); printf("Soft errors: %u/%d\n",srslte_bit_diff(bs.output,tmp,nbits),nbits);
free(bs.output); free(bs.output);
free(mod.output); free(mod.output);

@ -45,7 +45,7 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
printf("output: "); printf("output: ");
bit_fprint(stdout,output,100); srslte_bit_fprint(stdout,output,100);
printf("Done\n"); printf("Done\n");
exit(0); exit(0);
} }

@ -69,14 +69,14 @@ float uhd_amp = 0.03, uhd_gain = 70.0, uhd_freq = 2400000000;
bool null_file_sink=false; bool null_file_sink=false;
srslte_filesink_t fsink; srslte_filesink_t fsink;
srslte_fft_t ifft; srslte_ofdm_t ifft;
pbch_t pbch; srslte_pbch_t pbch;
pcfich_t pcfich; srslte_pcfich_t pcfich;
pdcch_t pdcch; srslte_pdcch_t pdcch;
pdsch_t pdsch; srslte_pdsch_t pdsch;
harq_t harq_process; srslte_harq_t harq_process;
regs_t regs; srslte_regs_t regs;
ra_pdsch_t ra_dl; srslte_ra_pdsch_t ra_dl;
cf_t *sf_buffer = NULL, *output_buffer = NULL; cf_t *sf_buffer = NULL, *output_buffer = NULL;
@ -108,7 +108,7 @@ void usage(char *prog) {
printf("\t-c cell id [Default %d]\n", cell.id); printf("\t-c cell id [Default %d]\n", cell.id);
printf("\t-p nof_prb [Default %d]\n", cell.nof_prb); printf("\t-p nof_prb [Default %d]\n", cell.nof_prb);
printf("\t-u listen TCP port for input data (-1 is random) [Default %d]\n", net_port); printf("\t-u listen TCP port for input data (-1 is random) [Default %d]\n", net_port);
printf("\t-v [set verbose to debug, default none]\n"); printf("\t-v [set srslte_verbose to debug, default none]\n");
} }
void parse_args(int argc, char **argv) { void parse_args(int argc, char **argv) {
@ -146,7 +146,7 @@ void parse_args(int argc, char **argv) {
cell.id = atoi(argv[optind]); cell.id = atoi(argv[optind]);
break; break;
case 'v': case 'v':
verbose++; srslte_verbose++;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -216,44 +216,44 @@ void base_init() {
} }
/* create ifft object */ /* create ifft object */
if (lte_ifft_init(&ifft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb)) { if (srslte_ofdm_rx_init(&ifft, SRSLTE_SRSLTE_CP_NORM, cell.nof_prb)) {
fprintf(stderr, "Error creating iFFT object\n"); fprintf(stderr, "Error creating iFFT object\n");
exit(-1); exit(-1);
} }
srslte_fft_set_normalize(&ifft, true); srslte_ofdm_set_normalize(&ifft, true);
if (pbch_init(&pbch, cell)) { if (srslte_pbch_init(&pbch, cell)) {
fprintf(stderr, "Error creating PBCH object\n"); fprintf(stderr, "Error creating PBCH object\n");
exit(-1); exit(-1);
} }
if (regs_init(&regs, cell)) { if (srslte_regs_init(&regs, cell)) {
fprintf(stderr, "Error initiating regs\n"); fprintf(stderr, "Error initiating regs\n");
exit(-1); exit(-1);
} }
if (pcfich_init(&pcfich, &regs, cell)) { if (srslte_pcfich_init(&pcfich, &regs, cell)) {
fprintf(stderr, "Error creating PBCH object\n"); fprintf(stderr, "Error creating PBCH object\n");
exit(-1); exit(-1);
} }
if (regs_set_cfi(&regs, cfi)) { if (srslte_regs_set_cfi(&regs, cfi)) {
fprintf(stderr, "Error setting CFI\n"); fprintf(stderr, "Error setting CFI\n");
exit(-1); exit(-1);
} }
if (pdcch_init(&pdcch, &regs, cell)) { if (srslte_pdcch_init(&pdcch, &regs, cell)) {
fprintf(stderr, "Error creating PDCCH object\n"); fprintf(stderr, "Error creating PDCCH object\n");
exit(-1); exit(-1);
} }
if (pdsch_init(&pdsch, cell)) { if (srslte_pdsrslte_sch_init(&pdsch, cell)) {
fprintf(stderr, "Error creating PDSCH object\n"); fprintf(stderr, "Error creating PDSCH object\n");
exit(-1); exit(-1);
} }
pdsch_set_rnti(&pdsch, 1234); srslte_pdsch_set_rnti(&pdsch, 1234);
if (harq_init(&harq_process, cell)) { if (srslte_harq_init(&harq_process, cell)) {
fprintf(stderr, "Error initiating HARQ process\n"); fprintf(stderr, "Error initiating HARQ process\n");
exit(-1); exit(-1);
} }
@ -262,12 +262,12 @@ void base_init() {
void base_free() { void base_free() {
harq_free(&harq_process); harq_free(&harq_process);
pdsch_free(&pdsch); srslte_pdsch_free(&pdsch);
pdcch_free(&pdcch); srslte_pdcch_free(&pdcch);
regs_free(&regs); srslte_regs_free(&regs);
pbch_free(&pbch); srslte_pbch_free(&pbch);
lte_ifft_free(&ifft); srslte_ofdm_rx_free(&ifft);
if (sf_buffer) { if (sf_buffer) {
free(sf_buffer); free(sf_buffer);
@ -304,7 +304,7 @@ reverse(register unsigned int x)
uint32_t prbset_to_bitmask() { uint32_t prbset_to_bitmask() {
uint32_t mask=0; uint32_t mask=0;
int nb = (int) ceilf((float) cell.nof_prb / ra_type0_P(cell.nof_prb)); int nb = (int) ceilf((float) cell.nof_prb / srslte_ra_type0_P(cell.nof_prb));
for (int i=0;i<nb;i++) { for (int i=0;i<nb;i++) {
if (i >= prbset_orig && i < prbset_orig + prbset_num) { if (i >= prbset_orig && i < prbset_orig + prbset_num) {
mask = mask | (0x1<<i); mask = mask | (0x1<<i);
@ -314,25 +314,25 @@ uint32_t prbset_to_bitmask() {
} }
int update_radl(uint32_t sf_idx) { int update_radl(uint32_t sf_idx) {
ra_dl_alloc_t prb_alloc; srslte_srslte_ra_dl_alloc_t prb_alloc;
bzero(&ra_dl, sizeof(ra_pdsch_t)); bzero(&ra_dl, sizeof(srslte_ra_pdsch_t));
ra_dl.harq_process = 0; ra_dl.harq_process = 0;
ra_dl.mcs_idx = mcs_idx; ra_dl.mcs_idx = mcs_idx;
ra_dl.ndi = 0; ra_dl.ndi = 0;
ra_dl.rv_idx = 0; ra_dl.rv_idx = 0;
ra_dl.alloc_type = alloc_type0; ra_dl.alloc_type = SRSLTE_RA_ALLOC_TYPE0;
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); srslte_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, SRSLTE_SRSLTE_CP_NORM); srslte_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); srslte_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); srslte_ra_pdsch_fprint(stdout, &ra_dl, cell.nof_prb);
printf("Type new MCS index and press Enter: "); fflush(stdout); printf("Type new MCS index and press Enter: "); fflush(stdout);
harq_reset(&harq_process); srslte_harq_reset(&harq_process);
if (harq_setup_dl(&harq_process, ra_dl.mcs, ra_dl.rv_idx, sf_idx, &prb_alloc)) { if (srslte_harq_setup_dl(&harq_process, ra_dl.mcs, ra_dl.rv_idx, sf_idx, &prb_alloc)) {
fprintf(stderr, "Error configuring HARQ process\n"); fprintf(stderr, "Error configuring HARQ process\n");
return -1; return -1;
} }
@ -359,7 +359,7 @@ int update_control(uint32_t sf_idx) {
if(input[0] == 27) { if(input[0] == 27) {
switch(input[2]) { switch(input[2]) {
case RIGHT_KEY: case RIGHT_KEY:
if (prbset_orig + prbset_num < (int) ceilf((float) cell.nof_prb / ra_type0_P(cell.nof_prb))) if (prbset_orig + prbset_num < (int) ceilf((float) cell.nof_prb / srslte_ra_type0_P(cell.nof_prb)))
prbset_orig++; prbset_orig++;
break; break;
case LEFT_KEY: case LEFT_KEY:
@ -367,7 +367,7 @@ int update_control(uint32_t sf_idx) {
prbset_orig--; prbset_orig--;
break; break;
case UP_KEY: case UP_KEY:
if (prbset_num < (int) ceilf((float) cell.nof_prb / ra_type0_P(cell.nof_prb))) if (prbset_num < (int) ceilf((float) cell.nof_prb / srslte_ra_type0_P(cell.nof_prb)))
prbset_num++; prbset_num++;
break; break;
case DOWN_KEY: case DOWN_KEY:
@ -417,7 +417,7 @@ void *net_thread_fnc(void *arg) {
while (rpm >= nbytes) { while (rpm >= nbytes) {
// wait for packet to be transmitted // wait for packet to be transmitted
sem_wait(&net_sem); sem_wait(&net_sem);
bit_pack_vector(&data_unpacked[wpm], data, nbytes*8); srslte_bit_pack_vector(&data_unpacked[wpm], data, nbytes*8);
INFO("Sent %d/%d bytes ready\n", nbytes, rpm); INFO("Sent %d/%d bytes ready\n", nbytes, rpm);
rpm -= nbytes; rpm -= nbytes;
wpm += nbytes; wpm += nbytes;
@ -439,15 +439,15 @@ void *net_thread_fnc(void *arg) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
int nf=0, sf_idx=0, N_id_2=0; int nf=0, sf_idx=0, N_id_2=0;
cf_t pss_signal[PSS_LEN]; cf_t pss_signal[SRSLTE_PSS_LEN];
float sss_signal0[SSS_LEN]; // for subframe 0 float sss_signal0[SRSLTE_SSS_LEN]; // for subframe 0
float sss_signal5[SSS_LEN]; // for subframe 5 float sss_signal5[SRSLTE_SSS_LEN]; // for subframe 5
uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_packed[BCH_PAYLOAD_LEN/8]; uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_packed[BCH_PAYLOAD_LEN/8];
int i; int i;
cf_t *sf_symbols[SRSLTE_MAX_PORTS]; cf_t *sf_symbols[SRSLTE_MAX_PORTS];
cf_t *slot1_symbols[SRSLTE_MAX_PORTS]; cf_t *slot1_symbols[SRSLTE_MAX_PORTS];
dci_msg_t dci_msg; srslte_dci_msg_t dci_msg;
dci_location_t locations[SRSLTE_NSUBFRAMES_X_FRAME][30]; srslte_dci_location_t locations[SRSLTE_NSUBFRAMES_X_FRAME][30];
uint32_t sfn; uint32_t sfn;
srslte_chest_dl_t est; srslte_chest_dl_t est;
@ -468,15 +468,15 @@ int main(int argc, char **argv) {
cell.phich_resources = SRSLTE_PHICH_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 / srslte_ra_type0_P(cell.nof_prb));
last_prbset_num = prbset_num; last_prbset_num = prbset_num;
/* this *must* be called after setting slot_len_* */ /* this *must* be called after setting slot_len_* */
base_init(); base_init();
/* Generate PSS/SSS signals */ /* Generate PSS/SSS signals */
pss_generate(pss_signal, N_id_2); srslte_pss_generate(pss_signal, N_id_2);
sss_generate(sss_signal0, sss_signal5, cell.id); srslte_sss_generate(sss_signal0, sss_signal5, cell.id);
/* Generate CRS signals */ /* Generate CRS signals */
if (srslte_chest_dl_init(&est, cell)) { if (srslte_chest_dl_init(&est, cell)) {
@ -512,7 +512,7 @@ int main(int argc, char **argv) {
/* Initiate valid DCI locations */ /* Initiate valid DCI locations */
for (i=0;i<SRSLTE_NSUBFRAMES_X_FRAME;i++) { for (i=0;i<SRSLTE_NSUBFRAMES_X_FRAME;i++) {
pdcch_ue_locations(&pdcch, locations[i], 30, i, cfi, 1234); srslte_pdcch_ue_locations(&pdcch, locations[i], 30, i, cfi, 1234);
} }
@ -525,20 +525,20 @@ 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, SRSLTE_SRSLTE_CP_NORM); srslte_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, srslte_sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, sf_buffer, cell.nof_prb,
SRSLTE_SRSLTE_CP_NORM); 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);
bcch_bch_pack(&cell, sfn, bch_payload_packed, BCH_PAYLOAD_LEN/8); bcch_bch_pack(&cell, sfn, bch_payload_packed, BCH_PAYLOAD_LEN/8);
bit_pack_vector(bch_payload_packed, bch_payload, BCH_PAYLOAD_LEN); srslte_bit_pack_vector(bch_payload_packed, bch_payload, BCH_PAYLOAD_LEN);
if (sf_idx == 0) { if (sf_idx == 0) {
pbch_encode(&pbch, bch_payload, slot1_symbols); srslte_pbch_encode(&pbch, bch_payload, slot1_symbols);
} }
pcfich_encode(&pcfich, cfi, sf_symbols, sf_idx); srslte_pcfich_encode(&pcfich, cfi, sf_symbols, sf_idx);
/* Update DL resource allocation from control port */ /* Update DL resource allocation from control port */
if (update_control(sf_idx)) { if (update_control(sf_idx)) {
@ -564,20 +564,20 @@ int main(int argc, char **argv) {
} }
if (send_data) { if (send_data) {
dci_msg_pack_pdsch(&ra_dl, &dci_msg, Format1, cell.nof_prb, false); srslte_dci_msg_pack_pdsch(&ra_dl, &dci_msg, SRSLTE_DCI_FORMAT1, cell.nof_prb, false);
INFO("Putting DCI to location: n=%d, L=%d\n", locations[sf_idx][0].ncce, locations[sf_idx][0].L); INFO("Putting DCI to location: n=%d, L=%d\n", locations[sf_idx][0].ncce, locations[sf_idx][0].L);
if (pdcch_encode(&pdcch, &dci_msg, locations[sf_idx][0], 1234, sf_symbols, sf_idx, cfi)) { if (encode(&pdcch, &dci_msg, locations[sf_idx][0], 1234, sf_symbols, sf_idx, cfi)) {
fprintf(stderr, "Error encoding DCI message\n"); fprintf(stderr, "Error encoding DCI message\n");
exit(-1); exit(-1);
} }
if (pdsch_encode(&pdsch, &harq_process, data, sf_symbols)) { if (srslte_pdsch_encode(&pdsch, &harq_process, data, sf_symbols)) {
fprintf(stderr, "Error encoding PDSCH\n"); fprintf(stderr, "Error encoding PDSCH\n");
exit(-1); exit(-1);
} }
if (net_port > 0 && net_packet_ready) { if (net_port > 0 && net_packet_ready) {
if (null_file_sink) { if (null_file_sink) {
bit_unpack_vector(data, data_tmp, ra_dl.mcs.tbs); srslte_bit_unpack_vector(data, data_tmp, ra_dl.mcs.tbs);
if (srslte_netsink_write(&net_sink, data_tmp, 1+(ra_dl.mcs.tbs-1)/8) < 0) { if (srslte_netsink_write(&net_sink, data_tmp, 1+(ra_dl.mcs.tbs-1)/8) < 0) {
fprintf(stderr, "Error sending data through UDP socket\n"); fprintf(stderr, "Error sending data through UDP socket\n");
} }
@ -588,10 +588,10 @@ int main(int argc, char **argv) {
} }
/* Transform to OFDM symbols */ /* Transform to OFDM symbols */
lte_ifft_run_sf(&ifft, sf_buffer, output_buffer); srslte_ofdm_rx_sf(&ifft, sf_buffer, output_buffer);
float norm_factor = (float) cell.nof_prb/15/sqrtf(ra_dl.prb_alloc.slot[0].nof_prb); float norm_factor = (float) cell.nof_prb/15/sqrtf(ra_dl.prb_alloc.slot[0].nof_prb);
vec_sc_prod_cfc(output_buffer, uhd_amp*norm_factor, output_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb)); srslte_vec_sc_prod_cfc(output_buffer, uhd_amp*norm_factor, output_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb));
/* send to file or usrp */ /* send to file or usrp */
if (output_file_name) { if (output_file_name) {
@ -601,7 +601,7 @@ int main(int argc, char **argv) {
usleep(1000); usleep(1000);
} else { } else {
#ifndef DISABLE_UHD #ifndef DISABLE_UHD
vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, sf_n_samples); srslte_vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, sf_n_samples);
cuhd_send(uhd, output_buffer, sf_n_samples, true); cuhd_send(uhd, output_buffer, sf_n_samples, true);
#endif #endif
} }

@ -130,7 +130,7 @@ void usage(prog_args_t *args, char *prog) {
printf("\t-S remote UDP address to send input signal [Default %s]\n", args->net_address_signal); printf("\t-S remote UDP address to send input signal [Default %s]\n", args->net_address_signal);
printf("\t-u remote TCP port to send data (-1 does nothing with it) [Default %d]\n", args->net_port); printf("\t-u remote TCP port to send data (-1 does nothing with it) [Default %d]\n", args->net_port);
printf("\t-U remote TCP address to send data [Default %s]\n", args->net_address); printf("\t-U remote TCP address to send data [Default %s]\n", args->net_address);
printf("\t-v [set verbose to debug, default none]\n"); printf("\t-v [set srslte_verbose to debug, default none]\n");
} }
void parse_args(prog_args_t *args, int argc, char **argv) { void parse_args(prog_args_t *args, int argc, char **argv) {
@ -181,7 +181,7 @@ void parse_args(prog_args_t *args, int argc, char **argv) {
args->disable_plots = true; args->disable_plots = true;
break; break;
case 'v': case 'v':
verbose++; srslte_verbose++;
break; break;
default: default:
usage(args, argv[0]); usage(args, argv[0]);
@ -218,8 +218,8 @@ extern float mean_exec_time;
enum receiver_state { DECODE_MIB, DECODE_PDSCH} state; enum receiver_state { DECODE_MIB, DECODE_PDSCH} state;
ue_dl_t ue_dl; srs_ue_dl_t ue_dl;
ue_sync_t ue_sync; srslte_ue_sync_t ue_sync;
prog_args_t prog_args; prog_args_t prog_args;
uint32_t sfn = 0; // system frame number uint32_t sfn = 0; // system frame number
@ -230,7 +230,7 @@ int main(int argc, char **argv) {
int ret; int ret;
srslte_cell_t cell; srslte_cell_t cell;
int64_t sf_cnt; int64_t sf_cnt;
ue_mib_t ue_mib; srslte_ue_mib_t ue_mib;
#ifndef DISABLE_UHD #ifndef DISABLE_UHD
void *uhd; void *uhd;
#endif #endif
@ -293,7 +293,7 @@ int main(int argc, char **argv) {
cuhd_stop_rx_stream(uhd); cuhd_stop_rx_stream(uhd);
cuhd_flush_buffer(uhd); cuhd_flush_buffer(uhd);
if (ue_mib_init(&ue_mib, cell)) { if (srslte_ue_mib_init(&ue_mib, cell)) {
fprintf(stderr, "Error initaiting UE MIB decoder\n"); fprintf(stderr, "Error initaiting UE MIB decoder\n");
exit(-1); exit(-1);
} }
@ -311,7 +311,7 @@ int main(int argc, char **argv) {
cell.nof_ports = 1; cell.nof_ports = 1;
cell.nof_prb = prog_args.file_nof_prb; cell.nof_prb = prog_args.file_nof_prb;
if (ue_sync_init_file(&ue_sync, prog_args.file_nof_prb, prog_args.input_file_name)) { if (srslte_ue_sync_init_file(&ue_sync, prog_args.file_nof_prb, prog_args.input_file_name)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
exit(-1); exit(-1);
} }
@ -319,20 +319,20 @@ int main(int argc, char **argv) {
} else { } else {
#ifndef DISABLE_UHD #ifndef DISABLE_UHD
state = DECODE_MIB; state = DECODE_MIB;
if (ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) { if (srslte_ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper, uhd)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
exit(-1); exit(-1);
} }
#endif #endif
} }
if (ue_dl_init(&ue_dl, cell)) { // This is the User RNTI if (srs_ue_dl_init(&ue_dl, cell)) { // This is the User RNTI
fprintf(stderr, "Error initiating UE downlink processing module\n"); fprintf(stderr, "Error initiating UE downlink processing module\n");
exit(-1); exit(-1);
} }
/* 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, prog_args.rnti); srs_ue_dl_set_rnti(&ue_dl, prog_args.rnti);
/* Initialize subframe counter */ /* Initialize subframe counter */
sf_cnt = 0; sf_cnt = 0;
@ -361,23 +361,23 @@ int main(int argc, char **argv) {
/* Main loop */ /* Main loop */
while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) { while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) {
ret = ue_sync_get_buffer(&ue_sync, &sf_buffer); ret = srslte_ue_sync_get_buffer(&ue_sync, &sf_buffer);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error calling ue_sync_work()\n"); fprintf(stderr, "Error calling srslte_ue_sync_work()\n");
} }
/* ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */ /* srslte_ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */
if (ret == 1) { if (ret == 1) {
switch (state) { switch (state) {
case DECODE_MIB: case DECODE_MIB:
if (ue_sync_get_sfidx(&ue_sync) == 0) { if (srslte_ue_sync_get_sfidx(&ue_sync) == 0) {
pbch_decode_reset(&ue_mib.pbch); decode_reset(&ue_mib.pbch);
n = ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset); n = srslte_ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error decoding UE MIB\n"); fprintf(stderr, "Error decoding UE MIB\n");
exit(-1); exit(-1);
} else if (n == MIB_FOUND) { } else if (n == SRSLTE_UE_MIB_FOUND) {
bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN); srslte_bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN);
bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn); bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn);
printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset); printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset);
sfn = (sfn + sfn_offset)%1024; sfn = (sfn + sfn_offset)%1024;
@ -390,7 +390,7 @@ int main(int argc, char **argv) {
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 */
if ((ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) { if ((srslte_ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) {
decode_pdsch = true; decode_pdsch = true;
} else { } else {
decode_pdsch = false; decode_pdsch = false;
@ -398,9 +398,9 @@ int main(int argc, char **argv) {
} }
if (decode_pdsch) { if (decode_pdsch) {
if (prog_args.rnti != SRSLTE_SIRNTI) { if (prog_args.rnti != SRSLTE_SIRNTI) {
n = ue_dl_decode(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync)); n = srs_ue_dl_decode(&ue_dl, sf_buffer, data_packed, srslte_ue_sync_get_sfidx(&ue_sync));
} else { } else {
n = ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data_packed, ue_sync_get_sfidx(&ue_sync), SRSLTE_SIRNTI, n = srs_ue_dl_decode_rnti_rv(&ue_dl, sf_buffer, data_packed, srslte_ue_sync_get_sfidx(&ue_sync), SRSLTE_SIRNTI,
((int) ceilf((float)3*(((sfn)/2)%4)/2))%4); ((int) ceilf((float)3*(((sfn)/2)%4)/2))%4);
} }
if (n < 0) { if (n < 0) {
@ -408,15 +408,15 @@ int main(int argc, char **argv) {
} else if (n > 0) { } else if (n > 0) {
/* Send data if socket active */ /* Send data if socket active */
if (prog_args.net_port > 0) { if (prog_args.net_port > 0) {
bit_unpack_vector(data_packed, data, n); srslte_bit_unpack_vector(data_packed, data, n);
srslte_netsink_write(&net_sink, data, 1+(n-1)/8); srslte_netsink_write(&net_sink, data, 1+(n-1)/8);
} }
} }
nof_trials++; nof_trials++;
rsrq = VEC_EMA(srslte_chest_dl_get_rsrq(&ue_dl.chest), rsrq, 0.05); rsrq = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrq(&ue_dl.chest), rsrq, 0.05);
rsrp = VEC_EMA(srslte_chest_dl_get_rsrp(&ue_dl.chest), rsrp, 0.05); rsrp = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrp(&ue_dl.chest), rsrp, 0.05);
snr = VEC_EMA(srslte_chest_dl_get_snr(&ue_dl.chest), snr, 0.01); snr = SRSLTE_VEC_EMA(srslte_chest_dl_get_snr(&ue_dl.chest), snr, 0.01);
nframes++; nframes++;
if (isnan(rsrq)) { if (isnan(rsrq)) {
rsrq = 0; rsrq = 0;
@ -443,32 +443,32 @@ int main(int argc, char **argv) {
#endif #endif
} }
if (ue_sync_get_sfidx(&ue_sync) != 5 && ue_sync_get_sfidx(&ue_sync) != 0) { if (srslte_ue_sync_get_sfidx(&ue_sync) != 5 && srslte_ue_sync_get_sfidx(&ue_sync) != 0) {
pdcch_tx++; pdcch_tx++;
} }
// Plot and Printf // Plot and Printf
if (ue_sync_get_sfidx(&ue_sync) == 5) { if (srslte_ue_sync_get_sfidx(&ue_sync) == 5) {
#ifdef STDOUT_COMPACT #ifdef STDOUT_COMPACT
printf("SFN: %4d, PDCCH-Miss: %5.2f%% (%d missed), PDSCH-BLER: %5.2f%% (%d errors)\r", printf("SFN: %4d, PDCCH-Miss: %5.2f%% (%d missed), PDSCH-BLER: %5.2f%% (%d errors)\r",
sfn, 100*(1-(float) ue_dl.nof_pdcch_detected/nof_trials),pdcch_tx-ue_dl.nof_pdcch_detected, sfn, 100*(1-(float) ue_dl.nof_detected/nof_trials),pdcch_tx-ue_dl.nof_detected,
(float) 100*ue_dl.pkt_errors/ue_dl.pkts_total,ue_dl.pkt_errors); (float) 100*ue_dl.pkt_errors/ue_dl.pkts_total,ue_dl.pkt_errors);
#else #else
printf("CFO: %+6.2f KHz, SFO: %+6.2f Khz, " printf("CFO: %+6.2f KHz, SFO: %+6.2f Khz, "
"RSRP: %+5.1f dBm, RSRQ: %5.1f dB, SNR: %4.1f dB, " "RSRP: %+5.1f dBm, RSRQ: %5.1f dB, SNR: %4.1f dB, "
"PDCCH-Miss: %5.2f%% (%d), PDSCH-BLER: %5.2f%% (%d)\r", "PDCCH-Miss: %5.2f%% (%d), PDSCH-BLER: %5.2f%% (%d)\r",
ue_sync_get_cfo(&ue_sync)/1000, ue_sync_get_sfo(&ue_sync)/1000, srslte_ue_sync_get_cfo(&ue_sync)/1000, srslte_ue_sync_get_sfo(&ue_sync)/1000,
10*log10(rsrp*1000)-gain_offset, 10*log10(rsrp*1000)-gain_offset,
10*log10(rsrq), 10*log10(snr), 10*log10(rsrq), 10*log10(snr),
100*(1-(float) ue_dl.nof_pdcch_detected/nof_trials), pdcch_tx-ue_dl.nof_pdcch_detected, 100*(1-(float) ue_dl.nof_detected/nof_trials), pdcch_tx-ue_dl.nof_detected,
(float) 100*ue_dl.pkt_errors/ue_dl.pkts_total, ue_dl.pkt_errors); (float) 100*ue_dl.pkt_errors/ue_dl.pkts_total, ue_dl.pkt_errors);
#endif #endif
} }
break; break;
} }
if (ue_sync_get_sfidx(&ue_sync) == 9) { if (srslte_ue_sync_get_sfidx(&ue_sync) == 9) {
sfn++; sfn++;
if (sfn == 1024) { if (sfn == 1024) {
sfn = 0; sfn = 0;
@ -477,25 +477,25 @@ int main(int argc, char **argv) {
#ifndef DISABLE_GRAPHICS #ifndef DISABLE_GRAPHICS
if (!prog_args.disable_plots) { if (!prog_args.disable_plots) {
plot_sf_idx = ue_sync_get_sfidx(&ue_sync); plot_sf_idx = srslte_ue_sync_get_sfidx(&ue_sync);
sem_post(&plot_sem); sem_post(&plot_sem);
} }
#endif #endif
} else if (ret == 0) { } else if (ret == 0) {
printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r", printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r",
sync_get_peak_value(&ue_sync.sfind), srslte_sync_get_peak_value(&ue_sync.sfind),
ue_sync.frame_total_cnt, ue_sync.state); ue_sync.frame_total_cnt, ue_sync.state);
} }
sf_cnt++; sf_cnt++;
} // Main loop } // Main loop
ue_dl_free(&ue_dl); srs_ue_dl_free(&ue_dl);
ue_sync_free(&ue_sync); srslte_ue_sync_free(&ue_sync);
#ifndef DISABLE_UHD #ifndef DISABLE_UHD
if (!prog_args.input_file_name) { if (!prog_args.input_file_name) {
ue_mib_free(&ue_mib); srslte_ue_mib_free(&ue_mib);
cuhd_close(uhd); cuhd_close(uhd);
} }
#endif #endif
@ -549,8 +549,8 @@ void *plot_thread_run(void *arg) {
//} //}
plot_real_setNewData(&pce, tmp_plot2, SRSLTE_REFSIGNAL_NUM_SF(ue_dl.cell.nof_prb,0)); 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) {
int max = vec_max_fi(ue_sync.strack.pss.conv_output_avg, ue_sync.strack.pss.frame_size+ue_sync.strack.pss.fft_size-1); int max = srslte_vec_max_fi(ue_sync.strack.pss.conv_output_avg, ue_sync.strack.pss.frame_size+ue_sync.strack.pss.fft_size-1);
vec_sc_prod_fff(ue_sync.strack.pss.conv_output_avg, srslte_vec_sc_prod_fff(ue_sync.strack.pss.conv_output_avg,
1/ue_sync.strack.pss.conv_output_avg[max], 1/ue_sync.strack.pss.conv_output_avg[max],
tmp_plot2, tmp_plot2,
ue_sync.strack.pss.frame_size+ue_sync.strack.pss.fft_size-1); ue_sync.strack.pss.frame_size+ue_sync.strack.pss.fft_size-1);
@ -558,13 +558,13 @@ void *plot_thread_run(void *arg) {
} }
plot_scatter_setNewData(&pscatequal, ue_dl.pdsch.pdsch_d, nof_symbols); plot_scatter_setNewData(&pscatequal, ue_dl.pdsch.d, nof_symbols);
plot_scatter_setNewData(&pscatequal_pdcch, ue_dl.pdcch.pdcch_d, 36*ue_dl.pdcch.nof_cce); plot_scatter_setNewData(&pscatequal_pdcch, ue_dl.pdcch.d, 36*ue_dl.pdcch.nof_cce);
if (plot_sf_idx == 1) { if (plot_sf_idx == 1) {
if (prog_args.net_port_signal > 0) { if (prog_args.net_port_signal > 0) {
srslte_netsink_write(&net_sink_signal, &sf_buffer[ue_sync_sf_len(&ue_sync)/7], srslte_netsink_write(&net_sink_signal, &sf_buffer[srslte_ue_sync_sf_len(&ue_sync)/7],
ue_sync_sf_len(&ue_sync)); srslte_ue_sync_sf_len(&ue_sync));
} }
} }

@ -105,7 +105,7 @@ void usage(prog_args_t *args, char *prog) {
printf("\t-p PRACH preamble idx [Default %d]\n",args->preamble_idx); printf("\t-p PRACH preamble idx [Default %d]\n",args->preamble_idx);
printf("\t-l Force N_id_2 [Default best]\n"); printf("\t-l Force N_id_2 [Default best]\n");
printf("\t-n nof_subframes [Default %d]\n", args->nof_subframes); printf("\t-n nof_subframes [Default %d]\n", args->nof_subframes);
printf("\t-v [set verbose to debug, default none]\n"); printf("\t-v [set srslte_verbose to debug, default none]\n");
} }
void parse_args(prog_args_t *args, int argc, char **argv) { void parse_args(prog_args_t *args, int argc, char **argv) {
@ -147,7 +147,7 @@ void parse_args(prog_args_t *args, int argc, char **argv) {
args->force_N_id_2 = atoi(argv[optind]); args->force_N_id_2 = atoi(argv[optind]);
break; break;
case 'v': case 'v':
verbose++; srslte_verbose++;
break; break;
default: default:
usage(args, argv[0]); usage(args, argv[0]);
@ -184,10 +184,10 @@ enum receiver_state { DECODE_MIB, SEND_PRACH, RECV_RAR, RECV_CONNSETUP} state;
#define NOF_PRACH_SEQUENCES 52 #define NOF_PRACH_SEQUENCES 52
ue_dl_t ue_dl; srs_ue_dl_t ue_dl;
ue_ul_t ue_ul; srslte_ue_ul_t ue_ul;
ue_sync_t ue_sync; srslte_ue_sync_t ue_sync;
prach_t prach; srslte_prach_t prach;
int prach_buffer_len; int prach_buffer_len;
prog_args_t prog_args; prog_args_t prog_args;
@ -265,20 +265,20 @@ int rar_unpack(uint8_t *buffer, rar_msg_t *msg)
msg->hdr_type = *ptr++; msg->hdr_type = *ptr++;
if(msg->hdr_type == rar_header_type_bi) { if(msg->hdr_type == rar_header_type_bi) {
ptr += 2; ptr += 2;
msg->BI = bit_unpack(&ptr, 4); msg->BI = srslte_bit_unpack(&ptr, 4);
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} else if (msg->hdr_type == rar_header_type_rapid) { } else if (msg->hdr_type == rar_header_type_rapid) {
msg->RAPID = bit_unpack(&ptr, 6); msg->RAPID = srslte_bit_unpack(&ptr, 6);
ptr++; ptr++;
msg->timing_adv_cmd = bit_unpack(&ptr, 11); msg->timing_adv_cmd = srslte_bit_unpack(&ptr, 11);
msg->hopping_flag = *ptr++; msg->hopping_flag = *ptr++;
msg->rba = bit_unpack(&ptr, 10); msg->rba = srslte_bit_unpack(&ptr, 10);
msg->mcs = bit_unpack(&ptr, 4); msg->mcs = srslte_bit_unpack(&ptr, 4);
msg->tpc_command = (rar_tpc_command_t) bit_unpack(&ptr, 3); msg->tpc_command = (rar_tpc_command_t) srslte_bit_unpack(&ptr, 3);
msg->ul_delay = *ptr++; msg->ul_delay = *ptr++;
msg->csi_req = *ptr++; msg->csi_req = *ptr++;
msg->temp_c_rnti = bit_unpack(&ptr, 16); msg->temp_c_rnti = srslte_bit_unpack(&ptr, 16);
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
} }
} }
@ -293,13 +293,13 @@ int main(int argc, char **argv) {
int ret; int ret;
srslte_cell_t cell; srslte_cell_t cell;
int64_t sf_cnt; int64_t sf_cnt;
ue_mib_t ue_mib; srslte_ue_mib_t ue_mib;
void *uhd; void *uhd;
int n; int n;
uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN]; uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN];
uint32_t sfn_offset; uint32_t sfn_offset;
rar_msg_t rar_msg; rar_msg_t rar_msg;
ra_pusch_t ra_pusch; srslte_ra_pusch_t ra_pusch;
uint32_t rar_window_start = 0, rar_trials = 0, rar_window_stop = 0; uint32_t rar_window_start = 0, rar_trials = 0, rar_window_stop = 0;
srslte_timestamp_t uhd_time; srslte_timestamp_t uhd_time;
srslte_timestamp_t next_tx_time; srslte_timestamp_t next_tx_time;
@ -368,33 +368,33 @@ int main(int argc, char **argv) {
#endif #endif
if (ue_mib_init(&ue_mib, cell)) { if (srslte_ue_mib_init(&ue_mib, cell)) {
fprintf(stderr, "Error initaiting UE MIB decoder\n"); fprintf(stderr, "Error initaiting UE MIB decoder\n");
exit(-1); exit(-1);
} }
if (prach_init(&prach, srslte_symbol_sz(cell.nof_prb), 0, 0, false, 1)) { if (srslte_prach_init(&prach, srslte_symbol_sz(cell.nof_prb), 0, 0, false, 1)) {
fprintf(stderr, "Error initializing PRACH\n"); fprintf(stderr, "Error initializing PRACH\n");
exit(-1); exit(-1);
} }
prach_buffer_len = prach.N_seq + prach.N_cp; prach_buffer_len = prach.N_seq + prach.N_cp;
prach_buffer = vec_malloc(prach_buffer_len*sizeof(cf_t)); prach_buffer = srslte_vec_malloc(prach_buffer_len*sizeof(cf_t));
if(!prach_buffer) { if(!prach_buffer) {
perror("maloc"); perror("maloc");
exit(-1); exit(-1);
} }
if(prach_gen(&prach, prog_args.preamble_idx, 0, prog_args.beta_prach, prach_buffer)){ if(srslte_prach_gen(&prach, prog_args.preamble_idx, 0, prog_args.beta_prach, prach_buffer)){
fprintf(stderr, "Error generating prach sequence\n"); fprintf(stderr, "Error generating prach sequence\n");
return -1; return -1;
} }
if (ue_ul_init(&ue_ul, cell)) { if (srslte_ue_ul_init(&ue_ul, cell)) {
fprintf(stderr, "Error initiating UE UL\n"); fprintf(stderr, "Error initiating UE UL\n");
exit(-1); exit(-1);
} }
pusch_hopping_cfg_t hop_cfg; srslte_pusch_hopping_cfg_t hop_cfg;
bzero(&hop_cfg, sizeof(pusch_hopping_cfg_t)); bzero(&hop_cfg, sizeof(srslte_pusch_hopping_cfg_t));
srslte_refsignal_drms_pusch_cfg_t drms_cfg; srslte_refsignal_drms_pusch_cfg_t drms_cfg;
bzero(&drms_cfg, sizeof(srslte_refsignal_drms_pusch_cfg_t)); bzero(&drms_cfg, sizeof(srslte_refsignal_drms_pusch_cfg_t));
drms_cfg.beta_pusch = 1.0; drms_cfg.beta_pusch = 1.0;
@ -404,16 +404,16 @@ int main(int argc, char **argv) {
drms_cfg.cyclic_shift = 0; drms_cfg.cyclic_shift = 0;
drms_cfg.cyclic_shift_for_drms = 0; drms_cfg.cyclic_shift_for_drms = 0;
drms_cfg.en_drms_2 = false; drms_cfg.en_drms_2 = false;
ue_ul_set_pusch_cfg(&ue_ul, &drms_cfg, &hop_cfg); srslte_ue_ul_set_pusch_cfg(&ue_ul, &drms_cfg, &hop_cfg);
cf_t *ul_signal = vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); cf_t *ul_signal = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
if (!ul_signal) { if (!ul_signal) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);
} }
bzero(ul_signal, sizeof(cf_t) * SRSLTE_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 (srs_ue_dl_init(&ue_dl, cell)) {
fprintf(stderr, "Error initiating UE downlink processing module\n"); fprintf(stderr, "Error initiating UE downlink processing module\n");
exit(-1); exit(-1);
} }
@ -423,7 +423,7 @@ int main(int argc, char **argv) {
#ifdef use_usrp #ifdef use_usrp
if (ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper_timed, uhd)) { if (srslte_ue_sync_init(&ue_sync, cell, cuhd_recv_wrapper_timed, uhd)) {
fprintf(stderr, "Error initiating ue_sync\n"); fprintf(stderr, "Error initiating ue_sync\n");
exit(-1); exit(-1);
} }
@ -445,9 +445,9 @@ int main(int argc, char **argv) {
while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) { while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) {
#ifdef kk #ifdef kk
ret = ue_sync_get_buffer(&ue_sync, &sf_buffer); ret = srslte_ue_sync_get_buffer(&ue_sync, &sf_buffer);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error calling ue_sync_work()\n"); fprintf(stderr, "Error calling srslte_ue_sync_work()\n");
} }
#else #else
ret = 1; ret = 1;
@ -455,28 +455,28 @@ int main(int argc, char **argv) {
cf_t dummy[4]; cf_t dummy[4];
#endif #endif
/* ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */ /* srslte_ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */
if (ret == 1) { if (ret == 1) {
if (state != RECV_RAR) { if (state != RECV_RAR) {
/* Run FFT for all subframe data */ /* Run FFT for all subframe data */
srslte_fft_run_sf(&ue_dl.fft, sf_buffer, ue_dl.sf_symbols); srslte_ofdm_tx_sf(&ue_dl.fft, sf_buffer, ue_dl.sf_symbols);
/* Get channel estimates for each port */ /* Get channel estimates for each port */
srslte_chest_dl_estimate(&ue_dl.chest, ue_dl.sf_symbols, ue_dl.ce, ue_sync_get_sfidx(&ue_sync)); srslte_chest_dl_estimate(&ue_dl.chest, ue_dl.sf_symbols, ue_dl.ce, srslte_ue_sync_get_sfidx(&ue_sync));
} }
if (sf_cnt > 1000) { if (sf_cnt > 1000) {
switch (state) { switch (state) {
case DECODE_MIB: case DECODE_MIB:
if (ue_sync_get_sfidx(&ue_sync) == 0) { if (srslte_ue_sync_get_sfidx(&ue_sync) == 0) {
pbch_decode_reset(&ue_mib.pbch); decode_reset(&ue_mib.pbch);
n = ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset); n = srslte_ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error decoding UE MIB\n"); fprintf(stderr, "Error decoding UE MIB\n");
exit(-1); exit(-1);
} else if (n == MIB_FOUND) { } else if (n == SRSLTE_UE_MIB_FOUND) {
bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN); srslte_bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN);
bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn); bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn);
printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset); printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset);
sfn = (sfn + sfn_offset)%1024; sfn = (sfn + sfn_offset)%1024;
@ -487,8 +487,8 @@ int main(int argc, char **argv) {
case SEND_PRACH: case SEND_PRACH:
#ifdef kk #ifdef kk
if (((sfn%2) == 1) && (ue_sync_get_sfidx(&ue_sync) == 1)) { if (((sfn%2) == 1) && (srslte_ue_sync_get_sfidx(&ue_sync) == 1)) {
ue_sync_get_last_timestamp(&ue_sync, &uhd_time); srslte_ue_sync_get_last_timestamp(&ue_sync, &uhd_time);
srslte_timestamp_copy(&next_tx_time, &uhd_time); srslte_timestamp_copy(&next_tx_time, &uhd_time);
srslte_timestamp_add(&next_tx_time, 0, 0.01); // send next frame (10 ms) srslte_timestamp_add(&next_tx_time, 0, 0.01); // send next frame (10 ms)
@ -508,7 +508,7 @@ int main(int argc, char **argv) {
srslte_timestamp_copy(&tx_time, &rx_time); srslte_timestamp_copy(&tx_time, &rx_time);
printf("Transmitting PRACH...\n"); printf("Transmitting PRACH...\n");
vec_save_file("prach_tx", prach_buffers[7], prach_buffer_len*sizeof(cf_t)); srslte_vec_save_file("srslte_prach_tx", prach_buffers[7], prach_buffer_len*sizeof(cf_t));
while(1) { while(1) {
srslte_timestamp_add(&tx_time, 0, 0.001); // send every (10 ms) srslte_timestamp_add(&tx_time, 0, 0.001); // send every (10 ms)
cuhd_send_timed(uhd, prach_buffers[7], prach_buffer_len, cuhd_send_timed(uhd, prach_buffers[7], prach_buffer_len,
@ -520,9 +520,9 @@ int main(int argc, char **argv) {
case RECV_RAR: case RECV_RAR:
#ifdef kk #ifdef kk
if ((sfn == rar_window_start && ue_sync_get_sfidx(&ue_sync) > 3) || sfn > rar_window_start) { if ((sfn == rar_window_start && srslte_ue_sync_get_sfidx(&ue_sync) > 3) || sfn > rar_window_start) {
printf("Looking for RAR in sfn: %d sf_idx: %d\n", sfn, ue_sync_get_sfidx(&ue_sync)); printf("Looking for RAR in sfn: %d sf_idx: %d\n", sfn, srslte_ue_sync_get_sfidx(&ue_sync));
n = ue_dl_decode_rnti(&ue_dl, sf_buffer, data_rx, ue_sync_get_sfidx(&ue_sync), ra_rnti); n = srs_ue_dl_decode_rnti(&ue_dl, sf_buffer, data_rx, srslte_ue_sync_get_sfidx(&ue_sync), ra_rnti);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error decoding UE DL\n");fflush(stdout); fprintf(stderr, "Error decoding UE DL\n");fflush(stdout);
} else if (n > 0) { } else if (n > 0) {
@ -535,14 +535,14 @@ int main(int argc, char **argv) {
//cuhd_flush_buffer(uhd); //cuhd_flush_buffer(uhd);
rar_msg_fprint(stdout, &rar_msg); rar_msg_fprint(stdout, &rar_msg);
dci_rar_to_ra_ul(rar_msg.rba, rar_msg.mcs, rar_msg.hopping_flag, cell.nof_prb, &ra_pusch); srslte_dci_rar_to_ra_ul(rar_msg.rba, rar_msg.mcs, rar_msg.hopping_flag, cell.nof_prb, &ra_pusch);
ra_pusch_fprint(stdout, &ra_pusch, cell.nof_prb); srslte_ra_pusch_fprint(stdout, &ra_pusch, cell.nof_prb);
ra_ul_alloc(&ra_pusch.prb_alloc, &ra_pusch, 0, cell.nof_prb); srslte_ra_ul_alloc(&ra_pusch.prb_alloc, &ra_pusch, 0, cell.nof_prb);
ue_sync_get_last_timestamp(&ue_sync, &uhd_time); srslte_ue_sync_get_last_timestamp(&ue_sync, &uhd_time);
bit_pack_vector((uint8_t*) conn_request_msg, data, ra_pusch.mcs.tbs); srslte_bit_pack_vector((uint8_t*) conn_request_msg, data, ra_pusch.mcs.tbs);
uint32_t n_ta = srssrslte_N_ta_new_rar(rar_msg.timing_adv_cmd); 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);
@ -554,15 +554,15 @@ int main(int argc, char **argv) {
const uint32_t rv[N_TX]={0,2,3,1,0}; const uint32_t rv[N_TX]={0,2,3,1,0};
for (int i=0; i<N_TX;i++) { for (int i=0; i<N_TX;i++) {
ra_pusch.rv_idx = rv[i]; ra_pusch.rv_idx = rv[i];
ul_sf_idx = (ue_sync_get_sfidx(&ue_sync)+6+i*8)%10; ul_sf_idx = (srslte_ue_sync_get_sfidx(&ue_sync)+6+i*8)%10;
n = ue_ul_pusch_encode_rnti(&ue_ul, &ra_pusch, data, ul_sf_idx, rar_msg.temp_c_rnti, ul_signal); n = srslte_ue_ul_srslte_pusch_encode_rnti(&ue_ul, &ra_pusch, data, ul_sf_idx, rar_msg.temp_c_rnti, ul_signal);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error encoding PUSCH\n"); fprintf(stderr, "Error encoding PUSCH\n");
exit(-1); exit(-1);
} }
vec_sc_prod_cfc(ul_signal, prog_args.beta_pusch, ul_signal, SRSLTE_SF_LEN_PRB(cell.nof_prb)); srslte_vec_sc_prod_cfc(ul_signal, prog_args.beta_pusch, ul_signal, SRSLTE_SF_LEN_PRB(cell.nof_prb));
srslte_timestamp_copy(&next_tx_time, &uhd_time); srslte_timestamp_copy(&next_tx_time, &uhd_time);
srslte_timestamp_add(&next_tx_time, 0, 0.006 + i*0.008 - time_adv_sec); // send after 6 sub-frames (6 ms) srslte_timestamp_add(&next_tx_time, 0, 0.006 + i*0.008 - time_adv_sec); // send after 6 sub-frames (6 ms)
@ -593,7 +593,7 @@ int main(int argc, char **argv) {
} }
#else #else
ra_pusch.mcs.mod = LTE_QPSK; ra_pusch.mcs.mod = SRSLTE_MOD_QPSK;
ra_pusch.mcs.tbs = 94; ra_pusch.mcs.tbs = 94;
ra_pusch.rv_idx = 0; ra_pusch.rv_idx = 0;
ra_pusch.prb_alloc.freq_hopping = 0; ra_pusch.prb_alloc.freq_hopping = 0;
@ -603,15 +603,15 @@ int main(int argc, char **argv) {
uint32_t ul_sf_idx = 4; uint32_t ul_sf_idx = 4;
printf("L: %d\n", ra_pusch.prb_alloc.L_prb); printf("L: %d\n", ra_pusch.prb_alloc.L_prb);
// ue_ul_set_cfo(&ue_ul, sync_get_cfo(&ue_sync.strack)); // srslte_ue_ul_set_cfo(&ue_ul, srslte_sync_get_cfo(&ue_sync.strack));
bit_pack_vector((uint8_t*) conn_request_msg, data, ra_pusch.mcs.tbs); srslte_bit_pack_vector((uint8_t*) conn_request_msg, data, ra_pusch.mcs.tbs);
n = ue_ul_pusch_encode_rnti(&ue_ul, &ra_pusch, data, ul_sf_idx, 111, ul_signal); n = srslte_ue_ul_srslte_pusch_encode_rnti(&ue_ul, &ra_pusch, data, ul_sf_idx, 111, ul_signal);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error encoding PUSCH\n"); fprintf(stderr, "Error encoding PUSCH\n");
exit(-1); exit(-1);
} }
vec_save_file("pusch_tx", ul_signal, SRSLTE_SF_LEN_PRB(cell.nof_prb)*sizeof(cf_t)); srslte_vec_save_file("srslte_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);
@ -629,19 +629,19 @@ int main(int argc, char **argv) {
break; break;
case RECV_CONNSETUP: case RECV_CONNSETUP:
if (ue_sync_get_sfidx(&ue_sync) == (ul_sf_idx+4)%10) { if (srslte_ue_sync_get_sfidx(&ue_sync) == (ul_sf_idx+4)%10) {
//verbose=VERBOSE_DEBUG; //srslte_verbose=SRSLTE_VERBOSE_DEBUG;
vec_save_file("connsetup",sf_buffer,SRSLTE_SF_LEN_PRB(cell.nof_prb)*sizeof(cf_t)); srslte_vec_save_file("connsetup",sf_buffer,SRSLTE_SF_LEN_PRB(cell.nof_prb)*sizeof(cf_t));
} else { } else {
//verbose=VERBOSE_NONE; //srslte_verbose=SRSLTE_VERBOSE_NONE;
} }
printf("Looking for ConnectionSetup in sfn: %d sf_idx: %d, RNTI: %d\n", sfn, ue_sync_get_sfidx(&ue_sync),rar_msg.temp_c_rnti); printf("Looking for ConnectionSetup in sfn: %d sf_idx: %d, RNTI: %d\n", sfn, srslte_ue_sync_get_sfidx(&ue_sync),rar_msg.temp_c_rnti);
n = ue_dl_decode_rnti(&ue_dl, sf_buffer, data_rx, ue_sync_get_sfidx(&ue_sync), rar_msg.temp_c_rnti); n = srs_ue_dl_decode_rnti(&ue_dl, sf_buffer, data_rx, srslte_ue_sync_get_sfidx(&ue_sync), rar_msg.temp_c_rnti);
if (n < 0) { if (n < 0) {
fprintf(stderr, "Error decoding UE DL\n");fflush(stdout); fprintf(stderr, "Error decoding UE DL\n");fflush(stdout);
} else if (n > 0) { } else if (n > 0) {
printf("Received ConnectionSetup len: %d.\n", n); printf("Received ConnectionSetup len: %d.\n", n);
vec_fprint_hex(stdout, data_rx, n); srslte_vec_fprint_hex(stdout, data_rx, n);
} else { } else {
conn_setup_trial++; conn_setup_trial++;
if (conn_setup_trial == 20) { if (conn_setup_trial == 20) {
@ -651,7 +651,7 @@ int main(int argc, char **argv) {
break; break;
} }
if (ue_sync_get_sfidx(&ue_sync) == 9) { if (srslte_ue_sync_get_sfidx(&ue_sync) == 9) {
sfn++; sfn++;
if (sfn == 1024) { if (sfn == 1024) {
sfn = 0; sfn = 0;
@ -662,17 +662,17 @@ int main(int argc, char **argv) {
} else if (ret == 0) { } else if (ret == 0) {
printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r", printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r",
sync_get_peak_value(&ue_sync.sfind), srslte_sync_get_peak_value(&ue_sync.sfind),
ue_sync.frame_total_cnt, ue_sync.state); ue_sync.frame_total_cnt, ue_sync.state);
} }
sf_cnt++; sf_cnt++;
} // Main loop } // Main loop
ue_dl_free(&ue_dl); srs_ue_dl_free(&ue_dl);
ue_sync_free(&ue_sync); srslte_ue_sync_free(&ue_sync);
ue_mib_free(&ue_mib); srslte_ue_mib_free(&ue_mib);
cuhd_close(uhd); cuhd_close(uhd);
printf("\nBye\n"); printf("\nBye\n");
exit(0); exit(0);

@ -52,7 +52,7 @@ void usage(char *prog) {
printf("\t-N out_N_id_2 [Default %d]\n", out_N_id_2); printf("\t-N out_N_id_2 [Default %d]\n", out_N_id_2);
printf("\t-f force_N_id_2 [Default %d]\n", force_N_id_2); printf("\t-f force_N_id_2 [Default %d]\n", force_N_id_2);
printf("\t-c force_cfo [Default disabled]\n"); printf("\t-c force_cfo [Default disabled]\n");
printf("\t-v verbose\n"); printf("\t-v srslte_verbose\n");
} }
void parse_args(int argc, char **argv) { void parse_args(int argc, char **argv) {
@ -87,7 +87,7 @@ void parse_args(int argc, char **argv) {
force_cfo = atof(argv[optind]); force_cfo = atof(argv[optind]);
break; break;
case 'v': case 'v':
verbose++; srslte_verbose++;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -103,9 +103,9 @@ void parse_args(int argc, char **argv) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
srslte_filesource_t fsrc; srslte_filesource_t fsrc;
srslte_filesink_t fsink; srslte_filesink_t fsink;
pss_synch_t pss[3]; // One for each N_id_2 srslte_pss_synch_t pss[3]; // One for each N_id_2
sss_synch_t sss[3]; // One for each N_id_2 srslte_sss_synch_t sss[3]; // One for each N_id_2
cfo_t cfocorr; srslte_cfo_t cfocorr;
int peak_pos[3]; int peak_pos[3];
float *cfo; float *cfo;
float peak_value[3]; float peak_value[3];
@ -153,7 +153,7 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
if (cfo_init(&cfocorr, frame_length)) { if (srslte_cfo_init(&cfocorr, frame_length)) {
fprintf(stderr, "Error initiating CFO\n"); fprintf(stderr, "Error initiating CFO\n");
return -1; return -1;
} }
@ -164,19 +164,19 @@ int main(int argc, char **argv) {
* a) requries more memory but has less latency and is paralellizable. * a) requries more memory but has less latency and is paralellizable.
*/ */
for (N_id_2=0;N_id_2<3;N_id_2++) { for (N_id_2=0;N_id_2<3;N_id_2++) {
if (pss_synch_init(&pss[N_id_2], frame_length)) { if (srslte_pss_synch_init(&pss[N_id_2], frame_length)) {
fprintf(stderr, "Error initializing PSS object\n"); fprintf(stderr, "Error initializing PSS object\n");
exit(-1); exit(-1);
} }
if (pss_synch_set_N_id_2(&pss[N_id_2], N_id_2)) { if (srslte_pss_synch_set_N_id_2(&pss[N_id_2], N_id_2)) {
fprintf(stderr, "Error initializing N_id_2\n"); fprintf(stderr, "Error initializing N_id_2\n");
exit(-1); exit(-1);
} }
if (sss_synch_init(&sss[N_id_2], 128)) { if (srslte_sss_synch_init(&sss[N_id_2], 128)) {
fprintf(stderr, "Error initializing SSS object\n"); fprintf(stderr, "Error initializing SSS object\n");
exit(-1); exit(-1);
} }
if (sss_synch_set_N_id_2(&sss[N_id_2], N_id_2)) { if (srslte_sss_synch_set_N_id_2(&sss[N_id_2], N_id_2)) {
fprintf(stderr, "Error initializing N_id_2\n"); fprintf(stderr, "Error initializing N_id_2\n");
exit(-1); exit(-1);
} }
@ -195,15 +195,15 @@ int main(int argc, char **argv) {
gettimeofday(&tdata[1], NULL); gettimeofday(&tdata[1], NULL);
if (force_cfo != CFO_AUTO) { if (force_cfo != CFO_AUTO) {
cfo_correct(&cfocorr, input, input, force_cfo/128); srslte_cfo_correct(&cfocorr, input, input, force_cfo/128);
} }
if (force_N_id_2 != -1) { if (force_N_id_2 != -1) {
N_id_2 = force_N_id_2; N_id_2 = force_N_id_2;
peak_pos[N_id_2] = pss_synch_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]); peak_pos[N_id_2] = srslte_pss_synch_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]);
} else { } else {
for (N_id_2=0;N_id_2<3;N_id_2++) { for (N_id_2=0;N_id_2<3;N_id_2++) {
peak_pos[N_id_2] = pss_synch_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]); peak_pos[N_id_2] = srslte_pss_synch_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]);
} }
float max_value=-99999; float max_value=-99999;
N_id_2=-1; N_id_2=-1;
@ -221,13 +221,13 @@ int main(int argc, char **argv) {
sss_idx = peak_pos[N_id_2]-2*(symbol_sz+SRSLTE_CP(symbol_sz,SRSLTE_SRSLTE_CP_NORM_LEN)); 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], srslte_sss_synch_m0m1_diff(&sss[N_id_2], &input[sss_idx],
&m0, &m0_value, &m1, &m1_value); &m0, &m0_value, &m1, &m1_value);
cfo[frame_cnt] = pss_synch_cfo_compute(&pss[N_id_2], &input[peak_pos[N_id_2]-128]); cfo[frame_cnt] = srslte_pss_synch_cfo_compute(&pss[N_id_2], &input[peak_pos[N_id_2]-128]);
printf("\t%d\t%d\t%d\t%d\t%.3f\t\t%3d\t%d\t%d\t%.3f\n", printf("\t%d\t%d\t%d\t%d\t%.3f\t\t%3d\t%d\t%d\t%.3f\n",
frame_cnt,N_id_2, sss_synch_N_id_1(&sss[N_id_2], m0, m1), frame_cnt,N_id_2, srslte_sss_synch_N_id_1(&sss[N_id_2], m0, m1),
sss_synch_subframe(m0, m1), peak_value[N_id_2], srslte_sss_synch_subframe(m0, m1), peak_value[N_id_2],
peak_pos[N_id_2], m0, m1, peak_pos[N_id_2], m0, m1,
cfo[frame_cnt]); cfo[frame_cnt]);
} }
@ -255,8 +255,8 @@ int main(int argc, char **argv) {
printf("Average CFO: %.3f\n", cfo_mean); printf("Average CFO: %.3f\n", cfo_mean);
for (N_id_2=0;N_id_2<3;N_id_2++) { for (N_id_2=0;N_id_2<3;N_id_2++) {
pss_synch_free(&pss[N_id_2]); srslte_pss_synch_free(&pss[N_id_2]);
sss_synch_free(&sss[N_id_2]); srslte_sss_synch_free(&sss[N_id_2]);
} }
srslte_filesource_free(&fsrc); srslte_filesource_free(&fsrc);

@ -35,7 +35,6 @@
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/resampling/interp.h" #include "srslte/resampling/interp.h"
#include "srslte/filter/filter2d.h"
#include "srslte/ch_estimation/refsignal_dl.h" #include "srslte/ch_estimation/refsignal_dl.h"
#include "srslte/common/phy_common.h" #include "srslte/common/phy_common.h"
@ -68,7 +67,7 @@ typedef struct {
cf_t *tmp_timeavg[SRSLTE_CHEST_MAX_FILTER_TIME_LEN]; cf_t *tmp_timeavg[SRSLTE_CHEST_MAX_FILTER_TIME_LEN];
cf_t *tmp_timeavg_mult; cf_t *tmp_timeavg_mult;
srslte_interp_linvec_t srslte_interp_linvec; srslte_interp_linsrslte_vec_t srslte_interp_linvec;
srslte_interp_lin_t srslte_interp_lin; srslte_interp_lin_t srslte_interp_lin;
float rssi[SRSLTE_MAX_PORTS]; float rssi[SRSLTE_MAX_PORTS];

@ -86,14 +86,14 @@ SRSLTE_API void srslte_refsignal_drms_pusch_put(srslte_refsignal_ul_t *q,
uint32_t n_prb[2], uint32_t n_prb[2],
cf_t *sf_symbols); cf_t *sf_symbols);
SRSLTE_API int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t *q, SRSLTE_API int srslte_refsignal_dmrs_gen(srslte_refsignal_ul_t *q,
srslte_refsignal_drms_pusch_cfg_t *cfg, srslte_refsignal_drms_pusch_cfg_t *cfg,
uint32_t nof_prb, uint32_t nof_prb,
uint32_t sf_idx, uint32_t sf_idx,
cf_t *r_pusch); cf_t *r_pusch);
SRSLTE_API int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, SRSLTE_API int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q,
pucch_cfg_t *cfg, srslte_pucch_cfg_t *cfg,
uint32_t sf_idx, uint32_t sf_idx,
uint32_t n_rb, uint32_t n_rb,
cf_t *r_pucch) ; cf_t *r_pucch) ;

@ -147,11 +147,16 @@ typedef struct SRSLTE_API {
}srslte_cell_t; }srslte_cell_t;
typedef enum SRSLTE_API { typedef enum SRSLTE_API {
SINGLE_ANTENNA,TX_DIVERSITY, SPATIAL_MULTIPLEX SRSLTE_MIMO_TYPE_SINGLE_ANTENNA,
SRSLTE_MIMO_TYPE_TX_DIVERSITY,
SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX
} srslte_mimo_type_t; } srslte_mimo_type_t;
typedef enum SRSLTE_API { typedef enum SRSLTE_API {
LTE_BPSK = 0, LTE_QPSK = 1, LTE_QAM16 = 2, LTE_QAM64 = 3 SRSLTE_MOD_BPSK = 0,
SRSLTE_MOD_QPSK,
SRSLTE_MOD_16QAM,
SRSLTE_MOD_64QAM
} srslte_mod_t; } srslte_mod_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
@ -160,7 +165,13 @@ typedef struct SRSLTE_API {
} srslte_earfcn_t; } srslte_earfcn_t;
enum band_geographical_area { enum band_geographical_area {
ALL, NAR, APAC, EMEA, JAPAN, CALA, NA SRSLTE_BAND_GEO_AREA_ALL,
SRSLTE_BAND_GEO_AREA_NAR,
SRSLTE_BAND_GEO_AREA_APAC,
SRSLTE_BAND_GEO_AREA_EMEA,
SRSLTE_BAND_GEO_AREA_JAPAN,
SRSLTE_BAND_GEO_AREA_CALA,
SRSLTE_BAND_GEO_AREA_NA
}; };
SRSLTE_API bool srslte_cell_isvalid(srslte_cell_t *cell); SRSLTE_API bool srslte_cell_isvalid(srslte_cell_t *cell);

@ -46,12 +46,12 @@
*/ */
typedef enum { typedef enum {
COMPLEX, REAL SRSLTE_DFT_COMPLEX, SRSLTE_REAL
}dft_mode_t; }srslte_dft_mode_t;
typedef enum { typedef enum {
FORWARD, BACKWARD SRSLTE_DFT_FORWARD, SRSLTE_DFT_BACKWARD
}dft_dir_t; }srslte_dft_dir_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
int size; // DFT length int size; // DFT length
@ -63,33 +63,56 @@ typedef struct SRSLTE_API {
bool db; // Provide output in dB? bool db; // Provide output in dB?
bool norm; // Normalize output? bool norm; // Normalize output?
bool dc; // Handle insertion/removal of null DC carrier internally? bool dc; // Handle insertion/removal of null DC carrier internally?
dft_dir_t dir; // Forward/Backward srslte_dft_dir_t dir; // Forward/Backward
dft_mode_t mode; // Complex/Real srslte_dft_mode_t mode; // Complex/Real
}srslte_dft_plan_t; }srslte_dft_plan_t;
typedef _Complex float dft_c_t; typedef _Complex float cf_t;
typedef float dft_r_t;
/* Create DFT plans */ /* Create DFT plans */
SRSLTE_API int dft_plan(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir, SRSLTE_API int srslte_dft_plan(srslte_dft_plan_t *plan,
dft_mode_t type); int dft_points,
SRSLTE_API int dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir); srslte_dft_dir_t dir,
SRSLTE_API int dft_plan_r(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir); srslte_dft_mode_t type);
SRSLTE_API void dft_plan_free(srslte_dft_plan_t *plan);
SRSLTE_API int srslte_dft_plan_c(srslte_dft_plan_t *plan,
int dft_points,
srslte_dft_dir_t dir);
SRSLTE_API int srslte_dft_plan_r(srslte_dft_plan_t *plan,
int dft_points,
srslte_dft_dir_t dir);
SRSLTE_API void srslte_dft_plan_free(srslte_dft_plan_t *plan);
/* Set options */ /* Set options */
SRSLTE_API void dft_plan_set_mirror(srslte_dft_plan_t *plan, bool val); SRSLTE_API void srslte_dft_plan_set_mirror(srslte_dft_plan_t *plan,
SRSLTE_API void dft_plan_set_db(srslte_dft_plan_t *plan, bool val); bool val);
SRSLTE_API void dft_plan_set_norm(srslte_dft_plan_t *plan, bool val);
SRSLTE_API void dft_plan_set_dc(srslte_dft_plan_t *plan, bool val); SRSLTE_API void srslte_dft_plan_set_db(srslte_dft_plan_t *plan,
bool val);
SRSLTE_API void srslte_dft_plan_set_norm(srslte_dft_plan_t *plan,
bool val);
SRSLTE_API void srslte_dft_plan_set_dc(srslte_dft_plan_t *plan,
bool val);
/* Compute DFT */ /* Compute DFT */
SRSLTE_API void dft_run(srslte_dft_plan_t *plan, void *in, void *out); SRSLTE_API void srslte_dft_run(srslte_dft_plan_t *plan,
SRSLTE_API void dft_run_c(srslte_dft_plan_t *plan, dft_c_t *in, dft_c_t *out); void *in,
SRSLTE_API void dft_run_r(srslte_dft_plan_t *plan, dft_r_t *in, dft_r_t *out); void *out);
SRSLTE_API void srslte_dft_run_c(srslte_dft_plan_t *plan,
cf_t *in,
cf_t *out);
SRSLTE_API void srslte_dft_run_r(srslte_dft_plan_t *plan,
float *in,
float *out);
#endif // DFT_H_ #endif // DFT_H_

@ -31,7 +31,7 @@
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/common/phy_common.h" #include "srslte/common/phy_common.h"
#include "srslte/utils/dft.h" #include "srslte/dft/dft.h"
typedef _Complex float cf_t; typedef _Complex float cf_t;
@ -42,22 +42,22 @@ typedef struct SRSLTE_API {
srslte_dft_plan_t dft_plan[SRSLTE_MAX_PRB]; srslte_dft_plan_t dft_plan[SRSLTE_MAX_PRB];
srslte_dft_plan_t idft_plan[SRSLTE_MAX_PRB]; srslte_dft_plan_t idft_plan[SRSLTE_MAX_PRB];
}srslte_srslte_dft_precoding_t; }srslte_dft_precoding_t;
SRSLTE_API int srslte_srslte_dft_precoding_init(srslte_srslte_dft_precoding_t *q, SRSLTE_API int srslte_dft_precoding_init(srslte_dft_precoding_t *q,
uint32_t max_prb); uint32_t max_prb);
SRSLTE_API void srslte_srslte_dft_precoding_free(srslte_srslte_dft_precoding_t *q); SRSLTE_API void srslte_dft_precoding_free(srslte_dft_precoding_t *q);
SRSLTE_API bool srslte_srslte_dft_precoding_valid_prb(uint32_t nof_prb); SRSLTE_API bool srslte_dft_precoding_valid_prb(uint32_t nof_prb);
SRSLTE_API int srslte_dft_precoding(srslte_srslte_dft_precoding_t *q, SRSLTE_API int srslte_dft_precoding(srslte_dft_precoding_t *q,
cf_t *input, cf_t *input,
cf_t *output, cf_t *output,
uint32_t nof_prb, uint32_t nof_prb,
uint32_t nof_symbols); uint32_t nof_symbols);
SRSLTE_API int srslte_dft_predecoding(srslte_srslte_dft_precoding_t *q, SRSLTE_API int srslte_dft_predecoding(srslte_dft_precoding_t *q,
cf_t *input, cf_t *input,
cf_t *output, cf_t *output,
uint32_t nof_prb, uint32_t nof_prb,

@ -35,7 +35,7 @@
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/common/phy_common.h" #include "srslte/common/phy_common.h"
#include "srslte/utils/dft.h" #include "srslte/dft/dft.h"
typedef _Complex float cf_t; /* this is only a shortcut */ typedef _Complex float cf_t; /* this is only a shortcut */
@ -52,40 +52,42 @@ typedef struct SRSLTE_API{
bool freq_shift; bool freq_shift;
cf_t *shift_buffer; cf_t *shift_buffer;
}srslte_fft_t; }srslte_ofdm_t;
SRSLTE_API int srslte_fft_init(srslte_fft_t *q, SRSLTE_API int srslte_ofdm_tx_init(srslte_ofdm_t *q,
srslte_cp_t cp_type, srslte_cp_t cp_type,
uint32_t nof_prb); uint32_t nof_prb);
SRSLTE_API void srslte_fft_free(srslte_fft_t *q); SRSLTE_API void srslte_ofdm_tx_free(srslte_ofdm_t *q);
SRSLTE_API void srslte_fft_run_slot(srslte_fft_t *q, SRSLTE_API void srslte_ofdm_tx_slot(srslte_ofdm_t *q,
cf_t *input, cf_t *input,
cf_t *output); cf_t *output);
SRSLTE_API void srslte_fft_run_sf(srslte_fft_t *q, SRSLTE_API void srslte_ofdm_tx_sf(srslte_ofdm_t *q,
cf_t *input, cf_t *input,
cf_t *output); cf_t *output);
SRSLTE_API int lte_ifft_init(srslte_fft_t *q,
srslte_cp_t cp_type,
uint32_t nof_prb);
SRSLTE_API void lte_ifft_free(srslte_fft_t *q);
SRSLTE_API void lte_ifft_run_slot(srslte_fft_t *q, SRSLTE_API int srslte_ofdm_rx_init(srslte_ofdm_t *q,
srslte_cp_t cp_type,
uint32_t nof_prb);
SRSLTE_API void srslte_ofdm_rx_free(srslte_ofdm_t *q);
SRSLTE_API void srslte_ofdm_rx_slot(srslte_ofdm_t *q,
cf_t *input, cf_t *input,
cf_t *output); cf_t *output);
SRSLTE_API void lte_ifft_run_sf(srslte_fft_t *q, SRSLTE_API void srslte_ofdm_rx_sf(srslte_ofdm_t *q,
cf_t *input, cf_t *input,
cf_t *output); cf_t *output);
SRSLTE_API int srslte_fft_set_freq_shift(srslte_fft_t *q, SRSLTE_API int srslte_ofdm_set_freq_shift(srslte_ofdm_t *q,
float freq_shift); float freq_shift);
SRSLTE_API void srslte_fft_set_normalize(srslte_fft_t *q, SRSLTE_API void srslte_ofdm_set_normalize(srslte_ofdm_t *q,
bool normalize_enable); bool normalize_enable);
#endif #endif

@ -1,80 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The srsLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef FILTER2D_
#define FILTER2D_
#include "srslte/config.h"
#include <stdint.h>
/* 2-D real filter of complex input
*
*/
typedef _Complex float cf_t;
typedef struct SRSLTE_API{
uint32_t sztime; // Output signal size in the time domain
uint32_t szfreq; // Output signal size in the freq domain
uint32_t ntime; // 2-D Filter size in time domain
uint32_t nfreq; // 2-D Filter size in frequency domain
float **taps; // 2-D filter coefficients
float norm; //normalization factor
cf_t *output; // Output signal
} srslte_filter2d_t;
SRSLTE_API int srslte_filter2d_init (srslte_filter2d_t* q,
float **taps,
uint32_t ntime,
uint32_t nfreq,
uint32_t sztime,
uint32_t szfreq);
SRSLTE_API int srslte_filter2d_init_ones (srslte_filter2d_t* q,
uint32_t ntime,
uint32_t nfreq,
uint32_t sztime,
uint32_t szfreq);
SRSLTE_API void srslte_filter2d_free(srslte_filter2d_t *q);
SRSLTE_API void srslte_filter2d_step(srslte_filter2d_t *q);
SRSLTE_API void srslte_filter2d_reset(srslte_filter2d_t *q);
SRSLTE_API void srslte_filter2d_add(srslte_filter2d_t *q,
cf_t h,
uint32_t time_idx,
uint32_t freq_idx);
SRSLTE_API void srslte_filter2d_add_out(srslte_filter2d_t *q, cf_t x, int time_idx, int freq_idx);
SRSLTE_API void srslte_filter2d_get_symbol(srslte_filter2d_t *q,
uint32_t nsymbol,
cf_t *output);
#endif // FILTER2D_

@ -29,6 +29,7 @@
#define PRECODING_H_ #define PRECODING_H_
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/common/phy_common.h"
typedef _Complex float cf_t; typedef _Complex float cf_t;
@ -47,59 +48,59 @@ typedef struct {
float *z_real; float *z_real;
float *z_imag; float *z_imag;
uint32_t max_frame_len; uint32_t max_frame_len;
}precoding_t; } srslte_precoding_t;
SRSLTE_API int precoding_init(precoding_t *q, SRSLTE_API int srslte_precoding_init(srslte_precoding_t *q,
uint32_t max_frame_len); uint32_t max_frame_len);
SRSLTE_API void precoding_free(precoding_t *q); SRSLTE_API void srslte_precoding_free(srslte_precoding_t *q);
/* Generates the vector "y" from the input vector "x" /* Generates the vector "y" from the input vector "x"
*/ */
SRSLTE_API int precoding_single(precoding_t *q, SRSLTE_API int srslte_precoding_single(srslte_precoding_t *q,
cf_t *x, cf_t *x,
cf_t *y, cf_t *y,
int nof_symbols); int nof_symbols);
SRSLTE_API int precoding_diversity(precoding_t *q,
cf_t *x[SRSLTE_MAX_LAYERS],
cf_t *y[SRSLTE_MAX_PORTS],
int nof_ports, int nof_symbols);
SRSLTE_API int precoding_type(precoding_t *q,
cf_t *x[SRSLTE_MAX_LAYERS],
cf_t *y[SRSLTE_MAX_PORTS],
int nof_layers,
int nof_ports,
int nof_symbols,
srslte_mimo_type_t type);
/* Estimates the vector "x" based on the received signal "y" and the channel estimates "h" SRSLTE_API int srslte_precoding_diversity(srslte_precoding_t *q,
*/ cf_t *x[SRSLTE_MAX_LAYERS],
SRSLTE_API int predecoding_single(precoding_t *q, cf_t *y[SRSLTE_MAX_PORTS],
cf_t *y, int nof_ports, int nof_symbols);
cf_t *h,
cf_t *x, SRSLTE_API int srslte_precoding_type(srslte_precoding_t *q,
int nof_symbols,
float noise_estimate);
SRSLTE_API int predecoding_diversity(precoding_t *q,
cf_t *y,
cf_t *h[SRSLTE_MAX_PORTS],
cf_t *x[SRSLTE_MAX_LAYERS], cf_t *x[SRSLTE_MAX_LAYERS],
cf_t *y[SRSLTE_MAX_PORTS],
int nof_layers,
int nof_ports, int nof_ports,
int nof_symbols, int nof_symbols,
float noise_estimate); srslte_mimo_type_t type);
SRSLTE_API int predecoding_type(precoding_t *q, /* Estimates the vector "x" based on the received signal "y" and the channel estimates "h"
cf_t *y, */
cf_t *h[SRSLTE_MAX_PORTS], SRSLTE_API int srslte_predecoding_single(srslte_precoding_t *q,
cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y,
int nof_ports, cf_t *h,
int nof_layers, cf_t *x,
int nof_symbols, int nof_symbols,
srslte_mimo_type_t type, float noise_estimate);
float noise_estimate);
SRSLTE_API int srslte_predecoding_diversity(srslte_precoding_t *q,
cf_t *y,
cf_t *h[SRSLTE_MAX_PORTS],
cf_t *x[SRSLTE_MAX_LAYERS],
int nof_ports,
int nof_symbols,
float noise_estimate);
SRSLTE_API int srslte_predecoding_type(srslte_precoding_t *q,
cf_t *y,
cf_t *h[SRSLTE_MAX_PORTS],
cf_t *x[SRSLTE_MAX_LAYERS],
int nof_ports,
int nof_layers,
int nof_symbols,
srslte_mimo_type_t type,
float noise_estimate);
#endif /* PRECODING_H_ */ #endif /* PRECODING_H_ */

@ -39,19 +39,23 @@ typedef _Complex float cf_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_mod_t mod; /* In this implementation, mapping table is hard-coded */ srslte_mod_t mod; /* In this implementation, mapping table is hard-coded */
}demod_hard_t; }srslte_demod_hard_t;
SRSLTE_API void demod_hard_init(demod_hard_t* q); SRSLTE_API void srslte_demod_hard_init(srslte_demod_hard_t* q);
SRSLTE_API void demod_hard_table_set(demod_hard_t* q, srslte_mod_t mod);
SRSLTE_API int demod_hard_demodulate(demod_hard_t* q, cf_t* symbols, uint8_t *bits, uint32_t nsymbols);
SRSLTE_API void srslte_demod_hard_table_set(srslte_demod_hard_t* q,
srslte_mod_t mod);
SRSLTE_API int srslte_demod_hard_demodulate(srslte_demod_hard_t* q,
cf_t* symbols,
uint8_t *bits,
uint32_t nsymbols);
/* High-level API */ /* High-level API */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
demod_hard_t obj; srslte_demod_hard_t obj;
struct demod_hard_init { struct srslte_demod_hard_init {
srslte_mod_t std; // Symbol mapping standard (see modem_table.h) srslte_mod_t std; // Symbol mapping standard (see modem_table.h)
} init; } init;
@ -60,11 +64,11 @@ typedef struct SRSLTE_API {
uint8_t* output; uint8_t* output;
int out_len; int out_len;
}demod_hard_hl; }srslte_demod_hard_hl;
SRSLTE_API int demod_hard_initialize(demod_hard_hl* hl); SRSLTE_API int srslte_demod_hard_initialize(srslte_demod_hard_hl* hl);
SRSLTE_API int demod_hard_work(demod_hard_hl* hl); SRSLTE_API int srslte_demod_hard_work(srslte_demod_hard_hl* hl);
SRSLTE_API int demod_hard_stop(demod_hard_hl* hl); SRSLTE_API int srslte_demod_hard_stop(srslte_demod_hard_hl* hl);
#endif // DEMOD_HARD_ #endif // DEMOD_HARD_

@ -35,50 +35,65 @@
#include "srslte/config.h" #include "srslte/config.h"
#include "modem_table.h" #include "modem_table.h"
enum alg { EXACT, APPROX }; typedef enum SRSLTE_API {
SRSLTE_DEMOD_SOFT_ALG_EXACT,
SRSLTE_DEMOD_SOFT_ALG_APPROX
} srslte_demod_soft_alg_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
float sigma; // noise power float sigma; // noise power
enum alg alg_type; // soft demapping algorithm (EXACT or APPROX) srslte_demod_soft_alg_t alg_type; // soft demapping algorithm (SRSLTE_DEMOD_SOFT_ALG_EXACT or SRSLTE_DEMOD_SOFT_ALG_APPROX)
modem_table_t *table; // symbol mapping table (see modem_table.h) srslte_srslte_modem_table_t *table; // symbol mapping table (see modem_table.h)
uint32_t *zones; uint32_t *zones;
float *dd; float *dd;
uint32_t max_symbols; uint32_t max_symbols;
}demod_soft_t; } srslte_demod_soft_t;
SRSLTE_API int demod_soft_init(demod_soft_t *q, uint32_t max_symbols); SRSLTE_API int srslte_demod_soft_init(srslte_demod_soft_t *q,
SRSLTE_API void demod_soft_free(demod_soft_t *q); uint32_t max_symbols);
SRSLTE_API void demod_soft_table_set(demod_soft_t *q, modem_table_t *table);
SRSLTE_API void demod_soft_alg_set(demod_soft_t *q, enum alg alg_type); SRSLTE_API void srslte_demod_soft_free(srslte_demod_soft_t *q);
SRSLTE_API void demod_soft_sigma_set(demod_soft_t *q, float sigma);
SRSLTE_API int demod_soft_demodulate(demod_soft_t *q, const cf_t* symbols, float* llr, int nsymbols); SRSLTE_API void srslte_demod_soft_table_set(srslte_demod_soft_t *q,
srslte_srslte_modem_table_t *table);
SRSLTE_API void srslte_demod_soft_alg_set(srslte_demod_soft_t *q,
srslte_demod_soft_alg_t alg_type);
SRSLTE_API void srslte_demod_soft_sigma_set(srslte_demod_soft_t *q,
float sigma);
SRSLTE_API int srslte_demod_soft_demodulate(srslte_demod_soft_t *q,
const cf_t* symbols,
float* llr,
int nsymbols);
/* High-level API */ /* High-level API */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
demod_soft_t obj; srslte_demod_soft_t obj;
modem_table_t table; srslte_srslte_modem_table_t table;
struct demod_soft_init{ struct srslte_demod_soft_init{
srslte_mod_t std; // symbol mapping standard (see modem_table.h) srslte_mod_t std; // symbol mapping standard (see modem_table.h)
} init; } init;
const cf_t* input; const cf_t* input;
int in_len; int in_len;
struct demod_soft_ctrl_in { struct srslte_demod_soft_ctrl_in {
float sigma; // Estimated noise variance float sigma; // Estimated noise variance
enum alg alg_type; // soft demapping algorithm (EXACT or APPROX) srslte_demod_soft_alg_t alg_type; // soft demapping algorithm (SRSLTE_DEMOD_SOFT_ALG_EXACT or SRSLTE_DEMOD_SOFT_ALG_APPROX)
}ctrl_in; }ctrl_in;
float* output; float* output;
int out_len; int out_len;
}demod_soft_hl; }srslte_demod_soft_hl;
SRSLTE_API int demod_soft_initialize(demod_soft_hl* hl); SRSLTE_API int srslte_demod_soft_initialize(srslte_demod_soft_hl* hl);
SRSLTE_API int demod_soft_work(demod_soft_hl* hl); SRSLTE_API int srslte_demod_soft_work(srslte_demod_soft_hl* hl);
SRSLTE_API int demod_soft_stop(demod_soft_hl* hl); SRSLTE_API int srslte_demod_soft_stop(srslte_demod_soft_hl* hl);
#endif // DEMOD_SOFT_ #endif // DEMOD_SOFT_

@ -37,24 +37,27 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
SRSLTE_API int mod_modulate(modem_table_t* table, const uint8_t *bits, cf_t* symbols, uint32_t nbits); SRSLTE_API int srslte_mod_modulate(srslte_srslte_modem_table_t* table,
uint8_t *bits,
cf_t* symbols,
uint32_t nbits);
/* High-level API */ /* High-level API */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
modem_table_t obj; srslte_srslte_modem_table_t obj;
struct mod_init { struct mod_init {
srslte_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; uint8_t* input;
int in_len; int in_len;
cf_t* output; cf_t* output;
int out_len; int out_len;
}mod_hl; }srslte_mod_hl;
SRSLTE_API int mod_initialize(mod_hl* hl); SRSLTE_API int mod_initialize(srslte_mod_hl* hl);
SRSLTE_API int mod_work(mod_hl* hl); SRSLTE_API int mod_work(srslte_mod_hl* hl);
SRSLTE_API int mod_stop(mod_hl* hl); SRSLTE_API int mod_stop(srslte_mod_hl* hl);
#endif // MOD_ #endif // MOD_

@ -43,30 +43,30 @@ typedef struct SRSLTE_API {
uint32_t min_idx[2][64][6]; /* NEW: for each constellation point zone (2, 4, 16, 64 for BPSK, QPSK, 16QAM, 64QAM) the 2x(1, 2, 4, and 6 closest constellation points) for each bit, respectively. */ uint32_t min_idx[2][64][6]; /* NEW: for each constellation point zone (2, 4, 16, 64 for BPSK, QPSK, 16QAM, 64QAM) the 2x(1, 2, 4, and 6 closest constellation points) for each bit, respectively. */
uint32_t d_idx[64][7]; /* NEW: for each constellation point zone (2, 4, 16, 64 for BPSK, QPSK, 16QAM, 64QAM) the 2, 3, 5 and 7 indices to constellation points that need to be computed for any recevied symbol modulated as BPSK, QPSK, 16QAM, and 64QAM, respectively. */ uint32_t d_idx[64][7]; /* NEW: for each constellation point zone (2, 4, 16, 64 for BPSK, QPSK, 16QAM, 64QAM) the 2, 3, 5 and 7 indices to constellation points that need to be computed for any recevied symbol modulated as BPSK, QPSK, 16QAM, and 64QAM, respectively. */
}soft_table_t; }srslte_soft_table_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
cf_t* symbol_table; // bit-to-symbol mapping cf_t* symbol_table; // bit-to-symbol mapping
soft_table_t soft_table; // symbol-to-bit mapping (used in soft demodulating) srslte_soft_table_t soft_table; // symbol-to-bit mapping (used in soft demodulating)
uint32_t nsymbols; // number of modulation symbols uint32_t nsymbols; // number of modulation symbols
uint32_t nbits_x_symbol; // number of bits per symbol uint32_t nbits_x_symbol; // number of bits per symbol
}modem_table_t; }srslte_srslte_modem_table_t;
SRSLTE_API void modem_table_init(modem_table_t* q); SRSLTE_API void srslte_modem_table_init(srslte_srslte_modem_table_t* q);
SRSLTE_API void modem_table_free(modem_table_t* q); SRSLTE_API void srslte_modem_table_free(srslte_srslte_modem_table_t* q);
SRSLTE_API void modem_table_reset(modem_table_t* q); SRSLTE_API void srslte_modem_table_reset(srslte_srslte_modem_table_t* q);
SRSLTE_API int modem_table_set(modem_table_t* q, SRSLTE_API int srslte_modem_table_set(srslte_srslte_modem_table_t* q,
cf_t* table, cf_t* table,
soft_table_t *soft_table, srslte_soft_table_t *soft_table,
uint32_t nsymbols, uint32_t nsymbols,
uint32_t nbits_x_symbol); uint32_t nbits_x_symbol);
SRSLTE_API int modem_table_lte(modem_table_t* q, SRSLTE_API int srslte_modem_table_lte(srslte_srslte_modem_table_t* q,
srslte_mod_t modulation, srslte_mod_t modulation,
bool compute_soft_demod); bool compute_soft_demod);
#endif // MODEM_TABLE_ #endif // MODEM_TABLE_

@ -46,7 +46,7 @@ transmission mode 8 configured without PMI/RI reporting). */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint8_t wideband_cqi; // 4-bit width uint8_t wideband_cqi; // 4-bit width
uint32_t subband_diff_cqi; // 2N-bit width uint32_t subband_diff_cqi; // 2N-bit width
} cqi_hl_subband_t; } srslte_cqi_hl_subband_t;
/* Table 5.2.2.6.3-1: Fields for channel quality information feedback for UE selected subband CQI /* Table 5.2.2.6.3-1: Fields for channel quality information feedback for UE selected subband CQI
reports reports
@ -56,7 +56,7 @@ typedef struct SRSLTE_API {
uint8_t wideband_cqi; // 4-bit width uint8_t wideband_cqi; // 4-bit width
uint8_t subband_diff_cqi; // 2-bit width uint8_t subband_diff_cqi; // 2-bit width
uint32_t position_subband; // L-bit width uint32_t position_subband; // L-bit width
} cqi_ue_subband_t; } srslte_cqi_ue_subband_t;
/* Table 5.2.3.3.1-1: Fields for channel quality information feedback for wideband CQI reports /* Table 5.2.3.3.1-1: Fields for channel quality information feedback for wideband CQI reports
(transmission mode 1, transmission mode 2, transmission mode 3, transmission mode 7 and (transmission mode 1, transmission mode 2, transmission mode 3, transmission mode 7 and
@ -65,29 +65,29 @@ This is for PUCCH Format 2 reports
*/ */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint8_t wideband_cqi; // 4-bit width uint8_t wideband_cqi; // 4-bit width
} cqi_format2_wideband_t; } srslte_cqi_format2_wideband_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint8_t subband_cqi; // 4-bit width uint8_t subband_cqi; // 4-bit width
uint8_t subband_label; // 1- or 2-bit width uint8_t subband_label; // 1- or 2-bit width
} cqi_format2_subband_t; } srslte_cqi_format2_subband_t;
SRSLTE_API int cqi_hl_subband_pack(cqi_hl_subband_t *msg, SRSLTE_API int srslte_cqi_hl_subband_pack(srslte_cqi_hl_subband_t *msg,
uint32_t N, uint32_t N,
uint8_t *buff, uint8_t *buff,
uint32_t buff_len); uint32_t buff_len);
SRSLTE_API int cqi_ue_subband_pack(cqi_ue_subband_t *msg, SRSLTE_API int srslte_cqi_ue_subband_pack(srslte_cqi_ue_subband_t *msg,
uint32_t L, uint32_t L,
uint8_t *buff, uint8_t *buff,
uint32_t buff_len); uint32_t buff_len);
SRSLTE_API int cqi_format2_wideband_pack(cqi_format2_wideband_t *msg, SRSLTE_API int srslte_cqi_format2_wideband_pack(srslte_cqi_format2_wideband_t *msg,
uint8_t *buff, uint8_t *buff,
uint32_t buff_len); uint32_t buff_len);
SRSLTE_API int cqi_format2_subband_pack(cqi_format2_subband_t *msg, SRSLTE_API int srslte_cqi_format2_subband_pack(srslte_cqi_format2_subband_t *msg,
uint8_t *buff, uint8_t *buff,
uint32_t buff_len); uint32_t buff_len);

@ -46,91 +46,100 @@ typedef _Complex float cf_t;
#define DCI_MAX_BITS 57 #define DCI_MAX_BITS 57
typedef enum { typedef enum {
Format0, Format1, Format1A, Format1C, FormatError SRSLTE_DCI_FORMAT0,
} dci_format_t; SRSLTE_DCI_FORMAT1,
SRSLTE_DCI_FORMAT1A,
SRSLTE_DCI_FORMAT1C,
SRSLTE_DCI_FORMAT_ERROR
} srslte_dci_format_t;
// Each type is for a different interface to packing/unpacking functions // Each type is for a different interface to packing/unpacking functions
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
enum { enum {
PUSCH_SCHED, PDSCH_SCHED, MCCH_CHANGE, TPC_COMMAND, RA_PROC_PDCCH SRSLTE_DCI_MSG_TYPE_PUSCH_SCHED,
SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED,
SRSLTE_DCI_MSG_TYPE_MCCH_CHANGE,
SRSLTE_DCI_MSG_TYPE_TPC_COMMAND,
SRSLTE_DCI_MSG_TYPE_RA_PROC_PDCCH
} type; } type;
dci_format_t format; srslte_dci_format_t format;
}dci_msg_type_t; }srslte_dci_msg_type_t;
typedef enum { typedef enum {
DCI_COMMON = 0, DCI_UE = 1 SRSLTE_DCI_SPEC_COMMON_ = 0,
SRSLTE_DCI_SPEC_UE = 1
} dci_spec_t; } dci_spec_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint32_t L; // Aggregation level uint32_t L; // Aggregation level
uint32_t ncce; // Position of first CCE of the dci uint32_t ncce; // Position of first CCE of the dci
} dci_location_t; } srslte_dci_location_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint8_t data[DCI_MAX_BITS]; uint8_t data[DCI_MAX_BITS];
uint32_t nof_bits; uint32_t nof_bits;
} dci_msg_t; } srslte_dci_msg_t;
/* Converts a received PDSCH DL scheduling DCI message /* Converts a received PDSCH DL scheduling DCI message
* to ra structures ready to be passed to the harq setup function * to ra structures ready to be passed to the harq setup function
*/ */
SRSLTE_API int dci_msg_to_ra_dl(dci_msg_t *msg, SRSLTE_API int srslte_dci_msg_to_ra_dl(srslte_dci_msg_t *msg,
uint16_t msg_rnti, uint16_t msg_rnti,
srslte_cell_t cell, srslte_cell_t cell,
uint32_t cfi, uint32_t cfi,
ra_pdsch_t *ra_dl); srslte_ra_pdsch_t *ra_dl);
SRSLTE_API int dci_msg_to_ra_ul(dci_msg_t *msg, SRSLTE_API int srslte_dci_msg_to_ra_ul(srslte_dci_msg_t *msg,
uint32_t nof_prb, uint32_t nof_prb,
uint32_t n_rb_ho, uint32_t n_rb_ho,
ra_pusch_t *ra_ul); srslte_ra_pusch_t *ra_ul);
SRSLTE_API int dci_rar_to_ra_ul(uint32_t rba, SRSLTE_API int srslte_dci_rar_to_ra_ul(uint32_t rba,
uint32_t trunc_mcs, uint32_t trunc_mcs,
bool hopping_flag, bool hopping_flag,
uint32_t nof_prb, uint32_t nof_prb,
ra_pusch_t *ra); srslte_ra_pusch_t *ra);
SRSLTE_API dci_format_t dci_format_from_string(char *str); SRSLTE_API srslte_dci_format_t srslte_dci_format_from_string(char *str);
SRSLTE_API char* dci_format_string(dci_format_t format); SRSLTE_API char* srslte_dci_format_string(srslte_dci_format_t format);
SRSLTE_API int dci_location_set(dci_location_t *c, SRSLTE_API int srslte_dci_location_set(srslte_dci_location_t *c,
uint32_t L, uint32_t L,
uint32_t nCCE); uint32_t nCCE);
SRSLTE_API bool dci_location_isvalid(dci_location_t *c); SRSLTE_API bool srslte_dci_location_isvalid(srslte_dci_location_t *c);
SRSLTE_API int dci_msg_get_type(dci_msg_t *msg, SRSLTE_API int srslte_dci_msg_get_type(srslte_dci_msg_t *msg,
dci_msg_type_t *type, srslte_dci_msg_type_t *type,
uint32_t nof_prb, uint32_t nof_prb,
uint16_t msg_rnti); uint16_t msg_rnti);
SRSLTE_API void dci_msg_type_fprint(FILE *f, SRSLTE_API void srslte_dci_msg_type_fprint(FILE *f,
dci_msg_type_t type); srslte_dci_msg_type_t type);
// For dci_msg_type_t = PUSCH_SCHED // For srslte_dci_msg_type_t = SRSLTE_DCI_MSG_TYPE_PUSCH_SCHED
SRSLTE_API int dci_msg_pack_pusch(ra_pusch_t *data, SRSLTE_API int srslte_dci_msg_pack_pusch(srslte_ra_pusch_t *data,
dci_msg_t *msg, srslte_dci_msg_t *msg,
uint32_t nof_prb); uint32_t nof_prb);
SRSLTE_API int dci_msg_unpack_pusch(dci_msg_t *msg, SRSLTE_API int srslte_dci_msg_unpack_pusch(srslte_dci_msg_t *msg,
ra_pusch_t *data, srslte_ra_pusch_t *data,
uint32_t nof_prb); uint32_t nof_prb);
// For dci_msg_type_t = PDSCH_SCHED // For srslte_dci_msg_type_t = SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED
SRSLTE_API int dci_msg_pack_pdsch(ra_pdsch_t *data, SRSLTE_API int srslte_dci_msg_pack_pdsch(srslte_ra_pdsch_t *data,
dci_msg_t *msg, srslte_dci_msg_t *msg,
dci_format_t format, srslte_dci_format_t format,
uint32_t nof_prb, uint32_t nof_prb,
bool srslte_crc_is_crnti); bool srslte_crc_is_crnti);
SRSLTE_API int dci_msg_unpack_pdsch(dci_msg_t *msg, SRSLTE_API int srslte_dci_msg_unpack_pdsch(srslte_dci_msg_t *msg,
ra_pdsch_t *data, srslte_ra_pdsch_t *data,
uint32_t nof_prb, uint32_t nof_prb,
bool srslte_crc_is_crnti); bool srslte_crc_is_crnti);
SRSLTE_API uint32_t dci_format_sizeof(dci_format_t format, SRSLTE_API uint32_t srslte_dci_format_sizeof(srslte_dci_format_t format,
uint32_t nof_prb); uint32_t nof_prb);
#endif // DCI_ #endif // DCI_

@ -34,21 +34,21 @@
#include "srslte/phch/ra.h" #include "srslte/phch/ra.h"
struct cb_segm { typedef struct SRSLTE_API {
uint32_t F; uint32_t F;
uint32_t C; uint32_t C;
uint32_t K1; uint32_t K1;
uint32_t K2; uint32_t K2;
uint32_t C1; uint32_t C1;
uint32_t C2; uint32_t C2;
}; } srslte_harq_cbsegm_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
ra_mcs_t mcs; srslte_ra_mcs_t mcs;
uint32_t rv; uint32_t rv;
uint32_t sf_idx; uint32_t sf_idx;
ra_dl_alloc_t dl_alloc; srslte_srslte_ra_dl_alloc_t dl_alloc;
ra_ul_alloc_t ul_alloc; srslte_srslte_ra_ul_alloc_t ul_alloc;
srslte_cell_t cell; srslte_cell_t cell;
uint32_t nof_re; // Number of RE per subframe uint32_t nof_re; // Number of RE per subframe
@ -61,31 +61,31 @@ typedef struct SRSLTE_API {
float **pdsch_w_buff_f; float **pdsch_w_buff_f;
uint8_t **pdsch_w_buff_c; uint8_t **pdsch_w_buff_c;
struct cb_segm cb_segm; srslte_harq_cbsegm_t cb_segm;
} harq_t; } srslte_harq_t;
SRSLTE_API int harq_init(harq_t * q, SRSLTE_API int srslte_harq_init(srslte_harq_t * q,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API int harq_setup_dl(harq_t *p, SRSLTE_API int srslte_harq_setup_dl(srslte_harq_t *p,
ra_mcs_t mcs, srslte_ra_mcs_t mcs,
uint32_t rv, uint32_t rv,
uint32_t sf_idx, uint32_t sf_idx,
ra_dl_alloc_t *prb_alloc); srslte_srslte_ra_dl_alloc_t *prb_alloc);
SRSLTE_API int harq_setup_ul(harq_t *p, SRSLTE_API int srslte_harq_setup_ul(srslte_harq_t *p,
ra_mcs_t mcs, srslte_ra_mcs_t mcs,
uint32_t rv, uint32_t rv,
uint32_t sf_idx, uint32_t sf_idx,
ra_ul_alloc_t *prb_alloc); srslte_srslte_ra_ul_alloc_t *prb_alloc);
SRSLTE_API void harq_reset(harq_t *p); SRSLTE_API void srslte_harq_reset(srslte_harq_t *p);
SRSLTE_API void harq_free(harq_t *p); SRSLTE_API void srslte_harq_free(srslte_harq_t *p);
SRSLTE_API int codeblock_segmentation(struct cb_segm *s, SRSLTE_API int srslte_harq_codeblock_segmentation(srslte_harq_cbsegm_t *s,
uint32_t tbs); uint32_t tbs);
#endif #endif

@ -58,34 +58,34 @@ typedef struct SRSLTE_API {
/* buffers */ /* buffers */
cf_t *ce[SRSLTE_MAX_PORTS]; cf_t *ce[SRSLTE_MAX_PORTS];
cf_t *pbch_symbols[SRSLTE_MAX_PORTS]; cf_t *symbols[SRSLTE_MAX_PORTS];
cf_t *pbch_x[SRSLTE_MAX_PORTS]; cf_t *x[SRSLTE_MAX_PORTS];
cf_t *pbch_d; cf_t *d;
float *pbch_llr; float *llr;
float *temp; float *temp;
float pbch_rm_f[BCH_ENCODED_LEN]; float rm_f[BCH_ENCODED_LEN];
uint8_t *pbch_rm_b; uint8_t *rm_b;
uint8_t data[BCH_PAYLOADCRC_LEN]; uint8_t data[BCH_PAYLOADCRC_LEN];
uint8_t data_enc[BCH_ENCODED_LEN]; uint8_t data_enc[BCH_ENCODED_LEN];
uint32_t frame_idx; uint32_t frame_idx;
/* tx & rx objects */ /* tx & rx objects */
modem_table_t mod; srslte_srslte_modem_table_t mod;
demod_soft_t demod; srslte_demod_soft_t demod;
srslte_sequence_t seq_pbch; srslte_sequence_t seq;
srslte_viterbi_t decoder; srslte_viterbi_t decoder;
srslte_crc_t crc; srslte_crc_t crc;
srslte_convcoder_t encoder; srslte_convcoder_t encoder;
precoding_t precoding; srslte_precoding_t precoding;
} pbch_t; } srslte_pbch_t;
SRSLTE_API int pbch_init(pbch_t *q, SRSLTE_API int srslte_pbch_init(srslte_pbch_t *q,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void pbch_free(pbch_t *q); SRSLTE_API void srslte_pbch_free(srslte_pbch_t *q);
SRSLTE_API int pbch_decode(pbch_t *q, SRSLTE_API int srslte_pbch_decode(srslte_pbch_t *q,
cf_t *slot1_symbols, cf_t *slot1_symbols,
cf_t *ce_slot1[SRSLTE_MAX_PORTS], cf_t *ce_slot1[SRSLTE_MAX_PORTS],
float noise_estimate, float noise_estimate,
@ -93,21 +93,21 @@ SRSLTE_API int pbch_decode(pbch_t *q,
uint32_t *nof_tx_ports, uint32_t *nof_tx_ports,
uint32_t *sfn_offset); uint32_t *sfn_offset);
SRSLTE_API int pbch_encode(pbch_t *q, SRSLTE_API int srslte_pbch_encode(srslte_pbch_t *q,
uint8_t bch_payload[BCH_PAYLOAD_LEN], uint8_t bch_payload[BCH_PAYLOAD_LEN],
cf_t *slot1_symbols[SRSLTE_MAX_PORTS]); cf_t *slot1_symbols[SRSLTE_MAX_PORTS]);
SRSLTE_API void pbch_decode_reset(pbch_t *q); SRSLTE_API void srslte_pbch_decode_reset(srslte_pbch_t *q);
SRSLTE_API void pbch_mib_unpack(uint8_t *msg, SRSLTE_API void srslte_pbch_mib_unpack(uint8_t *msg,
srslte_cell_t *cell, srslte_cell_t *cell,
uint32_t *sfn); uint32_t *sfn);
SRSLTE_API void pbch_mib_pack(srslte_cell_t *cell, SRSLTE_API void srslte_pbch_mib_pack(srslte_cell_t *cell,
uint32_t sfn, uint32_t sfn,
uint8_t *msg); uint8_t *msg);
SRSLTE_API void pbch_mib_fprint(FILE *stream, SRSLTE_API void srslte_pbch_mib_fprint(FILE *stream,
srslte_cell_t *cell, srslte_cell_t *cell,
uint32_t sfn, uint32_t sfn,
uint32_t cell_id); uint32_t cell_id);

@ -48,13 +48,13 @@ typedef struct SRSLTE_API {
int nof_symbols; int nof_symbols;
/* handler to REGs resource mapper */ /* handler to REGs resource mapper */
regs_t *regs; srslte_regs_t *regs;
/* buffers */ /* buffers */
cf_t ce[SRSLTE_MAX_PORTS][PCFICH_RE]; cf_t ce[SRSLTE_MAX_PORTS][PCFICH_RE];
cf_t pcfich_symbols[SRSLTE_MAX_PORTS][PCFICH_RE]; cf_t symbols[SRSLTE_MAX_PORTS][PCFICH_RE];
cf_t pcfich_x[SRSLTE_MAX_PORTS][PCFICH_RE]; cf_t x[SRSLTE_MAX_PORTS][PCFICH_RE];
cf_t pcfich_d[PCFICH_RE]; cf_t d[PCFICH_RE];
// cfi table in floats // cfi table in floats
float cfi_table_float[3][PCFICH_CFI_LEN]; float cfi_table_float[3][PCFICH_CFI_LEN];
@ -66,20 +66,20 @@ typedef struct SRSLTE_API {
float data_f[PCFICH_CFI_LEN]; float data_f[PCFICH_CFI_LEN];
/* tx & rx objects */ /* tx & rx objects */
modem_table_t mod; srslte_srslte_modem_table_t mod;
demod_soft_t demod; srslte_demod_soft_t demod;
srslte_sequence_t seq_pcfich[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
precoding_t precoding; srslte_precoding_t precoding;
} pcfich_t; } srslte_pcfich_t;
SRSLTE_API int pcfich_init(pcfich_t *q, SRSLTE_API int srslte_pcfich_init(srslte_pcfich_t *q,
regs_t *regs, srslte_regs_t *regs,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void pcfich_free(pcfich_t *q); SRSLTE_API void srslte_pcfich_free(srslte_pcfich_t *q);
SRSLTE_API int pcfich_decode(pcfich_t *q, SRSLTE_API int srslte_pcfich_decode(srslte_pcfich_t *q,
cf_t *sf_symbols, cf_t *sf_symbols,
cf_t *ce[SRSLTE_MAX_PORTS], cf_t *ce[SRSLTE_MAX_PORTS],
float noise_estimate, float noise_estimate,
@ -87,7 +87,7 @@ SRSLTE_API int pcfich_decode(pcfich_t *q,
uint32_t *cfi, uint32_t *cfi,
float *corr_result); float *corr_result);
SRSLTE_API int pcfich_encode(pcfich_t *q, SRSLTE_API int srslte_pcfich_encode(srslte_pcfich_t *q,
uint32_t cfi, uint32_t cfi,
cf_t *sf_symbols[SRSLTE_MAX_PORTS], cf_t *sf_symbols[SRSLTE_MAX_PORTS],
uint32_t subframe); uint32_t subframe);

@ -47,7 +47,7 @@ typedef _Complex float cf_t;
typedef enum SRSLTE_API { typedef enum SRSLTE_API {
SEARCH_UE, SEARCH_COMMON SEARCH_UE, SEARCH_COMMON
} pdcch_search_mode_t; } srslte_pdcch_search_mode_t;
/* PDCCH object */ /* PDCCH object */
@ -57,70 +57,70 @@ typedef struct SRSLTE_API {
uint32_t nof_cce; uint32_t nof_cce;
uint32_t max_bits; uint32_t max_bits;
regs_t *regs; srslte_regs_t *regs;
/* buffers */ /* buffers */
cf_t *ce[SRSLTE_MAX_PORTS]; cf_t *ce[SRSLTE_MAX_PORTS];
cf_t *pdcch_symbols[SRSLTE_MAX_PORTS]; cf_t *symbols[SRSLTE_MAX_PORTS];
cf_t *pdcch_x[SRSLTE_MAX_PORTS]; cf_t *x[SRSLTE_MAX_PORTS];
cf_t *pdcch_d; cf_t *d;
uint8_t *pdcch_e; uint8_t *e;
float pdcch_rm_f[3 * (DCI_MAX_BITS + 16)]; float rm_f[3 * (DCI_MAX_BITS + 16)];
float *pdcch_llr; float *llr;
/* tx & rx objects */ /* tx & rx objects */
modem_table_t mod; srslte_srslte_modem_table_t mod;
demod_soft_t demod; srslte_demod_soft_t demod;
srslte_sequence_t seq_pdcch[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
srslte_viterbi_t decoder; srslte_viterbi_t decoder;
srslte_crc_t crc; srslte_crc_t crc;
precoding_t precoding; srslte_precoding_t precoding;
} pdcch_t; } srslte_pdcch_t;
SRSLTE_API int pdcch_init(pdcch_t *q, SRSLTE_API int srslte_pdcch_init(srslte_pdcch_t *q,
regs_t *regs, srslte_regs_t *regs,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void pdcch_free(pdcch_t *q); SRSLTE_API void srslte_pdcch_free(srslte_pdcch_t *q);
/* Encoding function */ /* Encoding function */
SRSLTE_API int pdcch_encode(pdcch_t *q, SRSLTE_API int srslte_pdcch_encode(srslte_pdcch_t *q,
dci_msg_t *msg, srslte_dci_msg_t *msg,
dci_location_t location, srslte_dci_location_t location,
uint16_t rnti, uint16_t rnti,
cf_t *sf_symbols[SRSLTE_MAX_PORTS], cf_t *sf_symbols[SRSLTE_MAX_PORTS],
uint32_t nsubframe, uint32_t nsubframe,
uint32_t cfi); uint32_t cfi);
/* Decoding functions: Extract the LLRs and save them in the pdcch_t object */ /* Decoding functions: Extract the LLRs and save them in the srslte_pdcch_t object */
SRSLTE_API int pdcch_extract_llr(pdcch_t *q, SRSLTE_API int srslte_pdcch_extract_llr(srslte_pdcch_t *q,
cf_t *sf_symbols, cf_t *sf_symbols,
cf_t *ce[SRSLTE_MAX_PORTS], cf_t *ce[SRSLTE_MAX_PORTS],
float noise_estimate, float noise_estimate,
uint32_t nsubframe, uint32_t nsubframe,
uint32_t cfi); uint32_t cfi);
/* Decoding functions: Try to decode a DCI message after calling pdcch_extract_llr */ /* Decoding functions: Try to decode a DCI message after calling srslte_pdcch_extract_llr */
SRSLTE_API int pdcch_decode_msg(pdcch_t *q, SRSLTE_API int srslte_pdcch_decode_msg(srslte_pdcch_t *q,
dci_msg_t *msg, srslte_dci_msg_t *msg,
dci_location_t *location, srslte_dci_location_t *location,
dci_format_t format, srslte_dci_format_t format,
uint16_t *srslte_crc_rem); uint16_t *srslte_crc_rem);
/* Function for generation of UE-specific search space DCI locations */ /* Function for generation of UE-specific search space DCI locations */
SRSLTE_API uint32_t pdcch_ue_locations(pdcch_t *q, SRSLTE_API uint32_t srslte_pdcch_ue_locations(srslte_pdcch_t *q,
dci_location_t *locations, srslte_dci_location_t *locations,
uint32_t max_locations, uint32_t max_locations,
uint32_t nsubframe, uint32_t nsubframe,
uint32_t cfi, uint32_t cfi,
uint16_t rnti); uint16_t rnti);
/* Function for generation of common search space DCI locations */ /* Function for generation of common search space DCI locations */
SRSLTE_API uint32_t pdcch_common_locations(pdcch_t *q, SRSLTE_API uint32_t srslte_pdcch_common_locations(srslte_pdcch_t *q,
dci_location_t *locations, srslte_dci_location_t *locations,
uint32_t max_locations, uint32_t max_locations,
uint32_t cfi); uint32_t cfi);
#endif #endif

@ -41,7 +41,7 @@
#include "srslte/phch/sch.h" #include "srslte/phch/sch.h"
#include "srslte/phch/harq.h" #include "srslte/phch/harq.h"
#define TDEC_MAX_ITERATIONS 5 #define SRSLTE_PDSCH_MAX_TDEC_ITERS 5
typedef _Complex float cf_t; typedef _Complex float cf_t;
@ -56,57 +56,57 @@ typedef struct SRSLTE_API {
/* buffers */ /* buffers */
// void buffers are shared for tx and rx // void buffers are shared for tx and rx
cf_t *ce[SRSLTE_MAX_PORTS]; cf_t *ce[SRSLTE_MAX_PORTS];
cf_t *pdsch_symbols[SRSLTE_MAX_PORTS]; cf_t *symbols[SRSLTE_MAX_PORTS];
cf_t *pdsch_x[SRSLTE_MAX_PORTS]; cf_t *x[SRSLTE_MAX_PORTS];
cf_t *pdsch_d; cf_t *d;
void *pdsch_e; void *e;
/* tx & rx objects */ /* tx & rx objects */
modem_table_t mod[4]; srslte_srslte_modem_table_t mod[4];
demod_soft_t demod; srslte_demod_soft_t demod;
srslte_sequence_t seq_pdsch[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
precoding_t precoding; srslte_precoding_t precoding;
sch_t dl_sch; srslte_sch_t dl_sch;
}pdsch_t; } srslte_pdsch_t;
SRSLTE_API int pdsch_init(pdsch_t *q, SRSLTE_API int srslte_pdsch_init(srslte_pdsch_t *q,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void pdsch_free(pdsch_t *q); SRSLTE_API void srslte_pdsch_free(srslte_pdsch_t *q);
SRSLTE_API int pdsch_set_rnti(pdsch_t *q, SRSLTE_API int srslte_pdsch_set_rnti(srslte_pdsch_t *q,
uint16_t rnti); uint16_t rnti);
SRSLTE_API int pdsch_encode(pdsch_t *q, SRSLTE_API int srslte_pdsch_encode(srslte_pdsch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
uint8_t *data, uint8_t *data,
cf_t *sf_symbols[SRSLTE_MAX_PORTS]); cf_t *sf_symbols[SRSLTE_MAX_PORTS]);
SRSLTE_API int pdsch_encode_rnti(pdsch_t *q, SRSLTE_API int srslte_pdsch_encode_rnti(srslte_pdsch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
uint8_t *data, uint8_t *data,
uint16_t rnti, uint16_t rnti,
cf_t *sf_symbols[SRSLTE_MAX_PORTS]); cf_t *sf_symbols[SRSLTE_MAX_PORTS]);
SRSLTE_API int pdsch_decode(pdsch_t *q, SRSLTE_API int srslte_pdsch_decode(srslte_pdsch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
cf_t *sf_symbols, cf_t *sf_symbols,
cf_t *ce[SRSLTE_MAX_PORTS], cf_t *ce[SRSLTE_MAX_PORTS],
float noise_estimate, float noise_estimate,
uint8_t *data); uint8_t *data);
SRSLTE_API int pdsch_decode_rnti(pdsch_t *q, SRSLTE_API int srslte_pdsch_decode_rnti(srslte_pdsch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
cf_t *sf_symbols, cf_t *sf_symbols,
cf_t *ce[SRSLTE_MAX_PORTS], cf_t *ce[SRSLTE_MAX_PORTS],
float noise_estimate, float noise_estimate,
uint16_t rnti, uint16_t rnti,
uint8_t *data); uint8_t *data);
SRSLTE_API float pdsch_average_noi(pdsch_t *q); SRSLTE_API float srslte_pdsch_average_noi(srslte_pdsch_t *q);
SRSLTE_API uint32_t pdsch_last_noi(pdsch_t *q); SRSLTE_API uint32_t srslte_pdsch_last_noi(srslte_pdsch_t *q);
#endif #endif

@ -41,70 +41,69 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
#define SRSLTE_PHICH_NORM_NSEQUENCES 8 #define SRSLTE_PHICH_NORM_NSEQUENCES 8
#define SRSLTE_PHICH_EXT_NSEQUENCES 4 #define SRSLTE_PHICH_EXT_NSEQUENCES 4
#define PHICH_MAX_SEQUENCES SRSLTE_PHICH_NORM_NSEQUENCES #define SRSLTE_PHICH_NBITS 3
#define PHICH_NBITS 3
#define SRSLTE_PHICH_NORM_MSYMB SRSLTE_PHICH_NBITS * 4
#define SRSLTE_PHICH_NORM_MSYMB PHICH_NBITS * 4 #define SRSLTE_PHICH_EXT_MSYMB SRSLTE_PHICH_NBITS * 2
#define SRSLTE_PHICH_EXT_MSYMB PHICH_NBITS * 2 #define SRSLTE_PHICH_MAX_NSYMB SRSLTE_PHICH_NORM_MSYMB
#define PHICH_SRSLTE_MAX_NSYMB SRSLTE_PHICH_NORM_MSYMB #define SRSLTE_PHICH_NORM_C 1
#define SRSLTE_PHICH_NORM_C 1 #define SRSLTE_PHICH_EXT_C 2
#define SRSLTE_PHICH_EXT_C 2 #define SRSLTE_PHICH_NORM_NSF 4
#define SRSLTE_PHICH_NORM_NSF 4 #define SRSLTE_PHICH_EXT_NSF 2
#define SRSLTE_PHICH_EXT_NSF 2
/* phich object */ /* phich object */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_cell_t cell; srslte_cell_t cell;
/* handler to REGs resource mapper */ /* handler to REGs resource mapper */
regs_t *regs; srslte_regs_t *regs;
/* buffers */ /* buffers */
cf_t ce[SRSLTE_MAX_PORTS][PHICH_SRSLTE_MAX_NSYMB]; cf_t ce[SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB];
cf_t phich_symbols[SRSLTE_MAX_PORTS][PHICH_SRSLTE_MAX_NSYMB]; cf_t symbols[SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB];
cf_t phich_x[SRSLTE_MAX_PORTS][PHICH_SRSLTE_MAX_NSYMB]; cf_t x[SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB];
cf_t phich_d[PHICH_SRSLTE_MAX_NSYMB]; cf_t d[SRSLTE_PHICH_MAX_NSYMB];
cf_t phich_d0[PHICH_SRSLTE_MAX_NSYMB]; cf_t d0[SRSLTE_PHICH_MAX_NSYMB];
cf_t phich_z[PHICH_NBITS]; cf_t z[SRSLTE_PHICH_NBITS];
/* bit message */ /* bit message */
uint8_t data[PHICH_NBITS]; uint8_t data[SRSLTE_PHICH_NBITS];
/* tx & rx objects */ /* tx & rx objects */
modem_table_t mod; srslte_srslte_modem_table_t mod;
demod_hard_t demod; srslte_demod_hard_t demod;
srslte_sequence_t seq_phich[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
precoding_t precoding; srslte_precoding_t precoding;
}phich_t; } srslte_phich_t;
SRSLTE_API int phich_init(phich_t *q, SRSLTE_API int srslte_phich_init(srslte_phich_t *q,
regs_t *regs, srslte_regs_t *regs,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void phich_free(phich_t *q); SRSLTE_API void srslte_phich_free(srslte_phich_t *q);
SRSLTE_API int phich_decode(phich_t *q, SRSLTE_API int srslte_phich_decode(srslte_phich_t *q,
cf_t *slot_symbols, cf_t *slot_symbols,
cf_t *ce[SRSLTE_MAX_PORTS], cf_t *ce[SRSLTE_MAX_PORTS],
float noise_estimate, float noise_estimate,
uint32_t ngroup, uint32_t ngroup,
uint32_t nseq, uint32_t nseq,
uint32_t nsubframe, uint32_t nsubframe,
uint8_t *ack, uint8_t *ack,
uint32_t *distance); uint32_t *distance);
SRSLTE_API int phich_encode(phich_t *q, SRSLTE_API int srslte_phich_encode(srslte_phich_t *q,
uint8_t ack, uint8_t ack,
uint32_t ngroup, uint32_t ngroup,
uint32_t nseq, uint32_t nseq,
uint32_t nsubframe, uint32_t nsubframe,
cf_t *slot_symbols[SRSLTE_MAX_PORTS]); cf_t *slot_symbols[SRSLTE_MAX_PORTS]);
SRSLTE_API void phich_reset(phich_t *q, SRSLTE_API void srslte_phich_reset(srslte_phich_t *q,
cf_t *slot_symbols[SRSLTE_MAX_PORTS]); cf_t *slot_symbols[SRSLTE_MAX_PORTS]);
SRSLTE_API uint32_t phich_ngroups(phich_t *q); SRSLTE_API uint32_t srslte_phich_ngroups(srslte_phich_t *q);
#endif // PHICH_ #endif // PHICH_

@ -33,13 +33,10 @@
#include <complex.h> #include <complex.h>
#include <stdbool.h> #include <stdbool.h>
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/utils/dft.h" #include "srslte/dft/dft.h"
typedef _Complex float cf_t; typedef _Complex float cf_t;
//PRACH detection threshold is PRACH_DETECT_FACTOR*average
#define PRACH_DETECT_FACTOR 10
/** Generation and detection of RACH signals for uplink. /** Generation and detection of RACH signals for uplink.
* Currently only supports preamble formats 0-3. * Currently only supports preamble formats 0-3.
* Does not currently support high speed flag. * Does not currently support high speed flag.
@ -83,30 +80,30 @@ typedef struct SRSLTE_API {
srslte_dft_plan_t *zc_ifft; srslte_dft_plan_t *zc_ifft;
}prach_t; } srslte_prach_t;
SRSLTE_API int prach_init(prach_t *p, SRSLTE_API int srslte_prach_init(srslte_prach_t *p,
uint32_t N_ifft_ul, uint32_t N_ifft_ul,
uint32_t preamble_format, uint32_t preamble_format,
uint32_t root_seq_index, uint32_t root_seq_index,
bool high_speed_flag, bool high_speed_flag,
uint32_t zero_corr_zone_config); uint32_t zero_corr_zone_config);
SRSLTE_API int prach_gen(prach_t *p, SRSLTE_API int srslte_prach_gen(srslte_prach_t *p,
uint32_t seq_index, uint32_t seq_index,
uint32_t freq_offset, uint32_t freq_offset,
float beta_prach, float beta_prach,
cf_t *signal); cf_t *signal);
SRSLTE_API int prach_detect(prach_t *p, SRSLTE_API int srslte_prach_detect(srslte_prach_t *p,
uint32_t freq_offset, uint32_t freq_offset,
cf_t *signal, cf_t *signal,
uint32_t sig_len, uint32_t sig_len,
uint32_t *indices, uint32_t *indices,
uint32_t *ind_len); uint32_t *ind_len);
SRSLTE_API int prach_free(prach_t *p); SRSLTE_API int srslte_prach_free(srslte_prach_t *p);
SRSLTE_API int prach_print_seqs(prach_t *p); SRSLTE_API int srslte_prach_print_seqs(srslte_prach_t *p);
#endif // PRACH_ #endif // PRACH_

@ -39,71 +39,69 @@
#include "srslte/phch/regs.h" #include "srslte/phch/regs.h"
#include "srslte/phch/sch.h" #include "srslte/phch/sch.h"
#include "srslte/phch/harq.h" #include "srslte/phch/harq.h"
#include "srslte/filter/dft_precoding.h" #include "srslte/dft/dft_precoding.h"
#define TDEC_MAX_ITERATIONS 5
typedef _Complex float cf_t; typedef _Complex float cf_t;
#define PUCCH_N_SEQ 12 // Only Format 1, 1a and 1b supported #define SRSLTE_PUCCH_N_SEQ 12 // Only Format 1, 1a and 1b supported
#define PUCCH_MAX_BITS 2 #define SRSLTE_PUCCH_MAX_BITS 2
#define PUCCH_N_SF_MAX 4 #define SRSLTE_PUCCH_N_SF_MAX 4
typedef enum SRSLTE_API { typedef enum SRSLTE_API {
PUCCH_FORMAT_1 = 0, SRSLTE_PUCCH_FORMAT_1 = 0,
PUCCH_FORMAT_1A, SRSLTE_PUCCH_FORMAT_1A,
PUCCH_FORMAT_1B, SRSLTE_PUCCH_FORMAT_1B,
PUCCH_FORMAT_2, SRSLTE_PUCCH_FORMAT_2,
PUCCH_FORMAT_2A, SRSLTE_PUCCH_FORMAT_2A,
PUCCH_FORMAT_2B, SRSLTE_PUCCH_FORMAT_2B,
} pucch_format_t; } srslte_pucch_format_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
pucch_format_t format; srslte_pucch_format_t format;
float beta_pucch; float beta_pucch;
uint32_t delta_pucch_shift; uint32_t delta_pucch_shift;
uint32_t n_pucch; uint32_t n_pucch;
uint32_t N_cs; uint32_t N_cs;
} pucch_cfg_t; } srslte_pucch_cfg_t;
/* PUSCH object */ /* PUSCH object */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_cell_t cell; srslte_cell_t cell;
pucch_cfg_t pucch_cfg; srslte_pucch_cfg_t pucch_cfg;
uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]; 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[SRSLTE_PUCCH_N_SF_MAX*SRSLTE_PUCCH_N_SEQ];
float y[PUCCH_N_SEQ]; float y[SRSLTE_PUCCH_N_SEQ];
}pucch_t; }srslte_pucch_t;
SRSLTE_API int pucch_init(pucch_t *q, SRSLTE_API int srslte_pucch_init(srslte_pucch_t *q,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void pucch_free(pucch_t *q); SRSLTE_API void srslte_pucch_free(srslte_pucch_t *q);
SRSLTE_API void pucch_set_cfg(pucch_t *q, SRSLTE_API void srslte_pucch_set_cfg(srslte_pucch_t *q,
pucch_cfg_t *cfg); srslte_pucch_cfg_t *cfg);
SRSLTE_API int pucch_set_rnti(pucch_t *q, SRSLTE_API int srslte_pucch_set_rnti(srslte_pucch_t *q,
uint16_t rnti); uint16_t rnti);
SRSLTE_API int pucch_encode(pucch_t *q, SRSLTE_API int srslte_pucch_encode(srslte_pucch_t *q,
pucch_cfg_t *cfg, srslte_pucch_cfg_t *cfg,
uint8_t bits[PUCCH_MAX_BITS], uint8_t bits[SRSLTE_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_SRSLTE_SRSLTE_CP_NORM_NSYMB], SRSLTE_API float srslte_pucch_get_alpha(uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB],
pucch_cfg_t *cfg, srslte_pucch_cfg_t *cfg,
srslte_cp_t cp, srslte_cp_t cp,
bool is_drms, bool is_drms,
uint32_t ns, uint32_t ns,
uint32_t l, uint32_t l,
uint32_t *n_oc); uint32_t *n_oc);
SRSLTE_API int generate_n_cs_cell(srslte_cell_t cell, SRSLTE_API int srslte_generate_n_cs_cell(srslte_cell_t cell,
uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]); uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_SRSLTE_SRSLTE_CP_NORM_NSYMB]);
SRSLTE_API bool pucch_cfg_isvalid(pucch_cfg_t *cfg); SRSLTE_API bool srslte_pucch_cfg_isvalid(srslte_pucch_cfg_t *cfg);
#endif #endif

@ -39,102 +39,102 @@
#include "srslte/phch/regs.h" #include "srslte/phch/regs.h"
#include "srslte/phch/sch.h" #include "srslte/phch/sch.h"
#include "srslte/phch/harq.h" #include "srslte/phch/harq.h"
#include "srslte/filter/dft_precoding.h" #include "srslte/dft/dft_precoding.h"
#define TDEC_MAX_ITERATIONS 5 #define SRSLTE_PUSCH_MAX_TDEC_ITERS 5
typedef _Complex float cf_t; typedef _Complex float cf_t;
typedef struct { typedef struct {
enum { enum {
hop_mode_inter_sf = 1, SRSLTE_PUSCH_HOP_MODE_INTER_SF = 1,
hop_mode_intra_sf = 0 SRSLTE_PUSCH_HOP_MODE_INTRA_SF = 0
} hop_mode; } hop_mode;
uint32_t current_tx_nb; uint32_t current_tx_nb;
uint32_t hopping_offset; uint32_t hopping_offset;
uint32_t n_sb; uint32_t n_sb;
} pusch_hopping_cfg_t; } srslte_pusch_hopping_cfg_t;
/* PUSCH object */ /* PUSCH object */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_cell_t cell; srslte_cell_t cell;
pusch_hopping_cfg_t hopping_cfg; srslte_pusch_hopping_cfg_t hopping_cfg;
uint32_t max_re; uint32_t max_re;
bool rnti_is_set; bool rnti_is_set;
uint16_t rnti; uint16_t rnti;
srslte_srslte_dft_precoding_t srslte_dft_precoding; srslte_dft_precoding_t dft_precoding;
precoding_t equalizer; srslte_precoding_t equalizer;
/* buffers */ /* buffers */
// void buffers are shared for tx and rx // void buffers are shared for tx and rx
cf_t *ce; cf_t *ce;
cf_t *pusch_z; cf_t *z;
cf_t *pusch_d; cf_t *d;
void *pusch_q; void *q;
void *pusch_g; void *g;
/* tx & rx objects */ /* tx & rx objects */
modem_table_t mod[4]; srslte_srslte_modem_table_t mod[4];
demod_soft_t demod; srslte_demod_soft_t demod;
srslte_sequence_t seq_pusch[SRSLTE_NSUBFRAMES_X_FRAME]; srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
srslte_sequence_t seq_type2_fo; srslte_sequence_t seq_type2_fo;
sch_t dl_sch; srslte_sch_t dl_sch;
}pusch_t; }srslte_pusch_t;
SRSLTE_API int pusch_init(pusch_t *q, SRSLTE_API int srslte_pusch_init(srslte_pusch_t *q,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void pusch_free(pusch_t *q); SRSLTE_API void srslte_pusch_free(srslte_pusch_t *q);
SRSLTE_API void pusch_set_hopping_cfg(pusch_t *q, SRSLTE_API void srslte_pusch_set_hopping_cfg(srslte_pusch_t *q,
pusch_hopping_cfg_t *cfg); srslte_pusch_hopping_cfg_t *cfg);
SRSLTE_API int pusch_set_rnti(pusch_t *q, SRSLTE_API int srslte_pusch_set_rnti(srslte_pusch_t *q,
uint16_t rnti); uint16_t rnti);
SRSLTE_API int pusch_encode(pusch_t *q, SRSLTE_API int srslte_pusch_encode(srslte_pusch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
uint8_t *data, uint8_t *data,
cf_t *sf_symbols); cf_t *sf_symbols);
SRSLTE_API int pusch_encode_rnti(pusch_t *q, SRSLTE_API int srslte_pusch_encode_rnti(srslte_pusch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
uint8_t *data, uint8_t *data,
uint16_t rnti, uint16_t rnti,
cf_t *sf_symbols); cf_t *sf_symbols);
SRSLTE_API int pusch_uci_encode(pusch_t *q, SRSLTE_API int srslte_pusch_uci_encode(srslte_pusch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
uint8_t *data, uint8_t *data,
uci_data_t uci_data, srslte_uci_data_t uci_data,
cf_t *sf_symbols); cf_t *sf_symbols);
SRSLTE_API int pusch_uci_encode_rnti(pusch_t *q, SRSLTE_API int srslte_pusch_uci_encode_rnti(srslte_pusch_t *q,
harq_t *harq, srslte_harq_t *harq,
uint8_t *data, uint8_t *data,
uci_data_t uci_data, srslte_uci_data_t uci_data,
uint16_t rnti, uint16_t rnti,
cf_t *sf_symbols); cf_t *sf_symbols);
SRSLTE_API int pusch_decode(pusch_t *q, SRSLTE_API int srslte_pusch_decode(srslte_pusch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
cf_t *sf_symbols, cf_t *sf_symbols,
cf_t *ce, cf_t *ce,
float noise_estimate, float noise_estimate,
uint8_t *data); uint8_t *data);
SRSLTE_API float pusch_average_noi(pusch_t *q); SRSLTE_API float srslte_pusch_average_noi(srslte_pusch_t *q);
SRSLTE_API uint32_t pusch_last_noi(pusch_t *q); SRSLTE_API uint32_t srslte_pusch_last_noi(srslte_pusch_t *q);
#endif #endif

@ -32,6 +32,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/common/phy_common.h"
/** Structures and utility functions for DL/UL resource /** Structures and utility functions for DL/UL resource
* allocation. * allocation.
@ -40,164 +41,166 @@
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_mod_t mod; srslte_mod_t mod;
int tbs; int tbs;
} ra_mcs_t; } srslte_ra_mcs_t;
typedef enum SRSLTE_API { typedef enum SRSLTE_API {
alloc_type0 = 0, alloc_type1 = 1, alloc_type2 = 2 SRSLTE_RA_ALLOC_TYPE0 = 0,
} ra_type_t; SRSLTE_RA_ALLOC_TYPE1 = 1,
SRSLTE_RA_ALLOC_TYPE2 = 2
} srslte_ra_type_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint32_t rbg_bitmask; uint32_t rbg_bitmask;
} ra_type0_t; } srslte_ra_type0_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint32_t vrb_bitmask; uint32_t vrb_bitmask;
uint32_t rbg_subset; uint32_t rbg_subset;
bool shift; bool shift;
} ra_type1_t; } srslte_ra_type1_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint32_t riv; // if L_crb==0, DCI message packer will take this value directly uint32_t riv; // if L_crb==0, DCI message packer will take this value directly
uint32_t L_crb; uint32_t L_crb;
uint32_t RB_start; uint32_t RB_start;
enum { enum {
nprb1a_2 = 0, nprb1a_3 = 1 SRSLTE_RA_TYPE2_NPRB1A_2 = 0, SRSLTE_RA_TYPE2_NPRB1A_3 = 1
} n_prb1a; } n_prb1a;
enum { enum {
t2_ng1 = 0, t2_ng2 = 1 SRSLTE_RA_TYPE2_NG1 = 0, SRSLTE_RA_TYPE2_NG2 = 1
} n_gap; } n_gap;
enum { enum {
t2_loc = 0, t2_dist = 1 SRSLTE_RA_TYPE2_LOC = 0, SRSLTE_RA_TYPE2_DIST = 1
} mode; } mode;
} ra_type2_t; } srslte_ra_type2_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
bool prb_idx[SRSLTE_MAX_PRB]; bool prb_idx[SRSLTE_MAX_PRB];
uint32_t nof_prb; uint32_t nof_prb;
} ra_prb_slot_t; } srslte_ra_prb_slot_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
ra_prb_slot_t slot[2]; srslte_ra_prb_slot_t slot[2];
uint32_t lstart; uint32_t lstart;
uint32_t re_sf[SRSLTE_NSUBFRAMES_X_FRAME]; uint32_t re_sf[SRSLTE_NSUBFRAMES_X_FRAME];
} ra_dl_alloc_t; } srslte_srslte_ra_dl_alloc_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint32_t n_prb[2]; uint32_t n_prb[2];
uint32_t n_prb_tilde[2]; uint32_t n_prb_tilde[2];
uint32_t L_prb; uint32_t L_prb;
uint32_t freq_hopping; uint32_t freq_hopping;
} ra_ul_alloc_t; } srslte_srslte_ra_ul_alloc_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint16_t rnti; uint16_t rnti;
ra_type_t alloc_type; srslte_ra_type_t alloc_type;
union { union {
ra_type0_t type0_alloc; srslte_ra_type0_t type0_alloc;
ra_type1_t type1_alloc; srslte_ra_type1_t type1_alloc;
ra_type2_t type2_alloc; srslte_ra_type2_t type2_alloc;
}; };
ra_dl_alloc_t prb_alloc; srslte_srslte_ra_dl_alloc_t prb_alloc;
uint32_t mcs_idx; uint32_t mcs_idx;
ra_mcs_t mcs; srslte_ra_mcs_t mcs;
uint32_t harq_process; uint32_t harq_process;
uint32_t rv_idx; uint32_t rv_idx;
bool ndi; bool ndi;
} ra_pdsch_t; } srslte_ra_pdsch_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
/* 36.213 Table 8.4-2: hop_half is 0 for < 10 Mhz and 10 for > 10 Mhz. /* 36.213 Table 8.4-2: SRSLTE_RA_PUSCH_HOP_HALF is 0 for < 10 Mhz and 10 for > 10 Mhz.
* hop_quart is 00 for > 10 Mhz and hop_quart_neg is 01 for > 10 Mhz. * SRSLTE_RA_PUSCH_HOP_QUART is 00 for > 10 Mhz and SRSLTE_RA_PUSCH_HOP_QUART_NEG is 01 for > 10 Mhz.
*/ */
enum { enum {
hop_disabled = -1, SRSLTE_RA_PUSCH_HOP_DISABLED = -1,
hop_quart = 0, SRSLTE_RA_PUSCH_HOP_QUART = 0,
hop_quart_neg = 1, SRSLTE_RA_PUSCH_HOP_QUART_NEG = 1,
hop_half = 2, SRSLTE_RA_PUSCH_HOP_HALF = 2,
hop_type_2 = 3 SRSLTE_RA_PUSCH_HOP_TYPE2 = 3
} freq_hop_fl; } freq_hop_fl;
ra_ul_alloc_t prb_alloc; srslte_srslte_ra_ul_alloc_t prb_alloc;
ra_type2_t type2_alloc; srslte_ra_type2_t type2_alloc;
uint32_t mcs_idx; uint32_t mcs_idx;
ra_mcs_t mcs; srslte_ra_mcs_t mcs;
uint32_t rv_idx; // If set to non-zero, a retransmission is requested with the same modulation uint32_t rv_idx; // If set to non-zero, a retransmission is requested with the same modulation
// than before (Format0 message, see also 8.6.1 in 36.2313). // than before (SRSLTE_DCI_FORMAT0 message, see also 8.6.1 in 36.2313).
bool ndi; bool ndi;
bool cqi_request; bool cqi_request;
} ra_pusch_t; } srslte_ra_pusch_t;
SRSLTE_API void ra_prb_fprint(FILE *f, SRSLTE_API void srslte_ra_prb_fprint(FILE *f,
ra_prb_slot_t *prb, srslte_ra_prb_slot_t *prb,
uint32_t nof_prb); uint32_t nof_prb);
SRSLTE_API int ra_dl_alloc(ra_dl_alloc_t *prb, SRSLTE_API int srslte_ra_dl_alloc(srslte_srslte_ra_dl_alloc_t *prb,
ra_pdsch_t *ra, srslte_ra_pdsch_t *ra,
uint32_t nof_prb); uint32_t nof_prb);
SRSLTE_API int ra_ul_alloc(ra_ul_alloc_t *prb, SRSLTE_API int srslte_ra_ul_alloc(srslte_srslte_ra_ul_alloc_t *prb,
ra_pusch_t *ra, srslte_ra_pusch_t *ra,
uint32_t n_rb_ho, uint32_t n_rb_ho,
uint32_t nof_prb); uint32_t nof_prb);
SRSLTE_API void ra_dl_alloc_re(ra_dl_alloc_t *prb_dist, SRSLTE_API void srslte_ra_dl_alloc_re(srslte_srslte_ra_dl_alloc_t *prb_dist,
uint32_t nof_prb, uint32_t nof_prb,
uint32_t nof_ports, uint32_t nof_ports,
uint32_t nof_ctrl_symbols, uint32_t nof_ctrl_symbols,
srslte_cp_t cp); srslte_cp_t cp);
SRSLTE_API uint32_t ra_nprb_dl(ra_pdsch_t *ra, SRSLTE_API uint32_t srslte_ra_nprb_dl(srslte_ra_pdsch_t *ra,
uint32_t nof_prb); uint32_t nof_prb);
SRSLTE_API uint32_t ra_nprb_ul(ra_pusch_t *ra, SRSLTE_API uint32_t srslte_ra_nprb_ul(srslte_ra_pusch_t *ra,
uint32_t nof_prb); uint32_t nof_prb);
SRSLTE_API int ra_mcs_from_idx_dl(uint32_t mcs_idx, SRSLTE_API int srslte_ra_mcs_from_idx_dl(uint32_t mcs_idx,
uint32_t nof_prb, uint32_t nof_prb,
ra_mcs_t *mcs); srslte_ra_mcs_t *mcs);
SRSLTE_API int ra_mcs_from_idx_ul(uint32_t mcs_idx, SRSLTE_API int srslte_ra_mcs_from_idx_ul(uint32_t mcs_idx,
uint32_t nof_prb, uint32_t nof_prb,
ra_mcs_t *mcs); srslte_ra_mcs_t *mcs);
SRSLTE_API int ra_tbs_from_idx_format1c(uint32_t tbs_idx); SRSLTE_API int srslte_srslte_ra_tbs_from_idx_format1c(uint32_t tbs_idx);
SRSLTE_API int ra_tbs_from_idx(uint32_t tbs_idx, SRSLTE_API int srslte_ra_tbs_from_idx(uint32_t tbs_idx,
uint32_t n_prb); uint32_t n_prb);
SRSLTE_API int ra_tbs_to_table_idx(uint32_t tbs, SRSLTE_API int srslte_ra_tbs_to_table_idx(uint32_t tbs,
uint32_t n_prb); uint32_t n_prb);
SRSLTE_API uint32_t ra_type0_P(uint32_t nof_prb); SRSLTE_API uint32_t srslte_ra_type0_P(uint32_t nof_prb);
SRSLTE_API uint32_t ra_type2_to_riv(uint32_t L_crb, SRSLTE_API uint32_t srslte_ra_type2_to_riv(uint32_t L_crb,
uint32_t RB_start, uint32_t RB_start,
uint32_t nof_prb); uint32_t nof_prb);
SRSLTE_API void ra_type2_from_riv(uint32_t riv, SRSLTE_API void srslte_ra_type2_from_riv(uint32_t riv,
uint32_t *L_crb, uint32_t *L_crb,
uint32_t *RB_start, uint32_t *RB_start,
uint32_t nof_prb, uint32_t nof_prb,
uint32_t nof_vrb); uint32_t nof_vrb);
SRSLTE_API uint32_t ra_type2_n_vrb_dl(uint32_t nof_prb, SRSLTE_API uint32_t srslte_ra_type2_n_vrb_dl(uint32_t nof_prb,
bool ngap_is_1); bool ngap_is_1);
SRSLTE_API uint32_t ra_type2_n_rb_step(uint32_t nof_prb); SRSLTE_API uint32_t srslte_ra_type2_n_rb_step(uint32_t nof_prb);
SRSLTE_API uint32_t ra_type2_ngap(uint32_t nof_prb, SRSLTE_API uint32_t srslte_ra_type2_ngap(uint32_t nof_prb,
bool ngap_is_1); bool ngap_is_1);
SRSLTE_API uint32_t ra_type1_N_rb(uint32_t nof_prb); SRSLTE_API uint32_t srslte_ra_type1_N_rb(uint32_t nof_prb);
SRSLTE_API void ra_pdsch_fprint(FILE *f, SRSLTE_API void srslte_ra_pdsch_fprint(FILE *f,
ra_pdsch_t *ra, srslte_ra_pdsch_t *ra,
uint32_t nof_prb); uint32_t nof_prb);
SRSLTE_API void ra_pusch_fprint(FILE *f, SRSLTE_API void srslte_ra_pusch_fprint(FILE *f,
ra_pusch_t *ra, srslte_ra_pusch_t *ra,
uint32_t nof_prb); uint32_t nof_prb);
#endif /* RB_ALLOC_H_ */ #endif /* RB_ALLOC_H_ */

@ -49,12 +49,12 @@ typedef struct SRSLTE_API {
uint32_t k0; uint32_t k0;
uint32_t l; uint32_t l;
bool assigned; bool assigned;
}regs_reg_t; }srslte_regs_reg_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint32_t nof_regs; uint32_t nof_regs;
regs_reg_t **regs; srslte_regs_reg_t **regs;
}regs_ch_t; }srslte_regs_ch_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_cell_t cell; srslte_cell_t cell;
@ -66,67 +66,67 @@ typedef struct SRSLTE_API {
srslte_phich_resources_t phich_res; srslte_phich_resources_t phich_res;
srslte_phich_length_t phich_len; srslte_phich_length_t phich_len;
regs_ch_t pcfich; srslte_regs_ch_t pcfich;
regs_ch_t *phich; // there are several phich srslte_regs_ch_t *phich; // there are several phich
regs_ch_t pdcch[3]; /* PDCCH indexing, permutation and interleaving is computed for srslte_regs_ch_t pdcch[3]; /* PDCCH indexing, permutation and interleaving is computed for
the three possible CFI value */ the three possible CFI value */
uint32_t nof_regs; uint32_t nof_regs;
regs_reg_t *regs; srslte_regs_reg_t *regs;
}regs_t; }srslte_regs_t;
SRSLTE_API int regs_init(regs_t *h, SRSLTE_API int srslte_regs_init(srslte_regs_t *h,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void regs_free(regs_t *h); SRSLTE_API void srslte_regs_free(srslte_regs_t *h);
SRSLTE_API int regs_set_cfi(regs_t *h, SRSLTE_API int srslte_regs_set_cfi(srslte_regs_t *h,
uint32_t nof_ctrl_symbols); uint32_t nof_ctrl_symbols);
SRSLTE_API uint32_t regs_pcfich_nregs(regs_t *h); SRSLTE_API uint32_t srslte_regs_pcfich_nregs(srslte_regs_t *h);
SRSLTE_API int regs_pcfich_put(regs_t *h, SRSLTE_API int srslte_regs_pcfich_put(srslte_regs_t *h,
cf_t pcfich_symbols[REGS_PCFICH_NSYM], cf_t symbols[REGS_PCFICH_NSYM],
cf_t *slot_symbols); cf_t *slot_symbols);
SRSLTE_API int regs_pcfich_get(regs_t *h, SRSLTE_API int srslte_regs_pcfich_get(srslte_regs_t *h,
cf_t *slot_symbols, cf_t *slot_symbols,
cf_t pcfich_symbols[REGS_PCFICH_NSYM]); cf_t symbols[REGS_PCFICH_NSYM]);
SRSLTE_API uint32_t regs_phich_nregs(regs_t *h); SRSLTE_API uint32_t srslte_regs_phich_nregs(srslte_regs_t *h);
SRSLTE_API int regs_phich_add(regs_t *h, SRSLTE_API int srslte_regs_phich_add(srslte_regs_t *h,
cf_t phich_symbols[REGS_PHICH_NSYM], cf_t symbols[REGS_PHICH_NSYM],
uint32_t ngroup, uint32_t ngroup,
cf_t *slot_symbols); cf_t *slot_symbols);
SRSLTE_API int regs_phich_get(regs_t *h, SRSLTE_API int srslte_regs_phich_get(srslte_regs_t *h,
cf_t *slot_symbols, cf_t *slot_symbols,
cf_t phich_symbols[REGS_PHICH_NSYM], cf_t symbols[REGS_PHICH_NSYM],
uint32_t ngroup); uint32_t ngroup);
SRSLTE_API uint32_t regs_phich_ngroups(regs_t *h); SRSLTE_API uint32_t srslte_regs_phich_ngroups(srslte_regs_t *h);
SRSLTE_API int regs_phich_reset(regs_t *h, SRSLTE_API int srslte_regs_phich_reset(srslte_regs_t *h,
cf_t *slot_symbols); cf_t *slot_symbols);
SRSLTE_API int regs_pdcch_nregs(regs_t *h, uint32_t cfi); SRSLTE_API int srslte_regs_pdcch_nregs(srslte_regs_t *h, uint32_t cfi);
SRSLTE_API int regs_pdcch_put(regs_t *h, SRSLTE_API int srslte_regs_pdcch_put(srslte_regs_t *h,
cf_t *pdcch_symbols, cf_t *d,
cf_t *slot_symbols); cf_t *slot_symbols);
SRSLTE_API int regs_pdcch_put_offset(regs_t *h, SRSLTE_API int srslte_regs_pdcch_put_offset(srslte_regs_t *h,
cf_t *pdcch_symbols, cf_t *d,
cf_t *slot_symbols, cf_t *slot_symbols,
uint32_t start_reg, uint32_t start_reg,
uint32_t nof_regs); uint32_t nof_regs);
SRSLTE_API int regs_pdcch_get(regs_t *h, SRSLTE_API int srslte_regs_pdcch_get(srslte_regs_t *h,
cf_t *slot_symbols,
cf_t *pdcch_symbols);
SRSLTE_API int regs_pdcch_get_offset(regs_t *h,
cf_t *slot_symbols, cf_t *slot_symbols,
cf_t *pdcch_symbols, cf_t *d);
uint32_t start_reg,
uint32_t nof_regs); SRSLTE_API int srslte_regs_pdcch_get_offset(srslte_regs_t *h,
cf_t *slot_symbols,
cf_t *d,
uint32_t start_reg,
uint32_t nof_regs);
#endif // REGS_H_ #endif // REGS_H_

@ -38,7 +38,7 @@
#include "srslte/phch/harq.h" #include "srslte/phch/harq.h"
#include "srslte/phch/uci.h" #include "srslte/phch/uci.h"
#define TDEC_MAX_ITERATIONS 5 #define SRSLTE_PDSCH_MAX_TDEC_ITERS 5
#ifndef SRSLTE_RX_NULL #ifndef SRSLTE_RX_NULL
@ -58,51 +58,51 @@ typedef struct SRSLTE_API {
/* buffers */ /* buffers */
uint8_t *cb_in; uint8_t *cb_in;
void *cb_out; void *cb_out;
void *pdsch_e; void *e;
srslte_tcod_t encoder; srslte_tcod_t encoder;
srslte_tdec_t decoder; srslte_tdec_t decoder;
srslte_crc_t srslte_crc_tb; srslte_crc_t srslte_crc_tb;
srslte_crc_t srslte_crc_cb; srslte_crc_t srslte_crc_cb;
uci_cqi_pusch_t uci_cqi; srslte_uci_cqi_pusch_t uci_cqi;
} sch_t; } srslte_sch_t;
SRSLTE_API int sch_init(sch_t *q); SRSLTE_API int srslte_sch_init(srslte_sch_t *q);
SRSLTE_API void sch_free(sch_t *q); SRSLTE_API void srslte_sch_free(srslte_sch_t *q);
SRSLTE_API float sch_average_noi(sch_t *q); SRSLTE_API float srslte_sch_average_noi(srslte_sch_t *q);
SRSLTE_API uint32_t sch_last_noi(sch_t *q); SRSLTE_API uint32_t srslte_sch_last_noi(srslte_sch_t *q);
SRSLTE_API int dlsch_encode(sch_t *q, SRSLTE_API int srslte_dlsch_encode(srslte_sch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
uint8_t *data, uint8_t *data,
uint8_t *e_bits); uint8_t *e_bits);
SRSLTE_API int dlsch_decode(sch_t *q, SRSLTE_API int srslte_dlsch_decode(srslte_sch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
float *e_bits, float *e_bits,
uint8_t *data); uint8_t *data);
SRSLTE_API int ulsch_encode(sch_t *q, SRSLTE_API int srslte_ulsch_encode(srslte_sch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
uint8_t *data, uint8_t *data,
uint8_t *g_bits, uint8_t *g_bits,
uint8_t *q_bits); uint8_t *q_bits);
SRSLTE_API int ulsch_uci_encode(sch_t *q, SRSLTE_API int srslte_ulsch_uci_encode(srslte_sch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
uint8_t *data, uint8_t *data,
uci_data_t uci_data, srslte_uci_data_t uci_data,
uint8_t *g_bits, uint8_t *g_bits,
uint8_t *q_bits); uint8_t *q_bits);
SRSLTE_API int ulsch_decode(sch_t *q, SRSLTE_API int srslte_ulsch_decode(srslte_sch_t *q,
harq_t *harq_process, srslte_harq_t *harq_process,
float *e_bits, float *e_bits,
uint8_t *data); uint8_t *data);

@ -34,16 +34,16 @@
#include "srslte/phch/harq.h" #include "srslte/phch/harq.h"
#include "srslte/fec/crc.h" #include "srslte/fec/crc.h"
#define MAX_CQI_LEN_PUSCH 512 #define SRSLTE_UCI_MAX_CQI_LEN_PUSCH 512
#define MAX_CQI_LEN_PUCCH 13 #define SRSLTE_UCI_MAX_CQI_LEN_PUCCH 13
#define CQI_CODED_PUCCH_B 20 #define SRSLTE_UCI_CQI_CODED_PUCCH_B 20
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_crc_t crc; srslte_crc_t crc;
uint8_t tmp_cqi[MAX_CQI_LEN_PUSCH]; uint8_t tmp_cqi[SRSLTE_UCI_MAX_CQI_LEN_PUSCH];
uint8_t encoded_cqi[3*MAX_CQI_LEN_PUSCH]; uint8_t encoded_cqi[3*SRSLTE_UCI_MAX_CQI_LEN_PUSCH];
} uci_cqi_pusch_t; } srslte_uci_cqi_pusch_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint8_t *uci_cqi; uint8_t *uci_cqi;
@ -55,37 +55,37 @@ typedef struct SRSLTE_API {
uint8_t uci_ack; // Only 1-bit supported for HARQ uint8_t uci_ack; // Only 1-bit supported for HARQ
uint32_t uci_ack_len; uint32_t uci_ack_len;
float beta_ack; float beta_ack;
} uci_data_t; } srslte_uci_data_t;
SRSLTE_API int uci_cqi_init(uci_cqi_pusch_t *q); SRSLTE_API int srslte_uci_cqi_init(srslte_uci_cqi_pusch_t *q);
SRSLTE_API void uci_cqi_free(uci_cqi_pusch_t *q); SRSLTE_API void srslte_uci_cqi_free(srslte_uci_cqi_pusch_t *q);
SRSLTE_API int uci_encode_cqi_pusch(uci_cqi_pusch_t *q, SRSLTE_API int srslte_uci_encode_cqi_pusch(srslte_uci_cqi_pusch_t *q,
uint8_t *cqi_data, uint8_t *cqi_data,
uint32_t cqi_len, uint32_t cqi_len,
float beta, float beta,
uint32_t Q_prime_ri, uint32_t Q_prime_ri,
harq_t *harq_process, srslte_harq_t *harq_process,
uint8_t *q_bits); uint8_t *q_bits);
SRSLTE_API int uci_encode_cqi_pucch(uint8_t *cqi_data, SRSLTE_API int srslte_uci_encode_cqi_pucch(uint8_t *cqi_data,
uint32_t cqi_len, uint32_t cqi_len,
uint8_t b_bits[CQI_CODED_PUCCH_B]); uint8_t b_bits[SRSLTE_UCI_CQI_CODED_PUCCH_B]);
SRSLTE_API int uci_encode_ack(uint8_t data, SRSLTE_API int srslte_uci_encode_ack(uint8_t data,
uint32_t O_cqi, uint32_t O_cqi,
float beta, float beta,
harq_t *harq_process, srslte_harq_t *harq_process,
uint32_t H_prime_total, uint32_t H_prime_total,
uint8_t *q_bits); uint8_t *q_bits);
SRSLTE_API int uci_encode_ri(uint8_t data, SRSLTE_API int srslte_uci_encode_ri(uint8_t data,
uint32_t O_cqi, uint32_t O_cqi,
float beta, float beta,
harq_t *harq_process, srslte_harq_t *harq_process,
uint32_t H_prime_total, uint32_t H_prime_total,
uint8_t *q_bits); uint8_t *q_bits);
#endif #endif

@ -33,7 +33,14 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
SRSLTE_API void decim_c(cf_t *input, cf_t *output, int M, int len); SRSLTE_API void srslte_decim_c(cf_t *input,
SRSLTE_API void decim_f(float *input, float *output, int M, int len); cf_t *output,
int M,
int len);
SRSLTE_API void srslte_decim_f(float *input,
float *output,
int M,
int len);
#endif // DECIM_H #endif // DECIM_H

@ -44,16 +44,16 @@ SRSLTE_API cf_t srslte_interp_linear_onesample_cabs(cf_t input0,
cf_t input1); cf_t input1);
SRSLTE_API void srslte_interp_linear_offset_cabs(cf_t *input, SRSLTE_API void srslte_interp_linear_offset_cabs(cf_t *input,
cf_t *output, cf_t *output,
uint32_t M, uint32_t M,
uint32_t len, uint32_t len,
uint32_t off_st, uint32_t off_st,
uint32_t off_end); uint32_t off_end);
SRSLTE_API void srslte_interp_linear_f(float *input, SRSLTE_API void srslte_interp_linear_f(float *input,
float *output, float *output,
uint32_t M, uint32_t M,
uint32_t len); uint32_t len);
@ -62,18 +62,18 @@ SRSLTE_API void srslte_interp_linear_f(float *input,
typedef struct { typedef struct {
cf_t *diff_vec; cf_t *diff_vec;
uint32_t vector_len; uint32_t vector_len;
} srslte_interp_linvec_t; } srslte_interp_linsrslte_vec_t;
SRSLTE_API int srslte_interp_linear_vector_init(srslte_interp_linvec_t *q, SRSLTE_API int srslte_interp_linear_vector_init(srslte_interp_linsrslte_vec_t *q,
uint32_t vector_len); uint32_t vector_len);
SRSLTE_API void srslte_interp_linear_vector_free(srslte_interp_linvec_t *q); SRSLTE_API void srslte_interp_linear_vector_free(srslte_interp_linsrslte_vec_t *q);
SRSLTE_API void srslte_interp_linear_vector(srslte_interp_linvec_t *q, SRSLTE_API void srslte_interp_linear_vector(srslte_interp_linsrslte_vec_t *q,
cf_t *in0, cf_t *in0,
cf_t *in1, cf_t *in1,
cf_t *between, cf_t *between,
uint32_t M); uint32_t M);
@ -88,16 +88,16 @@ typedef struct {
} srslte_interp_lin_t; } srslte_interp_lin_t;
SRSLTE_API int srslte_interp_linear_init(srslte_interp_lin_t *q, SRSLTE_API int srslte_interp_linear_init(srslte_interp_lin_t *q,
uint32_t vector_len, uint32_t vector_len,
uint32_t M); uint32_t M);
SRSLTE_API void srslte_interp_linear_free(srslte_interp_lin_t *q); SRSLTE_API void srslte_interp_linear_free(srslte_interp_lin_t *q);
SRSLTE_API void srslte_interp_linear_offset(srslte_interp_lin_t *q, SRSLTE_API void srslte_interp_linear_offset(srslte_interp_lin_t *q,
cf_t *input, cf_t *input,
cf_t *output, cf_t *output,
uint32_t off_st, uint32_t off_st,
uint32_t off_end); uint32_t off_end);
#endif // INTERP_H #endif // INTERP_H

@ -35,17 +35,22 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
#define RESAMPLE_ARB_N 32 // Polyphase filter rows #define SRSLTE_RESAMPLE_ARB_N 32 // Polyphase filter rows
#define RESAMPLE_ARB_M 8 // Polyphase filter columns #define SRSLTE_RESAMPLE_ARB_M 8 // Polyphase filter columns
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
float rate; // Resample rate float rate; // Resample rate
float step; // Step increment through filter float step; // Step increment through filter
float acc; // Index into filter float acc; // Index into filter
cf_t reg[RESAMPLE_ARB_M]; // Our window of samples cf_t reg[SRSLTE_RESAMPLE_ARB_M]; // Our window of samples
}resample_arb_t; } srslte_resample_arb_t;
SRSLTE_API void resample_arb_init(resample_arb_t *q, float rate); SRSLTE_API void srslte_resample_arb_init(srslte_resample_arb_t *q,
SRSLTE_API int resample_arb_compute(resample_arb_t *q, cf_t *input, cf_t *output, int n_in); float rate);
SRSLTE_API int srslte_resample_arb_compute(srslte_resample_arb_t *q,
cf_t *input,
cf_t *output,
int n_in);
#endif //RESAMPLE_ARB_ #endif //RESAMPLE_ARB_

@ -36,68 +36,34 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
/* Scrambling has no state */ /* Scrambling has no state */
SRSLTE_API void scrambling_b(srslte_sequence_t *s, SRSLTE_API void srslte_scrambling_b(srslte_sequence_t *s,
uint8_t *data); uint8_t *data);
SRSLTE_API void scrambling_b_offset(srslte_sequence_t *s, SRSLTE_API void srslte_scrambling_b_offset(srslte_sequence_t *s,
uint8_t *data, uint8_t *data,
int offset, int offset,
int len); int len);
SRSLTE_API void scrambling_b_offset_pusch(srslte_sequence_t *s, SRSLTE_API void srslte_scrambling_b_offset_pusch(srslte_sequence_t *s,
uint8_t *data, uint8_t *data,
int offset, int offset,
int len); int len);
SRSLTE_API void scrambling_f(srslte_sequence_t *s, SRSLTE_API void srslte_scrambling_f(srslte_sequence_t *s,
float *data); float *data);
SRSLTE_API void scrambling_f_offset(srslte_sequence_t *s, SRSLTE_API void srslte_scrambling_f_offset(srslte_sequence_t *s,
float *data, float *data,
int offset, int offset,
int len); int len);
SRSLTE_API void scrambling_c(srslte_sequence_t *s, SRSLTE_API void srslte_scrambling_c(srslte_sequence_t *s,
cf_t *data); cf_t *data);
SRSLTE_API void scrambling_c_offset(srslte_sequence_t *s, SRSLTE_API void srslte_scrambling_c_offset(srslte_sequence_t *s,
cf_t *data, cf_t *data,
int offset, int offset,
int len); int len);
/* High-level API */
/* channel integer values */
#define SCRAMBLING_PDSCH 0 /* also PUSCH */
#define SCRAMBLING_PCFICH 1
#define SCRAMBLING_PDCCH 2
#define SCRAMBLING_PBCH 3
#define SCRAMBLING_PMCH 4
#define SCRAMBLING_PUCCH 5
typedef struct SRSLTE_API {
srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
}scrambling_t;
typedef struct SRSLTE_API {
scrambling_t obj;
struct scrambling_init {
int hard;
int q;
int cell_id;
int nrnti;
int nMBSFN;
int channel;
int nof_symbols; // 7 normal 6 extended
} init;
void *input; // input type may be uint8_t or float depending on hard
int in_len;
struct scrambling_ctrl_in {
int subframe;
} ctrl_in;
void *output;
int out_len;
}scrambling_hl;
#endif // SCRAMBLING_ #endif // SCRAMBLING_

@ -41,17 +41,12 @@
#include "srslte/utils/bit.h" #include "srslte/utils/bit.h"
#include "srslte/utils/convolution.h" #include "srslte/utils/convolution.h"
#include "srslte/utils/debug.h" #include "srslte/utils/debug.h"
#include "srslte/utils/dft.h"
#include "srslte/utils/matrix.h"
#include "srslte/utils/mux.h"
#include "srslte/utils/cexptab.h" #include "srslte/utils/cexptab.h"
#include "srslte/utils/pack.h"
#include "srslte/utils/vector.h" #include "srslte/utils/vector.h"
#include "srslte/common/timestamp.h" #include "srslte/common/timestamp.h"
#include "srslte/common/sequence.h" #include "srslte/common/sequence.h"
#include "srslte/common/phy_common.h" #include "srslte/common/phy_common.h"
#include "srslte/common/fft.h"
#include "srslte/ch_estimation/chest_dl.h" #include "srslte/ch_estimation/chest_dl.h"
#include "srslte/ch_estimation/refsignal_dl.h" #include "srslte/ch_estimation/refsignal_dl.h"
@ -72,8 +67,9 @@
#include "srslte/fec/rm_conv.h" #include "srslte/fec/rm_conv.h"
#include "srslte/fec/rm_turbo.h" #include "srslte/fec/rm_turbo.h"
#include "srslte/filter/filter2d.h" #include "srslte/dft/dft_precoding.h"
#include "srslte/filter/dft_precoding.h" #include "srslte/dft/ofdm.h"
#include "srslte/dft/dft.h"
#include "srslte/io/binsource.h" #include "srslte/io/binsource.h"
#include "srslte/io/filesink.h" #include "srslte/io/filesink.h"

@ -37,32 +37,32 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
/** If the frequency is changed more than the tolerance, a new table is generated */ /** If the frequency is changed more than the tolerance, a new table is generated */
#define CFO_TOLERANCE 0.00001 #define SRSLTE_CFO_TOLERANCE 0.00001
#define CFO_CEXPTAB_SIZE 4096 #define SRSLTE_CFO_CEXPTAB_SIZE 4096
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
float last_freq; float last_freq;
float tol; float tol;
int nsamples; int nsamples;
cexptab_t tab; srslte_cexptab_t tab;
cf_t *cur_cexp; cf_t *cur_cexp;
}cfo_t; }srslte_cfo_t;
SRSLTE_API int cfo_init(cfo_t *h, SRSLTE_API int srslte_cfo_init(srslte_cfo_t *h,
uint32_t nsamples); uint32_t nsamples);
SRSLTE_API void cfo_free(cfo_t *h); SRSLTE_API void srslte_cfo_free(srslte_cfo_t *h);
SRSLTE_API int cfo_realloc(cfo_t *h, SRSLTE_API int srslte_cfo_realloc(srslte_cfo_t *h,
uint32_t samples); uint32_t samples);
SRSLTE_API void cfo_set_tol(cfo_t *h, SRSLTE_API void srslte_cfo_set_tol(srslte_cfo_t *h,
float tol); float tol);
SRSLTE_API void cfo_correct(cfo_t *h, SRSLTE_API void srslte_cfo_correct(srslte_cfo_t *h,
cf_t *input, cf_t *input,
cf_t *output, cf_t *output,
float freq); float freq);
#endif // CFO_ #endif // CFO_

@ -40,21 +40,21 @@ typedef _Complex float cf_t; /* this is only a shortcut */
#define CONVOLUTION_FFT #define CONVOLUTION_FFT
#define PSS_LEN 62 #define SRSLTE_PSS_LEN 62
#define PSS_RE 6*12 #define SRSLTE_PSS_RE (6*12)
/* PSS processing options */ /* PSS processing options */
#define PSS_ACCUMULATE_ABS // If enabled, accumulates the correlation absolute value on consecutive calls to pss_synch_find_pss #define SRSLTE_PSS_ACCUMULATE_ABS // If enabled, accumulates the correlation absolute value on consecutive calls to srslte_pss_synch_find_pss
#define PSS_ABS_SQUARE // If enabled, compute abs square, otherwise computes absolute value only #define SRSLTE_PSS_ABS_SQUARE // If enabled, compute abs square, otherwise computes absolute value only
#define PSS_RETURN_PSR // If enabled returns peak to side-lobe ratio, otherwise returns absolute peak value #define SRSLTE_PSS_RETURN_PSR // If enabled returns peak to side-lobe ratio, otherwise returns absolute peak value
/** /**
* The pss_synch_t object provides functions for fast computation of the crosscorrelation * The srslte_pss_synch_t object provides functions for fast computation of the crosscorrelation
* between the PSS and received signal and CFO estimation. Also, the function pss_synch_periodic() is designed * between the PSS and received signal and CFO estimation. Also, the function srslte_pss_synch_tperiodic() is designed
* to be called periodically every subframe, taking care of the correct data alignment with respect * to be called periodically every subframe, taking care of the correct data alignment with respect
* to the PSS sequence. * to the PSS sequence.
* *
@ -70,14 +70,14 @@ typedef struct SRSLTE_API {
srslte_dft_plan_t dftp_input; srslte_dft_plan_t dftp_input;
#ifdef CONVOLUTION_FFT #ifdef CONVOLUTION_FFT
conv_fft_cc_t conv_fft; srslte_conv_fft_cc_t conv_fft;
#endif #endif
uint32_t frame_size; uint32_t frame_size;
uint32_t N_id_2; uint32_t N_id_2;
uint32_t fft_size; uint32_t fft_size;
cf_t pss_signal_time[3][PSS_LEN]; cf_t pss_signal_time[3][SRSLTE_PSS_LEN];
cf_t *pss_signal_freq[3]; // One sequence for each N_id_2 cf_t *pss_signal_freq[3]; // One sequence for each N_id_2
cf_t *tmp_input; cf_t *tmp_input;
cf_t *conv_output; cf_t *conv_output;
@ -85,53 +85,53 @@ typedef struct SRSLTE_API {
float ema_alpha; float ema_alpha;
float *conv_output_avg; float *conv_output_avg;
float peak_value; float peak_value;
}pss_synch_t; }srslte_pss_synch_t;
typedef enum { PSS_TX, PSS_RX } pss_direction_t; typedef enum { PSS_TX, PSS_RX } pss_direction_t;
/* Basic functionality */ /* Basic functionality */
SRSLTE_API int pss_synch_init_fft(pss_synch_t *q, SRSLTE_API int srslte_pss_synch_init_fft(srslte_pss_synch_t *q,
uint32_t frame_size, uint32_t frame_size,
uint32_t fft_size); uint32_t fft_size);
SRSLTE_API int pss_synch_init(pss_synch_t *q, SRSLTE_API int srslte_pss_synch_init(srslte_pss_synch_t *q,
uint32_t frame_size); uint32_t frame_size);
SRSLTE_API void pss_synch_free(pss_synch_t *q); SRSLTE_API void srslte_pss_synch_free(srslte_pss_synch_t *q);
SRSLTE_API void pss_synch_reset(pss_synch_t *q); SRSLTE_API void srslte_pss_synch_reset(srslte_pss_synch_t *q);
SRSLTE_API int pss_generate(cf_t *signal, SRSLTE_API int srslte_pss_generate(cf_t *signal,
uint32_t N_id_2); uint32_t N_id_2);
SRSLTE_API void pss_put_slot(cf_t *pss_signal, SRSLTE_API void srslte_pss_put_slot(cf_t *pss_signal,
cf_t *slot, cf_t *slot,
uint32_t nof_prb, uint32_t nof_prb,
srslte_cp_t cp); srslte_cp_t cp);
SRSLTE_API void pss_synch_set_ema_alpha(pss_synch_t *q, SRSLTE_API void srslte_pss_synch_set_ema_alpha(srslte_pss_synch_t *q,
float alpha); float alpha);
SRSLTE_API int pss_synch_set_N_id_2(pss_synch_t *q, SRSLTE_API int srslte_pss_synch_set_N_id_2(srslte_pss_synch_t *q,
uint32_t N_id_2); uint32_t N_id_2);
SRSLTE_API int pss_synch_find_pss(pss_synch_t *q, SRSLTE_API int srslte_pss_synch_find_pss(srslte_pss_synch_t *q,
cf_t *input, cf_t *input,
float *corr_peak_value); float *corr_peak_value);
SRSLTE_API int pss_synch_chest(pss_synch_t *q, SRSLTE_API int srslte_pss_synch_chest(srslte_pss_synch_t *q,
cf_t *input, cf_t *input,
cf_t ce[PSS_LEN]); cf_t ce[SRSLTE_PSS_LEN]);
SRSLTE_API float pss_synch_cfo_compute(pss_synch_t* q, SRSLTE_API float srslte_pss_synch_cfo_compute(srslte_pss_synch_t* q,
cf_t *pss_recv); cf_t *pss_recv);
/* High-level API */ /* High-level API */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
pss_synch_t obj; srslte_pss_synch_t obj;
struct pss_synch_init { struct srslte_pss_synch_init {
int frame_size; // if 0, 2048 int frame_size; // if 0, 2048
int unsync_nof_pkts; int unsync_nof_pkts;
int N_id_2; int N_id_2;
@ -139,19 +139,19 @@ typedef struct SRSLTE_API {
} init; } init;
cf_t *input; cf_t *input;
int in_len; int in_len;
struct pss_synch_ctrl_in { struct srslte_pss_synch_tctrl_in {
int correlation_threshold; int correlation_threshold;
float manual_cfo; float manual_cfo;
} ctrl_in; } ctrl_in;
cf_t *output; cf_t *output;
int out_len; int out_len;
}pss_synch_hl; }srslte_pss_synch_hl;
#define DEFAULT_FRAME_SIZE 2048 #define DEFAULT_FRAME_SIZE 2048
SRSLTE_API int pss_synch_initialize(pss_synch_hl* h); SRSLTE_API int srslte_pss_synch_initialize(srslte_pss_synch_hl* h);
SRSLTE_API int pss_synch_work(pss_synch_hl* hl); SRSLTE_API int srslte_pss_synch_twork(srslte_pss_synch_hl* hl);
SRSLTE_API int pss_synch_stop(pss_synch_hl* hl); SRSLTE_API int srslte_pss_synch_tstop(srslte_pss_synch_hl* hl);
#endif // PSS_ #endif // PSS_

@ -31,7 +31,13 @@
#include "srslte/config.h" #include "srslte/config.h"
SRSLTE_API float sfo_estimate(int *t0, int len, float period); SRSLTE_API float srslte_sfo_estimate(int *t0,
SRSLTE_API float sfo_estimate_period(int *t0, int *t, int len, float period); int len,
float period);
SRSLTE_API float srslte_sfo_estimate_period(int *t0,
int *t,
int len,
float period);
#endif // SFO_ #endif // SFO_

@ -34,29 +34,29 @@
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/common/phy_common.h" #include "srslte/common/phy_common.h"
#include "srslte/utils/dft.h" #include "srslte/dft/dft.h"
typedef _Complex float cf_t; /* this is only a shortcut */ typedef _Complex float cf_t; /* this is only a shortcut */
#define N_SSS 31 #define SRSLTE_SSS_N 31
#define SSS_LEN 2*N_SSS #define SRSLTE_SSS_LEN 2*SRSLTE_SSS_N
struct sss_tables{ typedef struct SRSLTE_API {
int z1[N_SSS][N_SSS]; int z1[SRSLTE_SSS_N][SRSLTE_SSS_N];
int c[2][N_SSS]; int c[2][SRSLTE_SSS_N];
int s[N_SSS][N_SSS]; int s[SRSLTE_SSS_N][SRSLTE_SSS_N];
}; }srslte_sss_tables_t;
/* Allocate 32 complex to make it multiple of 32-byte AVX instructions alignment requirement. /* Allocate 32 complex to make it multiple of 32-byte AVX instructions alignment requirement.
* Should use vec_malloc() to make it platform agnostic. * Should use srslte_vec_malloc() to make it platform agnostic.
*/ */
struct fc_tables{ typedef struct SRSLTE_API {
float z1[N_SSS][N_SSS]; float z1[SRSLTE_SSS_N][SRSLTE_SSS_N];
float c[2][N_SSS]; float c[2][SRSLTE_SSS_N];
float s[N_SSS][N_SSS]; float s[SRSLTE_SSS_N][SRSLTE_SSS_N];
float sd[N_SSS][N_SSS-1]; float sd[SRSLTE_SSS_N][SRSLTE_SSS_N-1];
}; }srslte_sss_fc_tables_t;
/* Low-level API */ /* Low-level API */
@ -72,107 +72,107 @@ typedef struct SRSLTE_API {
uint32_t N_id_2; uint32_t N_id_2;
uint32_t N_id_1_table[30][30]; uint32_t N_id_1_table[30][30];
struct fc_tables fc_tables[3]; // one for each N_id_2 srslte_sss_fc_tables_t fc_tables[3]; // one for each N_id_2
float corr_output_m0[N_SSS]; float corr_output_m0[SRSLTE_SSS_N];
float corr_output_m1[N_SSS]; float corr_output_m1[SRSLTE_SSS_N];
}sss_synch_t; }srslte_sss_synch_t;
/* Basic functionality */ /* Basic functionality */
SRSLTE_API int sss_synch_init(sss_synch_t *q, SRSLTE_API int srslte_sss_synch_init(srslte_sss_synch_t *q,
uint32_t fft_size); uint32_t fft_size);
SRSLTE_API int sss_synch_realloc(sss_synch_t *q, SRSLTE_API int srslte_sss_synch_realloc(srslte_sss_synch_t *q,
uint32_t fft_size); uint32_t fft_size);
SRSLTE_API void sss_synch_free(sss_synch_t *q); SRSLTE_API void srslte_sss_synch_free(srslte_sss_synch_t *q);
SRSLTE_API void sss_generate(float *signal0, SRSLTE_API void srslte_sss_generate(float *signal0,
float *signal5, float *signal5,
uint32_t cell_id); uint32_t cell_id);
SRSLTE_API void sss_put_slot(float *sss, SRSLTE_API void srslte_sss_put_slot(float *sss,
cf_t *symbol, cf_t *symbol,
uint32_t nof_prb, uint32_t nof_prb,
srslte_cp_t cp); srslte_cp_t cp);
SRSLTE_API int sss_synch_set_N_id_2(sss_synch_t *q, SRSLTE_API int srslte_sss_synch_set_N_id_2(srslte_sss_synch_t *q,
uint32_t N_id_2); uint32_t N_id_2);
SRSLTE_API int sss_synch_m0m1_partial(sss_synch_t *q, SRSLTE_API int srslte_sss_synch_m0m1_partial(srslte_sss_synch_t *q,
cf_t *input, cf_t *input,
uint32_t M, uint32_t M,
cf_t ce[2*N_SSS], cf_t ce[2*SRSLTE_SSS_N],
uint32_t *m0, uint32_t *m0,
float *m0_value, float *m0_value,
uint32_t *m1, uint32_t *m1,
float *m1_value); float *m1_value);
SRSLTE_API int sss_synch_m0m1_diff_coh(sss_synch_t *q, SRSLTE_API int srslte_sss_synch_m0m1_diff_coh(srslte_sss_synch_t *q,
cf_t *input, cf_t *input,
cf_t ce[2*N_SSS], cf_t ce[2*SRSLTE_SSS_N],
uint32_t *m0, uint32_t *m0,
float *m0_value, float *m0_value,
uint32_t *m1, uint32_t *m1,
float *m1_value); float *m1_value);
SRSLTE_API int sss_synch_m0m1_diff(sss_synch_t *q, SRSLTE_API int srslte_sss_synch_m0m1_diff(srslte_sss_synch_t *q,
cf_t *input, cf_t *input,
uint32_t *m0, uint32_t *m0,
float *m0_value, float *m0_value,
uint32_t *m1, uint32_t *m1,
float *m1_value); float *m1_value);
SRSLTE_API uint32_t sss_synch_subframe(uint32_t m0, SRSLTE_API uint32_t srslte_sss_synch_subframe(uint32_t m0,
uint32_t m1);
SRSLTE_API int srslte_sss_synch_N_id_1(srslte_sss_synch_t *q,
uint32_t m0,
uint32_t m1); uint32_t m1);
SRSLTE_API int sss_synch_N_id_1(sss_synch_t *q, SRSLTE_API int srslte_sss_synch_frame(srslte_sss_synch_t *q,
uint32_t m0, cf_t *input,
uint32_t m1); uint32_t *subframe_idx,
uint32_t *N_id_1);
SRSLTE_API int sss_synch_frame(sss_synch_t *q,
cf_t *input,
uint32_t *subframe_idx,
uint32_t *N_id_1);
SRSLTE_API void sss_synch_set_threshold(sss_synch_t *q, SRSLTE_API void srslte_sss_synch_set_threshold(srslte_sss_synch_t *q,
float threshold); float threshold);
SRSLTE_API void sss_synch_set_symbol_sz(sss_synch_t *q, SRSLTE_API void srslte_sss_synch_set_symbol_sz(srslte_sss_synch_t *q,
uint32_t symbol_sz); uint32_t symbol_sz);
SRSLTE_API void sss_synch_set_subframe_sz(sss_synch_t *q, SRSLTE_API void srslte_sss_synch_set_subframe_sz(srslte_sss_synch_t *q,
uint32_t subframe_sz); uint32_t subframe_sz);
/* High-level API */ /* High-level API */
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
sss_synch_t obj; srslte_sss_synch_t obj;
struct sss_synch_init { struct srslte_sss_synch_init {
uint32_t N_id_2; uint32_t N_id_2;
} init; } init;
cf_t *input; cf_t *input;
uint32_t in_len; uint32_t in_len;
struct sss_synch_ctrl_in { struct srslte_sss_synch_ctrl_in {
uint32_t symbol_sz; uint32_t symbol_sz;
uint32_t subframe_sz; uint32_t subframe_sz;
uint32_t correlation_threshold; uint32_t correlation_threshold;
} ctrl_in; } ctrl_in;
struct sss_synch_ctrl_out { struct srslte_sss_synch_ctrl_out {
uint32_t subframe_idx; uint32_t subframe_idx;
uint32_t N_id_1; uint32_t N_id_1;
} ctrl_out; } ctrl_out;
}sss_synch_hl; }srslte_sss_synch_hl;
#define DEFAULT_FRAME_SIZE 2048 #define DEFAULT_FRAME_SIZE 2048
SRSLTE_API int sss_synch_initialize(sss_synch_hl* h); SRSLTE_API int srslte_sss_synch_initialize(srslte_sss_synch_hl* h);
SRSLTE_API int sss_synch_work(sss_synch_hl* hl); SRSLTE_API int srslte_sss_synch_work(srslte_sss_synch_hl* hl);
SRSLTE_API int sss_synch_stop(sss_synch_hl* hl); SRSLTE_API int srslte_sss_synch_stop(srslte_sss_synch_hl* hl);
#endif // SSS_ #endif // SSS_

@ -37,8 +37,8 @@
#include "srslte/sync/sss.h" #include "srslte/sync/sss.h"
#include "srslte/sync/cfo.h" #include "srslte/sync/cfo.h"
#define FFT_SIZE_MIN 64 #define SRSLTE_SYNC_FFT_SZ_MIN 64
#define FFT_SIZE_MAX 2048 #define SRSLTE_SYNC_FFT_SZ_MAX 2048
/** /**
* *
@ -55,8 +55,8 @@
typedef enum {SSS_DIFF=0, SSS_PARTIAL_3=2, SSS_FULL=1} sss_alg_t; typedef enum {SSS_DIFF=0, SSS_PARTIAL_3=2, SSS_FULL=1} sss_alg_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
pss_synch_t pss; srslte_pss_synch_t pss;
sss_synch_t sss; srslte_sss_synch_t sss;
float threshold; float threshold;
float peak_value; float peak_value;
float mean_peak_value; float mean_peak_value;
@ -66,7 +66,7 @@ typedef struct SRSLTE_API {
uint32_t fft_size; uint32_t fft_size;
uint32_t frame_size; uint32_t frame_size;
float mean_cfo; float mean_cfo;
cfo_t cfocorr; srslte_cfo_t cfocorr;
sss_alg_t sss_alg; sss_alg_t sss_alg;
bool detect_cp; bool detect_cp;
bool sss_en; bool sss_en;
@ -79,79 +79,80 @@ typedef struct SRSLTE_API {
float M_norm_avg; float M_norm_avg;
float M_ext_avg; float M_ext_avg;
}sync_t; }srslte_sync_t;
SRSLTE_API int sync_init(sync_t *q, SRSLTE_API int srslte_sync_init(srslte_sync_t *q,
uint32_t frame_size, uint32_t frame_size,
uint32_t fft_size); uint32_t fft_size);
SRSLTE_API void sync_free(sync_t *q); SRSLTE_API void srslte_sync_free(srslte_sync_t *q);
SRSLTE_API void sync_reset(sync_t *q); SRSLTE_API void srslte_sync_reset(srslte_sync_t *q);
/* Finds a correlation peak in the input signal around position find_offset */ /* Finds a correlation peak in the input signal around position find_offset */
SRSLTE_API int sync_find(sync_t *q, SRSLTE_API int srslte_sync_find(srslte_sync_t *q,
cf_t *input, cf_t *input,
uint32_t find_offset, uint32_t find_offset,
uint32_t *peak_position); uint32_t *peak_position);
/* Estimates the CP length */ /* Estimates the CP length */
SRSLTE_API srslte_cp_t sync_detect_cp(sync_t *q, SRSLTE_API srslte_cp_t srslte_sync_detect_cp(srslte_sync_t *q,
cf_t *input, cf_t *input,
uint32_t peak_pos); uint32_t peak_pos);
/* Sets the threshold for peak comparison */ /* Sets the threshold for peak comparison */
SRSLTE_API void sync_set_threshold(sync_t *q, SRSLTE_API void srslte_sync_set_threshold(srslte_sync_t *q,
float threshold); float threshold);
/* Gets the subframe idx (0 or 5) */ /* Gets the subframe idx (0 or 5) */
SRSLTE_API uint32_t sync_get_sf_idx(sync_t *q); SRSLTE_API uint32_t srslte_sync_get_sf_idx(srslte_sync_t *q);
/* Gets the last peak value */ /* Gets the last peak value */
SRSLTE_API float sync_get_last_peak_value(sync_t *q); SRSLTE_API float srslte_sync_get_last_peak_value(srslte_sync_t *q);
/* Gets the mean peak value */ /* Gets the mean peak value */
SRSLTE_API float sync_get_peak_value(sync_t *q); SRSLTE_API float srslte_sync_get_peak_value(srslte_sync_t *q);
/* Choose SSS detection algorithm */ /* Choose SSS detection algorithm */
SRSLTE_API void sync_set_sss_algorithm(sync_t *q, SRSLTE_API void srslte_sync_set_sss_algorithm(srslte_sync_t *q,
sss_alg_t alg); sss_alg_t alg);
/* Sets PSS exponential averaging alpha weight */ /* Sets PSS exponential averaging alpha weight */
SRSLTE_API void sync_set_em_alpha(sync_t *q, SRSLTE_API void srslte_sync_set_em_alpha(srslte_sync_t *q,
float alpha); float alpha);
/* Sets the N_id_2 to search for */ /* Sets the N_id_2 to search for */
SRSLTE_API int sync_set_N_id_2(sync_t *q, SRSLTE_API int srslte_sync_set_N_id_2(srslte_sync_t *q,
uint32_t N_id_2); uint32_t N_id_2);
/* Gets the Physical CellId from the last call to synch_run() */ /* Gets the Physical CellId from the last call to synch_run() */
SRSLTE_API int sync_get_cell_id(sync_t *q); SRSLTE_API int srslte_sync_get_cell_id(srslte_sync_t *q);
/* Gets the CFO estimation from the last call to synch_run() */ /* Gets the CFO estimation from the last call to synch_run() */
SRSLTE_API float sync_get_cfo(sync_t *q); SRSLTE_API float srslte_sync_get_cfo(srslte_sync_t *q);
/* Gets the CP length estimation from the last call to synch_run() */ /* Gets the CP length estimation from the last call to synch_run() */
SRSLTE_API srslte_cp_t sync_get_cp(sync_t *q); SRSLTE_API srslte_cp_t srslte_sync_get_cp(srslte_sync_t *q);
/* Sets the CP length estimation (must do it if disabled) */ /* Sets the CP length estimation (must do it if disabled) */
SRSLTE_API void sync_set_cp(sync_t *q, srslte_cp_t cp); SRSLTE_API void srslte_sync_set_cp(srslte_sync_t *q,
srslte_cp_t cp);
/* Enables/Disables SSS detection */ /* Enables/Disables SSS detection */
SRSLTE_API void sync_sss_en(sync_t *q, SRSLTE_API void srslte_sync_sss_en(srslte_sync_t *q,
bool enabled); bool enabled);
SRSLTE_API bool sync_sss_detected(sync_t *q); SRSLTE_API bool srslte_sync_sss_detected(srslte_sync_t *q);
SRSLTE_API bool sync_sss_is_en(sync_t *q); SRSLTE_API bool srslte_sync_sss_is_en(srslte_sync_t *q);
/* Enables/Disables CP detection */ /* Enables/Disables CP detection */
SRSLTE_API void sync_cp_en(sync_t *q, SRSLTE_API void srslte_sync_cp_en(srslte_sync_t *q,
bool enabled); bool enabled);
SRSLTE_API void sync_correct_cfo(sync_t *q, SRSLTE_API void srslte_sync_correct_cfo(srslte_sync_t *q,
bool enabled); bool enabled);
#endif // SYNC_ #endif // SYNC_

@ -36,7 +36,7 @@
#include "srslte/sync/cfo.h" #include "srslte/sync/cfo.h"
#include "srslte/ch_estimation/chest_dl.h" #include "srslte/ch_estimation/chest_dl.h"
#include "srslte/phch/pbch.h" #include "srslte/phch/pbch.h"
#include "srslte/common/fft.h" #include "srslte/dft/ofdm.h"
/************************************************************ /************************************************************
* *
@ -44,8 +44,8 @@
* several synchronized frames and obtains the most common cell_id * several synchronized frames and obtains the most common cell_id
* and cp length. * and cp length.
* *
* The I/O stream device sampling frequency must be set to 1.92 MHz (CS_SAMP_FREQ constant) * The I/O stream device sampling frequency must be set to 1.92 MHz (SRSLTE_CS_SAMP_FREQ constant)
* before calling to ue_cell_search_scan() functions. * before calling to srslte_ue_cellsearch_scan() functions.
* *
************************************************************/ ************************************************************/
@ -53,14 +53,14 @@
* TODO: Check also peak offset * TODO: Check also peak offset
*/ */
#define CS_DEFAULT_MAXFRAMES_TOTAL 500 #define SRSLTE_CS_DEFAULT_MAXFRAMES_TOTAL 500
#define CS_DEFAULT_MAXFRAMES_DETECTED 50 #define SRSLTE_CS_DEFAULT_MAXFRAMES_DETECTED 50
#define CS_DEFAULT_NOFFRAMES_TOTAL 50 #define SRSLTE_CS_DEFAULT_NOFFRAMES_TOTAL 50
#define CS_DEFAULT_NOFFRAMES_DETECTED 10 #define SRSLTE_CS_DEFAULT_NOFFRAMES_DETECTED 10
#define CS_NOF_PRB 6 #define SRSLTE_CS_NOF_PRB 6
#define CS_SAMP_FREQ 1920000.0 #define SRSLTE_CS_SAMP_FREQ 1920000.0
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint32_t cell_id; uint32_t cell_id;
@ -68,11 +68,11 @@ typedef struct SRSLTE_API {
float peak; float peak;
float mode; float mode;
float psr; float psr;
} ue_cell_search_result_t; } srslte_ue_cellsearch_result_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
ue_sync_t ue_sync; srslte_ue_sync_t ue_sync;
uint32_t max_frames; uint32_t max_frames;
uint32_t nof_frames_to_scan; // number of 5 ms frames to scan uint32_t nof_frames_to_scan; // number of 5 ms frames to scan
@ -81,34 +81,34 @@ typedef struct SRSLTE_API {
uint32_t *mode_ntimes; uint32_t *mode_ntimes;
uint8_t *mode_counted; uint8_t *mode_counted;
ue_cell_search_result_t *candidates; srslte_ue_cellsearch_result_t *candidates;
} ue_cell_search_t; } srslte_ue_cellsearch_t;
SRSLTE_API int ue_cell_search_init(ue_cell_search_t *q, SRSLTE_API int srslte_ue_cellsearch_init(srslte_ue_cellsearch_t *q,
int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*), int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*),
void *stream_handler); void *stream_handler);
SRSLTE_API int ue_cell_search_init_max(ue_cell_search_t *q, SRSLTE_API int srslte_ue_cellsearch_init_max(srslte_ue_cellsearch_t *q,
uint32_t max_frames_total, uint32_t max_frames_total,
int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*), int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*),
void *stream_handler); void *stream_handler);
SRSLTE_API void ue_cell_search_free(ue_cell_search_t *q); SRSLTE_API void srslte_ue_cellsearch_free(srslte_ue_cellsearch_t *q);
SRSLTE_API int ue_cell_search_scan_N_id_2(ue_cell_search_t *q, SRSLTE_API int srslte_ue_cellsearch_scan_N_id_2(srslte_ue_cellsearch_t *q,
uint32_t N_id_2, uint32_t N_id_2,
ue_cell_search_result_t *found_cell); srslte_ue_cellsearch_result_t *found_cell);
SRSLTE_API int ue_cell_search_scan(ue_cell_search_t * q, SRSLTE_API int srslte_ue_cellsearch_scan(srslte_ue_cellsearch_t * q,
ue_cell_search_result_t found_cells[3], srslte_ue_cellsearch_result_t found_cells[3],
uint32_t *max_N_id_2); uint32_t *max_N_id_2);
SRSLTE_API int ue_cell_search_set_nof_frames_to_scan(ue_cell_search_t *q, SRSLTE_API int srslte_ue_cellsearch_set_nof_frames_to_scan(srslte_ue_cellsearch_t *q,
uint32_t nof_frames); uint32_t nof_frames);
SRSLTE_API void ue_cell_search_set_threshold(ue_cell_search_t *q, SRSLTE_API void srslte_ue_cellsearch_set_threshold(srslte_ue_cellsearch_t *q,
float threshold); float threshold);

@ -37,7 +37,7 @@
#include "srslte/ch_estimation/chest_dl.h" #include "srslte/ch_estimation/chest_dl.h"
#include "srslte/common/fft.h" #include "srslte/dft/ofdm.h"
#include "srslte/common/phy_common.h" #include "srslte/common/phy_common.h"
#include "srslte/phch/dci.h" #include "srslte/phch/dci.h"
@ -53,18 +53,18 @@
#include "srslte/config.h" #include "srslte/config.h"
#define NOF_HARQ_PROCESSES 8 #define SRSLTE_UE_UL_NOF_HARQ_PROCESSES 8
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
pcfich_t pcfich; srslte_pcfich_t pcfich;
pdcch_t pdcch; srslte_pdcch_t pdcch;
pdsch_t pdsch; srslte_pdsch_t pdsch;
harq_t harq_process[NOF_HARQ_PROCESSES]; srslte_harq_t harq_process[SRSLTE_UE_UL_NOF_HARQ_PROCESSES];
regs_t regs; srslte_regs_t regs;
srslte_fft_t fft; srslte_ofdm_t fft;
srslte_chest_dl_t chest; srslte_chest_dl_t chest;
ra_pdsch_t ra_dl; srslte_ra_pdsch_t ra_dl;
srslte_cell_t cell; srslte_cell_t cell;
@ -73,57 +73,57 @@ typedef struct SRSLTE_API {
uint64_t pkt_errors; uint64_t pkt_errors;
uint64_t pkts_total; uint64_t pkts_total;
uint64_t nof_pdcch_detected; uint64_t nof_detected;
uint16_t current_rnti; uint16_t current_rnti;
}ue_dl_t; }srs_ue_dl_t;
/* This function shall be called just after the initial synchronization */ /* This function shall be called just after the initial synchronization */
SRSLTE_API int ue_dl_init(ue_dl_t *q, SRSLTE_API int srs_ue_dl_init(srs_ue_dl_t *q,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void ue_dl_free(ue_dl_t *q); SRSLTE_API void srs_ue_dl_free(srs_ue_dl_t *q);
SRSLTE_API int ue_dl_decode_fft_estimate(ue_dl_t *q, SRSLTE_API int srs_ue_dl_decode_fft_estimate(srs_ue_dl_t *q,
cf_t *input, cf_t *input,
uint32_t sf_idx, uint32_t sf_idx,
uint32_t *cfi); uint32_t *cfi);
SRSLTE_API int ue_dl_decode_rnti_rv_packet(ue_dl_t *q, SRSLTE_API int srs_ue_dl_decode_rnti_rv_packet(srs_ue_dl_t *q,
dci_msg_t *dci_msg, srslte_dci_msg_t *dci_msg,
uint8_t *data, uint8_t *data,
uint32_t cfi, uint32_t cfi,
uint32_t sf_idx, uint32_t sf_idx,
uint16_t rnti, uint16_t rnti,
uint32_t rvidx); uint32_t rvidx);
SRSLTE_API int ue_dl_find_ul_dci(ue_dl_t *q, SRSLTE_API int srs_ue_dl_find_ul_dci(srs_ue_dl_t *q,
dci_msg_t *dci_msg, srslte_dci_msg_t *dci_msg,
uint32_t cfi, uint32_t cfi,
uint32_t sf_idx, uint32_t sf_idx,
uint16_t rnti); uint16_t rnti);
SRSLTE_API int ue_dl_decode(ue_dl_t * q, SRSLTE_API int srs_ue_dl_decode(srs_ue_dl_t * q,
cf_t *input, cf_t *input,
uint8_t *data, uint8_t *data,
uint32_t sf_idx); uint32_t sf_idx);
SRSLTE_API int ue_dl_decode_rnti(ue_dl_t * q, SRSLTE_API int srs_ue_dl_decode_rnti(srs_ue_dl_t * q,
cf_t *input, cf_t *input,
uint8_t *data, uint8_t *data,
uint32_t sf_idx, uint32_t sf_idx,
uint16_t rnti); uint16_t rnti);
SRSLTE_API int ue_dl_decode_rnti_rv(ue_dl_t * q, SRSLTE_API int srs_ue_dl_decode_rnti_rv(srs_ue_dl_t * q,
cf_t *input, cf_t *input,
uint8_t * data, uint8_t * data,
uint32_t sf_idx, uint32_t sf_idx,
uint16_t rnti, uint16_t rnti,
uint32_t rvidx); uint32_t rvidx);
SRSLTE_API void ue_dl_reset(ue_dl_t *q); SRSLTE_API void srs_ue_dl_reset(srs_ue_dl_t *q);
SRSLTE_API void ue_dl_set_rnti(ue_dl_t *q, SRSLTE_API void srs_ue_dl_set_rnti(srs_ue_dl_t *q,
uint16_t rnti); uint16_t rnti);
#endif #endif

@ -1,5 +1,5 @@
class ue_mac_itf class srslte_ue_mac_itf
{ {
public: public:
virtual void ready_to_send() = 0; virtual void ready_to_send() = 0;

@ -33,7 +33,7 @@
* *
* This object decodes the MIB from the PBCH of an LTE signal. * This object decodes the MIB from the PBCH of an LTE signal.
* *
* The function ue_mib_decode() shall be called multiple times, * The function srslte_ue_mib_decode() shall be called multiple times,
* each passing a number of samples multiple of 19200, sampled at 1.92 MHz * each passing a number of samples multiple of 19200, sampled at 1.92 MHz
* (that is, 10 ms of samples). * (that is, 10 ms of samples).
* *
@ -53,69 +53,69 @@
#include "srslte/sync/cfo.h" #include "srslte/sync/cfo.h"
#include "srslte/ch_estimation/chest_dl.h" #include "srslte/ch_estimation/chest_dl.h"
#include "srslte/phch/pbch.h" #include "srslte/phch/pbch.h"
#include "srslte/common/fft.h" #include "srslte/dft/ofdm.h"
#define MIB_SRSLTE_MAX_PORTS 4 #define SRSLTE_UE_MIB_MAX_PORTS 4
#define MIB_NOF_PRB 6 #define SRSLTE_UE_MIB_NOF_PRB 6
#define MIB_FOUND 1 #define SRSLTE_UE_MIB_FOUND 1
#define MIB_NOTFOUND 0 #define SRSLTE_UE_MIB_NOTFOUND 0
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
sync_t sfind; srslte_sync_t sfind;
cf_t *sf_symbols; cf_t *sf_symbols;
cf_t *ce[MIB_SRSLTE_MAX_PORTS]; cf_t *ce[SRSLTE_UE_MIB_MAX_PORTS];
srslte_fft_t fft; srslte_ofdm_t fft;
srslte_chest_dl_t chest; srslte_chest_dl_t chest;
pbch_t pbch; srslte_pbch_t pbch;
uint8_t bch_payload[BCH_PAYLOAD_LEN]; uint8_t bch_payload[BCH_PAYLOAD_LEN];
uint32_t nof_tx_ports; uint32_t nof_tx_ports;
uint32_t sfn_offset; uint32_t sfn_offset;
uint32_t frame_cnt; uint32_t frame_cnt;
} ue_mib_t; } srslte_ue_mib_t;
SRSLTE_API int ue_mib_init(ue_mib_t *q, SRSLTE_API int srslte_ue_mib_init(srslte_ue_mib_t *q,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void ue_mib_free(ue_mib_t *q); SRSLTE_API void srslte_ue_mib_free(srslte_ue_mib_t *q);
SRSLTE_API void ue_mib_reset(ue_mib_t * q); SRSLTE_API void srslte_ue_mib_reset(srslte_ue_mib_t * q);
SRSLTE_API int ue_mib_decode(ue_mib_t * q, SRSLTE_API int srslte_ue_mib_decode(srslte_ue_mib_t * q,
cf_t *input, cf_t *input,
uint8_t bch_payload[BCH_PAYLOAD_LEN], uint8_t bch_payload[BCH_PAYLOAD_LEN],
uint32_t *nof_tx_ports, uint32_t *nof_tx_ports,
uint32_t *sfn_offset); uint32_t *sfn_offset);
/* This interface uses ue_mib and ue_sync to first get synchronized subframes /* This interface uses ue_mib and ue_sync to first get synchronized subframes
* and then decode MIB * and then decode MIB
*/ */
typedef struct { typedef struct {
ue_mib_t ue_mib; srslte_ue_mib_t ue_mib;
ue_sync_t ue_sync; srslte_ue_sync_t ue_sync;
} ue_mib_sync_t; } srslte_ue_mib_sync_t;
SRSLTE_API int ue_mib_sync_init(ue_mib_sync_t *q, SRSLTE_API int srslte_ue_mib_sync_init(srslte_ue_mib_sync_t *q,
uint32_t cell_id, uint32_t cell_id,
srslte_cp_t cp, srslte_cp_t cp,
int (recv_callback)(void*, void*, uint32_t, srslte_timestamp_t *), int (recv_callback)(void*, void*, uint32_t, srslte_timestamp_t *),
void *stream_handler); void *stream_handler);
SRSLTE_API void ue_mib_sync_free(ue_mib_sync_t *q); SRSLTE_API void srslte_ue_mib_sync_free(srslte_ue_mib_sync_t *q);
SRSLTE_API void ue_mib_sync_reset(ue_mib_sync_t * q); SRSLTE_API void srslte_ue_mib_sync_reset(srslte_ue_mib_sync_t * q);
SRSLTE_API int ue_mib_sync_decode(ue_mib_sync_t * q, SRSLTE_API int srslte_ue_mib_sync_decode(srslte_ue_mib_sync_t * q,
uint32_t max_frames_timeout, uint32_t max_frames_timeout,
uint8_t bch_payload[BCH_PAYLOAD_LEN], uint8_t bch_payload[BCH_PAYLOAD_LEN],
uint32_t *nof_tx_ports, uint32_t *nof_tx_ports,
uint32_t *sfn_offset); uint32_t *sfn_offset);

@ -33,7 +33,7 @@
typedef _Complex float cf_t; typedef _Complex float cf_t;
class ue_phy class srslte_ue_phy
{ {
public: public:
@ -55,7 +55,7 @@ public:
bool is_tpc_pucch = false; bool is_tpc_pucch = false;
}; };
class pdcch_dl_search : public queue::element { class dl_search : public queue::element {
public: public:
set_crnti(uint16_t rnti); set_crnti(uint16_t rnti);
set_crnti_ra_procedure(uint16_t rnti); set_crnti_ra_procedure(uint16_t rnti);
@ -169,7 +169,7 @@ public:
void set_param(); void set_param();
pdcch_ul_search* get_pdcch_ul_search(uint32_t tti); pdcch_ul_search* get_pdcch_ul_search(uint32_t tti);
pdcch_dl_search* get_pdcch_dl_search(uint32_t tti); dl_search* get_dl_search(uint32_t tti);
ul_assignment* get_ul_assignment(uint32_t tti); ul_assignment* get_ul_assignment(uint32_t tti);
dl_assignment* get_dl_assignment(uint32_t tti); dl_assignment* get_dl_assignment(uint32_t tti);
phich_assignment* get_phich_assignment(uint32_t tti); phich_assignment* get_phich_assignment(uint32_t tti);
@ -183,11 +183,11 @@ private:
IDLE, MEASURE, RX_BCH, RXTX IDLE, MEASURE, RX_BCH, RXTX
} phy_state; } phy_state;
bool prach_initiated = false; bool srslte_prach_initiated = false;
bool prach_ready_to_send = false; bool prach_ready_to_send = false;
queue pdcch_ul_search; queue pdcch_ul_search;
queue pdcch_dl_search; queue dl_search;
queue ul_assignment; queue ul_assignment;
queue dl_assignment; queue dl_assignment;
queue phich_assignment; queue phich_assignment;

@ -35,7 +35,7 @@
#include "srslte/sync/cfo.h" #include "srslte/sync/cfo.h"
#include "srslte/ch_estimation/chest_dl.h" #include "srslte/ch_estimation/chest_dl.h"
#include "srslte/phch/pbch.h" #include "srslte/phch/pbch.h"
#include "srslte/common/fft.h" #include "srslte/dft/ofdm.h"
#include "srslte/common/timestamp.h" #include "srslte/common/timestamp.h"
#include "srslte/io/filesource.h" #include "srslte/io/filesource.h"
@ -43,26 +43,26 @@
* *
* This object automatically manages the cell synchronization procedure. * This object automatically manages the cell synchronization procedure.
* *
* The main function is ue_sync_get_buffer(), which returns a pointer * The main function is srslte_ue_sync_get_buffer(), which returns a pointer
* to the aligned subframe of samples (before FFT). This function * to the aligned subframe of samples (before FFT). This function
* should be called regularly, returning every 1 ms. It reads from the * should be called regularly, returning every 1 ms. It reads from the
* USRP, aligns the samples to the subframe and performs time/freq synch. * USRP, aligns the samples to the subframe and performs time/freq synch.
* *
* It is also possible to read the signal from a file using the init function * It is also possible to read the signal from a file using the init function
* ue_sync_init_file(). The sampling frequency is derived from the number of PRB. * srslte_ue_sync_init_file(). The sampling frequency is derived from the number of PRB.
* *
* The function returns 1 when the signal is correctly acquired and the * The function returns 1 when the signal is correctly acquired and the
* returned buffer is aligned with the subframe. * returned buffer is aligned with the subframe.
* *
*************************************************************/ *************************************************************/
typedef enum SRSLTE_API { SF_FIND, SF_TRACK} ue_sync_state_t; typedef enum SRSLTE_API { SF_FIND, SF_TRACK} srslte_ue_sync_state_t;
//#define MEASURE_EXEC_TIME //#define MEASURE_EXEC_TIME
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
sync_t sfind; srslte_sync_t sfind;
sync_t strack; srslte_sync_t strack;
void *stream; void *stream;
int (*recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*); int (*recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*);
@ -71,13 +71,13 @@ typedef struct SRSLTE_API {
srslte_filesource_t file_source; srslte_filesource_t file_source;
bool file_mode; bool file_mode;
ue_sync_state_t state; srslte_ue_sync_state_t state;
cf_t *input_buffer; cf_t *input_buffer;
uint32_t frame_len; uint32_t frame_len;
uint32_t fft_size; uint32_t fft_size;
uint32_t nof_recv_sf; // Number of subframes received each call to ue_sync_get_buffer uint32_t nof_recv_sf; // Number of subframes received each call to srslte_ue_sync_get_buffer
uint32_t nof_avg_find_frames; uint32_t nof_avg_find_frames;
uint32_t frame_find_cnt; uint32_t frame_find_cnt;
uint32_t sf_len; uint32_t sf_len;
@ -102,43 +102,43 @@ typedef struct SRSLTE_API {
#ifdef MEASURE_EXEC_TIME #ifdef MEASURE_EXEC_TIME
float mean_exec_time; float mean_exec_time;
#endif #endif
} ue_sync_t; } srslte_ue_sync_t;
SRSLTE_API int ue_sync_init(ue_sync_t *q, SRSLTE_API int srslte_ue_sync_init(srslte_ue_sync_t *q,
srslte_cell_t cell, srslte_cell_t cell,
int (recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*), int (recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*),
void *stream_handler); void *stream_handler);
SRSLTE_API int ue_sync_init_file(ue_sync_t *q, SRSLTE_API int srslte_ue_sync_init_file(srslte_ue_sync_t *q,
uint32_t nof_prb, uint32_t nof_prb,
char *file_name); char *file_name);
SRSLTE_API void ue_sync_free(ue_sync_t *q); SRSLTE_API void srslte_ue_sync_free(srslte_ue_sync_t *q);
SRSLTE_API uint32_t ue_sync_sf_len(ue_sync_t *q); SRSLTE_API uint32_t srslte_ue_sync_sf_len(srslte_ue_sync_t *q);
SRSLTE_API int ue_sync_get_buffer(ue_sync_t *q, SRSLTE_API int srslte_ue_sync_get_buffer(srslte_ue_sync_t *q,
cf_t **sf_symbols); cf_t **sf_symbols);
SRSLTE_API void ue_sync_reset(ue_sync_t *q); SRSLTE_API void srslte_ue_sync_reset(srslte_ue_sync_t *q);
SRSLTE_API void ue_sync_set_N_id_2(ue_sync_t *q, SRSLTE_API void ue_srslte_sync_set_N_id_2(srslte_ue_sync_t *q,
uint32_t N_id_2); uint32_t N_id_2);
SRSLTE_API void ue_sync_decode_sss_on_track(ue_sync_t *q, SRSLTE_API void srslte_ue_sync_decode_sss_on_track(srslte_ue_sync_t *q,
bool enabled); bool enabled);
SRSLTE_API ue_sync_state_t ue_sync_get_state(ue_sync_t *q); SRSLTE_API srslte_ue_sync_state_t srslte_ue_sync_get_state(srslte_ue_sync_t *q);
SRSLTE_API uint32_t ue_sync_get_sfidx(ue_sync_t *q); SRSLTE_API uint32_t srslte_ue_sync_get_sfidx(srslte_ue_sync_t *q);
SRSLTE_API float ue_sync_get_cfo(ue_sync_t *q); SRSLTE_API float srslte_ue_sync_get_cfo(srslte_ue_sync_t *q);
SRSLTE_API float ue_sync_get_sfo(ue_sync_t *q); SRSLTE_API float srslte_ue_sync_get_sfo(srslte_ue_sync_t *q);
SRSLTE_API void ue_sync_get_last_timestamp(ue_sync_t *q, SRSLTE_API void srslte_ue_sync_get_last_timestamp(srslte_ue_sync_t *q,
srslte_timestamp_t *timestamp); srslte_timestamp_t *timestamp);

@ -37,7 +37,7 @@
#include "srslte/common/phy_common.h" #include "srslte/common/phy_common.h"
#include "srslte/ch_estimation/chest_dl.h" #include "srslte/ch_estimation/chest_dl.h"
#include "srslte/common/fft.h" #include "srslte/dft/ofdm.h"
#include "srslte/ch_estimation/refsignal_ul.h" #include "srslte/ch_estimation/refsignal_ul.h"
#include "srslte/phch/pusch.h" #include "srslte/phch/pusch.h"
#include "srslte/phch/ra.h" #include "srslte/phch/ra.h"
@ -47,76 +47,76 @@
#include "srslte/config.h" #include "srslte/config.h"
#define NOF_HARQ_PROCESSES 8 #define SRSLTE_UE_UL_NOF_HARQ_PROCESSES 8
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
srslte_fft_t fft; srslte_ofdm_t fft;
cfo_t cfo; srslte_cfo_t cfo;
srslte_cell_t cell; srslte_cell_t cell;
bool normalize_en; bool normalize_en;
float current_cfo; float current_cfo;
srslte_refsignal_drms_pusch_cfg_t pusch_drms_cfg; srslte_refsignal_drms_pusch_cfg_t drms_cfg;
srslte_refsignal_ul_t drms; srslte_refsignal_ul_t drms;
harq_t harq_process[NOF_HARQ_PROCESSES]; srslte_harq_t harq_process[SRSLTE_UE_UL_NOF_HARQ_PROCESSES];
pusch_t pusch; srslte_pusch_t pusch;
cf_t *refsignal; cf_t *refsignal;
cf_t *sf_symbols; cf_t *sf_symbols;
uint16_t current_rnti; uint16_t current_rnti;
}ue_ul_t; }srslte_ue_ul_t;
/* This function shall be called just after the initial synchronization */ /* This function shall be called just after the initial synchronization */
SRSLTE_API int ue_ul_init(ue_ul_t *q, SRSLTE_API int srslte_ue_ul_init(srslte_ue_ul_t *q,
srslte_cell_t cell); srslte_cell_t cell);
SRSLTE_API void ue_ul_free(ue_ul_t *q); SRSLTE_API void srslte_ue_ul_free(srslte_ue_ul_t *q);
SRSLTE_API void ue_ul_set_cfo(ue_ul_t *q, SRSLTE_API void srslte_ue_ul_set_cfo(srslte_ue_ul_t *q,
float cur_cfo); float cur_cfo);
SRSLTE_API void ue_ul_set_normalization(ue_ul_t *q, SRSLTE_API void srslte_ue_ul_set_normalization(srslte_ue_ul_t *q,
bool enabled); bool enabled);
SRSLTE_API void ue_ul_set_pusch_cfg(ue_ul_t *q, SRSLTE_API void srslte_ue_ul_set_pusch_cfg(srslte_ue_ul_t *q,
srslte_refsignal_drms_pusch_cfg_t *pusch_drms_cfg, srslte_refsignal_drms_pusch_cfg_t *drms_cfg,
pusch_hopping_cfg_t *pusch_hopping_cfg); srslte_pusch_hopping_cfg_t *pusch_hopping_cfg);
SRSLTE_API int ue_ul_pusch_encode(ue_ul_t *q, SRSLTE_API int srslte_ue_ul_srslte_pusch_encode(srslte_ue_ul_t *q,
ra_pusch_t *ra_ul, srslte_ra_pusch_t *ra_ul,
uint8_t *data, uint8_t *data,
uint32_t sf_idx, uint32_t sf_idx,
cf_t *output_signal); cf_t *output_signal);
SRSLTE_API int ue_ul_pusch_encode_rnti(ue_ul_t *q, SRSLTE_API int srslte_ue_ul_srslte_pusch_encode_rnti(srslte_ue_ul_t *q,
ra_pusch_t *ra_ul, srslte_ra_pusch_t *ra_ul,
uint8_t *data, uint8_t *data,
uint32_t sf_idx, uint32_t sf_idx,
uint16_t rnti, uint16_t rnti,
cf_t *output_signal); cf_t *output_signal);
SRSLTE_API int ue_ul_pusch_uci_encode(ue_ul_t *q, SRSLTE_API int srslte_ue_ul_srslte_pusch_uci_encode(srslte_ue_ul_t *q,
ra_pusch_t *ra_ul, srslte_ra_pusch_t *ra_ul,
uint8_t *data, uint8_t *data,
uci_data_t uci_data, srslte_uci_data_t uci_data,
uint32_t sf_idx, uint32_t sf_idx,
cf_t *output_signal); cf_t *output_signal);
SRSLTE_API int ue_ul_pusch_uci_encode_rnti(ue_ul_t *q, SRSLTE_API int srslte_ue_ul_srslte_pusch_uci_encode_rnti(srslte_ue_ul_t *q,
ra_pusch_t *ra_ul, srslte_ra_pusch_t *ra_ul,
uint8_t *data, uint8_t *data,
uci_data_t uci_data, srslte_uci_data_t uci_data,
uint32_t sf_idx, uint32_t sf_idx,
uint16_t rnti, uint16_t rnti,
cf_t *output_signal); cf_t *output_signal);
SRSLTE_API void ue_ul_reset(ue_ul_t *q); SRSLTE_API void srslte_ue_ul_reset(srslte_ue_ul_t *q);
SRSLTE_API void ue_ul_set_rnti(ue_ul_t *q, SRSLTE_API void srslte_ue_ul_set_rnti(srslte_ue_ul_t *q,
uint16_t rnti); uint16_t rnti);
#endif #endif

@ -34,30 +34,30 @@
#include "srslte/config.h" #include "srslte/config.h"
SRSLTE_API void bit_pack_vector(uint8_t *bit_unpacked, SRSLTE_API void srslte_bit_pack_vector(uint8_t *srslte_bit_unpacked,
uint8_t *bits_packed, uint8_t *bits_packed,
int nof_bits); int nof_bits);
SRSLTE_API void bit_unpack_vector(uint8_t *bits_packed, SRSLTE_API void srslte_bit_unpack_vector(uint8_t *bits_packed,
uint8_t *bit_unpacked, uint8_t *srslte_bit_unpacked,
int nof_bits); int nof_bits);
SRSLTE_API uint32_t bit_unpack(uint8_t **bits, SRSLTE_API uint32_t srslte_bit_unpack(uint8_t **bits,
int nof_bits); int nof_bits);
SRSLTE_API void bit_pack(uint32_t value, SRSLTE_API void srslte_bit_pack(uint32_t value,
uint8_t **bits, uint8_t **bits,
int nof_bits); int nof_bits);
SRSLTE_API void bit_fprint(FILE *stream, SRSLTE_API void srslte_bit_fprint(FILE *stream,
uint8_t *bits, uint8_t *bits,
int nof_bits); int nof_bits);
SRSLTE_API uint32_t bit_diff(uint8_t *x, SRSLTE_API uint32_t srslte_bit_diff(uint8_t *x,
uint8_t *y, uint8_t *y,
int nbits); int nbits);
SRSLTE_API uint32_t bit_count(uint32_t n); SRSLTE_API uint32_t srslte_bit_count(uint32_t n);
#endif // BIT_ #endif // BIT_

@ -38,20 +38,20 @@ typedef _Complex float cf_t;
typedef struct SRSLTE_API { typedef struct SRSLTE_API {
uint32_t size; uint32_t size;
cf_t *tab; cf_t *tab;
}cexptab_t; }srslte_cexptab_t;
SRSLTE_API int cexptab_init(cexptab_t *nco, SRSLTE_API int srslte_cexptab_init(srslte_cexptab_t *nco,
uint32_t size); uint32_t size);
SRSLTE_API void cexptab_free(cexptab_t *nco); SRSLTE_API void srslte_cexptab_free(srslte_cexptab_t *nco);
SRSLTE_API void cexptab_gen(cexptab_t *nco, SRSLTE_API void srslte_cexptab_gen(srslte_cexptab_t *nco,
cf_t *x, cf_t *x,
float freq,
uint32_t len);
SRSLTE_API void cexptab_gen_direct(cf_t *x,
float freq, float freq,
uint32_t len); uint32_t len);
SRSLTE_API void srslte_cexptab_gen_direct(cf_t *x,
float freq,
uint32_t len);
#endif // CEXPTAB_ #endif // CEXPTAB_

@ -30,7 +30,7 @@
#define CONVOLUTION_H_ #define CONVOLUTION_H_
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/utils/dft.h" #include "srslte/dft/dft.h"
typedef _Complex float cf_t; typedef _Complex float cf_t;
@ -45,35 +45,35 @@ typedef struct SRSLTE_API {
srslte_dft_plan_t input_plan; srslte_dft_plan_t input_plan;
srslte_dft_plan_t filter_plan; srslte_dft_plan_t filter_plan;
srslte_dft_plan_t output_plan; srslte_dft_plan_t output_plan;
}conv_fft_cc_t; }srslte_conv_fft_cc_t;
SRSLTE_API int conv_fft_cc_init(conv_fft_cc_t *q, SRSLTE_API int srslte_conv_fft_cc_init(srslte_conv_fft_cc_t *q,
uint32_t input_len, uint32_t input_len,
uint32_t filter_len); uint32_t filter_len);
SRSLTE_API void conv_fft_cc_free(conv_fft_cc_t *q); SRSLTE_API void srslte_conv_fft_cc_free(srslte_conv_fft_cc_t *q);
SRSLTE_API uint32_t conv_fft_cc_run(conv_fft_cc_t *q, SRSLTE_API uint32_t srslte_conv_fft_cc_run(srslte_conv_fft_cc_t *q,
cf_t *input, cf_t *input,
cf_t *filter, cf_t *filter,
cf_t *output); cf_t *output);
SRSLTE_API uint32_t conv_cc(cf_t *input, SRSLTE_API uint32_t srslte_conv_cc(cf_t *input,
cf_t *filter, cf_t *filter,
cf_t *output, cf_t *output,
uint32_t input_len, uint32_t input_len,
uint32_t filter_len); uint32_t filter_len);
SRSLTE_API uint32_t conv_same_cf(cf_t *input, SRSLTE_API uint32_t srslte_conv_same_cf(cf_t *input,
float *filter, float *filter,
cf_t *output, cf_t *output,
uint32_t input_len, uint32_t input_len,
uint32_t filter_len); uint32_t filter_len);
SRSLTE_API uint32_t conv_same_cc(cf_t *input, SRSLTE_API uint32_t srslte_conv_same_cc(cf_t *input,
cf_t *filter, cf_t *filter,
cf_t *output, cf_t *output,
uint32_t input_len, uint32_t input_len,
uint32_t filter_len); uint32_t filter_len);
#endif // CONVOLUTION_H_ #endif // CONVOLUTION_H_

@ -31,36 +31,36 @@
#include <stdio.h> #include <stdio.h>
#include "srslte/config.h" #include "srslte/config.h"
#define VERBOSE_DEBUG 2 #define SRSLTE_VERBOSE_DEBUG 2
#define VERBOSE_INFO 1 #define SRSLTE_VERBOSE_INFO 1
#define VERBOSE_NONE 0 #define SRSLTE_VERBOSE_NONE 0
#include <sys/time.h> #include <sys/time.h>
SRSLTE_API void get_time_interval(struct timeval * tdata); SRSLTE_API void get_time_interval(struct timeval * tdata);
#ifndef DEBUG_DISABLED #ifndef SRSLTE_DEBUG_DISABLED
SRSLTE_API extern int verbose; SRSLTE_API extern int srslte_verbose;
#define VERBOSE_ISINFO() (verbose>=VERBOSE_INFO) #define SRSLTE_VERBOSE_ISINFO() (srslte_verbose>=SRSLTE_VERBOSE_INFO)
#define VERBOSE_ISDEBUG() (verbose>=VERBOSE_DEBUG) #define SRSLTE_VERBOSE_ISDEBUG() (srslte_verbose>=SRSLTE_VERBOSE_DEBUG)
#define VERBOSE_ISNONE() (verbose==VERBOSE_NONE) #define SRSLTE_VERBOSE_ISNONE() (srslte_verbose==SRSLTE_VERBOSE_NONE)
#define PRINT_DEBUG verbose=VERBOSE_DEBUG #define PRINT_DEBUG srslte_verbose=SRSLTE_VERBOSE_DEBUG
#define PRINT_INFO verbose=VERBOSE_INFO #define PRINT_INFO srslte_verbose=SRSLTE_VERBOSE_INFO
#define PRINT_NONE verbose=VERBOSE_NONE #define PRINT_NONE srslte_verbose=SRSLTE_VERBOSE_NONE
#define DEBUG(_fmt, ...) if (verbose >= VERBOSE_DEBUG) \ #define DEBUG(_fmt, ...) if (srslte_verbose >= SRSLTE_VERBOSE_DEBUG) \
fprintf(stdout, "[DEBUG]: " _fmt, __VA_ARGS__) fprintf(stdout, "[DEBUG]: " _fmt, __VA_ARGS__)
#define INFO(_fmt, ...) if (verbose >= VERBOSE_INFO) \ #define INFO(_fmt, ...) if (srslte_verbose >= SRSLTE_VERBOSE_INFO) \
fprintf(stdout, "[INFO]: " _fmt, __VA_ARGS__) fprintf(stdout, "[INFO]: " _fmt, __VA_ARGS__)
#else // DEBUG_DISABLED #else // SRSLTE_DEBUG_DISABLED
#define DEBUG #define DEBUG
#define INFO #define INFO
#endif // DEBUG_DISABLED #endif // SRSLTE_DEBUG_DISABLED
#endif // DEBUG_H #endif // DEBUG_H

@ -1,47 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The srsLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef MATRIX_
#define MATRIX_
#include <stdio.h>
#include "srslte/config.h"
typedef _Complex float cf_t;
SRSLTE_API int matrix_init(void ***m, int sz_x, int sz_y, int elem_sz);
SRSLTE_API void matrix_free(void **q, int sz_x);
SRSLTE_API void matrix_bzero(void **q, int sz_x, int sz_y, int elem_sz);
SRSLTE_API void matrix_fprintf_cf(FILE *f, cf_t **q, int sz_x, int sz_y);
SRSLTE_API void matrix_fprintf_f(FILE *f, float **q, int sz_x, int sz_y);
SRSLTE_API void matrix_copy(void **dst, void **src, int sz_x, int sz_y, int elem_sz);
SRSLTE_API void matrix_dotprod_cf(cf_t **x, cf_t **y, cf_t **out, int sz_x, int sz_y);
SRSLTE_API void matrix_dotprod_float(float **x, float **y, float **out, int sz_x, int sz_y);
SRSLTE_API void matrix_dotprod_int(int **x, int **y, int **out, int sz_x, int sz_y);
#endif // MATRIX_

@ -1,40 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The srsLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef MUX_
#define MUX_
#include "srslte/config.h"
SRSLTE_API void mux(void **input, void *output, int *input_lengths, int *input_padding_pre, int nof_inputs,
int sample_sz);
SRSLTE_API void demux(void *input, void **output, int *output_lengths,
int *output_padding_pre, int *output_padding_post, int nof_outputs,
int sample_sz);
#endif // MUX_

@ -1,42 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The srsLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef PACK_
#define PACK_
#include "srslte/config.h"
#include <stdint.h>
SRSLTE_API uint32_t unpack_bits(uint8_t **bits,
int nof_bits);
SRSLTE_API void pack_bits(uint32_t value,
uint8_t **bits,
int nof_bits);
#endif // PACK_

@ -30,7 +30,7 @@
#ifndef QUEUE_H #ifndef QUEUE_H
#define QUEUE_H #define QUEUE_H
class queue class srslte_queue
{ {
public: public:

@ -40,106 +40,106 @@ extern "C" {
typedef _Complex float cf_t; typedef _Complex float cf_t;
#define MAX(a,b) ((a)>(b)?(a):(b)) #define SRSLTE_MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b)) #define SRSLTE_MIN(a,b) ((a)<(b)?(a):(b))
// Cumulative moving average // Cumulative moving average
#define VEC_CMA(data, average, n) ((average) + ((data) - (average)) / ((n)+1)) #define SRSLTE_VEC_CMA(data, average, n) ((average) + ((data) - (average)) / ((n)+1))
// Exponential moving average // Exponential moving average
#define VEC_EMA(data, average, alpha) ((alpha)*(data)+(1-alpha)*(average)) #define SRSLTE_VEC_EMA(data, average, alpha) ((alpha)*(data)+(1-alpha)*(average))
/** Return the sum of all the elements */ /** Return the sum of all the elements */
SRSLTE_API int vec_acc_ii(int *x, uint32_t len); SRSLTE_API int srslte_vec_acc_ii(int *x, uint32_t len);
SRSLTE_API float vec_acc_ff(float *x, uint32_t len); SRSLTE_API float srslte_vec_acc_ff(float *x, uint32_t len);
SRSLTE_API cf_t vec_acc_cc(cf_t *x, uint32_t len); SRSLTE_API cf_t srslte_vec_acc_cc(cf_t *x, uint32_t len);
SRSLTE_API void *vec_malloc(uint32_t size); SRSLTE_API void *srslte_vec_malloc(uint32_t size);
SRSLTE_API void *vec_realloc(void *ptr, uint32_t old_size, uint32_t new_size); SRSLTE_API void *srslte_vec_realloc(void *ptr, uint32_t old_size, uint32_t new_size);
/* print vectors */ /* print vectors */
SRSLTE_API void vec_fprint_c(FILE *stream, cf_t *x, uint32_t len); SRSLTE_API void srslte_vec_fprint_c(FILE *stream, cf_t *x, uint32_t len);
SRSLTE_API void vec_fprint_f(FILE *stream, float *x, uint32_t len); SRSLTE_API void srslte_vec_fprint_f(FILE *stream, float *x, uint32_t len);
SRSLTE_API void vec_fprint_b(FILE *stream, uint8_t *x, uint32_t len); SRSLTE_API void srslte_vec_fprint_b(FILE *stream, uint8_t *x, uint32_t len);
SRSLTE_API void vec_fprint_byte(FILE *stream, uint8_t *x, uint32_t len); SRSLTE_API void srslte_vec_fprint_byte(FILE *stream, uint8_t *x, uint32_t len);
SRSLTE_API void vec_fprint_i(FILE *stream, int *x, uint32_t len); SRSLTE_API void srslte_vec_fprint_i(FILE *stream, int *x, uint32_t len);
SRSLTE_API void vec_fprint_hex(FILE *stream, uint8_t *x, uint32_t len); SRSLTE_API void srslte_vec_fprint_hex(FILE *stream, uint8_t *x, uint32_t len);
/* Saves a vector to a file */ /* Saves a vector to a file */
SRSLTE_API void vec_save_file(char *filename, void *buffer, uint32_t len); SRSLTE_API void srslte_vec_save_file(char *filename, void *buffer, uint32_t len);
/* sum two vectors */ /* sum two vectors */
SRSLTE_API void vec_sum_ch(uint8_t *x, uint8_t *y, char *z, uint32_t len); SRSLTE_API void srslte_vec_sum_ch(uint8_t *x, uint8_t *y, char *z, uint32_t len);
SRSLTE_API void vec_sum_fff(float *x, float *y, float *z, uint32_t len); SRSLTE_API void srslte_vec_sum_fff(float *x, float *y, float *z, uint32_t len);
SRSLTE_API void vec_sum_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); SRSLTE_API void srslte_vec_sum_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len);
/* substract two vectors z=x-y */ /* substract two vectors z=x-y */
SRSLTE_API void vec_sub_fff(float *x, float *y, float *z, uint32_t len); SRSLTE_API void srslte_vec_sub_fff(float *x, float *y, float *z, uint32_t len);
SRSLTE_API void vec_sub_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); SRSLTE_API void srslte_vec_sub_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len);
/* Square distance */ /* Square distance */
SRSLTE_API void vec_square_dist(cf_t symbol, cf_t *points, float *distance, uint32_t npoints); SRSLTE_API void srslte_vec_square_dist(cf_t symbol, cf_t *points, float *distance, uint32_t npoints);
/* scalar addition */ /* scalar addition */
SRSLTE_API void vec_sc_add_fff(float *x, float h, float *z, uint32_t len); SRSLTE_API void srslte_vec_sc_add_fff(float *x, float h, float *z, uint32_t len);
SRSLTE_API void vec_sc_add_cfc(cf_t *x, float h, cf_t *z, uint32_t len); SRSLTE_API void srslte_vec_sc_add_cfc(cf_t *x, float h, cf_t *z, uint32_t len);
SRSLTE_API void vec_sc_add_ccc(cf_t *x, cf_t h, cf_t *z, uint32_t len); SRSLTE_API void srslte_vec_sc_add_ccc(cf_t *x, cf_t h, cf_t *z, uint32_t len);
/* scalar product */ /* scalar product */
SRSLTE_API void vec_sc_prod_cfc(cf_t *x, float h, cf_t *z, uint32_t len); SRSLTE_API void srslte_vec_sc_prod_cfc(cf_t *x, float h, cf_t *z, uint32_t len);
SRSLTE_API void vec_sc_prod_ccc(cf_t *x, cf_t h, cf_t *z, uint32_t len); SRSLTE_API void srslte_vec_sc_prod_ccc(cf_t *x, cf_t h, cf_t *z, uint32_t len);
SRSLTE_API void vec_sc_prod_fff(float *x, float h, float *z, uint32_t len); SRSLTE_API void srslte_vec_sc_prod_fff(float *x, float h, float *z, uint32_t len);
SRSLTE_API void vec_convert_fi(float *x, int16_t *z, float scale, uint32_t len); SRSLTE_API void srslte_vec_convert_fi(float *x, int16_t *z, float scale, uint32_t len);
SRSLTE_API void vec_deinterleave_cf(cf_t *x, float *real, float *imag, uint32_t len); SRSLTE_API void srslte_vec_deinterleave_cf(cf_t *x, float *real, float *imag, uint32_t len);
SRSLTE_API void vec_deinterleave_real_cf(cf_t *x, float *real, uint32_t len); SRSLTE_API void srslte_vec_deinterleave_real_cf(cf_t *x, float *real, uint32_t len);
SRSLTE_API void vec_interleave_cf(float *real, float *imag, cf_t *x, uint32_t len); SRSLTE_API void srslte_vec_interleave_cf(float *real, float *imag, cf_t *x, uint32_t len);
/* vector product (element-wise) */ /* vector product (element-wise) */
SRSLTE_API void vec_prod_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); SRSLTE_API void srslte_vec_prod_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len);
/* vector product (element-wise) */ /* vector product (element-wise) */
SRSLTE_API void vec_prod_cfc(cf_t *x, float *y, cf_t *z, uint32_t len); SRSLTE_API void srslte_vec_prod_cfc(cf_t *x, float *y, cf_t *z, uint32_t len);
/* conjugate vector product (element-wise) */ /* conjugate vector product (element-wise) */
SRSLTE_API void vec_prod_conj_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len); SRSLTE_API void srslte_vec_prod_conj_ccc(cf_t *x, cf_t *y, cf_t *z, uint32_t len);
/* Dot-product */ /* Dot-product */
SRSLTE_API cf_t vec_dot_prod_cfc(cf_t *x, float *y, uint32_t len); SRSLTE_API cf_t srslte_vec_dot_prod_cfc(cf_t *x, float *y, uint32_t len);
SRSLTE_API cf_t vec_dot_prod_ccc(cf_t *x, cf_t *y, uint32_t len); SRSLTE_API cf_t srslte_vec_dot_prod_ccc(cf_t *x, cf_t *y, uint32_t len);
SRSLTE_API cf_t vec_dot_prod_conj_ccc(cf_t *x, cf_t *y, uint32_t len); SRSLTE_API cf_t srslte_vec_dot_prod_conj_ccc(cf_t *x, cf_t *y, uint32_t len);
SRSLTE_API float vec_dot_prod_fff(float *x, float *y, uint32_t len); SRSLTE_API float srslte_vec_dot_prod_fff(float *x, float *y, uint32_t len);
/* z=x/y vector division (element-wise) */ /* z=x/y vector division (element-wise) */
SRSLTE_API void vec_div_ccc(cf_t *x, cf_t *y, float *y_mod, cf_t *z, float *z_real, float *z_imag, uint32_t len); SRSLTE_API void srslte_vec_div_ccc(cf_t *x, cf_t *y, float *y_mod, cf_t *z, float *z_real, float *z_imag, uint32_t len);
void vec_div_cfc(cf_t *x, float *y, cf_t *z, float *z_real, float *z_imag, uint32_t len); void srslte_vec_div_cfc(cf_t *x, float *y, cf_t *z, float *z_real, float *z_imag, uint32_t len);
SRSLTE_API void vec_div_fff(float *x, float *y, float *z, uint32_t len); SRSLTE_API void srslte_vec_div_fff(float *x, float *y, float *z, uint32_t len);
/* conjugate */ /* conjugate */
SRSLTE_API void vec_conj_cc(cf_t *x, cf_t *y, uint32_t len); SRSLTE_API void srslte_vec_conj_cc(cf_t *x, cf_t *y, uint32_t len);
/* average vector power */ /* average vector power */
SRSLTE_API float vec_avg_power_cf(cf_t *x, uint32_t len); SRSLTE_API float srslte_vec_avg_power_cf(cf_t *x, uint32_t len);
/* return the index of the maximum value in the vector */ /* return the index of the maximum value in the vector */
SRSLTE_API uint32_t vec_max_fi(float *x, uint32_t len); SRSLTE_API uint32_t srslte_vec_max_fi(float *x, uint32_t len);
SRSLTE_API uint32_t vec_max_abs_ci(cf_t *x, uint32_t len); SRSLTE_API uint32_t srslte_vec_max_abs_ci(cf_t *x, uint32_t len);
/* maximum between two vectors */ /* maximum between two vectors */
SRSLTE_API void vec_max_fff(float *x, float *y, float *z, uint32_t len); SRSLTE_API void srslte_vec_max_fff(float *x, float *y, float *z, uint32_t len);
/* quantify vector of floats and convert to uint8_t */ /* quantify vector of floats and convert to uint8_t */
SRSLTE_API void vec_quant_fuc(float *in, uint8_t *out, float gain, float offset, float clip, uint32_t len); SRSLTE_API void srslte_vec_quant_fuc(float *in, uint8_t *out, float gain, float offset, float clip, uint32_t len);
/* magnitude of each vector element */ /* magnitude of each vector element */
SRSLTE_API void vec_abs_cf(cf_t *x, float *abs, uint32_t len); SRSLTE_API void srslte_vec_abs_cf(cf_t *x, float *abs, uint32_t len);
SRSLTE_API void vec_abs_square_cf(cf_t *x, float *abs_square, uint32_t len); SRSLTE_API void srslte_vec_abs_square_cf(cf_t *x, float *abs_square, uint32_t len);
/* argument of each vector element */ /* argument of each vector element */
SRSLTE_API void vec_arg_cf(cf_t *x, float *arg, uint32_t len); SRSLTE_API void srslte_vec_arg_cf(cf_t *x, float *arg, uint32_t len);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -81,10 +81,10 @@ void srslte_agc_lock(srslte_agc_t *q, bool enable) {
void srslte_agc_process(srslte_agc_t *q, cf_t *input, cf_t *output, uint32_t len) { void srslte_agc_process(srslte_agc_t *q, cf_t *input, cf_t *output, uint32_t len) {
// Apply current gain to input signal // Apply current gain to input signal
vec_sc_prod_cfc(input, q->gain, output, len); srslte_vec_sc_prod_cfc(input, q->gain, output, len);
// compute output energy estimate // compute output energy estimate
float y = sqrtf(crealf(vec_dot_prod_conj_ccc(output, output, len))/len); float y = sqrtf(crealf(srslte_vec_dot_prod_conj_ccc(output, output, len))/len);
if (q->isfirst) { if (q->isfirst) {
q->y_out = y; q->y_out = y;

@ -69,25 +69,25 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell)
goto clean_exit; goto clean_exit;
} }
q->tmp_freqavg = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(cell.nof_prb)); q->tmp_freqavg = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(cell.nof_prb));
if (!q->tmp_freqavg) { if (!q->tmp_freqavg) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
q->tmp_noise = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(cell.nof_prb)); q->tmp_noise = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(cell.nof_prb));
if (!q->tmp_noise) { if (!q->tmp_noise) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
for (int i=0;i<SRSLTE_CHEST_MAX_FILTER_TIME_LEN;i++) { for (int i=0;i<SRSLTE_CHEST_MAX_FILTER_TIME_LEN;i++) {
q->tmp_timeavg[i] = vec_malloc(sizeof(cf_t) * 2*cell.nof_prb); q->tmp_timeavg[i] = srslte_vec_malloc(sizeof(cf_t) * 2*cell.nof_prb);
if (!q->tmp_timeavg[i]) { if (!q->tmp_timeavg[i]) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
bzero(q->tmp_timeavg[i], sizeof(cf_t) * 2*cell.nof_prb); bzero(q->tmp_timeavg[i], sizeof(cf_t) * 2*cell.nof_prb);
} }
q->tmp_timeavg_mult = vec_malloc(sizeof(cf_t) * 2*cell.nof_prb); q->tmp_timeavg_mult = srslte_vec_malloc(sizeof(cf_t) * 2*cell.nof_prb);
if (!q->tmp_timeavg_mult) { if (!q->tmp_timeavg_mult) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
@ -95,17 +95,17 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell)
bzero(q->tmp_timeavg_mult, sizeof(cf_t) * 2*cell.nof_prb); bzero(q->tmp_timeavg_mult, sizeof(cf_t) * 2*cell.nof_prb);
for (int i=0;i<cell.nof_ports;i++) { for (int i=0;i<cell.nof_ports;i++) {
q->pilot_estimates[i] = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i)); q->pilot_estimates[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i));
if (!q->pilot_estimates[i]) { if (!q->pilot_estimates[i]) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
q->pilot_estimates_average[i] = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i)); q->pilot_estimates_average[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i));
if (!q->pilot_estimates_average[i]) { if (!q->pilot_estimates_average[i]) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
q->pilot_recv_signal[i] = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i)); q->pilot_recv_signal[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i));
if (!q->pilot_recv_signal[i]) { if (!q->pilot_recv_signal[i]) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
@ -210,10 +210,10 @@ int srslte_chest_dl_set_filter_time(srslte_chest_dl_t *q, float *filter, uint32_
/* Uses the difference between the averaged and non-averaged pilot estimates */ /* Uses the difference between the averaged and non-averaged pilot estimates */
static float estimate_noise_port(srslte_chest_dl_t *q, uint32_t port_id, cf_t *avg_pilots) { static float estimate_noise_port(srslte_chest_dl_t *q, uint32_t port_id, cf_t *avg_pilots) {
/* Use difference between averaged and noisy LS pilot estimates */ /* Use difference between averaged and noisy LS pilot estimates */
vec_sub_ccc(avg_pilots, q->pilot_estimates[port_id], srslte_vec_sub_ccc(avg_pilots, q->pilot_estimates[port_id],
q->tmp_noise, SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); q->tmp_noise, SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id));
return vec_avg_power_cf(q->tmp_noise, SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); return srslte_vec_avg_power_cf(q->tmp_noise, SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id));
} }
#else #else
@ -222,11 +222,11 @@ static float estimate_noise_port(srslte_chest_dl_t *q, uint32_t port_id, cf_t *a
static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) { static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) {
int k_sss = (SRSLTE_CP_NSYMB(q->cell.cp) - 2) * q->cell.nof_prb * SRSLTE_NRE + q->cell.nof_prb * SRSLTE_NRE / 2 - 31; 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 += srslte_vec_avg_power_cf(&input[k_sss-5], 5); // 5 empty SC before SSS
noise_power += vec_avg_power_cf(&input[k_sss+62], 5); // 5 empty SC after SSS noise_power += srslte_vec_avg_power_cf(&input[k_sss+62], 5); // 5 empty SC after SSS
int k_pss = (SRSLTE_CP_NSYMB(q->cell.cp) - 1) * q->cell.nof_prb * SRSLTE_NRE + q->cell.nof_prb * SRSLTE_NRE / 2 - 31; 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 += srslte_vec_avg_power_cf(&input[k_pss-5], 5); // 5 empty SC before PSS
noise_power += vec_avg_power_cf(&input[k_pss+62], 5); // 5 empty SC after PSS noise_power += srslte_vec_avg_power_cf(&input[k_pss+62], 5); // 5 empty SC after PSS
return noise_power; return noise_power;
} }
@ -245,7 +245,7 @@ static void average_pilots(srslte_chest_dl_t *q, uint32_t port_id)
for (l=0;l<srslte_refsignal_cs_nof_symbols(port_id);l++) { for (l=0;l<srslte_refsignal_cs_nof_symbols(port_id);l++) {
if (q->filter_freq_len > 0) { if (q->filter_freq_len > 0) {
/* Filter pilot estimates in frequency */ /* Filter pilot estimates in frequency */
conv_same_cf(&pilot_est(0), q->filter_freq, &pilot_tmp(0), nref, q->filter_freq_len); srslte_conv_same_cf(&pilot_est(0), q->filter_freq, &pilot_tmp(0), nref, q->filter_freq_len);
/* Adjust extremes using linear interpolation */ /* Adjust extremes using linear interpolation */
@ -275,8 +275,8 @@ static void average_pilots(srslte_chest_dl_t *q, uint32_t port_id)
/* Multiply all symbols by filter and add them */ /* Multiply all symbols by filter and add them */
bzero(&pilot_avg(0), nref * sizeof(cf_t)); bzero(&pilot_avg(0), nref * sizeof(cf_t));
for (i=0;i<q->filter_time_len;i++) { for (i=0;i<q->filter_time_len;i++) {
vec_sc_prod_cfc(q->tmp_timeavg[i], q->filter_time[i], q->tmp_timeavg[i], nref); srslte_vec_sc_prod_cfc(q->tmp_timeavg[i], q->filter_time[i], q->tmp_timeavg[i], nref);
vec_sum_ccc(q->tmp_timeavg[i], &pilot_avg(0), &pilot_avg(0), nref); srslte_vec_sum_ccc(q->tmp_timeavg[i], &pilot_avg(0), &pilot_avg(0), nref);
} }
} else { } else {
memcpy(&pilot_avg(0), &pilot_tmp(0), nref * sizeof(cf_t)); memcpy(&pilot_avg(0), &pilot_tmp(0), nref * sizeof(cf_t));
@ -334,7 +334,7 @@ float srslte_chest_dl_rssi(srslte_chest_dl_t *q, cf_t *input, uint32_t port_id)
uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(port_id); 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 * SRSLTE_NRE]; cf_t *tmp = &input[srslte_refsignal_cs_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE];
rssi += vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * SRSLTE_NRE); rssi += srslte_vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * SRSLTE_NRE);
} }
return rssi/nsymbols; return rssi/nsymbols;
} }
@ -343,10 +343,10 @@ float srslte_chest_dl_rssi(srslte_chest_dl_t *q, cf_t *input, uint32_t port_id)
float srslte_chest_dl_rsrp(srslte_chest_dl_t *q, uint32_t port_id) { float srslte_chest_dl_rsrp(srslte_chest_dl_t *q, uint32_t port_id) {
#ifdef RSRP_FROM_ESTIMATES #ifdef RSRP_FROM_ESTIMATES
return vec_avg_power_cf(q->pilot_estimates[port_id], return srslte_vec_avg_power_cf(q->pilot_estimates[port_id],
SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id));
#else #else
return vec_avg_power_cf(q->pilot_estimates_average[port_id], return srslte_vec_avg_power_cf(q->pilot_estimates_average[port_id],
SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id));
#endif #endif
} }
@ -357,7 +357,7 @@ int srslte_chest_dl_estimate_port(srslte_chest_dl_t *q, cf_t *input, cf_t *ce, u
srslte_refsignal_cs_get_sf(q->cell, port_id, input, q->pilot_recv_signal[port_id]); srslte_refsignal_cs_get_sf(q->cell, port_id, input, q->pilot_recv_signal[port_id]);
/* Use the known CSR signal to compute Least-squares estimates */ /* Use the known CSR signal to compute Least-squares estimates */
vec_prod_conj_ccc(q->pilot_recv_signal[port_id], q->csr_signal.pilots[port_id/2][sf_idx], srslte_vec_prod_conj_ccc(q->pilot_recv_signal[port_id], q->csr_signal.pilots[port_id/2][sf_idx],
q->pilot_estimates[port_id], SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); q->pilot_estimates[port_id], SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id));
/* Average pilot estimates */ /* Average pilot estimates */
@ -392,7 +392,7 @@ int srslte_chest_dl_estimate(srslte_chest_dl_t *q, cf_t *input, cf_t *ce[SRSLTE_
} }
float srslte_chest_dl_get_noise_estimate(srslte_chest_dl_t *q) { float srslte_chest_dl_get_noise_estimate(srslte_chest_dl_t *q) {
float noise = vec_acc_ff(q->noise_estimate, q->cell.nof_ports)/q->cell.nof_ports; float noise = srslte_vec_acc_ff(q->noise_estimate, q->cell.nof_ports)/q->cell.nof_ports;
#ifdef NOISE_POWER_USE_ESTIMATES #ifdef NOISE_POWER_USE_ESTIMATES
return noise*sqrtf(srslte_symbol_sz(q->cell.nof_prb)); return noise*sqrtf(srslte_symbol_sz(q->cell.nof_prb));
#else #else
@ -421,6 +421,6 @@ float srslte_chest_dl_get_rsrq(srslte_chest_dl_t *q) {
float srslte_chest_dl_get_rsrp(srslte_chest_dl_t *q) { float srslte_chest_dl_get_rsrp(srslte_chest_dl_t *q) {
// return sum of power received from all tx ports // return sum of power received from all tx ports
return vec_acc_ff(q->rsrp, q->cell.nof_ports); return srslte_vec_acc_ff(q->rsrp, q->cell.nof_ports);
} }

@ -133,7 +133,7 @@ int srslte_refsignal_cs_init(srslte_refsignal_cs_t * q, srslte_cell_t cell)
for (p=0;p<2;p++) { for (p=0;p<2;p++) {
for (i=0;i<SRSLTE_NSUBFRAMES_X_FRAME;i++) { for (i=0;i<SRSLTE_NSUBFRAMES_X_FRAME;i++) {
q->pilots[p][i] = vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, 2*p)); q->pilots[p][i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, 2*p));
if (!q->pilots[p][i]) { if (!q->pilots[p][i]) {
perror("malloc"); perror("malloc");
goto free_and_exit; goto free_and_exit;

@ -141,7 +141,7 @@ int srslte_refsignal_ul_init(srslte_refsignal_ul_t * q, srslte_cell_t cell)
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(SRSLTE_NRE * q->cell.nof_prb * sizeof(cf_t)); q->tmp_arg = srslte_vec_malloc(SRSLTE_NRE * q->cell.nof_prb * sizeof(cf_t));
if (!q->tmp_arg) { if (!q->tmp_arg) {
perror("malloc"); perror("malloc");
goto free_and_exit; goto free_and_exit;
@ -162,7 +162,7 @@ int srslte_refsignal_ul_init(srslte_refsignal_ul_t * q, srslte_cell_t cell)
goto free_and_exit; goto free_and_exit;
} }
if (generate_n_cs_cell(q->cell, q->n_cs_cell)) { if (srslte_generate_n_cs_cell(q->cell, q->n_cs_cell)) {
goto free_and_exit; goto free_and_exit;
} }
@ -243,7 +243,7 @@ static void compute_pusch_r_uv_arg(srslte_refsignal_ul_t *q, srslte_refsignal_dr
} }
/* Calculates alpha according to 5.5.2.1.1 of 36.211 */ /* Calculates alpha according to 5.5.2.1.1 of 36.211 */
static float pusch_get_alpha(srslte_refsignal_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *cfg, uint32_t ns) { static float get_alpha(srslte_refsignal_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *cfg, uint32_t ns) {
uint32_t n_drms_2_val = 0; uint32_t n_drms_2_val = 0;
if (cfg->en_drms_2) { if (cfg->en_drms_2) {
n_drms_2_val = n_drms_2[cfg->cyclic_shift_for_drms]; n_drms_2_val = n_drms_2[cfg->cyclic_shift_for_drms];
@ -280,7 +280,7 @@ void srslte_refsignal_drms_pusch_put(srslte_refsignal_ul_t *q, srslte_refsignal_
} }
/* Generate DRMS for PUSCH signal according to 5.5.2.1 of 36.211 */ /* Generate DRMS for PUSCH signal according to 5.5.2.1 of 36.211 */
int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *cfg, uint32_t nof_prb, uint32_t sf_idx, cf_t *r_pusch) int srslte_refsignal_dmrs_gen(srslte_refsignal_ul_t *q, srslte_refsignal_drms_pusch_cfg_t *cfg, uint32_t nof_prb, uint32_t sf_idx, cf_t *r_pusch)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
@ -305,9 +305,9 @@ int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t *q, srslte_refsignal_d
compute_pusch_r_uv_arg(q, cfg, nof_prb, u, v); compute_pusch_r_uv_arg(q, cfg, nof_prb, u, v);
// Add cyclic prefix alpha // Add cyclic prefix alpha
float alpha = pusch_get_alpha(q, cfg, ns); float alpha = get_alpha(q, cfg, ns);
if (verbose == VERBOSE_DEBUG) { if (srslte_verbose == SRSLTE_VERBOSE_DEBUG) {
uint32_t N_sz = largest_prime_lower_than(nof_prb*SRSLTE_NRE); 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",
@ -324,19 +324,19 @@ int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t *q, srslte_refsignal_d
return ret; return ret;
} }
int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg, uint32_t sf_idx, uint32_t n_rb, cf_t *r_pucch) int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, srslte_pucch_cfg_t *cfg, uint32_t sf_idx, uint32_t n_rb, cf_t *r_pucch)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (pucch_cfg_isvalid(cfg)) { if (srslte_pucch_cfg_isvalid(cfg)) {
ret = SRSLTE_ERROR; ret = SRSLTE_ERROR;
for (uint32_t ns=2*sf_idx;ns<2*(sf_idx+1);ns++) { for (uint32_t ns=2*sf_idx;ns<2*(sf_idx+1);ns++) {
uint32_t N_rs=0; uint32_t N_rs=0;
uint32_t *pucch_symbol = NULL; uint32_t *pucch_symbol = NULL;
switch (cfg->format) { switch (cfg->format) {
case PUCCH_FORMAT_1: case SRSLTE_PUCCH_FORMAT_1:
case PUCCH_FORMAT_1A: case SRSLTE_PUCCH_FORMAT_1A:
case PUCCH_FORMAT_1B: case SRSLTE_PUCCH_FORMAT_1B:
if (SRSLTE_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;
@ -345,7 +345,7 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg,
pucch_symbol=pucch_symbol_format1_cpext; pucch_symbol=pucch_symbol_format1_cpext;
} }
break; break;
case PUCCH_FORMAT_2: case SRSLTE_PUCCH_FORMAT_2:
if (SRSLTE_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;
@ -354,8 +354,8 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg,
pucch_symbol=pucch_symbol_format2_cpext; pucch_symbol=pucch_symbol_format2_cpext;
} }
break; break;
case PUCCH_FORMAT_2A: case SRSLTE_PUCCH_FORMAT_2A:
case PUCCH_FORMAT_2B: case SRSLTE_PUCCH_FORMAT_2B:
N_rs = 2; N_rs = 2;
pucch_symbol=pucch_symbol_format2_cpnorm; pucch_symbol=pucch_symbol_format2_cpnorm;
break; break;
@ -367,29 +367,29 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t *q, pucch_cfg_t *cfg,
uint32_t l = pucch_symbol[m]; uint32_t l = pucch_symbol[m];
// Add cyclic prefix alpha // Add cyclic prefix alpha
float alpha = pucch_get_alpha(q->n_cs_cell, cfg, q->cell.cp, true, ns, l, &n_oc); float alpha = srslte_pucch_get_alpha(q->n_cs_cell, cfg, q->cell.cp, true, ns, l, &n_oc);
// Choose number of symbols and orthogonal sequence from Tables 5.5.2.2.1-1 to -3 // Choose number of symbols and orthogonal sequence from Tables 5.5.2.2.1-1 to -3
float *w=NULL; float *w=NULL;
switch (cfg->format) { switch (cfg->format) {
case PUCCH_FORMAT_1: case SRSLTE_PUCCH_FORMAT_1:
case PUCCH_FORMAT_1A: case SRSLTE_PUCCH_FORMAT_1A:
case PUCCH_FORMAT_1B: case SRSLTE_PUCCH_FORMAT_1B:
if (SRSLTE_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 SRSLTE_PUCCH_FORMAT_2:
if (SRSLTE_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;
} }
break; break;
case PUCCH_FORMAT_2A: case SRSLTE_PUCCH_FORMAT_2A:
case PUCCH_FORMAT_2B: case SRSLTE_PUCCH_FORMAT_2B:
w=w_arg_pucch_format2_cpnorm; w=w_arg_pucch_format2_cpnorm;
break; break;
} }

@ -71,7 +71,7 @@ void parse_args(int argc, char **argv) {
output_matlab = argv[optind]; output_matlab = argv[optind];
break; break;
case 'v': case 'v':
verbose++; srslte_verbose++;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -83,7 +83,7 @@ void parse_args(int argc, char **argv) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
srslte_chest_dl_t est; srslte_chest_dl_t est;
precoding_t cheq; srslte_precoding_t cheq;
cf_t *input = NULL, *ce = NULL, *h = NULL, *output = NULL; cf_t *input = NULL, *ce = NULL, *h = NULL, *output = NULL;
int i, j, n_port, sf_idx, cid, num_re; int i, j, n_port, sf_idx, cid, num_re;
int ret = -1; int ret = -1;
@ -131,7 +131,7 @@ int main(int argc, char **argv) {
max_cid = cell.id; max_cid = cell.id;
} }
precoding_init(&cheq, num_re); srslte_precoding_init(&cheq, num_re);
while(cid <= max_cid) { while(cid <= max_cid) {
cell.id = cid; cell.id = cid;
@ -173,7 +173,7 @@ int main(int argc, char **argv) {
gettimeofday(&t[1], NULL); gettimeofday(&t[1], NULL);
for (int j=0;j<100;j++) { for (int j=0;j<100;j++) {
predecoding_single(&cheq, input, ce, output, num_re, 0); srslte_predecoding_single(&cheq, input, ce, output, num_re, 0);
} }
gettimeofday(&t[2], NULL); gettimeofday(&t[2], NULL);
get_time_interval(t); get_time_interval(t);
@ -188,7 +188,7 @@ int main(int argc, char **argv) {
gettimeofday(&t[1], NULL); gettimeofday(&t[1], NULL);
for (int j=0;j<100;j++) { for (int j=0;j<100;j++) {
predecoding_single(&cheq, input, ce, output, num_re, srslte_chest_dl_get_noise_estimate(&est)); srslte_predecoding_single(&cheq, input, ce, output, num_re, srslte_chest_dl_get_noise_estimate(&est));
} }
gettimeofday(&t[2], NULL); gettimeofday(&t[2], NULL);
get_time_interval(t); get_time_interval(t);
@ -207,13 +207,13 @@ int main(int argc, char **argv) {
if (fmatlab) { if (fmatlab) {
fprintf(fmatlab, "input="); fprintf(fmatlab, "input=");
vec_fprint_c(fmatlab, input, num_re); srslte_vec_fprint_c(fmatlab, input, num_re);
fprintf(fmatlab, ";\n"); fprintf(fmatlab, ";\n");
fprintf(fmatlab, "h="); fprintf(fmatlab, "h=");
vec_fprint_c(fmatlab, h, num_re); srslte_vec_fprint_c(fmatlab, h, num_re);
fprintf(fmatlab, ";\n"); fprintf(fmatlab, ";\n");
fprintf(fmatlab, "ce="); fprintf(fmatlab, "ce=");
vec_fprint_c(fmatlab, ce, num_re); srslte_vec_fprint_c(fmatlab, ce, num_re);
fprintf(fmatlab, ";\n"); fprintf(fmatlab, ";\n");
} }
} }
@ -228,7 +228,7 @@ int main(int argc, char **argv) {
do_exit: do_exit:
precoding_free(&cheq); srslte_precoding_free(&cheq);
if (output) { if (output) {
free(output); free(output);

@ -64,7 +64,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
int i; int i;
srslte_cell_t cell; srslte_cell_t cell;
srslte_chest_dl_t chest; srslte_chest_dl_t chest;
precoding_t cheq; srslte_precoding_t cheq;
cf_t *input_signal = NULL, *output_signal[SRSLTE_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];
@ -153,15 +153,15 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
/** Allocate input buffers */ /** Allocate input buffers */
int nof_re = 2*SRSLTE_CP_NSYMB(cell.cp)*cell.nof_prb*SRSLTE_NRE; 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] = srslte_vec_malloc(nof_re * sizeof(cf_t));
} }
input_signal = vec_malloc(nof_re * sizeof(cf_t)); input_signal = srslte_vec_malloc(nof_re * sizeof(cf_t));
for (i=0;i<SRSLTE_MAX_PORTS;i++) { for (i=0;i<SRSLTE_MAX_PORTS;i++) {
output_signal[i] = vec_malloc(nof_re * sizeof(cf_t)); output_signal[i] = srslte_vec_malloc(nof_re * sizeof(cf_t));
} }
output_signal2 = vec_malloc(nof_re * sizeof(cf_t)); output_signal2 = srslte_vec_malloc(nof_re * sizeof(cf_t));
precoding_init(&cheq, nof_re); srslte_precoding_init(&cheq, nof_re);
/* Create output values */ /* Create output values */
if (nlhs >= 1) { if (nlhs >= 1) {
@ -201,9 +201,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
if (cell.nof_ports == 1) { if (cell.nof_ports == 1) {
predecoding_single(&cheq, input_signal, ce[0], output_signal2, nof_re, srslte_chest_dl_get_noise_estimate(&chest)); srslte_predecoding_single(&cheq, input_signal, ce[0], output_signal2, nof_re, srslte_chest_dl_get_noise_estimate(&chest));
} else { } else {
predecoding_diversity(&cheq, input_signal, ce, output_signal, cell.nof_ports, nof_re, srslte_chest_dl_get_noise_estimate(&chest)); srslte_predecoding_diversity(&cheq, input_signal, ce, output_signal, cell.nof_ports, nof_re, srslte_chest_dl_get_noise_estimate(&chest));
srslte_layerdemap_diversity(output_signal, output_signal2, cell.nof_ports, nof_re/cell.nof_ports); srslte_layerdemap_diversity(output_signal, output_signal2, cell.nof_ports, nof_re/cell.nof_ports);
} }
@ -254,7 +254,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
srslte_chest_dl_free(&chest); srslte_chest_dl_free(&chest);
precoding_free(&cheq); srslte_precoding_free(&cheq);
return; return;
} }

@ -123,19 +123,19 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
mexPrintf("cyclic_shift_for_drms: %d, ",pusch_cfg.cyclic_shift_for_drms); mexPrintf("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*SRSLTE_NRE*nof_prb*sizeof(cf_t)); cf_t *signal = srslte_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(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp)*sizeof(cf_t)); cf_t *sf_symbols = srslte_vec_malloc(SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp)*sizeof(cf_t));
if (!sf_symbols) { if (!sf_symbols) {
perror("malloc"); perror("malloc");
return; return;
} }
bzero(sf_symbols, SRSLTE_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_gen(&refs, &pusch_cfg, nof_prb, sf_idx, signal);
uint32_t n_prb[2]; uint32_t n_prb[2];
n_prb[0] = prbset[0]; n_prb[0] = prbset[0];
n_prb[1] = prbset[0]; n_prb[1] = prbset[0];

@ -65,7 +65,7 @@ void parse_args(int argc, char **argv) {
cell.id = atoi(argv[optind]); cell.id = atoi(argv[optind]);
break; break;
case 'v': case 'v':
verbose++; srslte_verbose++;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -123,7 +123,7 @@ int main(int argc, char **argv) {
printf("cyclic_shift_for_drms: %d, ",pusch_cfg.cyclic_shift_for_drms); printf("cyclic_shift_for_drms: %d, ",pusch_cfg.cyclic_shift_for_drms);
printf("delta_ss: %d, ",pusch_cfg.delta_ss); printf("delta_ss: %d, ",pusch_cfg.delta_ss);
printf("SF_idx: %d\n", sf_idx); printf("SF_idx: %d\n", sf_idx);
srslte_refsignal_dmrs_pusch_gen(&refs, &pusch_cfg, nof_prb, sf_idx, signal); srslte_refsignal_dmrs_gen(&refs, &pusch_cfg, nof_prb, sf_idx, signal);
exit(0); exit(0);
} }
} }

@ -134,13 +134,13 @@ bool srslte_cb_size_isvalid(uint32_t size) {
char *srslte_mod_string(srslte_mod_t mod) { char *srslte_mod_string(srslte_mod_t mod) {
switch (mod) { switch (mod) {
case LTE_BPSK: case SRSLTE_MOD_BPSK:
return "BPSK"; return "BPSK";
case LTE_QPSK: case SRSLTE_MOD_QPSK:
return "QPSK"; return "QPSK";
case LTE_QAM16: case SRSLTE_MOD_16QAM:
return "QAM16"; return "QAM16";
case LTE_QAM64: case SRSLTE_MOD_64QAM:
return "QAM64"; return "QAM64";
default: default:
return "N/A"; return "N/A";
@ -149,13 +149,13 @@ char *srslte_mod_string(srslte_mod_t mod) {
uint32_t srslte_mod_bits_x_symbol(srslte_mod_t mod) { uint32_t srslte_mod_bits_x_symbol(srslte_mod_t mod) {
switch (mod) { switch (mod) {
case LTE_BPSK: case SRSLTE_MOD_BPSK:
return 1; return 1;
case LTE_QPSK: case SRSLTE_MOD_QPSK:
return 2; return 2;
case LTE_QAM16: case SRSLTE_MOD_16QAM:
return 4; return 4;
case LTE_QAM64: case SRSLTE_MOD_64QAM:
return 6; return 6;
default: default:
return 0; return 0;
@ -301,45 +301,45 @@ struct lte_band {
}; };
struct lte_band lte_bands[SRSLTE_NOF_LTE_BANDS] = { struct lte_band lte_bands[SRSLTE_NOF_LTE_BANDS] = {
{1, 2110, 0, 599, ALL}, {1, 2110, 0, 599, SRSLTE_BAND_GEO_AREA_ALL},
{2, 1930, 600, 1199, NAR}, {2, 1930, 600, 1199, SRSLTE_BAND_GEO_AREA_NAR},
{3, 1805, 1200, 1949, ALL}, {3, 1805, 1200, 1949, SRSLTE_BAND_GEO_AREA_ALL},
{4, 2110, 1950, 2399, NAR}, {4, 2110, 1950, 2399, SRSLTE_BAND_GEO_AREA_NAR},
{5, 869, 2400, 2649, NAR}, {5, 869, 2400, 2649, SRSLTE_BAND_GEO_AREA_NAR},
{6, 875, 2650, 2749, APAC}, {6, 875, 2650, 2749, SRSLTE_BAND_GEO_AREA_APAC},
{7, 2620, 2750, 3449, EMEA}, {7, 2620, 2750, 3449, SRSLTE_BAND_GEO_AREA_EMEA},
{8, 925, 3450, 3799, ALL}, {8, 925, 3450, 3799, SRSLTE_BAND_GEO_AREA_ALL},
{9, 1844.9, 3800, 4149, APAC}, {9, 1844.9, 3800, 4149, SRSLTE_BAND_GEO_AREA_APAC},
{10, 2110, 4150, 4749, NAR}, {10, 2110, 4150, 4749, SRSLTE_BAND_GEO_AREA_NAR},
{11, 1475.9, 4750, 4949, JAPAN}, {11, 1475.9, 4750, 4949, SRSLTE_BAND_GEO_AREA_JAPAN},
{12, 729, 5010, 5179, NAR}, {12, 729, 5010, 5179, SRSLTE_BAND_GEO_AREA_NAR},
{13, 746, 5180, 5279, NAR}, {13, 746, 5180, 5279, SRSLTE_BAND_GEO_AREA_NAR},
{14, 758, 5280, 5379, NAR}, {14, 758, 5280, 5379, SRSLTE_BAND_GEO_AREA_NAR},
{17, 734, 5730, 5849, NAR}, {17, 734, 5730, 5849, SRSLTE_BAND_GEO_AREA_NAR},
{18, 860, 5850, 5999, JAPAN}, {18, 860, 5850, 5999, SRSLTE_BAND_GEO_AREA_JAPAN},
{19, 875, 6000, 6149, JAPAN}, {19, 875, 6000, 6149, SRSLTE_BAND_GEO_AREA_JAPAN},
{20, 791, 6150, 6449, EMEA}, {20, 791, 6150, 6449, SRSLTE_BAND_GEO_AREA_EMEA},
{21, 1495.9, 6450, 6599, JAPAN}, {21, 1495.9, 6450, 6599, SRSLTE_BAND_GEO_AREA_JAPAN},
{22, 3500, 6600, 7399, NA}, {22, 3500, 6600, 7399, SRSLTE_BAND_GEO_AREA_NA},
{23, 2180, 7500, 7699, NAR}, {23, 2180, 7500, 7699, SRSLTE_BAND_GEO_AREA_NAR},
{24, 1525, 7700, 8039, NAR}, {24, 1525, 7700, 8039, SRSLTE_BAND_GEO_AREA_NAR},
{25, 1930, 8040, 8689, NAR}, {25, 1930, 8040, 8689, SRSLTE_BAND_GEO_AREA_NAR},
{26, 859, 8690, 9039, NAR}, {26, 859, 8690, 9039, SRSLTE_BAND_GEO_AREA_NAR},
{27, 852, 9040, 9209, NAR}, {27, 852, 9040, 9209, SRSLTE_BAND_GEO_AREA_NAR},
{28, 758, 9210, 9659, APAC}, {28, 758, 9210, 9659, SRSLTE_BAND_GEO_AREA_APAC},
{29, 717, 9660, 9769, NAR}, {29, 717, 9660, 9769, SRSLTE_BAND_GEO_AREA_NAR},
{30, 2350, 9770, 9869, NAR}, {30, 2350, 9770, 9869, SRSLTE_BAND_GEO_AREA_NAR},
{31, 462.5, 9870, 9919, CALA} {31, 462.5, 9870, 9919, SRSLTE_BAND_GEO_AREA_CALA}
}; };
#define EOF_BAND 9919 #define EOF_BAND 9919
int srslte_str2mimotype(char *mimo_type_str, srslte_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 = SRSLTE_MIMO_TYPE_SINGLE_ANTENNA;
} else if (!strcmp(mimo_type_str, "diversity")) { } else if (!strcmp(mimo_type_str, "diversity")) {
*type = TX_DIVERSITY; *type = SRSLTE_MIMO_TYPE_TX_DIVERSITY;
} else if (!strcmp(mimo_type_str, "multiplex")) { } else if (!strcmp(mimo_type_str, "multiplex")) {
*type = SPATIAL_MULTIPLEX; *type = SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX;
} else { } else {
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -31,18 +31,18 @@
#include <fftw3.h> #include <fftw3.h>
#include <string.h> #include <string.h>
#include "srslte/utils/dft.h" #include "srslte/dft/dft.h"
#include "srslte/utils/vector.h" #include "srslte/utils/vector.h"
#define dft_ceil(a,b) ((a-1)/b+1) #define dft_ceil(a,b) ((a-1)/b+1)
#define dft_floor(a,b) (a/b) #define dft_floor(a,b) (a/b)
int dft_plan(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir, int srslte_dft_plan(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir,
dft_mode_t mode) { srslte_dft_mode_t mode) {
if(mode == COMPLEX){ if(mode == SRSLTE_DFT_COMPLEX){
return dft_plan_c(plan,dft_points,dir); return srslte_dft_plan_c(plan,dft_points,dir);
} else { } else {
return dft_plan_r(plan,dft_points,dir); return srslte_dft_plan_r(plan,dft_points,dir);
} }
return 0; return 0;
} }
@ -52,17 +52,17 @@ static void allocate(srslte_dft_plan_t *plan, int size_in, int size_out, int len
plan->out = fftwf_malloc(size_out*len); plan->out = fftwf_malloc(size_out*len);
} }
int dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir) { int srslte_dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir) {
allocate(plan,sizeof(fftwf_complex),sizeof(fftwf_complex), dft_points); allocate(plan,sizeof(fftwf_complex),sizeof(fftwf_complex), dft_points);
int sign = (dir == FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD; int sign = (dir == SRSLTE_DFT_FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD;
plan->p = fftwf_plan_dft_1d(dft_points, plan->in, plan->out, sign, 0U); plan->p = fftwf_plan_dft_1d(dft_points, plan->in, plan->out, sign, 0U);
if (!plan->p) { if (!plan->p) {
return -1; return -1;
} }
plan->size = dft_points; plan->size = dft_points;
plan->mode = COMPLEX; plan->mode = SRSLTE_DFT_COMPLEX;
plan->dir = dir; plan->dir = dir;
plan->forward = (dir==FORWARD)?true:false; plan->forward = (dir==SRSLTE_DFT_FORWARD)?true:false;
plan->mirror = false; plan->mirror = false;
plan->db = false; plan->db = false;
plan->norm = false; plan->norm = false;
@ -71,17 +71,17 @@ int dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir) {
return 0; return 0;
} }
int dft_plan_r(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir) { int srslte_dft_plan_r(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir) {
allocate(plan,sizeof(float),sizeof(float), dft_points); allocate(plan,sizeof(float),sizeof(float), dft_points);
int sign = (dir == FORWARD) ? FFTW_R2HC : FFTW_HC2R; int sign = (dir == SRSLTE_DFT_FORWARD) ? FFTW_R2HC : FFTW_HC2R;
plan->p = fftwf_plan_r2r_1d(dft_points, plan->in, plan->out, sign, 0U); plan->p = fftwf_plan_r2r_1d(dft_points, plan->in, plan->out, sign, 0U);
if (!plan->p) { if (!plan->p) {
return -1; return -1;
} }
plan->size = dft_points; plan->size = dft_points;
plan->mode = REAL; plan->mode = SRSLTE_REAL;
plan->dir = dir; plan->dir = dir;
plan->forward = (dir==FORWARD)?true:false; plan->forward = (dir==SRSLTE_DFT_FORWARD)?true:false;
plan->mirror = false; plan->mirror = false;
plan->db = false; plan->db = false;
plan->norm = false; plan->norm = false;
@ -90,16 +90,16 @@ int dft_plan_r(srslte_dft_plan_t *plan, const int dft_points, dft_dir_t dir) {
return 0; return 0;
} }
void dft_plan_set_mirror(srslte_dft_plan_t *plan, bool val){ void srslte_dft_plan_set_mirror(srslte_dft_plan_t *plan, bool val){
plan->mirror = val; plan->mirror = val;
} }
void dft_plan_set_db(srslte_dft_plan_t *plan, bool val){ void srslte_dft_plan_set_db(srslte_dft_plan_t *plan, bool val){
plan->db = val; plan->db = val;
} }
void dft_plan_set_norm(srslte_dft_plan_t *plan, bool val){ void srslte_dft_plan_set_norm(srslte_dft_plan_t *plan, bool val){
plan->norm = val; plan->norm = val;
} }
void dft_plan_set_dc(srslte_dft_plan_t *plan, bool val){ void srslte_dft_plan_set_dc(srslte_dft_plan_t *plan, bool val){
plan->dc = val; plan->dc = val;
} }
@ -128,56 +128,56 @@ static void copy_post(uint8_t *dst, uint8_t *src, int size_d, int len,
} }
} }
void dft_run(srslte_dft_plan_t *plan, void *in, void *out) { void srslte_dft_run(srslte_dft_plan_t *plan, void *in, void *out) {
if(plan->mode == COMPLEX) { if(plan->mode == SRSLTE_DFT_COMPLEX) {
dft_run_c(plan,in,out); srslte_dft_run_c(plan,in,out);
} else { } else {
dft_run_r(plan,in,out); srslte_dft_run_r(plan,in,out);
} }
} }
void dft_run_c(srslte_dft_plan_t *plan, dft_c_t *in, dft_c_t *out) { void srslte_dft_run_c(srslte_dft_plan_t *plan, cf_t *in, cf_t *out) {
float norm; float norm;
int i; int i;
fftwf_complex *f_out = plan->out; fftwf_complex *f_out = plan->out;
copy_pre((uint8_t*)plan->in, (uint8_t*)in, sizeof(dft_c_t), plan->size, copy_pre((uint8_t*)plan->in, (uint8_t*)in, sizeof(cf_t), plan->size,
plan->forward, plan->mirror, plan->dc); plan->forward, plan->mirror, plan->dc);
fftwf_execute(plan->p); fftwf_execute(plan->p);
if (plan->norm) { if (plan->norm) {
norm = 1.0/sqrtf(plan->size); norm = 1.0/sqrtf(plan->size);
vec_sc_prod_cfc(f_out, norm, f_out, plan->size); srslte_vec_sc_prod_cfc(f_out, norm, f_out, plan->size);
} }
if (plan->db) { if (plan->db) {
for (i=0;i<plan->size;i++) { for (i=0;i<plan->size;i++) {
f_out[i] = 10*log10(f_out[i]); f_out[i] = 10*log10(f_out[i]);
} }
} }
copy_post((uint8_t*)out, (uint8_t*)plan->out, sizeof(dft_c_t), plan->size, copy_post((uint8_t*)out, (uint8_t*)plan->out, sizeof(cf_t), plan->size,
plan->forward, plan->mirror, plan->dc); plan->forward, plan->mirror, plan->dc);
} }
void dft_run_r(srslte_dft_plan_t *plan, dft_r_t *in, dft_r_t *out) { void srslte_dft_run_r(srslte_dft_plan_t *plan, float *in, float *out) {
float norm; float norm;
int i; int i;
int len = plan->size; int len = plan->size;
float *f_out = plan->out; float *f_out = plan->out;
memcpy(plan->in,in,sizeof(dft_r_t)*plan->size); memcpy(plan->in,in,sizeof(float)*plan->size);
fftwf_execute(plan->p); fftwf_execute(plan->p);
if (plan->norm) { if (plan->norm) {
norm = 1.0/plan->size; norm = 1.0/plan->size;
vec_sc_prod_fff(f_out, norm, f_out, plan->size); srslte_vec_sc_prod_fff(f_out, norm, f_out, plan->size);
} }
if (plan->db) { if (plan->db) {
for (i=0;i<len;i++) { for (i=0;i<len;i++) {
f_out[i] = 10*log10(f_out[i]); f_out[i] = 10*log10(f_out[i]);
} }
} }
memcpy(out,plan->out,sizeof(dft_r_t)*plan->size); memcpy(out,plan->out,sizeof(float)*plan->size);
} }
void dft_plan_free(srslte_dft_plan_t *plan) { void srslte_dft_plan_free(srslte_dft_plan_t *plan) {
if (!plan) return; if (!plan) return;
if (!plan->size) return; if (!plan->size) return;
if (plan->in) fftwf_free(plan->in); if (plan->in) fftwf_free(plan->in);

@ -37,30 +37,30 @@
#include "srslte/common/phy_common.h" #include "srslte/common/phy_common.h"
#include "srslte/utils/debug.h" #include "srslte/utils/debug.h"
#include "srslte/utils/vector.h" #include "srslte/utils/vector.h"
#include "srslte/utils/dft.h" #include "srslte/dft/dft.h"
#include "srslte/filter/dft_precoding.h" #include "srslte/dft/dft_precoding.h"
/* Create DFT plans for transform precoding */ /* Create DFT plans for transform precoding */
int srslte_srslte_dft_precoding_init(srslte_srslte_dft_precoding_t *q, uint32_t max_prb) int srslte_dft_precoding_init(srslte_dft_precoding_t *q, uint32_t max_prb)
{ {
int ret = SRSLTE_ERROR_INVALID_INPUTS; int ret = SRSLTE_ERROR_INVALID_INPUTS;
bzero(q, sizeof(srslte_srslte_dft_precoding_t)); bzero(q, sizeof(srslte_dft_precoding_t));
if (max_prb <= SRSLTE_MAX_PRB) { 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(srslte_srslte_dft_precoding_valid_prb(i)) { if(srslte_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*SRSLTE_NRE, FORWARD)) { if (srslte_dft_plan_c(&q->dft_plan[i], i*SRSLTE_NRE, SRSLTE_DFT_FORWARD)) {
fprintf(stderr, "Error: Creating DFT plan %d\n",i); fprintf(stderr, "Error: Creating DFT plan %d\n",i);
goto clean_exit; goto clean_exit;
} }
dft_plan_set_norm(&q->dft_plan[i], true); srslte_dft_plan_set_norm(&q->dft_plan[i], true);
if (dft_plan_c(&q->idft_plan[i], i*SRSLTE_NRE, BACKWARD)) { if (srslte_dft_plan_c(&q->idft_plan[i], i*SRSLTE_NRE, SRSLTE_DFT_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;
} }
dft_plan_set_norm(&q->idft_plan[i], true); srslte_dft_plan_set_norm(&q->idft_plan[i], true);
} }
} }
q->max_prb = max_prb; q->max_prb = max_prb;
@ -69,25 +69,25 @@ int srslte_srslte_dft_precoding_init(srslte_srslte_dft_precoding_t *q, uint32_t
clean_exit: clean_exit:
if (ret == SRSLTE_ERROR) { if (ret == SRSLTE_ERROR) {
srslte_srslte_dft_precoding_free(q); srslte_dft_precoding_free(q);
} }
return ret; return ret;
} }
/* Free DFT plans for transform precoding */ /* Free DFT plans for transform precoding */
void srslte_srslte_dft_precoding_free(srslte_srslte_dft_precoding_t *q) void srslte_dft_precoding_free(srslte_dft_precoding_t *q)
{ {
for (uint32_t i=1;i<q->max_prb;i++) { for (uint32_t i=1;i<q->max_prb;i++) {
if(srslte_srslte_dft_precoding_valid_prb(i)) { if(srslte_dft_precoding_valid_prb(i)) {
DEBUG("Freeing DFT precoding plan for %d PRBs\n", i); DEBUG("Freeing DFT precoding plan for %d PRBs\n", i);
dft_plan_free(&q->dft_plan[i]); srslte_dft_plan_free(&q->dft_plan[i]);
dft_plan_free(&q->idft_plan[i]); srslte_dft_plan_free(&q->idft_plan[i]);
} }
} }
bzero(q, sizeof(srslte_srslte_dft_precoding_t)); bzero(q, sizeof(srslte_dft_precoding_t));
} }
bool srslte_srslte_dft_precoding_valid_prb(uint32_t nof_prb) { bool srslte_dft_precoding_valid_prb(uint32_t nof_prb) {
if (nof_prb == 1 || (nof_prb%2) == 0 || (nof_prb%3) == 0 || (nof_prb%5) == 0) { if (nof_prb == 1 || (nof_prb%2) == 0 || (nof_prb%3) == 0 || (nof_prb%5) == 0) {
return true; return true;
} else { } else {
@ -95,32 +95,32 @@ bool srslte_srslte_dft_precoding_valid_prb(uint32_t nof_prb) {
} }
} }
int srslte_dft_precoding(srslte_srslte_dft_precoding_t *q, cf_t *input, cf_t *output, int srslte_dft_precoding(srslte_dft_precoding_t *q, cf_t *input, cf_t *output,
uint32_t nof_prb, uint32_t nof_symbols) uint32_t nof_prb, uint32_t nof_symbols)
{ {
if (!srslte_srslte_dft_precoding_valid_prb(nof_prb)) { if (!srslte_dft_precoding_valid_prb(nof_prb)) {
fprintf(stderr, "Error invalid number of PRB (%d)\n", nof_prb); fprintf(stderr, "Error invalid number of PRB (%d)\n", nof_prb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
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*SRSLTE_NRE*nof_prb], &output[i*SRSLTE_NRE*nof_prb]); srslte_dft_run_c(&q->dft_plan[nof_prb], &input[i*SRSLTE_NRE*nof_prb], &output[i*SRSLTE_NRE*nof_prb]);
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
int srslte_dft_predecoding(srslte_srslte_dft_precoding_t *q, cf_t *input, cf_t *output, int srslte_dft_predecoding(srslte_dft_precoding_t *q, cf_t *input, cf_t *output,
uint32_t nof_prb, uint32_t nof_symbols) uint32_t nof_prb, uint32_t nof_symbols)
{ {
if (!srslte_srslte_dft_precoding_valid_prb(nof_prb)) { if (!srslte_dft_precoding_valid_prb(nof_prb)) {
fprintf(stderr, "Error invalid number of PRB (%d)\n", nof_prb); fprintf(stderr, "Error invalid number of PRB (%d)\n", nof_prb);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
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*SRSLTE_NRE*nof_prb], &output[i*SRSLTE_NRE*nof_prb]); srslte_dft_run_c(&q->dft_plan[nof_prb], &input[i*SRSLTE_NRE*nof_prb], &output[i*SRSLTE_NRE*nof_prb]);
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;

@ -32,73 +32,74 @@
#include <math.h> #include <math.h>
#include "srslte/common/phy_common.h" #include "srslte/common/phy_common.h"
#include "srslte/utils/dft.h" #include "srslte/dft/dft.h"
#include "srslte/common/fft.h" #include "srslte/dft/ofdm.h"
#include "srslte/utils/debug.h" #include "srslte/utils/debug.h"
#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_ofdm_tx_init_(srslte_ofdm_t *q, srslte_cp_t cp, uint32_t nof_prb, srslte_dft_dir_t dir) {
int symbol_sz = srslte_symbol_sz(nof_prb); 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);
return -1; return -1;
} }
if (dft_plan_c(&q->fft_plan, symbol_sz, dir)) { if (srslte_dft_plan_c(&q->fft_plan, symbol_sz, dir)) {
fprintf(stderr, "Error: Creating DFT plan\n"); fprintf(stderr, "Error: Creating DFT plan\n");
return -1; return -1;
} }
q->tmp = malloc((uint32_t) symbol_sz * sizeof(cf_t)); q->tmp = srslte_vec_malloc((uint32_t) symbol_sz * sizeof(cf_t));
if (!q->tmp) { if (!q->tmp) {
perror("malloc"); perror("malloc");
return -1; return -1;
} }
dft_plan_set_mirror(&q->fft_plan, true); srslte_dft_plan_set_mirror(&q->fft_plan, true);
dft_plan_set_dc(&q->fft_plan, true); srslte_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 = SRSLTE_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->shift_buffer = NULL;
q->nof_re = nof_prb * SRSLTE_NRE; 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 = SRSLTE_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==SRSLTE_DFT_FORWARD?"FFT":"iFFT", q->symbol_sz, q->nof_symbols,
q->cp==SRSLTE_SRSLTE_CP_NORM?"Normal":"Extended", q->nof_re, q->nof_guards); q->cp==SRSLTE_SRSLTE_CP_NORM?"Normal":"Extended", q->nof_re, q->nof_guards);
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
void srslte_fft_free_(srslte_fft_t *q) { void srslte_ofdm_free_(srslte_ofdm_t *q) {
dft_plan_free(&q->fft_plan); srslte_dft_plan_free(&q->fft_plan);
if (q->tmp) { if (q->tmp) {
free(q->tmp); free(q->tmp);
} }
if (q->shift_buffer) { if (q->shift_buffer) {
free(q->shift_buffer); free(q->shift_buffer);
} }
bzero(q, sizeof(srslte_fft_t)); bzero(q, sizeof(srslte_ofdm_t));
} }
int srslte_fft_init(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb) { int srslte_ofdm_tx_init(srslte_ofdm_t *q, srslte_cp_t cp, uint32_t nof_prb) {
return srslte_fft_init_(q, cp, nof_prb, FORWARD); return srslte_ofdm_tx_init_(q, cp, nof_prb, SRSLTE_DFT_FORWARD);
} }
void srslte_fft_free(srslte_fft_t *q) { void srslte_ofdm_tx_free(srslte_ofdm_t *q) {
srslte_fft_free_(q); srslte_ofdm_free_(q);
} }
int lte_ifft_init(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb) { int srslte_ofdm_rx_init(srslte_ofdm_t *q, srslte_cp_t cp, uint32_t nof_prb) {
uint32_t i; uint32_t i;
int ret; int ret;
ret = srslte_fft_init_(q, cp, nof_prb, BACKWARD); ret = srslte_ofdm_tx_init_(q, cp, nof_prb, SRSLTE_DFT_BACKWARD);
if (ret == SRSLTE_SUCCESS) { if (ret == SRSLTE_SUCCESS) {
dft_plan_set_norm(&q->fft_plan, true); srslte_dft_plan_set_norm(&q->fft_plan, true);
/* set now zeros at CP */ /* set now zeros at CP */
for (i=0;i<q->nof_symbols;i++) { for (i=0;i<q->nof_symbols;i++) {
@ -113,8 +114,8 @@ int lte_ifft_init(srslte_fft_t *q, srslte_cp_t cp, uint32_t nof_prb) {
* Freq_shift is relative to inter-carrier spacing. * Freq_shift is relative to inter-carrier spacing.
* 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_ofdm_set_freq_shift(srslte_ofdm_t *q, float freq_shift) {
q->shift_buffer = vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN(q->symbol_sz)); q->shift_buffer = srslte_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;
@ -131,50 +132,50 @@ int srslte_fft_set_freq_shift(srslte_fft_t *q, float freq_shift) {
} }
/* Disable DC carrier addition */ /* Disable DC carrier addition */
dft_plan_set_dc(&q->fft_plan, false); srslte_dft_plan_set_dc(&q->fft_plan, false);
q->freq_shift = true; q->freq_shift = true;
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
void lte_ifft_free(srslte_fft_t *q) { void srslte_ofdm_rx_free(srslte_ofdm_t *q) {
srslte_fft_free_(q); srslte_ofdm_free_(q);
} }
/* Transforms input samples into output OFDM symbols. /* Transforms input samples into output OFDM symbols.
* Performs FFT on a each symbol and removes CP. * Performs FFT on a each symbol and removes CP.
*/ */
void srslte_fft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) { void srslte_ofdm_tx_slot(srslte_ofdm_t *q, cf_t *input, cf_t *output) {
uint32_t i; uint32_t i;
for (i=0;i<q->nof_symbols;i++) { for (i=0;i<q->nof_symbols;i++) {
input += SRSLTE_CP_ISNORM(q->cp)?SRSLTE_CP_NORM(i, q->symbol_sz):SRSLTE_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); srslte_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;
output += q->nof_re; output += q->nof_re;
} }
} }
void srslte_fft_run_sf(srslte_fft_t *q, cf_t *input, cf_t *output) { void srslte_ofdm_tx_sf(srslte_ofdm_t *q, cf_t *input, cf_t *output) {
uint32_t n; uint32_t n;
if (q->freq_shift) { if (q->freq_shift) {
vec_prod_ccc(input, q->shift_buffer, input, 2*q->slot_sz); srslte_vec_prod_ccc(input, q->shift_buffer, input, 2*q->slot_sz);
} }
for (n=0;n<2;n++) { for (n=0;n<2;n++) {
srslte_fft_run_slot(q, &input[n*q->slot_sz], &output[n*q->nof_re*q->nof_symbols]); srslte_ofdm_tx_slot(q, &input[n*q->slot_sz], &output[n*q->nof_re*q->nof_symbols]);
} }
} }
/* Transforms input OFDM symbols into output samples. /* Transforms input OFDM symbols into output samples.
* Performs FFT on a each symbol and adds CP. * Performs FFT on a each symbol and adds CP.
*/ */
void lte_ifft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) { void srslte_ofdm_rx_slot(srslte_ofdm_t *q, cf_t *input, cf_t *output) {
uint32_t i, cp_len; uint32_t i, cp_len;
for (i=0;i<q->nof_symbols;i++) { for (i=0;i<q->nof_symbols;i++) {
cp_len = SRSLTE_CP_ISNORM(q->cp)?SRSLTE_CP_NORM(i, q->symbol_sz):SRSLTE_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]); srslte_dft_run_c(&q->fft_plan, q->tmp, &output[cp_len]);
input += q->nof_re; input += q->nof_re;
/* add CP */ /* add CP */
memcpy(output, &output[q->symbol_sz], cp_len * sizeof(cf_t)); memcpy(output, &output[q->symbol_sz], cp_len * sizeof(cf_t));
@ -182,16 +183,16 @@ void lte_ifft_run_slot(srslte_fft_t *q, cf_t *input, cf_t *output) {
} }
} }
void srslte_fft_set_normalize(srslte_fft_t *q, bool normalize_enable) { void srslte_ofdm_set_normalize(srslte_ofdm_t *q, bool normalize_enable) {
dft_plan_set_norm(&q->fft_plan, normalize_enable); srslte_dft_plan_set_norm(&q->fft_plan, normalize_enable);
} }
void lte_ifft_run_sf(srslte_fft_t *q, cf_t *input, cf_t *output) { void srslte_ofdm_rx_sf(srslte_ofdm_t *q, cf_t *input, cf_t *output) {
uint32_t n; uint32_t n;
for (n=0;n<2;n++) { for (n=0;n<2;n++) {
lte_ifft_run_slot(q, &input[n*q->nof_re*q->nof_symbols], &output[n*q->slot_sz]); srslte_ofdm_rx_slot(q, &input[n*q->nof_re*q->nof_symbols], &output[n*q->slot_sz]);
} }
if (q->freq_shift) { if (q->freq_shift) {
vec_prod_ccc(output, q->shift_buffer, output, 2*q->slot_sz); srslte_vec_prod_ccc(output, q->shift_buffer, output, 2*q->slot_sz);
} }
} }

@ -23,12 +23,12 @@
# FFT TEST # FFT TEST
######################################################################## ########################################################################
ADD_EXECUTABLE(fft_test fft_test.c) ADD_EXECUTABLE(ofdm_test ofdm_test.c)
TARGET_LINK_LIBRARIES(fft_test lte_phy) TARGET_LINK_LIBRARIES(ofdm_test lte_phy)
ADD_TEST(fft_normal fft_test) ADD_TEST(ofdm_normal ofdm_test)
ADD_TEST(fft_extended fft_test -e) ADD_TEST(ofdm_extended ofdm_test -e)
ADD_TEST(fft_normal_single fft_test -n 6) ADD_TEST(ofdm_normal_single ofdm_test -n 6)
ADD_TEST(fft_extended_single fft_test -e -n 6) ADD_TEST(ofdm_extended_single ofdm_test -e -n 6)

@ -62,7 +62,7 @@ void parse_args(int argc, char **argv) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
srslte_fft_t fft, ifft; srslte_ofdm_t fft, ifft;
cf_t *input, *outfft, *outifft; cf_t *input, *outfft, *outifft;
float mse; float mse;
int n_prb, max_prb, n_re; int n_prb, max_prb, n_re;
@ -98,24 +98,24 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
if (srslte_fft_init(&fft, cp, n_prb)) { if (srslte_ofdm_tx_init(&fft, cp, n_prb)) {
fprintf(stderr, "Error initializing FFT\n"); fprintf(stderr, "Error initializing FFT\n");
exit(-1); exit(-1);
} }
dft_plan_set_norm(&fft.fft_plan, true); srslte_dft_plan_set_norm(&fft.fft_plan, true);
if (lte_ifft_init(&ifft, cp, n_prb)) { if (srslte_ofdm_rx_init(&ifft, cp, n_prb)) {
fprintf(stderr, "Error initializing iFFT\n"); fprintf(stderr, "Error initializing iFFT\n");
exit(-1); exit(-1);
} }
dft_plan_set_norm(&ifft.fft_plan, true); srslte_dft_plan_set_norm(&ifft.fft_plan, true);
for (i=0;i<n_re;i++) { for (i=0;i<n_re;i++) {
input[i] = 100 * ((float) rand()/RAND_MAX + (float) I*rand()/RAND_MAX); input[i] = 100 * ((float) rand()/RAND_MAX + (float) I*rand()/RAND_MAX);
} }
lte_ifft_run_slot(&ifft, input, outfft); srslte_ofdm_rx_slot(&ifft, input, outfft);
srslte_fft_run_slot(&fft, outfft, outifft); srslte_ofdm_tx_slot(&fft, outfft, outifft);
/* compute MSE */ /* compute MSE */
@ -130,8 +130,8 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
srslte_fft_free(&fft); srslte_ofdm_tx_free(&fft);
lte_ifft_free(&ifft); srslte_ofdm_rx_free(&ifft);
free(input); free(input);
free(outfft); free(outfft);

@ -29,7 +29,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "srslte/utils/pack.h" #include "srslte/utils/bit.h"
#include "srslte/fec/crc.h" #include "srslte/fec/crc.h"
void gen_srslte_crc_table(srslte_crc_t *h) { void gen_srslte_crc_table(srslte_crc_t *h) {
@ -137,7 +137,7 @@ uint32_t srslte_crc_checksum(srslte_crc_t *h, uint8_t *data, int len) {
h->byte |= ((uint8_t) *(pter + k)) << (7 - k); h->byte |= ((uint8_t) *(pter + k)) << (7 - k);
} }
} else { } else {
h->byte = (uint8_t) (unpack_bits(&pter, 8) & 0xFF); h->byte = (uint8_t) (srslte_bit_unpack(&pter, 8) & 0xFF);
} }
crc = crctable(h); crc = crctable(h);
} }
@ -160,6 +160,6 @@ void srslte_crc_attach(srslte_crc_t *h, uint8_t *data, int len) {
// Add CRC // Add CRC
uint8_t *ptr = &data[len]; uint8_t *ptr = &data[len];
pack_bits(checksum, &ptr, h->order); srslte_bit_pack(checksum, &ptr, h->order);
} }

@ -166,9 +166,9 @@ void srslte_map_gen_alpha(srslte_map_gen_t * s, srslte_llr_t * input, srslte_llr
int srslte_map_gen_init(srslte_map_gen_t * h, int max_long_cb) int srslte_map_gen_init(srslte_map_gen_t * h, int max_long_cb)
{ {
bzero(h, sizeof(srslte_map_gen_t)); bzero(h, sizeof(srslte_map_gen_t));
h->beta = vec_malloc(sizeof(srslte_llr_t) * (max_long_cb + SRSLTE_TCOD_TOTALTAIL + 1) * NUMSTATES); h->beta = srslte_vec_malloc(sizeof(srslte_llr_t) * (max_long_cb + SRSLTE_TCOD_TOTALTAIL + 1) * NUMSTATES);
if (!h->beta) { if (!h->beta) {
perror("vec_malloc"); perror("srslte_vec_malloc");
return -1; return -1;
} }
h->max_long_cb = max_long_cb; h->max_long_cb = max_long_cb;
@ -209,29 +209,29 @@ int srslte_tdec_init(srslte_tdec_t * h, uint32_t max_long_cb)
h->max_long_cb = max_long_cb; h->max_long_cb = max_long_cb;
h->llr1 = vec_malloc(sizeof(srslte_llr_t) * len); h->llr1 = srslte_vec_malloc(sizeof(srslte_llr_t) * len);
if (!h->llr1) { if (!h->llr1) {
perror("vec_malloc"); perror("srslte_vec_malloc");
goto clean_and_exit; goto clean_and_exit;
} }
h->llr2 = vec_malloc(sizeof(srslte_llr_t) * len); h->llr2 = srslte_vec_malloc(sizeof(srslte_llr_t) * len);
if (!h->llr2) { if (!h->llr2) {
perror("vec_malloc"); perror("srslte_vec_malloc");
goto clean_and_exit; goto clean_and_exit;
} }
h->w = vec_malloc(sizeof(srslte_llr_t) * len); h->w = srslte_vec_malloc(sizeof(srslte_llr_t) * len);
if (!h->w) { if (!h->w) {
perror("vec_malloc"); perror("srslte_vec_malloc");
goto clean_and_exit; goto clean_and_exit;
} }
h->syst = vec_malloc(sizeof(srslte_llr_t) * len); h->syst = srslte_vec_malloc(sizeof(srslte_llr_t) * len);
if (!h->syst) { if (!h->syst) {
perror("vec_malloc"); perror("srslte_vec_malloc");
goto clean_and_exit; goto clean_and_exit;
} }
h->parity = vec_malloc(sizeof(srslte_llr_t) * len); h->parity = srslte_vec_malloc(sizeof(srslte_llr_t) * len);
if (!h->parity) { if (!h->parity) {
perror("vec_malloc"); perror("srslte_vec_malloc");
goto clean_and_exit; goto clean_and_exit;
} }

@ -218,7 +218,7 @@ int srslte_viterbi_decode_f(srslte_viterbi_t *q, float *symbols, uint8_t *data,
len = 3 * (frame_length + q->K - 1); len = 3 * (frame_length + q->K - 1);
} }
if (!q->decode_f) { if (!q->decode_f) {
vec_quant_fuc(symbols, q->symbols_uc, q->gain_quant, 127.5, 255, len); srslte_vec_quant_fuc(symbols, q->symbols_uc, q->gain_quant, 127.5, 255, len);
return q->decode(q, q->symbols_uc, data, frame_length); return q->decode(q, q->symbols_uc, data, frame_length);
} else { } else {
return q->decode_f(q, symbols, data, frame_length); return q->decode_f(q, symbols, data, frame_length);

@ -68,8 +68,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
trblklen = (uint32_t) mxGetScalar(TRBLKLEN); trblklen = (uint32_t) mxGetScalar(TRBLKLEN);
rvidx = (uint32_t) mxGetScalar(RV); rvidx = (uint32_t) mxGetScalar(RV);
struct cb_segm cbsegm; srslte_harq_cbsegm_t cbsegm;
codeblock_segmentation(&cbsegm, trblklen); srslte_harq_codeblock_segmentation(&cbsegm, trblklen);
cblen = 3*cbsegm.K1+12; cblen = 3*cbsegm.K1+12;
w_buff_f = calloc(1,sizeof(float) * cblen * 10); w_buff_f = calloc(1,sizeof(float) * cblen * 10);
@ -79,7 +79,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
// allocate memory for output bits // allocate memory for output bits
output = vec_malloc(cblen * sizeof(float)); output = srslte_vec_malloc(cblen * sizeof(float));
srslte_rm_turbo_rx(w_buff_f, cblen * 10, input, in_len, output, cblen, srslte_rm_turbo_rx(w_buff_f, cblen * 10, input, in_len, output, cblen,
rvidx,cbsegm.F); rvidx,cbsegm.F);

@ -129,12 +129,12 @@ int main(int argc, char **argv) {
} }
printf("BITS: "); printf("BITS: ");
vec_fprint_b(stdout, bits, nof_tx_bits); srslte_vec_fprint_b(stdout, bits, nof_tx_bits);
srslte_rm_turbo_tx(w_buff_c, nof_tx_bits * 10, bits, nof_tx_bits, rm_bits, nof_rx_bits, rv_idx); srslte_rm_turbo_tx(w_buff_c, nof_tx_bits * 10, bits, nof_tx_bits, rm_bits, nof_rx_bits, rv_idx);
printf("RM: "); printf("RM: ");
vec_fprint_b(stdout, rm_bits, nof_rx_bits); srslte_vec_fprint_b(stdout, rm_bits, nof_rx_bits);
for (i = 0; i < nof_rx_bits; i++) { for (i = 0; i < nof_rx_bits; i++) {
rm_symbols[i] = (float) rm_bits[i] ? 1 : -1; rm_symbols[i] = (float) rm_bits[i] ? 1 : -1;
@ -144,15 +144,15 @@ int main(int argc, char **argv) {
rv_idx, nof_filler_bits); rv_idx, nof_filler_bits);
printf("UMRM: "); printf("UMRM: ");
vec_fprint_f(stdout, unrm_symbols, nof_tx_bits); srslte_vec_fprint_f(stdout, unrm_symbols, nof_tx_bits);
for (i=0;i<nof_tx_bits;i++) { for (i=0;i<nof_tx_bits;i++) {
bits_out[i] = unrm_symbols[i]>0?1:0; bits_out[i] = unrm_symbols[i]>0?1:0;
} }
printf("BITS: "); printf("BITS: ");
vec_fprint_b(stdout, bits_out, nof_tx_bits); srslte_vec_fprint_b(stdout, bits_out, nof_tx_bits);
printf("BITS: "); printf("BITS: ");
vec_fprint_b(stdout, bits, nof_tx_bits); srslte_vec_fprint_b(stdout, bits, nof_tx_bits);
nof_errors = 0; nof_errors = 0;
for (i = 0; i < nof_tx_bits; i++) { for (i = 0; i < nof_tx_bits; i++) {

@ -93,7 +93,7 @@ void parse_args(int argc, char **argv) {
seed = (uint32_t) strtoul(argv[optind], NULL, 0); seed = (uint32_t) strtoul(argv[optind], NULL, 0);
break; break;
case 'v': case 'v':
verbose++; srslte_verbose++;
break; break;
default: default:
usage(argv[0]); usage(argv[0]);
@ -162,29 +162,29 @@ int main(int argc, char **argv) {
printf(" EbNo: %.2f\n", ebno_db); printf(" EbNo: %.2f\n", ebno_db);
} }
data_tx = vec_malloc(frame_length * sizeof(uint8_t)); data_tx = srslte_vec_malloc(frame_length * sizeof(uint8_t));
if (!data_tx) { if (!data_tx) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);
} }
data_rx = vec_malloc(frame_length * sizeof(uint8_t)); data_rx = srslte_vec_malloc(frame_length * sizeof(uint8_t));
if (!data_rx) { if (!data_rx) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);
} }
symbols = vec_malloc(coded_length * sizeof(uint8_t)); symbols = srslte_vec_malloc(coded_length * sizeof(uint8_t));
if (!symbols) { if (!symbols) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);
} }
llr = vec_malloc(coded_length * sizeof(float)); llr = srslte_vec_malloc(coded_length * sizeof(float));
if (!llr) { if (!llr) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);
} }
llr_c = vec_malloc(coded_length * sizeof(uint8_t)); llr_c = srslte_vec_malloc(coded_length * sizeof(uint8_t));
if (!llr_c) { if (!llr_c) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);
@ -267,7 +267,7 @@ int main(int argc, char **argv) {
mean_usec = (float) mean_usec * 0.9 + (float) tdata[0].tv_usec * 0.1; mean_usec = (float) mean_usec * 0.9 + (float) tdata[0].tv_usec * 0.1;
/* check errors */ /* check errors */
errors[j] += bit_diff(data_tx, data_rx, frame_length); errors[j] += srslte_bit_diff(data_tx, data_rx, frame_length);
if (j < MAX_ITERATIONS) { if (j < MAX_ITERATIONS) {
ber[j][i] = (float) errors[j] / (frame_cnt * frame_length); ber[j][i] = (float) errors[j] / (frame_cnt * frame_length);
} }

@ -84,7 +84,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
// allocate memory for output bits // allocate memory for output bits
output_data = vec_malloc(nof_bits * sizeof(uint8_t)); output_data = srslte_vec_malloc(nof_bits * sizeof(uint8_t));
if (srslte_tdec_init(&tdec, nof_bits)) { if (srslte_tdec_init(&tdec, nof_bits)) {
mexErrMsgTxt("Error initiating Turbo decoder\n"); mexErrMsgTxt("Error initiating Turbo decoder\n");

@ -279,7 +279,7 @@ int main(int argc, char **argv) {
} }
srslte_ch_awgn_f(llr, llr, var[i], coded_length[n]); srslte_ch_awgn_f(llr, llr, var[i], coded_length[n]);
vec_quant_fuc(llr, llr_c, Gain, 127.5, 255, coded_length[n]); srslte_vec_quant_fuc(llr, llr_c, Gain, 127.5, 255, coded_length[n]);
/* decoder 1 */ /* decoder 1 */
srslte_viterbi_decode_uc(&dec[n], llr_c, data_rx[1+n], frame_length); srslte_viterbi_decode_uc(&dec[n], llr_c, data_rx[1+n], frame_length);
@ -287,7 +287,7 @@ int main(int argc, char **argv) {
/* check errors */ /* check errors */
for (j = 0; j < 1+ncods; j++) { for (j = 0; j < 1+ncods; j++) {
errors[j] += bit_diff(data_tx, data_rx[j], frame_length); errors[j] += srslte_bit_diff(data_tx, data_rx[j], frame_length);
} }
frame_cnt++; frame_cnt++;
printf("Eb/No: %3.2f %10d/%d ", printf("Eb/No: %3.2f %10d/%d ",

@ -59,7 +59,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
// Read input symbols // Read input symbols
nof_bits = mexutils_read_f(INPUT, &input_llr); nof_bits = mexutils_read_f(INPUT, &input_llr);
output_data = vec_malloc(nof_bits * sizeof(uint8_t)); output_data = srslte_vec_malloc(nof_bits * sizeof(uint8_t));
uint32_t poly[3] = { 0x6D, 0x4F, 0x57 }; uint32_t poly[3] = { 0x6D, 0x4F, 0x57 };
if (srslte_viterbi_init(&viterbi, SRSLTE_VITERBI_37, poly, nof_bits/3, true)) { if (srslte_viterbi_init(&viterbi, SRSLTE_VITERBI_37, poly, nof_bits/3, true)) {

@ -1,194 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The libLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the libLTE library.
*
* libLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include "srslte/utils/debug.h"
#include "srslte/resampling/interp.h"
#include "srslte/filter/filter2d.h"
#include "srslte/utils/matrix.h"
#include "srslte/utils/vector.h"
#include "srslte/utils/debug.h"
/* Useful macros */
#define intceil(X, Y) ((X-1)/Y+1)
#define idx(a, b) ((a)*(q->szfreq+q->nfreq)+b)
int srslte_filter2d_init(srslte_filter2d_t* q, float **taps, uint32_t ntime, uint32_t nfreq, uint32_t sztime,
uint32_t szfreq) {
int ret = -1;
bzero(q, sizeof(srslte_filter2d_t));
if (matrix_init((void***)&q->taps, ntime, nfreq, sizeof(float))) {
goto free_and_exit;
}
matrix_copy((void**) q->taps, (void**) taps, ntime, nfreq, sizeof(float));
q->output = vec_malloc((ntime+sztime)*(szfreq+nfreq)*sizeof(cf_t));
if (!q->output) {
goto free_and_exit;
}
bzero(q->output, (ntime+sztime)*(szfreq+nfreq)*sizeof(cf_t));
q->nfreq = nfreq;
q->ntime = ntime;
q->szfreq = szfreq;
q->sztime = sztime;
q->norm = 0.0;
for (int i = 0; i < ntime; i++) {
for (int j = 0; j < nfreq; j++) {
q->norm += q->taps[i][j];
}
}
ret = 0;
free_and_exit: if (ret == -1) {
srslte_filter2d_free(q);
}
return ret;
}
void srslte_filter2d_free(srslte_filter2d_t *q) {
matrix_free((void**) q->taps, q->ntime);
if (q->output) {
free(q->output);
}
bzero(q, sizeof(srslte_filter2d_t));
}
int srslte_filter2d_init_ones(srslte_filter2d_t* q, uint32_t ntime, uint32_t nfreq, uint32_t sztime,
uint32_t szfreq)
{
int i, j;
float **taps;
int ret = -1;
if (matrix_init((void***) &taps, ntime, nfreq, sizeof(float))) {
goto free_and_exit;
}
/* Compute the default 2-D interpolation mesh */
for (i = 0; i < ntime; i++) {
for (j = 0; j < nfreq; j++) {
taps[i][j] = 1.0/(i+1);
}
}
INFO("Using all-ones interpolation matrix of size %dx%d\n", ntime, nfreq);
if (verbose >= VERBOSE_INFO) {
matrix_fprintf_f(stdout, taps, ntime, nfreq);
}
if (srslte_filter2d_init(q, taps, ntime, nfreq, sztime, szfreq)) {
goto free_and_exit;
}
ret = 0;
free_and_exit:
matrix_free((void**) taps, ntime);
return ret;
}
/* Moves the last ntime symbols to the start and clears the remaining of the output.
* Should be called, for instance, before filtering each OFDM frame.
*/
void srslte_filter2d_step(srslte_filter2d_t *q) {
int i;
for (i = 0; i < q->ntime; i++) {
memcpy(&q->output[idx(i,0)], &q->output[idx(q->sztime + i,0)],
sizeof(cf_t) * (q->szfreq+q->nfreq));
}
for (; i < q->ntime + q->sztime; i++) {
memset(&q->output[idx(i,0)], 0, sizeof(cf_t) * (q->szfreq+q->nfreq));
}
}
void srslte_filter2d_reset(srslte_filter2d_t *q) {
bzero(q->output, (q->ntime+q->sztime)*(q->szfreq+q->nfreq)*sizeof(cf_t));
}
/** Adds samples x to the from the given time/freq indexes to the filter
* and computes the output.
*/
void srslte_filter2d_add(srslte_filter2d_t *q, cf_t x, uint32_t time_idx, uint32_t freq_idx) {
int i, j;
uint32_t ntime = q->ntime;
uint32_t nfreq = q->nfreq;
if (freq_idx < q->szfreq && time_idx < q->sztime) {
DEBUG("Adding %f+%fi to %d:%d\n",__real__ x,__imag__ x,time_idx,freq_idx);
for (i = 0; i < ntime; i++) {
for (j = 0; j < nfreq; j++) {
q->output[idx(i+time_idx, j+freq_idx)] += x * (cf_t)(q->taps[i][j])/q->norm;
}
}
}
}
void srslte_filter2d_add_out(srslte_filter2d_t *q, cf_t x, int time_idx, int freq_idx) {
int i, j;
uint32_t ntime = q->ntime;
uint32_t nfreq = q->nfreq;
float norm=0;
for (i = 0; i < ntime; i++) {
for (j = 0; j < nfreq; j++) {
if (i+time_idx >= 0 && j+freq_idx >= 0 &&
i+time_idx < q->ntime+q->sztime && j+freq_idx < q->nfreq + q->szfreq)
{
norm += q->taps[i][j];
}
}
}
for (i = 0; i < ntime; i++) {
for (j = 0; j < nfreq; j++) {
if (i+time_idx >= 0 && j+freq_idx >= 0 &&
i+time_idx < q->ntime+q->sztime && j+freq_idx < q->nfreq + q->szfreq)
{
q->output[idx(i+time_idx, j+freq_idx)] += x * (cf_t)(q->taps[i][j])/q->norm;
}
}
}
}
void srslte_filter2d_get_symbol(srslte_filter2d_t *q, uint32_t nsymbol, cf_t *output) {
memcpy(output, &q->output[idx(nsymbol,q->nfreq/2)], sizeof(cf_t) * (q->szfreq));
}

@ -106,9 +106,9 @@ static int int_2_bits(uint32_t* src, uint8_t* dst, int nbits) {
int n; int n;
n=nbits/32; n=nbits/32;
for (int i=0;i<n;i++) { for (int i=0;i<n;i++) {
bit_pack(src[i],&dst,32); srslte_bit_pack(src[i],&dst,32);
} }
bit_pack(src[n],&dst,nbits-n*32); srslte_bit_pack(src[n],&dst,nbits-n*32);
return n; return n;
} }

@ -94,7 +94,7 @@ int srslte_layermap_type(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_LAYER
} }
switch(type) { switch(type) {
case SINGLE_ANTENNA: case SRSLTE_MIMO_TYPE_SINGLE_ANTENNA:
if (nof_cw == 1 && nof_layers == 1) { if (nof_cw == 1 && nof_layers == 1) {
return srslte_layermap_single(x[0], d[0], nof_symbols[0]); return srslte_layermap_single(x[0], d[0], nof_symbols[0]);
} else { } else {
@ -102,7 +102,7 @@ int srslte_layermap_type(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_LAYER
return -1; return -1;
} }
break; break;
case TX_DIVERSITY: case SRSLTE_MIMO_TYPE_TX_DIVERSITY:
if (nof_cw == 1) { if (nof_cw == 1) {
if (nof_layers == 2 || nof_layers == 4) { if (nof_layers == 2 || nof_layers == 4) {
return srslte_layermap_diversity(d[0], x, nof_layers, nof_symbols[0]); return srslte_layermap_diversity(d[0], x, nof_layers, nof_symbols[0]);
@ -115,7 +115,7 @@ int srslte_layermap_type(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_LAYER
return -1; return -1;
} }
break; break;
case SPATIAL_MULTIPLEX: case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX:
return srslte_layermap_multiplex(d, x, nof_cw, nof_layers, nof_symbols); return srslte_layermap_multiplex(d, x, nof_cw, nof_layers, nof_symbols);
break; break;
} }
@ -183,7 +183,7 @@ int srslte_layerdemap_type(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d[SRSLTE_MAX_CODEWO
} }
switch(type) { switch(type) {
case SINGLE_ANTENNA: case SRSLTE_MIMO_TYPE_SINGLE_ANTENNA:
if (nof_cw == 1 && nof_layers == 1) { if (nof_cw == 1 && nof_layers == 1) {
nof_symbols[0] = srslte_layerdemap_single(x[0], d[0], nof_layer_symbols); nof_symbols[0] = srslte_layerdemap_single(x[0], d[0], nof_layer_symbols);
nof_symbols[1] = 0; nof_symbols[1] = 0;
@ -192,7 +192,7 @@ int srslte_layerdemap_type(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d[SRSLTE_MAX_CODEWO
return -1; return -1;
} }
break; break;
case TX_DIVERSITY: case SRSLTE_MIMO_TYPE_TX_DIVERSITY:
if (nof_cw == 1) { if (nof_cw == 1) {
if (nof_layers == 2 || nof_layers == 4) { if (nof_layers == 2 || nof_layers == 4) {
nof_symbols[0] = srslte_layerdemap_diversity(x, d[0], nof_layers, nof_layer_symbols); nof_symbols[0] = srslte_layerdemap_diversity(x, d[0], nof_layers, nof_layer_symbols);
@ -206,7 +206,7 @@ int srslte_layerdemap_type(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d[SRSLTE_MAX_CODEWO
return -1; return -1;
} }
break; break;
case SPATIAL_MULTIPLEX: case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX:
return srslte_layerdemap_multiplex(x, d, nof_layers, nof_cw, nof_layer_symbols, nof_symbols); return srslte_layerdemap_multiplex(x, d, nof_layers, nof_cw, nof_layer_symbols, nof_symbols);
break; break;
} }

@ -42,41 +42,41 @@
* *
**************************************************/ **************************************************/
int precoding_init(precoding_t *q, uint32_t max_frame_len) { int srslte_precoding_init(srslte_precoding_t *q, uint32_t max_frame_len) {
if (q) { if (q) {
bzero(q, sizeof(precoding_t)); bzero(q, sizeof(srslte_precoding_t));
q->h_mod = vec_malloc(sizeof(cf_t) * max_frame_len); q->h_mod = srslte_vec_malloc(sizeof(cf_t) * max_frame_len);
if (!q->h_mod) { if (!q->h_mod) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
q->tmp1 = vec_malloc(sizeof(cf_t) * max_frame_len); q->tmp1 = srslte_vec_malloc(sizeof(cf_t) * max_frame_len);
if (!q->tmp1) { if (!q->tmp1) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
q->tmp2 = vec_malloc(sizeof(cf_t) * max_frame_len); q->tmp2 = srslte_vec_malloc(sizeof(cf_t) * max_frame_len);
if (!q->tmp2) { if (!q->tmp2) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
q->tmp3 = vec_malloc(sizeof(cf_t) * max_frame_len); q->tmp3 = srslte_vec_malloc(sizeof(cf_t) * max_frame_len);
if (!q->tmp3) { if (!q->tmp3) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
q->y_mod = vec_malloc(sizeof(float) * max_frame_len); q->y_mod = srslte_vec_malloc(sizeof(float) * max_frame_len);
if (!q->y_mod) { if (!q->y_mod) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
q->z_real = vec_malloc(sizeof(float) * max_frame_len); q->z_real = srslte_vec_malloc(sizeof(float) * max_frame_len);
if (!q->z_real) { if (!q->z_real) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
q->z_imag = vec_malloc(sizeof(float) * max_frame_len); q->z_imag = srslte_vec_malloc(sizeof(float) * max_frame_len);
if (!q->z_imag) { if (!q->z_imag) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
@ -87,11 +87,11 @@ int precoding_init(precoding_t *q, uint32_t max_frame_len) {
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;
} }
clean_exit: clean_exit:
precoding_free(q); srslte_precoding_free(q);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
void precoding_free(precoding_t *q) { void srslte_precoding_free(srslte_precoding_t *q) {
if (q->tmp1) { if (q->tmp1) {
free(q->tmp1); free(q->tmp1);
@ -114,22 +114,22 @@ void precoding_free(precoding_t *q) {
if (q->z_imag) { if (q->z_imag) {
free(q->z_imag); free(q->z_imag);
} }
bzero(q, sizeof(precoding_t)); bzero(q, sizeof(srslte_precoding_t));
} }
/* ZF/MMSE SISO equalizer x=y(h'h+no)^(-1)h' (ZF if n0=0.0)*/ /* ZF/MMSE SISO equalizer x=y(h'h+no)^(-1)h' (ZF if n0=0.0)*/
int predecoding_single(precoding_t *q, cf_t *y, cf_t *h, cf_t *x, int nof_symbols, float noise_estimate) { int srslte_predecoding_single(srslte_precoding_t *q, cf_t *y, cf_t *h, cf_t *x, int nof_symbols, float noise_estimate) {
if (nof_symbols <= q->max_frame_len) { if (nof_symbols <= q->max_frame_len) {
// h'h // h'h
vec_abs_square_cf(h, q->y_mod, nof_symbols); srslte_vec_abs_square_cf(h, q->y_mod, nof_symbols);
if (noise_estimate > 0.0) { if (noise_estimate > 0.0) {
// (h'h + n0) // (h'h + n0)
vec_sc_add_fff(q->y_mod, noise_estimate, q->y_mod, nof_symbols); srslte_vec_sc_add_fff(q->y_mod, noise_estimate, q->y_mod, nof_symbols);
} }
// y*h' // y*h'
vec_prod_conj_ccc(y, h, x, nof_symbols); srslte_vec_prod_conj_ccc(y, h, x, nof_symbols);
// divide by (h'h+no) // divide by (h'h+no)
vec_div_cfc(x,q->y_mod,x,q->z_real,q->z_imag, nof_symbols); srslte_vec_div_cfc(x,q->y_mod,x,q->z_real,q->z_imag, nof_symbols);
return nof_symbols; return nof_symbols;
} else { } else {
return SRSLTE_ERROR; return SRSLTE_ERROR;
@ -138,7 +138,7 @@ int predecoding_single(precoding_t *q, cf_t *y, cf_t *h, cf_t *x, int nof_symbol
/* ZF/MMSE STBC equalizer x=y(H'H+n0·I)^(-1)H' (ZF is n0=0.0) /* ZF/MMSE STBC equalizer x=y(H'H+n0·I)^(-1)H' (ZF is n0=0.0)
*/ */
int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x[SRSLTE_MAX_LAYERS], int srslte_predecoding_diversity(srslte_precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x[SRSLTE_MAX_LAYERS],
int nof_ports, int nof_symbols, float noise_estimate) int nof_ports, int nof_symbols, float noise_estimate)
{ {
int i; int i;
@ -166,27 +166,27 @@ int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf
} }
// Compute common dividend and store in y_mod // Compute common dividend and store in y_mod
vec_abs_square_cf(h0, modh0, nof_symbols/2); srslte_vec_abs_square_cf(h0, modh0, nof_symbols/2);
vec_abs_square_cf(h1, modh1, nof_symbols/2); srslte_vec_abs_square_cf(h1, modh1, nof_symbols/2);
vec_sum_fff(modh0, modh1, modhh, nof_symbols/2); srslte_vec_sum_fff(modh0, modh1, modhh, nof_symbols/2);
//if (noise_estimate > 0.0) { //if (noise_estimate > 0.0) {
// (H'H + n0) // (H'H + n0)
//vec_sc_add_fff(modhh, noise_estimate, modhh, nof_symbols/2); //srslte_vec_sc_add_fff(modhh, noise_estimate, modhh, nof_symbols/2);
//} //}
vec_sc_prod_fff(modhh, 1/sqrt(2), modhh, nof_symbols/2); srslte_vec_sc_prod_fff(modhh, 1/sqrt(2), modhh, nof_symbols/2);
// x[0] = r0·h0*/(|h0|+|h1|)+r1*·h1/(|h0|+|h1|) // x[0] = r0·h0*/(|h0|+|h1|)+r1*·h1/(|h0|+|h1|)
vec_prod_conj_ccc(r0,h0,q->tmp1, nof_symbols/2); srslte_vec_prod_conj_ccc(r0,h0,q->tmp1, nof_symbols/2);
vec_prod_conj_ccc(h1,r1,q->tmp2, nof_symbols/2); srslte_vec_prod_conj_ccc(h1,r1,q->tmp2, nof_symbols/2);
vec_sum_ccc(q->tmp1, q->tmp2, x[0], nof_symbols/2); srslte_vec_sum_ccc(q->tmp1, q->tmp2, x[0], nof_symbols/2);
vec_div_cfc(x[0], modhh, x[0], q->z_real, q->z_imag, nof_symbols/2); srslte_vec_div_cfc(x[0], modhh, x[0], q->z_real, q->z_imag, nof_symbols/2);
// x[1] = r1·h0*/(|h0|+|h1|)-r0*·h1/(|h0|+|h1|) // x[1] = r1·h0*/(|h0|+|h1|)-r0*·h1/(|h0|+|h1|)
vec_prod_conj_ccc(r1,h0,q->tmp1, nof_symbols/2); srslte_vec_prod_conj_ccc(r1,h0,q->tmp1, nof_symbols/2);
vec_prod_conj_ccc(h1,r0,q->tmp2, nof_symbols/2); srslte_vec_prod_conj_ccc(h1,r0,q->tmp2, nof_symbols/2);
vec_sub_ccc(q->tmp1, q->tmp2, x[1], nof_symbols/2); srslte_vec_sub_ccc(q->tmp1, q->tmp2, x[1], nof_symbols/2);
vec_div_cfc(x[1], modhh, x[1], q->z_real, q->z_imag, nof_symbols/2); srslte_vec_div_cfc(x[1], modhh, x[1], q->z_real, q->z_imag, nof_symbols/2);
#else #else
cf_t h0, h1, h2, h3, r0, r1, r2, r3; cf_t h0, h1, h2, h3, r0, r1, r2, r3;
@ -240,7 +240,7 @@ int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf
} }
/* 36.211 v10.3.0 Section 6.3.4 */ /* 36.211 v10.3.0 Section 6.3.4 */
int predecoding_type(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x[SRSLTE_MAX_LAYERS], int srslte_predecoding_type(srslte_precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x[SRSLTE_MAX_LAYERS],
int nof_ports, int nof_layers, int nof_symbols, srslte_mimo_type_t type, float noise_estimate) { 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) {
@ -255,25 +255,25 @@ int predecoding_type(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x
} }
switch (type) { switch (type) {
case SINGLE_ANTENNA: case SRSLTE_MIMO_TYPE_SINGLE_ANTENNA:
if (nof_ports == 1 && nof_layers == 1) { if (nof_ports == 1 && nof_layers == 1) {
return predecoding_single(q, y, h[0], x[0], nof_symbols, noise_estimate); return srslte_predecoding_single(q, y, h[0], x[0], nof_symbols, noise_estimate);
} else { } else {
fprintf(stderr, fprintf(stderr,
"Number of ports and layers must be 1 for transmission on single antenna ports\n"); "Number of ports and layers must be 1 for transmission on single antenna ports\n");
return -1; return -1;
} }
break; break;
case TX_DIVERSITY: case SRSLTE_MIMO_TYPE_TX_DIVERSITY:
if (nof_ports == nof_layers) { if (nof_ports == nof_layers) {
return predecoding_diversity(q, y, h, x, nof_ports, nof_symbols, noise_estimate); return srslte_predecoding_diversity(q, y, h, x, nof_ports, nof_symbols, noise_estimate);
} else { } else {
fprintf(stderr, fprintf(stderr,
"Error number of layers must equal number of ports in transmit diversity\n"); "Error number of layers must equal number of ports in transmit diversity\n");
return -1; return -1;
} }
break; break;
case SPATIAL_MULTIPLEX: case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX:
fprintf(stderr, "Spatial multiplexing not supported\n"); fprintf(stderr, "Spatial multiplexing not supported\n");
return -1; return -1;
} }
@ -291,11 +291,11 @@ int predecoding_type(precoding_t *q, cf_t *y, cf_t *h[SRSLTE_MAX_PORTS], cf_t *x
* *
**************************************************/ **************************************************/
int precoding_single(precoding_t *q, cf_t *x, cf_t *y, int nof_symbols) { int srslte_precoding_single(srslte_precoding_t *q, cf_t *x, cf_t *y, int nof_symbols) {
memcpy(y, x, nof_symbols * sizeof(cf_t)); memcpy(y, x, nof_symbols * sizeof(cf_t));
return nof_symbols; return nof_symbols;
} }
int precoding_diversity(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_ports, int srslte_precoding_diversity(srslte_precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_ports,
int nof_symbols) { int nof_symbols) {
int i; int i;
if (nof_ports == 2) { if (nof_ports == 2) {
@ -306,8 +306,8 @@ int precoding_diversity(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSL
y[1][2 * i + 1] = conjf(x[0][i]); y[1][2 * i + 1] = conjf(x[0][i]);
} }
// normalize // normalize
vec_sc_prod_cfc(y[0], 1.0/sqrtf(2), y[0], 2*nof_symbols); srslte_vec_sc_prod_cfc(y[0], 1.0/sqrtf(2), y[0], 2*nof_symbols);
vec_sc_prod_cfc(y[1], 1.0/sqrtf(2), y[1], 2*nof_symbols); srslte_vec_sc_prod_cfc(y[1], 1.0/sqrtf(2), y[1], 2*nof_symbols);
return 2 * i; return 2 * i;
} else if (nof_ports == 4) { } else if (nof_ports == 4) {
//int m_ap = (nof_symbols%4)?(nof_symbols*4-2):nof_symbols*4; //int m_ap = (nof_symbols%4)?(nof_symbols*4-2):nof_symbols*4;
@ -341,7 +341,7 @@ int precoding_diversity(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSL
} }
/* 36.211 v10.3.0 Section 6.3.4 */ /* 36.211 v10.3.0 Section 6.3.4 */
int precoding_type(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_layers, int srslte_precoding_type(srslte_precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_layers,
int nof_ports, int nof_symbols, srslte_mimo_type_t type) { int nof_ports, int nof_symbols, srslte_mimo_type_t type) {
if (nof_ports > SRSLTE_MAX_PORTS) { if (nof_ports > SRSLTE_MAX_PORTS) {
@ -356,24 +356,24 @@ int precoding_type(precoding_t *q, cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MA
} }
switch (type) { switch (type) {
case SINGLE_ANTENNA: case SRSLTE_MIMO_TYPE_SINGLE_ANTENNA:
if (nof_ports == 1 && nof_layers == 1) { if (nof_ports == 1 && nof_layers == 1) {
return precoding_single(q, x[0], y[0], nof_symbols); return srslte_precoding_single(q, x[0], y[0], nof_symbols);
} else { } else {
fprintf(stderr, fprintf(stderr,
"Number of ports and layers must be 1 for transmission on single antenna ports\n"); "Number of ports and layers must be 1 for transmission on single antenna ports\n");
return -1; return -1;
} }
break; break;
case TX_DIVERSITY: case SRSLTE_MIMO_TYPE_TX_DIVERSITY:
if (nof_ports == nof_layers) { if (nof_ports == nof_layers) {
return precoding_diversity(q, x, y, nof_ports, nof_symbols); return srslte_precoding_diversity(q, x, y, nof_ports, nof_symbols);
} else { } else {
fprintf(stderr, fprintf(stderr,
"Error number of layers must equal number of ports in transmit diversity\n"); "Error number of layers must equal number of ports in transmit diversity\n");
return -1; return -1;
} }
case SPATIAL_MULTIPLEX: case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX:
fprintf(stderr, "Spatial multiplexing not supported\n"); fprintf(stderr, "Spatial multiplexing not supported\n");
return -1; return -1;
} }

@ -82,7 +82,7 @@ int main(int argc, char **argv) {
cf_t *x[SRSLTE_MAX_LAYERS], *r[SRSLTE_MAX_PORTS], *y[SRSLTE_MAX_PORTS], *h[SRSLTE_MAX_PORTS], cf_t *x[SRSLTE_MAX_LAYERS], *r[SRSLTE_MAX_PORTS], *y[SRSLTE_MAX_PORTS], *h[SRSLTE_MAX_PORTS],
*xr[SRSLTE_MAX_LAYERS]; *xr[SRSLTE_MAX_LAYERS];
srslte_mimo_type_t type; srslte_mimo_type_t type;
precoding_t precoding; srslte_precoding_t precoding;
parse_args(argc, argv); parse_args(argc, argv);
@ -97,35 +97,35 @@ int main(int argc, char **argv) {
} }
for (i = 0; i < nof_layers; i++) { for (i = 0; i < nof_layers; i++) {
x[i] = vec_malloc(sizeof(cf_t) * nof_symbols); x[i] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols);
if (!x[i]) { if (!x[i]) {
perror("vec_malloc"); perror("srslte_vec_malloc");
exit(-1); exit(-1);
} }
xr[i] = calloc(1,sizeof(cf_t) * nof_symbols); xr[i] = calloc(1,sizeof(cf_t) * nof_symbols);
if (!xr[i]) { if (!xr[i]) {
perror("vec_malloc"); perror("srslte_vec_malloc");
exit(-1); exit(-1);
} }
} }
for (i = 0; i < nof_ports; i++) { for (i = 0; i < nof_ports; i++) {
y[i] = vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers); y[i] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers);
// TODO: The number of symbols per port is different in spatial multiplexing. // TODO: The number of symbols per port is different in spatial multiplexing.
if (!y[i]) { if (!y[i]) {
perror("vec_malloc"); perror("srslte_vec_malloc");
exit(-1); exit(-1);
} }
h[i] = vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers); h[i] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers);
if (!h[i]) { if (!h[i]) {
perror("vec_malloc"); perror("srslte_vec_malloc");
exit(-1); exit(-1);
} }
} }
/* only 1 receiver antenna supported now */ /* only 1 receiver antenna supported now */
r[0] = vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers); r[0] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols * nof_layers);
if (!r[0]) { if (!r[0]) {
perror("vec_malloc"); perror("srslte_vec_malloc");
exit(-1); exit(-1);
} }
@ -136,13 +136,13 @@ int main(int argc, char **argv) {
} }
} }
if (precoding_init(&precoding, nof_symbols * nof_layers)) { if (srslte_precoding_init(&precoding, nof_symbols * nof_layers)) {
fprintf(stderr, "Error initializing precoding\n"); fprintf(stderr, "Error initializing precoding\n");
exit(-1); exit(-1);
} }
/* precoding */ /* precoding */
if (precoding_type(&precoding, x, y, nof_layers, nof_ports, nof_symbols, type) < 0) { if (srslte_precoding_type(&precoding, x, y, nof_layers, nof_ports, nof_symbols, type) < 0) {
fprintf(stderr, "Error layer mapper encoder\n"); fprintf(stderr, "Error layer mapper encoder\n");
exit(-1); exit(-1);
} }
@ -173,7 +173,7 @@ int main(int argc, char **argv) {
/* predecoding / equalization */ /* predecoding / equalization */
struct timeval t[3]; struct timeval t[3];
gettimeofday(&t[1], NULL); gettimeofday(&t[1], NULL);
if (predecoding_type(&precoding, r[0], h, xr, nof_ports, nof_layers, if (srslte_predecoding_type(&precoding, r[0], h, xr, nof_ports, nof_layers,
nof_symbols * nof_layers, type, 0) < 0) { nof_symbols * nof_layers, type, 0) < 0) {
fprintf(stderr, "Error layer mapper encoder\n"); fprintf(stderr, "Error layer mapper encoder\n");
exit(-1); exit(-1);
@ -206,7 +206,7 @@ int main(int argc, char **argv) {
free(r[0]); free(r[0]);
precoding_free(&precoding); srslte_precoding_free(&precoding);
printf("Ok\n"); printf("Ok\n");
exit(0); exit(0);

@ -33,31 +33,31 @@
#include "hard_demod_lte.h" #include "hard_demod_lte.h"
void demod_hard_init(demod_hard_t* q) { void srslte_demod_hard_init(srslte_demod_hard_t* q) {
bzero((void*) q, sizeof(demod_hard_t)); bzero((void*) q, sizeof(srslte_demod_hard_t));
} }
void demod_hard_table_set(demod_hard_t* q, srslte_mod_t mod) { void srslte_demod_hard_table_set(srslte_demod_hard_t* q, srslte_mod_t mod) {
q->mod = mod; q->mod = mod;
} }
int demod_hard_demodulate(demod_hard_t* q, cf_t* symbols, uint8_t *bits, uint32_t nsymbols) { int srslte_demod_hard_demodulate(srslte_demod_hard_t* q, cf_t* symbols, uint8_t *bits, uint32_t nsymbols) {
int nbits=-1; int nbits=-1;
switch(q->mod) { switch(q->mod) {
case LTE_BPSK: case SRSLTE_MOD_BPSK:
hard_bpsk_demod(symbols,bits,nsymbols); hard_bpsk_demod(symbols,bits,nsymbols);
nbits=nsymbols; nbits=nsymbols;
break; break;
case LTE_QPSK: case SRSLTE_MOD_QPSK:
hard_qpsk_demod(symbols,bits,nsymbols); hard_qpsk_demod(symbols,bits,nsymbols);
nbits=nsymbols*2; nbits=nsymbols*2;
break; break;
case LTE_QAM16: case SRSLTE_MOD_16QAM:
hard_qam16_demod(symbols,bits,nsymbols); hard_qam16_demod(symbols,bits,nsymbols);
nbits=nsymbols*4; nbits=nsymbols*4;
break; break;
case LTE_QAM64: case SRSLTE_MOD_64QAM:
hard_qam64_demod(symbols,bits,nsymbols); hard_qam64_demod(symbols,bits,nsymbols);
nbits=nsymbols*6; nbits=nsymbols*6;
break; break;
@ -66,20 +66,20 @@ int demod_hard_demodulate(demod_hard_t* q, cf_t* symbols, uint8_t *bits, uint32_
} }
int demod_hard_initialize(demod_hard_hl* hl) { int srslte_demod_hard_initialize(srslte_demod_hard_hl* hl) {
demod_hard_init(&hl->obj); srslte_demod_hard_init(&hl->obj);
demod_hard_table_set(&hl->obj,hl->init.std); srslte_demod_hard_table_set(&hl->obj,hl->init.std);
return 0; return 0;
} }
int demod_hard_work(demod_hard_hl* hl) { int srslte_demod_hard_work(srslte_demod_hard_hl* hl) {
int ret = demod_hard_demodulate(&hl->obj,hl->input,hl->output,hl->in_len); int ret = srslte_demod_hard_demodulate(&hl->obj,hl->input,hl->output,hl->in_len);
hl->out_len = ret; hl->out_len = ret;
return 0; return 0;
} }
int demod_hard_stop(demod_hard_hl* hl) { int srslte_demod_hard_stop(srslte_demod_hard_hl* hl) {
return 0; return 0;
} }

@ -35,17 +35,17 @@
#include "soft_algs.h" #include "soft_algs.h"
int demod_soft_init(demod_soft_t *q, uint32_t max_symbols) { int srslte_demod_soft_init(srslte_demod_soft_t *q, uint32_t max_symbols) {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
bzero((void*)q,sizeof(demod_soft_t)); bzero((void*)q,sizeof(srslte_demod_soft_t));
q->sigma = 1.0; q->sigma = 1.0;
q->zones = vec_malloc(sizeof(uint32_t) * max_symbols); q->zones = srslte_vec_malloc(sizeof(uint32_t) * max_symbols);
if (!q->zones) { if (!q->zones) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
} }
q->dd = vec_malloc(sizeof(float*) * max_symbols * 7); q->dd = srslte_vec_malloc(sizeof(float*) * max_symbols * 7);
if (!q->dd) { if (!q->dd) {
perror("malloc"); perror("malloc");
goto clean_exit; goto clean_exit;
@ -56,40 +56,40 @@ int demod_soft_init(demod_soft_t *q, uint32_t max_symbols) {
clean_exit: clean_exit:
if (ret != SRSLTE_SUCCESS) { if (ret != SRSLTE_SUCCESS) {
demod_soft_free(q); srslte_demod_soft_free(q);
} }
return ret; return ret;
} }
void demod_soft_free(demod_soft_t *q) { void srslte_demod_soft_free(srslte_demod_soft_t *q) {
if (q->zones) { if (q->zones) {
free(q->zones); free(q->zones);
} }
if (q->dd) { if (q->dd) {
free(q->dd); free(q->dd);
} }
bzero((void*)q,sizeof(demod_soft_t)); bzero((void*)q,sizeof(srslte_demod_soft_t));
} }
void demod_soft_table_set(demod_soft_t *q, modem_table_t *table) { void srslte_demod_soft_table_set(srslte_demod_soft_t *q, srslte_srslte_modem_table_t *table) {
q->table = table; q->table = table;
} }
void demod_soft_alg_set(demod_soft_t *q, enum alg alg_type) { void srslte_demod_soft_alg_set(srslte_demod_soft_t *q, srslte_demod_soft_alg_t alg_type) {
q->alg_type = alg_type; q->alg_type = alg_type;
} }
void demod_soft_sigma_set(demod_soft_t *q, float sigma) { void srslte_demod_soft_sigma_set(srslte_demod_soft_t *q, float sigma) {
q->sigma = 2*sigma; q->sigma = 2*sigma;
} }
int demod_soft_demodulate(demod_soft_t *q, const cf_t* symbols, float* llr, int nsymbols) { int srslte_demod_soft_demodulate(srslte_demod_soft_t *q, const cf_t* symbols, float* llr, int nsymbols) {
switch(q->alg_type) { switch(q->alg_type) {
case EXACT: case SRSLTE_DEMOD_SOFT_ALG_EXACT:
llr_exact(symbols, llr, nsymbols, q->table->nsymbols, q->table->nbits_x_symbol, llr_exact(symbols, llr, nsymbols, q->table->nsymbols, q->table->nbits_x_symbol,
q->table->symbol_table, q->table->soft_table.idx, q->sigma); q->table->symbol_table, q->table->soft_table.idx, q->sigma);
break; break;
case APPROX: case SRSLTE_DEMOD_SOFT_ALG_APPROX:
if (nsymbols <= q->max_symbols) { if (nsymbols <= q->max_symbols) {
llr_approx(symbols, llr, nsymbols, q->table->nsymbols, llr_approx(symbols, llr, nsymbols, q->table->nsymbols,
q->table->nbits_x_symbol, q->table->nbits_x_symbol,
@ -109,26 +109,26 @@ int demod_soft_demodulate(demod_soft_t *q, const cf_t* symbols, float* llr, int
/* High-Level API */ /* High-Level API */
int demod_soft_initialize(demod_soft_hl* hl) { int srslte_demod_soft_initialize(srslte_demod_soft_hl* hl) {
modem_table_init(&hl->table); srslte_modem_table_init(&hl->table);
if (modem_table_lte(&hl->table,hl->init.std,true)) { if (srslte_modem_table_lte(&hl->table,hl->init.std,true)) {
return -1; return -1;
} }
demod_soft_init(&hl->obj, 10000); srslte_demod_soft_init(&hl->obj, 10000);
hl->obj.table = &hl->table; hl->obj.table = &hl->table;
return 0; return 0;
} }
int demod_soft_work(demod_soft_hl* hl) { int srslte_demod_soft_work(srslte_demod_soft_hl* hl) {
hl->obj.sigma = hl->ctrl_in.sigma; hl->obj.sigma = hl->ctrl_in.sigma;
hl->obj.alg_type = hl->ctrl_in.alg_type; hl->obj.alg_type = hl->ctrl_in.alg_type;
int ret = demod_soft_demodulate(&hl->obj,hl->input,hl->output,hl->in_len); int ret = srslte_demod_soft_demodulate(&hl->obj,hl->input,hl->output,hl->in_len);
hl->out_len = ret; hl->out_len = ret;
return 0; return 0;
} }
int demod_soft_stop(demod_soft_hl* hl) { int srslte_demod_soft_stop(srslte_demod_soft_hl* hl) {
modem_table_free(&hl->table); srslte_modem_table_free(&hl->table);
return 0; return 0;
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save