GNU Radio's OWC Package
PAM_Modulator_cplus_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/* gr-owc OOT module for optical wireless communications.
3 * gr-owc is compatible with GNU Radio v3.10
4 *
5 * Copyright 2024 Kunal Sangurmath from Ubiquitous Communications and Networking (UCAN) Lab, University of Massachusetts, Boston.
6 *
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this software; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24#ifndef INCLUDED_OWC_PAM_MODULATOR_CPLUS_IMPL_H
25#define INCLUDED_OWC_PAM_MODULATOR_CPLUS_IMPL_H
26
28
29namespace gr {
30namespace owc {
31
33private:
34 int d_modulation_order;
35 float d_max_magnitude;
36 float d_min_magnitude;
37 int d_samples_per_symbol;
38
39 std::vector<int> d_symbol_array;
40 std::vector<float> d_level_array;
41
42 void set_symbol_array(int modulation_order){
43 int num_bits = floor(log2(modulation_order));
44 int max_symbol = pow(2,num_bits);
45
46 for (int i = 0; i < max_symbol; i++)
47 {
48 d_symbol_array.push_back(i);
49 }
50 }
51 std::vector<int> symbol_array() {return d_symbol_array;}
52
53 void set_level_array()
54 {
55 d_level_array.clear();
56
57 int num_bits = floor(log2(modulation_order()));
58 int max_symbol = pow(2,num_bits);
59 float range = max_magnitude() - min_magnitude();
60 float single_level_magnitude = range/(modulation_order()-1);
61
62 float levels = min_magnitude();
63
64 for (int i = 0; i < max_symbol; i++)
65 {
66 d_level_array.push_back(levels);
67 levels += single_level_magnitude;
68 }
69 }
70 std::vector<float> level_array() {return d_level_array;}
71
72public:
76
77 void set_modulation_order(int modulation_order) { d_modulation_order = modulation_order;}
78 int modulation_order() { return d_modulation_order; }
79
80 void set_max_magnitude(float max_magnitude) { d_max_magnitude = max_magnitude;}
81 float max_magnitude() { return d_max_magnitude; }
82
83 void set_min_magnitude(float min_magnitude) { d_min_magnitude = min_magnitude;}
84 float min_magnitude() { return d_min_magnitude; }
85
87 int samples_per_symbol() { return d_samples_per_symbol; }
88
89 // Where all the action really happens
90 int work(int noutput_items, gr_vector_const_void_star &input_items,
91 gr_vector_void_star &output_items);
92};
93
94} // namespace owc
95} // namespace gr
96
97#endif /* INCLUDED_OWC_PAM_MODULATOR_CPLUS_IMPL_H */
int samples_per_symbol()
Definition PAM_Modulator_cplus_impl.h:87
float max_magnitude()
Definition PAM_Modulator_cplus_impl.h:81
void set_samples_per_symbol(int samples_per_symbol)
Definition PAM_Modulator_cplus_impl.h:86
void set_max_magnitude(float max_magnitude)
Definition PAM_Modulator_cplus_impl.h:80
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
PAM_Modulator_cplus_impl(int modulation_order, float max_magnitude, float min_magnitude, int samples_per_symbol)
int modulation_order()
Definition PAM_Modulator_cplus_impl.h:78
void set_modulation_order(int modulation_order)
Definition PAM_Modulator_cplus_impl.h:77
void set_min_magnitude(float min_magnitude)
Definition PAM_Modulator_cplus_impl.h:83
float min_magnitude()
Definition PAM_Modulator_cplus_impl.h:84
<+description of block+>
Definition PAM_Modulator_cplus.h:38
Definition Hermitian_Symmetry_i_o_same_vec_size_cplus.h:31
Definition Hermitian_Symmetry_i_o_same_vec_size_cplus.h:30