diff options
Diffstat (limited to 'gr-fec/lib/puncture_bb_impl.cc')
-rw-r--r-- | gr-fec/lib/puncture_bb_impl.cc | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/gr-fec/lib/puncture_bb_impl.cc b/gr-fec/lib/puncture_bb_impl.cc index 2fedc7746c..63633b2748 100644 --- a/gr-fec/lib/puncture_bb_impl.cc +++ b/gr-fec/lib/puncture_bb_impl.cc @@ -26,6 +26,7 @@ #include "puncture_bb_impl.h" #include <gnuradio/io_signature.h> +#include <volk/volk.h> #include <boost/bind.hpp> #include <pmt/pmt.h> #include <string> @@ -35,25 +36,39 @@ namespace gr { namespace fec { puncture_bb::sptr - puncture_bb::make(int delay, int puncpat, - int puncholes, int puncsize) + puncture_bb::make(int puncsize, int puncpat, int delay) { return gnuradio::get_initial_sptr - (new puncture_bb_impl(delay, puncpat, - puncholes, puncsize)); + (new puncture_bb_impl(puncsize, puncpat, delay)); } - puncture_bb_impl::puncture_bb_impl(int delay, int puncpat, - int puncholes, int puncsize) + puncture_bb_impl::puncture_bb_impl(int puncsize, int puncpat, int delay) : block("puncture_bb", io_signature::make(1, 1, sizeof(char)), io_signature::make(1, 1, sizeof(char))), - d_delay(delay), d_puncholes(puncholes), d_puncsize(puncsize) + d_puncsize(puncsize), d_delay(delay) { + // Create a mask of all 1's of puncsize length + int mask = 0; + for(int i = 0; i < d_puncsize; i++) + mask |= 1 << i; + + // Rotate the pattern for the delay value; then mask it if there + // are any excess 1's in the pattern. for(int i = 0; i < d_delay; ++i) { puncpat = ((puncpat & 1) << (d_puncsize - 1)) + (puncpat >> 1); } - d_puncpat = puncpat; + d_puncpat = puncpat & mask; + + // Calculate the number of holes in the pattern. The mask is all + // 1's given puncsize and puncpat is a pattern with >= puncsize + // 0's (masked to ensure this). The difference between the + // number of 1's in the mask and the puncpat is the number of + // holes. + uint32_t count_mask=0, count_pat=0; + volk_32u_popcnt(&count_mask, static_cast<uint32_t>(mask)); + volk_32u_popcnt(&count_pat, static_cast<uint32_t>(d_puncpat)); + d_puncholes = count_mask - count_pat; set_fixed_rate(true); set_relative_rate((double)(d_puncsize - d_puncholes)/d_puncsize); @@ -112,14 +127,15 @@ namespace gr { } } + /* GR_LOG_DEBUG(d_debug_logger, ">>>>>> start"); for(int i = 0, k=0; i < noutput_items; ++i) { if((d_puncpat >> (d_puncsize - 1 - (i % d_puncsize))) & 1) { - GR_LOG_DEBUG(d_debug_logger, boost::format("%1%...%2%") \ + GR_LOG_DEBUG(d_debug_logger, boost::format("%1%...%2%") \ % out[k++] % in[i]); } else { - GR_LOG_DEBUG(d_debug_logger, boost::format("snit %1%") % in[i]); + GR_LOG_DEBUG(d_debug_logger, boost::format("snit %1%") % in[i]); } } @@ -127,6 +143,7 @@ namespace gr { % noutput_items % ninput_items[0]); GR_LOG_DEBUG(d_debug_logger, boost::format("consuming %1%") \ % ((int)(((1.0/relative_rate()) * noutput_items) + .5))); + */ consume_each((int)(((1.0/relative_rate()) * noutput_items) + .5)); return noutput_items; @@ -134,4 +151,3 @@ namespace gr { } /* namespace fec */ }/* namespace gr */ - |