GNU Radio C++ API Reference: fsm.h Source File

| GNU Radio C++ API Reference 3.10.12.0 The Free & Open Software Radio Ecosystem |

Loading...
Searching...
No Matches
fsm.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2002,2011-2012 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11#ifndef INCLUDED_TRELLIS_FSM_H
12#define INCLUDED_TRELLIS_FSM_H
13
14#include <gnuradio/trellis/api.h>
15#include <iosfwd>
16#include <string>
17#include <vector>
18
19namespace gr {
20namespace trellis {
21
22/*!
23 * \brief Finite State Machine Specification class.
24 * \ingroup trellis_coding_blk
25 *
26 * \details
27 * An instance of this class represents a finite state machine
28 * specification (FSMS) rather than the FSM itself. It particular
29 * the state of the FSM is not stored within an instance of this
30 * class.
31 */
32 class TRELLIS_API fsm
33{
34private:
35 // Input alphabet cardinality.
36 int d_I;
37
38 // Number of states.
39 int d_S;
40
41 // Output alphabet cardinality.
42 int d_O;
43
44 // NS means Next State.
45 // next_state = d_NS[current_state * d_I + input_symbol]
46 std::vector<int> d_NS;
47
48 // OS means Output Symbol.
49 // output_symbol = d_OS[current_state * d_I + input_symbol]
50 std::vector<int> d_OS;
51
52 // PS means Previous State.
53 std::vector<std::vector<int>> d_PS;
54
55 // PI means Previous Input Symbol.
56 // d_PS[current_state][k] and d_PI[current_state][k], is a pair of the form
57 // (previous_state, previous_input_symbol) that could have produced the
58 // current state.
59 std::vector<std::vector<int>> d_PI;
60
61 // TM means Termination matrix.
62 // d_TMl[s*d_S+es] is the shortest number of steps to get from state s to
63 // state es.
64 std::vector<int> d_TMl;
65
66 // d_TMi[s*d_S+es] is the input symbol required to set off on the shortest
67 // path from state s to es.
68 std::vector<int> d_TMi;
69 void generate_PS_PI();
70 void generate_TM();
71 bool find_es(int es);
72
73public:
74 /*!
75 * \brief Constructor to create an uninitialized FSMS.
76 */
77 fsm();
78
79 /*!
80 * \brief Constructor to copy an FSMS.
81 */
82 fsm(const fsm& FSM);
83
84 /*!
85 * \brief Constructor to to create an FSMS.
86 *
87 * \param I The number of possible input symbols.
88 * \param S The number of possible FSM states.
89 * \param O The number of possible output symbols.
90 * \param NS A mapping from (current state, input symbol) to next state.
91 * next_state = NS[current_state * I + input_symbol]
92 * \param OS A mapping from (current state, input symbol) to output symbol.
93 * output_symbol = OS[current_state * I + input_symbol]
94 *
95 */
96 fsm(int I, int S, int O, const std::vector<int>& NS, const std::vector<int>& OS);
97
98 /*!
99 * \brief Constructor to create an FSMS from file contents.
100 *
101 * \param name filename
102 *
103 */
104 fsm(const char* name);
105
106 /*!
107 * \brief Creates an FSMS from the generator matrix of a (n, k) binary convolutional
108 * code.
109 *
110 * \param k ???
111 * \param n ???
112 * \param G ???
113 *
114 */
115 fsm(int k, int n, const std::vector<int>& G);
116
117 /*!
118 * \brief Creates an FSMS describing ISI.
119 *
120 * \param mod_size modulation size
121 * \param ch_length channel length
122 *
123 */
124 fsm(int mod_size, int ch_length);
125
126 /*!
127 * \brief Creates an FSMS describing the trellis for a CPM.
128 *
129 * \param P ???? h=K/P (relatively prime)
130 * \param M alphabet size
131 * \param L pulse duration
132 *
133 * This FSM is based on the paper by B. Rimoldi
134 * "A decomposition approach to CPM", IEEE Trans. Info Theory, March 1988
135 * See also my own notes at http://www.eecs.umich.edu/~anastas/docs/cpm.pdf
136 */
137 fsm(int P, int M, int L);
138
139 /*!
140 * \brief Creates an FSMS describing the joint trellis of two FSMs.
141 *
142 * \param FSM1 first FSMS
143 * \param FSM2 second FSMS
144 */
145 fsm(const fsm& FSM1, const fsm& FSM2);
146
147
148 /*!
149 * \brief Creates an FSMS describing the trellis of two serially concatenated FSMs.
150 *
151 * \param FSMo outer FSMS
152 * \param FSMi inner FSMS
153 * \param serial set it to true to distinguish from the previous constructor
154 */
155 fsm(const fsm& FSMo, const fsm& FSMi, bool serial);
156
157 /*!
158 * \brief Creates an FSMS representing n stages through the original FSM (AKA radix-n
159 * FSM).
160 *
161 * \param FSM Original FSMs
162 * \param n Number of stages.
163 */
164 fsm(const fsm& FSM, int n);
165 int I() const { return d_I; }
166 int S() const { return d_S; }
167 int O() const { return d_O; }
168 const std::vector<int>& NS() const { return d_NS; }
169 const std::vector<int>& OS() const { return d_OS; }
170 const std::vector<std::vector<int>>& PS() const { return d_PS; }
171 const std::vector<std::vector<int>>& PI() const { return d_PI; }
172 const std::vector<int>& TMi() const { return d_TMi; }
173 const std::vector<int>& TMl() const { return d_TMl; }
174
175 /*!
176 * \brief Creates an svg image of the trellis representation.
177 *
178 * \param filename filename
179 * \param number_stages ????
180 */
181 void write_trellis_svg(std::string filename, int number_stages);
182
183 /*!
184 * \brief Write the FSMS to a file.
185 *
186 * \param filename filename
187 */
188 void write_fsm_txt(std::string filename);
189};
190
191} /* namespace trellis */
192} /* namespace gr */
193
194#endif /* INCLUDED_TRELLIS_FSM_H */
gr::trellis::fsm::TMi
const std::vector< int > & TMi() const
Definition fsm.h:172
gr::trellis::fsm::write_fsm_txt
void write_fsm_txt(std::string filename)
Write the FSMS to a file.
gr::trellis::fsm::write_trellis_svg
void write_trellis_svg(std::string filename, int number_stages)
Creates an svg image of the trellis representation.
gr::trellis::fsm::TMl
const std::vector< int > & TMl() const
Definition fsm.h:173
gr::trellis::fsm::fsm
fsm(const fsm &FSM, int n)
Creates an FSMS representing n stages through the original FSM (AKA radix-n FSM).
gr::trellis::fsm::fsm
fsm(const fsm &FSMo, const fsm &FSMi, bool serial)
Creates an FSMS describing the trellis of two serially concatenated FSMs.
gr::trellis::fsm::PI
const std::vector< std::vector< int > > & PI() const
Definition fsm.h:171
gr::trellis::fsm::fsm
fsm(int P, int M, int L)
Creates an FSMS describing the trellis for a CPM.
gr::trellis::fsm::fsm
fsm()
Constructor to create an uninitialized FSMS.
gr::trellis::fsm::PS
const std::vector< std::vector< int > > & PS() const
Definition fsm.h:170
gr::trellis::fsm::fsm
fsm(const fsm &FSM1, const fsm &FSM2)
Creates an FSMS describing the joint trellis of two FSMs.
gr::trellis::fsm::OS
const std::vector< int > & OS() const
Definition fsm.h:169
gr::trellis::fsm::I
int I() const
Definition fsm.h:165
gr::trellis::fsm::O
int O() const
Definition fsm.h:167
gr::trellis::fsm::S
int S() const
Definition fsm.h:166
gr::trellis::fsm::fsm
fsm(int k, int n, const std::vector< int > &G)
Creates an FSMS from the generator matrix of a (n, k) binary convolutional code.
gr::trellis::fsm::fsm
fsm(const fsm &FSM)
Constructor to copy an FSMS.
gr::trellis::fsm::fsm
fsm(int mod_size, int ch_length)
Creates an FSMS describing ISI.
gr::trellis::fsm::fsm
fsm(const char *name)
Constructor to create an FSMS from file contents.
gr::trellis::fsm::NS
const std::vector< int > & NS() const
Definition fsm.h:168
gr::trellis::fsm::fsm
fsm(int I, int S, int O, const std::vector< int > &NS, const std::vector< int > &OS)
Constructor to to create an FSMS.
api.h
TRELLIS_API
#define TRELLIS_API
Definition gr-trellis/include/gnuradio/trellis/api.h:18
gr::trellis
Definition base.h:17
gr
GNU Radio logging wrapper.
Definition basic_block.h:29