SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
leansdr::trellis< TS, NSTATES, TUS, NUS, NCS > Struct Template Reference

#include <viterbi.h>

+ Collaboration diagram for leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >:

Classes

struct  state
 

Public Member Functions

 trellis ()
 
void init_convolutional (const uint16_t G[])
 
void dump ()
 

Public Attributes

struct leansdr::trellis::state states [NSTATES]
 

Static Public Attributes

static const int NOSTATE = NSTATES + 1
 

Detailed Description

template<typename TS, int NSTATES, typename TUS, int NUS, int NCS>
struct leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >

Definition at line 44 of file viterbi.h.

Constructor & Destructor Documentation

◆ trellis()

template<typename TS, int NSTATES, typename TUS, int NUS, int NCS>
leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::trellis ( )
inline

Definition at line 57 of file viterbi.h.

References leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::state::branches, leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::state::branch::pred, and leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::states.

58  {
59  for (TS s = 0; s < NSTATES; ++s)
60  for (int cs = 0; cs < NCS; ++cs)
61  states[s].branches[cs].pred = NOSTATE;
62  }
static const int NOSTATE
Definition: viterbi.h:46
struct leansdr::trellis::state states[NSTATES]

Member Function Documentation

◆ dump()

template<typename TS, int NSTATES, typename TUS, int NUS, int NCS>
void leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::dump ( )
inline

Definition at line 102 of file viterbi.h.

References leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::state::branches, leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::state::branch::pred, leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::states, and leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::state::branch::us.

103  {
104  for (int s = 0; s < NSTATES; ++s)
105  {
106  fprintf(stderr, "State %02x:", s);
107  for (int cs = 0; cs < NCS; ++cs)
108  {
109  typename state::branch *b = &states[s].branches[cs];
110  if (b->pred == NOSTATE)
111  fprintf(stderr, " - ");
112  else
113  fprintf(stderr, " %02x+%x", b->pred, b->us);
114  }
115  fprintf(stderr, "\n");
116  }
117  }
static const int NOSTATE
Definition: viterbi.h:46
struct leansdr::trellis::state::branch branches[NCS]
struct leansdr::trellis::state states[NSTATES]

◆ init_convolutional()

template<typename TS, int NSTATES, typename TUS, int NUS, int NCS>
void leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::init_convolutional ( const uint16_t  G[])
inline

Definition at line 65 of file viterbi.h.

References leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::state::branches, leansdr::log2i(), leansdr::parity(), leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::state::branch::pred, leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::states, and leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::state::branch::us.

Referenced by leansdr::viterbi_sync::viterbi_sync().

66  {
67  if (NCS & (NCS - 1))
68  {
69  fprintf(stderr, "NCS must be a power of 2\n");
70  }
71  // Derive number of polynomials from NCS.
72  int nG = log2i(NCS);
73 
74  for (TS s = 0; s < NSTATES; ++s)
75  {
76  for (TUS us = 0; us < NUS; ++us)
77  {
78  // Run the convolutional encoder from state s with input us
79  uint64_t shiftreg = s; // TBD type
80  // Reverse bits
81  TUS us_rev = 0;
82  for (int b = 1; b < NUS; b *= 2)
83  if (us & b)
84  us_rev |= (NUS / 2 / b);
85  shiftreg |= us_rev * NSTATES;
86  uint32_t cs = 0; // TBD type
87  for (int g = 0; g < nG; ++g)
88  cs = (cs << 1) | parity(shiftreg & G[g]);
89  shiftreg /= NUS; // Shift bits for 1 uncoded symbol
90  // [us] at state [s] emits [cs] and leads to state [shiftreg].
91  typename state::branch *b = &states[shiftreg].branches[cs];
92  if (b->pred != NOSTATE)
93  {
94  fprintf(stderr, "Invalid convolutional code\n");
95  }
96  b->pred = s;
97  b->us = us;
98  }
99  }
100  }
static const int NOSTATE
Definition: viterbi.h:46
int log2i(uint64_t x)
Definition: math.cpp:48
struct leansdr::trellis::state::branch branches[NCS]
unsigned int uint32_t
Definition: rtptypes_win.h:46
struct leansdr::trellis::state states[NSTATES]
unsigned char parity(uint8_t x)
Definition: math.cpp:27
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ NOSTATE

template<typename TS, int NSTATES, typename TUS, int NUS, int NCS>
const int leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::NOSTATE = NSTATES + 1
static

◆ states

template<typename TS, int NSTATES, typename TUS, int NUS, int NCS>
struct leansdr::trellis::state leansdr::trellis< TS, NSTATES, TUS, NUS, NCS >::states[NSTATES]

The documentation for this struct was generated from the following file: