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.
Public Types | Public Member Functions | Private Attributes | List of all members
leansdr::deconvol_poly2< Tin, Thist, Tpoly, POLY_DECONVOL, POLY_ERRORS > Struct Template Reference

#include <convolutional.h>

Public Types

typedef u8 hardsymbol
 
typedef u8 decoded_byte
 

Public Member Functions

u8 SYMVAL (const hardsymbol *s)
 
u8 SYMVAL (const softsymbol *s)
 
 deconvol_poly2 ()
 
int run (const Tin *pin, const u8 remap[], decoded_byte *pout, int nb)
 

Private Attributes

Thist inI
 
Thist inQ
 

Detailed Description

template<typename Tin, typename Thist, typename Tpoly, Tpoly POLY_DECONVOL, Tpoly POLY_ERRORS>
struct leansdr::deconvol_poly2< Tin, Thist, Tpoly, POLY_DECONVOL, POLY_ERRORS >

Definition at line 90 of file convolutional.h.

Member Typedef Documentation

◆ decoded_byte

template<typename Tin, typename Thist, typename Tpoly, Tpoly POLY_DECONVOL, Tpoly POLY_ERRORS>
typedef u8 leansdr::deconvol_poly2< Tin, Thist, Tpoly, POLY_DECONVOL, POLY_ERRORS >::decoded_byte

Definition at line 98 of file convolutional.h.

◆ hardsymbol

template<typename Tin, typename Thist, typename Tpoly, Tpoly POLY_DECONVOL, Tpoly POLY_ERRORS>
typedef u8 leansdr::deconvol_poly2< Tin, Thist, Tpoly, POLY_DECONVOL, POLY_ERRORS >::hardsymbol

Definition at line 92 of file convolutional.h.

Constructor & Destructor Documentation

◆ deconvol_poly2()

template<typename Tin, typename Thist, typename Tpoly, Tpoly POLY_DECONVOL, Tpoly POLY_ERRORS>
leansdr::deconvol_poly2< Tin, Thist, Tpoly, POLY_DECONVOL, POLY_ERRORS >::deconvol_poly2 ( )
inline

Definition at line 100 of file convolutional.h.

Member Function Documentation

◆ run()

template<typename Tin, typename Thist, typename Tpoly, Tpoly POLY_DECONVOL, Tpoly POLY_ERRORS>
int leansdr::deconvol_poly2< Tin, Thist, Tpoly, POLY_DECONVOL, POLY_ERRORS >::run ( const Tin *  pin,
const u8  remap[],
decoded_byte pout,
int  nb 
)
inline

Definition at line 105 of file convolutional.h.

