summaryrefslogtreecommitdiff
path: root/gr-fec/include/gnuradio/fec/polar_decoder_sc.h
blob: 35f22dde5b6a4f40e527550c29c8a16308f21fff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* -*- c++ -*- */
/* 
 * Copyright 2015 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_FEC_POLAR_DECODER_SC_H
#define INCLUDED_FEC_POLAR_DECODER_SC_H

#include <gnuradio/fec/api.h>
#include <gnuradio/fec/polar_decoder_common.h>


namespace gr {
  namespace fec {

    /*!
     * \brief Standard successive cancellation (SC) decoder for POLAR codes
     * It expects float input with bits mapped 1 --> 1, 0 --> -1
     * Or: f = 2.0 * bit - 1.0
     *
     */
    class FEC_API polar_decoder_sc : public polar_decoder_common
    {
    public:
      static generic_decoder::sptr make(int block_size, int num_info_bits, std::vector<int> frozen_bit_positions, std::vector<char> frozen_bit_values);
      ~polar_decoder_sc();

      // FECAPI
      void generic_work(void *in_buffer, void *out_buffer);

    private:
      polar_decoder_sc(int block_size, int num_info_bits, std::vector<int> frozen_bit_positions, std::vector<char> frozen_bit_values);

      float* d_llr_vec;
      unsigned char* d_u_hat_vec;

      unsigned char retrieve_bit_from_llr(float llr, const int pos);
      void sc_decode(float* llrs, unsigned char* u);
    };

  } // namespace fec
} // namespace gr

#endif /* INCLUDED_FEC_POLAR_DECODER_SC_H */