mirror of https://github.com/pvnis/srsRAN_4G.git
Added scrambling, ratematching and layer mapping tests
parent
bea03bfdd2
commit
67b8cf3ee2
@ -0,0 +1,15 @@
|
|||||||
|
SET(CTEST_CUSTOM_MEMCHECK_IGNORE
|
||||||
|
|
||||||
|
# Ignore memcheck for plots. QT errors
|
||||||
|
|
||||||
|
waterfallplot_test
|
||||||
|
scatterplot_test
|
||||||
|
realplot_test
|
||||||
|
complexplot_test
|
||||||
|
|
||||||
|
# Ignore these to, they take too lonk
|
||||||
|
fft_normal
|
||||||
|
fft_extened
|
||||||
|
chest_test_all_cellids
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,34 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2012-2013 The libLTE Developers. See the
|
||||||
|
# COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
#
|
||||||
|
# This file is part of the libLTE library.
|
||||||
|
#
|
||||||
|
# libLTE is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of
|
||||||
|
# the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# libLTE is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# A copy of the GNU Lesser General Public License can be found in
|
||||||
|
# the LICENSE file in the top-level directory of this distribution
|
||||||
|
# and at http://www.gnu.org/licenses/.
|
||||||
|
#
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# FFT TEST
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(fft_test fft_test.c)
|
||||||
|
TARGET_LINK_LIBRARIES(fft_test lte)
|
||||||
|
|
||||||
|
ADD_TEST(fft_normal fft_test)
|
||||||
|
ADD_TEST(fft_extended fft_test -e)
|
||||||
|
|
||||||
|
ADD_TEST(fft_normal_single fft_test -n 6)
|
||||||
|
ADD_TEST(fft_extended_single fft_test -e -n 6)
|
||||||
|
|
@ -0,0 +1,141 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2014 The libLTE Developers. See the
|
||||||
|
* COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
*
|
||||||
|
* \section LICENSE
|
||||||
|
*
|
||||||
|
* This file is part of the libLTE library.
|
||||||
|
*
|
||||||
|
* libLTE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libLTE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of the GNU Lesser General Public License can be found in
|
||||||
|
* the LICENSE file in the top-level directory of this distribution
|
||||||
|
* and at http://www.gnu.org/licenses/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "lte.h"
|
||||||
|
|
||||||
|
int nof_prb = -1;
|
||||||
|
lte_cp_t cp = CPNORM;
|
||||||
|
|
||||||
|
void usage(char *prog) {
|
||||||
|
printf("Usage: %s\n", prog);
|
||||||
|
printf("\t-n nof_prb [Default All]\n");
|
||||||
|
printf("\t-e extended cyclic prefix [Default Normal]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse_args(int argc, char **argv) {
|
||||||
|
int opt;
|
||||||
|
while ((opt = getopt(argc, argv, "ne")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'n':
|
||||||
|
nof_prb = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
cp = CPEXT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
lte_fft_t fft, ifft;
|
||||||
|
cf_t *input, *outfft, *outifft;
|
||||||
|
float mse;
|
||||||
|
int n_prb, max_prb, n_re;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
parse_args(argc, argv);
|
||||||
|
|
||||||
|
if (nof_prb == -1) {
|
||||||
|
n_prb = 6;
|
||||||
|
max_prb = 100;
|
||||||
|
} else {
|
||||||
|
n_prb = nof_prb;
|
||||||
|
max_prb = nof_prb;
|
||||||
|
}
|
||||||
|
while(n_prb <= max_prb) {
|
||||||
|
n_re = CP_NSYMB(cp) * n_prb * RE_X_RB;
|
||||||
|
|
||||||
|
printf("Running test for %d PRB, %d RE... ", n_prb, n_re);fflush(stdout);
|
||||||
|
|
||||||
|
input = malloc(sizeof(cf_t) * n_re);
|
||||||
|
if (!input) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
outfft = malloc(sizeof(cf_t) * SLOT_LEN_CPNORM(lte_symbol_sz(n_prb)));
|
||||||
|
if (!outfft) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
outifft = malloc(sizeof(cf_t) * n_re);
|
||||||
|
if (!outifft) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lte_fft_init(&fft, cp, n_prb)) {
|
||||||
|
fprintf(stderr, "Error initializing FFT\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
if (lte_ifft_init(&ifft, cp, n_prb)) {
|
||||||
|
fprintf(stderr, "Error initializing iFFT\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<n_re;i++) {
|
||||||
|
input[i] = 100 * ((float) rand()/RAND_MAX + (float) I*rand()/RAND_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
lte_ifft_run(&ifft, input, outfft);
|
||||||
|
lte_fft_run(&fft, outfft, outifft);
|
||||||
|
|
||||||
|
/* compute MSE */
|
||||||
|
|
||||||
|
mse = 0;
|
||||||
|
for (i=0;i<n_re;i++) {
|
||||||
|
mse += cabsf(input[i] - outifft[i]);
|
||||||
|
}
|
||||||
|
printf("MSE=%f\n", mse);
|
||||||
|
|
||||||
|
if (mse >= 0.05) {
|
||||||
|
printf("MSE too large\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
lte_fft_free(&fft);
|
||||||
|
lte_ifft_free(&ifft);
|
||||||
|
|
||||||
|
free(input);
|
||||||
|
free(outfft);
|
||||||
|
free(outifft);
|
||||||
|
|
||||||
|
n_prb++;
|
||||||
|
}
|
||||||
|
fftwf_cleanup();
|
||||||
|
exit(0);
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2012-2013 The libLTE Developers. See the
|
||||||
|
# COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
#
|
||||||
|
# This file is part of the libLTE library.
|
||||||
|
#
|
||||||
|
# libLTE is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of
|
||||||
|
# the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# libLTE is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# A copy of the GNU Lesser General Public License can be found in
|
||||||
|
# the LICENSE file in the top-level directory of this distribution
|
||||||
|
# and at http://www.gnu.org/licenses/.
|
||||||
|
#
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# LAYER MAPPING TEST
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(layermap_test layermap_test.c)
|
||||||
|
TARGET_LINK_LIBRARIES(layermap_test lte)
|
||||||
|
|
||||||
|
ADD_TEST(layermap_single layermap_test -n 1000 -m single -c 1 -l 1)
|
||||||
|
|
||||||
|
ADD_TEST(layermap_diversity_2 layermap_test -n 1000 -m diversity -c 1 -l 2)
|
||||||
|
ADD_TEST(layermap_diversity_4 layermap_test -n 1000 -m diversity -c 1 -l 4)
|
||||||
|
|
||||||
|
ADD_TEST(layermap_multiplex_11 layermap_test -n 1000 -m multiplex -c 1 -l 1)
|
||||||
|
ADD_TEST(layermap_multiplex_12 layermap_test -n 1000 -m multiplex -c 1 -l 2)
|
||||||
|
ADD_TEST(layermap_multiplex_13 layermap_test -n 1002 -m multiplex -c 1 -l 3)
|
||||||
|
ADD_TEST(layermap_multiplex_14 layermap_test -n 1000 -m multiplex -c 1 -l 4)
|
||||||
|
ADD_TEST(layermap_multiplex_15 layermap_test -n 1000 -m multiplex -c 1 -l 5)
|
||||||
|
ADD_TEST(layermap_multiplex_16 layermap_test -n 1002 -m multiplex -c 1 -l 6)
|
||||||
|
ADD_TEST(layermap_multiplex_17 layermap_test -n 994 -m multiplex -c 1 -l 7)
|
||||||
|
ADD_TEST(layermap_multiplex_18 layermap_test -n 1000 -m multiplex -c 1 -l 8)
|
||||||
|
|
||||||
|
|
||||||
|
ADD_TEST(layermap_multiplex_22 layermap_test -n 1000 -m multiplex -c 2 -l 2)
|
||||||
|
ADD_TEST(layermap_multiplex_23 layermap_test -n 1002 -m multiplex -c 2 -l 3)
|
||||||
|
ADD_TEST(layermap_multiplex_24 layermap_test -n 1000 -m multiplex -c 2 -l 4)
|
||||||
|
ADD_TEST(layermap_multiplex_25 layermap_test -n 1002 -m multiplex -c 2 -l 5)
|
||||||
|
ADD_TEST(layermap_multiplex_26 layermap_test -n 1002 -m multiplex -c 2 -l 6)
|
||||||
|
ADD_TEST(layermap_multiplex_27 layermap_test -n 1000 -m multiplex -c 2 -l 7)
|
||||||
|
ADD_TEST(layermap_multiplex_28 layermap_test -n 1000 -m multiplex -c 2 -l 8)
|
||||||
|
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# LAYER MAPPING TEST
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
|
||||||
|
#ADD_EXECUTABLE(precoding_test precoding_test.c)
|
||||||
|
#TARGET_LINK_LIBRARIES(precoding_test lte)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,163 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2014 The libLTE Developers. See the
|
||||||
|
* COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
*
|
||||||
|
* \section LICENSE
|
||||||
|
*
|
||||||
|
* This file is part of the libLTE library.
|
||||||
|
*
|
||||||
|
* libLTE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libLTE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of the GNU Lesser General Public License can be found in
|
||||||
|
* the LICENSE file in the top-level directory of this distribution
|
||||||
|
* and at http://www.gnu.org/licenses/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "lte.h"
|
||||||
|
|
||||||
|
int nof_symbols = 1000;
|
||||||
|
int nof_cw = 1, nof_layers = 1;
|
||||||
|
char *mimo_type_name = NULL;
|
||||||
|
|
||||||
|
void usage(char *prog) {
|
||||||
|
printf("Usage: %s -m [single|diversity|multiplex] -c [nof_cw] -l [nof_layers]\n", prog);
|
||||||
|
printf("\t-n num_symbols [Default %d]\n", nof_symbols);
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse_args(int argc, char **argv) {
|
||||||
|
int opt;
|
||||||
|
while ((opt = getopt(argc, argv, "mcln")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'n':
|
||||||
|
nof_symbols = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
nof_cw = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
nof_layers = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
mimo_type_name = argv[optind];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!mimo_type_name) {
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int i, j, num_errors, symbols_layer;
|
||||||
|
cf_t *d[MAX_CODEWORDS], *x[MAX_LAYERS], *dp[MAX_CODEWORDS];
|
||||||
|
mimo_type_t type;
|
||||||
|
int nof_symb_cw[MAX_CODEWORDS];
|
||||||
|
int n[2];
|
||||||
|
|
||||||
|
parse_args(argc, argv);
|
||||||
|
|
||||||
|
if (lte_str2mimotype(mimo_type_name, &type)) {
|
||||||
|
fprintf(stderr, "Invalid MIMO type %s\n", mimo_type_name);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nof_cw > 1) {
|
||||||
|
n[0] = nof_layers / nof_cw;
|
||||||
|
n[1] = nof_layers - n[0];
|
||||||
|
nof_symb_cw[0] = nof_symbols * n[0];
|
||||||
|
nof_symb_cw[1] = nof_symbols * n[1];
|
||||||
|
} else {
|
||||||
|
nof_symb_cw[0] = nof_symbols;
|
||||||
|
nof_symb_cw[1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<nof_cw;i++) {
|
||||||
|
d[i] = malloc(sizeof(cf_t) * nof_symb_cw[i]);
|
||||||
|
if (!d[i]) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
dp[i] = malloc(sizeof(cf_t) * nof_symb_cw[i]);
|
||||||
|
if (!dp[i]) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i=0;i<nof_layers;i++) {
|
||||||
|
x[i] = malloc(sizeof(cf_t) * nof_symbols);
|
||||||
|
if (!x[i]) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* generate random data */
|
||||||
|
for (i=0;i<nof_cw;i++) {
|
||||||
|
for (j=0;j<nof_symb_cw[i];j++) {
|
||||||
|
d[i][j] = 100 * (rand()/RAND_MAX + I*rand()/RAND_MAX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* layer encode */
|
||||||
|
if ((symbols_layer = layermap_type(d, x, nof_cw, nof_layers, nof_symb_cw, type)) < 0) {
|
||||||
|
fprintf(stderr, "Error layer mapper encoder\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* layer decode */
|
||||||
|
if (layerdemap_type(x, dp, nof_layers, nof_cw, nof_symbols/nof_layers, nof_symb_cw, type) < 0) {
|
||||||
|
fprintf(stderr, "Error layer mapper encoder\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check errors */
|
||||||
|
num_errors = 0;
|
||||||
|
for (i=0;i<nof_cw;i++) {
|
||||||
|
for (j=0;j<nof_symb_cw[i];j++) {
|
||||||
|
if (d[i][j] != dp[i][j]) {
|
||||||
|
num_errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<nof_cw;i++) {
|
||||||
|
free(d[i]);
|
||||||
|
free(dp[i]);
|
||||||
|
}
|
||||||
|
for (i=0;i<nof_layers;i++) {
|
||||||
|
free(x[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num_errors) {
|
||||||
|
printf("%d Errors\n", num_errors);
|
||||||
|
exit(-1);
|
||||||
|
} else {
|
||||||
|
printf("Ok\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,163 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2014 The libLTE Developers. See the
|
||||||
|
* COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
*
|
||||||
|
* \section LICENSE
|
||||||
|
*
|
||||||
|
* This file is part of the libLTE library.
|
||||||
|
*
|
||||||
|
* libLTE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libLTE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of the GNU Lesser General Public License can be found in
|
||||||
|
* the LICENSE file in the top-level directory of this distribution
|
||||||
|
* and at http://www.gnu.org/licenses/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "lte.h"
|
||||||
|
|
||||||
|
int nof_symbols = 1000;
|
||||||
|
int nof_cw = 1, nof_layers = 1;
|
||||||
|
char *mimo_type_name = NULL;
|
||||||
|
|
||||||
|
void usage(char *prog) {
|
||||||
|
printf("Usage: %s -m [single|diversity|multiplex] -c [nof_cw] -l [nof_layers]\n", prog);
|
||||||
|
printf("\t-n num_symbols [Default %d]\n", nof_symbols);
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse_args(int argc, char **argv) {
|
||||||
|
int opt;
|
||||||
|
while ((opt = getopt(argc, argv, "mcln")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'n':
|
||||||
|
nof_symbols = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
nof_cw = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
nof_layers = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
mimo_type_name = argv[optind];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!mimo_type_name) {
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int i, j, num_errors, symbols_layer;
|
||||||
|
cf_t *d[MAX_CODEWORDS], *x[MAX_LAYERS], *dp[MAX_CODEWORDS];
|
||||||
|
mimo_type_t type;
|
||||||
|
int nof_symb_cw[MAX_CODEWORDS];
|
||||||
|
int n[2];
|
||||||
|
|
||||||
|
parse_args(argc, argv);
|
||||||
|
|
||||||
|
if (lte_str2mimotype(mimo_type_name, &type)) {
|
||||||
|
fprintf(stderr, "Invalid MIMO type %s\n", mimo_type_name);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nof_cw > 1) {
|
||||||
|
n[0] = nof_layers / nof_cw;
|
||||||
|
n[1] = nof_layers - n[0];
|
||||||
|
nof_symb_cw[0] = nof_symbols * n[0];
|
||||||
|
nof_symb_cw[1] = nof_symbols * n[1];
|
||||||
|
} else {
|
||||||
|
nof_symb_cw[0] = nof_symbols;
|
||||||
|
nof_symb_cw[1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<nof_cw;i++) {
|
||||||
|
d[i] = malloc(sizeof(cf_t) * nof_symb_cw[i]);
|
||||||
|
if (!d[i]) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
dp[i] = malloc(sizeof(cf_t) * nof_symb_cw[i]);
|
||||||
|
if (!dp[i]) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i=0;i<nof_layers;i++) {
|
||||||
|
x[i] = malloc(sizeof(cf_t) * nof_symbols);
|
||||||
|
if (!x[i]) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* generate random data */
|
||||||
|
for (i=0;i<nof_cw;i++) {
|
||||||
|
for (j=0;j<nof_symb_cw[i];j++) {
|
||||||
|
d[i][j] = 100 * (rand()/RAND_MAX + I*rand()/RAND_MAX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* layer encode */
|
||||||
|
if ((symbols_layer = layermap_type(d, x, nof_cw, nof_layers, nof_symb_cw, type)) < 0) {
|
||||||
|
fprintf(stderr, "Error layer mapper encoder\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* layer decode */
|
||||||
|
if (layerdemap_type(x, dp, nof_layers, nof_cw, nof_symbols/nof_layers, nof_symb_cw, type) < 0) {
|
||||||
|
fprintf(stderr, "Error layer mapper encoder\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check errors */
|
||||||
|
num_errors = 0;
|
||||||
|
for (i=0;i<nof_cw;i++) {
|
||||||
|
for (j=0;j<nof_symb_cw[i];j++) {
|
||||||
|
if (d[i][j] != dp[i][j]) {
|
||||||
|
num_errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<nof_cw;i++) {
|
||||||
|
free(d[i]);
|
||||||
|
free(dp[i]);
|
||||||
|
}
|
||||||
|
for (i=0;i<nof_layers;i++) {
|
||||||
|
free(x[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num_errors) {
|
||||||
|
printf("%d Errors\n", num_errors);
|
||||||
|
exit(-1);
|
||||||
|
} else {
|
||||||
|
printf("Ok\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2012-2013 The libLTE Developers. See the
|
||||||
|
# COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
#
|
||||||
|
# This file is part of the libLTE library.
|
||||||
|
#
|
||||||
|
# libLTE is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of
|
||||||
|
# the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# libLTE is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# A copy of the GNU Lesser General Public License can be found in
|
||||||
|
# the LICENSE file in the top-level directory of this distribution
|
||||||
|
# and at http://www.gnu.org/licenses/.
|
||||||
|
#
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# MODEM TEST
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(modem_test modem_test.c)
|
||||||
|
TARGET_LINK_LIBRARIES(modem_test lte)
|
||||||
|
|
||||||
|
ADD_TEST(modem_bpsk modem_test -n 1020 -m 1)
|
||||||
|
ADD_TEST(modem_qpsk modem_test -n 1020 -m 2)
|
||||||
|
ADD_TEST(modem_qam16 modem_test -n 1020 -m 4)
|
||||||
|
ADD_TEST(modem_qam64 modem_test -n 1020 -m 6)
|
||||||
|
|
||||||
|
ADD_TEST(modem_bpsk_soft modem_test -n 1020 -m 1 -s)
|
||||||
|
ADD_TEST(modem_qpsk_soft modem_test -n 1020 -m 2 -s)
|
||||||
|
ADD_TEST(modem_qam16_soft modem_test -n 1020 -m 4 -s)
|
||||||
|
ADD_TEST(modem_qam64_soft modem_test -n 1020 -m 6 -s)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,184 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2014 The libLTE Developers. See the
|
||||||
|
* COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
*
|
||||||
|
* \section LICENSE
|
||||||
|
*
|
||||||
|
* This file is part of the libLTE library.
|
||||||
|
*
|
||||||
|
* libLTE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libLTE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of the GNU Lesser General Public License can be found in
|
||||||
|
* the LICENSE file in the top-level directory of this distribution
|
||||||
|
* and at http://www.gnu.org/licenses/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "lte.h"
|
||||||
|
|
||||||
|
int num_bits = 1000;
|
||||||
|
enum modem_std modulation;
|
||||||
|
bool soft_output = false, soft_exact = false;
|
||||||
|
|
||||||
|
void usage(char *prog) {
|
||||||
|
printf("Usage: %s [nmse]\n", prog);
|
||||||
|
printf("\t-n num_bits [Default %d]\n", num_bits);
|
||||||
|
printf("\t-m modulation (1: BPSK, 2: QPSK, 3: QAM16, 4: QAM64) [Default BPSK]\n");
|
||||||
|
printf("\t-s soft outputs [Default hard]\n");
|
||||||
|
printf("\t-e soft outputs exact algorithm [Default approx]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse_args(int argc, char **argv) {
|
||||||
|
int opt;
|
||||||
|
while ((opt = getopt(argc, argv, "nmse")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'n':
|
||||||
|
num_bits = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
soft_output = true;
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
soft_exact = true;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
switch(atoi(argv[optind])) {
|
||||||
|
case 1:
|
||||||
|
modulation = LTE_BPSK;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
modulation = LTE_QPSK;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
modulation = LTE_QAM16;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
modulation = LTE_QAM64;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Invalid modulation %d. Possible values: "
|
||||||
|
"(1: BPSK, 2: QPSK, 3: QAM16, 4: QAM64)\n", atoi(argv[optind]));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int i;
|
||||||
|
modem_table_t mod;
|
||||||
|
demod_hard_t demod_hard;
|
||||||
|
demod_soft_t demod_soft;
|
||||||
|
char *input, *output;
|
||||||
|
cf_t *symbols;
|
||||||
|
float *llr;
|
||||||
|
|
||||||
|
parse_args(argc, argv);
|
||||||
|
|
||||||
|
/* initialize objects */
|
||||||
|
if (modem_table_std(&mod, modulation, soft_output)) {
|
||||||
|
fprintf(stderr, "Error initializing modem table\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check that num_bits is multiple of num_bits x symbol */
|
||||||
|
if (num_bits % mod.nbits_x_symbol) {
|
||||||
|
fprintf(stderr, "Error num_bits must be multiple of %d\n", mod.nbits_x_symbol);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (soft_output) {
|
||||||
|
demod_soft_init(&demod_soft);
|
||||||
|
demod_soft_table_set(&demod_soft, &mod);
|
||||||
|
demod_soft_alg_set(&demod_soft, soft_exact?EXACT:APPROX);
|
||||||
|
} else {
|
||||||
|
demod_hard_init(&demod_hard);
|
||||||
|
demod_hard_table_set(&demod_hard, modulation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate buffers */
|
||||||
|
input = malloc(sizeof(char) * num_bits);
|
||||||
|
if (!input) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
output = malloc(sizeof(char) * num_bits);
|
||||||
|
if (!output) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
symbols = malloc(sizeof(cf_t) * num_bits / mod.nbits_x_symbol);
|
||||||
|
if (!symbols) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
llr = malloc(sizeof(float) * num_bits);
|
||||||
|
if (!llr) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* generate random data */
|
||||||
|
srand(time(NULL));
|
||||||
|
for (i=0;i<num_bits;i++) {
|
||||||
|
input[i] = rand()%2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* modulate */
|
||||||
|
mod_modulate(&mod, input, symbols, num_bits);
|
||||||
|
|
||||||
|
/* demodulate */
|
||||||
|
if (soft_output) {
|
||||||
|
demod_soft_demodulate(&demod_soft, symbols, llr, num_bits / mod.nbits_x_symbol);
|
||||||
|
for (i=0;i<num_bits;i++) {
|
||||||
|
output[i] = llr[i]>=0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
demod_hard_demodulate(&demod_hard, symbols, output, num_bits / mod.nbits_x_symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check errors */
|
||||||
|
for (i=0;i<num_bits;i++) {
|
||||||
|
if (input[i] != output[i]) {
|
||||||
|
fprintf(stderr, "Error in bit %d\n", i);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(llr);
|
||||||
|
free(symbols);
|
||||||
|
free(output);
|
||||||
|
free(input);
|
||||||
|
|
||||||
|
modem_table_free(&mod);
|
||||||
|
|
||||||
|
printf("Ok\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2012-2013 The libLTE Developers. See the
|
||||||
|
# COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
#
|
||||||
|
# This file is part of the libLTE library.
|
||||||
|
#
|
||||||
|
# libLTE is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of
|
||||||
|
# the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# libLTE is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# A copy of the GNU Lesser General Public License can be found in
|
||||||
|
# the LICENSE file in the top-level directory of this distribution
|
||||||
|
# and at http://www.gnu.org/licenses/.
|
||||||
|
#
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# RATEMATCHING TEST
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(rm_conv_test rm_conv_test.c)
|
||||||
|
TARGET_LINK_LIBRARIES(rm_conv_test lte)
|
||||||
|
|
||||||
|
ADD_TEST(rm_conv_test_1 rm_conv_test -t 480 -r 1920)
|
||||||
|
ADD_TEST(rm_conv_test_2 rm_conv_test -t 1920 -r 480)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,134 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2014 The libLTE Developers. See the
|
||||||
|
* COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
*
|
||||||
|
* \section LICENSE
|
||||||
|
*
|
||||||
|
* This file is part of the libLTE library.
|
||||||
|
*
|
||||||
|
* libLTE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libLTE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of the GNU Lesser General Public License can be found in
|
||||||
|
* the LICENSE file in the top-level directory of this distribution
|
||||||
|
* and at http://www.gnu.org/licenses/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "lte.h"
|
||||||
|
|
||||||
|
int nof_tx_bits=-1, nof_rx_bits=-1;
|
||||||
|
|
||||||
|
void usage(char *prog) {
|
||||||
|
printf("Usage: %s -t nof_tx_bits -r nof_rx_bits\n", prog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse_args(int argc, char **argv) {
|
||||||
|
int opt;
|
||||||
|
while ((opt = getopt(argc, argv, "tr")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 't':
|
||||||
|
nof_tx_bits = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
nof_rx_bits = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nof_tx_bits == -1) {
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
if (nof_rx_bits == -1) {
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int i;
|
||||||
|
char *bits, *rm_bits;
|
||||||
|
float *rm_symbols, *unrm_symbols;
|
||||||
|
int nof_errors;
|
||||||
|
|
||||||
|
parse_args(argc, argv);
|
||||||
|
|
||||||
|
bits = malloc(sizeof(char) * nof_tx_bits);
|
||||||
|
if (!bits) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
rm_bits = malloc(sizeof(char) * nof_rx_bits);
|
||||||
|
if (!rm_bits) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
rm_symbols = malloc(sizeof(float) * nof_rx_bits);
|
||||||
|
if (!rm_symbols) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
unrm_symbols = malloc(sizeof(float) * nof_tx_bits);
|
||||||
|
if (!unrm_symbols) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<nof_tx_bits;i++) {
|
||||||
|
bits[i] = rand()%2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rm_conv_tx(bits, rm_bits, nof_tx_bits, nof_rx_bits)) {
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<nof_rx_bits;i++) {
|
||||||
|
rm_symbols[i] = rm_bits[i]?1:-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rm_conv_rx(rm_symbols, unrm_symbols, nof_rx_bits, nof_tx_bits)) {
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<nof_tx_bits;i++) {
|
||||||
|
if ((unrm_symbols[i] > 0) != bits[i]) {
|
||||||
|
nof_errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nof_rx_bits > nof_tx_bits) {
|
||||||
|
if (nof_errors) {
|
||||||
|
printf("nof_errors=%d\n", nof_errors);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(bits);
|
||||||
|
free(rm_bits);
|
||||||
|
free(rm_symbols);
|
||||||
|
free(unrm_symbols);
|
||||||
|
|
||||||
|
printf("Ok\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2012-2013 The libLTE Developers. See the
|
||||||
|
# COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
#
|
||||||
|
# This file is part of the libLTE library.
|
||||||
|
#
|
||||||
|
# libLTE is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of
|
||||||
|
# the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# libLTE is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# A copy of the GNU Lesser General Public License can be found in
|
||||||
|
# the LICENSE file in the top-level directory of this distribution
|
||||||
|
# and at http://www.gnu.org/licenses/.
|
||||||
|
#
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# SCRAMBLING TEST
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(scrambling_test scrambling_test.c)
|
||||||
|
TARGET_LINK_LIBRARIES(scrambling_test lte)
|
||||||
|
|
||||||
|
ADD_TEST(scrambling_pbch_bit scrambling_test -s PBCH -c 50)
|
||||||
|
ADD_TEST(scrambling_pbch_float scrambling_test -s PBCH -c 50 -f)
|
||||||
|
ADD_TEST(scrambling_pbch_e_bit scrambling_test -s PBCH -c 50 -e)
|
||||||
|
ADD_TEST(scrambling_pbch_e_float scrambling_test -s PBCH -c 50 -f -e)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,165 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* \section COPYRIGHT
|
||||||
|
*
|
||||||
|
* Copyright 2013-2014 The libLTE Developers. See the
|
||||||
|
* COPYRIGHT file at the top-level directory of this distribution.
|
||||||
|
*
|
||||||
|
* \section LICENSE
|
||||||
|
*
|
||||||
|
* This file is part of the libLTE library.
|
||||||
|
*
|
||||||
|
* libLTE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libLTE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of the GNU Lesser General Public License can be found in
|
||||||
|
* the LICENSE file in the top-level directory of this distribution
|
||||||
|
* and at http://www.gnu.org/licenses/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "lte.h"
|
||||||
|
|
||||||
|
char *sequence_name = NULL;
|
||||||
|
bool do_floats = false;
|
||||||
|
lte_cp_t cp = CPNORM;
|
||||||
|
int cell_id = -1;
|
||||||
|
|
||||||
|
void usage(char *prog) {
|
||||||
|
printf("Usage: %s [ef] -c cell_id -s [PBCH, PDSCH, PDCCH, PMCH, PUCCH]\n", prog);
|
||||||
|
printf("\t -e CP extended [Default CP Normal]\n");
|
||||||
|
printf("\t -f scramble floats [Default bits]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse_args(int argc, char **argv) {
|
||||||
|
int opt;
|
||||||
|
while ((opt = getopt(argc, argv, "csef")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'c':
|
||||||
|
cell_id = atoi(argv[optind]);
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
cp = CPEXT;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
do_floats = true;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
sequence_name = argv[optind];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cell_id == -1) {
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
if (!sequence_name) {
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int init_sequence(sequence_t *seq, char *name) {
|
||||||
|
if (!strcmp(name, "PBCH")) {
|
||||||
|
return sequence_pbch(seq, cp, cell_id);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Unsupported sequence name %s\n", name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int i;
|
||||||
|
sequence_t seq;
|
||||||
|
char *input_b, *scrambled_b;
|
||||||
|
float *input_f, *scrambled_f;
|
||||||
|
|
||||||
|
parse_args(argc, argv);
|
||||||
|
|
||||||
|
if (init_sequence(&seq, sequence_name) == -1) {
|
||||||
|
fprintf(stderr, "Error initiating sequence %s\n", sequence_name);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!do_floats) {
|
||||||
|
input_b = malloc(sizeof(char) * seq.len);
|
||||||
|
if (!input_b) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
scrambled_b = malloc(sizeof(char) * seq.len);
|
||||||
|
if (!scrambled_b) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<seq.len;i++) {
|
||||||
|
input_b[i] = rand()%2;
|
||||||
|
scrambled_b[i] = input_b[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
scrambling_bit(&seq, scrambled_b);
|
||||||
|
scrambling_bit(&seq, scrambled_b);
|
||||||
|
|
||||||
|
for (i=0;i<seq.len;i++) {
|
||||||
|
if (scrambled_b[i] != input_b[i]) {
|
||||||
|
printf("Error in %d\n", i);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(input_b);
|
||||||
|
free(scrambled_b);
|
||||||
|
} else {
|
||||||
|
input_f = malloc(sizeof(float) * seq.len);
|
||||||
|
if (!input_f) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
scrambled_f = malloc(sizeof(float) * seq.len);
|
||||||
|
if (!scrambled_f) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<seq.len;i++) {
|
||||||
|
input_f[i] = 100*(rand()/RAND_MAX);
|
||||||
|
scrambled_f[i] = input_f[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
scrambling_float(&seq, scrambled_f);
|
||||||
|
scrambling_float(&seq, scrambled_f);
|
||||||
|
|
||||||
|
for (i=0;i<seq.len;i++) {
|
||||||
|
if (scrambled_f[i] != input_f[i]) {
|
||||||
|
printf("Error in %d\n", i);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(input_f);
|
||||||
|
free(scrambled_f);
|
||||||
|
}
|
||||||
|
printf("Ok\n");
|
||||||
|
sequence_free(&seq);
|
||||||
|
exit(0);
|
||||||
|
}
|
Loading…
Reference in New Issue