Standard vector allocation uses vector library

master
Xavier Arteaga 5 years ago committed by Andre Puschmann
parent 25312e81b4
commit 9a2b0b7cc7

@ -100,7 +100,7 @@ int rvidx[SRSLTE_MAX_CODEWORDS] = {0, 0};
cf_t *sf_buffer[SRSLTE_MAX_PORTS] = {NULL}, *output_buffer[SRSLTE_MAX_PORTS] = {NULL};
int sf_n_re, sf_n_samples;
uint32_t sf_n_re, sf_n_samples;
pthread_t net_thread;
void* net_thread_fnc(void* arg);
@ -247,18 +247,18 @@ void base_init()
/* Allocate memory */
for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
data[i] = srslte_vec_malloc(sizeof(uint8_t) * SOFTBUFFER_SIZE);
data[i] = srslte_vec_u8_malloc(SOFTBUFFER_SIZE);
if (!data[i]) {
perror("malloc");
exit(-1);
}
bzero(data[i], sizeof(uint8_t) * SOFTBUFFER_SIZE);
}
data_mbms = srslte_vec_malloc(sizeof(uint8_t) * SOFTBUFFER_SIZE);
data_mbms = srslte_vec_u8_malloc(SOFTBUFFER_SIZE);
/* init memory */
for (i = 0; i < SRSLTE_MAX_PORTS; i++) {
sf_buffer[i] = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
sf_buffer[i] = srslte_vec_cf_malloc(sf_n_re);
if (!sf_buffer[i]) {
perror("malloc");
exit(-1);
@ -266,12 +266,12 @@ void base_init()
}
for (i = 0; i < SRSLTE_MAX_PORTS; i++) {
output_buffer[i] = srslte_vec_malloc(sizeof(cf_t) * sf_n_samples);
output_buffer[i] = srslte_vec_cf_malloc(sf_n_samples);
if (!output_buffer[i]) {
perror("malloc");
exit(-1);
}
bzero(output_buffer[i], sizeof(cf_t) * sf_n_samples);
srslte_vec_cf_zero(output_buffer[i], sf_n_samples);
}
/* open file or USRP */
@ -832,7 +832,7 @@ int main(int argc, char** argv)
while ((nf < nof_frames || nof_frames == -1) && !go_exit) {
for (sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME && (nf < nof_frames || nof_frames == -1) && !go_exit; sf_idx++) {
/* Set Antenna port resource elements to zero */
bzero(sf_symbols[0], sizeof(cf_t) * sf_n_re);
srslte_vec_cf_zero(sf_symbols[0], sf_n_re);
if (sf_idx == 0 || sf_idx == 5) {
srslte_pss_put_slot(pss_signal, sf_symbols[0], cell.nof_prb, SRSLTE_CP_NORM);

@ -403,7 +403,7 @@ int main(int argc, char** argv)
#endif /* ENABLE_GUI */
for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
data[i] = srslte_vec_malloc(sizeof(uint8_t) * 2000 * 8);
data[i] = srslte_vec_u8_malloc(2000 * 8);
if (!data[i]) {
ERROR("Allocating data");
go_exit = true;
@ -674,7 +674,7 @@ int main(int argc, char** argv)
bool decode_pdsch = false;
for (int i = 0; i < SRSLTE_MAX_LAYERS; i++) {
bzero(sinr[i], sizeof(float) * SRSLTE_MAX_CODEBOOKS);
srslte_vec_f_zero(sinr[i], SRSLTE_MAX_CODEBOOKS);
}
/* Main loop */
@ -1062,7 +1062,7 @@ void* plot_thread_run(void* arg)
}
}
int sz = srslte_symbol_sz(ue_dl.cell.nof_prb);
bzero(tmp_plot2, sizeof(float) * sz);
srslte_vec_f_zero(tmp_plot2, sz);
int g = (sz - 12 * ue_dl.cell.nof_prb) / 2;
for (i = 0; i < 12 * ue_dl.cell.nof_prb; i++) {
tmp_plot2[g + i] = srslte_convert_amplitude_to_dB(cabsf(ue_dl.chest_res.ce[0][0][i]));

@ -204,7 +204,7 @@ int main(int argc, char** argv)
}
uint32_t sf_n_re = SRSLTE_CP_NSYMB(SRSLTE_CP_NORM) * SRSLTE_NRE * 2 * sl_cell.nof_prb;
cf_t* equalized_sf_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
cf_t* equalized_sf_buffer = srslte_vec_cf_malloc(sf_n_re);
// RX
srslte_ofdm_t fft;

@ -135,17 +135,17 @@ int main(int argc, char** argv)
exit(-1);
}
input = malloc(frame_length * sizeof(cf_t));
input = srslte_vec_cf_malloc(frame_length);
if (!input) {
perror("malloc");
exit(-1);
}
cfo = malloc(nof_frames * sizeof(float));
cfo = srslte_vec_f_malloc(nof_frames);
if (!cfo) {
perror("malloc");
exit(-1);
}
exec_time = malloc(nof_frames * sizeof(int));
exec_time = srslte_vec_i32_malloc(nof_frames);
if (!exec_time) {
perror("malloc");
exit(-1);

@ -113,7 +113,7 @@ int main(int argc, char** argv)
sample_count = 0;
for (int i = 0; i < nof_rx_antennas; i++) {
buffer[i] = malloc(sizeof(cf_t) * buflen);
buffer[i] = srslte_vec_cf_malloc(buflen);
if (!buffer[i]) {
perror("malloc");
exit(-1);

@ -138,7 +138,7 @@ int main(int argc, char** argv)
cell.base.nof_ports = 1;
cf_t* buff_ptrs[SRSLTE_MAX_PORTS] = {NULL, NULL, NULL, NULL};
buff_ptrs[0] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB_NBIOT * 10);
buff_ptrs[0] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB_NBIOT * 10);
srslte_nbiot_ue_sync_t ue_sync;
if (srslte_ue_sync_nbiot_init(&ue_sync, cell, srslte_rf_recv_wrapper, (void*)&rf)) {

@ -111,24 +111,25 @@ int main(int argc, char** argv)
uint32_t flen = srslte_sampling_freq_hz(nof_prb) / 1000;
cf_t* rx_buffer = malloc(sizeof(cf_t) * flen * nof_frames);
cf_t* rx_buffer = srslte_vec_cf_malloc(flen * nof_frames);
if (!rx_buffer) {
perror("malloc");
exit(-1);
}
cf_t* tx_buffer = malloc(sizeof(cf_t) * (flen + time_adv_samples));
cf_t* tx_buffer = srslte_vec_cf_malloc((flen + time_adv_samples));
if (!tx_buffer) {
perror("malloc");
exit(-1);
}
bzero(tx_buffer, sizeof(cf_t) * (flen + time_adv_samples));
srslte_vec_cf_zero(tx_buffer, flen + time_adv_samples);
cf_t* zeros = calloc(sizeof(cf_t), flen);
cf_t* zeros = srslte_vec_cf_malloc(flen);
if (!zeros) {
perror("calloc");
exit(-1);
}
srslte_vec_cf_zero(zeros, flen);
float time_adv_sec = (float)time_adv_samples / srslte_sampling_freq_hz(nof_prb);

@ -108,7 +108,7 @@ int main(int argc, char** argv)
// Initializes memory for input buffer
bzero(buffer, sizeof(void*) * max_rx_antennas);
for (int i = 0; i < nof_rx_antennas; i++) {
buffer[i] = malloc(buflen * sizeof(cf_t));
buffer[i] = srslte_vec_cf_malloc(buflen);
if (!buffer[i]) {
perror("malloc");
exit(-1);

@ -92,31 +92,31 @@ int srslte_chest_dl_init(srslte_chest_dl_t* q, uint32_t max_prb, uint32_t nof_rx
pilot_vec_size = SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb);
}
q->tmp_noise = srslte_vec_malloc(sizeof(cf_t) * pilot_vec_size);
q->tmp_noise = srslte_vec_cf_malloc(pilot_vec_size);
if (!q->tmp_noise) {
perror("malloc");
goto clean_exit;
}
q->tmp_cfo_estimate = srslte_vec_malloc(sizeof(cf_t) * pilot_vec_size);
q->tmp_cfo_estimate = srslte_vec_cf_malloc(pilot_vec_size);
if (!q->tmp_cfo_estimate) {
perror("malloc");
goto clean_exit;
}
q->pilot_estimates = srslte_vec_malloc(sizeof(cf_t) * pilot_vec_size);
q->pilot_estimates = srslte_vec_cf_malloc(pilot_vec_size);
if (!q->pilot_estimates) {
perror("malloc");
goto clean_exit;
}
q->pilot_estimates_average = srslte_vec_malloc(sizeof(cf_t) * pilot_vec_size);
q->pilot_estimates_average = srslte_vec_cf_malloc(pilot_vec_size);
if (!q->pilot_estimates_average) {
perror("malloc");
goto clean_exit;
}
q->pilot_recv_signal = srslte_vec_malloc(sizeof(cf_t) * pilot_vec_size);
q->pilot_recv_signal = srslte_vec_cf_malloc(pilot_vec_size);
if (!q->pilot_recv_signal) {
perror("malloc");
goto clean_exit;
@ -197,12 +197,12 @@ int srslte_chest_dl_res_init(srslte_chest_dl_res_t* q, uint32_t max_prb)
q->nof_re = SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM);
for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) {
for (uint32_t j = 0; j < SRSLTE_MAX_PORTS; j++) {
q->ce[i][j] = srslte_vec_malloc(q->nof_re * sizeof(cf_t));
q->ce[i][j] = srslte_vec_cf_malloc(q->nof_re);
if (!q->ce[i][j]) {
perror("malloc");
return -1;
}
bzero(q->ce[i][j], SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM) * sizeof(cf_t));
srslte_vec_cf_zero(q->ce[i][j], SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM));
}
}
return 0;

@ -46,19 +46,18 @@ int srslte_chest_dl_nbiot_init(srslte_chest_dl_nbiot_t* q, uint32_t max_prb)
goto clean_exit;
}
q->tmp_noise = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb));
q->tmp_noise = srslte_vec_cf_malloc(SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb));
if (!q->tmp_noise) {
perror("malloc");
goto clean_exit;
}
q->pilot_estimates =
srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb) + SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN);
q->pilot_estimates = srslte_vec_cf_malloc(SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb) + SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN);
if (!q->pilot_estimates) {
perror("malloc");
goto clean_exit;
}
q->pilot_estimates_average =
srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb) + SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN);
srslte_vec_cf_malloc(SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb) + SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN);
if (!q->pilot_estimates_average) {
perror("malloc");
goto clean_exit;
@ -67,7 +66,7 @@ int srslte_chest_dl_nbiot_init(srslte_chest_dl_nbiot_t* q, uint32_t max_prb)
q->pilot_estimates_average[i] = 1;
}
q->pilot_recv_signal = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb));
q->pilot_recv_signal = srslte_vec_cf_malloc(SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb));
if (!q->pilot_recv_signal) {
perror("malloc");
goto clean_exit;

@ -35,38 +35,38 @@ int srslte_chest_sl_init_dmrs(srslte_chest_sl_t* q)
srslte_interp_linear_vector_init(&q->lin_vec_sl, SRSLTE_MAX_PRB * SRSLTE_NRE);
for (int i = 0; i < SRSLTE_SL_MAX_DMRS_SYMB; i++) {
q->r[i] = srslte_vec_malloc(sizeof(float) * SRSLTE_MAX_PRB * SRSLTE_NRE);
q->r[i] = srslte_vec_f_malloc(SRSLTE_MAX_PRB * SRSLTE_NRE);
if (!q->r[i]) {
ERROR("Error allocating memory");
return SRSLTE_ERROR;
}
q->r_uv[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_MAX_PRB * SRSLTE_NRE);
q->r_uv[i] = srslte_vec_cf_malloc(SRSLTE_MAX_PRB * SRSLTE_NRE);
if (!q->r_uv[i]) {
ERROR("Error allocating memory");
return SRSLTE_ERROR;
}
q->r_sequence[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_MAX_PRB * SRSLTE_NRE);
q->r_sequence[i] = srslte_vec_cf_malloc(SRSLTE_MAX_PRB * SRSLTE_NRE);
if (!q->r_sequence[i]) {
ERROR("Error allocating memory");
return SRSLTE_ERROR;
}
q->dmrs_received[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_MAX_PRB * SRSLTE_NRE);
q->dmrs_received[i] = srslte_vec_cf_malloc(SRSLTE_MAX_PRB * SRSLTE_NRE);
if (!q->dmrs_received[i]) {
ERROR("Error allocating memory");
return SRSLTE_ERROR;
}
}
q->f_gh_pattern = srslte_vec_malloc(sizeof(uint32_t) * SRSLTE_SL_MAX_DMRS_PERIOD_LENGTH); // MAX PERIOD LENGTH 320
q->f_gh_pattern = srslte_vec_u32_malloc(SRSLTE_SL_MAX_DMRS_PERIOD_LENGTH); // MAX PERIOD LENGTH 320
if (!q->f_gh_pattern) {
ERROR("Error allocating memory");
return SRSLTE_ERROR;
}
q->ce = srslte_vec_malloc(sizeof(cf_t) * 2 * SRSLTE_CP_NSYMB(SRSLTE_CP_NORM) * SRSLTE_NRE * SRSLTE_MAX_PRB);
q->ce = srslte_vec_cf_malloc(2 * SRSLTE_CP_NSYMB(SRSLTE_CP_NORM) * SRSLTE_NRE * SRSLTE_MAX_PRB);
if (!q->ce) {
ERROR("Error allocating memory");
return SRSLTE_ERROR;
@ -464,7 +464,7 @@ void srslte_chest_sl_psbch_ls_estimate_equalize(srslte_chest_sl_t* q,
// Get Pilot Estimates
// Use the known DMRS signal to compute least-squares estimates
bzero(q->ce, sizeof(cf_t) * sf_n_re);
srslte_vec_cf_zero(q->ce, sf_n_re);
if (tm <= SRSLTE_SIDELINK_TM2) {
if (cp == SRSLTE_CP_NORM) {
@ -628,7 +628,7 @@ void srslte_chest_sl_pscch_ls_estimate_equalize(srslte_chest_sl_t* q,
// Get Pilot Estimates
// Use the known DMRS signal to compute least-squares estimates
bzero(q->ce, sizeof(cf_t) * sf_n_re);
srslte_vec_cf_zero(q->ce, sf_n_re);
if ((tm == SRSLTE_SIDELINK_TM1) || (tm == SRSLTE_SIDELINK_TM2)) {
uint32_t dmrs_index = 0;

@ -60,30 +60,30 @@ int srslte_chest_ul_init(srslte_chest_ul_t* q, uint32_t max_prb)
goto clean_exit;
}
q->tmp_noise = srslte_vec_malloc(sizeof(cf_t) * MAX_REFS_SF);
q->tmp_noise = srslte_vec_cf_malloc(MAX_REFS_SF);
if (!q->tmp_noise) {
perror("malloc");
goto clean_exit;
}
q->pilot_estimates = srslte_vec_malloc(sizeof(cf_t) * MAX_REFS_SF);
q->pilot_estimates = srslte_vec_cf_malloc(MAX_REFS_SF);
if (!q->pilot_estimates) {
perror("malloc");
goto clean_exit;
}
for (int i = 0; i < 4; i++) {
q->pilot_estimates_tmp[i] = srslte_vec_malloc(sizeof(cf_t) * MAX_REFS_SF);
q->pilot_estimates_tmp[i] = srslte_vec_cf_malloc(MAX_REFS_SF);
if (!q->pilot_estimates_tmp[i]) {
perror("malloc");
goto clean_exit;
}
}
q->pilot_recv_signal = srslte_vec_malloc(sizeof(cf_t) * (MAX_REFS_SF + 1));
q->pilot_recv_signal = srslte_vec_cf_malloc(MAX_REFS_SF + 1);
if (!q->pilot_recv_signal) {
perror("malloc");
goto clean_exit;
}
q->pilot_known_signal = srslte_vec_malloc(sizeof(cf_t) * (MAX_REFS_SF + 1));
q->pilot_known_signal = srslte_vec_cf_malloc(MAX_REFS_SF + 1);
if (!q->pilot_known_signal) {
perror("malloc");
goto clean_exit;
@ -145,7 +145,7 @@ int srslte_chest_ul_res_init(srslte_chest_ul_res_t* q, uint32_t max_prb)
{
bzero(q, sizeof(srslte_chest_ul_res_t));
q->nof_re = SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM);
q->ce = srslte_vec_malloc(q->nof_re * sizeof(cf_t));
q->ce = srslte_vec_cf_malloc(q->nof_re);
if (!q->ce) {
perror("malloc");
return -1;

@ -44,7 +44,7 @@ int srslte_refsignal_cs_init(srslte_refsignal_t* q, uint32_t max_prb)
bzero(q, sizeof(srslte_refsignal_t));
for (int p = 0; p < 2; p++) {
for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) {
q->pilots[p][i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb));
q->pilots[p][i] = srslte_vec_cf_malloc(SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb));
if (!q->pilots[p][i]) {
perror("malloc");
goto free_and_exit;
@ -424,7 +424,7 @@ int srslte_refsignal_mbsfn_init(srslte_refsignal_t* q, uint32_t max_prb)
for (p = 0; p < 2; p++) {
for (i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) {
q->pilots[p][i] = srslte_vec_malloc(sizeof(cf_t) * max_prb * 18);
q->pilots[p][i] = srslte_vec_cf_malloc(max_prb * 18);
if (!q->pilots[p][i]) {
perror("malloc");
goto free_and_exit;

@ -102,7 +102,7 @@ int srslte_refsignal_dl_nbiot_init(srslte_refsignal_dl_nbiot_t* q)
for (uint32_t p = 0; p < 2; p++) {
for (uint32_t i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) {
q->pilots[p][i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_NBIOT_REFSIGNAL_NUM_SF(SRSLTE_NBIOT_MAX_PRB, p));
q->pilots[p][i] = srslte_vec_cf_malloc(SRSLTE_NBIOT_REFSIGNAL_NUM_SF(SRSLTE_NBIOT_MAX_PRB, p));
if (!q->pilots[p][i]) {
perror("malloc");
goto free_and_exit;

@ -155,7 +155,7 @@ int srslte_refsignal_ul_init(srslte_refsignal_ul_t* q, uint32_t max_prb)
bzero(q, sizeof(srslte_refsignal_ul_t));
// Allocate temporal buffer for computing signal argument
q->tmp_arg = srslte_vec_malloc(SRSLTE_NRE * max_prb * sizeof(cf_t));
q->tmp_arg = srslte_vec_f_malloc(SRSLTE_NRE * max_prb);
if (!q->tmp_arg) {
perror("malloc");
goto free_and_exit;
@ -361,7 +361,7 @@ int srslte_refsignal_dmrs_pusch_pregen_init(srslte_refsignal_ul_dmrs_pregen_t* p
if (pregen->r[cs][sf_idx]) {
for (uint32_t n = 0; n <= max_prb; n++) {
if (srslte_dft_precoding_valid_prb(n)) {
pregen->r[cs][sf_idx][n] = (cf_t*)srslte_vec_malloc(sizeof(cf_t) * n * 2 * SRSLTE_NRE);
pregen->r[cs][sf_idx][n] = srslte_vec_cf_malloc(n * 2 * SRSLTE_NRE);
if (pregen->r[cs][sf_idx][n]) {
} else {
return SRSLTE_ERROR;
@ -943,7 +943,7 @@ int srslte_refsignal_srs_pregen(srslte_refsignal_ul_t* q,
{
uint32_t M_sc = srslte_refsignal_srs_M_sc(q, cfg);
for (uint32_t sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) {
pregen->r[sf_idx] = srslte_vec_malloc(2 * M_sc * sizeof(cf_t));
pregen->r[sf_idx] = srslte_vec_cf_malloc(2 * M_sc);
if (pregen->r[sf_idx]) {
if (srslte_refsignal_srs_gen(q, cfg, dmrs, sf_idx, pregen->r[sf_idx])) {
return SRSLTE_ERROR;

@ -105,29 +105,29 @@ int main(int argc, char** argv)
parse_args(argc, argv);
int num_re = 2 * cell.base.nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cell.base.cp);
uint32_t num_re = 2 * cell.base.nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cell.base.cp);
input = srslte_vec_malloc(num_re * sizeof(cf_t));
input = srslte_vec_cf_malloc(num_re);
if (!input) {
perror("srslte_vec_malloc");
goto do_exit;
}
output = srslte_vec_malloc(num_re * sizeof(cf_t));
output = srslte_vec_cf_malloc(num_re);
if (!output) {
perror("srslte_vec_malloc");
goto do_exit;
}
sf_buffer = malloc(2 * SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.base.nof_prb)) * sizeof(cf_t));
sf_buffer = srslte_vec_cf_malloc(2U * SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.base.nof_prb)));
if (!sf_buffer) {
perror("malloc");
return -1;
}
h = srslte_vec_malloc(num_re * sizeof(cf_t));
h = srslte_vec_cf_malloc(num_re);
if (!h) {
perror("srslte_vec_malloc");
goto do_exit;
}
ce = srslte_vec_malloc(num_re * sizeof(cf_t));
ce = srslte_vec_cf_malloc(num_re);
if (!ce) {
perror("srslte_vec_malloc");
goto do_exit;
@ -152,13 +152,13 @@ int main(int argc, char** argv)
for (int sf_idx = 0; sf_idx < 1; sf_idx++) {
for (int n_port = 0; n_port < cell.base.nof_ports; n_port++) {
bzero(input, sizeof(cf_t) * num_re);
srslte_vec_cf_zero(input, num_re);
for (int i = 0; i < num_re; i++) {
input[i] = 0.5 - rand() / RAND_MAX + I * (0.5 - rand() / RAND_MAX);
}
bzero(ce, sizeof(cf_t) * num_re);
bzero(h, sizeof(cf_t) * num_re);
srslte_vec_cf_zero(ce, num_re);
srslte_vec_cf_zero(h, num_re);
srslte_ofdm_t ifft, fft;
if (have_ofdm) {

@ -81,7 +81,7 @@ int main(int argc, char** argv)
{
srslte_chest_dl_t est;
cf_t * input = NULL, *ce = NULL, *h = NULL, *output = NULL;
int i, j, num_re;
int i, j;
int ret = -1;
int max_cid;
FILE* fmatlab = NULL;
@ -97,24 +97,24 @@ int main(int argc, char** argv)
}
}
num_re = 2 * cell.nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cell.cp);
uint32_t num_re = 2 * cell.nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cell.cp);
input = srslte_vec_malloc(num_re * sizeof(cf_t));
input = srslte_vec_cf_malloc(num_re);
if (!input) {
perror("srslte_vec_malloc");
goto do_exit;
}
output = srslte_vec_malloc(num_re * sizeof(cf_t));
output = srslte_vec_cf_malloc(num_re);
if (!output) {
perror("srslte_vec_malloc");
goto do_exit;
}
h = srslte_vec_malloc(num_re * sizeof(cf_t));
h = srslte_vec_cf_malloc(num_re);
if (!h) {
perror("srslte_vec_malloc");
goto do_exit;
}
ce = srslte_vec_malloc(num_re * sizeof(cf_t));
ce = srslte_vec_cf_malloc(num_re);
if (!ce) {
perror("srslte_vec_malloc");
goto do_exit;
@ -145,13 +145,13 @@ int main(int argc, char** argv)
for (uint32_t n_port = 0; n_port < cell.nof_ports; n_port++) {
bzero(input, sizeof(cf_t) * num_re);
srslte_vec_cf_zero(input, num_re);
for (i = 0; i < num_re; i++) {
input[i] = 0.5 - rand() / RAND_MAX + I * (0.5 - rand() / RAND_MAX);
}
bzero(ce, sizeof(cf_t) * num_re);
bzero(h, sizeof(cf_t) * num_re);
srslte_vec_cf_zero(ce, num_re);
srslte_vec_cf_zero(h, num_re);
srslte_refsignal_cs_put_sf(&est.csr_refs, &sf_cfg, n_port, input);

@ -95,16 +95,16 @@ int main(int argc, char** argv)
parse_args(argc, argv);
int sf_n_re = SRSLTE_CP_NSYMB(cp) * SRSLTE_NRE * nof_prb * 2;
cf_t* sf_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
bzero(sf_buffer, sizeof(cf_t) * sf_n_re);
cf_t* sf_buffer = srslte_vec_cf_malloc(sf_n_re);
srslte_vec_cf_zero(sf_buffer, sf_n_re);
// Variables init Rx
cf_t* sf_buffer_rx = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
bzero(sf_buffer_rx, sizeof(cf_t) * sf_n_re);
cf_t* sf_buffer_rx = srslte_vec_cf_malloc(sf_n_re);
srslte_vec_cf_zero(sf_buffer_rx, sf_n_re);
cf_t* dmrs_received[SRSLTE_SL_MAX_DMRS_SYMB] = {NULL};
for (int i = 0; i < SRSLTE_SL_MAX_DMRS_SYMB; i++) {
dmrs_received[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_NRE * nof_prb);
dmrs_received[i] = srslte_vec_cf_malloc(SRSLTE_NRE * nof_prb);
}
// Variables init Tx

@ -84,7 +84,7 @@ int main(int argc, char** argv)
{
srslte_chest_ul_t est;
cf_t * input = NULL, *ce = NULL, *h = NULL;
int i, j, n_port = 0, sf_idx = 0, cid = 0, num_re;
int i, j, n_port = 0, sf_idx = 0, cid = 0;
int ret = -1;
int max_cid;
FILE* fmatlab = NULL;
@ -99,24 +99,24 @@ int main(int argc, char** argv)
}
}
num_re = 2 * cell.nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cell.cp);
uint32_t num_re = 2U * cell.nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cell.cp);
input = srslte_vec_malloc(num_re * sizeof(cf_t));
input = srslte_vec_cf_malloc(num_re);
if (!input) {
perror("srslte_vec_malloc");
goto do_exit;
}
h = srslte_vec_malloc(num_re * sizeof(cf_t));
h = srslte_vec_cf_malloc(num_re);
if (!h) {
perror("srslte_vec_malloc");
goto do_exit;
}
ce = srslte_vec_malloc(num_re * sizeof(cf_t));
ce = srslte_vec_cf_malloc(num_re);
if (!ce) {
perror("srslte_vec_malloc");
goto do_exit;
}
bzero(ce, num_re * sizeof(cf_t));
srslte_vec_cf_zero(ce, num_re);
if (cell.id == 1000) {
cid = 0;
@ -180,7 +180,7 @@ int main(int argc, char** argv)
}
/* Generate random input */
bzero(input, sizeof(cf_t) * num_re);
srslte_vec_cf_zero(input, num_re);
for (i = 0; i < num_re; i++) {
input[i] = 0.5 - rand() / RAND_MAX + I * (0.5 - (float)rand() / RAND_MAX);
}

@ -94,7 +94,7 @@ int main(int argc, char** argv)
goto do_exit;
}
signal = malloc(2 * SRSLTE_NRE * cell.nof_prb * sizeof(cf_t));
signal = srslte_vec_cf_malloc(2 * SRSLTE_NRE * cell.nof_prb);
if (!signal) {
perror("malloc");
goto do_exit;

@ -43,8 +43,8 @@ channel::channel(const channel::args_t& channel_args, uint32_t _nof_channels)
args = channel_args;
// Allocate internal buffers
buffer_in = (cf_t*)srslte_vec_malloc(sizeof(cf_t) * buffer_size);
buffer_out = (cf_t*)srslte_vec_malloc(sizeof(cf_t) * buffer_size);
buffer_in = srslte_vec_cf_malloc(buffer_size);
buffer_out = srslte_vec_cf_malloc(buffer_size);
if (!buffer_out || !buffer_in) {
ret = SRSLTE_ERROR;
}

@ -69,7 +69,7 @@ int srslte_channel_delay_init(srslte_channel_delay_t* q,
int ret = srslte_ringbuffer_init(&q->rb, sizeof(cf_t) * buff_size);
// Create zero buffer
q->zero_buffer = srslte_vec_malloc(sizeof(cf_t) * buff_size);
q->zero_buffer = srslte_vec_cf_malloc(buff_size);
if (!q->zero_buffer) {
ret = SRSLTE_ERROR;
}
@ -114,7 +114,7 @@ void srslte_channel_delay_execute(srslte_channel_delay_t* q,
if (available_nsamples < q->delay_nsamples) {
uint32_t nzeros = q->delay_nsamples - available_nsamples;
bzero(q->zero_buffer, sizeof(cf_t) * nzeros);
srslte_vec_cf_zero(q->zero_buffer, nzeros);
srslte_ringbuffer_write(&q->rb, q->zero_buffer, sizeof(cf_t) * nzeros);
} else if (available_nsamples > q->delay_nsamples) {
srslte_ringbuffer_read(&q->rb, q->zero_buffer, sizeof(cf_t) * (available_nsamples - q->delay_nsamples));

@ -189,7 +189,7 @@ static inline void filter_segment(srslte_channel_fading_t* q, const cf_t* input,
{
// Fill Input vector
memcpy(q->temp, input, sizeof(cf_t) * nsamples);
bzero(&q->temp[nsamples], sizeof(cf_t) * (q->N - nsamples));
srslte_vec_cf_zero(&q->temp[nsamples], q->N - nsamples);
// Do FFT
srslte_dft_run_c_zerocopy(&q->fft, q->temp, q->y_freq);
@ -245,7 +245,7 @@ int srslte_channel_fading_init(srslte_channel_fading_t* q, double srate, const c
}
// Allocate tap frequency response
q->h_tap[i] = srslte_vec_malloc(sizeof(cf_t) * q->N);
q->h_tap[i] = srslte_vec_cf_malloc(q->N);
// Generate tap frequency response
generate_tap(

@ -87,8 +87,8 @@ int main(int argc, char** argv)
// Initialise buffers
uint32_t size = srate_hz / 1000;
input_buffer = srslte_vec_malloc(sizeof(cf_t) * size);
output_buffer = srslte_vec_malloc(sizeof(cf_t) * size);
input_buffer = srslte_vec_cf_malloc(size);
output_buffer = srslte_vec_cf_malloc(size);
if (!input_buffer || !output_buffer) {
fprintf(stderr, "Error: Allocating memory\n");
ret = SRSLTE_ERROR;

@ -131,19 +131,19 @@ int main(int argc, char** argv)
srslte_dft_plan_c(&fft, srate / 1000, SRSLTE_DFT_FORWARD);
fft_buffer = srslte_vec_malloc(sizeof(cf_t) * srate / 1000);
fft_buffer = srslte_vec_cf_malloc(srate / 1000);
if (!fft_buffer) {
fprintf(stderr, "Error: malloc\n");
goto clean_exit;
}
fft_mag = srslte_vec_malloc(sizeof(float) * srate / 1000);
fft_mag = srslte_vec_f_malloc(srate / 1000);
if (!fft_mag) {
fprintf(stderr, "Error: malloc\n");
goto clean_exit;
}
imp = srslte_vec_malloc(sizeof(float) * srate / 1000);
imp = srslte_vec_f_malloc(srate / 1000);
if (!imp) {
fprintf(stderr, "Error: malloc\n");
goto clean_exit;
@ -158,14 +158,14 @@ int main(int argc, char** argv)
}
// Allocate buffers
input_buffer = srslte_vec_malloc(sizeof(cf_t) * srate / 1000);
input_buffer = srslte_vec_cf_malloc(srate / 1000);
if (!input_buffer) {
fprintf(stderr, "Error: allocating input buffer\n");
goto clean_exit;
}
#if INPUT_TYPE == 0
bzero(input_buffer, sizeof(cf_t) * srate / 1000);
srslte_vec_cf_zero(input_buffer, srate / 1000);
input_buffer[0] = 1;
#else
for (int i = 0; i < srate / 1000; i++) {
@ -174,7 +174,7 @@ int main(int argc, char** argv)
srslte_dft_run_c(&ifft, input_buffer, input_buffer);
#endif
output_buffer = srslte_vec_malloc(sizeof(cf_t) * srate / 1000);
output_buffer = srslte_vec_cf_malloc(srate / 1000);
if (!output_buffer) {
fprintf(stderr, "Error: allocating output buffer\n");
goto clean_exit;

@ -84,8 +84,8 @@ int main(int argc, char** argv)
// Initialise buffers
uint32_t size = srate_hz / 1000; // 1 ms samples
input_buffer = srslte_vec_malloc(sizeof(cf_t) * size);
output_buffer = srslte_vec_malloc(sizeof(cf_t) * size);
input_buffer = srslte_vec_cf_malloc(size);
output_buffer = srslte_vec_cf_malloc(size);
if (!input_buffer || !output_buffer) {
fprintf(stderr, "Error: Allocating memory\n");
ret = SRSLTE_ERROR;

@ -146,23 +146,23 @@ int srslte_sequence_init(srslte_sequence_t* q, uint32_t len)
srslte_sequence_free(q);
}
if (!q->c) {
q->c = srslte_vec_malloc(len * sizeof(uint8_t));
q->c = srslte_vec_u8_malloc(len);
if (!q->c) {
return SRSLTE_ERROR;
}
q->c_bytes = srslte_vec_malloc(len * sizeof(uint8_t) / 8 + 8);
q->c_bytes = srslte_vec_u8_malloc(len / 8 + 8);
if (!q->c_bytes) {
return SRSLTE_ERROR;
}
q->c_float = srslte_vec_malloc(len * sizeof(float));
q->c_float = srslte_vec_f_malloc(len);
if (!q->c_float) {
return SRSLTE_ERROR;
}
q->c_short = srslte_vec_malloc(len * sizeof(short));
q->c_short = srslte_vec_i16_malloc(len);
if (!q->c_short) {
return SRSLTE_ERROR;
}
q->c_char = srslte_vec_malloc(len * sizeof(int8_t));
q->c_char = srslte_vec_i8_malloc(len);
if (!q->c_char) {
return SRSLTE_ERROR;
}

@ -71,37 +71,34 @@ int srslte_ofdm_init_mbsfn_(srslte_ofdm_t* q,
if (srslte_dft_plan_c(&q->fft_plan, symbol_sz, dir)) {
ERROR("Error: Creating DFT plan\n");
return -1;
return SRSLTE_ERROR;
}
#ifdef AVOID_GURU
q->tmp = srslte_vec_malloc((uint32_t)symbol_sz * sizeof(cf_t));
q->tmp = srslte_vec_cf_malloc(symbol_sz);
if (!q->tmp) {
perror("malloc");
return -1;
return SRSLTE_ERROR;
}
bzero(q->tmp, sizeof(cf_t) * symbol_sz);
srslte_vec_cf_zero(q->tmp, symbol_sz);
#else
int cp1 = SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_LEN_NORM(0, symbol_sz) : SRSLTE_CP_LEN_EXT(symbol_sz);
int cp2 = SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_LEN_NORM(1, symbol_sz) : SRSLTE_CP_LEN_EXT(symbol_sz);
q->tmp = srslte_vec_malloc(sizeof(cf_t) * q->sf_sz);
q->tmp = srslte_vec_cf_malloc(q->sf_sz);
if (!q->tmp) {
perror("malloc");
return -1;
return SRSLTE_ERROR;
}
bzero(q->tmp, sizeof(cf_t) * q->sf_sz);
srslte_vec_cf_zero(q->tmp, q->sf_sz);
if (dir == SRSLTE_DFT_BACKWARD) {
bzero(in_buffer, sizeof(cf_t) * SRSLTE_SF_LEN_RE(nof_prb, cp));
srslte_vec_cf_zero(in_buffer, SRSLTE_SF_LEN_RE(nof_prb, cp));
} else {
bzero(in_buffer, sizeof(cf_t) * q->sf_sz);
srslte_vec_cf_zero(in_buffer, q->sf_sz);
}
for (int slot = 0; slot < 2; slot++) {
// bzero(&q->fft_plan_sf[slot], sizeof(srslte_dft_plan_t));
// bzero(q->tmp + SRSLTE_CP_NSYMB(cp)*symbol_sz*slot, sizeof(cf_t) * (cp1 + (SRSLTE_CP_NSYMB(cp) - 1)*cp2 +
// SRSLTE_CP_NSYMB(cp)*symbol_sz));
if (dir == SRSLTE_DFT_FORWARD) {
if (srslte_dft_plan_guru_c(&q->fft_plan_sf[slot],
symbol_sz,
@ -134,7 +131,7 @@ int srslte_ofdm_init_mbsfn_(srslte_ofdm_t* q,
}
#endif
q->shift_buffer = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN(symbol_sz));
q->shift_buffer = srslte_vec_cf_malloc(SRSLTE_SF_LEN(symbol_sz));
if (!q->shift_buffer) {
perror("malloc");
return -1;
@ -197,17 +194,17 @@ int srslte_ofdm_replan_(srslte_ofdm_t* q, srslte_cp_t cp, int symbol_sz, int nof
free(q->tmp);
}
q->tmp = srslte_vec_malloc(sizeof(cf_t) * q->sf_sz);
q->tmp = srslte_vec_cf_malloc(q->sf_sz);
if (!q->tmp) {
perror("malloc");
return -1;
}
bzero(q->tmp, sizeof(cf_t) * q->sf_sz);
srslte_vec_cf_zero(q->tmp, q->sf_sz);
if (dir == SRSLTE_DFT_BACKWARD) {
bzero(in_buffer, sizeof(cf_t) * SRSLTE_SF_LEN_RE(nof_prb, cp));
srslte_vec_cf_zero(in_buffer, SRSLTE_SF_LEN_RE(nof_prb, cp));
} else {
bzero(in_buffer, sizeof(cf_t) * q->sf_sz);
srslte_vec_cf_zero(in_buffer, q->sf_sz);
}
for (int slot = 0; slot < 2; slot++) {
@ -320,8 +317,8 @@ int srslte_ofdm_tx_init(srslte_ofdm_t* q, srslte_cp_t cp, cf_t* in_buffer, cf_t*
/* set now zeros at CP */
for (i = 0; i < q->nof_symbols; i++) {
bzero(q->tmp, q->nof_guards * sizeof(cf_t));
bzero(&q->tmp[q->nof_re + q->nof_guards], q->nof_guards * sizeof(cf_t));
srslte_vec_cf_zero(q->tmp, q->nof_guards);
srslte_vec_cf_zero(&q->tmp[q->nof_re + q->nof_guards], q->nof_guards);
}
}
return ret;
@ -345,8 +342,8 @@ int srslte_ofdm_tx_init_mbsfn(srslte_ofdm_t* q, srslte_cp_t cp, cf_t* in_buffer,
/* set now zeros at CP */
for (i = 0; i < q->nof_symbols; i++) {
bzero(q->tmp, q->nof_guards * sizeof(cf_t));
bzero(&q->tmp[q->nof_re + q->nof_guards], q->nof_guards * sizeof(cf_t));
srslte_vec_cf_zero(q->tmp, q->nof_guards);
srslte_vec_cf_zero(&q->tmp[q->nof_re + q->nof_guards], q->nof_guards);
}
}
return ret;
@ -386,8 +383,8 @@ int srslte_ofdm_tx_set_prb(srslte_ofdm_t* q, srslte_cp_t cp, uint32_t nof_prb)
if (ret == SRSLTE_SUCCESS) {
/* set now zeros at CP */
for (i = 0; i < q->nof_symbols; i++) {
bzero(q->tmp, q->nof_guards * sizeof(cf_t));
bzero(&q->tmp[q->nof_re + q->nof_guards], q->nof_guards * sizeof(cf_t));
srslte_vec_cf_zero(q->tmp, q->nof_guards);
srslte_vec_cf_zero(&q->tmp[q->nof_re + q->nof_guards], q->nof_guards);
}
}
return ret;
@ -583,31 +580,6 @@ void srslte_ofdm_tx_slot(srslte_ofdm_t* q, int slot_in_sf)
output += q->symbol_sz + cp_len;
}
#endif
/*input = q->in_buffer + slot_in_sf * q->nof_re * q->nof_symbols;
cf_t *output2 = srslte_vec_malloc(sizeof(cf_t) * q->slot_sz);
cf_t *o2 = output2;
bzero(q->tmp, sizeof(cf_t)*q->symbol_sz);
//bzero(output2, sizeof(cf_t)*q->slot_sz);
for (int i=0;i<q->nof_symbols;i++) {
int cp_len = SRSLTE_CP_ISNORM(q->cp)?SRSLTE_CP_LEN_NORM(i, q->symbol_sz):SRSLTE_CP_LEN_EXT(q->symbol_sz);
memcpy(&q->tmp[q->nof_guards], input, q->nof_re * sizeof(cf_t));
srslte_dft_run_c(&q->fft_plan, q->tmp, &o2[cp_len]);
input += q->nof_re;
memcpy(o2, &o2[q->symbol_sz], cp_len * sizeof(cf_t));
o2 += q->symbol_sz + cp_len;
}
cf_t *output1 = q->out_buffer + slot_in_sf * q->slot_sz;//srslte_vec_malloc(sizeof(cf_t) * q->slot_sz);
for (int i = 0; i < q->slot_sz; i++) {
float error = cabsf(output1[i] - output2[i])/cabsf(output2[i]);
cf_t k = output1[i]/output2[i];
if (error > 0.1) printf("%d/%05d error=%f output=%+f%+fi gold=%+f%+fi k=%+f%+fi\n", slot_in_sf, i, ERROR(
__real__ output1[i], __imag__ output1[i],
__real__ output2[i], __imag__ output2[i],
__real__ k, __imag__ k);
}
free(output2);/**/
}
void srslte_ofdm_tx_slot_mbsfn(srslte_ofdm_t* q, cf_t* input, cf_t* output)

@ -96,22 +96,22 @@ int main(int argc, char** argv)
printf("Running test for %d PRB, %d RE... ", n_prb, n_re);
fflush(stdout);
input = srslte_vec_malloc(sizeof(cf_t) * n_re * 2);
input = srslte_vec_cf_malloc(n_re * 2U);
if (!input) {
perror("malloc");
exit(-1);
}
outfft = srslte_vec_malloc(sizeof(cf_t) * n_re * 2);
outfft = srslte_vec_cf_malloc(n_re * 2U);
if (!outfft) {
perror("malloc");
exit(-1);
}
outifft = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SLOT_LEN(srslte_symbol_sz(n_prb)) * 2);
outifft = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN(srslte_symbol_sz(n_prb)) * 2U);
if (!outifft) {
perror("malloc");
exit(-1);
}
bzero(outifft, sizeof(cf_t) * SRSLTE_SLOT_LEN(srslte_symbol_sz(n_prb)) * 2);
srslte_vec_cf_zero(outifft, SRSLTE_SLOT_LEN(srslte_symbol_sz(n_prb)) * 2);
if (srslte_ofdm_rx_init(&fft, cp, outifft, outfft, n_prb)) {
ERROR("Error initializing FFT\n");

@ -44,7 +44,7 @@ int srslte_enb_dl_init(srslte_enb_dl_t* q, cf_t* out_buffer[SRSLTE_MAX_PORTS], u
bzero(q, sizeof(srslte_enb_dl_t));
for (int i = 0; i < SRSLTE_MAX_PORTS; i++) {
q->sf_symbols[i] = srslte_vec_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM) * sizeof(cf_t));
q->sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM));
if (!q->sf_symbols[i]) {
perror("malloc");
goto clean_exit;
@ -288,7 +288,7 @@ void srslte_enb_dl_prepare_power_allocation(srslte_enb_dl_t* q)
static void clear_sf(srslte_enb_dl_t* q)
{
for (int i = 0; i < q->cell.nof_ports; i++) {
bzero(q->sf_symbols[i], CURRENT_SFLEN_RE * sizeof(cf_t));
srslte_vec_cf_zero(q->sf_symbols[i], CURRENT_SFLEN_RE);
}
}

@ -35,13 +35,13 @@ int srslte_enb_ul_init(srslte_enb_ul_t* q, cf_t* in_buffer, uint32_t max_prb)
bzero(q, sizeof(srslte_enb_ul_t));
q->sf_symbols = srslte_vec_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM) * sizeof(cf_t));
q->sf_symbols = srslte_vec_cf_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM));
if (!q->sf_symbols) {
perror("malloc");
goto clean_exit;
}
q->chest_res.ce = srslte_vec_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM) * sizeof(cf_t));
q->chest_res.ce = srslte_vec_cf_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM));
if (!q->chest_res.ce) {
perror("malloc");
goto clean_exit;

@ -71,13 +71,13 @@ int srslte_softbuffer_rx_init(srslte_softbuffer_rx_t* q, uint32_t nof_prb)
// TODO: Use HARQ buffer limitation based on UE category
for (uint32_t i = 0; i < q->max_cb; i++) {
q->buffer_f[i] = srslte_vec_malloc(sizeof(int16_t) * SOFTBUFFER_SIZE);
q->buffer_f[i] = srslte_vec_i16_malloc(SOFTBUFFER_SIZE);
if (!q->buffer_f[i]) {
perror("malloc");
goto clean_exit;
}
q->data[i] = srslte_vec_malloc(sizeof(uint8_t) * 6144 / 8);
q->data[i] = srslte_vec_u8_malloc(6144 / 8);
if (!q->data[i]) {
perror("malloc");
goto clean_exit;
@ -159,8 +159,6 @@ int srslte_softbuffer_tx_init(srslte_softbuffer_tx_t* q, uint32_t nof_prb)
int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL) {
ret = SRSLTE_ERROR;
bzero(q, sizeof(srslte_softbuffer_tx_t));
ret = srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, nof_prb);
@ -175,7 +173,7 @@ int srslte_softbuffer_tx_init(srslte_softbuffer_tx_t* q, uint32_t nof_prb)
// TODO: Use HARQ buffer limitation based on UE category
for (uint32_t i = 0; i < q->max_cb; i++) {
q->buffer_b[i] = srslte_vec_malloc(sizeof(float) * SOFTBUFFER_SIZE);
q->buffer_b[i] = srslte_vec_u8_malloc(SOFTBUFFER_SIZE);
if (!q->buffer_b[i]) {
perror("malloc");
return SRSLTE_ERROR;

@ -28,6 +28,7 @@
#include "srslte/phy/fec/tc_interl.h"
#include "srslte/phy/fec/turbocoder.h"
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h"
/************************************************
*
@ -92,8 +93,8 @@ int srslte_tc_interl_LTE_gen_interl(srslte_tc_interl_t* h, uint32_t long_cb, uin
h->reverse[j] = (uint32_t)i;
}
if (interl_win != 1) {
uint16_t* f = malloc(long_cb * sizeof(uint16_t));
uint16_t* r = malloc(long_cb * sizeof(uint16_t));
uint16_t* f = srslte_vec_u16_malloc(long_cb);
uint16_t* r = srslte_vec_u16_malloc(long_cb);
memcpy(f, h->forward, long_cb * sizeof(uint16_t));
memcpy(r, h->reverse, long_cb * sizeof(uint16_t));
for (i = 0; i < long_cb; i++) {

@ -26,6 +26,7 @@
#include "srslte/phy/fec/tc_interl.h"
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h"
#define TURBO_SRSLTE_TCOD_RATE 3
@ -50,12 +51,12 @@ const uint8_t table_v[52] = {3, 2, 2, 3, 2, 5, 2, 3, 2, 6, 3, 5, 2, 2, 2
int srslte_tc_interl_init(srslte_tc_interl_t* h, uint32_t max_long_cb)
{
int ret = -1;
h->forward = malloc(sizeof(uint32_t) * max_long_cb);
h->forward = srslte_vec_u16_malloc(max_long_cb);
if (!h->forward) {
perror("malloc");
goto clean_exit;
}
h->reverse = malloc(sizeof(uint32_t) * max_long_cb);
h->reverse = srslte_vec_u16_malloc(max_long_cb);
if (!h->reverse) {
perror("malloc");
goto clean_exit;

@ -76,7 +76,7 @@ int main(int argc, char** argv)
parse_args(argc, argv);
data = malloc(sizeof(uint8_t) * (num_bits + crc_length * 2));
data = srslte_vec_u8_malloc(num_bits + crc_length * 2);
if (!data) {
perror("malloc");
exit(-1);

@ -30,7 +30,8 @@
#include "srslte/srslte.h"
int nof_tx_bits = -1, nof_rx_bits = -1;
static uint32_t nof_tx_bits = 0;
static uint32_t nof_rx_bits = 0;
void usage(char* prog)
{
@ -43,21 +44,21 @@ void parse_args(int argc, char** argv)
while ((opt = getopt(argc, argv, "tr")) != -1) {
switch (opt) {
case 't':
nof_tx_bits = (int)strtol(argv[optind], NULL, 10);
nof_tx_bits = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'r':
nof_rx_bits = (int)strtol(argv[optind], NULL, 10);
nof_rx_bits = (uint32_t)strtol(argv[optind], NULL, 10);
break;
default:
usage(argv[0]);
exit(-1);
}
}
if (nof_tx_bits == -1) {
if (nof_tx_bits == 0) {
usage(argv[0]);
exit(-1);
}
if (nof_rx_bits == -1) {
if (nof_rx_bits == 0) {
usage(argv[0]);
exit(-1);
}
@ -72,22 +73,22 @@ int main(int argc, char** argv)
parse_args(argc, argv);
bits = malloc(sizeof(uint8_t) * nof_tx_bits);
bits = srslte_vec_u8_malloc(nof_tx_bits);
if (!bits) {
perror("malloc");
exit(-1);
}
rm_bits = malloc(sizeof(uint8_t) * nof_rx_bits);
rm_bits = srslte_vec_u8_malloc(nof_rx_bits);
if (!rm_bits) {
perror("malloc");
exit(-1);
}
rm_symbols = malloc(sizeof(float) * nof_rx_bits);
rm_symbols = srslte_vec_f_malloc(nof_rx_bits);
if (!rm_symbols) {
perror("malloc");
exit(-1);
}
unrm_symbols = malloc(sizeof(float) * nof_tx_bits);
unrm_symbols = srslte_vec_f_malloc(nof_tx_bits);
if (!unrm_symbols) {
perror("malloc");
exit(-1);

@ -30,14 +30,14 @@
#include "srslte/srslte.h"
int nof_e_bits = -1;
int rv_idx = -1;
int cb_idx = -1;
uint32_t nof_e_bits = 0;
uint32_t rv_idx = 0;
uint32_t cb_idx = 0;
uint8_t systematic[6148], parity[2 * 6148];
uint8_t systematic_bytes[6148 / 8 + 1], parity_bytes[2 * 6148 / 8 + 1];
#define BUFFSZ 6176 * 3
#define BUFFSZ (6176 * 3)
uint8_t bits[3 * 6144 + 12];
uint8_t buff_b[BUFFSZ];
@ -56,20 +56,20 @@ void parse_args(int argc, char** argv)
while ((opt = getopt(argc, argv, "cei")) != -1) {
switch (opt) {
case 'c':
cb_idx = (int)strtol(argv[optind], NULL, 10);
cb_idx = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'e':
nof_e_bits = (int)strtol(argv[optind], NULL, 10);
nof_e_bits = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'i':
rv_idx = (int)strtol(argv[optind], NULL, 10);
rv_idx = (uint32_t)strtol(argv[optind], NULL, 10);
break;
default:
usage(argv[0]);
exit(-1);
}
}
if (nof_e_bits == -1) {
if (nof_e_bits == 0) {
usage(argv[0]);
exit(-1);
}
@ -86,27 +86,27 @@ int main(int argc, char** argv)
srslte_rm_turbo_gentables();
rm_bits_s = srslte_vec_malloc(sizeof(short) * nof_e_bits);
rm_bits_s = srslte_vec_i16_malloc(nof_e_bits);
if (!rm_bits_s) {
perror("malloc");
exit(-1);
}
rm_bits_f = srslte_vec_malloc(sizeof(float) * nof_e_bits);
rm_bits_f = srslte_vec_f_malloc(nof_e_bits);
if (!rm_bits_f) {
perror("malloc");
exit(-1);
}
rm_bits = srslte_vec_malloc(sizeof(uint8_t) * nof_e_bits);
rm_bits = srslte_vec_u8_malloc(nof_e_bits);
if (!rm_bits) {
perror("malloc");
exit(-1);
}
rm_bits2 = malloc(sizeof(uint8_t) * nof_e_bits);
rm_bits2 = srslte_vec_u8_malloc(nof_e_bits);
if (!rm_bits2) {
perror("malloc");
exit(-1);
}
rm_bits2_bytes = malloc(sizeof(uint8_t) * nof_e_bits / 8 + 1);
rm_bits2_bytes = srslte_vec_u8_malloc(nof_e_bits / 8 + 1);
if (!rm_bits2_bytes) {
perror("malloc");
exit(-1);
@ -175,7 +175,7 @@ int main(int argc, char** argv)
rm_bits_s[i] = (short)rm_bits_f[i];
}
bzero(buff_f, BUFFSZ * sizeof(float));
srslte_vec_f_zero(buff_f, BUFFSZ);
srslte_rm_turbo_rx(buff_f, BUFFSZ, rm_bits_f, nof_e_bits, bits_f, long_cb_enc, rv_idx, 0);
bzero(bits2_s, long_cb_enc * sizeof(short));

@ -150,39 +150,39 @@ int main(int argc, char** argv)
printf(" EbNo: %.2f\n", ebno_db);
}
data_tx = srslte_vec_malloc(frame_length * sizeof(uint8_t));
data_tx = srslte_vec_u8_malloc(frame_length);
if (!data_tx) {
perror("malloc");
exit(-1);
}
data_rx = srslte_vec_malloc(frame_length * sizeof(uint8_t));
data_rx = srslte_vec_u8_malloc(frame_length);
if (!data_rx) {
perror("malloc");
exit(-1);
}
data_rx_bytes = srslte_vec_malloc(frame_length * sizeof(uint8_t));
data_rx_bytes = srslte_vec_u8_malloc(frame_length);
if (!data_rx_bytes) {
perror("malloc");
exit(-1);
}
symbols = srslte_vec_malloc(coded_length * sizeof(uint8_t));
symbols = srslte_vec_u8_malloc(coded_length);
if (!symbols) {
perror("malloc");
exit(-1);
}
llr = srslte_vec_malloc(coded_length * sizeof(float));
llr = srslte_vec_f_malloc(coded_length);
if (!llr) {
perror("malloc");
exit(-1);
}
llr_s = srslte_vec_malloc(coded_length * sizeof(short));
llr_s = srslte_vec_i16_malloc(coded_length);
if (!llr_s) {
perror("malloc");
exit(-1);
}
llr_c = srslte_vec_malloc(coded_length * sizeof(uint8_t));
llr_c = srslte_vec_u8_malloc(coded_length);
if (!llr_c) {
perror("malloc");
exit(-1);

@ -202,42 +202,42 @@ int srslte_tdec_init_manual(srslte_tdec_t* h, uint32_t max_long_cb, srslte_tdec_
h->max_long_cb = max_long_cb;
h->app1 = srslte_vec_malloc(sizeof(int16_t) * len);
h->app1 = srslte_vec_i16_malloc(len);
if (!h->app1) {
perror("srslte_vec_malloc");
goto clean_and_exit;
}
h->app2 = srslte_vec_malloc(sizeof(int16_t) * len);
h->app2 = srslte_vec_i16_malloc(len);
if (!h->app2) {
perror("srslte_vec_malloc");
goto clean_and_exit;
}
h->ext1 = srslte_vec_malloc(sizeof(int16_t) * len);
h->ext1 = srslte_vec_i16_malloc(len);
if (!h->ext1) {
perror("srslte_vec_malloc");
goto clean_and_exit;
}
h->ext2 = srslte_vec_malloc(sizeof(int16_t) * len);
h->ext2 = srslte_vec_i16_malloc(len);
if (!h->ext2) {
perror("srslte_vec_malloc");
goto clean_and_exit;
}
h->syst0 = srslte_vec_malloc(sizeof(int16_t) * len);
h->syst0 = srslte_vec_i16_malloc(len);
if (!h->syst0) {
perror("srslte_vec_malloc");
goto clean_and_exit;
}
h->parity0 = srslte_vec_malloc(sizeof(int16_t) * len);
h->parity0 = srslte_vec_i16_malloc(len);
if (!h->parity0) {
perror("srslte_vec_malloc");
goto clean_and_exit;
}
h->parity1 = srslte_vec_malloc(sizeof(int16_t) * len);
h->parity1 = srslte_vec_i16_malloc(len);
if (!h->parity1) {
perror("srslte_vec_malloc");
goto clean_and_exit;
}
h->input_conv = srslte_vec_malloc(sizeof(int16_t) * (len * 3 + 32 * 3));
h->input_conv = srslte_vec_i16_malloc(len * 3 + 32 * 3);
if (!h->input_conv) {
perror("srslte_vec_malloc");
goto clean_and_exit;

@ -203,7 +203,7 @@ int tdec_gen_init(void** hh, uint32_t max_long_cb)
tdec_gen_t* h = (tdec_gen_t*)*hh;
h->beta = srslte_vec_malloc(sizeof(int16_t) * (max_long_cb + SRSLTE_TCOD_TOTALTAIL + 1) * NUMSTATES);
h->beta = srslte_vec_i16_malloc((max_long_cb + SRSLTE_TCOD_TOTALTAIL + 1) * NUMSTATES);
if (!h->beta) {
perror("srslte_vec_malloc");
return -1;

@ -389,12 +389,12 @@ int tdec_sse_init(void** hh, uint32_t max_long_cb)
h->max_long_cb = max_long_cb;
h->alpha = srslte_vec_malloc(sizeof(int16_t) * (max_long_cb + TOTALTAIL + 1) * NUMSTATES);
h->alpha = srslte_vec_i16_malloc((max_long_cb + TOTALTAIL + 1) * NUMSTATES);
if (!h->alpha) {
perror("srslte_vec_malloc");
return -1;
}
h->branch = srslte_vec_malloc(sizeof(int16_t) * (max_long_cb + TOTALTAIL + 1) * NUMSTATES);
h->branch = srslte_vec_i16_malloc((max_long_cb + TOTALTAIL + 1) * NUMSTATES);
if (!h->branch) {
perror("srslte_vec_malloc");
return -1;

@ -285,13 +285,13 @@ int init37(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_bitin
q->decode = decode37;
q->free = free37;
q->decode_f = NULL;
q->symbols_uc = srslte_vec_malloc(3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
q->symbols_uc = srslte_vec_u8_malloc(3 * (q->framebits + q->K - 1));
if (!q->symbols_uc) {
perror("malloc");
return -1;
}
if (q->tail_biting) {
q->tmp = srslte_vec_malloc(TB_ITER * 3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
q->tmp = srslte_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1));
bzero(q->tmp, 3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
if (!q->tmp) {
perror("malloc");
@ -336,7 +336,7 @@ int init37_sse(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_b
}
#endif
if (q->tail_biting) {
q->tmp = srslte_vec_malloc(TB_ITER * 3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
q->tmp = srslte_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1));
if (!q->tmp) {
perror("malloc");
free37(q);
@ -368,13 +368,13 @@ int init37_neon(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_
q->decode = decode37_neon;
q->free = free37_neon;
q->decode_f = NULL;
q->symbols_uc = srslte_vec_malloc(3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
q->symbols_uc = srslte_vec_u8_malloc(3 * (q->framebits + q->K - 1));
if (!q->symbols_uc) {
perror("malloc");
return -1;
}
if (q->tail_biting) {
q->tmp = srslte_vec_malloc(TB_ITER * 3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
q->tmp = srslte_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1));
if (!q->tmp) {
perror("malloc");
free37(q);
@ -406,13 +406,13 @@ int init37_avx2(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_
q->decode = decode37_avx2;
q->free = free37_avx2;
q->decode_f = NULL;
q->symbols_uc = srslte_vec_malloc(3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
q->symbols_uc = srslte_vec_u8_malloc(3 * (q->framebits + q->K - 1));
if (!q->symbols_uc) {
perror("malloc");
return -1;
}
if (q->tail_biting) {
q->tmp = srslte_vec_malloc(TB_ITER * 3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
q->tmp = srslte_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1));
if (!q->tmp) {
perror("malloc");
free37(q);
@ -442,15 +442,15 @@ int init37_avx2_16bit(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool
q->decode_s = decode37_avx2_16bit;
q->free = free37_avx2_16bit;
q->decode_f = NULL;
q->symbols_uc = srslte_vec_malloc(3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
q->symbols_us = srslte_vec_malloc(3 * (q->framebits + q->K - 1) * sizeof(uint16_t));
q->symbols_uc = srslte_vec_u8_malloc(3 * (q->framebits + q->K - 1));
q->symbols_us = srslte_vec_u16_malloc(3 * (q->framebits + q->K - 1));
if (!q->symbols_uc || !q->symbols_us) {
perror("malloc");
return -1;
}
if (q->tail_biting) {
q->tmp = srslte_vec_malloc(TB_ITER * 3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
q->tmp_s = srslte_vec_malloc(TB_ITER * 3 * (q->framebits + q->K - 1) * sizeof(uint16_t));
q->tmp = srslte_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1));
q->tmp_s = srslte_vec_u16_malloc(TB_ITER * 3 * (q->framebits + q->K - 1));
if (!q->tmp) {
perror("malloc");
free37(q);

@ -25,6 +25,7 @@
#include "srslte/phy/io/binsource.h"
#include "srslte/phy/utils/bit.h"
#include "srslte/phy/utils/vector.h"
#define DIV(a, b) ((a - 1) / b + 1)
@ -36,7 +37,7 @@ static int gen_seq_buff(srslte_binsource_t* q, int nwords)
q->seq_buff_nwords = 0;
}
if (!q->seq_buff_nwords) {
q->seq_buff = malloc(nwords * sizeof(uint32_t));
q->seq_buff = srslte_vec_u32_malloc(nwords);
if (!q->seq_buff) {
return -1;
}

@ -101,19 +101,19 @@ int main(int argc, char** argv)
}
for (i = 0; i < nof_cw; i++) {
d[i] = srslte_vec_malloc(sizeof(cf_t) * nof_symb_cw[i]);
d[i] = srslte_vec_cf_malloc(nof_symb_cw[i]);
if (!d[i]) {
perror("malloc");
exit(-1);
}
dp[i] = srslte_vec_malloc(sizeof(cf_t) * nof_symb_cw[i]);
dp[i] = srslte_vec_cf_malloc(nof_symb_cw[i]);
if (!dp[i]) {
perror("malloc");
exit(-1);
}
}
for (i = 0; i < nof_layers; i++) {
x[i] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols);
x[i] = srslte_vec_cf_malloc(nof_symbols);
if (!x[i]) {
perror("malloc");
exit(-1);

@ -48,11 +48,11 @@ int main(int argc, char** argv)
/* Allocate channels */
for (int i = 0; i < SRSLTE_MAX_PORTS; i++) {
for (int j = 0; j < SRSLTE_MAX_PORTS; j++) {
h[i][j] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols);
h[i][j] = srslte_vec_cf_malloc(nof_symbols);
if (!h[i][j]) {
goto clean;
}
bzero(h[i][j], sizeof(cf_t) * nof_symbols);
srslte_vec_cf_zero(h[i][j], nof_symbols);
}
}

@ -214,14 +214,14 @@ int main(int argc, char** argv)
/* Allocate x and xr (received symbols) in memory for each layer */
for (i = 0; i < nof_layers; i++) {
/* Source data */
x[i] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols);
x[i] = srslte_vec_cf_malloc(nof_symbols);
if (!x[i]) {
perror("srslte_vec_malloc");
exit(-1);
}
/* Sink data */
xr[i] = srslte_vec_malloc(sizeof(cf_t) * nof_symbols);
xr[i] = srslte_vec_cf_malloc(nof_symbols);
if (!xr[i]) {
perror("srslte_vec_malloc");
exit(-1);
@ -230,7 +230,7 @@ int main(int argc, char** argv)
/* Allocate y in memory for tx each port */
for (i = 0; i < nof_tx_ports; i++) {
y[i] = srslte_vec_malloc(sizeof(cf_t) * nof_re);
y[i] = srslte_vec_cf_malloc(nof_re);
if (!y[i]) {
perror("srslte_vec_malloc");
exit(-1);
@ -240,7 +240,7 @@ int main(int argc, char** argv)
/* Allocate h in memory for each cross channel and layer */
for (i = 0; i < nof_tx_ports; i++) {
for (j = 0; j < nof_rx_ports; j++) {
h[i][j] = srslte_vec_malloc(sizeof(cf_t) * nof_re);
h[i][j] = srslte_vec_cf_malloc(nof_re);
if (!h[i][j]) {
perror("srslte_vec_malloc");
exit(-1);
@ -250,7 +250,7 @@ int main(int argc, char** argv)
/* Allocate r */
for (i = 0; i < nof_rx_ports; i++) {
r[i] = srslte_vec_malloc(sizeof(cf_t) * nof_re);
r[i] = srslte_vec_cf_malloc(nof_re);
if (!r[i]) {
perror("srslte_vec_malloc");
exit(-1);

@ -34,7 +34,7 @@
/** Internal functions */
static int table_create(srslte_modem_table_t* q)
{
q->symbol_table = srslte_vec_malloc(q->nsymbols * sizeof(cf_t));
q->symbol_table = srslte_vec_cf_malloc(q->nsymbols);
return q->symbol_table == NULL;
}

@ -33,8 +33,8 @@
time_t start, finish;
struct timeval x, y;
int num_bits = 1000;
srslte_mod_t modulation = SRSLTE_MOD_BPSK;
static uint32_t num_bits = 1000;
static srslte_mod_t modulation = SRSLTE_MOD_BPSK;
void usage(char* prog)
{
@ -49,7 +49,7 @@ void parse_args(int argc, char** argv)
while ((opt = getopt(argc, argv, "nm")) != -1) {
switch (opt) {
case 'n':
num_bits = (int)strtol(argv[optind], NULL, 10);
num_bits = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'm':
switch (strtol(argv[optind], NULL, 10)) {
@ -108,33 +108,33 @@ int main(int argc, char** argv)
}
/* allocate buffers */
input = srslte_vec_malloc(sizeof(uint8_t) * num_bits);
input = srslte_vec_u8_malloc(num_bits);
if (!input) {
perror("malloc");
exit(-1);
}
input_bytes = srslte_vec_malloc(sizeof(uint8_t) * num_bits / 8);
input_bytes = srslte_vec_u8_malloc(num_bits / 8);
if (!input_bytes) {
perror("malloc");
exit(-1);
}
output = srslte_vec_malloc(sizeof(uint8_t) * num_bits);
output = srslte_vec_u8_malloc(num_bits);
if (!output) {
perror("malloc");
exit(-1);
}
symbols = srslte_vec_malloc(sizeof(cf_t) * num_bits / mod.nbits_x_symbol);
symbols = srslte_vec_cf_malloc(num_bits / mod.nbits_x_symbol);
if (!symbols) {
perror("malloc");
exit(-1);
}
symbols_bytes = srslte_vec_malloc(sizeof(cf_t) * num_bits / mod.nbits_x_symbol);
symbols_bytes = srslte_vec_cf_malloc(num_bits / mod.nbits_x_symbol);
if (!symbols_bytes) {
perror("malloc");
exit(-1);
}
llr = srslte_vec_malloc(sizeof(float) * num_bits);
llr = srslte_vec_f_malloc(num_bits);
if (!llr) {
perror("malloc");
exit(-1);
@ -174,7 +174,7 @@ int main(int argc, char** argv)
}
}
bzero(llr, sizeof(float) * num_bits / mod.nbits_x_symbol);
srslte_vec_f_zero(llr, num_bits / mod.nbits_x_symbol);
printf("Symbols OK\n");
/* demodulate */

@ -30,9 +30,9 @@
#include "srslte/srslte.h"
int nof_frames = 10;
int num_bits = 1000;
srslte_mod_t modulation = 10;
static uint32_t nof_frames = 10;
static uint32_t num_bits = 1000;
static srslte_mod_t modulation = 10;
void usage(char* prog)
{
@ -48,10 +48,10 @@ void parse_args(int argc, char** argv)
while ((opt = getopt(argc, argv, "nmvf")) != -1) {
switch (opt) {
case 'n':
num_bits = (int)strtol(argv[optind], NULL, 10);
num_bits = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'f':
nof_frames = (int)strtol(argv[optind], NULL, 10);
nof_frames = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srslte_verbose++;
@ -105,7 +105,7 @@ float mse_threshold()
case SRSLTE_MOD_256QAM:
return 0.3;
default:
return -1.0;
return -1.0f;
}
}
@ -131,35 +131,35 @@ int main(int argc, char** argv)
num_bits = mod.nbits_x_symbol * (num_bits / mod.nbits_x_symbol);
/* allocate buffers */
input = srslte_vec_malloc(sizeof(uint8_t) * num_bits);
input = srslte_vec_u8_malloc(num_bits);
if (!input) {
perror("malloc");
exit(-1);
}
output = srslte_vec_malloc(sizeof(uint8_t) * num_bits);
output = srslte_vec_u8_malloc(num_bits);
if (!output) {
perror("malloc");
exit(-1);
}
symbols = srslte_vec_malloc(sizeof(cf_t) * num_bits / mod.nbits_x_symbol);
symbols = srslte_vec_cf_malloc(num_bits / mod.nbits_x_symbol);
if (!symbols) {
perror("malloc");
exit(-1);
}
llr = srslte_vec_malloc(sizeof(float) * num_bits);
llr = srslte_vec_f_malloc(num_bits);
if (!llr) {
perror("malloc");
exit(-1);
}
llr_s = srslte_vec_malloc(sizeof(short) * num_bits);
llr_s = srslte_vec_i16_malloc(num_bits);
if (!llr_s) {
perror("malloc");
exit(-1);
}
llr_b = srslte_vec_malloc(sizeof(int8_t) * num_bits);
llr_b = srslte_vec_i8_malloc(num_bits);
if (!llr_b) {
perror("malloc");
exit(-1);

@ -79,40 +79,40 @@ int srslte_npbch_init(srslte_npbch_t* q)
q->encoder.tail_biting = true;
memcpy(q->encoder.poly, poly, 3 * sizeof(int));
q->d = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols);
q->d = srslte_vec_cf_malloc(q->nof_symbols);
if (!q->d) {
fprintf(stderr, "Error allocating memory.\n");
goto clean;
}
for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) {
q->ce[i] = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols);
q->ce[i] = srslte_vec_cf_malloc(q->nof_symbols);
if (!q->ce[i]) {
fprintf(stderr, "Error allocating memory.\n");
goto clean;
}
q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols);
q->x[i] = srslte_vec_cf_malloc(q->nof_symbols);
if (!q->x[i]) {
fprintf(stderr, "Error allocating memory.\n");
goto clean;
}
q->symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES);
q->symbols[i] = srslte_vec_cf_malloc(q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES);
if (!q->symbols[i]) {
fprintf(stderr, "Error allocating memory.\n");
goto clean;
}
}
q->llr = srslte_vec_malloc(sizeof(float) * q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES * 2);
q->llr = srslte_vec_f_malloc(q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES * 2);
if (!q->llr) {
fprintf(stderr, "Error allocating memory.\n");
goto clean;
}
q->temp = srslte_vec_malloc(sizeof(float) * q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES * 2);
q->temp = srslte_vec_f_malloc(q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES * 2);
if (!q->temp) {
fprintf(stderr, "Error allocating memory.\n");
goto clean;
}
q->rm_b = srslte_vec_malloc(sizeof(float) * q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES * 2);
q->rm_b = srslte_vec_u8_malloc(q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES * 2);
if (!q->rm_b) {
fprintf(stderr, "Error allocating memory.\n");
goto clean;

@ -66,37 +66,37 @@ int srslte_npdcch_init(srslte_npdcch_t* q)
goto clean;
}
q->e = srslte_vec_malloc(sizeof(uint8_t) * q->max_bits);
q->e = srslte_vec_u8_malloc(q->max_bits);
if (!q->e) {
goto clean;
}
for (int i = 0; i < 2; i++) {
q->llr[i] = srslte_vec_malloc(sizeof(float) * q->max_bits);
q->llr[i] = srslte_vec_f_malloc(q->max_bits);
if (!q->llr[i]) {
goto clean;
}
bzero(q->llr[i], sizeof(float) * q->max_bits);
srslte_vec_f_zero(q->llr[i], q->max_bits);
}
q->d = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2);
q->d = srslte_vec_cf_malloc(q->max_bits / 2);
if (!q->d) {
goto clean;
}
for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) {
q->ce[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2);
q->ce[i] = srslte_vec_cf_malloc(q->max_bits / 2);
if (!q->ce[i]) {
goto clean;
}
for (uint32_t k = 0; k < q->max_bits / 2; k++) {
q->ce[i][k] = 1;
}
q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2);
q->x[i] = srslte_vec_cf_malloc(q->max_bits / 2);
if (!q->x[i]) {
goto clean;
}
q->symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2);
q->symbols[i] = srslte_vec_cf_malloc(q->max_bits / 2);
if (!q->symbols[i]) {
goto clean;
}
@ -200,7 +200,7 @@ int srslte_npdcch_dci_decode(srslte_npdcch_t* q, float* e, uint8_t* data, uint32
if (q != NULL) {
if (data != NULL && E <= q->max_bits && nof_bits <= SRSLTE_DCI_MAX_BITS) {
bzero(q->rm_f, sizeof(float) * 3 * (SRSLTE_DCI_MAX_BITS + 16));
srslte_vec_f_zero(q->rm_f, 3 * (SRSLTE_DCI_MAX_BITS + 16));
uint32_t coded_len = 3 * (nof_bits + 16);
@ -337,7 +337,7 @@ int srslte_npdcch_extract_llr(srslte_npdcch_t* q,
if (i != SRSLTE_NPDCCH_FORMAT0_UPPER_HALF) {
// don't overwrite lower half LLRs
bzero(llr, sizeof(float) * q->max_bits);
srslte_vec_f_zero(llr, q->max_bits);
}
// number of layers equals number of ports

@ -163,34 +163,34 @@ int srslte_pbch_init(srslte_pbch_t* q)
q->nof_symbols = PBCH_RE_CP_NORM;
q->d = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols);
q->d = srslte_vec_cf_malloc(q->nof_symbols);
if (!q->d) {
goto clean;
}
int i;
for (i = 0; i < SRSLTE_MAX_PORTS; i++) {
q->ce[i] = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols);
q->ce[i] = srslte_vec_cf_malloc(q->nof_symbols);
if (!q->ce[i]) {
goto clean;
}
q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols);
q->x[i] = srslte_vec_cf_malloc(q->nof_symbols);
if (!q->x[i]) {
goto clean;
}
q->symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->nof_symbols);
q->symbols[i] = srslte_vec_cf_malloc(q->nof_symbols);
if (!q->symbols[i]) {
goto clean;
}
}
q->llr = srslte_vec_malloc(sizeof(float) * q->nof_symbols * 4 * 2);
q->llr = srslte_vec_f_malloc(q->nof_symbols * 4 * 2);
if (!q->llr) {
goto clean;
}
q->temp = srslte_vec_malloc(sizeof(float) * q->nof_symbols * 4 * 2);
q->temp = srslte_vec_f_malloc(q->nof_symbols * 4 * 2);
if (!q->temp) {
goto clean;
}
q->rm_b = srslte_vec_malloc(sizeof(float) * q->nof_symbols * 4 * 2);
q->rm_b = srslte_vec_u8_malloc(q->nof_symbols * 4 * 2);
if (!q->rm_b) {
goto clean;
}

@ -75,35 +75,35 @@ static int pdcch_init(srslte_pdcch_t* q, uint32_t max_prb, uint32_t nof_rx_anten
goto clean;
}
q->e = srslte_vec_malloc(sizeof(uint8_t) * q->max_bits);
q->e = srslte_vec_u8_malloc(q->max_bits);
if (!q->e) {
goto clean;
}
q->llr = srslte_vec_malloc(sizeof(float) * q->max_bits);
q->llr = srslte_vec_f_malloc(q->max_bits);
if (!q->llr) {
goto clean;
}
bzero(q->llr, sizeof(float) * q->max_bits);
srslte_vec_f_zero(q->llr, q->max_bits);
q->d = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2);
q->d = srslte_vec_cf_malloc(q->max_bits / 2);
if (!q->d) {
goto clean;
}
for (int i = 0; i < SRSLTE_MAX_PORTS; i++) {
q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2);
q->x[i] = srslte_vec_cf_malloc(q->max_bits / 2);
if (!q->x[i]) {
goto clean;
}
q->symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2);
q->symbols[i] = srslte_vec_cf_malloc(q->max_bits / 2);
if (!q->symbols[i]) {
goto clean;
}
if (q->is_ue) {
for (int j = 0; j < q->nof_rx_antennas; j++) {
q->ce[i][j] = srslte_vec_malloc(sizeof(cf_t) * q->max_bits / 2);
q->ce[i][j] = srslte_vec_cf_malloc(q->max_bits / 2);
if (!q->ce[i][j]) {
goto clean;
}
@ -343,7 +343,7 @@ int srslte_pdcch_dci_decode(srslte_pdcch_t* q, float* e, uint8_t* data, uint32_t
if (q != NULL) {
if (data != NULL && E <= q->max_bits && nof_bits <= SRSLTE_DCI_MAX_BITS) {
bzero(q->rm_f, sizeof(float) * 3 * (SRSLTE_DCI_MAX_BITS + 16));
srslte_vec_f_zero(q->rm_f, 3 * (SRSLTE_DCI_MAX_BITS + 16));
uint32_t coded_len = 3 * (nof_bits + 16);
@ -445,7 +445,7 @@ int srslte_pdcch_extract_llr(srslte_pdcch_t* q,
uint32_t e_bits = 72 * NOF_CCE(sf->cfi);
nof_symbols = e_bits / 2;
ret = SRSLTE_ERROR;
bzero(q->llr, sizeof(float) * q->max_bits);
srslte_vec_f_zero(q->llr, q->max_bits);
DEBUG("Extracting LLRs: E: %d, SF: %d, CFI: %d\n", e_bits, sf->tti % 10, sf->cfi);

@ -149,30 +149,30 @@ int srslte_pmch_init(srslte_pmch_t* q, uint32_t max_prb, uint32_t nof_rx_antenna
srslte_sch_init(&q->dl_sch);
// Allocate int16_t for reception (LLRs)
q->e = srslte_vec_malloc(sizeof(int16_t) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM));
q->e = srslte_vec_i16_malloc(q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM));
if (!q->e) {
goto clean;
}
q->d = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->d = srslte_vec_cf_malloc(q->max_re);
if (!q->d) {
goto clean;
}
for (int i = 0; i < SRSLTE_MAX_PORTS; i++) {
q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->x[i] = srslte_vec_cf_malloc(q->max_re);
if (!q->x[i]) {
goto clean;
}
for (int j = 0; j < q->nof_rx_antennas; j++) {
q->ce[i][j] = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->ce[i][j] = srslte_vec_cf_malloc(q->max_re);
if (!q->ce[i][j]) {
goto clean;
}
}
}
for (int j = 0; j < q->nof_rx_antennas; j++) {
q->symbols[j] = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->symbols[j] = srslte_vec_cf_malloc(q->max_re);
if (!q->symbols[j]) {
goto clean;
}

@ -346,9 +346,9 @@ int srslte_prach_init(srslte_prach_t* p, uint32_t max_N_ifft_ul)
p->max_N_ifft_ul = max_N_ifft_ul;
// Set up containers
p->prach_bins = srslte_vec_malloc(sizeof(cf_t) * MAX_N_zc);
p->corr_spec = srslte_vec_malloc(sizeof(cf_t) * MAX_N_zc);
p->corr = srslte_vec_malloc(sizeof(float) * MAX_N_zc);
p->prach_bins = srslte_vec_cf_malloc(MAX_N_zc);
p->corr_spec = srslte_vec_cf_malloc(MAX_N_zc);
p->corr = srslte_vec_f_malloc(MAX_N_zc);
// Set up ZC FFTS
if (srslte_dft_plan(&p->zc_fft, MAX_N_zc, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) {
@ -365,8 +365,8 @@ int srslte_prach_init(srslte_prach_t* p, uint32_t max_N_ifft_ul)
uint32_t fft_size_alloc = max_N_ifft_ul * DELTA_F / DELTA_F_RA;
p->ifft_in = (cf_t*)srslte_vec_malloc(fft_size_alloc * sizeof(cf_t));
p->ifft_out = (cf_t*)srslte_vec_malloc(fft_size_alloc * sizeof(cf_t));
p->ifft_in = srslte_vec_cf_malloc(fft_size_alloc);
p->ifft_out = srslte_vec_cf_malloc(fft_size_alloc);
if (srslte_dft_plan(&p->ifft, fft_size_alloc, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) {
ERROR("Error creating DFT plan\n");
return -1;
@ -379,7 +379,7 @@ int srslte_prach_init(srslte_prach_t* p, uint32_t max_N_ifft_ul)
return -1;
}
p->signal_fft = srslte_vec_malloc(sizeof(cf_t) * fft_size_alloc);
p->signal_fft = srslte_vec_cf_malloc(fft_size_alloc);
if (!p->signal_fft) {
ERROR("Error allocating memory\n");
return -1;

@ -58,19 +58,19 @@ int srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srs
q->sl_bch_tb_crc_len = q->sl_bch_tb_len + SRSLTE_SL_BCH_CRC_LEN;
q->sl_bch_encoded_len = 3 * q->sl_bch_tb_crc_len;
q->c = srslte_vec_malloc(sizeof(uint8_t) * q->sl_bch_tb_crc_len);
q->c = srslte_vec_u8_malloc(q->sl_bch_tb_crc_len);
if (!q->c) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->d = srslte_vec_malloc(sizeof(uint8_t) * q->sl_bch_encoded_len);
q->d = srslte_vec_u8_malloc(q->sl_bch_encoded_len);
if (!q->d) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->d_16 = srslte_vec_malloc(sizeof(int16_t) * q->sl_bch_encoded_len);
q->d_16 = srslte_vec_i16_malloc(q->sl_bch_encoded_len);
if (!q->d_16) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
@ -82,7 +82,7 @@ int srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srs
return SRSLTE_ERROR;
}
q->crc_temp = srslte_vec_malloc(sizeof(uint8_t) * SRSLTE_SL_BCH_CRC_LEN);
q->crc_temp = srslte_vec_u8_malloc(SRSLTE_SL_BCH_CRC_LEN);
if (!q->crc_temp) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
@ -104,19 +104,19 @@ int srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srs
q->Qm = srslte_mod_bits_x_symbol(SRSLTE_MOD_QPSK);
q->E = q->nof_data_re * q->Qm;
q->e = srslte_vec_malloc(sizeof(uint8_t) * q->E);
q->e = srslte_vec_u8_malloc(q->E);
if (!q->e) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->e_16 = srslte_vec_malloc(sizeof(int16_t) * q->E);
q->e_16 = srslte_vec_i16_malloc(q->E);
if (!q->e_16) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->e_bytes = srslte_vec_malloc(sizeof(uint8_t) * q->E / 8);
q->e_bytes = srslte_vec_u8_malloc(q->E / 8);
if (!q->e_bytes) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
@ -129,20 +129,20 @@ int srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srs
return SRSLTE_ERROR;
}
q->codeword = srslte_vec_malloc(sizeof(uint8_t) * q->E);
q->codeword = srslte_vec_u8_malloc(q->E);
if (!q->codeword) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->codeword_bytes = srslte_vec_malloc(sizeof(uint8_t) * q->E / 8);
q->codeword_bytes = srslte_vec_u8_malloc(q->E / 8);
if (!q->codeword_bytes) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
// Interleaving
q->interleaver_lut = srslte_vec_malloc(sizeof(uint32_t) * q->E);
q->interleaver_lut = srslte_vec_u32_malloc(q->E);
if (!q->interleaver_lut) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
@ -154,33 +154,33 @@ int srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srs
return SRSLTE_ERROR;
}
q->mod_symbols = srslte_vec_malloc(sizeof(cf_t) * q->nof_data_re);
q->mod_symbols = srslte_vec_cf_malloc(q->nof_data_re);
if (!q->mod_symbols) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
// Soft-demod
q->llr = srslte_vec_malloc(sizeof(int16_t) * q->E);
q->llr = srslte_vec_i16_malloc(q->E);
if (!q->llr) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
// Transform precoding
q->precoding_scaling = 1.0;
q->precoding_scaling = 1.0f;
if (srslte_dft_precoding_init_tx(&q->dft_precoder, SRSLTE_PSBCH_NOF_PRB) != SRSLTE_SUCCESS) {
ERROR("Error srslte_dft_precoding_init\n");
return SRSLTE_ERROR;
}
q->scfdma_symbols = srslte_vec_malloc(sizeof(cf_t) * q->nof_data_re);
q->scfdma_symbols = srslte_vec_cf_malloc(q->nof_data_re);
if (!q->scfdma_symbols) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
///< Make sure last bits are zero as they are not considered during unpack
bzero(q->scfdma_symbols, sizeof(cf_t) * q->nof_data_re);
srslte_vec_cf_zero(q->scfdma_symbols, q->nof_data_re);
if (srslte_dft_precoding_init_rx(&q->idft_precoder, SRSLTE_PSBCH_NOF_PRB) != SRSLTE_SUCCESS) {
ERROR("Error srslte_idft_precoding_init\n");

@ -49,12 +49,12 @@ int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb)
if (srslte_crc_init(&q->crc, crc_poly, SRSLTE_SCI_CRC_LEN)) {
return SRSLTE_ERROR;
}
q->c = srslte_vec_malloc(sizeof(uint8_t) * SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN);
q->c = srslte_vec_u8_malloc(SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN);
if (!q->c) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->sci_crc = srslte_vec_malloc(sizeof(uint8_t) * SRSLTE_SCI_CRC_LEN);
q->sci_crc = srslte_vec_u8_malloc(SRSLTE_SCI_CRC_LEN);
if (!q->sci_crc) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
@ -66,14 +66,14 @@ int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb)
q->encoder.tail_biting = true;
int poly[3] = {0x6D, 0x4F, 0x57};
memcpy(q->encoder.poly, poly, 3 * sizeof(int));
q->d = srslte_vec_malloc(sizeof(uint8_t) * SRSLTE_PSCCH_MAX_CODED_BITS);
q->d = srslte_vec_u8_malloc(SRSLTE_PSCCH_MAX_CODED_BITS);
if (!q->d) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
memset(q->d, 0, sizeof(uint8_t) * SRSLTE_PSCCH_MAX_CODED_BITS);
q->d_16 = srslte_vec_malloc(sizeof(int16_t) * SRSLTE_PSCCH_MAX_CODED_BITS);
q->d_16 = srslte_vec_i16_malloc(SRSLTE_PSCCH_MAX_CODED_BITS);
if (!q->d_16) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
@ -84,34 +84,34 @@ int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb)
///< Max E value for memory allocation
uint32_t E_max = SRSLTE_NRE * SRSLTE_PSCCH_MAX_NUM_DATA_SYMBOLS * SRSLTE_PSCCH_MAX_NOF_PRB * SRSLTE_PSCCH_QM;
q->e = srslte_vec_malloc(sizeof(uint8_t) * E_max);
q->e = srslte_vec_u8_malloc(E_max);
if (!q->e) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->e_16 = srslte_vec_malloc(sizeof(int16_t) * E_max);
q->e_16 = srslte_vec_i16_malloc(E_max);
if (!q->e_16) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->e_bytes = srslte_vec_malloc(sizeof(uint8_t) * E_max / 8);
q->e_bytes = srslte_vec_u8_malloc(E_max / 8);
if (!q->e_bytes) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->interleaver_lut = srslte_vec_malloc(sizeof(uint32_t) * E_max);
q->interleaver_lut = srslte_vec_u32_malloc(E_max);
if (!q->interleaver_lut) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->codeword = srslte_vec_malloc(sizeof(uint8_t) * E_max);
q->codeword = srslte_vec_u8_malloc(E_max);
if (!q->codeword) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->codeword_bytes = srslte_vec_malloc(sizeof(uint8_t) * E_max / 8);
q->codeword_bytes = srslte_vec_u8_malloc(E_max / 8);
if (!q->codeword_bytes) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
@ -126,13 +126,13 @@ int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb)
return SRSLTE_ERROR;
}
q->mod_symbols = srslte_vec_malloc(sizeof(cf_t) * E_max / SRSLTE_PSCCH_QM);
q->mod_symbols = srslte_vec_cf_malloc(E_max / SRSLTE_PSCCH_QM);
if (!q->mod_symbols) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->llr = srslte_vec_malloc(sizeof(float) * E_max);
q->llr = srslte_vec_i16_malloc(E_max);
if (!q->llr) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
@ -142,7 +142,7 @@ int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb)
if (srslte_dft_precoding_init(&q->dft_precoder, SRSLTE_PSCCH_MAX_NOF_PRB, true)) {
return SRSLTE_ERROR;
}
q->scfdma_symbols = srslte_vec_malloc(sizeof(cf_t) * E_max / SRSLTE_PSCCH_QM);
q->scfdma_symbols = srslte_vec_cf_malloc(E_max / SRSLTE_PSCCH_QM);
if (!q->scfdma_symbols) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;

@ -68,11 +68,11 @@ int srslte_pucch_init_(srslte_pucch_t* q, bool is_ue)
srslte_uci_cqi_pucch_init(&q->cqi);
q->z = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_PUCCH_MAX_SYMBOLS);
q->z_tmp = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_PUCCH_MAX_SYMBOLS);
q->z = srslte_vec_cf_malloc(SRSLTE_PUCCH_MAX_SYMBOLS);
q->z_tmp = srslte_vec_cf_malloc(SRSLTE_PUCCH_MAX_SYMBOLS);
if (!q->is_ue) {
q->ce = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_PUCCH_MAX_SYMBOLS);
q->ce = srslte_vec_cf_malloc(SRSLTE_PUCCH_MAX_SYMBOLS);
}
ret = SRSLTE_SUCCESS;
@ -560,7 +560,7 @@ static int encode_signal_format3(srslte_pucch_t* q,
uint32_t n_cs_cell = q->n_cs_cell[(2 * (sf->tti % 10) + ((n < N_sf_0) ? 0 : 1)) % SRSLTE_NSLOTS_X_FRAME][l];
cf_t y_n[SRSLTE_NRE];
bzero(y_n, sizeof(cf_t) * SRSLTE_NRE);
srslte_vec_cf_zero(y_n, SRSLTE_NRE);
cf_t h;
if (n < N_sf_0) {
@ -608,8 +608,7 @@ static int decode_signal_format3(srslte_pucch_t* q,
uint32_t l = get_pucch_symbol(n, cfg->format, q->cell.cp);
uint32_t n_cs_cell = q->n_cs_cell[(2 * (sf->tti % 10) + ((n < N_sf_0) ? 0 : 1)) % SRSLTE_NSLOTS_X_FRAME][l];
cf_t y_n[SRSLTE_NRE];
bzero(y_n, sizeof(cf_t) * SRSLTE_NRE);
cf_t y_n[SRSLTE_NRE] = {};
// Do FFT
for (int k = 0; k < SRSLTE_NRE; k++) {

@ -144,24 +144,24 @@ static int pusch_init(srslte_pusch_t* q, uint32_t max_prb, bool is_ue)
}
// Allocate int16 for reception (LLRs). Buffer casted to uint8_t for transmission
q->q = srslte_vec_malloc(sizeof(int16_t) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM));
q->q = srslte_vec_i16_malloc(q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM));
if (!q->q) {
goto clean;
}
// Allocate int16 for reception (LLRs). Buffer casted to uint8_t for transmission
q->g = srslte_vec_malloc(sizeof(int16_t) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM));
q->g = srslte_vec_i16_malloc(q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM));
if (!q->g) {
goto clean;
}
q->d = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->d = srslte_vec_cf_malloc(q->max_re);
if (!q->d) {
goto clean;
}
// Allocate eNb specific buffers
if (!q->is_ue) {
q->ce = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->ce = srslte_vec_cf_malloc(q->max_re);
if (!q->ce) {
goto clean;
}
@ -172,7 +172,7 @@ static int pusch_init(srslte_pusch_t* q, uint32_t max_prb, bool is_ue)
goto clean;
}
}
q->z = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
q->z = srslte_vec_cf_malloc(q->max_re);
if (!q->z) {
goto clean;
}

@ -171,7 +171,7 @@ int srslte_sch_init(srslte_sch_t* q)
goto clean;
}
bzero(q->temp_g_bits, SRSLTE_MAX_PRB * 12 * 12 * 12);
q->ul_interleaver = srslte_vec_malloc(sizeof(uint32_t) * SCH_MAX_G_BITS);
q->ul_interleaver = srslte_vec_u32_malloc(SCH_MAX_G_BITS);
if (!q->ul_interleaver) {
goto clean;
}

@ -120,20 +120,20 @@ int base_init()
exit(-1);
}
input_buffer = malloc(SFLEN * sizeof(cf_t));
input_buffer = srslte_vec_cf_malloc(SFLEN);
if (!input_buffer) {
perror("malloc");
exit(-1);
}
fft_buffer = malloc(SRSLTE_SF_LEN(srslte_symbol_sz(cell.base.nof_prb)) * sizeof(cf_t));
fft_buffer = srslte_vec_cf_malloc(SRSLTE_SF_LEN(srslte_symbol_sz(cell.base.nof_prb)));
if (!fft_buffer) {
perror("malloc");
return -1;
}
for (int i = 0; i < cell.base.nof_ports; i++) {
ce[i] = malloc(SRSLTE_SF_LEN_RE(cell.base.nof_prb, cell.base.cp) * sizeof(cf_t));
ce[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_RE(cell.base.nof_prb, cell.base.cp));
if (!ce[i]) {
perror("malloc");
return -1;

@ -129,7 +129,7 @@ int main(int argc, char** argv)
/* init memory */
for (int i = 0; i < cell.nof_ports; i++) {
ce[i] = malloc(sizeof(cf_t) * nof_re);
ce[i] = srslte_vec_cf_malloc(nof_re);
if (!ce[i]) {
perror("malloc");
exit(-1);
@ -137,7 +137,7 @@ int main(int argc, char** argv)
for (int j = 0; j < nof_re; j++) {
ce[i][j] = 1;
}
sf_symbols[i] = malloc(sizeof(cf_t) * nof_re);
sf_symbols[i] = srslte_vec_cf_malloc(nof_re);
if (!sf_symbols[i]) {
perror("malloc");
exit(-1);

@ -103,7 +103,7 @@ int main(int argc, char** argv)
// init memory
for (int i = 0; i < SRSLTE_MAX_PORTS; i++) {
ce[i] = malloc(sizeof(cf_t) * nof_re);
ce[i] = srslte_vec_cf_malloc(nof_re);
if (!ce[i]) {
perror("malloc");
exit(-1);
@ -111,7 +111,7 @@ int main(int argc, char** argv)
for (int j = 0; j < nof_re; j++) {
ce[i][j] = 1;
}
slot_symbols[i] = malloc(sizeof(cf_t) * nof_re);
slot_symbols[i] = srslte_vec_cf_malloc(nof_re);
if (!slot_symbols[i]) {
perror("malloc");
exit(-1);

@ -107,13 +107,13 @@ int base_init()
exit(-1);
}
input_buffer = malloc(FLEN * sizeof(cf_t));
input_buffer = srslte_vec_cf_malloc(FLEN);
if (!input_buffer) {
perror("malloc");
exit(-1);
}
fft_buffer[0] = malloc(SRSLTE_NOF_RE(cell) * sizeof(cf_t));
fft_buffer[0] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell));
if (!fft_buffer[0]) {
perror("malloc");
return -1;

@ -94,7 +94,7 @@ int main(int argc, char** argv)
chest_dl_res.ce[i][j][k] = 1;
}
}
sf_symbols[i] = malloc(sizeof(cf_t) * nof_re);
sf_symbols[i] = srslte_vec_cf_malloc(nof_re);
if (!sf_symbols[i]) {
perror("malloc");
exit(-1);

@ -123,13 +123,13 @@ int base_init()
flen = SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb));
input_buffer = srslte_vec_malloc(flen * sizeof(cf_t));
input_buffer = srslte_vec_cf_malloc(flen);
if (!input_buffer) {
perror("malloc");
exit(-1);
}
fft_buffer[0] = srslte_vec_malloc(SRSLTE_NOF_RE(cell) * sizeof(cf_t));
fft_buffer[0] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell));
if (!fft_buffer[0]) {
perror("malloc");
return -1;

@ -93,7 +93,7 @@ int main(int argc, char** argv)
srslte_chest_dl_res_set_identity(&chest_res);
for (i = 0; i < SRSLTE_MAX_PORTS; i++) {
slot_symbols[i] = malloc(sizeof(cf_t) * nof_re);
slot_symbols[i] = srslte_vec_cf_malloc(nof_re);
if (!slot_symbols[i]) {
perror("malloc");
exit(-1);

@ -128,13 +128,13 @@ int base_init()
flen = 2 * (SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb)));
input_buffer = malloc(flen * sizeof(cf_t));
input_buffer = srslte_vec_cf_malloc(flen);
if (!input_buffer) {
perror("malloc");
exit(-1);
}
fft_buffer[0] = malloc(SRSLTE_NOF_RE(cell) * sizeof(cf_t));
fft_buffer[0] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell));
if (!fft_buffer[0]) {
perror("malloc");
return -1;

@ -191,12 +191,12 @@ int main(int argc, char** argv)
srslte_chest_dl_res_set_identity(&chest_dl_res);
for (i = 0; i < SRSLTE_MAX_PORTS; i++) {
slot_symbols[i] = malloc(sizeof(cf_t) * nof_re);
slot_symbols[i] = srslte_vec_cf_malloc(nof_re);
if (!slot_symbols[i]) {
perror("malloc");
exit(-1);
}
bzero(slot_symbols[i], sizeof(cf_t) * nof_re);
srslte_vec_cf_zero(slot_symbols[i], nof_re);
}
if (srslte_regs_init(&regs, cell)) {

@ -131,7 +131,7 @@ int base_init()
flen = SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb));
input_buffer[0] = malloc(flen * sizeof(cf_t));
input_buffer[0] = srslte_vec_cf_malloc(flen);
if (!input_buffer[0]) {
perror("malloc");
exit(-1);

@ -289,7 +289,7 @@ int main(int argc, char** argv)
/* init memory */
for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) {
rx_slot_symbols[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_NOF_RE(cell));
rx_slot_symbols[i] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell));
if (!rx_slot_symbols[i]) {
perror("srslte_vec_malloc");
goto quit;
@ -306,14 +306,14 @@ int main(int argc, char** argv)
for (uint32_t i = 0; i < SRSLTE_MAX_TB; i++) {
if (pdsch_cfg.grant.tb[i].enabled) {
data_tx[i] = srslte_vec_malloc(sizeof(uint8_t) * pdsch_cfg.grant.tb[i].tbs);
data_tx[i] = srslte_vec_u8_malloc(pdsch_cfg.grant.tb[i].tbs);
if (!data_tx[i]) {
perror("srslte_vec_malloc");
goto quit;
}
bzero(data_tx[i], sizeof(uint8_t) * pdsch_cfg.grant.tb[i].tbs);
data_rx[i] = srslte_vec_malloc(sizeof(uint8_t) * pdsch_cfg.grant.tb[i].tbs);
data_rx[i] = srslte_vec_u8_malloc(pdsch_cfg.grant.tb[i].tbs);
if (!data_rx[i]) {
perror("srslte_vec_malloc");
goto quit;

@ -145,13 +145,13 @@ int base_init()
flen = SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb));
input_buffer = malloc(flen * sizeof(cf_t));
input_buffer = srslte_vec_cf_malloc(flen);
if (!input_buffer) {
perror("malloc");
exit(-1);
}
fft_buffer[0] = malloc(SRSLTE_NOF_RE(cell) * sizeof(cf_t));
fft_buffer[0] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell));
if (!fft_buffer[0]) {
perror("malloc");
return -1;

@ -121,7 +121,7 @@ int main(int argc, char** argv)
srslte_chest_dl_res_set_ones(&chest_res);
for (i = 0; i < SRSLTE_MAX_PORTS; i++) {
slot_symbols[i] = malloc(sizeof(cf_t) * nof_re);
slot_symbols[i] = srslte_vec_cf_malloc(nof_re);
if (!slot_symbols[i]) {
perror("malloc");
exit(-1);

@ -121,7 +121,7 @@ int base_init()
flen = 2 * (SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb)));
input_buffer[0] = malloc(flen * sizeof(cf_t));
input_buffer[0] = srslte_vec_cf_malloc(flen);
if (!input_buffer[0]) {
perror("malloc");
exit(-1);

@ -159,7 +159,7 @@ int main(int argc, char** argv)
srslte_chest_dl_res_set_identity(&chest_dl_res);
for (i = 0; i < SRSLTE_MAX_PORTS; i++) {
rx_slot_symbols[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_NOF_RE(cell));
rx_slot_symbols[i] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell));
if (!rx_slot_symbols[i]) {
perror("srslte_vec_malloc");
goto quit;
@ -202,8 +202,8 @@ int main(int argc, char** argv)
#ifdef DO_OFDM
for (i = 0; i < cell.nof_ports; i++) {
tx_sf_symbols[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
bzero(tx_sf_symbols[i], sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
tx_sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB(cell.nof_prb));
srslte_vec_cf_zero(tx_sf_symbols[i], SRSLTE_SF_LEN_PRB(cell.nof_prb));
if (srslte_ofdm_tx_init_mbsfn(&ifft_mbsfn[i], SRSLTE_CP_EXT, tx_slot_symbols[i], tx_sf_symbols[i], cell.nof_prb)) {
ERROR("Error creating iFFT object\n");
exit(-1);
@ -214,8 +214,8 @@ int main(int argc, char** argv)
}
for (i = 0; i < nof_rx_antennas; i++) {
rx_sf_symbols[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
bzero(rx_sf_symbols[i], sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb));
rx_sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB(cell.nof_prb));
srslte_vec_cf_zero(rx_sf_symbols[i], SRSLTE_SF_LEN_PRB(cell.nof_prb));
if (srslte_ofdm_rx_init_mbsfn(&fft_mbsfn[i], SRSLTE_CP_EXT, rx_sf_symbols[i], rx_slot_symbols[i], cell.nof_prb)) {
ERROR("Error creating iFFT object\n");
exit(-1);
@ -252,14 +252,14 @@ int main(int argc, char** argv)
for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
if (pmch_cfg.pdsch_cfg.grant.tb[i].enabled) {
data_tx[i] = srslte_vec_malloc(sizeof(uint8_t) * pmch_cfg.pdsch_cfg.grant.tb[i].tbs);
data_tx[i] = srslte_vec_u8_malloc((uint32_t)pmch_cfg.pdsch_cfg.grant.tb[i].tbs);
if (!data_tx[i]) {
perror("srslte_vec_malloc");
goto quit;
}
bzero(data_tx[i], sizeof(uint8_t) * pmch_cfg.pdsch_cfg.grant.tb[i].tbs);
data_rx[i] = srslte_vec_malloc(sizeof(uint8_t) * pmch_cfg.pdsch_cfg.grant.tb[i].tbs);
data_rx[i] = srslte_vec_u8_malloc((uint32_t)pmch_cfg.pdsch_cfg.grant.tb[i].tbs);
if (!data_rx[i]) {
perror("srslte_vec_malloc");
goto quit;

@ -149,14 +149,14 @@ int main(int argc, char** argv)
uint32_t flen = srate / 1000;
printf("Generating PRACH\n");
bzero(preamble, flen * sizeof(cf_t));
srslte_vec_cf_zero(preamble, flen);
srslte_prach_gen(&prach, seq_idx, frequency_offset, preamble);
uint32_t prach_len = prach.N_seq + prach.N_cp;
srslte_vec_save_file("generated", preamble, prach_len * sizeof(cf_t));
cf_t* buffer = malloc(sizeof(cf_t) * flen * nof_frames);
cf_t* buffer = srslte_vec_cf_malloc(flen * nof_frames);
// Send through UHD
srslte_rf_t rf;

@ -125,11 +125,11 @@ int main(int argc, char** argv)
printf("sf_n_samples: %i\n", sf_n_samples);
uint32_t sf_n_re = SRSLTE_CP_NSYMB(cp) * SRSLTE_NRE * 2 * nof_prb;
cf_t* sf_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
cf_t* equalized_sf_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
cf_t* sf_buffer = srslte_vec_cf_malloc(sf_n_re);
cf_t* equalized_sf_buffer = srslte_vec_cf_malloc(sf_n_re);
cf_t* input_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_samples);
cf_t* output_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_samples);
cf_t* input_buffer = srslte_vec_cf_malloc(sf_n_samples);
cf_t* output_buffer = srslte_vec_cf_malloc(sf_n_samples);
// TX
srslte_ofdm_t ifft;

@ -96,7 +96,7 @@ int main(int argc, char** argv)
parse_args(argc, argv);
uint32_t sf_n_re = SRSLTE_SF_LEN_RE(nof_prb, cp);
cf_t* sf_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
cf_t* sf_buffer = srslte_vec_cf_malloc(sf_n_re);
// MIB-SL
srslte_mib_sl_t mib_sl;

@ -130,19 +130,19 @@ int base_init()
sf_n_re = SRSLTE_CP_NSYMB(cell.cp) * SRSLTE_NRE * 2 * cell.nof_prb;
sf_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
sf_buffer = srslte_vec_cf_malloc(sf_n_re);
if (!sf_buffer) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
equalized_sf_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
equalized_sf_buffer = srslte_vec_cf_malloc(sf_n_re);
if (!equalized_sf_buffer) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
input_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_samples);
input_buffer = srslte_vec_cf_malloc(sf_n_samples);
if (!input_buffer) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;

@ -96,7 +96,7 @@ int main(int argc, char** argv)
char sci_msg[SRSLTE_SCI_MSG_MAX_LEN] = "";
uint32_t sf_n_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp);
cf_t* sf_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
cf_t* sf_buffer = srslte_vec_cf_malloc(sf_n_re);
// SCI
srslte_sci_t sci;

@ -172,7 +172,7 @@ int main(int argc, char** argv)
goto quit;
}
sf_symbols = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_NOF_RE(cell));
sf_symbols = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell));
if (!sf_symbols) {
goto quit;
}

@ -249,19 +249,19 @@ int main(int argc, char** argv)
srslte_pusch_set_rnti(&pusch_rx, rnti);
uint32_t nof_re = SRSLTE_NRE * cell.nof_prb * 2 * SRSLTE_CP_NSYMB(cell.cp);
sf_symbols = srslte_vec_malloc(sizeof(cf_t) * nof_re);
sf_symbols = srslte_vec_cf_malloc(nof_re);
if (!sf_symbols) {
perror("malloc");
exit(-1);
}
data = srslte_vec_malloc(sizeof(uint8_t) * 150000);
data = srslte_vec_u8_malloc(150000);
if (!data) {
perror("malloc");
exit(-1);
}
data_rx = srslte_vec_malloc(sizeof(uint8_t) * 150000);
data_rx = srslte_vec_u8_malloc(150000);
if (!data_rx) {
perror("malloc");
exit(-1);

@ -279,8 +279,8 @@ void cqi_pusch_pregen(srslte_uci_cqi_pusch_t* q)
for (int i = 0; i < 11; i++) {
uint32_t nwords = (1 << (i + 1));
q->cqi_table[i] = srslte_vec_malloc(sizeof(uint8_t) * nwords * 32);
q->cqi_table_s[i] = srslte_vec_malloc(sizeof(int16_t) * nwords * 32);
q->cqi_table[i] = srslte_vec_u8_malloc(nwords * 32);
q->cqi_table_s[i] = srslte_vec_i16_malloc(nwords * 32);
for (uint32_t w = 0; w < nwords; w++) {
uint8_t* ptr = word;
srslte_bit_unpack(w, &ptr, i + 1);

@ -103,7 +103,7 @@ int srslte_interp_linear_vector_init(srslte_interp_linsrslte_vec_t* q, uint32_t
if (q) {
bzero(q, sizeof(srslte_interp_linsrslte_vec_t));
ret = SRSLTE_SUCCESS;
q->diff_vec = srslte_vec_malloc(vector_len * sizeof(cf_t));
q->diff_vec = srslte_vec_cf_malloc(vector_len);
if (!q->diff_vec) {
perror("malloc");
return SRSLTE_ERROR;
@ -193,18 +193,18 @@ int srslte_interp_linear_init(srslte_interp_lin_t* q, uint32_t vector_len, uint3
if (q) {
bzero(q, sizeof(srslte_interp_lin_t));
ret = SRSLTE_SUCCESS;
q->diff_vec = srslte_vec_malloc(vector_len * sizeof(cf_t));
q->diff_vec = srslte_vec_cf_malloc(vector_len);
if (!q->diff_vec) {
perror("malloc");
return SRSLTE_ERROR;
}
q->diff_vec2 = srslte_vec_malloc(M * vector_len * sizeof(cf_t));
q->diff_vec2 = srslte_vec_cf_malloc(M * vector_len);
if (!q->diff_vec2) {
perror("malloc");
free(q->diff_vec);
return SRSLTE_ERROR;
}
q->ramp = srslte_vec_malloc(M * sizeof(float));
q->ramp = srslte_vec_f_malloc(M);
if (!q->ramp) {
perror("malloc");
free(q->ramp);

@ -34,8 +34,8 @@ int main(int argc, char** argv)
{
int N = 9000;
float rate = 24.0 / 25.0;
cf_t* in = malloc(N * sizeof(cf_t));
cf_t* out = malloc(N * sizeof(cf_t));
cf_t* in = srslte_vec_cf_malloc(N);
cf_t* out = srslte_vec_cf_malloc(N);
for (int i = 0; i < N; i++)
in[i] = sin(i * 2 * M_PI / 100);

@ -39,12 +39,12 @@ int main(int argc, char** argv)
float rate = up / down;
printf("Testing rate %f\n", rate);
cf_t* in = malloc(N * sizeof(cf_t));
cf_t* in = srslte_vec_cf_malloc(N);
if (!in) {
perror("malloc");
exit(-1);
}
cf_t* out = malloc(N * sizeof(cf_t));
cf_t* out = srslte_vec_cf_malloc(N);
if (!out) {
perror("malloc");
exit(-1);

@ -523,7 +523,7 @@ int rf_uhd_open_multi(char* args, void** h, uint32_t nof_channels)
// Initialize handler
handler->uhd_error_handler = NULL;
bzero(zero_mem, sizeof(cf_t) * 64 * 1024);
srslte_vec_cf_zero(zero_mem, 64 * 1024);
// Check external clock argument
enum { DEFAULT, EXTERNAL, GPSDO } clock_src;

@ -109,12 +109,12 @@ int main(int argc, char** argv)
}
if (!do_floats) {
input_b = malloc(sizeof(uint8_t) * seq.cur_len);
input_b = srslte_vec_u8_malloc(seq.cur_len);
if (!input_b) {
perror("malloc");
exit(-1);
}
scrambled_b = malloc(sizeof(uint8_t) * seq.cur_len);
scrambled_b = srslte_vec_u8_malloc(seq.cur_len);
if (!scrambled_b) {
perror("malloc");
exit(-1);
@ -142,12 +142,12 @@ int main(int argc, char** argv)
free(input_b);
free(scrambled_b);
} else {
input_f = malloc(sizeof(float) * seq.cur_len);
input_f = srslte_vec_f_malloc(seq.cur_len);
if (!input_f) {
perror("malloc");
exit(-1);
}
scrambled_f = malloc(sizeof(float) * seq.cur_len);
scrambled_f = srslte_vec_f_malloc(seq.cur_len);
if (!scrambled_f) {
perror("malloc");
exit(-1);
@ -179,12 +179,12 @@ int main(int argc, char** argv)
int16_t *input_s, *scrambled_s;
// Scramble also shorts
input_s = malloc(sizeof(int16_t) * seq.cur_len);
input_s = srslte_vec_i16_malloc(seq.cur_len);
if (!input_s) {
perror("malloc");
exit(-1);
}
scrambled_s = malloc(sizeof(int16_t) * seq.cur_len);
scrambled_s = srslte_vec_i16_malloc(seq.cur_len);
if (!scrambled_s) {
perror("malloc");
exit(-1);
@ -216,12 +216,12 @@ int main(int argc, char** argv)
int8_t *input_b, *scrambled_b;
// Scramble also bytes
input_b = malloc(sizeof(int8_t) * seq.cur_len);
input_b = srslte_vec_i8_malloc(seq.cur_len);
if (!input_b) {
perror("malloc");
exit(-1);
}
scrambled_b = malloc(sizeof(int8_t) * seq.cur_len);
scrambled_b = srslte_vec_i8_malloc(seq.cur_len);
if (!scrambled_b) {
perror("malloc");
exit(-1);

@ -41,7 +41,7 @@ int srslte_cfo_init(srslte_cfo_t* h, uint32_t nsamples)
if (srslte_cexptab_init(&h->tab, SRSLTE_CFO_CEXPTAB_SIZE)) {
goto clean;
}
h->cur_cexp = srslte_vec_malloc(sizeof(cf_t) * nsamples);
h->cur_cexp = srslte_vec_cf_malloc(nsamples);
if (!h->cur_cexp) {
goto clean;
}

@ -31,7 +31,7 @@ int srslte_cp_synch_init(srslte_cp_synch_t* q, uint32_t symbol_sz)
q->symbol_sz = symbol_sz;
q->max_symbol_sz = symbol_sz;
q->corr = srslte_vec_malloc(sizeof(cf_t) * q->symbol_sz);
q->corr = srslte_vec_cf_malloc(q->symbol_sz);
if (!q->corr) {
perror("malloc");
return SRSLTE_ERROR;

@ -61,27 +61,27 @@ int srslte_npss_synch_init(srslte_npss_synch_t* q, uint32_t frame_size, uint32_t
uint32_t buffer_size = SRSLTE_NPSS_CORR_FILTER_LEN + frame_size + 1;
q->tmp_input = srslte_vec_malloc(buffer_size * sizeof(cf_t));
q->tmp_input = srslte_vec_cf_malloc(buffer_size);
if (!q->tmp_input) {
PRINT_ERR("Error allocating memory\n");
goto clean_and_exit;
}
memset(q->tmp_input, 0, buffer_size * sizeof(cf_t));
q->conv_output = srslte_vec_malloc(buffer_size * sizeof(cf_t));
q->conv_output = srslte_vec_cf_malloc(buffer_size);
if (!q->conv_output) {
fprintf(stderr, "Error allocating memory\n");
goto clean_and_exit;
}
memset(q->conv_output, 0, sizeof(cf_t) * buffer_size);
q->conv_output_avg = srslte_vec_malloc(buffer_size * sizeof(float));
q->conv_output_avg = srslte_vec_f_malloc(buffer_size);
if (!q->conv_output_avg) {
fprintf(stderr, "Error allocating memory\n");
goto clean_and_exit;
}
memset(q->conv_output_avg, 0, sizeof(float) * buffer_size);
#ifdef SRSLTE_NPSS_ACCUMULATE_ABS
q->conv_output_abs = srslte_vec_malloc(buffer_size * sizeof(float));
q->conv_output_abs = srslte_vec_f_malloc(buffer_size);
if (!q->conv_output_abs) {
fprintf(stderr, "Error allocating memory\n");
goto clean_and_exit;
@ -89,7 +89,7 @@ int srslte_npss_synch_init(srslte_npss_synch_t* q, uint32_t frame_size, uint32_t
memset(q->conv_output_abs, 0, sizeof(float) * buffer_size);
#endif
q->npss_signal_time = srslte_vec_malloc(buffer_size * sizeof(cf_t));
q->npss_signal_time = srslte_vec_cf_malloc(buffer_size);
if (!q->npss_signal_time) {
fprintf(stderr, "Error allocating memory\n");
goto clean_and_exit;

@ -48,34 +48,34 @@ int srslte_nsss_synch_init(srslte_nsss_synch_t* q, uint32_t input_size, uint32_t
uint32_t buffer_size = SRSLTE_NSSS_CORR_FILTER_LEN + q->input_size + 1;
DEBUG("NSSS buffer size is %d samples.\n", buffer_size);
q->tmp_input = srslte_vec_malloc(buffer_size * sizeof(cf_t));
q->tmp_input = srslte_vec_cf_malloc(buffer_size);
if (!q->tmp_input) {
fprintf(stderr, "Error allocating memory\n");
goto clean_and_exit;
}
bzero(q->tmp_input, buffer_size * sizeof(cf_t));
srslte_vec_cf_zero(q->tmp_input, buffer_size);
q->conv_output = srslte_vec_malloc(buffer_size * sizeof(cf_t));
q->conv_output = srslte_vec_cf_malloc(buffer_size);
if (!q->conv_output) {
fprintf(stderr, "Error allocating memory\n");
goto clean_and_exit;
}
bzero(q->conv_output, sizeof(cf_t) * buffer_size);
srslte_vec_cf_zero(q->conv_output, buffer_size);
q->conv_output_abs = srslte_vec_malloc(buffer_size * sizeof(float));
q->conv_output_abs = srslte_vec_f_malloc(buffer_size);
if (!q->conv_output_abs) {
fprintf(stderr, "Error allocating memory\n");
goto clean_and_exit;
}
bzero(q->conv_output_abs, sizeof(float) * buffer_size);
srslte_vec_f_zero(q->conv_output_abs, buffer_size);
for (int i = 0; i < SRSLTE_NUM_PCI; i++) {
q->nsss_signal_time[i] = srslte_vec_malloc(buffer_size * sizeof(cf_t));
q->nsss_signal_time[i] = srslte_vec_cf_malloc(buffer_size);
if (!q->nsss_signal_time[i]) {
fprintf(stderr, "Error allocating memory\n");
goto clean_and_exit;
}
bzero(q->nsss_signal_time[i], sizeof(cf_t) * buffer_size);
srslte_vec_cf_zero(q->nsss_signal_time[i], buffer_size);
}
// generate NSSS sequences
@ -172,8 +172,7 @@ int srslte_nsss_corr_init(srslte_nsss_synch_t* q)
// generate correlation sequences
DEBUG("Generating NSSS sequences\n");
for (int i = 0; i < SRSLTE_NUM_PCI; i++) {
float complex nsss_signal[SRSLTE_NSSS_TOT_LEN];
bzero(nsss_signal, SRSLTE_NSSS_TOT_LEN * sizeof(cf_t));
float complex nsss_signal[SRSLTE_NSSS_TOT_LEN] = {};
srslte_nsss_generate(nsss_signal, i);
// one symbol at a time
@ -181,7 +180,7 @@ int srslte_nsss_corr_init(srslte_nsss_synch_t* q)
int output_len = 0;
for (int i = 0; i < SRSLTE_NSSS_NSYMB; i++) {
// zero buffer, copy NSSS symbol to appr. pos and transform to time-domain
bzero(nsss_signal_pad, q->fft_size * sizeof(cf_t));
srslte_vec_cf_zero(nsss_signal_pad, q->fft_size);
// 5th NSSS symbol has CP length of 10 symbols
int cp_len =

@ -38,8 +38,8 @@ int srslte_pss_init_N_id_2(cf_t* pss_signal_freq, cf_t* pss_signal_time, uint32_
srslte_pss_generate(pss_signal_freq, N_id_2);
bzero(pss_signal_pad, fft_size * sizeof(cf_t));
bzero(pss_signal_time, fft_size * sizeof(cf_t));
srslte_vec_cf_zero(pss_signal_pad, fft_size);
srslte_vec_cf_zero(pss_signal_time, fft_size);
memcpy(&pss_signal_pad[(fft_size - SRSLTE_PSS_LEN) / 2 + cfo_i], pss_signal_freq, SRSLTE_PSS_LEN * sizeof(cf_t));
/* Convert signal into the time domain */
@ -121,8 +121,8 @@ int srslte_pss_init_fft_offset_decim(srslte_pss_t* q,
if (q->decimate > 1) {
int filter_order = 3;
srslte_filt_decim_cc_init(&q->filter, q->decimate, filter_order);
q->filter.filter_output = srslte_vec_malloc((buffer_size) * sizeof(cf_t));
q->filter.downsampled_input = srslte_vec_malloc((buffer_size + filter_order) * sizeof(cf_t));
q->filter.filter_output = srslte_vec_cf_malloc(buffer_size);
q->filter.downsampled_input = srslte_vec_cf_malloc(buffer_size + filter_order);
printf("decimation for the PSS search is %d \n", q->decimate);
}
@ -142,39 +142,39 @@ int srslte_pss_init_fft_offset_decim(srslte_pss_t* q,
srslte_dft_plan_set_dc(&q->idftp_input, true);
srslte_dft_plan_set_norm(&q->idftp_input, false);
bzero(q->tmp_fft2, sizeof(cf_t) * SRSLTE_SYMBOL_SZ_MAX);
srslte_vec_cf_zero(q->tmp_fft2, SRSLTE_SYMBOL_SZ_MAX);
q->tmp_input = srslte_vec_malloc((buffer_size + frame_size * (q->decimate - 1)) * sizeof(cf_t));
q->tmp_input = srslte_vec_cf_malloc(buffer_size + frame_size * (q->decimate - 1));
if (!q->tmp_input) {
ERROR("Error allocating memory\n");
goto clean_and_exit;
}
bzero(&q->tmp_input[q->frame_size], q->fft_size * sizeof(cf_t));
srslte_vec_cf_zero(&q->tmp_input[q->frame_size], q->fft_size);
q->conv_output = srslte_vec_malloc(buffer_size * sizeof(cf_t));
q->conv_output = srslte_vec_cf_malloc(buffer_size);
if (!q->conv_output) {
ERROR("Error allocating memory\n");
goto clean_and_exit;
}
bzero(q->conv_output, sizeof(cf_t) * buffer_size);
q->conv_output_avg = srslte_vec_malloc(buffer_size * sizeof(float));
srslte_vec_cf_zero(q->conv_output, buffer_size);
q->conv_output_avg = srslte_vec_f_malloc(buffer_size);
if (!q->conv_output_avg) {
ERROR("Error allocating memory\n");
goto clean_and_exit;
}
bzero(q->conv_output_avg, sizeof(float) * buffer_size);
srslte_vec_f_zero(q->conv_output_avg, buffer_size);
#ifdef SRSLTE_PSS_ACCUMULATE_ABS
q->conv_output_abs = srslte_vec_malloc(buffer_size * sizeof(float));
q->conv_output_abs = srslte_vec_f_malloc(buffer_size);
if (!q->conv_output_abs) {
ERROR("Error allocating memory\n");
goto clean_and_exit;
}
bzero(q->conv_output_abs, sizeof(float) * buffer_size);
srslte_vec_f_zero(q->conv_output_abs, buffer_size);
#endif
for (N_id_2 = 0; N_id_2 < 3; N_id_2++) {
q->pss_signal_time[N_id_2] = srslte_vec_malloc(buffer_size * sizeof(cf_t));
q->pss_signal_time[N_id_2] = srslte_vec_cf_malloc(buffer_size);
if (!q->pss_signal_time[N_id_2]) {
ERROR("Error allocating memory\n");
goto clean_and_exit;
@ -184,7 +184,7 @@ int srslte_pss_init_fft_offset_decim(srslte_pss_t* q,
ERROR("Error initiating PSS detector for N_id_2=%d fft_size=%d\n", N_id_2, fft_size);
goto clean_and_exit;
}
bzero(&q->pss_signal_time[N_id_2][q->fft_size], q->frame_size * sizeof(cf_t));
srslte_vec_cf_zero(&q->pss_signal_time[N_id_2][q->fft_size], q->frame_size);
}
#ifdef CONVOLUTION_FFT
@ -193,7 +193,7 @@ int srslte_pss_init_fft_offset_decim(srslte_pss_t* q,
goto clean_and_exit;
}
for (N_id_2 = 0; N_id_2 < 3; N_id_2++) {
q->pss_signal_freq_full[N_id_2] = srslte_vec_malloc(buffer_size * sizeof(cf_t));
q->pss_signal_freq_full[N_id_2] = srslte_vec_cf_malloc(buffer_size);
srslte_dft_run_c(&q->conv_fft.filter_plan, q->pss_signal_time[N_id_2], q->pss_signal_freq_full[N_id_2]);
}
@ -253,14 +253,14 @@ int srslte_pss_resize(srslte_pss_t* q, uint32_t frame_size, uint32_t fft_size, i
return SRSLTE_ERROR;
}
bzero(q->tmp_fft2, sizeof(cf_t) * SRSLTE_SYMBOL_SZ_MAX);
srslte_vec_cf_zero(q->tmp_fft2, SRSLTE_SYMBOL_SZ_MAX);
bzero(&q->tmp_input[q->frame_size], q->fft_size * sizeof(cf_t));
bzero(q->conv_output, sizeof(cf_t) * buffer_size);
bzero(q->conv_output_avg, sizeof(float) * buffer_size);
srslte_vec_cf_zero(&q->tmp_input[q->frame_size], q->fft_size);
srslte_vec_cf_zero(q->conv_output, buffer_size);
srslte_vec_f_zero(q->conv_output_avg, buffer_size);
#ifdef SRSLTE_PSS_ACCUMULATE_ABS
bzero(q->conv_output_abs, sizeof(float) * buffer_size);
srslte_vec_f_zero(q->conv_output_abs, buffer_size);
#endif
// Generate PSS sequences for this FFT size
@ -269,7 +269,7 @@ int srslte_pss_resize(srslte_pss_t* q, uint32_t frame_size, uint32_t fft_size, i
ERROR("Error initiating PSS detector for N_id_2=%d fft_size=%d\n", N_id_2, fft_size);
return SRSLTE_ERROR;
}
bzero(&q->pss_signal_time[N_id_2][q->fft_size], q->frame_size * sizeof(cf_t));
srslte_vec_cf_zero(&q->pss_signal_time[N_id_2][q->fft_size], q->frame_size);
}
#ifdef CONVOLUTION_FFT
@ -336,7 +336,7 @@ void srslte_pss_free(srslte_pss_t* q)
void srslte_pss_reset(srslte_pss_t* q)
{
uint32_t buffer_size = q->fft_size + q->frame_size + 1;
bzero(q->conv_output_avg, sizeof(float) * buffer_size);
srslte_vec_f_zero(q->conv_output_avg, buffer_size);
}
/**
@ -573,7 +573,7 @@ void srslte_pss_sic(srslte_pss_t* q, cf_t* input)
{
if (q->chest_on_filter) {
bzero(q->tmp_fft, sizeof(cf_t) * q->fft_size);
srslte_vec_cf_zero(q->tmp_fft, q->fft_size);
// Pass transmitted PSS sequence through the channel
srslte_vec_prod_ccc(

@ -57,17 +57,17 @@ int srslte_psss_init(srslte_psss_t* q, uint32_t nof_prb, srslte_cp_t cp)
return SRSLTE_ERROR;
}
for (uint32_t i = 0; i < 2; ++i) {
q->psss_sf_freq[i] = srslte_vec_malloc(sizeof(cf_t) * fft_size);
q->psss_sf_freq[i] = srslte_vec_cf_malloc(fft_size);
if (!q->psss_sf_freq[i]) {
return SRSLTE_ERROR;
}
}
q->input_pad_freq = srslte_vec_malloc(sizeof(cf_t) * fft_size);
q->input_pad_freq = srslte_vec_cf_malloc(fft_size);
if (!q->input_pad_freq) {
return SRSLTE_ERROR;
}
q->input_pad_time = srslte_vec_malloc(sizeof(cf_t) * fft_size);
q->input_pad_time = srslte_vec_cf_malloc(fft_size);
if (!q->input_pad_time) {
return SRSLTE_ERROR;
}
@ -89,8 +89,8 @@ int srslte_psss_init(srslte_psss_t* q, uint32_t nof_prb, srslte_cp_t cp)
// Create empty subframes with only PSSS
for (uint32_t N_id_2 = 0; N_id_2 < 2; ++N_id_2) {
bzero(q->input_pad_freq, sizeof(cf_t) * fft_size);
bzero(q->input_pad_time, sizeof(cf_t) * fft_size);
srslte_vec_cf_zero(q->input_pad_freq, fft_size);
srslte_vec_cf_zero(q->input_pad_time, fft_size);
srslte_psss_put_sf_buffer(q->psss_signal[N_id_2], q->input_pad_freq, nof_prb, cp);
srslte_ofdm_tx_sf(&psss_tx);
@ -102,19 +102,19 @@ int srslte_psss_init(srslte_psss_t* q, uint32_t nof_prb, srslte_cp_t cp)
srslte_dft_plan_free(&plan);
srslte_ofdm_tx_free(&psss_tx);
q->dot_prod_output = srslte_vec_malloc(sizeof(cf_t) * fft_size);
q->dot_prod_output = srslte_vec_cf_malloc(fft_size);
if (!q->dot_prod_output) {
return SRSLTE_ERROR;
}
q->dot_prod_output_time = srslte_vec_malloc(sizeof(cf_t) * fft_size);
q->dot_prod_output_time = srslte_vec_cf_malloc(fft_size);
if (!q->dot_prod_output_time) {
return SRSLTE_ERROR;
}
q->shifted_output = srslte_vec_malloc(sizeof(cf_t) * fft_size);
q->shifted_output = srslte_vec_cf_malloc(fft_size);
if (!q->shifted_output) {
return SRSLTE_ERROR;
}
q->shifted_output_abs = srslte_vec_malloc(sizeof(float) * fft_size);
q->shifted_output_abs = srslte_vec_f_malloc(fft_size);
if (!q->shifted_output_abs) {
return SRSLTE_ERROR;
}
@ -178,9 +178,9 @@ void srslte_psss_put_sf_buffer(cf_t* psss_signal, cf_t* sf_buffer, uint32_t nof_
// Extended cyclic prefix l = 0,1
for (int i = 0; i < 2; i++) {
uint32_t k = (SRSLTE_CP_NSYMB(cp) - (5 + i)) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31;
bzero(&sf_buffer[k - 5], sizeof(cf_t) * 5);
srslte_vec_cf_zero(&sf_buffer[k - 5], 5);
memcpy(&sf_buffer[k], psss_signal, SRSLTE_PSSS_LEN * sizeof(cf_t));
bzero(&sf_buffer[k + SRSLTE_PSSS_LEN], sizeof(cf_t) * 5);
srslte_vec_cf_zero(&sf_buffer[k + SRSLTE_PSSS_LEN], 5);
}
}
@ -200,8 +200,8 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_
uint32_t sf_n_samples = srslte_symbol_sz(nof_prb) * 15;
uint32_t fft_size = sf_n_samples * 2;
bzero(q->input_pad_freq, sizeof(cf_t) * fft_size);
bzero(q->input_pad_time, sizeof(cf_t) * fft_size);
srslte_vec_cf_zero(q->input_pad_freq, fft_size);
srslte_vec_cf_zero(q->input_pad_time, fft_size);
memcpy(q->input_pad_time, input, sizeof(cf_t) * sf_n_samples);
@ -214,13 +214,13 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_
// IFFT
srslte_dft_run_c(&q->plan_out, q->dot_prod_output, q->dot_prod_output_time);
bzero(q->shifted_output, sizeof(cf_t) * fft_size);
srslte_vec_cf_zero(q->shifted_output, fft_size);
memcpy(q->shifted_output, &q->dot_prod_output_time[fft_size / 2], sizeof(cf_t) * fft_size / 2);
memcpy(&q->shifted_output[fft_size / 2], q->dot_prod_output_time, sizeof(cf_t) * fft_size / 2);
// Peak detection
q->corr_peak_pos = -1;
bzero(q->shifted_output_abs, sizeof(float) * fft_size);
srslte_vec_f_zero(q->shifted_output_abs, fft_size);
srslte_vec_abs_cf_simd(q->shifted_output, q->shifted_output_abs, fft_size);
// Experimental Validation
@ -243,7 +243,7 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_
q->corr_peak_pos = -1;
continue;
}
bzero(&q->shifted_output_abs[q->corr_peak_pos - (symbol_sz / 2)], sizeof(float) * symbol_sz);
srslte_vec_f_zero(&q->shifted_output_abs[q->corr_peak_pos - (symbol_sz / 2)], symbol_sz);
// Find the first side peak
uint32_t peak_1_pos = srslte_vec_max_fi(q->shifted_output_abs, fft_size);
@ -256,7 +256,7 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_
q->corr_peak_pos = -1;
continue;
}
bzero(&q->shifted_output_abs[peak_1_pos - (symbol_sz / 2)], sizeof(float) * symbol_sz);
srslte_vec_f_zero(&q->shifted_output_abs[peak_1_pos - (symbol_sz / 2)], symbol_sz);
// Find the second side peak
uint32_t peak_2_pos = srslte_vec_max_fi(q->shifted_output_abs, fft_size);
@ -269,7 +269,7 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_
q->corr_peak_pos = -1;
continue;
}
bzero(&q->shifted_output_abs[peak_2_pos - (symbol_sz / 2)], sizeof(float) * symbol_sz);
srslte_vec_f_zero(&q->shifted_output_abs[peak_2_pos - (symbol_sz / 2)], symbol_sz);
float threshold_above = q->corr_peak_value / 2.0 * 1.4;
if ((peak_1_value > threshold_above) || (peak_2_value > threshold_above)) {

@ -78,7 +78,7 @@ static inline void refsignal_sf_prepare_correlation(srslte_refsignal_dl_sync_t*
uint32_t sf_len = q->ifft.sf_sz;
cf_t* ptr_filt = q->conv_fft_cc.filter_fft;
memcpy(ptr_filt, q->sequences[0], sizeof(cf_t) * sf_len);
bzero(&ptr_filt[sf_len], sizeof(cf_t) * sf_len);
srslte_vec_cf_zero(&ptr_filt[sf_len], sf_len);
srslte_dft_run_c(&q->conv_fft_cc.filter_plan, ptr_filt, ptr_filt);
}
@ -236,7 +236,7 @@ int srslte_refsignal_dl_sync_set_cell(srslte_refsignal_dl_sync_t* q, srslte_cell
dl_sf_cfg.tti = i;
// Reset OFDM buffer
bzero(q->ifft_buffer_in, sizeof(cf_t) * q->ifft.sf_sz);
srslte_vec_cf_zero(q->ifft_buffer_in, q->ifft.sf_sz);
// Put Synchronization signals
if (i == 0 || i == 5) {

@ -64,11 +64,11 @@ int srslte_ssss_init(srslte_ssss_t* q, uint32_t nof_prb, srslte_cp_t cp, srslte_
srslte_dft_plan_set_mirror(&q->plan_input, true);
srslte_dft_plan_set_norm(&q->plan_input, true);
q->input_pad_freq = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
q->input_pad_freq = srslte_vec_cf_malloc(sf_n_re);
if (!q->input_pad_freq) {
return SRSLTE_ERROR;
}
q->input_pad_time = srslte_vec_malloc(sizeof(cf_t) * sf_n_samples);
q->input_pad_time = srslte_vec_cf_malloc(sf_n_samples);
if (!q->input_pad_time) {
return SRSLTE_ERROR;
}
@ -86,16 +86,16 @@ int srslte_ssss_init(srslte_ssss_t* q, uint32_t nof_prb, srslte_cp_t cp, srslte_
return SRSLTE_ERROR;
}
for (int i = 0; i < SRSLTE_SSSS_NOF_SEQ; ++i) {
q->ssss_sf_freq[i] = srslte_vec_malloc(sizeof(cf_t) * ssss_n_samples);
q->ssss_sf_freq[i] = srslte_vec_cf_malloc(ssss_n_samples);
if (!q->ssss_sf_freq[i]) {
return SRSLTE_ERROR;
}
}
for (int i = 0; i < SRSLTE_SSSS_NOF_SEQ; ++i) {
bzero(q->input_pad_freq, sizeof(cf_t) * ssss_n_samples);
bzero(q->input_pad_time, sizeof(cf_t) * ssss_n_samples);
bzero(q->ssss_sf_freq[i], sizeof(cf_t) * ssss_n_samples);
srslte_vec_cf_zero(q->input_pad_freq, ssss_n_samples);
srslte_vec_cf_zero(q->input_pad_time, ssss_n_samples);
srslte_vec_cf_zero(q->ssss_sf_freq[i], ssss_n_samples);
srslte_ssss_put_sf_buffer(q->ssss_signal[i], q->input_pad_freq, nof_prb, cp);
srslte_ofdm_tx_sf(&ssss_ifft);
@ -106,23 +106,23 @@ int srslte_ssss_init(srslte_ssss_t* q, uint32_t nof_prb, srslte_cp_t cp, srslte_
srslte_ofdm_tx_free(&ssss_ifft);
q->dot_prod_output = srslte_vec_malloc(sizeof(cf_t) * ssss_n_samples);
q->dot_prod_output = srslte_vec_cf_malloc(ssss_n_samples);
if (!q->dot_prod_output) {
return SRSLTE_ERROR;
}
q->dot_prod_output_time = srslte_vec_malloc(sizeof(cf_t) * ssss_n_samples);
q->dot_prod_output_time = srslte_vec_cf_malloc(ssss_n_samples);
if (!q->dot_prod_output_time) {
return SRSLTE_ERROR;
}
q->shifted_output = srslte_vec_malloc(sizeof(cf_t) * ssss_n_samples);
q->shifted_output = srslte_vec_cf_malloc(ssss_n_samples);
if (!q->shifted_output) {
return SRSLTE_ERROR;
}
memset(q->shifted_output, 0, sizeof(cf_t) * ssss_n_samples);
q->shifted_output_abs = srslte_vec_malloc(sizeof(float) * ssss_n_samples);
q->shifted_output_abs = srslte_vec_f_malloc(ssss_n_samples);
if (!q->shifted_output_abs) {
return SRSLTE_ERROR;
}
@ -191,12 +191,12 @@ void srslte_ssss_put_sf_buffer(float* ssss_signal, cf_t* sf_buffer, uint32_t nof
uint32_t slot1_pos = SRSLTE_CP_NSYMB(cp) * SRSLTE_NRE * nof_prb;
for (int i = 0; i < 2; i++) {
uint32_t k = (SRSLTE_CP_NSYMB(cp) - 3 + i) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31;
bzero(&sf_buffer[slot1_pos + k - 5], sizeof(cf_t) * 5);
srslte_vec_cf_zero(&sf_buffer[slot1_pos + k - 5], 5);
for (int j = 0; j < SRSLTE_SSSS_LEN; j++) {
__real__ sf_buffer[slot1_pos + k + j] = ssss_signal[j];
__imag__ sf_buffer[slot1_pos + k + j] = 0;
}
bzero(&sf_buffer[slot1_pos + k + SRSLTE_SSSS_LEN], sizeof(cf_t) * 5);
srslte_vec_cf_zero(&sf_buffer[slot1_pos + k + SRSLTE_SSSS_LEN], 5);
}
}
@ -219,8 +219,8 @@ int srslte_ssss_find(srslte_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N
uint32_t ssss_n_samples = (symbol_sz + cp_len) * 2 +
cp_len; // We need an extra cp_len in order to get the peaks centered after the correlation
bzero(q->input_pad_freq, sizeof(cf_t) * ssss_n_samples);
bzero(q->input_pad_time, sizeof(cf_t) * ssss_n_samples);
srslte_vec_cf_zero(q->input_pad_freq, ssss_n_samples);
srslte_vec_cf_zero(q->input_pad_time, ssss_n_samples);
// CP Normal: ssss (with its cp) starts at sample number: 11 symbol_sz + 2 CP_LEN_NORM_0 + 9 cp_len
// CP Extended: ssss (with its cp) starts at sample number: 9 symbol_sz + 9 cp_len
@ -259,7 +259,7 @@ int srslte_ssss_find(srslte_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N
q->corr_peak_pos = -1;
continue;
}
bzero(&q->shifted_output_abs[q->corr_peak_pos - (symbol_sz / 2)], sizeof(float) * symbol_sz);
srslte_vec_f_zero(&q->shifted_output_abs[q->corr_peak_pos - (symbol_sz / 2)], symbol_sz);
// Find the first side peak
uint32_t peak_1_pos = srslte_vec_max_fi(q->shifted_output_abs, ssss_n_samples);
@ -272,7 +272,7 @@ int srslte_ssss_find(srslte_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N
q->corr_peak_pos = -1;
continue;
}
bzero(&q->shifted_output_abs[peak_1_pos - ((cp_len - 2) / 2)], sizeof(float) * (cp_len - 2));
srslte_vec_f_zero(&q->shifted_output_abs[peak_1_pos - ((cp_len - 2) / 2)], cp_len - 2);
// Find the second side peak
uint32_t peak_2_pos = srslte_vec_max_fi(q->shifted_output_abs, ssss_n_samples);
@ -285,7 +285,7 @@ int srslte_ssss_find(srslte_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N
q->corr_peak_pos = -1;
continue;
}
bzero(&q->shifted_output_abs[peak_2_pos - ((cp_len - 2) / 2)], sizeof(float) * (cp_len - 2));
srslte_vec_f_zero(&q->shifted_output_abs[peak_2_pos - ((cp_len - 2) / 2)], cp_len - 2);
float threshold_above = q->corr_peak_value / 2.0 * 1.6;
if ((peak_1_value > threshold_above) || (peak_2_value > threshold_above)) {

@ -96,14 +96,14 @@ int srslte_sync_init_decim(srslte_sync_t* q, uint32_t frame_size, uint32_t max_o
srslte_sync_set_cfo_tol(q, DEFAULT_CFO_TOL);
for (int i = 0; i < 2; i++) {
q->cfo_i_corr[i] = srslte_vec_malloc(sizeof(cf_t) * q->frame_size);
q->cfo_i_corr[i] = srslte_vec_cf_malloc(q->frame_size);
if (!q->cfo_i_corr[i]) {
perror("malloc");
goto clean_exit;
}
}
q->temp = srslte_vec_malloc(sizeof(cf_t) * 2 * q->frame_size);
q->temp = srslte_vec_cf_malloc(2 * q->frame_size);
if (!q->temp) {
perror("malloc");
goto clean_exit;
@ -314,7 +314,7 @@ static void generate_freq_sss(srslte_sync_t* q, uint32_t N_id_1)
uint32_t k = q->fft_size / 2 - 31;
for (int n = 0; n < 2; n++) {
bzero(symbol, q->fft_size * sizeof(cf_t));
srslte_vec_cf_zero(symbol, q->fft_size);
for (uint32_t i = 0; i < SRSLTE_SSS_LEN; i++) {
__real__ symbol[k + i] = sf[n][i];
__imag__ symbol[k + i] = 0;

@ -64,7 +64,7 @@ int srslte_sync_nbiot_init(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32_t
srslte_sync_nbiot_set_cfo_tol(q, DEFAULT_CFO_TOL);
// initialize shift buffer for CFO estimation
q->shift_buffer = srslte_vec_malloc(SRSLTE_SF_LEN(q->fft_size) * sizeof(cf_t));
q->shift_buffer = srslte_vec_cf_malloc(SRSLTE_SF_LEN(q->fft_size));
if (!q->shift_buffer) {
perror("malloc");
goto clean_exit;
@ -72,7 +72,7 @@ int srslte_sync_nbiot_init(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32_t
srslte_cexptab_gen_sf(q->shift_buffer, -SRSLTE_NBIOT_FREQ_SHIFT_FACTOR, q->fft_size);
// allocate memory for early CFO estimation
q->cfo_output = srslte_vec_malloc(10 * SRSLTE_SF_LEN(q->fft_size) * sizeof(cf_t));
q->cfo_output = srslte_vec_cf_malloc(SRSLTE_NOF_SF_X_FRAME * SRSLTE_SF_LEN(q->fft_size));
if (!q->cfo_output) {
perror("malloc");
goto clean_exit;

@ -72,12 +72,12 @@ int main(int argc, char** argv)
parse_args(argc, argv);
input = malloc(sizeof(cf_t) * num_samples);
input = srslte_vec_cf_malloc(num_samples);
if (!input) {
perror("malloc");
exit(-1);
}
output = malloc(sizeof(cf_t) * num_samples);
output = srslte_vec_cf_malloc(num_samples);
if (!output) {
perror("malloc");
exit(-1);

@ -114,7 +114,7 @@ int main(int argc, char** argv)
parse_args(argc, argv);
buffer = malloc(sizeof(cf_t) * FLEN * 2);
buffer = srslte_vec_cf_malloc(FLEN * 2);
if (!buffer) {
perror("malloc");
exit(-1);

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

Loading…
Cancel
Save