106  {
107  if (nb & (sizeof(Thist) - 1)) {
108  fail("Must deconvolve sizeof(Thist) bytes at a time");
109  }
110 
111  nb /= sizeof(Thist);
112  unsigned long nerrors = 0;
113  int halfway = nb / 2;
114  Thist histI = inI, histQ = inQ;
115 
116  for (; nb--;)
117  {
118  // This is where we convolve bits in parallel.
119  Thist wd = 0; // decoded bits
120  Thist we = 0; // error bits (should be 0)
121 #if 0
122  // Trust gcc to unroll and evaluate the bit tests at compile-time.
123  for ( int bit=sizeof(Thist)*8; bit--; ++pin ) {
124  u8 iq = remap[SYMVAL(pin)];
125  histI = (histI<<1) | (iq>>1);
126  histQ = (histQ<<1) | (iq&1);
127  if ( POLY_DECONVOL & ((Tpoly)2<<(2*bit)) ) wd ^= histI;
128  if ( POLY_DECONVOL & ((Tpoly)1<<(2*bit)) ) wd ^= histQ;
129  if ( POLY_ERRORS & ((Tpoly)2<<(2*bit)) ) we ^= histI;
130  if ( POLY_ERRORS & ((Tpoly)1<<(2*bit)) ) we ^= histQ;
131  }
132 #else
133  // Unroll manually.
134 #define LOOP(bit) \
135  { \
136  u8 iq = remap[SYMVAL(pin)]; \
137  histI = (histI << 1) | (iq >> 1); \
138  histQ = (histQ << 1) | (iq & 1); \
139  if (POLY_DECONVOL & ((Tpoly)2 << (2 * bit))) \
140  wd ^= histI; \
141  if (POLY_DECONVOL & ((Tpoly)1 << (2 * bit))) \
142  wd ^= histQ; \
143  if (POLY_ERRORS & ((Tpoly)2 << (2 * bit))) \
144  we ^= histI; \
145  if (POLY_ERRORS & ((Tpoly)1 << (2 * bit))) \
146  we ^= histQ; \
147  ++pin; \
148  }
149  // Don't shift by more than the operand width
150  switch (sizeof(Thist) * 8)
151  {
152 #if 0 // Not needed yet - avoid compiler warnings
153  case 64:
154  LOOP(63); LOOP(62); LOOP(61); LOOP(60);
155  LOOP(59); LOOP(58); LOOP(57); LOOP(56);
156  LOOP(55); LOOP(54); LOOP(53); LOOP(52);
157  LOOP(51); LOOP(50); LOOP(49); LOOP(48);
158  LOOP(47); LOOP(46); LOOP(45); LOOP(44);
159  LOOP(43); LOOP(42); LOOP(41); LOOP(40);
160  LOOP(39); LOOP(38); LOOP(37); LOOP(36);
161  LOOP(35); LOOP(34); LOOP(33); LOOP(32);
162  // Fall-through
163 #endif
164  case 32:
165  LOOP(31);
166  LOOP(30);
167  LOOP(29);
168  LOOP(28);
169  LOOP(27);
170  LOOP(26);
171  LOOP(25);
172  LOOP(24);
173  LOOP(23);
174  LOOP(22);
175  LOOP(21);
176  LOOP(20);
177  LOOP(19);
178  LOOP(18);
179  LOOP(17);
180  LOOP(16);
181  // Fall-through
182  case 16:
183  LOOP(15);
184  LOOP(14);
185  LOOP(13);
186  LOOP(12);
187  LOOP(11);
188  LOOP(10);
189  LOOP(9);
190  LOOP(8);
191  // Fall-through
192  case 8:
193  LOOP(7);
194  LOOP(6);
195  LOOP(5);
196  LOOP(4);
197  LOOP(3);
198  LOOP(2);
199  LOOP(1);
200  LOOP(0);
201  break;
202  default:
203  fail("Thist not supported");
204  }
205 #undef LOOP
206 #endif
207  switch (sizeof(Thist) * 8)
208  {
209 #if 0 // Not needed yet - avoid compiler warnings
210  case 64:
211  *pout++ = wd >> 56;
212  *pout++ = wd >> 48;
213  *pout++ = wd >> 40;
214  *pout++ = wd >> 32;
215  // Fall-through
216 #endif
217  case 32:
218  *pout++ = wd >> 24;
219  *pout++ = wd >> 16;
220  // Fall-through
221  case 16:
222  *pout++ = wd >> 8;
223  // Fall-through
224  case 8:
225  *pout++ = wd;
226  break;
227  default:
228  fail("Thist not supported");
229  }
230  // Count errors when the shift registers are full
231  if (nb < halfway)
232  nerrors += hamming_weight(we);
233  }
234 
235  inI = histI;
236  inQ = histQ;
237  return nerrors;
238  }
u8 SYMVAL(const hardsymbol *s)
Definition: convolutional.h:95
unsigned char u8
Definition: framework.h:453
int hamming_weight(uint8_t x)
Definition: math.cpp:6
void fail(const char *s)
Definition: framework.cpp:11
#define LOOP(bit)

◆ SYMVAL() [1/2]

template<typename Tin, typename Thist, typename Tpoly, Tpoly POLY_DECONVOL, Tpoly POLY_ERRORS>
u8 leansdr::deconvol_poly2< Tin, Thist, Tpoly, POLY_DECONVOL, POLY_ERRORS >::SYMVAL ( const hardsymbol s)
inline

Definition at line 95 of file convolutional.h.

95 { return *s; }

◆ SYMVAL() [2/2]

template<typename Tin, typename Thist, typename Tpoly, Tpoly POLY_DECONVOL, Tpoly POLY_ERRORS>
u8 leansdr::deconvol_poly2< Tin, Thist, Tpoly, POLY_DECONVOL, POLY_ERRORS >::SYMVAL ( const softsymbol s)
inline

Definition at line 96 of file convolutional.h.

96 { return s->symbol; }

Member Data Documentation

◆ inI

template<typename Tin, typename Thist, typename Tpoly, Tpoly POLY_DECONVOL, Tpoly POLY_ERRORS>
Thist leansdr::deconvol_poly2< Tin, Thist, Tpoly, POLY_DECONVOL, POLY_ERRORS >::inI
private

Definition at line 241 of file convolutional.h.

◆ inQ

template<typename Tin, typename Thist, typename Tpoly, Tpoly POLY_DECONVOL, Tpoly POLY_ERRORS>
Thist leansdr::deconvol_poly2< Tin, Thist, Tpoly, POLY_DECONVOL, POLY_ERRORS >::inQ
private

Definition at line 241 of file convolutional.h.


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