From db4127ca647b01a80fe03e0ed12b93fcbf6d5600 Mon Sep 17 00:00:00 2001 From: Guillem Foreman Date: Thu, 27 Jun 2019 18:52:20 +0200 Subject: [PATCH] Fixes 256QAM, added pdsch table 2, fixed warnings --- lib/examples/pdsch_enodeb.c | 11 ++- lib/examples/pdsch_ue.c | 11 ++- lib/src/phy/modem/hard_demod_lte.c | 56 +++++++-------- lib/src/phy/modem/hard_demod_lte.h | 22 +++--- lib/src/phy/phch/ra.c | 32 --------- lib/src/phy/phch/test/pmch_file_test.c | 2 +- lib/src/phy/phch/test/pmch_test.c | 2 +- lib/test/phy/CMakeLists.txt | 33 ++++++--- lib/test/phy/phy_dl_test.c | 96 +++++++++++++++----------- srsenb/test/mac/scheduler_test_rand.cc | 12 ++-- 10 files changed, 142 insertions(+), 135 deletions(-) diff --git a/lib/examples/pdsch_enodeb.c b/lib/examples/pdsch_enodeb.c index 850c8f84b..8de64511f 100644 --- a/lib/examples/pdsch_enodeb.c +++ b/lib/examples/pdsch_enodeb.c @@ -79,6 +79,7 @@ int mbsfn_area_id = -1; char *rf_args = ""; char *rf_dev = ""; float rf_amp = 0.8, rf_gain = 60.0, rf_freq = 2400000000; +static bool enable_256qam = false; float output_file_snr = +INFINITY; @@ -145,13 +146,14 @@ void usage(char *prog) { printf("\t-u listen TCP/UDP port for input data (if mbsfn is active then the stream is over mbsfn only) (-1 is random) [Default %d]\n", net_port); printf("\t-v [set srslte_verbose to debug, default none]\n"); printf("\t-s output file SNR [Default %f]\n", output_file_snr); + printf("\t-q Enable/Disable 256QAM modulation (default %s)\n", enable_256qam ? "enabled" : "disabled"); printf("\n"); printf("\t*: See 3GPP 36.212 Table 5.3.3.1.5-4 for more information\n"); } void parse_args(int argc, char **argv) { int opt; - while ((opt = getopt(argc, argv, "IadglfmoncpvutxbwMsB")) != -1) { + while ((opt = getopt(argc, argv, "IadglfmoncpqvutxbwMsB")) != -1) { switch (opt) { case 'I': @@ -208,6 +210,9 @@ void parse_args(int argc, char **argv) { case 'B': mbsfn_sf_mask = atoi(argv[optind]); break; + case 'q': + enable_256qam ^= true; + break; default: usage(argv[0]); exit(-1); @@ -920,7 +925,7 @@ int main(int argc, char **argv) { } /* Configure pdsch_cfg parameters */ - if (srslte_ra_dl_dci_to_grant(&cell, &dl_sf, transmission_mode, &dci_dl, &pdsch_cfg.grant)) { + if (srslte_ra_dl_dci_to_grant(&cell, &dl_sf, transmission_mode, enable_256qam, &dci_dl, &pdsch_cfg.grant)) { ERROR("Error configuring PDSCH\n"); exit(-1); } @@ -955,7 +960,7 @@ int main(int argc, char **argv) { dci_dl.format = SRSLTE_DCI_FORMAT1; /* Configure pdsch_cfg parameters */ - if (srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, &dci_dl, &pmch_cfg.pdsch_cfg.grant)) { + if (srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, enable_256qam, &dci_dl, &pmch_cfg.pdsch_cfg.grant)) { ERROR("Error configuring PDSCH\n"); exit(-1); } diff --git a/lib/examples/pdsch_ue.c b/lib/examples/pdsch_ue.c index 241955da3..626a8885d 100644 --- a/lib/examples/pdsch_ue.c +++ b/lib/examples/pdsch_ue.c @@ -109,6 +109,7 @@ typedef struct { int tdd_special_sf; int sf_config; int verbose; + bool enable_256qam; }prog_args_t; void args_default(prog_args_t* args) @@ -134,6 +135,7 @@ void args_default(prog_args_t* args) args->rf_nof_rx_ant = 1; args->enable_cfo_ref = false; args->average_subframe = false; + args->enable_256qam = false; #ifdef ENABLE_AGC_DEFAULT args->rf_gain = -1.0; #else @@ -192,6 +194,7 @@ void usage(prog_args_t *args, char *prog) { printf("\t-U remote TCP address to send data [Default %s]\n", args->net_address); printf("\t-M MBSFN area id [Default %d]\n", args->mbsfn_area_id); printf("\t-N Non-MBSFN region [Default %d]\n", args->non_mbsfn_region); + printf("\t-q Enable/Disable 256QAM modulation (default %s)\n", args->enable_256qam ? "enabled" : "disabled"); printf("\t-v [set srslte_verbose to debug, default none]\n"); } @@ -199,7 +202,7 @@ void parse_args(prog_args_t *args, int argc, char **argv) { int opt; args_default(args); - while ((opt = getopt(argc, argv, "adAogliIpPcOCtdDFRnvrfuUsSZyWMNBTG")) != -1) { + while ((opt = getopt(argc, argv, "adAogliIpPcOCtdDFRqnvrfuUsSZyWMNBTG")) != -1) { switch (opt) { case 'i': args->input_file_name = argv[optind]; @@ -301,6 +304,9 @@ void parse_args(prog_args_t *args, int argc, char **argv) { case 'B': args->mbsfn_sf_mask = atoi(argv[optind]); break; + case 'q': + args->enable_256qam ^= true; + break; default: usage(args, argv[0]); exit(-1); @@ -393,7 +399,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) * 1500 * 8); + data[i] = srslte_vec_malloc(sizeof(uint8_t) * 2000 * 8); if (!data[i]) { ERROR("Allocating data"); go_exit = true; @@ -783,6 +789,7 @@ int main(int argc, char **argv) { dl_sf.tti = tti; dl_sf.sf_type = sf_type; ue_dl_cfg.cfg.tm = (srslte_tm_t)tm; + ue_dl_cfg.pdsch_use_tbs_index_alt = prog_args.enable_256qam; if ((ue_dl_cfg.cfg.tm == SRSLTE_TM1 && cell.nof_ports == 1) || (ue_dl_cfg.cfg.tm > SRSLTE_TM1 && cell.nof_ports > 1)) { diff --git a/lib/src/phy/modem/hard_demod_lte.c b/lib/src/phy/modem/hard_demod_lte.c index f62bd1400..dc07eed24 100644 --- a/lib/src/phy/modem/hard_demod_lte.c +++ b/lib/src/phy/modem/hard_demod_lte.c @@ -212,32 +212,32 @@ inline void hard_qam256_demod(const cf_t* in, uint8_t* out, uint32_t N) out[8 * s + 4] = 0x1; out[8 * s + 6] = 0x1; } else if ((__real__ in[s] > QAM256_THRESHOLD_6) || (__real__ in[s] < -QAM256_THRESHOLD_6)) { - out[6 * s + 2] = 0x1; - out[6 * s + 4] = 0x1; + out[8 * s + 2] = 0x1; + out[8 * s + 4] = 0x1; out[8 * s + 6] = 0x0; } else if ((__real__ in[s] > QAM256_THRESHOLD_5) || (__real__ in[s] < -QAM256_THRESHOLD_5)) { - out[6 * s + 2] = 0x1; - out[6 * s + 4] = 0x0; + out[8 * s + 2] = 0x1; + out[8 * s + 4] = 0x0; out[8 * s + 6] = 0x0; } else if ((__real__ in[s] > QAM256_THRESHOLD_4) || (__real__ in[s] < -QAM256_THRESHOLD_4)) { - out[6 * s + 2] = 0x1; - out[6 * s + 4] = 0x0; + out[8 * s + 2] = 0x1; + out[8 * s + 4] = 0x0; out[8 * s + 6] = 0x1; } else if ((__real__ in[s] > QAM256_THRESHOLD_3) || (__real__ in[s] < -QAM256_THRESHOLD_3)) { - out[6 * s + 2] = 0x0; - out[6 * s + 4] = 0x0; + out[8 * s + 2] = 0x0; + out[8 * s + 4] = 0x0; out[8 * s + 6] = 0x1; } else if ((__real__ in[s] > QAM256_THRESHOLD_2) || (__real__ in[s] < -QAM256_THRESHOLD_2)) { - out[6 * s + 2] = 0x0; - out[6 * s + 4] = 0x1; + out[8 * s + 2] = 0x0; + out[8 * s + 4] = 0x1; out[8 * s + 6] = 0x1; } else if ((__real__ in[s] > QAM256_THRESHOLD_1) || (__real__ in[s] < -QAM256_THRESHOLD_1)) { - out[6 * s + 2] = 0x0; - out[6 * s + 4] = 0x1; + out[8 * s + 2] = 0x0; + out[8 * s + 4] = 0x1; out[8 * s + 6] = 0x0; } else { - out[6 * s + 2] = 0x0; - out[6 * s + 4] = 0x0; + out[8 * s + 2] = 0x0; + out[8 * s + 4] = 0x0; out[8 * s + 6] = 0x0; } @@ -252,32 +252,32 @@ inline void hard_qam256_demod(const cf_t* in, uint8_t* out, uint32_t N) out[8 * s + 5] = 0x1; out[8 * s + 7] = 0x1; } else if ((__imag__ in[s] > QAM256_THRESHOLD_6) || (__imag__ in[s] < -QAM256_THRESHOLD_6)) { - out[6 * s + 3] = 0x1; - out[6 * s + 5] = 0x1; + out[8 * s + 3] = 0x1; + out[8 * s + 5] = 0x1; out[8 * s + 7] = 0x0; } else if ((__imag__ in[s] > QAM256_THRESHOLD_5) || (__imag__ in[s] < -QAM256_THRESHOLD_5)) { - out[6 * s + 3] = 0x1; - out[6 * s + 5] = 0x0; + out[8 * s + 3] = 0x1; + out[8 * s + 5] = 0x0; out[8 * s + 7] = 0x0; } else if ((__imag__ in[s] > QAM256_THRESHOLD_4) || (__imag__ in[s] < -QAM256_THRESHOLD_4)) { - out[6 * s + 3] = 0x1; - out[6 * s + 5] = 0x0; + out[8 * s + 3] = 0x1; + out[8 * s + 5] = 0x0; out[8 * s + 7] = 0x1; } else if ((__imag__ in[s] > QAM256_THRESHOLD_3) || (__imag__ in[s] < -QAM256_THRESHOLD_3)) { - out[6 * s + 3] = 0x0; - out[6 * s + 5] = 0x0; + out[8 * s + 3] = 0x0; + out[8 * s + 5] = 0x0; out[8 * s + 7] = 0x1; } else if ((__imag__ in[s] > QAM256_THRESHOLD_2) || (__imag__ in[s] < -QAM256_THRESHOLD_2)) { - out[6 * s + 3] = 0x0; - out[6 * s + 5] = 0x1; + out[8 * s + 3] = 0x0; + out[8 * s + 5] = 0x1; out[8 * s + 7] = 0x1; } else if ((__imag__ in[s] > QAM256_THRESHOLD_1) || (__imag__ in[s] < -QAM256_THRESHOLD_1)) { - out[6 * s + 3] = 0x0; - out[6 * s + 5] = 0x1; + out[8 * s + 3] = 0x0; + out[8 * s + 5] = 0x1; out[8 * s + 7] = 0x0; } else { - out[6 * s + 3] = 0x0; - out[6 * s + 5] = 0x0; + out[8 * s + 3] = 0x0; + out[8 * s + 5] = 0x0; out[8 * s + 7] = 0x0; } } diff --git a/lib/src/phy/modem/hard_demod_lte.h b/lib/src/phy/modem/hard_demod_lte.h index 0c6585bf8..e49f1ec30 100644 --- a/lib/src/phy/modem/hard_demod_lte.h +++ b/lib/src/phy/modem/hard_demod_lte.h @@ -23,17 +23,17 @@ /* Assume perfect amplitude and phase alignment. * Check threshold values for real case * or implement dynamic threshold adjustent as a function of received symbol amplitudes */ -#define QAM16_THRESHOLD 2/sqrt(10) -#define QAM64_THRESHOLD_1 2/sqrt(42) -#define QAM64_THRESHOLD_2 4/sqrt(42) -#define QAM64_THRESHOLD_3 6/sqrt(42) -#define QAM256_THRESHOLD_1 2 / sqrt(170) -#define QAM256_THRESHOLD_2 4 / sqrt(170) -#define QAM256_THRESHOLD_3 6 / sqrt(170) -#define QAM256_THRESHOLD_4 8 / sqrt(170) -#define QAM256_THRESHOLD_5 10 / sqrt(170) -#define QAM256_THRESHOLD_6 12 / sqrt(170) -#define QAM256_THRESHOLD_7 14 / sqrt(170) +#define QAM16_THRESHOLD (2 / sqrtf(10)) +#define QAM64_THRESHOLD_1 (2 / sqrtf(42)) +#define QAM64_THRESHOLD_2 (4 / sqrtf(42)) +#define QAM64_THRESHOLD_3 (6 / sqrtf(42)) +#define QAM256_THRESHOLD_1 (2 / sqrtf(170)) +#define QAM256_THRESHOLD_2 (4 / sqrtf(170)) +#define QAM256_THRESHOLD_3 (6 / sqrtf(170)) +#define QAM256_THRESHOLD_4 (8 / sqrtf(170)) +#define QAM256_THRESHOLD_5 (10 / sqrtf(170)) +#define QAM256_THRESHOLD_6 (12 / sqrtf(170)) +#define QAM256_THRESHOLD_7 (14 / sqrtf(170)) void hard_bpsk_demod(const cf_t* in, uint8_t* out, diff --git a/lib/src/phy/phch/ra.c b/lib/src/phy/phch/ra.c index 353d9fdea..ecd038b28 100644 --- a/lib/src/phy/phch/ra.c +++ b/lib/src/phy/phch/ra.c @@ -129,15 +129,6 @@ static int srslte_ra_dl_tbs_idx_from_mcs(uint32_t mcs) } } -static int srslte_ra_dl_tbs_idx_from_mcs2(uint32_t mcs) -{ - if (mcs < 28) { - return dl_mcs_tbs_idx_table2[mcs]; - } else { - return SRSLTE_ERROR; - } -} - static int srslte_ra_ul_tbs_idx_from_mcs(uint32_t mcs) { if (mcs < 29) { @@ -163,19 +154,6 @@ srslte_mod_t srslte_ra_dl_mod_from_mcs(uint32_t mcs) } } -srslte_mod_t srslte_ra_dl_mod_from_mcs2(uint32_t mcs) -{ - if (mcs <= 4 || mcs == 28) { - return SRSLTE_MOD_QPSK; - } else if (mcs <= 10 || mcs == 29) { - return SRSLTE_MOD_16QAM; - } else if (mcs <= 19 || mcs == 30) { - return SRSLTE_MOD_64QAM; - } else { - return SRSLTE_MOD_256QAM; - } -} - srslte_mod_t srslte_ra_ul_mod_from_mcs(uint32_t mcs) { /* Table 8.6.1-1 on 36.213 */ @@ -200,16 +178,6 @@ static int srslte_ra_dl_mcs_from_tbs_idx(uint32_t tbs_idx) return SRSLTE_ERROR; } -static int srslte_ra_dl_mcs_from_tbs_idx2(uint32_t tbs_idx) -{ - for (int i = 0; i < 28; i++) { - if (tbs_idx == dl_mcs_tbs_idx_table2[i]) { - return i; - } - } - return SRSLTE_ERROR; -} - static int srslte_ra_ul_mcs_from_tbs_idx(uint32_t tbs_idx) { for (int i = 0; i < 29; i++) { diff --git a/lib/src/phy/phch/test/pmch_file_test.c b/lib/src/phy/phch/test/pmch_file_test.c index 16d38f202..a4079868f 100644 --- a/lib/src/phy/phch/test/pmch_file_test.c +++ b/lib/src/phy/phch/test/pmch_file_test.c @@ -210,7 +210,7 @@ int main(int argc, char **argv) { dci.type0_alloc.rbg_bitmask = 0xffffffff; dci.tb[0].mcs_idx = 2; SRSLTE_DCI_TB_DISABLE(dci.tb[1]); - srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, &dci, &pmch_cfg.pdsch_cfg.grant); + srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, false, &dci, &pmch_cfg.pdsch_cfg.grant); srslte_pdsch_res_t pdsch_res; pdsch_res.payload = data; diff --git a/lib/src/phy/phch/test/pmch_test.c b/lib/src/phy/phch/test/pmch_test.c index 57412f700..28499b79c 100644 --- a/lib/src/phy/phch/test/pmch_test.c +++ b/lib/src/phy/phch/test/pmch_test.c @@ -246,7 +246,7 @@ int main(int argc, char **argv) { dci.type0_alloc.rbg_bitmask = 0xffffffff; dci.tb[0].mcs_idx = mcs_idx; SRSLTE_DCI_TB_DISABLE(dci.tb[1]); - srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, &dci, &pmch_cfg.pdsch_cfg.grant); + srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, false, &dci, &pmch_cfg.pdsch_cfg.grant); for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { if (pmch_cfg.pdsch_cfg.grant.tb[i].enabled) { diff --git a/lib/test/phy/CMakeLists.txt b/lib/test/phy/CMakeLists.txt index 900b290cd..37b5431ef 100644 --- a/lib/test/phy/CMakeLists.txt +++ b/lib/test/phy/CMakeLists.txt @@ -31,17 +31,30 @@ set(ue_dl_max_mcs 28) set(ue_dl_step_mcs 7) foreach (cell_n_prb 6 15 25 50 75 100) - foreach (ue_dl_tm 1 2 3 4) - foreach (ue_dl_mcs RANGE ${ue_dl_min_mcs} ${ue_dl_max_mcs} ${ue_dl_step_mcs}) - set(phy_dl_test_args "") + foreach (allow_256 0 1) + foreach (ue_dl_tm 1 2 3 4) + foreach (ue_dl_mcs RANGE ${ue_dl_min_mcs} ${ue_dl_max_mcs} ${ue_dl_step_mcs}) + set(phy_dl_test_args "") - set(phy_dl_test_args ${phy_dl_test_args} -p ${cell_n_prb}) - set(phy_dl_test_args ${phy_dl_test_args} -t ${ue_dl_tm}) - set(phy_dl_test_args ${phy_dl_test_args} -m ${ue_dl_mcs}) + set(phy_dl_test_args ${phy_dl_test_args} -p ${cell_n_prb}) + set(phy_dl_test_args ${phy_dl_test_args} -t ${ue_dl_tm}) + if (${allow_256}) + if (${ue_dl_mcs} EQUAL 28) + if (${cell_n_prb} EQUAL 15) + set(ue_dl_mcs 26) + else (${cell_n_prb} EQUAL 15) + set(ue_dl_mcs 27) + endif (${cell_n_prb} EQUAL 15) + endif (${ue_dl_mcs} EQUAL 28) - string(REGEX REPLACE "\ " "" test_name_args ${phy_dl_test_args}) + set(phy_dl_test_args ${phy_dl_test_args} -q) + endif (${allow_256}) + set(phy_dl_test_args ${phy_dl_test_args} -m ${ue_dl_mcs}) - add_test(phy_dl_test${test_name_args} phy_dl_test ${phy_dl_test_args}) - endforeach (ue_dl_mcs) - endforeach(ue_dl_tm) + string(REGEX REPLACE "\ " "" test_name_args ${phy_dl_test_args}) + message(${phy_dl_test_args}) + add_test(phy_dl_test${test_name_args} phy_dl_test ${phy_dl_test_args}) + endforeach (ue_dl_mcs) + endforeach (ue_dl_tm) + endforeach (allow_256 0 1) endforeach (cell_n_prb) diff --git a/lib/test/phy/phy_dl_test.c b/lib/test/phy/phy_dl_test.c index 7f1c224f4..ae8cf46a7 100644 --- a/lib/test/phy/phy_dl_test.c +++ b/lib/test/phy/phy_dl_test.c @@ -37,14 +37,15 @@ srslte_cell_t cell = { .phich_length = SRSLTE_PHICH_NORM }; -uint32_t transmission_mode = 1; -uint32_t cfi = 1; -uint32_t nof_rx_ant = 1; -uint32_t nof_subframes = 0; -uint16_t rnti = 0x1234; -bool print_dci_table; -uint32_t mcs = 20; -int cross_carrier_indicator = -1; +static uint32_t transmission_mode = 1; +static uint32_t cfi = 1; +static uint32_t nof_rx_ant = 1; +static uint32_t nof_subframes = 0; +static uint16_t rnti = 0x1234; +static bool print_dci_table; +static uint32_t mcs = 20; +static int cross_carrier_indicator = -1; +static bool enable_256qam = false; void usage(char *prog) { printf("Usage: %s [cfpndvs]\n", prog); @@ -62,6 +63,7 @@ void usage(char *prog) { printf("\t\t-a carrier-indicator [Default none]\n"); } printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-q Enable/Disable 256QAM modulation (default %s)\n", enable_256qam ? "enabled" : "disabled"); } void parse_extensive_param(char* param, char* arg) @@ -81,7 +83,17 @@ void parse_extensive_param(char* param, char* arg) void parse_args(int argc, char **argv) { int opt; - while ((opt = getopt(argc, argv, "cfapndvstm")) != -1) { + + // Load default transmission mode to avoid wrong number of ports/antennas + if (transmission_mode == 0) { + cell.nof_ports = 1; + nof_rx_ant = 1; + } else if (transmission_mode < 4) { + cell.nof_ports = 2; + nof_rx_ant = 2; + } + + while ((opt = getopt(argc, argv, "cfapndvqstm")) != -1) { switch (opt) { case 't': transmission_mode = (uint32_t)strtol(argv[optind], NULL, 10) - 1; @@ -118,6 +130,9 @@ void parse_args(int argc, char **argv) { case 'v': srslte_verbose++; break; + case 'q': + enable_256qam ^= true; + break; default: usage(argv[0]); exit(-1); @@ -145,7 +160,7 @@ int work_enb(srslte_enb_dl_t* enb_dl, // Create pdsch config srslte_pdsch_cfg_t pdsch_cfg; - if (srslte_ra_dl_dci_to_grant(&cell, dl_sf, transmission_mode, dci, &pdsch_cfg.grant)) { + if (srslte_ra_dl_dci_to_grant(&cell, dl_sf, transmission_mode, enable_256qam, dci, &pdsch_cfg.grant)) { ERROR("Computing DL grant sf_idx=%d\n", dl_sf->tti); goto quit; } @@ -211,7 +226,8 @@ int work_ue(srslte_ue_dl_t* ue_dl, srslte_dci_dl_info(&dci_dl[0], str, 512); INFO("UE PDCCH: rnti=0x%x, %s\n", rnti, str); - if (srslte_ra_dl_dci_to_grant(&cell, sf_cfg_dl, transmission_mode, &dci_dl[0], &ue_dl_cfg->cfg.pdsch.grant)) { + if (srslte_ra_dl_dci_to_grant( + &cell, sf_cfg_dl, transmission_mode, enable_256qam, &dci_dl[0], &ue_dl_cfg->cfg.pdsch.grant)) { ERROR("Computing DL grant sf_idx=%d\n", sf_idx); return -1; } @@ -255,10 +271,8 @@ uint32_t prbset_to_bitmask() { return reverse(mask) >> (32 - nb); } -static srslte_enb_dl_t enb_dl; -static srslte_ue_dl_t ue_dl; - -static int check_softbits(srslte_ue_dl_cfg_t* ue_dl_cfg, uint32_t sf_idx, int tb) +static int +check_softbits(srslte_enb_dl_t enb_dl, srslte_ue_dl_t ue_dl, srslte_ue_dl_cfg_t* ue_dl_cfg, uint32_t sf_idx, int tb) { int ret = SRSLTE_SUCCESS; @@ -292,11 +306,12 @@ static int check_softbits(srslte_ue_dl_cfg_t* ue_dl_cfg, uint32_t sf_idx, int tb return ret; } -static int check_evm(srslte_ue_dl_cfg_t* ue_dl_cfg, int tb) +static int check_evm(srslte_enb_dl_t enb_dl, srslte_ue_dl_t ue_dl, srslte_ue_dl_cfg_t* ue_dl_cfg, int tb) { int ret = SRSLTE_SUCCESS; srslte_vec_sub_ccc(enb_dl.pdsch.d[tb], ue_dl.pdsch.d[tb], enb_dl.pdsch.d[tb], ue_dl_cfg->cfg.pdsch.grant.nof_re); - float evm = srslte_vec_avg_power_cf(enb_dl.pdsch.d[tb], ue_dl_cfg->cfg.pdsch.grant.nof_re); + uint32_t evm_max_i = srslte_vec_max_abs_ci(enb_dl.pdsch.d[tb], ue_dl_cfg->cfg.pdsch.grant.nof_re); + float evm = cabsf(enb_dl.pdsch.d[tb][evm_max_i]); if (evm > 0.1f) { printf("TB%d Constellation EVM (%.3f) is too high\n", tb, evm); @@ -307,6 +322,8 @@ static int check_evm(srslte_ue_dl_cfg_t* ue_dl_cfg, int tb) } int main(int argc, char **argv) { + srslte_enb_dl_t* enb_dl = srslte_vec_malloc(sizeof(srslte_enb_dl_t)); + srslte_ue_dl_t* ue_dl = srslte_vec_malloc(sizeof(srslte_ue_dl_t)); srslte_random_t random = srslte_random_init(0); struct timeval t[3] = {}; size_t tx_nof_bits = 0, rx_nof_bits = 0; @@ -374,17 +391,17 @@ int main(int argc, char **argv) { /* * Initialise eNb */ - if (srslte_enb_dl_init(&enb_dl, signal_buffer, cell.nof_prb)) { + if (srslte_enb_dl_init(enb_dl, signal_buffer, cell.nof_prb)) { ERROR("Error initiating eNb downlink\n"); goto quit; } - if (srslte_enb_dl_set_cell(&enb_dl, cell)) { + if (srslte_enb_dl_set_cell(enb_dl, cell)) { ERROR("Error setting eNb DL cell\n"); goto quit; } - if (srslte_enb_dl_add_rnti(&enb_dl, rnti)) { + if (srslte_enb_dl_add_rnti(enb_dl, rnti)) { ERROR("Error adding RNTI\n"); goto quit; } @@ -392,17 +409,17 @@ int main(int argc, char **argv) { /* * Initialise UE */ - if (srslte_ue_dl_init(&ue_dl, signal_buffer, cell.nof_prb, nof_rx_ant)) { + if (srslte_ue_dl_init(ue_dl, signal_buffer, cell.nof_prb, nof_rx_ant)) { ERROR("Error initiating UE downlink\n"); goto quit; } - if (srslte_ue_dl_set_cell(&ue_dl, cell)) { + if (srslte_ue_dl_set_cell(ue_dl, cell)) { ERROR("Error setting UE downlink cell\n"); goto quit; } - srslte_ue_dl_set_rnti(&ue_dl, rnti); + srslte_ue_dl_set_rnti(ue_dl, rnti); /* * Create PDCCH Allocations @@ -417,7 +434,7 @@ int main(int argc, char **argv) { sf_cfg_dl.cfi = cfi; sf_cfg_dl.sf_type = SRSLTE_SF_NORM; - nof_locations[i] = srslte_pdcch_ue_locations(&enb_dl.pdcch, &sf_cfg_dl, dci_locations[i], MAX_CANDIDATES_UE, rnti); + nof_locations[i] = srslte_pdcch_ue_locations(&enb_dl->pdcch, &sf_cfg_dl, dci_locations[i], MAX_CANDIDATES_UE, rnti); location_counter += nof_locations[i]; } @@ -529,7 +546,7 @@ int main(int argc, char **argv) { INFO("--- Process eNb ---\n"); gettimeofday(&t[1], NULL); - if (work_enb(&enb_dl, &sf_cfg_dl, &dci_cfg, &dci, softbuffer_tx, data_tx)) { + if (work_enb(enb_dl, &sf_cfg_dl, &dci_cfg, &dci, softbuffer_tx, data_tx)) { goto quit; } gettimeofday(&t[2], NULL); @@ -576,6 +593,7 @@ int main(int argc, char **argv) { ue_dl_cfg.chest_cfg.cfo_estimate_sf_mask = false; ue_dl_cfg.chest_cfg.sync_error_enable = false; ue_dl_cfg.dci_cfg = dci_cfg; + ue_dl_cfg.pdsch_use_tbs_index_alt = enable_256qam; srslte_pdsch_res_t pdsch_res[SRSLTE_MAX_CODEWORDS]; for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { @@ -584,7 +602,7 @@ int main(int argc, char **argv) { pdsch_res[i].crc = false; ue_dl_cfg.cfg.pdsch.softbuffers.rx[i] = softbuffer_rx[i]; } - if (work_ue(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, dci_dl, sf_idx, pdsch_res)) { + if (work_ue(ue_dl, &sf_cfg_dl, &ue_dl_cfg, dci_dl, sf_idx, pdsch_res)) { goto quit; } @@ -594,15 +612,15 @@ int main(int argc, char **argv) { for (int i = 0; i < SRSLTE_MAX_TB; i++) { if (ue_dl_cfg.cfg.pdsch.grant.tb[i].enabled) { - if (check_evm(&ue_dl_cfg, i)) { + if (check_evm(*enb_dl, *ue_dl, &ue_dl_cfg, i)) { count_failures++; - } else if (check_softbits(&ue_dl_cfg, sf_idx, i) != SRSLTE_SUCCESS) { + } else if (check_softbits(*enb_dl, *ue_dl, &ue_dl_cfg, sf_idx, i) != SRSLTE_SUCCESS) { printf("TB%d: The received softbits in subframe %d DO NOT match the encoded bits (crc=%d)\n", i, sf_idx, pdsch_res[i].crc); - srslte_vec_fprint_byte(stdout, (uint8_t*)enb_dl.pdsch.e[i], ue_dl_cfg.cfg.pdsch.grant.tb[i].nof_bits / 8); - srslte_vec_fprint_byte(stdout, (uint8_t*)ue_dl.pdsch.e[i], ue_dl_cfg.cfg.pdsch.grant.tb[i].nof_bits / 8); + srslte_vec_fprint_byte(stdout, (uint8_t*)enb_dl->pdsch.e[i], ue_dl_cfg.cfg.pdsch.grant.tb[i].nof_bits / 8); + srslte_vec_fprint_byte(stdout, (uint8_t*)ue_dl->pdsch.e[i], ue_dl_cfg.cfg.pdsch.grant.tb[i].nof_bits / 8); count_failures++; } else if (!pdsch_res[i].crc || memcmp(data_tx[i], data_rx[i], (uint32_t)ue_dl_cfg.cfg.pdsch.grant.tb[i].tbs / 8) != 0) { @@ -637,18 +655,14 @@ int main(int argc, char **argv) { printf("BLER: %5.1f%%\n", (float) count_failures / (float) count_tbs * 100.0f); quit: - srslte_enb_dl_free(&enb_dl); - srslte_ue_dl_free(&ue_dl); - srslte_random_free(random); + srslte_enb_dl_free(enb_dl); + srslte_ue_dl_free(ue_dl); + srslte_random_free(random); - for ( - int i = 0; - i < cell. - nof_ports; - i++) { - if (signal_buffer[i]) { - free(signal_buffer[i]); - } + for (int i = 0; i < cell.nof_ports; i++) { + if (signal_buffer[i]) { + free(signal_buffer[i]); + } } for ( diff --git a/srsenb/test/mac/scheduler_test_rand.cc b/srsenb/test/mac/scheduler_test_rand.cc index 7a458ba7e..5f498e30d 100644 --- a/srsenb/test/mac/scheduler_test_rand.cc +++ b/srsenb/test/mac/scheduler_test_rand.cc @@ -772,8 +772,8 @@ void sched_tester::test_collisions() for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_data_elems; ++i) { alloc_mask.reset(); srslte_pdsch_grant_t grant; - CondError(srslte_ra_dl_dci_to_grant(&cfg.cell, &dl_sf, SRSLTE_TM1, &tti_data.sched_result_dl.data[i].dci, &grant) == - SRSLTE_ERROR, + CondError(srslte_ra_dl_dci_to_grant( + &cfg.cell, &dl_sf, SRSLTE_TM1, false, &tti_data.sched_result_dl.data[i].dci, &grant) == SRSLTE_ERROR, "Failed to decode PDSCH grant\n"); for (uint32_t i = 0; i < alloc_mask.size(); ++i) { if (grant.prb_idx[0][i]) { @@ -792,8 +792,8 @@ void sched_tester::test_collisions() } for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_bc_elems; ++i) { srslte_pdsch_grant_t grant; - CondError(srslte_ra_dl_dci_to_grant(&cfg.cell, &dl_sf, SRSLTE_TM1, &tti_data.sched_result_dl.bc[i].dci, &grant) == - SRSLTE_ERROR, + CondError(srslte_ra_dl_dci_to_grant( + &cfg.cell, &dl_sf, SRSLTE_TM1, false, &tti_data.sched_result_dl.bc[i].dci, &grant) == SRSLTE_ERROR, "Failed to decode PDSCH grant\n"); alloc_mask.reset(); for (uint32_t i = 0; i < alloc_mask.size(); ++i) { @@ -811,8 +811,8 @@ void sched_tester::test_collisions() for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_rar_elems; ++i) { alloc_mask.reset(); srslte_pdsch_grant_t grant; - CondError(srslte_ra_dl_dci_to_grant(&cfg.cell, &dl_sf, SRSLTE_TM1, &tti_data.sched_result_dl.rar[i].dci, &grant) == - SRSLTE_ERROR, + CondError(srslte_ra_dl_dci_to_grant( + &cfg.cell, &dl_sf, SRSLTE_TM1, false, &tti_data.sched_result_dl.rar[i].dci, &grant) == SRSLTE_ERROR, "Failed to decode PDSCH grant\n"); for (uint32_t i = 0; i < alloc_mask.size(); ++i) { if (grant.prb_idx[0][i]) {