Commit cda82edf authored by francescomani's avatar francescomani

adapt LLR unit test to a generic UL/DL scenario

parent 98a8e5dc
...@@ -25,20 +25,9 @@ ...@@ -25,20 +25,9 @@
#include <algorithm> #include <algorithm>
#include <numeric> #include <numeric>
extern "C" { extern "C" {
void nr_ulsch_16qam_llr(int32_t *rxdataF_comp, int32_t *ul_ch_mag, int16_t *ulsch_llr, uint32_t nb_re, uint8_t symbol); void nr_16qam_llr(int32_t *rxdataF_comp, int32_t *ch_mag_in, int16_t *llr, uint32_t nb_re);
void nr_ulsch_64qam_llr(int32_t *rxdataF_comp, void nr_64qam_llr(int32_t *rxdataF_comp, int32_t *ch_mag, int32_t *ch_mag2, int16_t *llr, uint32_t nb_re);
int32_t *ul_ch_mag, void nr_256qam_llr(int32_t *rxdataF_comp, int32_t *ch_mag, int32_t *ch_mag2, int32_t *ch_mag3, int16_t *llr, uint32_t nb_re);
int32_t *ul_ch_magb,
int16_t *ulsch_llr,
uint32_t nb_re,
uint8_t symbol);
void nr_ulsch_256qam_llr(int32_t *rxdataF_comp,
int32_t *ul_ch_mag,
int32_t *ul_ch_magb,
int32_t *ul_ch_magc,
int16_t *ulsch_llr,
uint32_t nb_re,
uint8_t symbol);
struct configmodule_interface_s; struct configmodule_interface_s;
struct configmodule_interface_s *uniqCfg = NULL; struct configmodule_interface_s *uniqCfg = NULL;
...@@ -72,74 +61,72 @@ int16_t saturating_sub(int16_t a, int16_t b) ...@@ -72,74 +61,72 @@ int16_t saturating_sub(int16_t a, int16_t b)
} }
} }
void nr_ulsch_16qam_llr_ref(c16_t *rxdataF_comp, int32_t *ul_ch_mag, int16_t *ulsch_llr, uint32_t nb_re, uint8_t symbol) void nr_16qam_llr_ref(c16_t *rxdataF_comp, int32_t *ch_mag, int16_t *llr, uint32_t nb_re)
{ {
int16_t *ul_ch_mag_i16 = (int16_t *)ul_ch_mag; int16_t *ch_mag_i16 = (int16_t *)ch_mag;
for (auto i = 0U; i < nb_re; i++) { for (auto i = 0U; i < nb_re; i++) {
int16_t real = rxdataF_comp[i].r; int16_t real = rxdataF_comp[i].r;
int16_t imag = rxdataF_comp[i].i; int16_t imag = rxdataF_comp[i].i;
int16_t mag_real = ul_ch_mag_i16[2 * i]; int16_t mag_real = ch_mag_i16[2 * i];
int16_t mag_imag = ul_ch_mag_i16[2 * i + 1]; int16_t mag_imag = ch_mag_i16[2 * i + 1];
ulsch_llr[4 * i] = real; llr[4 * i] = real;
ulsch_llr[4 * i + 1] = imag; llr[4 * i + 1] = imag;
ulsch_llr[4 * i + 2] = saturating_sub(mag_real, std::abs(real)); llr[4 * i + 2] = saturating_sub(mag_real, std::abs(real));
ulsch_llr[4 * i + 3] = saturating_sub(mag_imag, std::abs(imag)); llr[4 * i + 3] = saturating_sub(mag_imag, std::abs(imag));
} }
} }
void nr_ulsch_64qam_llr_ref(c16_t *rxdataF_comp, void nr_64qam_llr_ref(c16_t *rxdataF_comp,
int32_t *ul_ch_mag, int32_t *ch_mag,
int32_t *ul_ch_magb, int32_t *ch_magb,
int16_t *ulsch_llr, int16_t *llr,
uint32_t nb_re, uint32_t nb_re)
uint8_t symbol)
{ {
int16_t *ul_ch_mag_i16 = (int16_t *)ul_ch_mag; int16_t *ch_mag_i16 = (int16_t *)ch_mag;
int16_t *ul_ch_magb_i16 = (int16_t *)ul_ch_magb; int16_t *ch_magb_i16 = (int16_t *)ch_magb;
for (auto i = 0U; i < nb_re; i++) { for (auto i = 0U; i < nb_re; i++) {
int16_t real = rxdataF_comp[i].r; int16_t real = rxdataF_comp[i].r;
int16_t imag = rxdataF_comp[i].i; int16_t imag = rxdataF_comp[i].i;
int16_t mag_real = ul_ch_mag_i16[2 * i]; int16_t mag_real = ch_mag_i16[2 * i];
int16_t mag_imag = ul_ch_mag_i16[2 * i + 1]; int16_t mag_imag = ch_mag_i16[2 * i + 1];
ulsch_llr[6 * i] = real; llr[6 * i] = real;
ulsch_llr[6 * i + 1] = imag; llr[6 * i + 1] = imag;
ulsch_llr[6 * i + 2] = saturating_sub(mag_real, std::abs(real)); llr[6 * i + 2] = saturating_sub(mag_real, std::abs(real));
ulsch_llr[6 * i + 3] = saturating_sub(mag_imag, std::abs(imag)); llr[6 * i + 3] = saturating_sub(mag_imag, std::abs(imag));
int16_t mag_realb = ul_ch_magb_i16[2 * i]; int16_t mag_realb = ch_magb_i16[2 * i];
int16_t mag_imagb = ul_ch_magb_i16[2 * i + 1]; int16_t mag_imagb = ch_magb_i16[2 * i + 1];
ulsch_llr[6 * i + 4] = saturating_sub(mag_realb, std::abs(ulsch_llr[6 * i + 2])); llr[6 * i + 4] = saturating_sub(mag_realb, std::abs(llr[6 * i + 2]));
ulsch_llr[6 * i + 5] = saturating_sub(mag_imagb, std::abs(ulsch_llr[6 * i + 3])); llr[6 * i + 5] = saturating_sub(mag_imagb, std::abs(llr[6 * i + 3]));
} }
} }
void nr_ulsch_256qam_llr_ref(c16_t *rxdataF_comp, void nr_256qam_llr_ref(c16_t *rxdataF_comp,
int32_t *ul_ch_mag, int32_t *ch_mag,
int32_t *ul_ch_magb, int32_t *ch_magb,
int32_t *ul_ch_magc, int32_t *ch_magc,
int16_t *ulsch_llr, int16_t *llr,
uint32_t nb_re, uint32_t nb_re)
uint8_t symbol)
{ {
int16_t *ul_ch_mag_i16 = (int16_t *)ul_ch_mag; int16_t *ch_mag_i16 = (int16_t *)ch_mag;
int16_t *ul_ch_magb_i16 = (int16_t *)ul_ch_magb; int16_t *ch_magb_i16 = (int16_t *)ch_magb;
int16_t *ul_ch_magc_i16 = (int16_t *)ul_ch_magc; int16_t *ch_magc_i16 = (int16_t *)ch_magc;
for (auto i = 0U; i < nb_re; i++) { for (auto i = 0U; i < nb_re; i++) {
int16_t real = rxdataF_comp[i].r; int16_t real = rxdataF_comp[i].r;
int16_t imag = rxdataF_comp[i].i; int16_t imag = rxdataF_comp[i].i;
int16_t mag_real = ul_ch_mag_i16[2 * i]; int16_t mag_real = ch_mag_i16[2 * i];
int16_t mag_imag = ul_ch_mag_i16[2 * i + 1]; int16_t mag_imag = ch_mag_i16[2 * i + 1];
ulsch_llr[8 * i] = real; llr[8 * i] = real;
ulsch_llr[8 * i + 1] = imag; llr[8 * i + 1] = imag;
ulsch_llr[8 * i + 2] = saturating_sub(mag_real, std::abs(real)); llr[8 * i + 2] = saturating_sub(mag_real, std::abs(real));
ulsch_llr[8 * i + 3] = saturating_sub(mag_imag, std::abs(imag)); llr[8 * i + 3] = saturating_sub(mag_imag, std::abs(imag));
int16_t magb_real = ul_ch_magb_i16[2 * i]; int16_t magb_real = ch_magb_i16[2 * i];
int16_t magb_imag = ul_ch_magb_i16[2 * i + 1]; int16_t magb_imag = ch_magb_i16[2 * i + 1];
ulsch_llr[8 * i + 4] = saturating_sub(magb_real, std::abs(ulsch_llr[8 * i + 2])); llr[8 * i + 4] = saturating_sub(magb_real, std::abs(llr[8 * i + 2]));
ulsch_llr[8 * i + 5] = saturating_sub(magb_imag, std::abs(ulsch_llr[8 * i + 3])); llr[8 * i + 5] = saturating_sub(magb_imag, std::abs(llr[8 * i + 3]));
int16_t magc_real = ul_ch_magc_i16[2 * i]; int16_t magc_real = ch_magc_i16[2 * i];
int16_t magc_imag = ul_ch_magc_i16[2 * i + 1]; int16_t magc_imag = ch_magc_i16[2 * i + 1];
ulsch_llr[8 * i + 6] = saturating_sub(magc_real, std::abs(ulsch_llr[8 * i + 4])); llr[8 * i + 6] = saturating_sub(magc_real, std::abs(llr[8 * i + 4]));
ulsch_llr[8 * i + 7] = saturating_sub(magc_imag, std::abs(ulsch_llr[8 * i + 5])); llr[8 * i + 7] = saturating_sub(magc_imag, std::abs(llr[8 * i + 5]));
} }
} }
...@@ -149,21 +136,21 @@ void test_function_16_qam(AlignedVector512<uint32_t> nb_res) ...@@ -149,21 +136,21 @@ void test_function_16_qam(AlignedVector512<uint32_t> nb_res)
uint32_t nb_re = nb_res[i]; uint32_t nb_re = nb_res[i];
auto rf_data = generate_random_c16(nb_re); auto rf_data = generate_random_c16(nb_re);
auto magnitude_data = generate_random_uint16(nb_re * 2); auto magnitude_data = generate_random_uint16(nb_re * 2);
AlignedVector512<uint64_t> ulsch_llr_ref; AlignedVector512<uint64_t> llr_ref;
ulsch_llr_ref.resize(nb_re); llr_ref.resize(nb_re);
std::fill(ulsch_llr_ref.begin(), ulsch_llr_ref.end(), 0); std::fill(llr_ref.begin(), llr_ref.end(), 0);
nr_ulsch_16qam_llr_ref((c16_t *)rf_data.data(), (int32_t *)magnitude_data.data(), (int16_t *)ulsch_llr_ref.data(), nb_re, 0); nr_16qam_llr_ref((c16_t *)rf_data.data(), (int32_t *)magnitude_data.data(), (int16_t *)llr_ref.data(), nb_re);
AlignedVector512<uint64_t> ulsch_llr; AlignedVector512<uint64_t> llr;
ulsch_llr.resize(nb_re); llr.resize(nb_re);
std::fill(ulsch_llr.begin(), ulsch_llr.end(), 0); std::fill(llr.begin(), llr.end(), 0);
nr_ulsch_16qam_llr((int32_t *)rf_data.data(), (int32_t *)magnitude_data.data(), (int16_t *)ulsch_llr.data(), nb_re, 0); nr_16qam_llr((int32_t *)rf_data.data(), (int32_t *)magnitude_data.data(), (int16_t *)llr.data(), nb_re);
int num_errors = 0; int num_errors = 0;
for (auto i = 0U; i < nb_re; i++) { for (auto i = 0U; i < nb_re; i++) {
EXPECT_EQ(ulsch_llr_ref[i], ulsch_llr[i]) EXPECT_EQ(llr_ref[i], llr[i])
<< "Mismatch 16qam REF " << std::hex << ulsch_llr_ref[i] << " != DUT " << ulsch_llr[i] << " at " << std::dec << i; << "Mismatch 16qam REF " << std::hex << llr_ref[i] << " != DUT " << llr[i] << " at " << std::dec << i;
if (ulsch_llr_ref[i] != ulsch_llr[i]) { if (llr_ref[i] != llr[i]) {
num_errors++; num_errors++;
} }
} }
...@@ -178,31 +165,29 @@ void test_function_64_qam(AlignedVector512<uint32_t> nb_res) ...@@ -178,31 +165,29 @@ void test_function_64_qam(AlignedVector512<uint32_t> nb_res)
auto rf_data = generate_random_c16(nb_re); auto rf_data = generate_random_c16(nb_re);
auto magnitude_data = generate_random_uint16(nb_re * 2); auto magnitude_data = generate_random_uint16(nb_re * 2);
auto magnitude_b_data = generate_random_uint16(nb_re * 2); auto magnitude_b_data = generate_random_uint16(nb_re * 2);
AlignedVector512<uint32_t> ulsch_llr_ref; AlignedVector512<uint32_t> llr_ref;
ulsch_llr_ref.resize(nb_re * 3); llr_ref.resize(nb_re * 3);
std::fill(ulsch_llr_ref.begin(), ulsch_llr_ref.end(), 0); std::fill(llr_ref.begin(), llr_ref.end(), 0);
nr_ulsch_64qam_llr_ref((c16_t *)rf_data.data(), nr_64qam_llr_ref((c16_t *)rf_data.data(),
(int32_t *)magnitude_data.data(), (int32_t *)magnitude_data.data(),
(int32_t *)magnitude_b_data.data(), (int32_t *)magnitude_b_data.data(),
(int16_t *)ulsch_llr_ref.data(), (int16_t *)llr_ref.data(),
nb_re, nb_re);
0);
AlignedVector512<uint32_t> llr;
AlignedVector512<uint32_t> ulsch_llr; llr.resize(nb_re * 3);
ulsch_llr.resize(nb_re * 3); std::fill(llr.begin(), llr.end(), 0);
std::fill(ulsch_llr.begin(), ulsch_llr.end(), 0); nr_64qam_llr((int32_t *)rf_data.data(),
nr_ulsch_64qam_llr((int32_t *)rf_data.data(),
(int32_t *)magnitude_data.data(), (int32_t *)magnitude_data.data(),
(int32_t *)magnitude_b_data.data(), (int32_t *)magnitude_b_data.data(),
(int16_t *)ulsch_llr.data(), (int16_t *)llr.data(),
nb_re, nb_re);
0);
int num_errors = 0; int num_errors = 0;
for (auto i = 0U; i < nb_re * 3; i++) { for (auto i = 0U; i < nb_re * 3; i++) {
EXPECT_EQ(ulsch_llr_ref[i], ulsch_llr[i]) EXPECT_EQ(llr_ref[i], llr[i])
<< "Mismatch 64qam REF " << std::hex << ulsch_llr_ref[i] << " != DUT " << ulsch_llr[i] << " at " << std::dec << i; << "Mismatch 64qam REF " << std::hex << llr_ref[i] << " != DUT " << llr[i] << " at " << std::dec << i;
if (ulsch_llr_ref[i] != ulsch_llr[i]) { if (llr_ref[i] != llr[i]) {
num_errors++; num_errors++;
} }
} }
...@@ -218,33 +203,31 @@ void test_function_256_qam(AlignedVector512<uint32_t> nb_res) ...@@ -218,33 +203,31 @@ void test_function_256_qam(AlignedVector512<uint32_t> nb_res)
auto magnitude_data = generate_random_uint16(nb_re * 2); auto magnitude_data = generate_random_uint16(nb_re * 2);
auto magnitude_b_data = generate_random_uint16(nb_re * 2); auto magnitude_b_data = generate_random_uint16(nb_re * 2);
auto magnitude_c_data = generate_random_uint16(nb_re * 2); auto magnitude_c_data = generate_random_uint16(nb_re * 2);
AlignedVector512<uint32_t> ulsch_llr_ref; AlignedVector512<uint32_t> llr_ref;
ulsch_llr_ref.resize(nb_re * 4); llr_ref.resize(nb_re * 4);
std::fill(ulsch_llr_ref.begin(), ulsch_llr_ref.end(), 0); std::fill(llr_ref.begin(), llr_ref.end(), 0);
nr_ulsch_256qam_llr_ref((c16_t *)rf_data.data(), nr_256qam_llr_ref((c16_t *)rf_data.data(),
(int32_t *)magnitude_data.data(), (int32_t *)magnitude_data.data(),
(int32_t *)magnitude_b_data.data(), (int32_t *)magnitude_b_data.data(),
(int32_t *)magnitude_c_data.data(), (int32_t *)magnitude_c_data.data(),
(int16_t *)ulsch_llr_ref.data(), (int16_t *)llr_ref.data(),
nb_re, nb_re);
0);
AlignedVector512<uint32_t> llr;
AlignedVector512<uint32_t> ulsch_llr; llr.resize(nb_re * 4);
ulsch_llr.resize(nb_re * 4); std::fill(llr.begin(), llr.end(), 0);
std::fill(ulsch_llr.begin(), ulsch_llr.end(), 0); nr_256qam_llr((int32_t *)rf_data.data(),
nr_ulsch_256qam_llr((int32_t *)rf_data.data(),
(int32_t *)magnitude_data.data(), (int32_t *)magnitude_data.data(),
(int32_t *)magnitude_b_data.data(), (int32_t *)magnitude_b_data.data(),
(int32_t *)magnitude_c_data.data(), (int32_t *)magnitude_c_data.data(),
(int16_t *)ulsch_llr.data(), (int16_t *)llr.data(),
nb_re, nb_re);
0);
int num_errors = 0; int num_errors = 0;
for (auto i = 0U; i < nb_re * 4; i++) { for (auto i = 0U; i < nb_re * 4; i++) {
EXPECT_EQ(ulsch_llr_ref[i], ulsch_llr[i]) EXPECT_EQ(llr_ref[i], llr[i])
<< "Mismatch 256qam REF " << std::hex << ulsch_llr_ref[i] << " != DUT " << ulsch_llr[i] << " at " << std::dec << i; << "Mismatch 256qam REF " << std::hex << llr_ref[i] << " != DUT " << llr[i] << " at " << std::dec << i;
if (ulsch_llr_ref[i] != ulsch_llr[i]) { if (llr_ref[i] != llr[i]) {
num_errors++; num_errors++;
} }
} }
...@@ -370,59 +353,57 @@ TEST(test_llr, check_2_res_256_qam) ...@@ -370,59 +353,57 @@ TEST(test_llr, check_2_res_256_qam)
AlignedVector512<int16_t> magnitude_data = {1, 1, 1, 1}; AlignedVector512<int16_t> magnitude_data = {1, 1, 1, 1};
AlignedVector512<int16_t> magnitude_b_data = {2, 2, 2, 2}; AlignedVector512<int16_t> magnitude_b_data = {2, 2, 2, 2};
AlignedVector512<int16_t> magnitude_c_data = {3, 3, 3, 3}; AlignedVector512<int16_t> magnitude_c_data = {3, 3, 3, 3};
AlignedVector512<int16_t> ulsch_llr_ref; AlignedVector512<int16_t> llr_ref;
ulsch_llr_ref.resize(2 * 8); llr_ref.resize(2 * 8);
std::fill(ulsch_llr_ref.begin(), ulsch_llr_ref.end(), 0); std::fill(llr_ref.begin(), llr_ref.end(), 0);
nr_ulsch_256qam_llr_ref((c16_t *)rf_data.data(), nr_256qam_llr_ref((c16_t *)rf_data.data(),
(int32_t *)magnitude_data.data(), (int32_t *)magnitude_data.data(),
(int32_t *)magnitude_b_data.data(), (int32_t *)magnitude_b_data.data(),
(int32_t *)magnitude_c_data.data(), (int32_t *)magnitude_c_data.data(),
(int16_t *)ulsch_llr_ref.data(), (int16_t *)llr_ref.data(),
2, 2);
0);
AlignedVector512<int16_t> llr;
AlignedVector512<int16_t> ulsch_llr; llr.resize(2 * 8);
ulsch_llr.resize(2 * 8); std::fill(llr.begin(), llr.end(), 0);
std::fill(ulsch_llr.begin(), ulsch_llr.end(), 0); nr_256qam_llr((int32_t *)rf_data.data(),
nr_ulsch_256qam_llr((int32_t *)rf_data.data(),
(int32_t *)magnitude_data.data(), (int32_t *)magnitude_data.data(),
(int32_t *)magnitude_b_data.data(), (int32_t *)magnitude_b_data.data(),
(int32_t *)magnitude_c_data.data(), (int32_t *)magnitude_c_data.data(),
(int16_t *)ulsch_llr.data(), (int16_t *)llr.data(),
2, 2);
0);
printf("\nDUT:\n"); printf("\nDUT:\n");
for (auto i = 0U; i < 2; i++) { for (auto i = 0U; i < 2; i++) {
printf("%d %d %d %d %d %d %d %d\n", printf("%d %d %d %d %d %d %d %d\n",
ulsch_llr[i * 8], llr[i * 8],
ulsch_llr[i * 8 + 1], llr[i * 8 + 1],
ulsch_llr[i * 8 + 2], llr[i * 8 + 2],
ulsch_llr[i * 8 + 3], llr[i * 8 + 3],
ulsch_llr[i * 8 + 4], llr[i * 8 + 4],
ulsch_llr[i * 8 + 5], llr[i * 8 + 5],
ulsch_llr[i * 8 + 6], llr[i * 8 + 6],
ulsch_llr[i * 8 + 7]); llr[i * 8 + 7]);
} }
printf("\nREF:\n"); printf("\nREF:\n");
for (auto i = 0U; i < 2; i++) { for (auto i = 0U; i < 2; i++) {
printf("%d %d %d %d %d %d %d %d\n", printf("%d %d %d %d %d %d %d %d\n",
ulsch_llr_ref[i * 8], llr_ref[i * 8],
ulsch_llr_ref[i * 8 + 1], llr_ref[i * 8 + 1],
ulsch_llr_ref[i * 8 + 2], llr_ref[i * 8 + 2],
ulsch_llr_ref[i * 8 + 3], llr_ref[i * 8 + 3],
ulsch_llr_ref[i * 8 + 4], llr_ref[i * 8 + 4],
ulsch_llr_ref[i * 8 + 5], llr_ref[i * 8 + 5],
ulsch_llr_ref[i * 8 + 6], llr_ref[i * 8 + 6],
ulsch_llr_ref[i * 8 + 7]); llr_ref[i * 8 + 7]);
} }
int num_errors = 0; int num_errors = 0;
for (auto i = 0U; i < 2 * 8; i++) { for (auto i = 0U; i < 2 * 8; i++) {
EXPECT_EQ(ulsch_llr_ref[i], ulsch_llr[i]) EXPECT_EQ(llr_ref[i], llr[i])
<< "Mismatch 256qam REF " << std::hex << ulsch_llr_ref[i] << " != DUT " << ulsch_llr[i] << " at " << std::dec << i; << "Mismatch 256qam REF " << std::hex << llr_ref[i] << " != DUT " << llr[i] << " at " << std::dec << i;
if (ulsch_llr_ref[i] != ulsch_llr[i]) { if (llr_ref[i] != llr[i]) {
num_errors++; num_errors++;
} }
} }
......
add_library(nr_phy_common src/nr_phy_common.c) add_library(nr_phy_common src/nr_phy_common.c)
target_link_libraries(nr_phy_common PRIVATE UTIL) target_link_libraries(nr_phy_common PRIVATE UTIL PHY_COMMON)
target_include_directories(nr_phy_common PUBLIC inc/) target_include_directories(nr_phy_common PUBLIC inc/)
add_library(nr_ue_phy_meas src/nr_ue_phy_meas.c) add_library(nr_ue_phy_meas src/nr_ue_phy_meas.c)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment