mirror of https://github.com/pvnis/srsRAN_4G.git
All tests completed
parent
f588d670ad
commit
6a514e4107
@ -0,0 +1,42 @@
|
||||
#
|
||||
# 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/.
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# PBCH TEST
|
||||
########################################################################
|
||||
|
||||
ADD_EXECUTABLE(pbch_test pbch_test.c)
|
||||
TARGET_LINK_LIBRARIES(pbch_test lte)
|
||||
|
||||
ADD_TEST(pbch_test_6 pbch_test -p 6 -c 100)
|
||||
ADD_TEST(pbch_test_50 pbch_test -p 50 -c 50)
|
||||
|
||||
########################################################################
|
||||
# PBCH FILE TEST
|
||||
########################################################################
|
||||
|
||||
ADD_EXECUTABLE(pbch_file_test pbch_file_test.c)
|
||||
TARGET_LINK_LIBRARIES(pbch_file_test lte)
|
||||
|
||||
ADD_TEST(pbch_file_test pbch_file_test -i ${CMAKE_CURRENT_SOURCE_DIR}/h3g.mib.dat)
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -0,0 +1,129 @@
|
||||
/**
|
||||
*
|
||||
* \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 "lte.h"
|
||||
|
||||
int cell_id = 1;
|
||||
int nof_prb = 6;
|
||||
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s [cpv]\n", prog);
|
||||
printf("\t-c cell id [Default %d]\n", cell_id);
|
||||
printf("\t-p nof_prb [Default %d]\n", nof_prb);
|
||||
printf("\t-v [set verbose to debug, default none]\n");
|
||||
}
|
||||
|
||||
void parse_args(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "cpv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'p':
|
||||
nof_prb = atoi(argv[optind]);
|
||||
break;
|
||||
case 'c':
|
||||
cell_id = atoi(argv[optind]);
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
pbch_t pbch;
|
||||
cf_t *buffer = NULL;
|
||||
pbch_mib_t mib_tx, mib_rx;
|
||||
int i, j;
|
||||
cf_t *ce[MAX_PORTS_CTRL];
|
||||
int nof_re;
|
||||
cf_t *slot1_symbols[MAX_PORTS_CTRL];
|
||||
|
||||
parse_args(argc,argv);
|
||||
|
||||
nof_re = CPNORM_NSYMB * nof_prb * RE_X_RB;
|
||||
|
||||
/* init memory */
|
||||
buffer = malloc(sizeof(cf_t) * nof_re);
|
||||
if (!buffer) {
|
||||
perror("malloc");
|
||||
exit(-1);
|
||||
}
|
||||
for (i=0;i<MAX_PORTS_CTRL;i++) {
|
||||
ce[i] = malloc(sizeof(cf_t) * nof_re);
|
||||
if (!ce[i]) {
|
||||
perror("malloc");
|
||||
exit(-1);
|
||||
}
|
||||
for (j=0;j<nof_re;j++) {
|
||||
ce[i][j] = 1;
|
||||
}
|
||||
slot1_symbols[i] = buffer;
|
||||
}
|
||||
if (pbch_init(&pbch, cell_id, CPNORM)) {
|
||||
fprintf(stderr, "Error creating PBCH object\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
mib_tx.nof_ports = 1;
|
||||
mib_tx.nof_prb = 50;
|
||||
mib_tx.phich_length = EXTENDED;
|
||||
mib_tx.phich_resources = R_1_6;
|
||||
mib_tx.sfn = 124;
|
||||
|
||||
pbch_encode(&pbch, &mib_tx, slot1_symbols, nof_prb, 1);
|
||||
pbch_decode_reset(&pbch);
|
||||
if (1 != pbch_decode(&pbch, buffer, ce, nof_prb, 1, &mib_rx)) {
|
||||
printf("Error decoding\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
pbch_free(&pbch);
|
||||
|
||||
if (buffer) {
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
if (!memcmp(&mib_tx, &mib_rx, sizeof(pbch_mib_t))) {
|
||||
printf("OK\n");
|
||||
exit(0);
|
||||
} else {
|
||||
pbch_mib_fprint(stdout, &mib_rx);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
#
|
||||
# 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/.
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# SYNC TEST
|
||||
########################################################################
|
||||
|
||||
ADD_EXECUTABLE(sync_test sync_test.c)
|
||||
TARGET_LINK_LIBRARIES(sync_test lte)
|
||||
|
||||
ADD_TEST(sync_test_100 sync_test -o 100)
|
||||
ADD_TEST(sync_test_400 sync_test -o 400)
|
||||
|
||||
########################################################################
|
||||
# CFO TEST
|
||||
########################################################################
|
||||
|
||||
ADD_EXECUTABLE(cfo_test cfo_test.c)
|
||||
TARGET_LINK_LIBRARIES(cfo_test lte)
|
||||
|
||||
ADD_TEST(cfo_test_1 cfo_test -f 0.12345 -n 1000)
|
||||
ADD_TEST(cfo_test_2 cfo_test -f 0.99849 -n 1000)
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,119 @@
|
||||
/**
|
||||
*
|
||||
* \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"
|
||||
|
||||
#define MAX_MSE 0.1
|
||||
|
||||
float freq = 0;
|
||||
int num_samples = 1000;
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s -f freq -n num_samples\n", prog);
|
||||
}
|
||||
|
||||
void parse_args(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "nf")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
num_samples = atoi(argv[optind]);
|
||||
break;
|
||||
case 'f':
|
||||
freq = atof(argv[optind]);
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
cf_t *input, *output;
|
||||
cfo_t cfocorr;
|
||||
float mse;
|
||||
|
||||
if (argc < 5) {
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
parse_args(argc, argv);
|
||||
|
||||
input = malloc(sizeof(cf_t) * num_samples);
|
||||
if (!input) {
|
||||
perror("malloc");
|
||||
exit(-1);
|
||||
}
|
||||
output = malloc(sizeof(cf_t) * num_samples);
|
||||
if (!output) {
|
||||
perror("malloc");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for (i=0;i<num_samples;i++) {
|
||||
input[i] = 100 * (rand()/RAND_MAX + I*rand()/RAND_MAX);
|
||||
output[i] = input[i];
|
||||
}
|
||||
|
||||
if (cfo_init(&cfocorr, num_samples)) {
|
||||
fprintf(stderr, "Error initiating CFO\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
cfo_correct(&cfocorr, output, freq);
|
||||
cfo_correct(&cfocorr, output, -freq);
|
||||
|
||||
mse = 0;
|
||||
for (i=0;i<num_samples;i++) {
|
||||
mse += cabsf(input[i] - output[i]) / num_samples;
|
||||
}
|
||||
|
||||
cfo_free(&cfocorr);
|
||||
free(input);
|
||||
free(output);
|
||||
|
||||
printf("MSE: %f\n", mse);
|
||||
if (mse > MAX_MSE) {
|
||||
printf("MSE too large\n");
|
||||
exit(-1);
|
||||
} else {
|
||||
printf("Ok\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
/**
|
||||
*
|
||||
* \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 cell_id = -1, offset = 0;
|
||||
|
||||
#define FLEN 9600
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s [co]\n", prog);
|
||||
printf("\t-c cell_id [Default check for all]\n");
|
||||
printf("\t-o offset [Default %d]\n", offset);
|
||||
}
|
||||
|
||||
void parse_args(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "co")) != -1) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
cell_id = atoi(argv[optind]);
|
||||
break;
|
||||
case 'o':
|
||||
offset = atoi(argv[optind]);
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int N_id_2, ns, find_ns;
|
||||
cf_t *buffer, *fft_buffer;
|
||||
cf_t pss_signal[PSS_LEN];
|
||||
float sss_signal0[SSS_LEN]; // for subframe 0
|
||||
float sss_signal5[SSS_LEN]; // for subframe 5
|
||||
int cid, max_cid, find_idx;
|
||||
sync_t sync;
|
||||
lte_fft_t ifft;
|
||||
|
||||
parse_args(argc, argv);
|
||||
|
||||
buffer = malloc(sizeof(cf_t) * FLEN);
|
||||
if (!buffer) {
|
||||
perror("malloc");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fft_buffer = malloc(sizeof(cf_t) * 2 * FLEN);
|
||||
if (!fft_buffer) {
|
||||
perror("malloc");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (lte_ifft_init(&ifft, CPNORM, 6)) {
|
||||
fprintf(stderr, "Error creating iFFT object\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (sync_init(&sync, FLEN)) {
|
||||
fprintf(stderr, "Error initiating PSS/SSS\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sync_set_threshold(&sync, 20);
|
||||
sync_force_N_id_2(&sync, -1);
|
||||
|
||||
if (cell_id == -1) {
|
||||
cid = 0;
|
||||
max_cid = 149;
|
||||
} else {
|
||||
cid = cell_id;
|
||||
max_cid = cell_id;
|
||||
}
|
||||
while(cid <= max_cid) {
|
||||
N_id_2 = cid%3;
|
||||
|
||||
/* Generate PSS/SSS signals */
|
||||
pss_generate(pss_signal, N_id_2);
|
||||
sss_generate(sss_signal0, sss_signal5, cid);
|
||||
|
||||
for (ns=0;ns<2;ns++) {
|
||||
memset(buffer, 0, sizeof(cf_t) * FLEN);
|
||||
pss_put_slot(pss_signal, buffer, 6, CPNORM);
|
||||
sss_put_slot(ns?sss_signal5:sss_signal0, buffer, 6, CPNORM);
|
||||
|
||||
/* Transform to OFDM symbols */
|
||||
memset(fft_buffer, 0, sizeof(cf_t) * 2 * FLEN);
|
||||
lte_ifft_run(&ifft, buffer, &fft_buffer[offset]);
|
||||
|
||||
find_idx = sync_run(&sync, fft_buffer);
|
||||
find_ns = sync_get_slot_id(&sync);
|
||||
printf("cell_id: %d find: %d, offset: %d, ns=%d find_ns=%d\n", cid, find_idx, offset,
|
||||
ns, find_ns);
|
||||
if (find_idx != offset + 960) {
|
||||
printf("offset != find_offset: %d != %d\n", find_idx, offset + 960);
|
||||
exit(-1);
|
||||
}
|
||||
if (ns*10 != find_ns) {
|
||||
printf("ns != find_ns\n", 10 * ns, find_ns);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
cid++;
|
||||
}
|
||||
|
||||
free(fft_buffer);
|
||||
free(buffer);
|
||||
|
||||
sync_free(&sync);
|
||||
lte_ifft_free(&ifft);
|
||||
|
||||
fftwf_cleanup();
|
||||
|
||||
printf("Ok\n");
|
||||
exit(0);
|
||||
}
|
Loading…
Reference in New Issue