/** * * \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 #include #include #include #include #include #include #include #include #include "lte.h" #include "turbocoder_test.h" typedef _Complex float cf_t; int frame_length = 1000, nof_frames=100; float ebno_db = 100.0; unsigned int seed = 0; int K = -1; #define MAX_ITERATIONS 4 int nof_iterations = MAX_ITERATIONS; int test_known_data = 0; int test_errors = 0; #define SNR_POINTS 8 #define SNR_MIN 0.0 #define SNR_MAX 4.0 void usage(char *prog) { printf("Usage: %s [nlesv]\n", prog); printf("\t-k Test with known data (ignores frame_length) [Default disabled]\n"); printf("\t-i nof_iterations [Default %d]\n", nof_iterations); printf("\t-n nof_frames [Default %d]\n", nof_frames); printf("\t-l frame_length [Default %d]\n", frame_length); printf("\t-e ebno in dB [Default scan]\n"); printf("\t-t test: check errors on exit [Default disabled]\n"); printf("\t-s seed [Default 0=time]\n"); } void parse_args(int argc, char **argv) { int opt; while ((opt = getopt(argc, argv, "inlstvekt")) != -1) { switch (opt) { case 'n': nof_frames = atoi(argv[optind]); break; case 'k': test_known_data = 1; break; case 't': test_errors = 1; break; case 'i': nof_iterations = atoi(argv[optind]); break; case 'l': frame_length = atoi(argv[optind]); break; case 'e': ebno_db = atof(argv[optind]); break; case 's': seed = (unsigned int) strtoul(argv[optind], NULL, 0); break; case 'v': verbose++; break; default: usage(argv[0]); exit(-1); } } } void output_matlab(float ber[MAX_ITERATIONS][SNR_POINTS], int snr_points) { int i, j; FILE *f = fopen("turbocoder_snr.m", "w"); if (!f) { perror("fopen"); exit(-1); } fprintf(f, "ber=["); for (j=0;j known_data_errors[j]) { fprintf(stderr, "Expected %d errors but got %d\n", known_data_errors[j], errors[j]); exit(-1); }else { printf("Iter %d ok\n", j+1); } } } else { for (j=0;j get_expected_errors(frame_cnt, seed, j+1, frame_length, ebno_db)) { fprintf(stderr, "Expected %d errors but got %d\n", get_expected_errors(frame_cnt, seed, j+1, frame_length, ebno_db), errors[j]); exit(-1); } else { printf("Iter %d ok\n", j+1); } } } } } } free(data_tx); free(symbols); free(llr); free(llr_c); free(data_rx); tdec_free(&tdec); tcod_free(&tcod); printf("\n"); output_matlab(ber, snr_points); printf("Done\n"); exit(0); }