Fix more static analysis warnings

master
Xavier Arteaga 4 years ago committed by Xavier Arteaga
parent 70d6e4d9b3
commit b6fa82bf9a

@ -314,7 +314,7 @@ int main(int argc, char** argv)
// SCI // SCI
srsran_sci_t sci; srsran_sci_t sci;
srsran_sci_init(&sci, cell_sl, sl_comm_resource_pool); srsran_sci_init(&sci, &cell_sl, &sl_comm_resource_pool);
uint8_t sci_rx[SRSRAN_SCI_MAX_LEN] = {}; uint8_t sci_rx[SRSRAN_SCI_MAX_LEN] = {};
char sci_msg[SRSRAN_SCI_MSG_MAX_LEN] = {}; char sci_msg[SRSRAN_SCI_MSG_MAX_LEN] = {};
@ -337,7 +337,7 @@ int main(int argc, char** argv)
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
if (srsran_pssch_init(&pssch, cell_sl, sl_comm_resource_pool) != SRSRAN_SUCCESS) { if (srsran_pssch_init(&pssch, &cell_sl, &sl_comm_resource_pool) != SRSRAN_SUCCESS) {
ERROR("Error initializing PSSCH"); ERROR("Error initializing PSSCH");
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }

@ -106,8 +106,9 @@ typedef struct SRSRAN_API {
} srsran_pssch_t; } srsran_pssch_t;
SRSRAN_API int SRSRAN_API int srsran_pssch_init(srsran_pssch_t* q,
srsran_pssch_init(srsran_pssch_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool); const srsran_cell_sl_t* cell,
const srsran_sl_comm_resource_pool_t* sl_comm_resource_pool);
SRSRAN_API int srsran_pssch_set_cfg(srsran_pssch_t* q, srsran_pssch_cfg_t pssch_cfg); SRSRAN_API int srsran_pssch_set_cfg(srsran_pssch_t* q, srsran_pssch_cfg_t pssch_cfg);
SRSRAN_API int srsran_pssch_encode(srsran_pssch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer); SRSRAN_API int srsran_pssch_encode(srsran_pssch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer);
SRSRAN_API int srsran_pssch_decode(srsran_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t output_len); SRSRAN_API int srsran_pssch_decode(srsran_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t output_len);

@ -89,8 +89,9 @@ typedef struct SRSRAN_API {
} srsran_sci_t; } srsran_sci_t;
SRSRAN_API int SRSRAN_API int srsran_sci_init(srsran_sci_t* q,
srsran_sci_init(srsran_sci_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool); const srsran_cell_sl_t* cell,
const srsran_sl_comm_resource_pool_t* sl_comm_resource_pool);
SRSRAN_API int srsran_sci_format0_pack(srsran_sci_t* q, uint8_t* output); SRSRAN_API int srsran_sci_format0_pack(srsran_sci_t* q, uint8_t* output);
SRSRAN_API int srsran_sci_format1_pack(srsran_sci_t* q, uint8_t* output); SRSRAN_API int srsran_sci_format1_pack(srsran_sci_t* q, uint8_t* output);
SRSRAN_API int srsran_sci_format0_unpack(srsran_sci_t* q, uint8_t* input); SRSRAN_API int srsran_sci_format0_unpack(srsran_sci_t* q, uint8_t* input);

