PUSCH test cases generator in CMake

master
Xavier Arteaga 7 years ago
parent 563bf6cde5
commit 36936349fe

@ -224,7 +224,76 @@ add_test(pmch_file_test pmch_file_test -i ${CMAKE_CURRENT_SOURCE_DIR}/pmch_100p
add_executable(pusch_test pusch_test.c) add_executable(pusch_test pusch_test.c)
target_link_libraries(pusch_test srslte_phy) target_link_libraries(pusch_test srslte_phy)
add_test(pusch_test pusch_test) if (NOT DEFINED TEST_EXTENSION)
set(TEST_EXTENSION Normal)
endif(NOT DEFINED TEST_EXTENSION)
if (TEST_EXTENSION STREQUAL Paranoid)
# All valid number of PRBs for PUSCH
set(cell_n_prb_valid 1 2 3 4 5 6 8 9 10 12 15 16 18 20 24 25 27 30 32 36 40 45 48 50 54 60 64 72 75 80 81 90 96 100)
set(pusch_min_mcs 0)
set(pusch_max_mcs 28)
set(pusch_step_mcs 1)
set(pusch_acks -1 0 1)
set(pusch_cqi none wideband)
else (TEST_EXTENSION STREQUAL Paranoid)
set(cell_n_prb_valid 6 15 25 50 100)
set(pusch_min_mcs 0)
set(pusch_max_mcs 28)
set(pusch_step_mcs 10)
set(pusch_acks -1 0)
set(pusch_cqi none wideband)
endif (TEST_EXTENSION STREQUAL Paranoid)
foreach (cell_n_prb 6 15 25 50 75 100)
set(pusch_cell_n_prb)
foreach (n_prb ${cell_n_prb_valid})
if (NOT (${n_prb} GREATER ${cell_n_prb}))
set(pusch_cell_n_prb ${pusch_cell_n_prb} ${n_prb})
endif (NOT (${n_prb} GREATER ${cell_n_prb}))
endforeach (n_prb)
foreach (n_prb ${pusch_cell_n_prb})
foreach (mcs RANGE ${pusch_min_mcs} ${pusch_max_mcs} ${pusch_step_mcs})
foreach (ack ${pusch_acks})
foreach (cqi ${pusch_cqi})
set(pusch_test_args "")
set(pusch_test_args ${pusch_test_args} -n ${cell_n_prb})
set(pusch_test_args ${pusch_test_args} -L ${n_prb})
if (NOT (${ack} EQUAL -1))
set(pusch_test_args ${pusch_test_args} -p uci_ack ${ack})
if (mcs EQUAL 28)
set(mcs 27)
endif (mcs EQUAL 28)
endif (NOT (${ack} EQUAL -1))
if (NOT (${cqi} STREQUAL none))
set(pusch_test_args ${pusch_test_args} -p uci_cqi ${cqi})
#if (mcs EQUAL 28)
# set(mcs 27)
#endif (mcs EQUAL 28)
endif (NOT (${cqi} STREQUAL none))
set(pusch_test_args ${pusch_test_args} -m ${mcs})
string(REGEX REPLACE "\ " "" test_name_args ${pusch_test_args})
add_test(pusch_test${test_name_args} pusch_test ${pusch_test_args})
endforeach (cqi)
endforeach (ack)
endforeach (mcs)
endforeach (n_prb)
endforeach (cell_n_prb)
######################################################################## ########################################################################
# PUCCH TEST # PUCCH TEST

@ -34,12 +34,32 @@
#include "srslte/srslte.h" #include "srslte/srslte.h"
srslte_cell_t cell = { srslte_cell_t cell = {
6, // nof_prb .nof_prb = 6, // nof_prb
1, // nof_ports .nof_ports = 1, // nof_ports
0, // cell_id .id = 0, // cell_id
SRSLTE_CP_NORM, // cyclic prefix .cp = SRSLTE_CP_NORM, // cyclic prefix
SRSLTE_PHICH_R_1_6, // PHICH resources .phich_length = SRSLTE_PHICH_NORM, // PHICH length
SRSLTE_PHICH_NORM // PHICH length .phich_resources = SRSLTE_PHICH_R_1_6 // PHICH resources
};
srslte_uci_cfg_t uci_cfg = {
.I_offset_cqi = 6,
.I_offset_ri = 2,
.I_offset_ack = 9,
};
srslte_uci_data_t uci_data_tx = {
.uci_cqi = {0},
.uci_cqi_len = 0,
.uci_ri = 0,
.uci_ri_len = 0,
.uci_ack = 0,
.uci_ack_2 = 0,
.uci_ack_len = 0,
.ri_periodic_report = false,
.scheduling_request = false,
.channel_selection = false,
.cqi_ack = false
}; };
uint32_t cfi = 2; uint32_t cfi = 2;
@ -52,25 +72,110 @@ uint32_t n_prb = 0;
int freq_hop = -1; int freq_hop = -1;
int riv = -1; int riv = -1;
uint32_t mcs_idx = 0; uint32_t mcs_idx = 0;
srslte_cqi_value_t cqi_value;
void usage(char *prog) { void usage(char *prog) {
printf("Usage: %s [csrnfvmtLNF] -m MCS \n", prog); printf("Usage: %s [csrnfvmtLNF] \n", prog);
printf("\t-m MCS index [Default %d]\n", mcs_idx); printf("\n\tCell specific parameters:\n");
printf("\t-c cell id [Default %d]\n", cell.id); printf("\t\t-n number of PRB [Default %d]\n", cell.nof_prb);
printf("\t-s subframe [Default %d]\n", subframe); printf("\t\t-c cell id [Default %d]\n", cell.id);
printf("\t-L L_prb [Default %d]\n", L_prb);
printf("\t-N n_prb [Default %d]\n", n_prb); printf("\n\tGrant parameters:\n");
printf("\t-F frequency hopping [Default %d]\n", freq_hop); printf("\t\t-m MCS index (0-28) [Default %d]\n", mcs_idx);
printf("\t-R RIV [Default %d]\n", riv); printf("\t\t-L L_prb [Default %d]\n", L_prb);
printf("\t-r rv_idx [Default %d]\n", rv_idx); printf("\t\t-N n_prb [Default %d]\n", n_prb);
printf("\t-f cfi [Default %d]\n", cfi); printf("\t\t-F frequency hopping [Default %d]\n", freq_hop);
printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); printf("\t\t-R RIV [Default %d]\n", riv);
printf("\t\t-r rv_idx (0-3) [Default %d]\n", rv_idx);
printf("\t\t-f cfi [Default %d]\n", cfi);
printf("\n\tCQI/RI/ACK Reporting indexes parameters:\n");
printf("\t\t-p I_offset_cqi (0-15) [Default %d]\n", uci_cfg.I_offset_cqi);
printf("\t\t-p I_offset_ri (0-15) [Default %d]\n", uci_cfg.I_offset_ri);
printf("\t\t-p I_offset_ack (0-15) [Default %d]\n", uci_cfg.I_offset_ack);
printf("\n\tCQI/RI/ACK Reporting contents:\n");
printf("\t\t-p uci_cqi (zeros, ones, random) [Default zeros]\n");
printf("\t\t-p uci_cqi_len (0-64) [Default %d]\n", uci_data_tx.uci_cqi_len);
printf("\t\t-p uci_ri (0-1) (zeros, ones, random) [Default none]\n");
printf("\t\t-p uci_ack (0-1) [Default none]\n");
printf("\t\t-p uci_ack_2 (0-1) [Default none]\n");
printf("\n\tOther parameters:\n");
printf("\t\t-s subframe [Default %d]\n", subframe);
printf("\t-v [set srslte_verbose to debug, default none]\n"); printf("\t-v [set srslte_verbose to debug, default none]\n");
} }
void parse_extensive_param (char *param, char *arg) {
int ext_code = SRSLTE_SUCCESS;
if (!strcmp(param, "I_offset_cqi")) {
uci_cfg.I_offset_cqi = (uint32_t) atoi(arg);
if (uci_cfg.I_offset_cqi > 15) {
ext_code = SRSLTE_ERROR;
}
} else if (!strcmp(param, "I_offset_ri")) {
uci_cfg.I_offset_ri = (uint32_t) atoi(arg);
if (uci_cfg.I_offset_ri > 15) {
ext_code = SRSLTE_ERROR;
}
} else if (!strcmp(param, "I_offset_ack")) {
uci_cfg.I_offset_ack = (uint32_t) atoi(arg);
if (uci_cfg.I_offset_ack > 15) {
ext_code = SRSLTE_ERROR;
}
} else if (!strcmp(param, "uci_cqi")) {
if (!strcmp(arg, "wideband")) {
cqi_value.type = SRSLTE_CQI_TYPE_WIDEBAND;
cqi_value.wideband.wideband_cqi = (uint8_t) (rand() & 0x03);
uci_data_tx.uci_cqi_len = (uint32_t) srslte_cqi_value_unpack(uci_data_tx.uci_cqi, &cqi_value);
} else {
ext_code = SRSLTE_ERROR;
}
} else if (!strcmp(param, "uci_cqi_len")) {
uci_data_tx.uci_cqi_len = (uint32_t) atol(arg);
if (uci_data_tx.uci_cqi_len >= SRSLTE_CQI_MAX_BITS) {
ext_code = SRSLTE_ERROR;
}
} else if (!strcmp(param, "uci_ri")) {
uci_data_tx.uci_ri = (uint8_t) atol(arg);
if (uci_data_tx.uci_ri > 1) {
ext_code = SRSLTE_ERROR;
} else {
uci_data_tx.uci_ri_len = 1;
}
} else if (!strcmp(param, "uci_ack")) {
uci_data_tx.uci_ack = (uint8_t) atol(arg);
if (uci_data_tx.uci_ack > 1) {
ext_code = SRSLTE_ERROR;
} else {
uci_data_tx.uci_ack_len++;
if (uci_data_tx.uci_ack_len > 2) {
uci_data_tx.uci_ack_len = 2;
}
}
} else if (!strcmp(param, "uci_ack_2")) {
uci_data_tx.uci_ack_2 = (uint8_t) atol(arg);
if (uci_data_tx.uci_ack_2 > 1) {
ext_code = SRSLTE_ERROR;
} else {
uci_data_tx.uci_ack_len++;
if (uci_data_tx.uci_ack_len > 2) {
uci_data_tx.uci_ack_len = 2;
}
}
} else {
ext_code = SRSLTE_ERROR;
}
if (ext_code) {
fprintf(stderr, "Error parsing parameter '%s' and argument '%s'\n", param, arg);
exit(ext_code);
}
}
void parse_args(int argc, char **argv) { void parse_args(int argc, char **argv) {
int opt; int opt;
while ((opt = getopt(argc, argv, "cnfvmtsrLNFR")) != -1) { while ((opt = getopt(argc, argv, "msLNRFrncpv")) != -1) {
switch(opt) { switch(opt) {
case 'm': case 'm':
mcs_idx = atoi(argv[optind]); mcs_idx = atoi(argv[optind]);
@ -99,6 +204,10 @@ void parse_args(int argc, char **argv) {
case 'c': case 'c':
cell.id = atoi(argv[optind]); cell.id = atoi(argv[optind]);
break; break;
case 'p':
parse_extensive_param(argv[optind], argv[optind + 1]);
optind++;
break;
case 'v': case 'v':
srslte_verbose++; srslte_verbose++;
break; break;
@ -125,6 +234,8 @@ int main(int argc, char **argv) {
bzero(&cfg, sizeof(srslte_pusch_cfg_t)); bzero(&cfg, sizeof(srslte_pusch_cfg_t));
srslte_dft_load();
srslte_ra_ul_dci_t dci; srslte_ra_ul_dci_t dci;
dci.freq_hop_fl = freq_hop; dci.freq_hop_fl = freq_hop;
if (riv < 0) { if (riv < 0) {
@ -165,13 +276,6 @@ int main(int argc, char **argv) {
/* Configure PUSCH */ /* Configure PUSCH */
printf("Encoding rv_idx=%d\n",rv_idx);
srslte_uci_cfg_t uci_cfg;
uci_cfg.I_offset_cqi = 6;
uci_cfg.I_offset_ri = 2;
uci_cfg.I_offset_ack = 4;
if (srslte_pusch_cfg(&pusch_tx, &cfg, &grant, &uci_cfg, &ul_hopping, NULL, subframe, 0, 0)) { if (srslte_pusch_cfg(&pusch_tx, &cfg, &grant, &uci_cfg, &ul_hopping, NULL, subframe, 0, 0)) {
fprintf(stderr, "Error configuring PDSCH\n"); fprintf(stderr, "Error configuring PDSCH\n");
exit(-1); exit(-1);
@ -185,21 +289,9 @@ int main(int argc, char **argv) {
srslte_pusch_set_rnti(&pusch_tx, rnti); srslte_pusch_set_rnti(&pusch_tx, rnti);
srslte_pusch_set_rnti(&pusch_rx, rnti); srslte_pusch_set_rnti(&pusch_rx, rnti);
srslte_uci_data_t uci_data_tx;
srslte_uci_data_t uci_data_rx; srslte_uci_data_t uci_data_rx;
bzero(&uci_data_tx, sizeof(srslte_uci_data_t));
uci_data_tx.uci_cqi_len = 4;
uci_data_tx.uci_ri_len = 0;
uci_data_tx.uci_ack_len = 1;
memcpy(&uci_data_rx, &uci_data_tx, sizeof(srslte_uci_data_t)); memcpy(&uci_data_rx, &uci_data_tx, sizeof(srslte_uci_data_t));
for (uint32_t i=0;i<uci_data_tx.uci_cqi_len;i++) {
uci_data_tx.uci_cqi [i] = 1;
}
uci_data_tx.uci_ri = 1;
uci_data_tx.uci_ack = 1;
uci_data_tx.uci_ack_2 = 1;
uint32_t nof_re = SRSLTE_NRE*cell.nof_prb*2*SRSLTE_CP_NSYMB(cell.cp); 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_malloc(sizeof(cf_t) * nof_re);
if (!sf_symbols) { if (!sf_symbols) {
@ -252,7 +344,16 @@ int main(int argc, char **argv) {
} }
gettimeofday(&t[1], NULL); gettimeofday(&t[1], NULL);
int r = srslte_pusch_decode(&pusch_rx, &cfg, &softbuffer_rx, sf_symbols, ce, 0, rnti, data, NULL, &uci_data_rx); int r = srslte_pusch_decode(&pusch_rx,
&cfg,
&softbuffer_rx,
sf_symbols,
ce,
0,
rnti,
data,
(uci_data_tx.uci_cqi_len) ? &cqi_value : NULL,
&uci_data_rx);
gettimeofday(&t[2], NULL); gettimeofday(&t[2], NULL);
get_time_interval(t); get_time_interval(t);
if (r) { if (r) {
@ -285,10 +386,13 @@ int main(int argc, char **argv) {
} }
} }
if (uci_data_tx.uci_cqi_len) { if (uci_data_tx.uci_cqi_len) {
printf("cqi_tx="); if (memcmp(uci_data_tx.uci_cqi, uci_data_rx.uci_cqi, uci_data_tx.uci_cqi_len)) {
srslte_vec_fprint_b(stdout, uci_data_tx.uci_cqi, uci_data_tx.uci_cqi_len); printf("cqi_tx=");
printf("cqi_rx="); srslte_vec_fprint_b(stdout, uci_data_tx.uci_cqi, uci_data_tx.uci_cqi_len);
srslte_vec_fprint_b(stdout, uci_data_rx.uci_cqi, uci_data_rx.uci_cqi_len); printf("cqi_rx=");
srslte_vec_fprint_b(stdout, uci_data_rx.uci_cqi, uci_data_rx.uci_cqi_len);
ret = SRSLTE_ERROR;
}
} }
quit: quit:

Loading…
Cancel
Save