GNU Radio's DVBS2RX Package
reed_muller.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright (c) 2019-2021 Igor Freire.
4 *
5 * This file is part of gr-dvbs2rx.
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 */
9
10#ifndef INCLUDED_DVBS2RX_REED_MULLER_H
11#define INCLUDED_DVBS2RX_REED_MULLER_H
12
13#include "pl_defs.h"
15#include <volk/volk_alloc.hh>
16
17namespace gr {
18namespace dvbs2rx {
19
20// Pointer to an Euclidean-space mapping function:
21typedef void (*euclidean_map_func_ptr)(float* dptr, uint64_t codeword);
22
23/**
24 * @brief Interleaved (64, 7, 32) Reed-Muller encoder/decoder.
25 *
26 * This class implements DVB-S2's Reed-Muller (RM) code used by the physical
27 * layer signaling (PLS) encoding.
28 */
30{
31private:
32 // Vector with all possible codeword indexes. When the constructor does not specify
33 // the enabled codewords, this vector holds the sequence from 0 to 127. Otherwise,
34 // when it's known a priori that only a subset of the codewords can be present in the
35 // incoming signal, this vector can be reduced to a subset of the codewords.
36 std::vector<uint8_t> d_enabled_codewords;
37 // LUT with all the 64-bit codewords:
38 uint64_t d_codeword_lut[n_plsc_codewords];
39 // LUT with the Euclidean-space image of the codewords (real vectors):
40 volk::vector<float> d_euclidean_img_lut;
41 // Buffer used by the maximum inner product soft decoder:
42 volk::vector<float> d_dot_prod_buf;
43
44 /**
45 * @brief Initialize the codeword and Euclidean-space image LUTs
46 *
47 * @param p_custom_map Custom Euclidean space mapping function defined on the
48 * constructor.
49 */
50 void init(euclidean_map_func_ptr p_custom_map = nullptr);
51
52public:
53 // Function used to map binary codewords into the corresponding real vector:
55
56 /**
57 * @brief Construct the Reed-Muller encoder/decoder.
58 * @param p_custom_map Pointer to a custom mapping function used to map the
59 * binary the codewords into real-valued Euclidean-space images. If
60 * not defined, method "default_euclidean_map" is used.
61 */
62 explicit reed_muller(euclidean_map_func_ptr p_custom_map = nullptr);
63
64 /**
65 * @brief Construct the Reed-Muller encoder/decoder for a codeword subset.
66 * @param enabled_codewords Temporary vector with the indexes within [0, 128)
67 * corresponding to subset of codewords that may appear (according to a priori
68 * knowledge) on the incoming signal.
69 * @param p_custom_map Pointer to a custom mapping function used to map the
70 * binary the codewords into real-valued Euclidean-space images. If
71 * not defined, method "default_euclidean_map" is used.
72 */
73 explicit reed_muller(std::vector<uint8_t>&& enabled_codewords,
74 euclidean_map_func_ptr p_custom_map = nullptr);
75
76 /**
77 * @brief Map codeword to a real vector using 2-PAM.
78 * @param dptr Destination pointer for the 64 real 2-PAM mapped symbols.
79 * @param codeword 64-bit (64, 7, 32) Reed-Muller codeword to be mapped.
80 * @note This is the default Euclidean-space mapping if another custom
81 * mapping is not provided through the constructor.
82 */
83 static void default_euclidean_map(float* dptr, uint64_t codeword);
84
85 /**
86 * @brief Encode a given dataword (PLSC) into the corresponding codeword.
87 * @param in_dataword 7-bit PLSC dataword.
88 * @return 64-bit interleaved (64, 7, 32) RM codeword.
89 */
90 uint64_t encode(uint8_t in_dataword);
91
92 /**
93 * @brief Decode a binary hard decision into the corresponding dataword.
94 * @param hard_dec Received 64-bit hard decision to be decoded.
95 * @return Decoded 7-bit dataword.
96 */
97 uint8_t decode(uint64_t hard_dec);
98
99 /**
100 * @brief Decode a real soft decision vector into the corresponding dataword.
101 * @param soft_dec Received 64-element soft decision real vector to be decoded.
102 * @return Decoded 7-bit dataword.
103 */
104 uint8_t decode(const float* soft_dec);
105};
106
107} // namespace dvbs2rx
108} // namespace gr
109
110#endif /* INCLUDED_DVBS2RX_REED_MULLER_H */
Interleaved (64, 7, 32) Reed-Muller encoder/decoder.
Definition reed_muller.h:30
reed_muller(std::vector< uint8_t > &&enabled_codewords, euclidean_map_func_ptr p_custom_map=nullptr)
Construct the Reed-Muller encoder/decoder for a codeword subset.
static void default_euclidean_map(float *dptr, uint64_t codeword)
Map codeword to a real vector using 2-PAM.
reed_muller(euclidean_map_func_ptr p_custom_map=nullptr)
Construct the Reed-Muller encoder/decoder.
uint8_t decode(const float *soft_dec)
Decode a real soft decision vector into the corresponding dataword.
uint64_t encode(uint8_t in_dataword)
Encode a given dataword (PLSC) into the corresponding codeword.
uint8_t decode(uint64_t hard_dec)
Decode a binary hard decision into the corresponding dataword.
euclidean_map_func_ptr euclidean_map
Definition reed_muller.h:54
#define DVBS2RX_API
Definition include/gnuradio/dvbs2rx/api.h:19
const unsigned int n_plsc_codewords
Definition pl_defs.h:40
void(* euclidean_map_func_ptr)(float *dptr, uint64_t codeword)
Definition reed_muller.h:21
Fixed-length double-ended queue with contiguous volk-aligned elements.
Definition gr_bch.h:22