@ -81,6 +81,7 @@ int main(int argc, char** argv)
uint8_t * input, *input_bytes, *output; uint8_t * input, *input_bytes, *output;
cf_t * symbols, *symbols_bytes; cf_t * symbols, *symbols_bytes;
float* llr; float* llr;
srsran_random_t random_gen = srsran_random_init(0x1234);
parse_args(argc, argv); parse_args(argc, argv);
@ -133,14 +134,14 @@ int main(int argc, char** argv)
/* generate random data */ /* generate random data */
for (i = 0; i < num_bits; i++) { for (i = 0; i < num_bits; i++) {
input[i] = rand() % 2; input[i] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 1);
} }
/* modulate */ /* modulate */
struct timeval t[3]; struct timeval t[3];
gettimeofday(&t[1], NULL); gettimeofday(&t[1], NULL);
int ntrials = 100; int ntrials = 100;
for (int i = 0; i < ntrials; i++) { for (int j = 0; j < ntrials; j++) {
srsran_mod_modulate(&mod, input, symbols, num_bits); srsran_mod_modulate(&mod, input, symbols, num_bits);
} }
gettimeofday(&t[2], NULL); gettimeofday(&t[2], NULL);
@ -151,16 +152,16 @@ int main(int argc, char** argv)
/* Test packed implementation */ /* Test packed implementation */
srsran_bit_pack_vector(input, input_bytes, num_bits); srsran_bit_pack_vector(input, input_bytes, num_bits);
gettimeofday(&t[1], NULL); gettimeofday(&t[1], NULL);
for (int i = 0; i < ntrials; i++) { for (int j = 0; j < ntrials; j++) {
srsran_mod_modulate_bytes(&mod, input_bytes, symbols_bytes, num_bits); srsran_mod_modulate_bytes(&mod, input_bytes, symbols_bytes, num_bits);
} }
gettimeofday(&t[2], NULL); gettimeofday(&t[2], NULL);
get_time_interval(t); get_time_interval(t);
printf("Byte: %ld us\n", t[0].tv_usec); printf("Byte: %ld us\n", t[0].tv_usec);
for (int i = 0; i < num_bits / mod.nbits_x_symbol; i++) { for (int j = 0; i < num_bits / mod.nbits_x_symbol; j++) {
if (symbols[i] != symbols_bytes[i]) { if (symbols[j] != symbols_bytes[j]) {
printf("error in symbol %d\n", i); printf("error in symbol %d\n", j);
exit(-1); exit(-1);
} }
} }
@ -191,7 +192,7 @@ int main(int argc, char** argv)
free(output); free(output);
free(input); free(input);
free(input_bytes); free(input_bytes);
srsran_random_free(random_gen);
srsran_modem_table_free(&mod); srsran_modem_table_free(&mod);
exit(ret); exit(ret);

