diff options
Diffstat (limited to 'gr-fec/lib')
-rw-r--r-- | gr-fec/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-fec/lib/ber_bf_impl.cc | 16 | ||||
-rw-r--r-- | gr-fec/lib/ber_tools.cc | 117 | ||||
-rw-r--r-- | gr-fec/lib/ber_tools.h | 73 |
4 files changed, 4 insertions, 203 deletions
diff --git a/gr-fec/lib/CMakeLists.txt b/gr-fec/lib/CMakeLists.txt index e261cb5dac..3712eb7485 100644 --- a/gr-fec/lib/CMakeLists.txt +++ b/gr-fec/lib/CMakeLists.txt @@ -66,7 +66,6 @@ list(APPEND gnuradio_fec_sources repetition_encoder_impl.cc decode_ccsds_27_fb_impl.cc encode_ccsds_27_bb_impl.cc - ber_tools.cc ber_bf_impl.cc conv_bit_corr_bb_impl.cc puncture_bb_impl.cc diff --git a/gr-fec/lib/ber_bf_impl.cc b/gr-fec/lib/ber_bf_impl.cc index d7282ea699..a7c38700d6 100644 --- a/gr-fec/lib/ber_bf_impl.cc +++ b/gr-fec/lib/ber_bf_impl.cc @@ -25,7 +25,6 @@ #endif #include "ber_bf_impl.h" -#include "ber_tools.h" #include <gnuradio/io_signature.h> #include <volk/volk.h> #include <math.h> @@ -79,18 +78,11 @@ namespace gr { int items = ninput_items[0] <= ninput_items[1] ? ninput_items[0] : ninput_items[1]; if(items > 0) { - /* - for(int i = 0; i < items; ++i) { - if(inbuffer0[i] != inbuffer1[i]) { - GR_LOG_INFO(d_logger, boost::format("%1%/%2%: %3% versus %4%") \ - % i % items % inbuffer0[i] % inbuffer1[i]); - } + uint32_t ret; + for(int i = 0; i < items; i++) { + volk_32u_popcnt(&ret, static_cast<uint32_t>(inbuffer0[i]^inbuffer1[i])); + d_total_errors += ret; } - GR_LOG_INFO(d_logger, boost::format("%1% errors") \ - % (compber(inbuffer0, inbuffer1, items))); - */ - - d_total_errors += compber(inbuffer0, inbuffer1, items); d_total += items; } consume_each(items); diff --git a/gr-fec/lib/ber_tools.cc b/gr-fec/lib/ber_tools.cc deleted file mode 100644 index 043fbef216..0000000000 --- a/gr-fec/lib/ber_tools.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013-2014 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <cstdlib> -#ifdef _MSC_VER -#define _USE_MATH_DEFINES -#include <cmath> -#endif - -#include "ber_tools.h" - -inline int -putbit(int word, int loc, int bit) -{ - return (((word)&(~((1)<<(loc))))^((bit)<<(loc))); -} - -void -gaussnoise(float *inbuffer, int buffsize, float sigma) -{ - int i; - float udrn1=0.0, udrn2=0.0, noise=0.0; - - for(i = 0; i < buffsize;i++) { - #ifdef _MSC_VER - while((udrn1 = (float)(std::rand())) < 0.0000001); - udrn2 = (float)(std::rand()); - #else - while((udrn1 = (float)drand48()) < 0.0000001); - udrn2 = (float)drand48(); - #endif - noise = sigma*sqrt(-2*log(udrn1))*cos(2*M_PI*udrn2); - inbuffer[i] += noise; - } -} - - -int -compber(unsigned char *inbuffer1, unsigned char *inbuffer2, int buffsize) -{ - int i, totaldiff=0; - int popcnt[256] = - { - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 - }; - - for(i = 0; i < buffsize; i++) { - totaldiff += popcnt[inbuffer1[i]^inbuffer2[i]]; - } - - return totaldiff; -} - -void randbuffer(unsigned char *databuffer,int buffsize, int charout) -{ - int i; - unsigned char randbit; - - for(i = 0; i < buffsize; i++) { - // generate random element - randbit = (unsigned char)((0x000010000&rand())>>16); - // place in the data buffer - if(charout == 0) - databuffer[i>>3] = putbit(databuffer[i>>3],7-(i&0x7),randbit); - else - databuffer[i] = randbit; - } -} - -void -char2bin(unsigned char *inbuffer,int buffSize) -{ - int i; - unsigned char fbit=0; - - for(i = 0; i < buffSize; i++) { - if(inbuffer[i] == 0) - fbit = 0; - else - fbit = 1; - inbuffer[i>>3] = putbit(inbuffer[i>>3],7-(i&0x7),fbit); - } -} diff --git a/gr-fec/lib/ber_tools.h b/gr-fec/lib/ber_tools.h deleted file mode 100644 index 038b362974..0000000000 --- a/gr-fec/lib/ber_tools.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013-2014 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GNURADIO_FEC_BER_TOOLS_H -#define INCLUDED_GNURADIO_FEC_BER_TOOLS_H - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#define BERMINFRAMES (10000) -#define BERMINERRORS (100) -#define BERMAXBITS (1000000000) - -/*! - * Add BPSK gaussian noise with standard deviation equal to sigma to a - * floating point input buffer. - * - * \param inbuffer (float*) buffer containing data to receive additive - * gaussian noise - * \param buffsize (int) size of \p inbuffer - * \param sigma (float) noise power of the guassian random variables - */ -void gaussnoise(float *inbuffer, int buffsize, float sigma); - -/*! - * Compute the number of bit differences between input buffers - * - * \param inbuffer1 input stream 1 to compare against \p inbuffer2 - * \param inbuffer2 input stream 2 to be compared against - * \param buffsize number of elements in each buffer - */ -int compber(unsigned char *inbuffer1, unsigned char *inbuffer2, int buffsize); - -/*! - * Generate a random buffer of data - * - * \param databuffer pointer to buffer containing random data - * \param buffsize number of elements in each buffer - */ -void randbuffer(unsigned char *databuffer, int buffsize, int charout); - -/*! - * Pack the character buffer - * - * \param databuffer pointer to buffer containing unpacked chars - * \param buffsize number of elements in each buffer - */ -void char2bin(unsigned char *inbuffer, int buffsize); - -#endif /* INCLUDED_GNURADIO_FEC_BER_TOOLS_H */ - - |