@ -21,23 +21,25 @@
#include "srsran/phy/utils/debug.h" #include "srsran/phy/utils/debug.h"
#include "srsran/phy/utils/vector.h" #include "srsran/phy/utils/vector.h"
int srsran_pssch_init(srsran_pssch_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool) int srsran_pssch_init(srsran_pssch_t* q,
const srsran_cell_sl_t* cell,
const srsran_sl_comm_resource_pool_t* sl_comm_resource_pool)
{ {
if (q == NULL) { if (q == NULL || cell == NULL || sl_comm_resource_pool == NULL) {
return SRSRAN_ERROR_INVALID_INPUTS; return SRSRAN_ERROR_INVALID_INPUTS;
} }
q->cell = cell; q->cell = *cell;
q->sl_comm_resource_pool = sl_comm_resource_pool; q->sl_comm_resource_pool = *sl_comm_resource_pool;
if (cell.tm == SRSRAN_SIDELINK_TM1 || cell.tm == SRSRAN_SIDELINK_TM2) { if (cell->tm == SRSRAN_SIDELINK_TM1 || cell->tm == SRSRAN_SIDELINK_TM2) {
if (cell.cp == SRSRAN_CP_NORM) { if (cell->cp == SRSRAN_CP_NORM) {
q->nof_data_symbols = SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS; q->nof_data_symbols = SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS;
} else { } else {
q->nof_data_symbols = SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS_CP_EXT; q->nof_data_symbols = SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS_CP_EXT;
} }
} else if (cell.tm == SRSRAN_SIDELINK_TM3 || cell.tm == SRSRAN_SIDELINK_TM4) { } else if (cell->tm == SRSRAN_SIDELINK_TM3 || cell->tm == SRSRAN_SIDELINK_TM4) {
if (cell.cp == SRSRAN_CP_NORM) { if (cell->cp == SRSRAN_CP_NORM) {
q->nof_data_symbols = SRSRAN_PSSCH_TM34_NUM_DATA_SYMBOLS; q->nof_data_symbols = SRSRAN_PSSCH_TM34_NUM_DATA_SYMBOLS;
} else { } else {
ERROR("Invalid CP for PSSCH, SL TM 3/4"); ERROR("Invalid CP for PSSCH, SL TM 3/4");

@ -162,9 +162,9 @@ static ra_nr_table_t ra_nr_select_table_pusch_noprecoding(srsran_mcs_table_t
// - the UE is configured with MCS-C-RNTI, and // - the UE is configured with MCS-C-RNTI, and
// - the PUSCH is scheduled by a PDCCH with // - the PUSCH is scheduled by a PDCCH with
// - CRC scrambled by MCS-C-RNTI, // - CRC scrambled by MCS-C-RNTI,
if (mcs_c_rnti && dci_format != srsran_dci_format_nr_rar && rnti_type == srsran_rnti_type_mcs_c) { // if (mcs_c_rnti && dci_format != srsran_dci_format_nr_rar && rnti_type == srsran_rnti_type_mcs_c) {
return ra_nr_table_3; // return ra_nr_table_3;
} // }
// - mcs-Table in configuredGrantConfig is set to 'qam256', // - mcs-Table in configuredGrantConfig is set to 'qam256',
// - if PUSCH is scheduled by a PDCCH with CRC scrambled by CS-RNTI or // - if PUSCH is scheduled by a PDCCH with CRC scrambled by CS-RNTI or
@ -192,7 +192,6 @@ static ra_nr_table_t ra_nr_select_table_pdsch(srsran_mcs_table_t mcs_tab
{ {
// Non-implemented parameters // Non-implemented parameters
bool sps_config_mcs_table_present = false; bool sps_config_mcs_table_present = false;
srsran_mcs_table_t sps_config_mcs_table = srsran_mcs_table_64qam;
bool is_pdcch_sps = false; bool is_pdcch_sps = false;
// - the higher layer parameter mcs-Table given by PDSCH-Config is set to 'qam256', and // - the higher layer parameter mcs-Table given by PDSCH-Config is set to 'qam256', and
@ -224,10 +223,10 @@ static ra_nr_table_t ra_nr_select_table_pdsch(srsran_mcs_table_t mcs_tab
// - the UE is configured with the higher layer parameter mcs-Table given by SPS-Config set to 'qam64LowSE' // - the UE is configured with the higher layer parameter mcs-Table given by SPS-Config set to 'qam64LowSE'
// - if the PDSCH is scheduled by a PDCCH with CRC scrambled by CS-RNTI or // - if the PDSCH is scheduled by a PDCCH with CRC scrambled by CS-RNTI or
// - if the PDSCH is scheduled without corresponding PDCCH transmission using SPS-Config, // - if the PDSCH is scheduled without corresponding PDCCH transmission using SPS-Config,
if (sps_config_mcs_table_present && sps_config_mcs_table == srsran_mcs_table_qam64LowSE && // if (sps_config_mcs_table_present && sps_config_mcs_table == srsran_mcs_table_qam64LowSE &&
(rnti_type == srsran_rnti_type_cs || is_pdcch_sps)) { // (rnti_type == srsran_rnti_type_cs || is_pdcch_sps)) {
return ra_nr_table_3; // return ra_nr_table_3;
} // }
// else // else
return ra_nr_table_1; return ra_nr_table_1;

@ -15,7 +15,9 @@
#include "srsran/phy/phch/sci.h" #include "srsran/phy/phch/sci.h"
#include "srsran/phy/utils/bit.h" #include "srsran/phy/utils/bit.h"
int srsran_sci_init(srsran_sci_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool) int srsran_sci_init(srsran_sci_t* q,
const srsran_cell_sl_t* cell,
const srsran_sl_comm_resource_pool_t* sl_comm_resource_pool)
{ {
int ret = SRSRAN_ERROR_INVALID_INPUTS; int ret = SRSRAN_ERROR_INVALID_INPUTS;
if (q != NULL) { if (q != NULL) {
@ -23,18 +25,18 @@ int srsran_sci_init(srsran_sci_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resou
bzero(q, sizeof(srsran_sci_t)); bzero(q, sizeof(srsran_sci_t));
q->nof_prb = cell.nof_prb; q->nof_prb = cell->nof_prb;
q->tm = cell.tm; q->tm = cell->tm;
if (cell.tm == SRSRAN_SIDELINK_TM1 || cell.tm == SRSRAN_SIDELINK_TM2) { if (cell->tm == SRSRAN_SIDELINK_TM1 || cell->tm == SRSRAN_SIDELINK_TM2) {
q->format = SRSRAN_SCI_FORMAT0; q->format = SRSRAN_SCI_FORMAT0;
q->sci_len = srsran_sci_format0_sizeof(cell.nof_prb); q->sci_len = srsran_sci_format0_sizeof(cell->nof_prb);
} else if (cell.tm == SRSRAN_SIDELINK_TM3 || cell.tm == SRSRAN_SIDELINK_TM4) { } else if (cell->tm == SRSRAN_SIDELINK_TM3 || cell->tm == SRSRAN_SIDELINK_TM4) {
q->format = SRSRAN_SCI_FORMAT1; q->format = SRSRAN_SCI_FORMAT1;
q->sci_len = SRSRAN_SCI_TM34_LEN; q->sci_len = SRSRAN_SCI_TM34_LEN;
q->size_sub_channel = sl_comm_resource_pool.size_sub_channel; q->size_sub_channel = sl_comm_resource_pool->size_sub_channel;
q->num_sub_channel = sl_comm_resource_pool.num_sub_channel; q->num_sub_channel = sl_comm_resource_pool->num_sub_channel;
} else { } else {
return SRSRAN_ERROR; return SRSRAN_ERROR;

@ -48,6 +48,8 @@ uint16_t rnti = 1234;
uint16_t i_tbs_val = 0; uint16_t i_tbs_val = 0;
char* input_file = NULL; char* input_file = NULL;
static srsran_random_t random_gen = NULL;
void usage(char* prog) void usage(char* prog)
{ {
printf("Usage: %s [fmMlsrRFpnv] \n", prog); printf("Usage: %s [fmMlsrRFpnv] \n", prog);
@ -163,7 +165,7 @@ int get_ref_res(srsran_nbiot_cell_t cell, int32_t* re_with_refs)
return num_ref; return num_ref;
} }
int extract_re(srsran_nbiot_cell_t cell, uint32_t l_start, uint32_t expected_nof_re) int extract_re(srsran_nbiot_cell_t cell, uint32_t l_start, uint32_t expected_nof_re2)
{ {
srsran_npdsch_t npdsch; srsran_npdsch_t npdsch;
bzero(&npdsch, sizeof(srsran_npdsch_t)); bzero(&npdsch, sizeof(srsran_npdsch_t));
@ -197,8 +199,8 @@ int extract_re(srsran_nbiot_cell_t cell, uint32_t l_start, uint32_t expected_nof
#endif #endif
// check number of extracted REs // check number of extracted REs
if (nof_ext_syms != expected_nof_re) { if (nof_ext_syms != expected_nof_re2) {
printf("RE extraction failed (expected %d, but got %d)!\n", expected_nof_re, nof_ext_syms); printf("RE extraction failed (expected %d, but got %d)!\n", expected_nof_re2, nof_ext_syms);
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
@ -234,7 +236,9 @@ int re_extract_test(int argc, char** argv)
// Standalone mode with l_start=0 gives the maximum number of REs // Standalone mode with l_start=0 gives the maximum number of REs
cell.mode = mode; cell.mode = mode;
cell.base.nof_prb = 1; cell.base.nof_prb = 1;
cell.base.id = (mode == SRSRAN_NBIOT_MODE_INBAND_SAME_PCI) ? n_id_ncell : rand() % SRSRAN_NUM_PCI; cell.base.id = (mode == SRSRAN_NBIOT_MODE_INBAND_SAME_PCI)
? n_id_ncell
: srsran_random_uniform_int_dist(random_gen, 0, SRSRAN_NUM_PCI - 1);
cell.n_id_ncell = n_id_ncell; cell.n_id_ncell = n_id_ncell;
cell.nof_ports = nof_ports_nbiot; cell.nof_ports = nof_ports_nbiot;
cell.base.nof_ports = nof_ports_lte; cell.base.nof_ports = nof_ports_lte;
@ -379,9 +383,8 @@ int coding_test(int argc, char** argv)
} }
// generate random data // generate random data
srand(time(NULL));
for (int i = 0; i < grant.mcs[0].tbs / 8; i++) { for (int i = 0; i < grant.mcs[0].tbs / 8; i++) {
data[i] = rand() % 256; data[i] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 255);
} }
if (!input_file) { if (!input_file) {
@ -464,7 +467,7 @@ quit:
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
int ret = SRSRAN_ERROR; int ret = SRSRAN_ERROR;
random_gen = srsran_random_init(0x1234);
if (re_extract_test(argc, argv) != SRSRAN_SUCCESS) { if (re_extract_test(argc, argv) != SRSRAN_SUCCESS) {
printf("Resource element extraction test failed!\n"); printf("Resource element extraction test failed!\n");
return ret; return ret;

@ -72,6 +72,7 @@ int main(int argc, char** argv)
int nof_re; int nof_re;
cf_t* sf_symbols[SRSRAN_MAX_PORTS]; cf_t* sf_symbols[SRSRAN_MAX_PORTS];
uint32_t nof_rx_ports; uint32_t nof_rx_ports;
srsran_random_t random_gen = srsran_random_init(0x1234);
parse_args(argc, argv); parse_args(argc, argv);
@ -100,9 +101,8 @@ int main(int argc, char** argv)
exit(-1); exit(-1);
} }
srand(time(NULL));
for (i = 0; i < SRSRAN_BCH_PAYLOAD_LEN; i++) { for (i = 0; i < SRSRAN_BCH_PAYLOAD_LEN; i++) {
bch_payload_tx[i] = rand() % 2; bch_payload_tx[i] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 1);
} }
srsran_pbch_encode(&pbch, bch_payload_tx, sf_symbols, 0); srsran_pbch_encode(&pbch, bch_payload_tx, sf_symbols, 0);
@ -127,6 +127,7 @@ int main(int argc, char** argv)
} }
srsran_chest_dl_res_free(&chest_dl_res); srsran_chest_dl_res_free(&chest_dl_res);
srsran_random_free(random_gen);
printf("Tx ports: %d - Rx ports: %d\n", cell.nof_ports, nof_rx_ports); printf("Tx ports: %d - Rx ports: %d\n", cell.nof_ports, nof_rx_ports);
printf("Tx payload: "); printf("Tx payload: ");

@ -164,6 +164,7 @@ int main(int argc, char** argv)
int nof_dcis; int nof_dcis;
bzero(&testcases, sizeof(testcase_dci_t) * 10); bzero(&testcases, sizeof(testcase_dci_t) * 10);
srsran_random_t random_gen = srsran_random_init(0x1234);
int ret = -1; int ret = -1;
@ -224,14 +225,14 @@ int main(int argc, char** argv)
dci.type0_alloc.rbg_bitmask = 0x5; dci.type0_alloc.rbg_bitmask = 0x5;
dci.cif_present = dci_cfg.cif_enabled; dci.cif_present = dci_cfg.cif_enabled;
if (dci_cfg.cif_enabled) { if (dci_cfg.cif_enabled) {
dci.cif = (uint32_t)(random() & 0x7); dci.cif = (uint32_t)srsran_random_uniform_int_dist(random_gen, 0, 7);
} }
/* Format 1 Test case */ /* Format 1 Test case */
if (cell.nof_ports == 1) { if (cell.nof_ports == 1) {
testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT1; testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT1;
if (dci_cfg.cif_enabled) { if (dci_cfg.cif_enabled) {
dci.cif = (uint32_t)(random() & 0x7); dci.cif = (uint32_t)srsran_random_uniform_int_dist(random_gen, 0, 7);
} }
testcases[nof_dcis].ra_dl_tx = dci; testcases[nof_dcis].ra_dl_tx = dci;
nof_dcis++; nof_dcis++;
@ -240,7 +241,7 @@ int main(int argc, char** argv)
dci.tb[0].mcs_idx = 15; dci.tb[0].mcs_idx = 15;
testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT1; testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT1;
if (dci_cfg.cif_enabled) { if (dci_cfg.cif_enabled) {
dci.cif = (uint32_t)(random() & 0x7); dci.cif = (uint32_t)srsran_random_uniform_int_dist(random_gen, 0, 7);
} }
testcases[nof_dcis].ra_dl_tx = dci; testcases[nof_dcis].ra_dl_tx = dci;
nof_dcis++; nof_dcis++;
@ -253,7 +254,7 @@ int main(int argc, char** argv)
dci.tb[1].ndi = true; dci.tb[1].ndi = true;
testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT2A; testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT2A;
if (dci_cfg.cif_enabled) { if (dci_cfg.cif_enabled) {
dci.cif = (uint32_t)(random() & 0x7); dci.cif = (uint32_t)srsran_random_uniform_int_dist(random_gen, 0, 7);
} }
testcases[nof_dcis].ra_dl_tx = dci; testcases[nof_dcis].ra_dl_tx = dci;
nof_dcis++; nof_dcis++;
@ -266,15 +267,12 @@ int main(int argc, char** argv)
dci.tb[1].ndi = false; dci.tb[1].ndi = false;
testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT2; testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT2;
if (dci_cfg.cif_enabled) { if (dci_cfg.cif_enabled) {
dci.cif = (uint32_t)(random() & 0x7); dci.cif = (uint32_t)srsran_random_uniform_int_dist(random_gen, 0, 7);
} }
testcases[nof_dcis].ra_dl_tx = dci; testcases[nof_dcis].ra_dl_tx = dci;
nof_dcis++; nof_dcis++;
} }
srsran_dci_cfg_t dci_cfg;
ZERO_OBJECT(dci_cfg);
srsran_dl_sf_cfg_t dl_sf; srsran_dl_sf_cfg_t dl_sf;
ZERO_OBJECT(dl_sf); ZERO_OBJECT(dl_sf);
dl_sf.cfi = cfi; dl_sf.cfi = cfi;
@ -391,6 +389,7 @@ quit:
srsran_pdcch_free(&pdcch_rx); srsran_pdcch_free(&pdcch_rx);
srsran_chest_dl_res_free(&chest_dl_res); srsran_chest_dl_res_free(&chest_dl_res);
srsran_regs_free(&regs); srsran_regs_free(&regs);
srsran_random_free(random_gen);
for (i = 0; i < SRSRAN_MAX_PORTS; i++) { for (i = 0; i < SRSRAN_MAX_PORTS; i++) {
free(slot_symbols[i]); free(slot_symbols[i]);

@ -194,6 +194,7 @@ int main(int argc, char** argv)
srsran_chest_dl_t chest; srsran_chest_dl_t chest;
srsran_chest_dl_res_t chest_res; srsran_chest_dl_res_t chest_res;
srsran_pdsch_res_t pdsch_res[SRSRAN_MAX_CODEWORDS]; srsran_pdsch_res_t pdsch_res[SRSRAN_MAX_CODEWORDS];
srsran_random_t random_gen = srsran_random_init(0x1234);
/* Initialise to zeros */ /* Initialise to zeros */
ZERO_OBJECT(softbuffers_tx); ZERO_OBJECT(softbuffers_tx);
@ -386,7 +387,7 @@ int main(int argc, char** argv)
for (int tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { for (int tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) {
if (pdsch_cfg.grant.tb[tb].enabled) { if (pdsch_cfg.grant.tb[tb].enabled) {
for (int byte = 0; byte < pdsch_cfg.grant.tb[tb].tbs / 8; byte++) { for (int byte = 0; byte < pdsch_cfg.grant.tb[tb].tbs / 8; byte++) {
data_tx[tb][byte] = (uint8_t)(rand() % 256); data_tx[tb][byte] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 255);
} }
} }
} }
@ -566,6 +567,7 @@ quit:
free(rx_slot_symbols[i]); free(rx_slot_symbols[i]);
} }
} }
srsran_random_free(random_gen);
if (ret) { if (ret) {
printf("Error\n"); printf("Error\n");
} else { } else {

@ -98,6 +98,7 @@ int main(int argc, char** argv)
uint32_t nsf; uint32_t nsf;
int cid, max_cid; int cid, max_cid;
uint32_t ngroup, nseq, max_nseq; uint32_t ngroup, nseq, max_nseq;
srsran_random_t random_gen = srsran_random_init(0x1234);
parse_args(argc, argv); parse_args(argc, argv);
@ -161,7 +162,7 @@ int main(int argc, char** argv)
resource.ngroup = ngroup; resource.ngroup = ngroup;
resource.nseq = nseq; resource.nseq = nseq;
ack[ngroup][nseq] = rand() % 2; ack[ngroup][nseq] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 1);
srsran_phich_encode(&phich, &dl_sf, resource, ack[ngroup][nseq], slot_symbols); srsran_phich_encode(&phich, &dl_sf, resource, ack[ngroup][nseq], slot_symbols);
} }
@ -207,7 +208,7 @@ int main(int argc, char** argv)
cid++; cid++;
} }
srsran_phich_free(&phich); srsran_phich_free(&phich);
srsran_random_free(random_gen);
srsran_chest_dl_res_free(&chest_res); srsran_chest_dl_res_free(&chest_res);
for (i = 0; i < SRSRAN_MAX_PORTS; i++) { for (i = 0; i < SRSRAN_MAX_PORTS; i++) {

@ -144,9 +144,8 @@ int main(int argc, char** argv)
{ {
parse_args(argc, argv); parse_args(argc, argv);
srsran_prach_t prach; srsran_prach_t prach;
srsran_random_t random_gen = srsran_random_init(0x1234);
bool high_speed_flag = false; bool high_speed_flag = false;
srand(0);
cf_t preamble[MAX_LEN]; cf_t preamble[MAX_LEN];
memset(preamble, 0, sizeof(cf_t) * MAX_LEN); memset(preamble, 0, sizeof(cf_t) * MAX_LEN);
cf_t preamble_sum[MAX_LEN]; cf_t preamble_sum[MAX_LEN];
@ -182,7 +181,7 @@ int main(int argc, char** argv)
printf("limiting number of preambles to 6\n"); printf("limiting number of preambles to 6\n");
if (test_offset_calculation) { if (test_offset_calculation) {
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
offsets[i] = (rand() % 50); offsets[i] = srsran_random_uniform_int_dist(random_gen, 0, 49);
} }
} }
} }
@ -252,6 +251,7 @@ int main(int argc, char** argv)
} }
srsran_prach_free(&prach); srsran_prach_free(&prach);
srsran_random_free(random_gen);
printf("Done\n"); printf("Done\n");
exit(0); exit(0);
} }

@ -98,7 +98,7 @@ int main(int argc, char** argv)
// SCI // SCI
srsran_sci_t sci; srsran_sci_t sci;
srsran_sci_init(&sci, cell, sl_comm_resource_pool); srsran_sci_init(&sci, &cell, &sl_comm_resource_pool);
sci.mcs_idx = 2; sci.mcs_idx = 2;
// PSCCH // PSCCH

@ -151,7 +151,10 @@ int base_init()
} }
srsran_vec_cf_zero(input_buffer, sf_n_samples); srsran_vec_cf_zero(input_buffer, sf_n_samples);
srsran_sci_init(&sci, cell, sl_comm_resource_pool); if (srsran_sci_init(&sci, &cell, &sl_comm_resource_pool) < SRSRAN_SUCCESS) {
ERROR("Error in SCI init");
return SRSRAN_ERROR;
}
if (srsran_pscch_init(&pscch, SRSRAN_MAX_PRB) != SRSRAN_SUCCESS) { if (srsran_pscch_init(&pscch, SRSRAN_MAX_PRB) != SRSRAN_SUCCESS) {
ERROR("Error in PSCCH init"); ERROR("Error in PSCCH init");
@ -168,7 +171,7 @@ int base_init()
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
if (srsran_pssch_init(&pssch, cell, sl_comm_resource_pool) != SRSRAN_SUCCESS) { if (srsran_pssch_init(&pssch, &cell, &sl_comm_resource_pool) != SRSRAN_SUCCESS) {
ERROR("Error initializing PSSCH"); ERROR("Error initializing PSSCH");
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }

@ -83,7 +83,7 @@ int main(int argc, char** argv)
} }
srsran_pssch_t pssch = {}; srsran_pssch_t pssch = {};
if (srsran_pssch_init(&pssch, cell, sl_comm_resource_pool) != SRSRAN_SUCCESS) { if (srsran_pssch_init(&pssch, &cell, &sl_comm_resource_pool) != SRSRAN_SUCCESS) {
ERROR("Error initializing PSSCH"); ERROR("Error initializing PSSCH");
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }

@ -10,6 +10,7 @@
* *
*/ */
#include "srsran/phy/utils/random.h"
#include <complex.h> #include <complex.h>
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
@ -132,19 +133,17 @@ int test_dft(cf_t* in)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
srsran_random_t random_gen = srsran_random_init(0x1234);
parse_args(argc, argv); parse_args(argc, argv);
cf_t* in = srsran_vec_cf_malloc(N); cf_t* in = srsran_vec_cf_malloc(N);
srsran_vec_cf_zero(in, N); in[0] = 0.0f;
for (int i = 1; i < N - 1; i++) { srsran_random_uniform_complex_dist_vector(random_gen, &in[1], N - 1, -1, 1);
float re = 100 * rand() / (float)RAND_MAX;
float im = 100 * rand() / (float)RAND_MAX;
in[i] = re + im * I;
}
if (test_dft(in) != 0) if (test_dft(in) != 0)
return -1; return -1;
free(in); free(in);
srsran_random_free(random_gen);
printf("Done\n"); printf("Done\n");
exit(0); exit(0);
} }

Loading…
Cancel
Save